builder_post_type_callback(); // Post Type Register
add_action( 'wp', array( $this, 'checkfor_header_footer' ), 999 );
add_filter( 'template_include', array( $this, 'include_builder_files' ), 100 );
add_action( 'add_meta_boxes', array( $this, 'init_metabox_callback' ) );
add_action( 'save_post', array( $this, 'metabox_save_data' ) );
add_action( 'save_post', array( $this, 'metabox_save_video_data' ) );
add_action( 'delete_post', array( $this, 'delete_option_meta_action' ) );
add_action( 'load-post-new.php', array( $this, 'disable_new_post_templates' ) );
}
public function checkfor_header_footer() {
$this->theme_name = get_template();
$this->is_block_theme = wp_is_block_theme();
$header_id = ultimate_post()->builder_check_conditions( 'header' );
$footer_id = ultimate_post()->builder_check_conditions( 'footer' );
global $ULTP_HEADER_ID;
global $ULTP_FOOTER_ID;
if ( $header_id ) {
$ULTP_HEADER_ID = $header_id;
do_action(
'ultp_enqueue_postx_block_css',
array(
'post_id' => $header_id,
'css' => '',
)
);
$this->header_id = $header_id;
if ( $this->is_block_theme ) {
add_action( 'wp_head', array( $this, 'ultp_header_builder_template' ) );
} else {
switch ( $this->theme_name ) {
case 'astra':
remove_all_actions( 'astra_header' );
add_action( 'astra_header', array( $this, 'ultp_header_builder_template' ) );
break;
default:
add_action( 'get_header', array( $this, 'ultp_header_builder_template' ) );
}
}
}
if ( $footer_id ) {
$ULTP_FOOTER_ID = $footer_id;
$this->footer_id = $footer_id;
do_action(
'ultp_enqueue_postx_block_css',
array(
'post_id' => $footer_id,
'css' => '',
)
);
if ( $this->is_block_theme ) {
add_action( 'wp_footer', array( $this, 'ultp_footer_builder_template' ) );
} else {
switch ( $this->theme_name ) {
case 'astra':
remove_all_actions( 'astra_footer' );
add_action( 'astra_footer', array( $this, 'ultp_footer_builder_template' ) );
break;
case 'generatepress':
remove_action( 'generate_footer', 'generate_construct_footer_widgets' );
remove_action( 'generate_footer', 'generate_construct_footer' );
add_action( 'generate_footer', array( $this, 'ultp_footer_builder_template' ) );
break;
default:
add_action( 'get_footer', array( $this, 'ultp_footer_builder_template' ) );
}
}
}
}
public function ultp_header_builder_template() {
if ( $this->header_id ) {
if ( $this->is_block_theme ) {
remove_action( 'wp_head', array( $this, 'ultp_header_builder_template' ) );
} elseif ( $this->theme_name == 'generatepress' ) {
require_once ULTP_PATH . 'addons/builder/templates/header.php';
} else {
if ( $this->theme_name != 'astra' ) { // Astra theme issue
require_once ULTP_PATH . 'addons/builder/templates/header.php';
}
$templates = array();
$templates[] = 'header.php';
remove_all_actions( 'wp_head' );
if ( $this->theme_name != 'bricks' ) { // Conflict with Bricks Builder Backend
ob_start();
}
locate_template( $templates, true );
if ( $this->theme_name != 'bricks' ) { // Conflict with Bricks Builder Backend
ob_get_clean();
} else {
wp_enqueue_style( 'wp-block-library' ); // Gutenberg CSS issue Bricks Builder frontend
}
}
?>
_x( 'Builder', 'Builder', 'ultimate-post' ), 'singular_name' => _x( 'Builder', 'Builder', 'ultimate-post' ), 'menu_name' => __( 'Builder', 'ultimate-post' ), 'parent_item_colon' => __( 'Parent Builder', 'ultimate-post' ), 'all_items' => __( 'Builder', 'ultimate-post' ), 'view_item' => __( 'View Builder', 'ultimate-post' ), 'add_new_item' => __( 'Add New', 'ultimate-post' ), 'add_new' => __( 'Add New', 'ultimate-post' ), 'edit_item' => __( 'Edit Builder', 'ultimate-post' ), 'update_item' => __( 'Update Builder', 'ultimate-post' ), 'search_items' => __( 'Search Builder', 'ultimate-post' ), 'not_found' => __( 'No Builder Found', 'ultimate-post' ), 'not_found_in_trash' => __( 'Not Builder found in Trash', 'ultimate-post' ), ); $args = array( 'labels' => $labels, 'show_in_rest' => true, 'supports' => array( 'title', 'editor', 'comments' ), 'hierarchical' => false, 'public' => false, 'rewrite' => false, 'show_ui' => true, 'show_in_menu' => false, 'show_in_nav_menus' => false, 'exclude_from_search' => true, 'capability_type' => 'page', ); register_post_type( 'ultp_builder', $args ); } }