plugin = $plugin; } /** * Register admin hooks. * * @return void */ public function register_hooks() { add_action( 'admin_menu', array( $this, 'register_admin_menu' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) ); } /** * Add top-level Sample Saz admin menu. * * @return void */ public function register_admin_menu() { $this->page_hook = add_menu_page( __( 'Sample Saz – Demo Content Generator', 'sample-saz' ), __( 'Sample Saz', 'sample-saz' ), 'manage_options', 'sample-saz', array( $this, 'render_admin_page' ), SAMPLESAZ_URL . 'assets/images/menu-icon.svg', 58 ); } /** * Enqueue local CSS, Vanilla JS, and Vazirmatn variable font (RTL only). * * @param string $hook_suffix Current admin page hook suffix. * @return void */ public function enqueue_assets( $hook_suffix ) { if ( $hook_suffix !== $this->page_hook ) { return; } $style_deps = array(); // Load bundled Vazirmatn variable font ONLY in RTL admin mode. if ( is_rtl() ) { wp_enqueue_style( 'samplesaz-vazirmatn', SAMPLESAZ_URL . 'assets/css/vazirmatn.css', array(), SAMPLESAZ_VERSION ); $style_deps[] = 'samplesaz-vazirmatn'; } wp_enqueue_style( 'samplesaz-admin', SAMPLESAZ_URL . 'assets/css/admin.css', $style_deps, (string) filemtime( SAMPLESAZ_PATH . 'assets/css/admin.css' ) ); wp_enqueue_script( 'samplesaz-admin', SAMPLESAZ_URL . 'assets/js/admin.js', array(), (string) filemtime( SAMPLESAZ_PATH . 'assets/js/admin.js' ), true ); wp_localize_script( 'samplesaz-admin', 'samplesazData', array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'samplesaz_ajax_nonce' ), 'wcActive' => $this->plugin->is_woocommerce_active(), 'i18n' => array( 'starting' => __( 'Initializing task...', 'sample-saz' ), 'invalidCount' => __( 'Please enter a valid number between 1 and 50.', 'sample-saz' ), 'wcRequired' => __( 'WooCommerce is inactive. Product generation is disabled.', 'sample-saz' ), 'generatingPosts' => __( 'Generating demo posts...', 'sample-saz' ), 'generatingProds' => __( 'Generating WooCommerce products...', 'sample-saz' ), 'generatingComms' => __( 'Generating comments and reviews...', 'sample-saz' ), 'preparingCleanup' => __( 'Scanning demo items for safe cleanup...', 'sample-saz' ), 'cleaningItems' => __( 'Cleaning selected demo items...', 'sample-saz' ), 'nothingToClean' => __( 'No unprotected demo items found to clean.', 'sample-saz' ), 'completedSuccess' => __( 'Operation completed successfully!', 'sample-saz' ), 'completedWarnings' => __( 'Operation completed with some warnings. Check the console log.', 'sample-saz' ), 'requestFailed' => __( 'AJAX request failed. Please check the console log.', 'sample-saz' ), 'confirmCleanAll' => __( 'Are you sure you want to remove all unprotected demo content? Items marked as Live Content will not be touched.', 'sample-saz' ), 'busyNotice' => __( 'Another operation is currently running. Please wait until it finishes.', 'sample-saz' ), 'readyStatus' => __( 'Ready. Choose an action above to begin.', 'sample-saz' ), 'restoringItems' => __( 'Restoring items from Trash...', 'sample-saz' ), 'emptyingTrash' => __( 'Permanently deleting items from Trash...', 'sample-saz' ), 'trashEmpty' => __( 'Trash is empty.', 'sample-saz' ), 'confirmEmptyTrash' => __( 'Are you sure you want to permanently delete all items in Trash? This cannot be undone.', 'sample-saz' ), 'restoreLabel' => __( 'Restore', 'sample-saz' ), 'deletePermLabel' => __( 'Delete Permanently', 'sample-saz' ), 'typePost' => __( 'Post', 'sample-saz' ), 'typeProduct' => __( 'Product', 'sample-saz' ), 'typeComment' => __( 'Comment', 'sample-saz' ), 'typeReview' => __( 'Review', 'sample-saz' ), ), ) ); } /** * Render the Sample Saz admin dashboard page. * * @return void */ public function render_admin_page() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'sample-saz' ) ); } $wc_active = $this->plugin->is_woocommerce_active(); $yoast_active = $this->plugin->is_yoast_active(); $rankmath_active = $this->plugin->is_rankmath_active(); $wc_currency = $this->plugin->get_wc_currency(); $default_lang = $this->plugin->get_default_content_language(); $stats = $this->plugin->get_demo_stats(); $trashed_items = $this->plugin->cleaner->get_trashed_items(); $post_media_count = count( $this->plugin->media_manager->get_media_files( 'post' ) ); $product_media_count = count( $this->plugin->media_manager->get_media_files( 'product' ) ); $music_media_count = count( $this->plugin->media_manager->get_media_files( 'music' ) ); ?>
| # |