page_slug, array( $this, 'render_page' ), 'dashicons-format-image', 100 ); // Переименовываем первый подпункт (WordPress создает его автоматически) add_submenu_page( $this->page_slug, __( 'Auto Featured Image', 'ai-thumbnails-maker' ), __( 'Auto Featured Image', 'ai-thumbnails-maker' ), 'manage_options', $this->page_slug, array( $this, 'render_page' ) ); } /** * Enqueue scripts * * @param string $hook Current admin page hook. */ public function enqueue_scripts( $hook ) { if ( strpos( $hook, $this->page_slug ) === false ) { return; } // Стили дашборда wp_enqueue_style( 'aitm-dashboard', AITM_PLUGIN_URL . 'assets/dist/dashboard.css', array(), AITM_VERSION ); // Скрипты дашборда (Chart.js включен в bundle) wp_enqueue_script( 'aitm-dashboard', AITM_PLUGIN_URL . 'assets/dist/dashboard.js', array( 'jquery' ), AITM_VERSION, true ); // Локализация wp_localize_script( 'aitm-dashboard', 'aitmData', array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'aitm_nonce' ), 'strings' => array( 'generating' => __( 'Generating...', 'ai-thumbnails-maker' ), 'completed' => __( 'Generation completed!', 'ai-thumbnails-maker' ), 'error' => __( 'Error occurred', 'ai-thumbnails-maker' ), 'processing' => __( 'Processing post:', 'ai-thumbnails-maker' ), 'success' => __( 'Success', 'ai-thumbnails-maker' ), 'failed' => __( 'Failed', 'ai-thumbnails-maker' ), 'withThumbnail' => __( 'With featured image', 'ai-thumbnails-maker' ), 'withoutThumbnail' => __( 'Without featured image', 'ai-thumbnails-maker' ), ), ) ); } /** * Render page */ public function render_page() { if ( ! current_user_can( 'manage_options' ) ) { return; } // Get settings $settings = get_option( 'aitm_settings', array() ); // Get log from separate option $log = get_option( 'aitm_generation_log', array() ); // Get statistics $generator = new AITM_Thumbnail_Generator( $settings ); $stats = $generator->get_statistics( 'post' ); // Get post types $post_types = get_post_types( array( 'public' => true, ), 'objects' ); // Check if overwrite is enabled $overwrite_existing = $settings['overwrite_existing'] ?? false; ?>

%

%

  • -
  • -
__( 'First Content Image', 'ai-thumbnails-maker' ), 'generate_from_title' => __( 'Generate from Title', 'ai-thumbnails-maker' ), 'search_or_generate' => __( 'Search or Generate', 'ai-thumbnails-maker' ), 'use_default_image' => __( 'Use Default Image', 'ai-thumbnails-maker' ), 'ai_generation' => __( 'AI Generation', 'ai-thumbnails-maker' ), ); $method_descriptions = array( 'first_content_image' => __( 'Uses the first image found in post content', 'ai-thumbnails-maker' ), 'generate_from_title' => __( 'Generates image from post title on colored background', 'ai-thumbnails-maker' ), 'search_or_generate' => __( 'Searches in content, generates from title if not found', 'ai-thumbnails-maker' ), 'use_default_image' => __( 'Searches in content, uses default image if not found', 'ai-thumbnails-maker' ), 'ai_generation' => __( 'Generates images using AI (ChatGPT + DALL-E)', 'ai-thumbnails-maker' ), ); $method_label = $method_labels[ $method ] ?? $method_labels['first_content_image']; $method_desc = $method_descriptions[ $method ] ?? $method_descriptions['first_content_image']; ?>

render_log_entry( $entry ); ?>