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; ?>
%