'metadata', 'aeogm_meta_titles' => 'titles', 'aeogm_meta_only' => 'meta_only', ); public function __construct() { add_action( 'admin_init', array( $this, 'register_bulk_actions' ) ); add_action( 'admin_footer-edit.php', array( $this, 'inject_progress_ui' ) ); } /** * Register the bulk-action filter for every public post type. * * Excludes `attachment` (Media library has its own bulk semantics) and * any post type that opts out via the `aeogm_bulk_meta_post_types` filter * (third-party plugins can deny-list custom types they own). */ public function register_bulk_actions() { $post_types = get_post_types( array( 'public' => true ), 'names' ); unset( $post_types['attachment'] ); /** * Filter the post types that receive AEO God Mode bulk actions. * * @since 1.6.9 * @param string[] $post_types Post type names. */ $post_types = apply_filters( 'aeogm_bulk_meta_post_types', $post_types ); foreach ( $post_types as $pt ) { add_filter( "bulk_actions-edit-{$pt}", array( $this, 'add_bulk_actions' ), 20 ); } } /** * Inject the AEO God Mode actions into a list table's bulk-action menu. * * @param array $actions Existing bulk actions. * @return array */ public function add_bulk_actions( $actions ) { // Nested array renders as an (WP 5.6+). The group label is // greyed out and cannot be selected, same as Rank Math's separators. $actions[ '⚡️ ' . __( 'AEO God Mode', 'aeo-god-mode' ) ] = array( 'aeogm_meta_combined' => '⚡️ ' . __( 'Write AEO Title + Meta (2 credits/post)', 'aeo-god-mode' ), 'aeogm_meta_titles' => '⚡️ ' . __( 'Write AEO Titles Only (1 credit/post)', 'aeo-god-mode' ), 'aeogm_meta_only' => '⚡️ ' . __( 'Write AEO Meta Only (1 credit/post)', 'aeo-god-mode' ), ); return $actions; } /** * Print the JavaScript that intercepts our bulk actions and runs the * generation in place with a progress overlay. Only loaded on the * edit.php list-table screen. */ public function inject_progress_ui() { if ( ! current_user_can( 'edit_posts' ) ) { return; } $nonce = wp_create_nonce( 'wp_rest' ); $generate_url = esc_url_raw( rest_url( self::ADMIN_PAGE_SLUG . '/v1/metadata/generate' ) ); $accept_url = esc_url_raw( rest_url( self::ADMIN_PAGE_SLUG . '/v1/metadata/accept' ) ); ?>