true), 'names'); foreach ($post_types as $post_type) { register_post_meta($post_type, self::META_KEY, array( 'show_in_rest' => true, 'single' => true, 'type' => 'boolean', 'default' => false, 'auth_callback' => function() { return current_user_can('edit_posts'); }, )); } } /** * Add meta box to post types */ public function ayudawp_add_meta_box() { $post_types = get_post_types(array('public' => true), 'names'); foreach ($post_types as $post_type) { add_meta_box( 'ayudawp_aiss_exclude_metabox', __('AI Share & Summarize', 'ai-share-summarize'), array($this, 'ayudawp_render_meta_box'), $post_type, 'side', 'default' ); } } /** * Render meta box content * * @param WP_Post $post Current post object */ public function ayudawp_render_meta_box($post) { // Add nonce for security wp_nonce_field('ayudawp_aiss_meta_box', 'ayudawp_aiss_meta_box_nonce'); // Get current value $excluded = get_post_meta($post->ID, self::META_KEY, true); ?>