'xlwcty_builder_settings', 'title' => __( 'Component Builder Settings', 'woo-thank-you-page-nextmove-lite' ), 'classes' => 'xlwcty_options_common', 'show_names' => true, 'context' => 'normal', 'priority' => 'high', ); $cmb2_builder_fields = new_cmb2_box( $box_options ); $get_fields = include plugin_dir_path( XLWCTY_PLUGIN_FILE ) . 'admin/includes/cmb2-wcthankyou-meta-config.php'; $get_fields = self::parse_default_values( $get_fields ); foreach ( $get_fields as $field_arr ) { if ( isset( $field_arr['is_multiple'] ) && $field_arr['is_multiple'] === true && isset( $field_arr['count'] ) && $field_arr['count'] > 0 ) { for ( $i = 1; $i <= $field_arr['count']; $i ++ ) { foreach ( $field_arr['fields'] as $field ) { $field = self::recursive_replace_index_tag( $field, $i ); $cmb2_builder_fields->add_field( $field ); } } } else { foreach ( $field_arr['fields'] as $field ) { $cmb2_builder_fields->add_field( $field ); } } } $cmb2_builder_fields->add_field( array( 'id' => '_xlwcty_chosen_order_preview', 'type' => 'hidden', ) ); $cmb2_builder_fields->add_field( array( 'id' => '_xlwcty_builder_layout', 'type' => 'hidden', ) ); $cmb2_builder_fields->add_field( array( 'id' => '_xlwcty_builder_template', 'type' => 'hidden', ) ); $cmb2_builder_fields->add_field( array( 'id' => '_wp_page_template', 'type' => 'hidden', ) ); $box_options_global = array( 'id' => 'xlwcty_global_settings', 'title' => __( 'Global Settings', 'woo-thank-you-page-nextmove-lite' ), 'classes' => 'xlwcty_options_common', 'hookup' => false, 'show_on' => array( 'key' => 'options-page', 'value' => array( 'xlwcty' ), ), ); $cmb2_builder_fields_global = new_cmb2_box( $box_options_global ); add_filter( 'intermediate_image_sizes', array( __CLASS__, 'xlwcty_modify_intermediate_image_sizes' ), 10, 1 ); $get_fields = include plugin_dir_path( XLWCTY_PLUGIN_FILE ) . 'admin/includes/cmb2-settings-config.php'; remove_filter( 'intermediate_image_sizes', array( __CLASS__, 'xlwcty_modify_intermediate_image_sizes' ) ); foreach ( $get_fields as $field ) { $cmb2_builder_fields_global->add_field( self::settings_add_default_value( $field ) ); } $box_options_debug = array( 'id' => 'xlwcty_debug_settings', 'title' => __( 'Debug Settings', 'woo-thank-you-page-nextmove-lite' ), 'classes' => 'xlwcty_options_common', 'hookup' => false, 'show_on' => array( 'key' => 'options-page', 'value' => array( 'xlwcty' ), ), ); $cmb2_builder_fields_global = new_cmb2_box( $box_options_debug ); $get_fields = include plugin_dir_path( XLWCTY_PLUGIN_FILE ) . 'admin/includes/cmb2-debug-config.php'; foreach ( $get_fields as $field ) { $cmb2_builder_fields_global->add_field( self::settings_add_default_value( $field ) ); } } public static function parse_default_values( $field_config ) { foreach ( $field_config as $slug => $fields ) { $get_component = XLWCTY_Components::get_components( $slug ); $defaults = $get_component->get_defaults(); $get_mapping = $get_component->fields; foreach ( $field_config[ $slug ]['fields'] as $key => $field ) { //handling for the multiple field components $field['id'] = str_replace( '_{{index}}', '', $field['id'] ); if ( $slug . '_enable' == $field['id'] || $slug . '_hide_mobile' == $field['id'] || $slug . '_hide_desktop' == $field['id'] ) { continue; } $continue = apply_filters( 'xlwcty_skip_field_for_default_values', false, $slug, $field ); if ( $continue === true ) { continue; } $mapped_key = array_search( $field['id'], $get_mapping ); if ( $mapped_key !== false && isset( $field_config[ $slug ]['fields'][ $key ] ) && isset( $defaults[ $mapped_key ] ) ) { $field_config[ $slug ]['fields'][ $key ]['default'] = $defaults[ $mapped_key ]; } } } return $field_config; } public static function menu_order_metabox_fields() { $box_options = array( 'id' => 'xlwcty_menu_order_settings', 'title' => __( 'Thank You Page Priority', 'woo-thank-you-page-nextmove-lite' ), 'classes' => 'xlwcty_options_common', 'object_types' => array( XLWCTY_Common::get_thank_you_page_post_type_slug() ), 'show_names' => true, 'context' => 'side', 'priority' => 'low', ); $cmb = new_cmb2_box( $box_options ); $priority_desc = __( 'Page Priority features come into play when multiple Thank You pages are set.', 'woo-thank-you-page-nextmove-lite' ); $priority_desc .= '

' . __( 'Priority works in ascending order. Lower the number higher the priority.', 'woo-thank-you-page-nextmove-lite' ); $priority_desc_link = add_query_arg( array( 'utm_source' => 'nextmove-pro', 'utm_campaign' => 'sidebar', 'utm_medium' => 'text-click', 'utm_term' => 'priority-usage', ), 'https://xlplugins.com/documentation/nextmove-woocommerce-thank-you-page/page-priority/' ); $priority_desc .= '

' . __( 'Need Help with priority? ', 'woo-thank-you-page-nextmove-lite' ) . ''; $priority_desc .= __( 'Read Docs', 'woo-thank-you-page-nextmove-lite' ); $priority_desc .= ''; $shortcode_box = array( array( 'id' => 'xlwcty_shortcode_metabox', 'position' => 1, 'fields' => array( array( 'name' => 'Page Priority', 'desc' => $priority_desc, 'id' => '_xlwcty_menu_order', 'type' => 'text', 'attributes' => array( 'type' => 'number', 'pattern' => '\d*', ), 'sanitization_cb' => 'absint', 'escape_cb' => array( 'XLWCTY_Admin_CMB2_Support', 'escape_cb_to_consider_default' ), ), ), ), ); foreach ( $shortcode_box as $meta_box ) { foreach ( $meta_box['fields'] as $fields ) { $cmb->add_field( $fields ); } } } public static function quick_view_metabox_fields() { $box_options = array( 'id' => 'xlwcty_quick_view_settings', 'title' => __( 'Quick View', 'woo-thank-you-page-nextmove-lite' ), 'classes' => 'xlwcty_options_common', 'object_types' => array( XLWCTY_Common::get_thank_you_page_post_type_slug() ), 'show_names' => true, 'context' => 'side', 'priority' => 'default', ); $cmb = new_cmb2_box( $box_options ); $shortcode_box = array( array( 'id' => 'xlwcty_shortcode_metabox', 'position' => 1, 'fields' => array( array( 'content' => apply_filters( 'xlwcty_get_qyuck_view', '' ), 'id' => '_xlwcty_qv_html', 'type' => 'xlwcty_html_content_field', 'row_classes' => array( 'row_title_classes', 'xlwcty_small_text', 'xlwcty_label_gap', 'xlwcty_p0' ), ), ), ), ); foreach ( $shortcode_box as $meta_box ) { foreach ( $meta_box['fields'] as $fields ) { $cmb->add_field( $fields ); } } } /** * Setting up property `options_data` by options data saved. */ public static function prepere_default_config() { self::$options_data = XLWCTY_Common::get_default_settings(); } public static function xlwcty_button_html() { $new_array = array(); ob_start(); $customization_fields = include plugin_dir_path( XLWCTY_PLUGIN_FILE ) . 'admin/includes/cmb2-wcthankyou-meta-config.php'; if ( is_array( $customization_fields ) && count( $customization_fields ) > 0 ) { foreach ( $customization_fields as $val ) { if ( isset( $val['is_multiple'] ) && $val['is_multiple'] === true && isset( $val['count'] ) && $val['count'] > 0 ) { for ( $i = 1; $i <= $val['count']; $i ++ ) { $new_array[ $val['position'] ][ $i ]['title'] = $val['xlwcty_accordion_title'] . ' ' . $i; $new_array[ $val['position'] ][ $i ]['component_title'] = $val['xlwcty_accordion_title']; $new_array[ $val['position'] ][ $i ]['id'] = $val['id']; if ( isset( $val['xlwcty_accordion_head'] ) && $i === 1 ) { $new_array[ $val['position'] ][ $i ]['head'] = $val['xlwcty_accordion_head']; } if ( isset( $val['xlwcty_accordion_head_end'] ) && $i === $val['count'] ) { $new_array[ $val['position'] ][ $i ]['head_end'] = $val['xlwcty_accordion_head_end']; $new_array[ $val['position'] ][ $i ]['add_more'] = true; } if ( isset( $val['xlwcty_icon'] ) ) { $new_array[ $val['position'] ][ $i ]['icon'] = $val['xlwcty_icon']; } } } else { $new_array[ $val['position'] ][0]['title'] = $val['xlwcty_accordion_title']; $new_array[ $val['position'] ][0]['id'] = $val['id']; if ( isset( $val['xlwcty_accordion_head'] ) ) { $new_array[ $val['position'] ][0]['head'] = $val['xlwcty_accordion_head']; } if ( isset( $val['xlwcty_accordion_head_end'] ) ) { $new_array[ $val['position'] ][0]['head_end'] = $val['xlwcty_accordion_head_end']; } if ( isset( $val['xlwcty_icon'] ) ) { $new_array[ $val['position'] ][0]['icon'] = $val['xlwcty_icon']; } if ( isset( $val['xlwcty_disabled'] ) && $val['xlwcty_disabled'] == 'yes' ) { $new_array[ $val['position'] ][0]['disabled'] = 'yes'; } } } ksort( $new_array ); $is_multiple_arr_count = array(); $layout = get_post_meta( $_GET['id'], '_xlwcty_builder_layout', true ); $template = get_post_meta( $_GET['id'], '_xlwcty_builder_template', true ); $get_choosed_templ_components = array(); if ( $layout != '' && $template != '' ) { $template_data = json_decode( $layout, true ); if ( is_array( $template_data ) && count( $template_data ) > 0 ) { if ( array_key_exists( $template, $template_data ) ) { $get_choosed_templ_components = $template_data[ $template ]; } } } $get_all_components = array(); if ( count( $get_choosed_templ_components ) > 0 ) { foreach ( $get_choosed_templ_components as $key => $layout_val ) { if ( is_array( $layout_val ) && count( $layout_val ) > 0 ) { foreach ( $layout_val as $k => $v ) { $get_all_components[] = $v['slug']; } } } } if ( is_array( $new_array ) ) { foreach ( $new_array as $component_arr ) { $multiple = false; if ( is_array( $component_arr ) && count( $component_arr ) > 1 ) { $multiple = true; } $k = 1; foreach ( $component_arr as $key => $component ) { $unique_id = ''; $component_selected = ''; $component_selected_html = ''; echo isset( $component['head'] ) ? '
' . $component['head'] . '
' : ''; if ( isset( $component['title'] ) && $component['title'] != '' ) { if ( $multiple ) { $unique_id = '_' . $k; } $data_comp = $component['id']; $is_mulpliple_gr_one = ''; if ( $multiple && ! in_array( $data_comp . $unique_id, $get_all_components ) ) { if ( ! isset( $is_multiple_arr_count[ $data_comp ] ) ) { $is_multiple_arr_count[ $data_comp ] = array(); $is_multiple_arr_count[ $data_comp ]['count'] = 0; } $is_multiple_arr_count[ $data_comp ]['count'] ++; $is_multiple_arr_count[ $data_comp ]['title'] = $component['component_title']; $is_multiple_arr_count[ $data_comp ]['slug'][ $data_comp . $unique_id ] = 1; $is_mulpliple_gr_one = 'xlwct_hide_this_componets'; } if ( isset( $component['disabled'] ) ) { $component_selected .= ' xlwcty_lock'; } echo '
'; if ( isset( $component['icon'] ) ) { echo '
'; } else { echo '
'; } echo '

' . $component['title'] . '

'; echo $component_selected_html; if ( isset( $component['disabled'] ) ) { echo '
'; } echo '
'; } if ( isset( $component['head_end'] ) && $multiple == true ) { if ( is_array( $is_multiple_arr_count ) && count( $is_multiple_arr_count ) > 0 ) { global $template_previews; ?>
    $val ) { ?>
  • ' data-count="" data-max=""> ()
' : ''; $k ++; } } } } return ob_get_clean(); } public static function xlwcty_builder_html() { global $template_previews; global $template_previews_template; $template_previews_template = get_post_meta( $_GET['id'], '_xlwcty_builder_template', true ); $layouts = XLWCTY_Common::get_builder_layouts(); ob_start(); ?>
3 Choose Layout
4 Arrange Components
Header
  • {{comp.name}}
  • {{comp.name}}
  • {{comp.name}}
  • {{comp.name}}
0 ) { foreach ( $array as $key => $val ) { if ( is_array( $val ) ) { $array[ $key ] = self::recursive_replace_index_tag( $val, $index ); } else { if ( is_string( $val ) && strpos( $val, '{{index}}' ) !== false ) { $array[ $key ] = str_replace( '{{index}}', $index, $val ); } } } } return $array; } public static function settings_add_default_value( $field ) { $get_defaults = XLWCTY_Common::get_options_defaults(); if ( array_key_exists( $field['id'], $get_defaults ) ) { $field['default'] = $get_defaults[ $field['id'] ]; } return $field; } public static function xlwcty_modify_intermediate_image_sizes( $sizes ) { $new_array = array(); if ( is_array( $sizes ) && count( $sizes ) > 0 ) { foreach ( $sizes as $key => $val ) { $new_array[ $key ] = ucwords( str_replace( '_', ' ', $val ) ); } } return $new_array; } }