* @since 6.3.0 * @since 7.0.0 Refactored to BeyondWords namespace with snake_case methods. */ namespace BeyondWords\Editor\Components; /** * ContentId * * @since 6.3.0 * @since 7.0.0 Refactored to BeyondWords namespace with snake_case methods. */ defined( 'ABSPATH' ) || exit; class ContentId { /** * Init. * * @since 6.3.0 * @since 7.0.0 Refactored to BeyondWords namespace with snake_case methods. */ public static function init() { 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'], 10 ); } } } ); } /** * HTML output for this component. * * @since 6.3.0 * @since 7.0.0 Refactored to BeyondWords namespace with snake_case methods. * * @param \WP_Post $post The post object. */ public static function element( $post ) { $content_id = \BeyondWords\Post\Meta::get_content_id( $post->ID ) ?: ''; $project_id = \BeyondWords\Post\Meta::get_project_id( $post->ID ) ?: get_option( 'beyondwords_project_id', '' ); $post_type = get_post_type( $post ); $post_type_object = $post_type ? get_post_type_object( $post_type ) : null; $rest_base = ( $post_type_object && ! empty( $post_type_object->rest_base ) ) ? $post_type_object->rest_base : $post_type; wp_nonce_field( 'beyondwords_content_id', 'beyondwords_content_id_nonce' ); ?>