admin_url( 'admin-ajax.php' ) ) ); wp_localize_script( 'ai-content-wizard-settings-script', 'ai_content_wizard_settings', array( 'selectWatermarkImageTitle' => __( 'Select Watermark Image', 'ai-content-wizard' ), 'selectWatermarkButtonText' => __( 'Select Image', 'ai-content-wizard' ) ) ); // Подключаем стили вкладок и новый облик настроек wp_enqueue_style( 'ai-content-wizard-content-plan-style', AI_CONTENT_WIZARD_URL . 'css/content-plan-styles.css', array(), AI_CONTENT_WIZARD_VERSION ); $settings_lite_style = AI_CONTENT_WIZARD_PATH . 'css/settings-page-lite.css'; $settings_lite_version = AI_CONTENT_WIZARD_VERSION; if ( file_exists( $settings_lite_style ) ) { $settings_lite_version .= '-' . filemtime( $settings_lite_style ); } wp_enqueue_style( 'ai-content-wizard-settings-lite-style', AI_CONTENT_WIZARD_URL . 'css/settings-page-lite.css', array( 'ai-content-wizard-content-plan-style' ), $settings_lite_version ); } add_action( 'admin_enqueue_scripts', 'enqueue_settings_page_script' ); function ai_content_wizard_settings_page() { if ( ! current_user_can( 'manage_options' ) ) { return; } $latest_post = get_posts( array( 'numberposts' => 1 ) ); if ( ! empty( $latest_post ) ) { $latest_post = $latest_post[0]; } else { $latest_post = null; } if ( $latest_post ) { $latest_post_title = get_the_title( $latest_post ); $latest_post_date = get_the_date( get_option( 'date_format' ), $latest_post ); $latest_status = get_post_status( $latest_post ); $status_object = $latest_status ? get_post_status_object( $latest_status ) : null; $latest_post_status_label = $status_object ? $status_object->label : ( $latest_status ? ucfirst( $latest_status ) : __( 'Published', 'ai-content-wizard' ) ); } else { $latest_post_title = __( 'Ready to publish', 'ai-content-wizard' ); $latest_post_date = __( 'No posts yet', 'ai-content-wizard' ); $latest_post_status_label = __( 'Not available', 'ai-content-wizard' ); } $errors = array(); if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) { if ( ! isset( $_POST['ai_content_wizard_nonce'] ) || ! wp_verify_nonce( $_POST['ai_content_wizard_nonce'], 'ai_content_wizard_save_settings' ) ) { $errors[] = __( 'Security error. Please try again.', 'ai-content-wizard' ); } else { // Обработка основных настроек (без e-mail уведомлений, категорий и Telegram) ai_content_wizard_update_setting( 'ai_content_wizard_image_size', sanitize_text_field( $_POST['ai_content_wizard_image_size'] ) ); ai_content_wizard_update_setting( 'ai_content_wizard_image_quality', sanitize_text_field( $_POST['ai_content_wizard_image_quality'] ) ); ai_content_wizard_update_setting( 'ai_content_wizard_image_style', sanitize_text_field( $_POST['ai_content_wizard_image_style'] ) ); ai_content_wizard_update_setting( 'ai_content_wizard_prompt_specification', sanitize_text_field( $_POST['ai_content_wizard_prompt_specification'] ) ); ai_content_wizard_update_setting( 'ai_content_wizard_format', sanitize_text_field( $_POST['ai_content_wizard_format'] ) ); ai_content_wizard_update_setting( 'ai_content_wizard_text_length', sanitize_text_field( $_POST['ai_content_wizard_text_length'] ) ); ai_content_wizard_update_setting( 'ai_content_wizard_site_type', sanitize_text_field( $_POST['ai_content_wizard_site_type'] ) ); ai_content_wizard_update_setting( 'ai_content_wizard_writing_style', sanitize_text_field( $_POST['ai_content_wizard_writing_style'] ) ); // Удалены поля Custom Theme и Additional Requests ai_content_wizard_update_setting( 'ai_content_wizard_target_audience', sanitize_text_field( $_POST['ai_content_wizard_target_audience'] ) ); // Регионы заблокированы – их значение не меняется // ai_content_wizard_update_setting( 'ai_content_wizard_target_region', sanitize_text_field( $_POST['ai_content_wizard_target_region'] ) ); ai_content_wizard_update_setting( 'ai_content_wizard_post_status', sanitize_text_field( $_POST['ai_content_wizard_post_status'] ) ); ai_content_wizard_update_setting( 'ai_content_wizard_enable_image_generation', isset( $_POST['ai_content_wizard_enable_image_generation'] ) ? 1 : 0 ); // E-mail уведомления удалены в lite-версии // Footer Credit – всегда включён (locked) ai_content_wizard_update_setting( 'ai_content_wizard_enable_footer_credit', 1 ); // Telegram настройки – в lite-версии не доступны, поэтому не сохраняем // Настройка генерации тегов ai_content_wizard_update_setting( 'ai_content_wizard_enable_tags_generation', isset( $_POST['ai_content_wizard_enable_tags_generation'] ) ? 1 : 0 ); // Водяной знак – блокируется в lite-версии (сохраняем как выключено) ai_content_wizard_update_setting( 'ai_content_wizard_enable_watermark', 0 ); ai_content_wizard_update_setting( 'ai_content_wizard_watermark_type', 'text' ); ai_content_wizard_update_setting( 'ai_content_wizard_watermark_text', '' ); ai_content_wizard_update_setting( 'ai_content_wizard_watermark_image_id', '' ); ai_content_wizard_update_setting( 'ai_content_wizard_watermark_color', '' ); ai_content_wizard_update_setting( 'ai_content_wizard_watermark_opacity', '' ); ai_content_wizard_update_setting( 'ai_content_wizard_watermark_size', '' ); ai_content_wizard_update_setting( 'ai_content_wizard_watermark_position', '' ); // Дополнительные изображения и оптимизация – блокируются ai_content_wizard_update_setting( 'ai_content_wizard_enable_additional_images', 0 ); ai_content_wizard_update_setting( 'ai_content_wizard_additional_images_count', '' ); ai_content_wizard_update_setting( 'ai_content_wizard_enable_image_optimization', 0 ); // Enhanced Generation Quality – сохраняем как выключено ai_content_wizard_update_setting( 'ai_content_wizard_enhanced_generation_quality', 0 ); // Telegram формат сообщений – блокируются ai_content_wizard_update_setting( 'ai_content_wizard_custom_announcement_prompt', '' ); ai_content_wizard_update_setting( 'ai_content_wizard_telegram_message_format', '' ); ai_content_wizard_update_setting( 'ai_content_wizard_telegram_format_type', 'standard' ); if ( empty( $errors ) ) { echo '
' . esc_html__( 'Settings saved.', 'ai-content-wizard' ) . '
' . esc_html__( 'Lite version overview', 'ai-content-wizard' ) . '
'; echo '' . esc_html__( 'Fine-tune defaults for text, images, and publishing. Upgrade to Pro for automations, bulk scheduling, and multi-channel support.', 'ai-content-wizard' ) . '
'; echo '' . esc_html__( 'Switch providers and unlock premium prompts in the API settings.', 'ai-content-wizard' ) . '
'; echo ' ' . esc_html__( 'Manage text model', 'ai-content-wizard' ) . ''; echo '' . esc_html__( 'Lite users can work with DALL-E defaults. Pro unlocks more formats.', 'ai-content-wizard' ) . '
'; echo ' ' . esc_html__( 'Adjust image model', 'ai-content-wizard' ) . ''; echo '' . esc_html( $latest_post_title ) . '
'; echo ' ' . esc_html( $latest_post_date ) . ''; echo '' . implode( '
', array_map( 'esc_html', $errors ) ) . '