/** * Twenty Twenty-Five functions and definitions. * * @link https://developer.wordpress.org/themes/basics/theme-functions/ * * @package WordPress * @subpackage Twenty_Twenty_Five * @since Twenty Twenty-Five 1.0 */ // Adds theme support for post formats. if ( ! function_exists( 'twentytwentyfive_post_format_setup' ) ) : /** * Adds theme support for post formats. * * @since Twenty Twenty-Five 1.0 * * @return void */function twentytwentyfive_post_format_setup() { add_theme_support( 'post-formats', array( 'aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video' ) ); } endif; add_action( 'after_setup_theme', 'twentytwentyfive_post_format_setup' ); // Enqueues editor-style.css in the editors. if ( ! function_exists( 'twentytwentyfive_editor_style' ) ) : /** * Enqueues editor-style.css in the editors. * * @since Twenty Twenty-Five 1.0 * * @return void */ function twentytwentyfive_editor_style() { add_editor_style( 'assets/css/editor-style.css' ); } endif; add_action( 'after_setup_theme', 'twentytwentyfive_editor_style' ); // Enqueues the theme stylesheet on the front. if ( ! function_exists( 'twentytwentyfive_enqueue_styles' ) ) : /** * Enqueues the theme stylesheet on the front. * * @since Twenty Twenty-Five 1.0 * * @return void */ function twentytwentyfive_enqueue_styles() { $suffix = SCRIPT_DEBUG ? '' : '.min'; $src = 'style' . $suffix . '.css'; wp_enqueue_style( 'twentytwentyfive-style', get_parent_theme_file_uri( $src ), array(), wp_get_theme()->get( 'Version' ) ); wp_style_add_data( 'twentytwentyfive-style', 'path', get_parent_theme_file_path( $src ) ); } endif; add_action( 'wp_enqueue_scripts', 'twentytwentyfive_enqueue_styles' ); // Registers custom block styles. if ( ! function_exists( 'twentytwentyfive_block_styles' ) ) : /** * Registers custom block styles. * * @since Twenty Twenty-Five 1.0 * * @return void */ function twentytwentyfive_block_styles() { register_block_style( 'core/list', array( 'name' => 'checkmark-list', 'label' => __( 'Checkmark', 'twentytwentyfive' ), 'inline_style' => ' ul.is-style-checkmark-list { list-style-type: "\2713"; } ul.is-style-checkmark-list li { padding-inline-start: 1ch; }', ) ); } endif; add_action( 'init', 'twentytwentyfive_block_styles' ); // Registers pattern categories. if ( ! function_exists( 'twentytwentyfive_pattern_categories' ) ) : /** * Registers pattern categories. * * @since Twenty Twenty-Five 1.0 * * @return void */ function twentytwentyfive_pattern_categories() { register_block_pattern_category( 'twentytwentyfive_page', array( 'label' => __( 'Pages', 'twentytwentyfive' ), 'description' => __( 'A collection of full page layouts.', 'twentytwentyfive' ), ) ); register_block_pattern_category( 'twentytwentyfive_post-format', array( 'label' => __( 'Post formats', 'twentytwentyfive' ), 'description' => __( 'A collection of post format patterns.', 'twentytwentyfive' ), ) ); } endif; add_action( 'init', 'twentytwentyfive_pattern_categories' ); // Registers block binding sources. if ( ! function_exists( 'twentytwentyfive_register_block_bindings' ) ) : /** * Registers the post format block binding source. * * @since Twenty Twenty-Five 1.0 * * @return void */ function twentytwentyfive_register_block_bindings() { register_block_bindings_source( 'twentytwentyfive/format', array( 'label' => _x( 'Post format name', 'Label for the block binding placeholder in the editor', 'twentytwentyfive' ), 'get_value_callback' => 'twentytwentyfive_format_binding', ) ); } endif; add_action( 'init', 'twentytwentyfive_register_block_bindings' ); // Registers block binding callback function for the post format name. if ( ! function_exists( 'twentytwentyfive_format_binding' ) ) : /** * Callback function for the post format name block binding source. * * @since Twenty Twenty-Five 1.0 * * @return string|void Post format name, or nothing if the format is 'standard'. */ function twentytwentyfive_format_binding() { $post_format_slug = get_post_format(); if ( $post_format_slug && 'standard' !== $post_format_slug ) { return get_post_format_string( $post_format_slug ); } } endif; // Этот код нужно добавить в functions.php вашей темы // Добавьте следующий код в файл functions.php: /* // РАСКОММЕНТИРУЙТЕ ЭТОТ КОД И ВСТАВЬТЕ В ФАЙЛ FUNCTIONS.PHP ВАШЕЙ ТЕМЫ: // Обработка AJAX запроса для создания поста add_action('wp_ajax_create_post_ajax', 'handle_create_post_ajax'); add_action('wp_ajax_nopriv_create_post_ajax', 'handle_create_post_ajax'); function handle_create_post_ajax() { // Проверка nonce if (!isset($_POST['post_nonce'])) { wp_send_json_error(['message' => 'Ошибка безопасности']); return; } // Проверка прав (только администраторы) if (!current_user_can('administrator')) { wp_send_json_error(['message' => 'У вас нет прав для создания публикаций']); return; } $title = sanitize_text_field($_POST['post_title']); $content = wp_kses_post($_POST['post_content']); $date = sanitize_text_field($_POST['post_date']); $tags = sanitize_text_field($_POST['post_tags']); $category = intval($_POST['post_category']); $status = sanitize_text_field($_POST['post_status']); if (empty($title)) { wp_send_json_error(['message' => 'Введите название публикации']); return; } if (empty($content)) { wp_send_json_error(['message' => 'Введите текст публикации']); return; } $post_data = [ 'post_title' => $title, 'post_content' => $content, 'post_status' => $status, 'post_type' => 'post', 'post_category' => [$category], 'tags_input' => $tags, 'post_date' => $date ]; $post_id = wp_insert_post($post_data); if ($post_id) { // Обработка файлов if (!empty($_FILES['post_attachments'])) { require_once(ABSPATH . 'wp-admin/includes/file.php'); require_once(ABSPATH . 'wp-admin/includes/media.php'); require_once(ABSPATH . 'wp-admin/includes/image.php'); $files = $_FILES['post_attachments']; $attachments = []; for ($i = 0; $i < count($files['name']); $i++) { if ($files['error'][$i] === 0) { $file = [ 'name' => $files['name'][$i], 'type' => $files['type'][$i], 'tmp_name' => $files['tmp_name'][$i], 'error' => $files['error'][$i], 'size' => $files['size'][$i] ]; $attachment_id = media_handle_sideload($file, $post_id); if (!is_wp_error($attachment_id)) { $attachments[] = $attachment_id; } } } if (!empty($attachments)) { update_post_meta($post_id, '_post_attachments', $attachments); } } wp_send_json_success([ 'message' => 'Публикация успешно создана!', 'post_id' => $post_id, 'post_url' => get_permalink($post_id) ]); } else { wp_send_json_error(['message' => 'Ошибка при создании публикации']); } } // Инициализация add_action('wp_ajax_init_post_creator', function() { wp_send_json_success(['message' => 'Ready']); }); */ ?> https://blog.doctordobra.com/wp-sitemap-posts-post-1.xmlhttps://blog.doctordobra.com/wp-sitemap-posts-page-1.xmlhttps://blog.doctordobra.com/wp-sitemap-taxonomies-category-1.xmlhttps://blog.doctordobra.com/wp-sitemap-users-1.xml