umber == $pagination ) ? 'current' : ''; $setPagination .= sprintf( "
  • %2\$d
  • ", $active, $pagination ); } } } else { for ( $pagination = 1; $pagination <= $pagination_Paginationlist; $pagination ++ ) { $active = ( $paginationNumber == $pagination ) ? 'current' : ''; $setPagination .= sprintf( "
  • %2\$d
  • ", $active, $pagination ); } } if ( $paginationNumber < $pagination_Paginationlist ) { $setPagination .= "
  • $next_label
  • "; } $setPagination .= ""; } printf( '%1$s', $setPagination ); wp_die(); } /** * Product Add to Cart * added product in cart through ajax * * @access public * @return void of a html markup with AJAX call. * @since unknown */ public function eael_product_add_to_cart() { $ajax = wp_doing_ajax(); $cart_items = isset( $_POST['cart_item_data'] ) ? $_POST['cart_item_data'] : []; $variation = []; if ( ! empty( $cart_items ) ) { foreach ( $cart_items as $key => $value ) { if ( preg_match( "/^attribute*/", $value['name'] ) ) { $variation[ $value['name'] ] = sanitize_text_field( $value['value'] ); } } } if ( isset( $_POST['product_data'] ) ) { foreach ( $_POST['product_data'] as $item ) { $product_id = isset( $item['product_id'] ) ? sanitize_text_field( $item['product_id'] ) : 0; $variation_id = isset( $item['variation_id'] ) ? sanitize_text_field( $item['variation_id'] ) : 0; $quantity = isset( $item['quantity'] ) ? sanitize_text_field( $item['quantity'] ) : 0; if ( $variation_id ) { WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, $variation ); } else { WC()->cart->add_to_cart( $product_id, $quantity ); } } } wp_send_json_success(); } /** * Woo Checkout Update Order Review * return order review data * * @access public * @return void * @since 4.0.0 */ public function woo_checkout_update_order_review() { $setting = $_POST['orderReviewData']; ob_start(); Woo_Checkout_Helper::checkout_order_review_default( $setting ); $woo_checkout_update_order_review = ob_get_clean(); wp_send_json( array( 'order_review' => $woo_checkout_update_order_review, ) ); } /** * Eael Product Quick View Popup * Retrieve product quick view data * * @access public * @return void * @since 4.0.0 */ public function eael_product_quickview_popup() { //check nonce check_ajax_referer( 'essential-addons-elementor', 'security' ); $widget_id = sanitize_key( $_POST['widget_id'] ); $product_id = absint( $_POST['product_id'] ); $page_id = absint( $_POST['page_id'] ); if ( $widget_id == '' && $product_id == '' && $page_id == '' ) { wp_send_json_error(); } global $post, $product; $product = wc_get_product( $product_id ); $post = get_post( $product_id ); setup_postdata( $post ); $settings = $this->eael_get_widget_settings( $page_id, $widget_id ); ob_start(); HelperClass::eael_product_quick_view( $product, $settings, $widget_id ); $data = ob_get_clean(); wp_reset_postdata(); wp_send_json_success( $data ); } /** * Ajax Eael Product Gallery * Retrieve product quick view data * * @access public * @return false|void * @since 4.0.0 */ public function ajax_eael_product_gallery() { $ajax = wp_doing_ajax(); wp_parse_str( $_POST['args'], $args ); $args['post_status'] = 'publish'; if ( isset( $args['date_query']['relation'] ) ) { $args['date_query']['relation'] = HelperClass::eael_sanitize_relation( $args['date_query']['relation'] ); } if ( empty( $_POST['nonce'] ) ) { $err_msg = __( 'Insecure form submitted without security token', 'essential-addons-for-elementor-lite' ); if ( $ajax ) { wp_send_json_error( $err_msg ); } return false; } if ( ! wp_verify_nonce( $_POST['nonce'], 'eael_product_gallery' ) ) { $err_msg = __( 'Security token did not match', 'essential-addons-for-elementor-lite' ); if ( $ajax ) { wp_send_json_error( $err_msg ); } return false; } if ( ! empty( $_POST['page_id'] ) ) { $page_id = intval( $_POST['page_id'], 10 ); } else { $err_msg = __( 'Page ID is missing', 'essential-addons-for-elementor-lite' ); if ( $ajax ) { wp_send_json_error( $err_msg ); } return false; } if ( ! empty( $_POST['widget_id'] ) ) { $widget_id = sanitize_text_field( $_POST['widget_id'] ); } else { $err_msg = __( 'Widget ID is missing', 'essential-addons-for-elementor-lite' ); if ( $ajax ) { wp_send_json_error( $err_msg ); } return false; } $settings = HelperClass::eael_get_widget_settings( $page_id, $widget_id ); if ( empty( $settings ) ) { wp_send_json_error( [ 'message' => __( 'Widget settings are not found. Did you save the widget before using load more??', 'essential-addons-for-elementor-lite' ) ] ); } if ( $widget_id == '' && $page_id == '' ) { wp_send_json_error(); } $settings['eael_widget_id'] = $widget_id; $settings['eael_page_id'] = $page_id; $args['offset'] = (int) $args['offset'] + ( ( (int) $_REQUEST['page'] - 1 ) * (int) $args['posts_per_page'] ); if ( isset( $_REQUEST['taxonomy'] ) && isset( $_REQUEST['taxonomy']['taxonomy'] ) && $_REQUEST['taxonomy']['taxonomy'] != 'all' ) { $args['tax_query'] = [ $this->sanitize_taxonomy_data( $_REQUEST['taxonomy'] ), ]; $args['tax_query'] = $this->eael_terms_query_multiple( $args['tax_query'] ); if ( $settings[ 'eael_product_gallery_product_filter' ] == 'featured-products' ) { $args[ 'tax_query' ][] = [ 'relation' => 'AND', [ 'taxonomy' => 'product_visibility', 'field' => 'name', 'terms' => 'featured', ], [ 'taxonomy' => 'product_visibility', 'field' => 'name', 'terms' => [ 'exclude-from-search', 'exclude-from-catalog' ], 'operator' => 'NOT IN', ], ]; } } $template_info = $this->eael_sanitize_template_param( $_REQUEST['template_info'] ); if ( $template_info ) { if ( $template_info['dir'] === 'theme' ) { $dir_path = $this->retrive_theme_path(); } else if ( $template_info['dir'] === 'pro' ) { $dir_path = sprintf( "%sincludes", EAEL_PRO_PLUGIN_PATH ); } else { $dir_path = sprintf( "%sincludes", EAEL_PLUGIN_PATH ); } $file_path = realpath( sprintf( '%s/Template/%s/%s', $dir_path, $template_info['name'], $template_info['file_name'] ) ); if ( ! $file_path || 0 !== strpos( $file_path, realpath( $dir_path ) ) ) { wp_send_json_error( 'Invalid template', 'invalid_template', 400 ); } $html = ''; if ( $file_path ) { $query = new \WP_Query( $args ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); $html .= HelperClass::include_with_variable( $file_path, [ 'settings' => $settings ] ); } $html .= ''; printf( '%1$s', $html ); wp_reset_postdata(); } } } wp_die(); } public function eael_terms_query_multiple( $args_tax_query = [] ){ if ( strpos($args_tax_query[0]['taxonomy'], '|') !== false ) { $args_tax_query_item = $args_tax_query[0]; //Query for category and tag $args_multiple['tax_query'] = []; if( isset( $args_tax_query_item['terms'] ) ){ $args_multiple['tax_query'][] = [ 'taxonomy' => 'product_cat', 'field' => 'term_id', 'terms' => $args_tax_query_item['terms'], ]; } if( isset( $args_tax_query_item['terms_tag'] ) ){ $args_multiple['tax_query'][] = [ 'taxonomy' => 'product_tag', 'field' => 'term_id', 'terms' => $args_tax_query_item['terms_tag'], ]; } if ( count( $args_multiple['tax_query'] ) ) { $args_multiple['tax_query']['relation'] = 'OR'; } $args_tax_query = $args_multiple['tax_query']; } if( isset( $args_tax_query[0]['terms_tag'] ) ){ if( 'product_tag' === $args_tax_query[0]['taxonomy'] ){ $args_tax_query[0]['terms'] = $args_tax_query[0]['terms_tag']; } unset($args_tax_query[0]['terms_tag']); } return $args_tax_query; } /** * Select2 Ajax Posts Filter Autocomplete * Fetch post/taxonomy data and render in Elementor control select2 ajax search box * * @access public * @return void * @since 4.0.0 */ public function select2_ajax_posts_filter_autocomplete() { $post_type = 'post'; $source_name = 'post_type'; if ( ! empty( $_POST['post_type'] ) ) { $post_type = sanitize_text_field( $_POST['post_type'] ); } if ( ! empty( $_POST['source_name'] ) ) { $source_name = sanitize_text_field( $_POST['source_name'] ); } $search = ! empty( $_POST['term'] ) ? sanitize_text_field( $_POST['term'] ) : ''; $results = $post_list = []; switch ( $source_name ) { case 'taxonomy': $args = [ 'hide_empty' => false, 'orderby' => 'name', 'order' => 'ASC', 'search' => $search, 'number' => '5', ]; if ( $post_type !== 'all' ) { $args['taxonomy'] = $post_type; } $post_list = wp_list_pluck( get_terms( $args ), 'name', 'term_id' ); break; case 'user': if ( ! current_user_can( 'list_users' ) ) { $post_list = []; break; } $users = []; foreach ( get_users( [ 'search' => "*{$search}*" ] ) as $user ) { $user_id = $user->ID; $user_name = $user->display_name; $users[ $user_id ] = $user_name; } $post_list = $users; break; default: $post_list = HelperClass::get_query_post_list( $post_type, 10, $search ); } if ( ! empty( $post_list ) ) { foreach ( $post_list as $key => $item ) { $results[] = [ 'text' => $item, 'id' => $key ]; } } wp_send_json( [ 'results' => $results ] ); } /** * Select2 Ajax Get Posts Value Titles * get selected value to show elementor editor panel in select2 ajax search box * * @access public * @return void * @since 4.0.0 */ public function select2_ajax_get_posts_value_titles() { if ( empty( $_POST['id'] ) ) { wp_send_json_error( [] ); } if ( empty( array_filter( $_POST['id'] ) ) ) { wp_send_json_error( [] ); } $ids = array_map( 'intval', $_POST['id'] ); $source_name = ! empty( $_POST['source_name'] ) ? sanitize_text_field( $_POST['source_name'] ) : ''; switch ( $source_name ) { case 'taxonomy': $args = [ 'hide_empty' => false, 'orderby' => 'name', 'order' => 'ASC', 'include' => implode( ',', $ids ), ]; if ( $_POST['post_type'] !== 'all' ) { $args['taxonomy'] = sanitize_text_field( $_POST['post_type'] ); } $response = wp_list_pluck( get_terms( $args ), 'name', 'term_id' ); break; case 'user': $users = []; foreach ( get_users( [ 'include' => $ids ] ) as $user ) { $user_id = $user->ID; $user_name = $user->display_name; $users[ $user_id ] = $user_name; } $response = $users; break; default: $post_info = get_posts( [ 'post_type' => sanitize_text_field( $_POST['post_type'] ), 'include' => implode( ',', $ids ) ] ); $response = wp_list_pluck( $post_info, 'post_title', 'ID' ); } if ( ! empty( $response ) ) { wp_send_json_success( [ 'results' => $response ] ); } else { wp_send_json_error( [] ); } } /** * Save Settings * Save EA settings data through ajax request * * @access public * @return void * @since 1.1.2 */ public function save_settings() { check_ajax_referer( 'essential-addons-elementor', 'security' ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( __( 'you are not allowed to do this action', 'essential-addons-for-elementor-lite' ) ); } if ( ! isset( $_POST['fields'] ) ) { return; } wp_parse_str( $_POST['fields'], $settings ); if ( ! empty( $_POST['is_login_register'] ) ) { // Saving Login | Register Related Data if ( isset( $settings['recaptchaSiteKey'] ) ) { update_option( 'eael_recaptcha_sitekey', sanitize_text_field( $settings['recaptchaSiteKey'] ) ); } if ( isset( $settings['recaptchaSiteSecret'] ) ) { update_option( 'eael_recaptcha_secret', sanitize_text_field( $settings['recaptchaSiteSecret'] ) ); } if ( isset( $settings['recaptchaLanguage'] ) ) { update_option( 'eael_recaptcha_language', sanitize_text_field( $settings['recaptchaLanguage'] ) ); } //reCAPTCHA V3 if ( isset( $settings['recaptchaSiteKeyV3'] ) ) { update_option( 'eael_recaptcha_sitekey_v3', sanitize_text_field( $settings['recaptchaSiteKeyV3'] ) ); } if ( isset( $settings['recaptchaSiteSecretV3'] ) ) { update_option( 'eael_recaptcha_secret_v3', sanitize_text_field( $settings['recaptchaSiteSecretV3'] ) ); } if ( isset( $settings['recaptchaLanguageV3'] ) ) { update_option( 'eael_recaptcha_language_v3', sanitize_text_field( $settings['recaptchaLanguageV3'] ) ); } //pro settings if ( isset( $settings['gClientId'] ) ) { update_option( 'eael_g_client_id', sanitize_text_field( $settings['gClientId'] ) ); } if ( isset( $settings['fbAppId'] ) ) { update_option( 'eael_fb_app_id', sanitize_text_field( $settings['fbAppId'] ) ); } if ( isset( $settings['fbAppSecret'] ) ) { update_option( 'eael_fb_app_secret', sanitize_text_field( $settings['fbAppSecret'] ) ); } wp_send_json_success( [ 'message' => __( 'Login | Register Settings updated', 'essential-addons-for-elementor-lite' ) ] ); } //Login-register data if ( isset( $settings['lr_recaptcha_sitekey'] ) ) { update_option( 'eael_recaptcha_sitekey', sanitize_text_field( $settings['lr_recaptcha_sitekey'] ) ); } if ( isset( $settings['lr_recaptcha_secret'] ) ) { update_option( 'eael_recaptcha_secret', sanitize_text_field( $settings['lr_recaptcha_secret'] ) ); } if ( isset( $settings['lr_recaptcha_language'] ) ) { update_option( 'eael_recaptcha_language', sanitize_text_field( $settings['lr_recaptcha_language'] ) ); } //reCAPTCHA v3 if ( isset( $settings['lr_recaptcha_sitekey_v3'] ) ) { update_option( 'eael_recaptcha_sitekey_v3', sanitize_text_field( $settings['lr_recaptcha_sitekey_v3'] ) ); } if ( isset( $settings['lr_recaptcha_secret_v3'] ) ) { update_option( 'eael_recaptcha_secret_v3', sanitize_text_field( $settings['lr_recaptcha_secret_v3'] ) ); } if ( isset( $settings['lr_recaptcha_language_v3'] ) ) { update_option( 'eael_recaptcha_language_v3', sanitize_text_field( $settings['lr_recaptcha_language_v3'] ) ); } if ( isset( $settings['lr_custom_profile_fields'] ) ) { update_option( 'eael_custom_profile_fields', sanitize_text_field( $settings['lr_custom_profile_fields'] ) ); } else { update_option( 'eael_custom_profile_fields', '' ); } if ( isset( $settings['lr_custom_profile_fields_text'] ) ) { update_option( 'eael_custom_profile_fields_text', sanitize_text_field( $settings['lr_custom_profile_fields_text'] ) ); } else { update_option( 'eael_custom_profile_fields_text', '' ); } if ( isset( $settings['lr_custom_profile_fields_img'] ) ) { update_option( 'eael_custom_profile_fields_img', sanitize_text_field( $settings['lr_custom_profile_fields_img'] ) ); } else { update_option( 'eael_custom_profile_fields_img', '' ); } //pro settings if ( isset( $settings['lr_g_client_id'] ) ) { update_option( 'eael_g_client_id', sanitize_text_field( $settings['lr_g_client_id'] ) ); } if ( isset( $settings['lr_fb_app_id'] ) ) { update_option( 'eael_fb_app_id', sanitize_text_field( $settings['lr_fb_app_id'] ) ); } if ( isset( $settings['lr_fb_app_secret'] ) ) { update_option( 'eael_fb_app_secret', sanitize_text_field( $settings['lr_fb_app_secret'] ) ); } // Business Reviews : Saving Google Place Api Key if ( isset( $settings['br_google_place_api_key'] ) ) { update_option( 'eael_br_google_place_api_key', sanitize_text_field( $settings['br_google_place_api_key'] ) ); } // Saving Google Map Api Key if ( isset( $settings['google-map-api'] ) ) { update_option( 'eael_save_google_map_api', sanitize_text_field( $settings['google-map-api'] ) ); } // Saving Mailchimp Api Key if ( isset( $settings['mailchimp-api'] ) ) { update_option( 'eael_save_mailchimp_api', sanitize_text_field( $settings['mailchimp-api'] ) ); } // Saving Mailchimp Api Key for EA Login | Register Form if ( isset( $settings['lr_mailchimp_api_key'] ) ) { update_option( 'eael_lr_mailchimp_api_key', sanitize_text_field( $settings['lr_mailchimp_api_key'] ) ); } // Saving TYpeForm token if ( isset( $settings['typeform-personal-token'] ) ) { update_option( 'eael_save_typeform_personal_token', sanitize_text_field( $settings['typeform-personal-token'] ) ); } // Saving Duplicator Settings if ( isset( $settings['post-duplicator-post-type'] ) ) { update_option( 'eael_save_post_duplicator_post_type', sanitize_text_field( $settings['post-duplicator-post-type'] ) ); } // save js print method if ( isset( $settings['eael-js-print-method'] ) ) { update_option( 'eael_js_print_method', sanitize_text_field( $settings['eael-js-print-method'] ) ); } $settings = array_map( 'sanitize_text_field', $settings ); $defaults = array_fill_keys( array_keys( array_merge( $this->registered_elements, $this->registered_extensions ) ), false ); $elements = array_merge( $defaults, array_fill_keys( array_keys( array_intersect_key( $settings, $defaults ) ), true ) ); // update new settings $updated = update_option( 'eael_save_settings', $elements ); // clear assets files $this->empty_dir( EAEL_ASSET_PATH ); wp_send_json( $updated ); } /** * Clear Cache Files * Clear cache files from uploads/essential-addons-elementor * * @access public * @return void * @since 3.0.0 */ public function clear_cache_files() { check_ajax_referer( 'essential-addons-elementor', 'security' ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( __( 'you are not allowed to do this action', 'essential-addons-for-elementor-lite' ) ); } if ( isset( $_REQUEST['posts'] ) ) { if ( ! empty( $_POST['posts'] ) ) { foreach ( json_decode( $_POST['posts'] ) as $post ) { $this->remove_files( 'post-' . $post ); } } } else { // clear cache files $this->empty_dir( EAEL_ASSET_PATH ); if ( $this->is_activate_elementor() ) { \Elementor\Plugin::$instance->files_manager->clear_cache(); } } // Purge All LS Cache do_action( 'litespeed_purge_all', '3rd Essential Addons for Elementor' ); // After clear the cache hook do_action( 'eael_after_clear_cache_files' ); wp_send_json( true ); } public function eael_admin_promotion(){ check_ajax_referer( 'essential-addons-elementor', 'security' ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( __( 'you are not allowed to do this action', 'essential-addons-for-elementor-lite' ) ); } update_option( 'eael_admin_promotion', self::EAEL_PROMOTION_FLAG ); } /** * Get nonce token through ajax request * * @since 5.1.13 * @return void */ public function eael_get_token() { $nonce = wp_create_nonce( 'essential-addons-elementor' ); if ( $nonce ) { wp_send_json_success( [ 'nonce' => $nonce ] ); } wp_send_json_error( __( 'you are not allowed to do this action', 'essential-addons-for-elementor-lite' ) ); } public function eael_yith_wcwl_ajax_disable( $request ) { add_filter( 'option_yith_wcwl_ajax_enable', function ( $data ) { return 'no'; } ); } }