Skip to content

Commit

Permalink
add display to the header cpt post list if one is chosen as the theme…
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-c-woodard committed Feb 10, 2025
1 parent 9e536ae commit ec1940b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions includes/header/class-kadence-header-cpt.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public function __construct() {
add_action( 'enqueue_block_editor_assets', array( $this, 'script_enqueue' ) );
add_action( 'enqueue_block_assets', array( $this, 'title_styles_enqueue' ) );

// Add a post display state for the current header (if choosen in theme).
add_filter( 'display_post_states', array( $this, 'add_display_post_states' ), 10, 2 );

if( is_admin() && class_exists( 'Kadence_Blocks_Duplicate_Post' ) ) {
new Kadence_Blocks_Duplicate_Post( $this->post_type );
}
Expand Down Expand Up @@ -930,6 +933,25 @@ public function register_meta() {
}

}

/**
* Add a post display state for special pages in the page list table.
*
* @param array $post_states An array of post display states.
* @param WP_Post $post The current post object.
*/
public function add_display_post_states( $post_states, $post ) {
if ( class_exists( 'Kadence\Theme' ) ) {
if(Kadence\kadence()->option( 'blocks_header' )) {
$header_id = intval(Kadence\kadence()->option( 'blocks_header_id' ));
if ( $header_id === $post->ID ) {
$post_states['kb_post_for_header'] = __( 'Theme Header', 'kadence-blocks' );
}
}
}

return $post_states;
}
}

Kadence_Blocks_Header_CPT_Controller::get_instance();

0 comments on commit ec1940b

Please sign in to comment.