scanner = $scanner; $this->cleaner = $cleaner; $this->exporter = $exporter; add_action( 'admin_menu', array( $this, 'register_menu' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) ); } /** * Register admin menu. * * @return void */ public function register_menu() { add_menu_page( __( 'adbear Image Cleaner', 'adbear-image-cleaner' ), __( 'Image Cleaner', 'adbear-image-cleaner' ), 'manage_options', 'adbear-image-cleaner', array( $this, 'render_page' ), 'dashicons-trash', 75 ); } /** * Enqueue admin scripts/styles. * * @param string $hook_suffix Page hook. * @return void */ public function enqueue_assets( $hook_suffix ) { if ( 'toplevel_page_adbear-image-cleaner' !== $hook_suffix ) { return; } wp_enqueue_style( 'adbear-image-cleaner-admin', ADBEAR_IMAGE_CLEANER_URL . 'assets/admin.css', array(), ADBEAR_IMAGE_CLEANER_VERSION ); wp_enqueue_script( 'adbear-image-cleaner-admin', ADBEAR_IMAGE_CLEANER_URL . 'assets/admin.js', array( 'jquery' ), ADBEAR_IMAGE_CLEANER_VERSION, true ); wp_localize_script( 'adbear-image-cleaner-admin', 'AdbearImageCleaner', array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'scanNonce' => wp_create_nonce( 'adbear_scan_nonce' ), 'deleteNonce' => wp_create_nonce( 'adbear_delete_nonce' ), 'batchSize' => 25, 'i18n' => array( 'scanning' => __( 'Scanning in progress...', 'adbear-image-cleaner' ), 'scanComplete' => __( 'Scan completed.', 'adbear-image-cleaner' ), 'deleteConfirm' => __( 'This image will be moved to trash (safe delete). Continue?', 'adbear-image-cleaner' ), 'bulkDeleteConfirm' => __( 'Selected images will be moved to trash (safe delete). Continue?', 'adbear-image-cleaner' ), 'backupWarning' => __( 'Please ensure you have a recent backup before deleting media.', 'adbear-image-cleaner' ), 'genericError' => __( 'Something went wrong.', 'adbear-image-cleaner' ), 'nothingToDelete'=> __( 'No unused images found yet. Run a scan first.', 'adbear-image-cleaner' ), 'noSelection' => __( 'Please select at least one image.', 'adbear-image-cleaner' ), 'bulkDeleteDone' => __( 'Selected images moved to trash.', 'adbear-image-cleaner' ), ), ) ); } /** * Render plugin dashboard page. * * @return void */ public function render_page() { if ( ! current_user_can( 'manage_options' ) ) { return; } $rows = $this->scanner->get_unused_results(); $total_rows = count( $rows ); ?>

0

render_rows( $rows ); ?>
> $rows Row set. * @return void */ private function render_rows( array $rows ) { if ( empty( $rows ) ) { echo '' . esc_html__( 'No unused images found yet. Start a scan.', 'adbear-image-cleaner' ) . ''; return; } foreach ( $rows as $row ) { $id = isset( $row['id'] ) ? (int) $row['id'] : 0; $file_name = isset( $row['file_name'] ) ? (string) $row['file_name'] : ''; $file_path = isset( $row['file_path'] ) ? (string) $row['file_path'] : ''; $file_size = isset( $row['file_size'] ) ? (int) $row['file_size'] : 0; $upload_date = isset( $row['upload_date'] ) ? (string) $row['upload_date'] : ''; $status = isset( $row['status'] ) ? (string) $row['status'] : ''; $status_text = isset( $row['status_text'] ) ? (string) $row['status_text'] : ''; ?>