$value ) { if ( ! empty( $layout_vars['controls'] ) ) { if ( 'block' == $key ) { if ( ! empty( $layout_vars['controls']['bottom_block'] ) ) { unset( $layout_vars['controls']['bottom_block'] ); } if ( ! empty( $layout_vars['controls']['inner_bottom_block'] ) ) { unset( $layout_vars['controls']['inner_bottom_block'] ); } if ( ! empty( $layout_vars['controls']['inner_top_block'] ) ) { unset( $layout_vars['controls']['inner_top_block'] ); } if ( ! empty( $layout_vars['controls']['top_block'] ) ) { unset( $layout_vars['controls']['top_block'] ); } if ( ! empty( $layout_vars['controls']['content_error'] ) ) { unset( $layout_vars['controls']['content_error'] ); } } if ( 'header' == $key && ! empty( $layout_vars['controls']['header'] ) ) { unset( $layout_vars['controls']['header'] ); } if ( 'footer' == $key && ! empty( $layout_vars['controls']['footer'] ) ) { unset( $layout_vars['controls']['footer'] ); } if ( 'popup' == $key && ! empty( $layout_vars['controls']['general']['popup'] ) ) { unset( $layout_vars['controls']['general']['popup'] ); unset( $layout_vars['controls']['general']['popup_delay'] ); } if ( 'product_layout' == $key && ! empty( $layout_vars['controls']['content_single_product'] ) ) { unset( $layout_vars['controls']['content_single_product'] ); } if ( 'shop_layout' == $key && ! empty( $layout_vars['controls']['content_archive_product'] ) ) { unset( $layout_vars['controls']['content_archive_product'] ); } if ( 'cart' == $key && ! empty( $layout_vars['controls']['content_cart'] ) ) { unset( $layout_vars['controls']['content_cart'] ); } if ( 'checkout' == $key && ! empty( $layout_vars['controls']['content_checkout'] ) ) { unset( $layout_vars['controls']['content_checkout'] ); } if ( 'single' == $key && ! empty( $layout_vars['controls']['content_single_post'] ) ) { unset( $layout_vars['controls']['content_single_post'] ); } if ( 'archive' == $key && ! empty( $layout_vars['controls']['content_archive_post'] ) ) { unset( $layout_vars['controls']['content_archive_post'] ); } } } } return $layout_vars; } /** * Enqueue scripts for layout builder. * * @since 1.0 * @access public */ public function enqueue_scripts() { $this->get_condition_categories(); $this->conditions = alpus_get_option( 'conditions' ); // Parsing as array. foreach ( $this->conditions as $category => $conditions ) { $condition_data = array(); foreach ( $conditions as $i => $condition ) { $condition_data[] = $condition; } $this->conditions[ $category ] = $condition_data; } // Enqueue styles and scripts. wp_enqueue_style( 'jquery-select2' ); wp_enqueue_script( 'jquery-select2' ); wp_enqueue_script( 'isotope-pkgd' ); wp_enqueue_style( 'alpus-layout-builder-admin', alpus_framework_uri( '/admin/layout-builder/layout-builder-admin' . ( is_rtl() ? '-rtl' : '' ) . '.min.css' ), array(), ALPUS_VERSION ); wp_enqueue_script( 'alpus-layout-builder-admin', alpus_framework_uri( '/admin/layout-builder/layout-builder-admin' . ALPUS_JS_SUFFIX ), array( 'jquery-core' ), ALPUS_VERSION, true ); // Localize vars. wp_localize_script( 'alpus-layout-builder-admin', 'alpus_layout_vars', apply_filters( 'alpus_layout_vars', array( 'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ), 'site_url' => esc_url( site_url() ), 'schemes' => $this->schemes, 'controls' => Alpus_Layout_Builder::get_instance()->get_controls(), 'default_cat' => isset( $_REQUEST['layout'] ) ? $_REQUEST['layout'] : '', 'conditions' => $this->conditions, 'nonce' => wp_create_nonce( 'alpus-layout-nonce' ), 'templates' => alpus_get_global_templates_sidebars(), 'layout_images_url' => ALPUS_ASSETS . '/images/admin/', 'text_default' => esc_html__( 'Default', 'alpus' ), 'text_all' => esc_html__( 'All', 'alpus' ), 'text_hide' => esc_html__( 'Hide', 'alpus' ), 'text_my_templates' => esc_html__( 'My Templates', 'alpus' ), 'text_duplicate' => esc_html__( 'Duplicate', 'alpus' ), 'text_options' => esc_html__( 'Options', 'alpus' ), 'text_apply_prefix' => esc_html__( 'Apply this ', 'alpus' ), 'text_apply_suffix' => esc_html__( ' for:', 'alpus' ), 'text_delete' => esc_html__( 'Delete', 'alpus' ), 'text_open' => esc_html__( 'Open', 'alpus' ), 'text_close' => esc_html__( 'Close', 'alpus' ), 'text_copy' => esc_html__( 'Copy Options', 'alpus' ), 'text_paste' => esc_html__( 'Paste Options', 'alpus' ), 'text_confirm_delete_condition' => esc_html__( 'Do you want to delete this layout?', 'alpus' ), 'text_create_layout' => esc_html__( 'Create Layout for ', 'alpus' ), 'template_builder' => array( 'block' => alpus_get_feature( 'fs_builder_block' ) && defined( 'ALPUS_CORE_VERSION' ), 'header' => alpus_get_feature( 'fs_builder_header' ) && defined( 'ALPUS_CORE_VERSION' ), 'footer' => alpus_get_feature( 'fs_builder_footer' ) && defined( 'ALPUS_CORE_VERSION' ), 'popup' => alpus_get_feature( 'fs_builder_popup' ) && defined( 'ALPUS_CORE_VERSION' ), 'product_layout' => class_exists( 'WooCommerce' ) && alpus_get_feature( 'fs_plugin_woocommerce' ) && alpus_get_feature( 'fs_builder_singleproduct' ) && defined( 'ALPUS_CORE_VERSION' ), 'shop_layout' => class_exists( 'WooCommerce' ) && alpus_get_feature( 'fs_plugin_woocommerce' ) && alpus_get_feature( 'fs_builder_shop' ) && defined( 'ALPUS_CORE_VERSION' ), 'cart' => class_exists( 'WooCommerce' ) && alpus_get_feature( 'fs_plugin_woocommerce' ) && alpus_get_feature( 'fs_builder_cart' ) && defined( 'ALPUS_CORE_VERSION' ), 'checkout' => class_exists( 'WooCommerce' ) && alpus_get_feature( 'fs_plugin_woocommerce' ) && alpus_get_feature( 'fs_builder_checkout' ) && defined( 'ALPUS_CORE_VERSION' ), 'sidebar' => alpus_get_feature( 'fs_builder_sidebar' ) && defined( 'ALPUS_CORE_VERSION' ), 'single' => alpus_get_feature( 'fs_builder_single' ) && defined( 'ALPUS_CORE_VERSION' ), 'archive' => alpus_get_feature( 'fs_builder_archive' ) && defined( 'ALPUS_CORE_VERSION' ), ), ) ) ); } /** * Get condition categories. * * @since 1.0 * @access public */ public function get_condition_categories() { // Add layouts. $this->schemes = array(); $this->schemes['site'] = array( 'title' => esc_html__( 'All Layouts', 'alpus' ), 'icon' => 'fa fa-layer-group', ); $this->schemes['single_front'] = array( 'title' => esc_html__( 'Home Page', 'alpus' ), 'icon' => 'fa fa-home', ); $this->schemes['single_page'] = array( 'title' => esc_html__( 'General Page', 'alpus' ), 'icon' => 'fa fa-file', ); // @start feature: fs_plugin_woocommerce if ( class_exists( 'WooCommerce' ) ) { $this->schemes['archive_product'] = array( 'title' => esc_html__( 'Shop Page', 'alpus' ), 'icon' => 'fa fa-shopping-bag', ); $this->schemes['single_product'] = array( 'title' => esc_html__( 'Single Product', 'alpus' ), 'icon' => 'fa fa-shopping-cart', ); // @start feature: fs_plugin_cart if ( alpus_get_feature( 'fs_builder_cart' ) ) { $this->schemes['cart'] = array( 'title' => esc_html__( 'Cart Page', 'alpus' ), 'icon' => 'fa fa-file', ); } // @end feature: fs_plugin_cart // @start feature: fs_plugin_checkout if ( alpus_get_feature( 'fs_builder_checkout' ) ) { $this->schemes['checkout'] = array( 'title' => esc_html__( 'Checkout Page', 'alpus' ), 'icon' => 'fa fa-file', ); } // @end feature: fs_plugin_checkout } // @end feature: fs_plugin_woocommerce $this->schemes['archive_post'] = array( 'title' => esc_html__( 'Blog Page', 'alpus' ), 'icon' => 'fa fa-calendar', ); $this->schemes['single_post'] = array( 'title' => esc_html__( 'Single Post', 'alpus' ), 'icon' => 'fa fa-calendar-check', ); $this->schemes['search'] = array( 'title' => esc_html__( 'Search Page', 'alpus' ), 'scheme' => array( 'all' => array( 'title' => esc_html__( 'All Post Types', 'alpus' ), ), ), 'icon' => 'fa fa-search', ); $this->schemes['error'] = array( 'title' => esc_html__( '404 Page', 'alpus' ), 'icon' => 'fa fa-sad-tear', ); // Get post types to apply layout condition. $post_types = array(); /** * Filters the exclude post type. * * @param array The post type array. * @since 1.0 */ $post_types_exclude = apply_filters( 'alpus_condition_exclude_post_types', array( ALPUS_NAME . '_template', 'attachment', 'elementor_library' ) ); $available_post_types = get_post_types( array( 'public' => true ), 'objects' ); foreach ( $available_post_types as $post_type_slug => $post_type ) { if ( ! in_array( $post_type_slug, $post_types_exclude ) ) { $post_types[ $post_type_slug ] = array( 'name' => $post_type->labels->name, 'singular_name' => $post_type->labels->singular_name, ); } } foreach ( $post_types as $post_type => $titles ) { /** * Filters the layout builder which is avaiable archive. * * @since 1.0 */ if ( empty( $this->schemes[ 'archive_' . $post_type ] ) && apply_filters( 'alpus_layout_builder_is_available_archive', 'page' != $post_type, $post_type ) ) { $this->schemes[ 'archive_' . $post_type ] = array( 'title' => $titles['name'], ); } /** * Filters the single layout builder which is avaiable. * * @since 1.0 */ if ( empty( $this->schemes[ 'single_' . $post_type ] ) && apply_filters( 'alpus_layout_builder_is_available_single', true, $post_type ) ) { $this->schemes[ 'single_' . $post_type ] = array( 'title' => $titles['singular_name'], ); } } foreach ( $post_types as $post_type => $titles ) { $schemes = array( 'all' => array( 'title' => esc_html__( 'All', 'alpus' ), ), ); if ( 'product' == $post_type ) { // Products archive $schemes['product_cat'] = array( 'title' => esc_html__( 'Categories', 'alpus' ), 'list' => get_terms( array( 'taxonomy' => 'product_cat', 'fields' => 'id=>name', 'hide_empty' => false, ) ), ); $schemes['product_brand'] = array( 'title' => esc_html__( 'Brands', 'alpus' ), 'list' => get_terms( array( 'taxonomy' => 'product_brand', 'fields' => 'id=>name', 'hide_empty' => false, ) ), ); $schemes['product_tag'] = array( 'title' => esc_html__( 'Tags', 'alpus' ), 'list' => get_terms( array( 'taxonomy' => 'product_tag', 'fields' => 'id=>name', 'hide_empty' => false, ) ), ); } elseif ( 'post' == $post_type ) { // Posts archive $schemes['category'] = array( 'title' => esc_html__( 'Categories', 'alpus' ), 'list' => get_terms( array( 'taxonomy' => 'category', 'fields' => 'id=>name', 'hide_empty' => false, ) ), ); $schemes['post_tag'] = array( 'title' => esc_html__( 'Tags', 'alpus' ), 'list' => get_terms( array( 'taxonomy' => 'post_tag', 'fields' => 'id=>name', 'hide_empty' => false, ) ), ); } foreach ( $schemes as $key => $scheme ) { if ( isset( $schemes[ $key ]['list'] ) ) { // translators: %s represents post types or taxonomies in the plural. $schemes[ $key ]['placeholder'] = sprintf( esc_html__( 'All %s', 'alpus' ), $scheme['title'] ); } } if ( count( $schemes ) ) { // Correct archive names of post types. if ( 'product' == $post_type ) { $schemes['all']['title'] = esc_html__( 'All Shop Pages', 'alpus' ); } elseif ( 'post' == $post_type ) { $schemes['all']['title'] = esc_html__( 'All Blog Pages', 'alpus' ); } elseif ( 'page' == $post_type ) { $schemes['all']['title'] = esc_html__( 'All Pages', 'alpus' ); } /** * Filters the title of layout builder in all archive. * * @since 1.0 */ $schemes['all']['title'] = apply_filters( 'alpus_layout_builder_get_title_of_all_archive', $schemes['all']['title'], $post_type ); /** * Add archive scheme for $post_type * * Filters the layout builder which is avaiable archive page. * * @since 1.0 */ if ( apply_filters( 'alpus_layout_builder_is_available_archive', 'page' != $post_type, $post_type ) ) { $this->schemes[ 'archive_' . $post_type ]['scheme'] = $schemes; } // Correct single names of post types. if ( 'product' == $post_type ) { $schemes['all']['title'] = esc_html__( 'All Product Pages', 'alpus' ); } elseif ( 'post' == $post_type ) { $schemes['all']['title'] = esc_html__( 'All Post Pages', 'alpus' ); } /** * Filters the title of layout builder in all single page. * * @since 1.0 */ $schemes['all']['title'] = apply_filters( 'alpus_layout_builder_get_title_of_all_single', $schemes['all']['title'], $post_type ); // Add post pages for each post type. $schemes[ $post_type ] = array( 'title' => $titles['singular_name'], // translators: %s represents singular name of post type. 'placeholder' => sprintf( esc_html__( 'Select Individual %s', 'alpus' ), $titles['name'] ), 'ajaxselect' => true, ); if ( 'page' == $post_type ) { $schemes['child'] = array( 'title' => esc_html__( 'Child of Pages', 'alpus' ), 'placeholder' => esc_html__( 'Select Parent Pages', 'alpus' ), 'ajaxselect' => true, ); } /** * Add single scheme for $post_type * * Filters the single layout builder which is avaiable. * * @since 1.0 */ if ( apply_filters( 'alpus_layout_builder_is_available_single', true, $post_type ) ) { $this->schemes[ 'single_' . $post_type ]['scheme'] = $schemes; } } // Add post type to search scheme $this->schemes['search']['scheme'][ $post_type ] = array( 'title' => $titles['singular_name'], ); } foreach ( $this->schemes as $category => $scheme ) { if ( empty( $this->schemes[ $category ]['layout_title'] ) ) { /* translators: %s represents condition category title. */ $this->schemes[ $category ]['layout_title'] = sprintf( esc_html__( '%s Layout', 'alpus' ), $this->schemes[ $category ]['title'] ); } } /** * Filters the layout builder schemes. * * @since 1.0 */ $this->schemes = apply_filters( 'alpus_layout_builder_schemes', $this->schemes ); } /** * Print Builder Content * * @since 1.0 * @access public */ public function view_layout_builder() { $title = array( 'title' => esc_html__( 'Layout Builder', 'alpus' ), 'desc' => esc_html__( 'Create a remarkable site with fully customizable layouts and online library.', 'alpus' ), ); $admin_config = Alpus_Admin::get_instance()->admin_config; Alpus_Admin_Panel::get_instance()->view_header( 'layout_builder', $admin_config, $title ); ?>