true ) ); wp_set_script_translations( self::SCRIPT, 'wpinterface-seo', WPISEO_PATH . 'languages' ); // Data is added when the editor loads, after all post types are registered. add_action( 'enqueue_block_editor_assets', array( self::class, 'add_data' ) ); } /** * Adds `window.wpiseoBlocks` for the block editor scripts. */ public static function add_data(): void { wp_add_inline_script( self::SCRIPT, 'window.wpiseoBlocks = ' . wp_json_encode( array( 'breadcrumbs' => function_exists( 'wpiseo_module_enabled' ) && wpiseo_module_enabled( 'breadcrumbs' ), 'local' => function_exists( 'wpiseo_module_enabled' ) && wpiseo_module_enabled( 'local' ), 'localUrl' => admin_url( 'admin.php?page=' . Admin::MENU_SLUG . '-local' ), 'htmlSitemap' => function_exists( 'wpiseo_module_enabled' ) && wpiseo_module_enabled( 'sitemaps' ), 'postTypes' => array_values( array_map( static fn( $type ) => array( 'value' => $type->name, 'label' => $type->labels->name, ), array_filter( get_post_types( array( 'public' => true ), 'objects' ), static fn( $type ) => 'attachment' !== $type->name ) ) ), ) ) . ';', 'before' ); } }