* @since 3.0.0 * @since 7.0.0 Refactored to BeyondWords namespace with snake_case methods. */ namespace BeyondWords\Editor\Components; /** * Inspect * * @since 3.0.0 * @since 7.0.0 Refactored to BeyondWords namespace with snake_case methods. */ defined( 'ABSPATH' ) || exit; class InspectPanel { /** * Constructor * * @since 6.0.0 Make static. * @since 7.0.0 Refactored to BeyondWords namespace with snake_case methods. */ public static function init() { add_action( 'add_meta_boxes', [ self::class, 'add_meta_box_callback'] ); add_action( 'rest_api_init', [ self::class, 'rest_api_init_callback'] ); add_filter( 'default_hidden_meta_boxes', [ self::class, 'hide_meta_box'] ); add_action( 'wp_loaded', function (): void { $post_types = \BeyondWords\Settings\Utils::get_compatible_post_types(); if ( is_array( $post_types ) ) { foreach ( $post_types as $post_type ) { add_action( "save_post_{$post_type}", [ self::class, 'save'], 5 ); } } } ); } /** * Hides the metabox by default. * * @since 6.0.0 Make static. * @since 7.0.0 Refactored to BeyondWords namespace with snake_case methods. * * @param string[] $hidden An array of IDs of meta boxes hidden by default. */ public static function hide_meta_box( $hidden ) { $hidden[] = 'beyondwords__inspect'; return $hidden; } /** * Adds the meta box container for the Classic Editor. * * The Block Editor UI is handled using JavaScript. * * @since 6.0.0 Make static. * @since 7.0.0 Refactored to BeyondWords namespace with snake_case methods. * * @param string $post_type */ public static function add_meta_box_callback( $post_type ) { $post_types = \BeyondWords\Settings\Utils::get_compatible_post_types(); if ( ! in_array( $post_type, $post_types ) ) { return; } add_meta_box( 'beyondwords__inspect', __( 'BeyondWords', 'speechkit' ) . ': ' . __( 'Inspect', 'speechkit' ), [ self::class, 'render_meta_box_content'], $post_type, 'advanced', 'low', [ '__back_compat_meta_box' => true, ] ); } /** * Render Meta Box content. * * @since 6.0.0 Make static. * @since 7.0.0 Refactored to BeyondWords namespace with snake_case methods. * * @param \WP_Post $post The post object. */ public static function render_meta_box_content( $post ) { $metadata = \BeyondWords\Post\Meta::get_all_beyondwords_metadata( $post->ID ); self::post_meta_table( $metadata ); ?>