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() { $theme_name = get_template(); $header_id = ultimate_post()->conditions('header'); $footer_id = ultimate_post()->conditions('footer'); if ( $header_id ) { if ( wp_is_block_theme() ) { // add_action('wp_head', function() use ($header_id) { // $this->header_builder_template($header_id); // }); add_action('wp_head', array($this, 'header_builder_template')); } else { // add_action('get_header', function() use ($header_id) { // $this->header_builder_template($header_id); // }); add_action('get_header', array($this, 'header_builder_template')); } } if ( $footer_id ) { if ( wp_is_block_theme() ) { add_action('wp_footer', function() use ($footer_id, $theme_name) { $this->footer_builder_template($footer_id, $theme_name); }); } else { switch ($theme_name) { case 'astra': remove_all_actions( 'astra_footer' ); add_action( 'astra_footer', function() use ($footer_id, $theme_name) { $this->footer_builder_template($footer_id, $theme_name); }); break; case 'generatepress': remove_action( 'generate_footer', 'generate_construct_footer_widgets'); remove_action( 'generate_footer', 'generate_construct_footer' ); add_action( 'generate_footer', function() use ($footer_id, $theme_name) { $this->footer_builder_template($footer_id, $theme_name); }); break; default: add_action('get_footer', function() use ($footer_id, $theme_name) { $this->footer_builder_template($footer_id, $theme_name); }); } } } } public function header_builder_template() { $header_id = ultimate_post()->conditions('header'); $theme_name = get_template(); if ($header_id) { if ( !wp_is_block_theme() ) { require_once ULTP_PATH.'addons/builder/templates/header.php'; $templates = []; $templates[] = 'header.php'; remove_all_actions( 'wp_head' ); if ($theme_name != 'bricks') { // Conflict with Bricks Builder Backend ob_start(); } locate_template( $templates, true ); if ($theme_name != 'bricks') { // Conflict with Bricks Builder Backend ob_get_clean(); } else { wp_enqueue_style( 'wp-block-library' ); // Gutenberg CSS issue Bricks Builder frontend } } ultimate_post()->register_scripts_common(); ?>
content($header_id); //phpcs:ignore ?>
register_scripts_common(); if ( !wp_is_block_theme() ) { require_once ULTP_PATH.'addons/builder/templates/footer.php'; $templates = []; $templates[] = 'footer.php'; remove_all_actions( 'wp_footer' ); if ($theme_name != 'bricks') { // Conflict with Bricks Builder Backend ob_start(); } locate_template( $templates, true ); if ($theme_name != 'bricks') { // Conflict with Bricks Builder Backend ob_get_clean(); } } ?> post_type == 'ultp_builder' && (!defined('ULTP_PRO_VER')) ){ $post_count = wp_count_posts('ultp_builder'); $post_count = $post_count->publish + $post_count->draft; if ($post_count > 0) { wp_die( 'You are not allowed to do that! Only one template can be created in the free version. Please Upgrade Pro.' ); } } } public function delete_option_meta_action( $post_id ) { if (get_post_type( $post_id ) != 'ultp_builder') { return; } $conditions = get_option('ultp_builder_conditions', array()); if($conditions){ $has_change = false; if(isset($conditions['archive'][$post_id])) { $has_change = true; unset($conditions['archive'][$post_id]); } if(isset($conditions['singular'][$post_id])) { $has_change = true; unset($conditions['singular'][$post_id]); } if($has_change) { update_option('ultp_builder_conditions', $conditions); } } delete_post_meta($post_id, '_ultp_active'); } public function include_builder_files($template) { $includes = ultimate_post()->conditions('includes'); return $includes ? $includes : $template; } function init_metabox_callback() { $all_types = get_post_types( array( 'public' => true ), 'names' ); $post_type = array_diff_key($all_types, array('page' => 'page', 'attachment' => 'attachment' )); $title = '
PostX Settings
'; add_meta_box( 'postx-builder-id', __('PostX Builder Settings', 'ultimate-post'), array($this, 'container_width_callback'), 'ultp_builder', 'side' ); add_meta_box( 'ultp-feature-video', $title, array($this, 'video_source_callback'), $post_type, 'side' ); } function video_source_callback($post) { wp_nonce_field('video_meta_box', 'video_meta_box_nonce'); $video = get_post_meta($post->ID, '__builder_feature_video', true); $caption = get_post_meta($post->ID, '__builder_feature_caption', true); ?>
ID, '__container_width', true); $sidebar = get_post_meta($post->ID, '__builder_sidebar', true); $widget = get_post_meta($post->ID, '__builder_widget_area', true); $p_type = get_post_meta($post->ID, '__ultp_builder_type', true); $p_type = $p_type ? $p_type : 'archive'; $widget_area = wp_get_sidebars_widgets(); if (isset($widget_area['wp_inactive_widgets'])) { unset($widget_area['wp_inactive_widgets']); } if (isset($widget_area['array_version'])) { unset($widget_area['array_version']); } ?>

_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 ); } }