Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/woo-thank-you-page-nextmove-lite/admin/includes/cmb2-addons/post-search/post-search.php
+++ b/woo-thank-you-page-nextmove-lite/admin/includes/cmb2-addons/post-search/post-search.php
@@ -1,215 +0,0 @@
-<?php
-defined( 'ABSPATH' ) || exit;
-
-/*
- Plugin Name: CMB2 Field Type: Post Search Ajax
- Plugin URI: https://github.com/alexis-magina/cmb2-field-post-search-ajax
- GitHub Plugin URI: https://github.com/alexis-magina/cmb2-field-post-search-ajax
- Description: CMB2 field type to attach posts to each others.
- Version: 1.1.5
- Author: Magina
- Author URI: http://magina.fr/
- License: GPLv2+
- */
-
-/**
- * Class MAG_CMB2_Field_Post_Search_Ajax
- */
-if ( ! class_exists( 'MAG_CMB2_Field_Post_Search_Ajax' ) ) {
-
- class MAG_CMB2_Field_Post_Search_Ajax {
-
- /**
- * Current version number
- */
- const VERSION = '1.1.5';
-
- /**
- * The url which is used to load local resources
- */
- protected static $url = '';
-
- /**
- * Initialize the plugin by hooking into CMB2
- */
- public function __construct() {
- add_action( 'cmb2_render_post_search_ajax', array( $this, 'render' ), 10, 5 );
- add_action( 'cmb2_sanitize_post_search_ajax', array( $this, 'sanitize' ), 10, 4 );
- add_action( 'wp_ajax_cmb_post_search_ajax_get_results', array( $this, 'cmb_post_search_ajax_get_results' ) );
- }
-
- /**
- * Render field
- */
- public function render( $field, $value, $object_id, $object_type, $field_type ) {
- $this->setup_admin_scripts();
- $field_name = $field->_name();
-
- if ( $field->args( 'limit' ) > 1 ) {
- echo '<ul class="cmb-post-search-ajax-results" id="' . $field_name . '_results">';
- if ( isset( $value ) && ! empty( $value ) ) {
- if ( ! is_array( $value ) ) {
- $value = array( $value );
- }
- foreach ( $value as $val ) {
- $handle = ( $field->args( 'sortable' ) ) ? '<span class="hndl"></span>' : '';
- if ( $field->args( 'object_type' ) == 'user' ) {
- $guid = get_edit_user_link( $val );
- $user = get_userdata( $val );
- $title = $user->display_name;
- } else {
- $guid = get_edit_post_link( $val );
- $title = get_the_title( $val );
- }
- echo '<li>' . $handle . '<input type="hidden" name="' . $field_name . '_results[]" value="' . $val . '"><a href="' . $guid . '" target="_blank" class="edit-link">' . $title . '</a><a class="remover"><span class="dashicons dashicons-no"></span><span class="dashicons dashicons-dismiss"></span></a></li>';
- }
- }
- echo '</ul>';
- $field_value = '';
- } else {
- if ( is_array( $value ) ) {
- $value = $value[0];
- }
- if ( $field->args( 'object_type' ) == 'user' ) {
- $field_value = ( $value ? get_userdata( $value )->display_name : '' );
- } else {
- $field_value = ( $value ? get_the_title( $value ) : '' );
- }
- echo $field_type->input( array(
- 'type' => 'hidden',
- 'name' => $field_name . '_results',
- 'value' => $value,
- 'desc' => false,
- ) );
- }
-
- echo $field_type->input( array(
- 'type' => 'text',
- 'name' => $field_name,
- 'id' => $field_name,
- 'class' => 'cmb-post-search-ajax',
- 'value' => $field_value,
- 'desc' => false,
- 'data-limit' => $field->args( 'limit' ) ? $field->args( 'limit' ) : '1',
- 'data-sortable' => $field->args( 'sortable' ) ? $field->args( 'sortable' ) : '0',
- 'data-object' => $field->args( 'object_type' ) ? $field->args( 'object_type' ) : 'post',
- 'data-queryargs' => $field->args( 'query_args' ) ? htmlspecialchars( json_encode( $field->args( 'query_args' ) ), ENT_QUOTES, 'UTF-8' ) : '',
- ) );
-
- echo '<img src="' . admin_url( 'images/spinner.gif' ) . '" class="cmb-post-search-ajax-spinner" />';
-
- $field_type->_desc( true, true );
- }
-
- /**
- * Optionally save the latitude/longitude values into two custom fields
- */
- public function sanitize( $override_value, $value, $object_id, $field_args ) {
- $fid = $field_args['id'];
- if ( ! empty( $field_args['render_row_cb'][0]->data_to_save[ $fid . '_results' ] ) ) {
- $value = $field_args['render_row_cb'][0]->data_to_save[ $fid . '_results' ];
- } else {
- $value = false;
- }
-
- return $value;
- }
-
- /**
- * Defines the url which is used to load local resources. Based on, and uses,
- * the CMB2_Utils class from the CMB2 library.
- */
- public static function url( $path = '' ) {
- if ( self::$url ) {
- return self::$url . $path;
- }
-
- /**
- * Set the variable cmb2_fpsa_dir
- */
- $cmb2_fpsa_dir = trailingslashit( __DIR__ );
-
- /**
- * Use CMB2_Utils to gather the url from cmb2_fpsa_dir
- */
- $cmb2_fpsa_url = CMB2_Utils::get_url_from_dir( $cmb2_fpsa_dir );
-
- /**
- * Filter the CMB2 FPSA location url
- */
- self::$url = trailingslashit( apply_filters( 'cmb2_fpsa_url', $cmb2_fpsa_url, self::VERSION ) );
-
- return self::$url . $path;
- }
-
- /**
- * Enqueue scripts and styles
- */
- public function setup_admin_scripts() {
-
- wp_register_script( 'jquery-autocomplete', self::url( 'js/jquery.autocomplete.min.js' ), array( 'jquery' ), self::VERSION );
- wp_register_script( 'mag-post-search-ajax', self::url( 'js/mag-post-search-ajax.js' ), array( 'jquery', 'jquery-autocomplete', 'jquery-ui-sortable' ), self::VERSION );
- wp_localize_script( 'mag-post-search-ajax', 'psa', array(
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
- 'nonce' => wp_create_nonce( 'mag_cmb_post_search_ajax_get_results' ),
- ) );
- wp_enqueue_script( 'mag-post-search-ajax' );
- wp_enqueue_style( 'mag-post-search-ajax', self::url( 'css/mag-post-search-ajax.css' ), array(), self::VERSION );
- }
-
- /**
- * Ajax request : get results
- */
- public function cmb_post_search_ajax_get_results() {
- $nonce = isset( $_POST['psacheck'] ) ? sanitize_text_field( wp_unslash( $_POST['psacheck'] ) ) : '';
- if ( ! wp_verify_nonce( $nonce, 'mag_cmb_post_search_ajax_get_results' ) ) {
- die( json_encode( array( 'error' => __( 'Error : Unauthorized action' ) ) ) );
- } else {
- $raw_args = isset( $_POST['query_args'] ) ? wp_unslash( $_POST['query_args'] ) : '';
- $args = json_decode( stripslashes( htmlspecialchars_decode( $raw_args ) ), true );
- if ( ! is_array( $args ) ) {
- $args = array();
- }
- // Whitelist allowed query arguments to prevent injection
- $allowed_args = array( 'post_type', 'post_status', 'posts_per_page', 'paged', 's', 'meta_query', 'tax_query', 'search' );
- $args = array_intersect_key( $args, array_flip( $allowed_args ) );
- $args['s'] = isset( $_POST['query'] ) ? sanitize_text_field( wp_unslash( $_POST['query'] ) ) : '';
- $datas = array();
- $object = isset( $_POST['object'] ) ? sanitize_text_field( wp_unslash( $_POST['object'] ) ) : '';
- if ( $object == 'user' ) {
- $args['search'] = '*' . esc_attr( $args['s'] ) . '*';
- $users = new WP_User_Query( $args );
- $results = $users->get_results();
- if ( ! empty( $results ) ) {
- foreach ( $results as $result ) {
- $user_info = get_userdata( $result->ID );
- // Define filter "mag_cmb_post_search_ajax_result" to allow customize ajax results.
- $datas[] = apply_filters( 'mag_cmb_post_search_ajax_result', array(
- 'value' => $user_info->display_name,
- 'data' => $result->ID,
- 'guid' => get_edit_user_link( $result->ID ),
- ) );
- }
- }
- } else {
- $results = new WP_Query( $args );
- if ( $results->have_posts() ) :
- while ( $results->have_posts() ) :
- $results->the_post();
- // Define filter "mag_cmb_post_search_ajax_result" to allow customize ajax results.
- $datas[] = apply_filters( 'mag_cmb_post_search_ajax_result', array(
- 'value' => get_the_title(),
- 'data' => get_the_ID(),
- 'guid' => get_edit_post_link(),
- ) );
- endwhile;
- endif;
- }
- wp_reset_postdata();
- die( json_encode( $datas ) );
- }
- }
- }
-
-}
-$mag_cmb2_field_post_search_ajax = new MAG_CMB2_Field_Post_Search_Ajax();
--- a/woo-thank-you-page-nextmove-lite/admin/includes/cmb2-addons/tabs/assets/css/index.php
+++ b/woo-thank-you-page-nextmove-lite/admin/includes/cmb2-addons/tabs/assets/css/index.php
@@ -1,2 +0,0 @@
-<?php
-// Silence is golden.
--- a/woo-thank-you-page-nextmove-lite/admin/includes/cmb2-addons/tabs/assets/index.php
+++ b/woo-thank-you-page-nextmove-lite/admin/includes/cmb2-addons/tabs/assets/index.php
@@ -1,2 +0,0 @@
-<?php
-// Silence is golden.
--- a/woo-thank-you-page-nextmove-lite/admin/includes/cmb2-addons/tabs/assets/js/index.php
+++ b/woo-thank-you-page-nextmove-lite/admin/includes/cmb2-addons/tabs/assets/js/index.php
@@ -1,2 +0,0 @@
-<?php
-// Silence is golden.
--- a/woo-thank-you-page-nextmove-lite/admin/includes/cmb2-addons/tabs/inc/assets.class.php
+++ b/woo-thank-you-page-nextmove-lite/admin/includes/cmb2-addons/tabs/inc/assets.class.php
@@ -1,22 +0,0 @@
-<?php
-defined( 'ABSPATH' ) || exit;
-
-if ( ! class_exists( 'cmb2_XL_TABS_Assets' ) ) {
- class cmb2_XL_TABS_Assets {
-
- public function __construct() {
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_assets' ) );
- }
-
-
- public function admin_assets() {
- // css
- wp_enqueue_style( 'dtheme-cmb2-tabs', plugin_dir_url( __DIR__ ) . 'assets/css/cmb2-tabs.css', array(), '1.0.1' );
-
- // js
- wp_enqueue_script( 'jquery-ui' );
- wp_enqueue_script( 'dtheme-cmb2-tabs', plugin_dir_url( __DIR__ ) . 'assets/js/cmb2-tabs.js', array( 'jquery-ui-tabs' ) );
- }
-
- }
-}
No newline at end of file
--- a/woo-thank-you-page-nextmove-lite/admin/includes/cmb2-addons/tabs/inc/cmb2-tabs.class.php
+++ b/woo-thank-you-page-nextmove-lite/admin/includes/cmb2-addons/tabs/inc/cmb2-tabs.class.php
@@ -1,114 +0,0 @@
-<?php
-defined( 'ABSPATH' ) || exit;
-
-/**
- * Class xlwcty_CMB2_Tabs
- * @package cmb2_tabsinc
- * @since 1.0.1
- */
-if ( ! class_exists( 'cmb2_XL_Tabs' ) ) {
-
- class cmb2_XL_Tabs {
-
- protected static $instance = null;
-
- /**
- * xlwcty_CMB2_Tabs constructor.
- */
- public function __construct() {
- add_action( 'cmb2_render_tabs', array( $this, 'render' ), 10, 3 );
- add_filter( 'cmb2_sanitize_tabs', array( $this, 'save' ), 10, 4 );
- }
-
- /**
- * Return an instance of this class.
- * @since 1.0.0
- * @return object A single instance of this class.
- */
- public static function get_instance() {
-
- if ( null == self::$instance ) {
- self::$instance = new self;
- }
-
- return self::$instance;
- }
-
- /**
- * Hook: Render field
- *
- * @param $field_object
- * @param $escaped_value
- * @param $object_id
- */
- public function render( $field_object, $escaped_value, $object_id ) {
- $settings = $field_object->args['tabs'];
- $attrs = $field_object->args['attributes'];
- $attributes = '';
- foreach ( $attrs as $attr => $val ) {
- // if data attribute, use single quote wraps, else double
- $quotes = false !== stripos( $attr, 'data-' ) ? "'" : '"';
- $attributes .= sprintf( ' %1$s=%3$s%2$s%3$s', $attr, $val, $quotes );
- }
- ?>
- <div class="dtheme-cmb2-tabs" <?php echo $attributes; ?>>
-
- <ul>
- <?php foreach ( $settings['tabs'] as $key => $tab ): ?>
- <li><a href="#<?php echo $tab['id']; ?>"><?php echo $tab['title']; ?></a></li>
- <?php endforeach; ?>
- </ul>
-
- <?php foreach ( $settings['tabs'] as $key => $tab ): ?>
- <div id="<?php echo $tab['id']; ?>" class='angular_components'>
-
- <?php
- // set options to cmb2
- $setting_fields = array_merge( $settings['args'], array( 'fields' => $tab['fields'] ) );
- $CMB2 = new CMB2( $setting_fields, $object_id );
-
- foreach ( $tab['fields'] as $key_field => $field ) {
- if ( $CMB2->is_options_page_mb() ) {
-
- $CMB2->object_type( $settings['args']['object_type'] );
- }
-
- // cmb2 render field
- $CMB2->render_field( $field );
- }
- ?>
-
- </div>
- <?php endforeach; ?>
- </div>
- <?php
- }
-
- /**
- * Hook: Save field values
- *
- * @param $override_value
- * @param $value
- * @param $post_id
- * @param $data
- */
- public function save( $override_value, $value, $post_id, $data ) {
- foreach ( $data['tabs']['tabs'] as $tab ) {
- $setting_fields = array_merge( $data['tabs']['args'], array( 'fields' => $tab['fields'] ) );
- $CMB2 = new CMB2( $setting_fields, $post_id );
-
- if ( $CMB2->is_options_page_mb() ) {
- $cmb2_options = cmb2_options( $post_id );
- $values = $CMB2->get_sanitized_values( $_POST );
- foreach ( $values as $key => $value ) {
- $cmb2_options->update( $key, $value );
- }
- } else {
- $CMB2->save_fields();
- }
- }
- }
-
- }
-
-}
No newline at end of file
--- a/woo-thank-you-page-nextmove-lite/admin/includes/cmb2-addons/tabs/inc/index.php
+++ b/woo-thank-you-page-nextmove-lite/admin/includes/cmb2-addons/tabs/inc/index.php
@@ -1,2 +0,0 @@
-<?php
-// Silence is golden.
--- a/woo-thank-you-page-nextmove-lite/admin/includes/cmb2-addons/tabs/index.php
+++ b/woo-thank-you-page-nextmove-lite/admin/includes/cmb2-addons/tabs/index.php
@@ -1,2 +0,0 @@
-<?php
-// Silence is golden.
--- a/woo-thank-you-page-nextmove-lite/admin/includes/cmb2-addons/tabs/plugin.php
+++ b/woo-thank-you-page-nextmove-lite/admin/includes/cmb2-addons/tabs/plugin.php
@@ -1,14 +0,0 @@
-<?php
-defined( 'ABSPATH' ) || exit;
-
-if ( is_admin() ) {
-
- include_once __DIR__ . '/inc/assets.class.php';
- include_once __DIR__ . '/inc/cmb2-tabs.class.php';
-
- // connection css and js
- new cmb2_XL_TABS_Assets();
-
- // run global hooks
- cmb2_XL_Tabs::get_instance();
-}
--- a/woo-thank-you-page-nextmove-lite/admin/includes/cmb2-debug-config.php
+++ b/woo-thank-you-page-nextmove-lite/admin/includes/cmb2-debug-config.php
@@ -1,6 +1,16 @@
<?php
defined( 'ABSPATH' ) || exit;
+/**
+ * The order pre-data runs a wc_get_orders() query. This file is included on every
+ * `cmb2_init` (i.e. every admin request), so only build it on the NextMove settings
+ * screen where the debug box is actually rendered.
+ */
+$xlwcty_debug_pre_data = array();
+if ( is_admin() && 'wc-settings' === filter_input( INPUT_GET, 'page' ) && XLWCTY_Common::get_wc_settings_tab_slug() === filter_input( INPUT_GET, 'tab' ) && 'settings' === filter_input( INPUT_GET, 'section' ) ) {
+ $xlwcty_debug_pre_data = XLWCTY_Admin_CMB2_Support::get_orders_cmb2( null, true );
+}
+
return array(
array(
'id' => "order_select",
@@ -11,7 +21,7 @@
'show_option_none' => __( 'Choose an Order', 'woo-thank-you-page-nextmove-lite' ),
'options_cb' => array( 'XLWCTY_Admin_CMB2_Support', 'get_orders_cmb2' ),
'attributes' => array(
- 'data-pre-data' => wp_json_encode( XLWCTY_Admin_CMB2_Support::get_orders_cmb2( null, true ) ),
+ 'data-pre-data' => wp_json_encode( $xlwcty_debug_pre_data ),
)
),
array(
--- a/woo-thank-you-page-nextmove-lite/admin/includes/cmb2-settings-config.php
+++ b/woo-thank-you-page-nextmove-lite/admin/includes/cmb2-settings-config.php
@@ -73,7 +73,7 @@
'id' => 'ga_fb_pixel_id',
'desc' => __( 'Log into your facebook ads account to find your Pixel ID. <a href="https://www.facebook.com/ads/manager/pixel/facebook_pixel" target="_blank">Click here for more info</a>.', 'woo-thank-you-page-nextmove-lite' ),
'row_classes' => array( 'xlwcty_no_border', 'xlwcty_hide_label', 'xlwcty_pt0' ),
- 'before' => '<p>Facebook Pixel ID</p>',
+ 'before' => '<p>' . esc_html__( 'Facebook Pixel ID', 'woo-thank-you-page-nextmove-lite' ) . '</p>',
'type' => 'text',
'attributes' => array(
'data-conditional-id' => 'enable_fb_ecom_tracking',
@@ -144,7 +144,7 @@
'id' => 'ga_analytics_id',
'desc' => __( 'Log into your google analytics account to <a href="https://support.google.com/analytics/answer/1008080?hl=en#trackingID" target="_blank">find your ID</a>. eg: G-XXXXXXXX.', 'woo-thank-you-page-nextmove-lite' ),
'row_classes' => array( 'xlwcty_no_border', 'xlwcty_hide_label', 'xlwcty_pt0' ),
- 'before' => '<p>Note: GA4 must be activated in your Google Analytics account. To enable GA4 <a href="https://support.google.com/analytics/answer/9304153?hl=en&ref_topic=9303319" target="_blank">click here for more information.</a></p><p>Google Analytics ID</p>',
+ 'before' => '<p>' . __( 'Note: GA4 must be activated in your Google Analytics account. To enable GA4 <a href="https://support.google.com/analytics/answer/9304153?hl=en&ref_topic=9303319" target="_blank">click here for more information.</a>', 'woo-thank-you-page-nextmove-lite' ) . '</p><p>' . esc_html__( 'Google Analytics ID', 'woo-thank-you-page-nextmove-lite' ) . '</p>',
'after_row' => $ga_after_row_text,
'type' => 'text',
'attributes' => array(
--- a/woo-thank-you-page-nextmove-lite/admin/includes/pages/xl-automation.php
+++ b/woo-thank-you-page-nextmove-lite/admin/includes/pages/xl-automation.php
@@ -23,8 +23,8 @@
$desc = __( 'The All-In-One Email Marketing Platform For WordPress to Create Email Broadcasts and Automated Campaigns', 'woo-thank-you-page-nextmove-lite' );
?>
<section class="xl-top">
- <img class="img-top" src="<?php echo esc_url( $img ); ?>" alt="<?php esc_attr_e( $heading ); ?>"/>
- <h1><?php esc_attr_e( $heading ); ?></h1>
+ <img class="img-top" src="<?php echo esc_url( $img ); ?>" alt="<?php echo esc_attr( $heading ); ?>"/>
+ <h1><?php echo esc_html( $heading ); ?></h1>
<p><?php echo wp_kses_post( $desc ); ?></p>
</section>
<?php
@@ -69,7 +69,10 @@
<h1><?php esc_html_e( 'Install and Activate FunnelKit Automations', 'woo-thank-you-page-nextmove-lite' ); ?></h1>
<p><?php esc_html_e( 'Click on the button below to install and activate the FunnelKit Automations.', 'woo-thank-you-page-nextmove-lite' ); ?></p>
<button id="xl_install_button" class="button button-primary" data-xl-slug="wp-marketing-automations" data-xl-file="/wp-marketing-automations.php">
- <?php printf( __( 'Activate %s', 'woo-thank-you-page-nextmove-lite' ), 'FunnelKit Automations' ); ?>
+ <?php
+ /* translators: %s: plugin name */
+ printf( __( 'Activate %s', 'woo-thank-you-page-nextmove-lite' ), 'FunnelKit Automations' );
+ ?>
</button>
</div>
</section>
--- a/woo-thank-you-page-nextmove-lite/admin/includes/pages/xl-cart.php
+++ b/woo-thank-you-page-nextmove-lite/admin/includes/pages/xl-cart.php
@@ -23,8 +23,8 @@
$desc = __( 'Replace your default WooCommerce cart page with a modern sliding cart for direct checkout - Edit cart, Add upsells and set up a rewards system', 'woo-thank-you-page-nextmove-lite' );
?>
<section class="xl-top">
- <img class="img-top" src="<?php echo esc_url( $img ); ?>" alt="<?php esc_attr_e( $heading ); ?>"/>
- <h1><?php esc_attr_e( $heading ); ?></h1>
+ <img class="img-top" src="<?php echo esc_url( $img ); ?>" alt="<?php echo esc_attr( $heading ); ?>"/>
+ <h1><?php echo esc_html( $heading ); ?></h1>
<p><?php echo wp_kses_post( $desc ); ?></p>
</section>
<?php
--- a/woo-thank-you-page-nextmove-lite/admin/includes/pages/xl-checkout.php
+++ b/woo-thank-you-page-nextmove-lite/admin/includes/pages/xl-checkout.php
@@ -23,8 +23,8 @@
$desc = __( 'Customize WooCommerce Checkout Pages, Conversion Friendly Templates, Performance Stats & A/B Funnel Testing', 'woo-thank-you-page-nextmove-lite' );
?>
<section class="xl-top">
- <img class="img-top" src="<?php echo esc_url( $img ); ?>" alt="<?php esc_attr_e( $heading ); ?>"/>
- <h1><?php esc_attr_e( $heading ); ?></h1>
+ <img class="img-top" src="<?php echo esc_url( $img ); ?>" alt="<?php echo esc_attr( $heading ); ?>"/>
+ <h1><?php echo esc_html( $heading ); ?></h1>
<p><?php echo wp_kses_post( $desc ); ?></p>
</section>
<?php
--- a/woo-thank-you-page-nextmove-lite/admin/includes/pages/xl-stripe.php
+++ b/woo-thank-you-page-nextmove-lite/admin/includes/pages/xl-stripe.php
@@ -23,8 +23,8 @@
$desc = __( 'SCA-Ensured Secure Gateway to Accept Payments in WooCommerce, Quick Onboarding, Multiple Payment Methods and Recurring Subscriptions', 'woo-thank-you-page-nextmove-lite' );
?>
<section class="xl-top">
- <img class="img-top" src="<?php echo esc_url( $img ); ?>" alt="<?php esc_attr_e( $heading ); ?>"/>
- <h1><?php esc_attr_e( $heading ); ?></h1>
+ <img class="img-top" src="<?php echo esc_url( $img ); ?>" alt="<?php echo esc_attr( $heading ); ?>"/>
+ <h1><?php echo esc_html( $heading ); ?></h1>
<p><?php echo wp_kses_post( $desc ); ?></p>
</section>
<?php
--- a/woo-thank-you-page-nextmove-lite/admin/includes/upsell/class-xlwcty-upsell.php
+++ b/woo-thank-you-page-nextmove-lite/admin/includes/upsell/class-xlwcty-upsell.php
@@ -124,7 +124,7 @@
public function notice_enqueue_scripts() {
wp_enqueue_style( 'xlwcty-notices-css', plugin_dir_url( $this->plugin_path ) . 'admin/assets/css/xlwcty-xl-notice.css', array(), XLWCTY_VERSION );
wp_enqueue_script( 'wp-util' );
- wp_enqueue_script( 'xlwcty-notices.js', $this->get_admin_url() . '/assets/js/xlwcty-notices.min.js', XLWCTY_VERSION );
+ wp_enqueue_script( 'xlwcty-notices.js', $this->get_admin_url() . '/assets/js/xlwcty-notices.min.js', array( 'jquery', 'wp-util' ), XLWCTY_VERSION, true );
$xlwcty_notice_nonce = wp_create_nonce( 'xlwcty_notice_nonce' );
wp_localize_script( 'xlwcty-notices.js', 'xlwcty_notice_vars', array(
'nonce' => $xlwcty_notice_nonce,
@@ -472,7 +472,7 @@
) );
exit;
}
- $nonce = isset( $_POST['xli_nonce'] ) ? $_POST['xli_nonce'] : '';
+ $nonce = isset( $_POST['xli_nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['xli_nonce'] ) ) : '';
if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'xlwcty_notice_nonce' ) ) {
wp_send_json( array(
'status' => 'error',
@@ -480,12 +480,23 @@
) );
exit;
}
- if ( isset( $_POST['notice_displayed_count'] ) && ( '' != $_POST['notice_displayed_count'] ) ) {
- $notice_displayed_count = $_POST['notice_displayed_count'];
+ if ( isset( $_POST['notice_displayed_count'] ) && ( '+1' === wp_unslash( $_POST['notice_displayed_count'] ) ) ) {
+ $notice_displayed_count = '+1'; // "Later" snooze, handled by dismiss_notice().
+ } elseif ( isset( $_POST['notice_displayed_count'] ) && ( '' != $_POST['notice_displayed_count'] ) ) {
+ $notice_displayed_count = absint( $_POST['notice_displayed_count'] );
} else {
- $notice_displayed_count = '100';
+ $notice_displayed_count = 100;
}
- $this->dismiss_notice( $_POST['plugin'], $notice_displayed_count );
+ // Sanitize the plugin identifier — it is used to build an option/transient name.
+ $plugin = isset( $_POST['plugin'] ) ? sanitize_key( wp_unslash( $_POST['plugin'] ) ) : '';
+ if ( '' === $plugin ) {
+ wp_send_json( array(
+ 'status' => 'error',
+ 'message' => 'Invalid plugin.',
+ ) );
+ exit;
+ }
+ $this->dismiss_notice( $plugin, $notice_displayed_count );
wp_send_json_success();
}
@@ -532,34 +543,14 @@
var noticeWrap = $('#xl_notice_type_3');
var pluginShortSlug = noticeWrap.attr("data-plugin");
var pluginSlug = noticeWrap.attr("data-plugin-slug");
- $('body').on('click', '.xl-notice-dismiss', function (e) {
- e.preventDefault();
- var $this = $(this);
- var xlDisplayedMode = $this.attr("data-mode");
- if (xlDisplayedMode == 'dismiss') {
- xlDisplayedCount = '100';
- } else if (xlDisplayedMode == 'later') {
- xlDisplayedCount = '+1';
- }
- noticeWrap = $this.parents('#xl_notice_type_3');
- pluginShortSlug = noticeWrap.attr("data-plugin");
- pluginSlug = noticeWrap.attr("data-plugin-slug");
- wp.ajax.send('finale_upsells_dismiss', {
- data: {
- plugin: pluginShortSlug,
- notice_displayed_count: xlDisplayedCount,
- },
- });
- $this.closest('.updated').slideUp('fast', function () {
- $this.remove();
- });
- });
+ /** Dismiss / later clicks are handled by xlwcty-notices.js (nonce-protected nextmove_upsells_dismiss) */
$(document).on('wp-plugin-install-success', function (e, args) {
- if (args.slug == pluginSlug) {
- wp.ajax.send('finale_upsells_dismiss', {
+ if (args.slug == pluginSlug && typeof xlwcty_notice_vars !== 'undefined') {
+ wp.ajax.send('nextmove_upsells_dismiss', {
data: {
plugin: pluginShortSlug,
notice_displayed_count: '100',
+ xli_nonce: xlwcty_notice_vars.nonce,
},
});
}
--- a/woo-thank-you-page-nextmove-lite/admin/includes/xlwcty-admin-cmb2-support.php
+++ b/woo-thank-you-page-nextmove-lite/admin/includes/xlwcty-admin-cmb2-support.php
@@ -55,7 +55,7 @@
$xlwcty_notice = '<div class="xlwcty_error_notice">' . $field_args['xlwcty_error_notice']['error'] . '</div>';
}
- echo '<div class="cmb2_xlwcty_wrapper_ac" data-slug="' . $field_args['xlwcty_component'] . ( isset( $field_args['xlwcty_accordion_index'] ) ? '_' . $field_args['xlwcty_accordion_index'] : '' ) . '" data-title="' . trim( $field_args['xlwcty_accordion_title'] ) . '" data-component="' . $field_args['xlwcty_component'] . '" ><div class="cmb2_xlwcty_acc_head ' . $is_active . ' "><a href="javascript:void(0);">' . $field_args['xlwcty_accordion_title'] . '</a> <div class="toggleArrow"></div></div><div class="cmb2_xlwcty_wrapper_ac_data" ' . $is_display_none . '>' . $xlwcty_notice . '<div class="xlwcty_field_head">' . $field_args['xlwcty_accordion_title'] . ' <a href="javascript:void(0);" onclick="xlwcty_show_tb('' . $field_args['xlwcty_accordion_title'] . ' Settings','xlwcty_component_settings' . $field_args['xlwcty_component'] . '_help');"><i class="dashicons dashicons-warning"></i> See how it appears</a></div>';
+ echo '<div class="cmb2_xlwcty_wrapper_ac" data-slug="' . $field_args['xlwcty_component'] . ( isset( $field_args['xlwcty_accordion_index'] ) ? '_' . $field_args['xlwcty_accordion_index'] : '' ) . '" data-title="' . esc_attr( trim( $field_args['xlwcty_accordion_title'] ) ) . '" data-component="' . $field_args['xlwcty_component'] . '" ><div class="cmb2_xlwcty_acc_head ' . $is_active . ' "><a href="javascript:void(0);">' . esc_html( $field_args['xlwcty_accordion_title'] ) . '</a> <div class="toggleArrow"></div></div><div class="cmb2_xlwcty_wrapper_ac_data" ' . $is_display_none . '>' . $xlwcty_notice . '<div class="xlwcty_field_head">' . esc_html( $field_args['xlwcty_accordion_title'] ) . ' <a href="javascript:void(0);" onclick="xlwcty_show_tb('' . esc_js( sprintf( /* translators: %s: component title. */ __( '%s Settings', 'woo-thank-you-page-nextmove-lite' ), $field_args['xlwcty_accordion_title'] ) ) . '','xlwcty_component_settings' . $field_args['xlwcty_component'] . '_help');"><i class="dashicons dashicons-warning"></i> ' . esc_html__( 'See how it appears', 'woo-thank-you-page-nextmove-lite' ) . '</a></div>';
}
/**
--- a/woo-thank-you-page-nextmove-lite/admin/includes/xlwcty-admin-wcthankyou-options.php
+++ b/woo-thank-you-page-nextmove-lite/admin/includes/xlwcty-admin-wcthankyou-options.php
@@ -4,403 +4,411 @@
#[AllowDynamicProperties]
class XLWCTY_Admin_Post_Options {
- protected static $options_data = false;
+ protected static $options_data = false;
- /**
- * Option key, and option page slug
- * @var string
- */
- private static $key = 'xlwcty_post_option';
-
- /**
- * Options page metabox id
- * @var string
- */
- private static $metabox_id = 'xlwcty_post_option_metabox';
-
- /**
- * Setting Up CMB2 Fields
- */
- public static function setup_fields() {
-
- // single builder main fields metabox
- $box_options = array(
- 'id' => '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 .= '<br/><br/>' . __( '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 .= '<br/><br/>' . __( 'Need Help with priority? ', 'woo-thank-you-page-nextmove-lite' ) . '<a href="' . $priority_desc_link . '" target="_blank">';
- $priority_desc .= __( 'Read Docs', 'woo-thank-you-page-nextmove-lite' );
- $priority_desc .= '</a>';
-
- $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'] ) ? '<div class="xlwcty_field_head">' . $component['head'] . '</div><div class="xlwcty_field_wrap">' : '';
- 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 '<div class="xlwcty_field_btn' . $component_selected . ' ' . $is_mulpliple_gr_one . '" data-slug="' . $data_comp . $unique_id . '" data-component="' . $data_comp . '" >';
- if ( isset( $component['icon'] ) ) {
- echo '<div class="xlwcty_field_icon"><i class="' . $component['icon'] . '"></i></div>';
- } else {
- echo '<div class="xlwcty_field_icon"><i class="xlwcty-fa xlwcty-fa-cog"></i></div>';
- }
- echo '<p>' . $component['title'] . '</p>';
- echo $component_selected_html;
- if ( isset( $component['disabled'] ) ) {
- echo '<div class="xlwcty_lockicon"><i class="xlwcty-fa xlwcty-fa-lock"></i></div>';
- }
- echo '</div>';
- }
-
- if ( isset( $component['head_end'] ) && $multiple == true ) {
- if ( is_array( $is_multiple_arr_count ) && count( $is_multiple_arr_count ) > 0 ) {
- global $template_previews;
- ?>
+ /**
+ * Option key, and option page slug
+ * @var string
+ */
+ private static $key = 'xlwcty_post_option';
+
+ /**
+ * Options page metabox id
+ * @var string
+ */
+ private static $metabox_id = 'xlwcty_post_option_metabox';
+
+ /**
+ * Setting Up CMB2 Fields
+ */
+ public static function setup_fields() {
+
+ // single builder main fields metabox
+ $box_options = array(
+ 'id' => '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 .= '<br/><br/>' . __( '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 .= '<br/><br/>' . __( 'Need Help with priority? ', 'woo-thank-you-page-nextmove-lite' ) . '<a href="' . $priority_desc_link . '" target="_blank">';
+ $priority_desc .= __( 'Read Docs', 'woo-thank-you-page-nextmove-lite' );
+ $priority_desc .= '</a>';
+
+ $shortcode_box = array(
+ array(
+ 'id' => 'xlwcty_shortcode_metabox',
+ 'position' => 1,
+ 'fields' => array(
+ array(
+ 'name' => __( 'Page Priority', 'woo-thank-you-page-nextmove-lite' ),
+ '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();
+ $builder_post_id = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : 0;
+ if ( ! $builder_post_id ) {
+ return '';
+ }
+ 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( $builder_post_id, '_xlwcty_builder_layout', true );
+ $template = get_post_meta( $builder_post_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'] ) ? '<div class="xlwcty_field_head">' . $component['head'] . '</div><div class="xlwcty_field_wrap">' : '';
+ 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 '<div class="xlwcty_field_btn' . $component_selected . ' ' . $is_mulpliple_gr_one . '" data-slug="' . $data_comp . $unique_id . '" data-component="' . $data_comp . '" >';
+ if ( isset( $component['icon'] ) ) {
+ echo '<div class="xlwcty_field_icon"><i class="' . $component['icon'] . '"></i></div>';
+ } else {
+ echo '<div class="xlwcty_field_icon"><i class="xlwcty-fa xlwcty-fa-cog"></i></div>';
+ }
+ echo '<p>' . esc_html( $component['title'] ) . '</p>';
+ echo $component_selected_html;
+ if ( isset( $component['disabled'] ) ) {
+ echo '<div class="xlwcty_lockicon"><i class="xlwcty-fa xlwcty-fa-lock"></i></div>';
+ }
+ echo '</div>';
+ }
+
+ if ( isset( $component['head_end'] ) && $multiple == true ) {
+ if ( is_array( $is_multiple_arr_count ) && count( $is_multiple_arr_count ) > 0 ) {
+ global $template_previews;
+ ?>
<div class="xlwcty_field_btn xlwcty_add_more_ui">
<div class="xlwcty_add_more_items">
<i class="xlwcty-fa xlwcty-fa-plus"></i>
</div>
<div class="xlwcty_btn_layouts">
<ul>
- <?php
- foreach ( $is_multiple_arr_count as $key => $val ) {
- ?>
+ <?php
+ foreach ( $is_multiple_arr_count as $key => $val ) {
+