// ──────────────────────────────────────────────────────────────────────── // OCR Labels Report + “Clear All” button // ──────────────────────────────────────────────────────────────────────── // 1) Add submenu under “Images” add_action( 'admin_menu', function(){ add_submenu_page( 'edit.php?post_type=image', // parent slug 'OCR Labels', // page title 'OCR Labels', // menu title 'manage_options', // capability 'image-ocr-labels', // menu slug 'stoxo_render_ocr_report' // callback ); }, 20 ); // 2) Render the OCR report table function stoxo_render_ocr_report() { // Handle “Clear All” form submission if ( isset( $_POST['stoxo_clear_ocr'] ) && check_admin_referer( 'stoxo_clear_ocr_action', 'stoxo_clear_ocr_nonce' ) ) { delete_post_meta_by_key( '_ocr_labels' ); echo '

All OCR labels cleared.

'; } // Fetch only ‘image’ posts whose _ocr_labels meta exists and is not empty $ocrged = get_posts([ 'post_type' => 'image', 'posts_per_page' => -1, 'meta_query' => [ [ 'key' => '_ocr_labels', 'compare' => 'EXISTS', ], [ 'key' => '_ocr_labels', 'value' => '', 'compare' => '!=', ], ], ]); // Header / Clear Form echo '
'; echo '

OCR Labels (' . count( $ocrged ) . ')

'; echo '
'; wp_nonce_field( 'stoxo_clear_ocr_action', 'stoxo_clear_ocr_nonce' ); echo ''; echo '
'; // Table start echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; if ( empty( $ocrged ) ) { echo ''; } else { foreach ( $ocrged as $p ) { $thumb = has_post_thumbnail( $p->ID ) ? get_the_post_thumbnail( $p->ID, [150,150], [ 'style' => 'width:100px;height:100px;object-fit:cover;border:1px solid #ccc;', ] ) : '
No Image
'; $text = get_post_meta( $p->ID, '_ocr_labels', true ); $edit_link = esc_url( admin_url( 'post.php?post=' . $p->ID . '&action=edit' ) ); $trash_link = esc_url( get_delete_post_link( $p->ID ) ); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } } echo '
ThumbnailIDTitleOCR TextActions
No OCR labels found.
' . $thumb . '' . intval( $p->ID ) . '' . esc_html( get_the_title( $p->ID ) ) . '
' . esc_html( $text ) . '
'; echo 'Edit '; echo 'Trash'; echo '
'; echo '
'; }
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/mu-plugins/ocr-scan.php:1) in /var/www/html/wp-includes/pluggable.php on line 1450

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/mu-plugins/ocr-scan.php:1) in /var/www/html/wp-includes/pluggable.php on line 1453