'array', 'sanitize_callback' => [self::class, 'sanitize']]); }); add_action('admin_enqueue_scripts', [self::class, 'assets']); add_action('wp_ajax_a1local_mdi_page', [self::class, 'get_page']); add_action('wp_ajax_a1local_mdi_save_page', [self::class, 'save_page']); } public static function sanitize($value): array { $value = is_array($value) ? $value : []; $types = array_values(array_intersect(array_map('sanitize_key', (array) ($value['types'] ?? [])), array_keys(self::types()))); return ['types' => $types, 'negotiation' => !empty($value['negotiation']), 'training' => !empty($value['training'])]; } private static function types(): array { $types = get_post_types(['public' => true], 'objects'); unset($types['attachment']); return $types; } public static function assets(string $hook): void { if ($hook !== 'settings_page_a1-local-markdown-delivery-inspector') { return; } wp_enqueue_style('a1local-mdi-admin', A1LOCAL_MDI_URL . 'assets/admin.css', [], A1LOCAL_MDI_VERSION); wp_enqueue_script('a1local-mdi-admin', A1LOCAL_MDI_URL . 'assets/admin.js', [], A1LOCAL_MDI_VERSION, true); wp_localize_script('a1local-mdi-admin', 'a1localMdiAdmin', ['ajax' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('a1local-mdi-admin'), 'negotiation' => (bool) Plugin::settings()['negotiation']]); } private static function authorised_post(): \WP_Post { if (!current_user_can('manage_options')) { wp_send_json_error(['message' => 'Administrator access is required.'], 403); } check_ajax_referer('a1local-mdi-admin', 'nonce'); $id = absint($_POST['post_id'] ?? 0); $post = get_post($id); if (!$post || !current_user_can('edit_post', $id)) { wp_send_json_error(['message' => 'This page is unavailable.'], 404); } return $post; } public static function get_page(): void { check_ajax_referer('a1local-mdi-admin', 'nonce'); $post = self::authorised_post(); Legacy::post($post->ID); wp_send_json_success([ 'id' => $post->ID, 'title' => get_the_title($post), 'url' => get_permalink($post), 'markdown_url' => Plugin::url($post), 'excluded' => (bool) get_post_meta($post->ID, '_a1local_mdi_exclude', true), 'reason' => Plugin::exclusion($post), 'expected' => (string) get_post_meta($post->ID, '_a1local_mdi_expected', true), ]); } public static function save_page(): void { check_ajax_referer('a1local-mdi-admin', 'nonce'); $post = self::authorised_post(); $expected = sanitize_textarea_field(wp_unslash((string) ($_POST['expected'] ?? ''))); if (strlen($expected) > 4000) { wp_send_json_error(['message' => 'Keep important details under 4,000 characters.'], 400); } update_post_meta($post->ID, '_a1local_mdi_expected', wp_slash($expected)); update_post_meta($post->ID, '_a1local_mdi_exclude', !empty($_POST['excluded']) ? 1 : 0); self::get_page(); } public static function page(): void { if (!current_user_can('manage_options')) { return; } $settings = Plugin::settings(); $posts = get_posts(['post_type' => array_keys(self::types()), 'post_status' => 'publish', 'posts_per_page' => 200, 'orderby' => 'title', 'order' => 'ASC', 'suppress_filters' => false]); ?>
YOUR WORDPRESS CONTENT, MADE READABLE
Turn public pages into clean Markdown. Check the details that matter before an agent reads them.
Choose a page to see its Markdown, check important details, and test how it is delivered.
No API key. No external AI service.A result applies to this page and this request path. It does not prove every cache location or AI crawler behaves the same way.
02 / THE DELIVERED DOCUMENT