have_posts() ) { if ( $class === '\Essential_Addons_Elementor\Elements\Product_Grid' && boolval( $settings[ 'show_add_to_cart_custom_text' ] ) ) { $add_to_cart_text = [ 'add_to_cart_simple_product_button_text' => $settings[ 'add_to_cart_simple_product_button_text' ], 'add_to_cart_variable_product_button_text' => $settings[ 'add_to_cart_variable_product_button_text' ], 'add_to_cart_grouped_product_button_text' => $settings[ 'add_to_cart_grouped_product_button_text' ], 'add_to_cart_external_product_button_text' => $settings[ 'add_to_cart_external_product_button_text' ], 'add_to_cart_default_product_button_text' => $settings[ 'add_to_cart_default_product_button_text' ], ]; $this->change_add_to_cart_text($add_to_cart_text); } if ( $class === '\Essential_Addons_Elementor\Pro\Elements\Post_List' ) { // $html .= '
'; } while ( $query->have_posts() ) { $query->the_post(); $html .= HelperClass::include_with_variable( $file_path, [ 'settings' => $settings, 'iterator' => $iterator ] ); $iterator++; } if ( $class === '\Essential_Addons_Elementor\Pro\Elements\Post_List' ) { // $html .= '
'; } } } } echo $html; wp_die(); } /** * Woo Checkout */ public function woo_checkout_update_order_review() { $setting = $_POST[ 'orderReviewData' ]; ob_start(); Woo_Checkout::checkout_order_review_default( $setting ); $woo_checkout_update_order_review = ob_get_clean(); wp_send_json( array( 'order_review' => $woo_checkout_update_order_review, ) ); } /** Filter to add plugins to the TOC list. * * @param array TOC plugins. * * @return mixed * @since 3.9.3 */ public function toc_rank_math_support( $toc_plugins ) { $toc_plugins[ 'essential-addons-for-elementor-lite/essential_adons_elementor.php' ] = __( 'Essential Addons for Elementor', 'essential-addons-for-elementor-lite' ); return $toc_plugins; } /** * Save typeform access token * * @since 4.0.2 */ public function typeform_auth_handle() { $post = $_POST; if ( isset( $post[ 'typeform_tk' ] ) && isset( $post[ 'pr_code' ] ) ) { if ( wp_hash( 'eael_typeform' ) === $post[ 'pr_code' ] ) { update_option( 'eael_save_typeform_personal_token', sanitize_text_field( $post[ 'typeform_tk' ] ) ); } } wp_send_json_success( [ 'status' => 'success' ] ); } /***************************** * * Compatibility for Pro * * @since 4.2.4 */ public function eael_get_page_templates( $type = null ) { return HelperClass::get_elementor_templates( $type ); } public function eael_query_controls() { return do_action( 'eael/controls/query', $this ); } public function eael_layout_controls() { return do_action( 'eael/controls/layout', $this ); } public function eael_load_more_button_style() { return do_action( 'eael/controls/load_more_button_style', $this ); } public function eael_read_more_button_style() { return do_action( 'eael/controls/read_more_button_style', $this ); } public function eael_controls_custom_positioning( $_1, $_2, $_3, $_4 ) { return do_action( 'eael/controls/custom_positioning', $this, $_1, $_2, $_3, $_4 ); } public function eael_get_all_types_post() { return HelperClass::get_post_types(); } public function eael_get_pages() { return HelperClass::get_post_list( 'page' ); } public function eael_woocommerce_product_categories_by_id() { return HelperClass::get_terms_list( 'product_cat' ); } public function fix_old_query( $settings ) { return HelperClass::fix_old_query( $settings ); } public function eael_get_query_args( $settings ) { return HelperClass::get_query_args( $settings ); } public function eael_get_tags( $args ) { return HelperClass::get_tags_list( $args ); } public function eael_get_taxonomies_by_post( $args ) { return HelperClass::get_taxonomies_by_post( $args ); } public function twitter_feed_render_items( $id, $settings, $class = '' ) { $token = get_option( $id . '_' . $settings[ 'eael_twitter_feed_ac_name' ] . '_tf_token' ); $items = get_transient( $id . '_' . $settings[ 'eael_twitter_feed_ac_name' ] . '_tf_cache' ); $html = ''; if ( empty( $settings[ 'eael_twitter_feed_consumer_key' ] ) || empty( $settings[ 'eael_twitter_feed_consumer_secret' ] ) ) { return; } if ( $items === false ) { if ( empty( $token ) ) { $credentials = base64_encode( $settings[ 'eael_twitter_feed_consumer_key' ] . ':' . $settings[ 'eael_twitter_feed_consumer_secret' ] ); add_filter( 'https_ssl_verify', '__return_false' ); $response = wp_remote_post( 'https://api.twitter.com/oauth2/token', [ 'method' => 'POST', 'httpversion' => '1.1', 'blocking' => true, 'headers' => [ 'Authorization' => 'Basic ' . $credentials, 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8', ], 'body' => [ 'grant_type' => 'client_credentials' ], ] ); $body = json_decode( wp_remote_retrieve_body( $response ) ); if ( $body ) { update_option( $id . '_' . $settings[ 'eael_twitter_feed_ac_name' ] . '_tf_token', $body->access_token ); $token = $body->access_token; } } $args = array( 'httpversion' => '1.1', 'blocking' => true, 'headers' => array( 'Authorization' => "Bearer $token", ), ); add_filter( 'https_ssl_verify', '__return_false' ); $response = wp_remote_get( 'https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=' . $settings[ 'eael_twitter_feed_ac_name' ] . '&count=999&tweet_mode=extended', [ 'httpversion' => '1.1', 'blocking' => true, 'headers' => [ 'Authorization' => "Bearer $token", ], ] ); if ( !is_wp_error( $response ) ) { $items = json_decode( wp_remote_retrieve_body( $response ), true ); set_transient( $id . '_' . $settings[ 'eael_twitter_feed_ac_name' ] . '_tf_cache', $items, 1800 ); } } if ( empty( $items ) ) { return; } if ( $settings[ 'eael_twitter_feed_hashtag_name' ] ) { foreach ( $items as $key => $item ) { $match = false; if ( $item[ 'entities' ][ 'hashtags' ] ) { foreach ( $item[ 'entities' ][ 'hashtags' ] as $tag ) { if ( strcasecmp( $tag[ 'text' ], $settings[ 'eael_twitter_feed_hashtag_name' ] ) == 0 ) { $match = true; } } } if ( $match == false ) { unset( $items[ $key ] ); } } } $items = array_splice( $items, 0, $settings[ 'eael_twitter_feed_post_limit' ] ); foreach ( $items as $item ) { $delimeter = strlen( $item[ 'full_text' ] ) > $settings[ 'eael_twitter_feed_content_length' ] ? '...' : ''; $html .= '
' . ( isset( $item[ 'extended_entities' ][ 'media' ][ 0 ] ) && $settings[ 'eael_twitter_feed_media' ] == 'true' ? ( $item[ 'extended_entities' ][ 'media' ][ 0 ][ 'type' ] == 'photo' ? '' : '' ) : '' ) . '
'; } return $html; } public function select2_ajax_posts_filter_autocomplete() { $post_type = 'post'; if ( !empty( $_GET[ 'post_type' ] ) ) { $post_type = sanitize_text_field( $_GET[ 'post_type' ] ); } $search = !empty( $_GET[ 'term' ] ) ? sanitize_text_field( $_GET[ 'term' ] ) : ''; $results = []; $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 ] ); } public function select2_ajax_get_posts_value_titles() { if ( empty( $_POST[ 'id' ] ) ) { wp_send_json_error( [] ); } $id = sanitize_text_field( $_POST[ 'id' ] ); $post_info = get_post( $id ); if ( $post_info ) { wp_send_json_success( [ 'id' => $id, 'text' => $post_info->post_title ] ); } else { wp_send_json_error( [] ); } } public function eael_product_grid_script(){ if ( version_compare( WC()->version, '3.0.0', '>=' ) ) { if ( current_theme_supports( 'wc-product-gallery-zoom' ) ) { wp_enqueue_script( 'zoom' ); } if ( current_theme_supports( 'wc-product-gallery-slider' ) ) { wp_enqueue_script( 'flexslider' ); } if ( current_theme_supports( 'wc-product-gallery-lightbox' ) ) { wp_enqueue_script( 'photoswipe-ui-default' ); wp_enqueue_style( 'photoswipe-default-skin' ); if ( has_action( 'wp_footer', 'woocommerce_photoswipe' ) === false ) { add_action( 'wp_footer', 'woocommerce_photoswipe', 15 ); } } wp_enqueue_script( 'wc-add-to-cart-variation' ); wp_enqueue_script( 'wc-single-product' ); } } /** * Rating Markup */ public function eael_rating_markup( $html, $rating, $count ) { if ( 0 == $rating ) { $html = '
'; $html .= wc_get_star_rating_html( $rating, $count ); $html .= '
'; } return $html; } public function eael_woo_pagination_product_ajax() { parse_str($_REQUEST['args'], $args); parse_str($_REQUEST['settings'], $settings); $paginationNumber = absint($_POST['number']); $paginationLimit = absint($_POST['limit']); $args['posts_per_page'] = $paginationLimit; if( $paginationNumber == "1" ){ $paginationOffsetValue = "0"; }else{ $paginationOffsetValue = ($paginationNumber-1)*$paginationLimit; $args['offset'] = $paginationOffsetValue; } $template_info = $_REQUEST['templateInfo']; $this->set_widget_name( $template_info['name'] ); $template = $this->get_template( $template_info['file_name'] ); ob_start(); $query = new \WP_Query( $args ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); include( $template ); } } echo ob_get_clean(); wp_die(); } public function eael_woo_pagination_ajax() { parse_str($_REQUEST['args'], $args); parse_str($_REQUEST['settings'], $settings); $class = '\Essential_Addons_Elementor\Elements\Product_Grid'; global $wpdb; $paginationNumber = absint($_POST['number']); $paginationLimit = absint($_POST['limit']); $pagination_args = $args; $pagination_args['posts_per_page'] = -1; $pagination_Query = new \WP_Query( $pagination_args ); $pagination_Count = count($pagination_Query->posts); $pagination_Paginationlist = ceil($pagination_Count/$paginationLimit); $last = ceil( $pagination_Paginationlist ); $paginationprev = $paginationNumber-1; $paginationnext = $paginationNumber+1; if( $paginationNumber>1 ){ $paginationprev; } if( $paginationNumber < $last ){ $paginationnext; } $adjacents = "2"; $widget_id = $settings['eael_widget_id']; $next_label = $settings['pagination_next_label']; $prev_label = $settings['pagination_prev_label']; $setPagination = ""; if( $pagination_Paginationlist > 0 ){ $setPagination .=""; } echo $setPagination; wp_die(); } public function eael_product_add_to_cart () { $ajax = wp_doing_ajax(); 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 ); } else { WC()->cart->add_to_cart( $product_id, $quantity ); } } } wp_send_json_success(); } public function change_add_to_cart_text( $add_to_cart_text ) { add_filter( 'woocommerce_product_add_to_cart_text', function ( $default ) use ( $add_to_cart_text ) { global $product; switch ( $product->get_type() ) { case 'external': return $add_to_cart_text[ 'add_to_cart_external_product_button_text' ]; break; case 'grouped': return $add_to_cart_text[ 'add_to_cart_grouped_product_button_text' ]; break; case 'simple': return $add_to_cart_text[ 'add_to_cart_simple_product_button_text' ]; break; case 'variable': return $add_to_cart_text[ 'add_to_cart_variable_product_button_text' ]; break; default: return $default; } } ); } }