From cc711702c89d5a0e83b113fd29a5e31d414c009a Mon Sep 17 00:00:00 2001 From: Saiful Islam Date: Mon, 24 May 2021 15:36:06 +0600 Subject: [PATCH 1/9] wpt_args_manage_by_get_args() added for manage qury_args using filter hook --- includes/functions.php | 69 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/includes/functions.php b/includes/functions.php index e92501b2..127d6c5b 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -1101,6 +1101,75 @@ function wpt_args_manipulation_frontend( $args ){ } add_filter( 'wpto_table_query_args', 'wpt_args_manipulation_frontend' ); + +if( ! function_exists( 'wpt_args_manage_by_get_args' ) ){ + + /** + * Manage Query Args based on link + * using Supper Global $_GET + * + * @since 2.8.9 + * @param type $args + * @return Array + */ + function wpt_args_manage_by_get_args( $args, $table_ID ){ + //var_dump($args); + /** + * Check WooCommerce Archive Page, such product taxonomy + * show page, search page. etc + */ + if( is_shop() || is_product_taxonomy() || empty( $_GET ) ){ + return $args; + } + + /** + * Check if already not set table id in link + */ + if( isset( $_GET['table_ID'] ) && $_GET['table_ID'] != $table_ID ){ + return $args; + } + + $MY_GETS = $_GET; + + if( isset( $_GET['search_key'] ) && ! empty( $_GET['search_key'] ) ){ + $MY_GETS['s'] = $_GET['search_key']; + unset($MY_GETS['search_key']); + } + + /** + * Handle Tax Query + */ + if( isset( $_GET['tax'] ) && ! empty( $_GET['tax'] ) ){ + $tax = $_GET['tax']; + $tax = stripslashes( $tax ); + $tax = json_decode($tax,true); + + $MY_GETS['tax_query'] = $tax; + unset( $MY_GETS['tax'] ); + } + + + /** + * Handle Meta Query + */ + if( isset( $_GET['meta'] ) && ! empty( $_GET['meta'] ) ){ + $meta = $_GET['meta']; + $meta = stripslashes( $meta ); + $meta = json_decode($meta,true); + + $MY_GETS['meta_query'] = $meta; + unset( $MY_GETS['meta'] ); + } + + $args = array_merge($args,$MY_GETS); + + return $args; + } +} +add_filter( 'wpto_table_query_args', 'wpt_args_manage_by_get_args', 10, 2 ); + + + if( !function_exists( 'wpt_freeze_column_maintain' ) ){ /** From 4df4adfd8ae882857b5f466cab73215c94246b0b Mon Sep 17 00:00:00 2001 From: Saiful Islam Date: Mon, 24 May 2021 15:39:17 +0600 Subject: [PATCH 2/9] query wise link generating also added two hook --- assets/js/custom.js | 66 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/assets/js/custom.js b/assets/js/custom.js index 2c3dc69b..bfcce5b3 100644 --- a/assets/js/custom.js +++ b/assets/js/custom.js @@ -1222,6 +1222,13 @@ var temp_number = thisID.replace('table_id_',''); $('#wpt_query_search_button_' + temp_number).trigger('click'); }); + + $('body').on('change','select.query_box_direct_value',function(){ + var thisID = $(this).parents('.wpt_product_table_wrapper').attr('id'); + var temp_number = thisID.replace('table_id_',''); + $('#wpt_query_search_button_' + temp_number).trigger('click'); + }); + /** * Search Box Query and Scripting Here * @since 1.9 @@ -1335,9 +1342,10 @@ targetTableArgs.args.meta_query = targetTableArgsBackup.args.meta_query; } - + //Display Loading on before load targetTableBody.prepend("
" + config_json.loading_more_text + "
"); //Laoding.. + $(document.body).trigger('wpt_query_progress',targetTableArgs); $.ajax({ type: 'POST', url: ajax_url,// + get_data, @@ -1357,6 +1365,29 @@ loadMiniFilter(); //@Since 4.8 fixAfterAjaxLoad(); $('div.wpt_loader_text').remove(); + + /** + * Link Generating here, based on Query + * + * @type String + * @since 2.8.9 + */ + var extra_link_tax_cf = ""; + if( !$.isEmptyObject(texonomies)){ + extra_link_tax_cf = "tax=" + JSON.stringify(targetTableArgs.args.tax_query) + } + if( !$.isEmptyObject(custom_field)){ + extra_link_tax_cf = "meta=" + JSON.stringify(targetTableArgs.args.meta_query) + } + + generat_url_by_search_query(temp_number, extra_link_tax_cf); + + /** + * Trigger on this event, when search will be completed + * + * @since 2.8.9 + */ + $(document.body).trigger('wpt_query_done',targetTableArgs); }, success: function(data) { @@ -1400,6 +1431,7 @@ targetTable.attr('data-page_number',pageNumber); }, error: function() { + $(document.body).trigger('wpt_query_faild',targetTableArgs); console.log("Error On Ajax Query Load. Please check console. - wpt_query_search_button"); }, }); @@ -1408,6 +1440,38 @@ }); + + /** + * Link Generator Based On Query String + * + * @since 2.8.9 + * @param {type} table_id + * @returns {undefined} + */ + function generat_url_by_search_query( table_id = 0, extra = '' ){ + var key,value; + var link = window.location.origin + window.location.pathname + "?table_ID=" + table_id + "&"; + $('.query_box_direct_value').each(function(){ + key = $(this).attr('data-key'); + if(key === 's'){ + key = 'search_key'; + } + value = $(this).val(); + if(value !== ''){ + link += key + "=" + value + "&"; + } + + }); + var page_number = $('#table_id_' + table_id + ' table').attr('data-page_number'); + page_number = parseInt( page_number ) - 1; + link += "paged=" + page_number + "&"; + + link += extra; + //window.location.href = link; + window.history.pushState('data', null, link.replace(/(^&)|(&$)/g, "")); + } + + function loadPaginationLinks($data,temp_number){ var targetTable = $('#table_id_' + temp_number + ' table#wpt_table'); $.ajax({ From f8974de120b133f4af6d704a7e74993ffe8d8722 Mon Sep 17 00:00:00 2001 From: Saiful Islam Date: Mon, 24 May 2021 15:40:41 +0600 Subject: [PATCH 3/9] search box default text set, when available in link, using get link --- includes/shortcode.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/shortcode.php b/includes/shortcode.php index 171f92d7..6a92e3bd 100644 --- a/includes/shortcode.php +++ b/includes/shortcode.php @@ -1298,11 +1298,15 @@ function wpt_search_box($temp_number, $search_box_texonomiy_keyword = array( 'pr * At Version 3.3, we have changed few features */ $html .= "
"; + + $search_keyword = isset( $_GET['search_key'] ) ? $_GET['search_key'] : ''; + $order_by = isset( $_GET['orderby'] ) ? $_GET['orderby'] : $order_by; + $order = isset( $_GET['order'] ) ? $_GET['order'] : $order; $single_keyword = $config_value['search_box_searchkeyword'];//__( 'Search keyword', 'wpt_pro' ); $html .= "
"; $html .= ''; - $html .= ''; + $html .= ''; $html .= "
";// End of .search_single_column $order_by_validation = apply_filters( 'wpto_searchbox_order_show', false,$temp_number, $config_value, $search_box_texonomiy_keyword ); From 6485df421bb8cc032045750c15111cd488f51287 Mon Sep 17 00:00:00 2001 From: Saiful Islam Date: Mon, 24 May 2021 17:42:17 +0600 Subject: [PATCH 4/9] query reset close button added --- assets/css/universal.css | 31 +++++++++++++++++++++++++++++++ assets/js/custom.js | 2 +- includes/functions.php | 2 ++ includes/shortcode.php | 7 ++++++- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/assets/css/universal.css b/assets/css/universal.css index 974713a8..767374ee 100644 --- a/assets/css/universal.css +++ b/assets/css/universal.css @@ -1544,6 +1544,37 @@ div.wpt_product_table_wrapper table.wpt_product_table th.wpt_action { margin: 10px 0; } +.wpt_search_box .search_box_wrapper { + position: relative; +} + +.wpt_search_box .search_box_wrapper a.search_box_reset, +a.search_box_reset { + position: absolute; + right: 8px; + top: 0; + height: 25px; + padding: 0; + width: 25px; + text-align: center; + font-family: Helvetica; + font-weight: normal; + color: #ff8989; + background: black; + border-radius: 15px; + line-height: 25px; + font-size: 11px; + transition: all .1s; + outline: none !important; + border: none !important; + text-decoration: none !important; + display: none; +} +a.search_box_reset:focus, +.wpt_search_box .search_box_wrapper a.search_box_reset:hover, a.search_box_reset:hover { + color: #ff4747; + background: #5d0202; +} /***************Search Box or option start****************/ /*option.level-1 { padding-left: 25px; diff --git a/assets/js/custom.js b/assets/js/custom.js index bfcce5b3..a564da29 100644 --- a/assets/js/custom.js +++ b/assets/js/custom.js @@ -1381,7 +1381,7 @@ } generat_url_by_search_query(temp_number, extra_link_tax_cf); - + $('#wpt_query_reset_button_' + temp_number).fadeIn('medium'); /** * Trigger on this event, when search will be completed * diff --git a/includes/functions.php b/includes/functions.php index 127d6c5b..b412a481 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -1145,6 +1145,7 @@ function wpt_args_manage_by_get_args( $args, $table_ID ){ $tax = json_decode($tax,true); $MY_GETS['tax_query'] = $tax; + unset( $args['tax_query'] ); unset( $MY_GETS['tax'] ); } @@ -1158,6 +1159,7 @@ function wpt_args_manage_by_get_args( $args, $table_ID ){ $meta = json_decode($meta,true); $MY_GETS['meta_query'] = $meta; + unset( $args['meta_query'] ); unset( $MY_GETS['meta'] ); } diff --git a/includes/shortcode.php b/includes/shortcode.php index 6a92e3bd..ab836a36 100644 --- a/includes/shortcode.php +++ b/includes/shortcode.php @@ -1352,8 +1352,13 @@ function wpt_search_box($temp_number, $search_box_texonomiy_keyword = array( 'pr } } $html .= apply_filters('end_part_advance_search_box','',$table_ID); + $cutnt_link = get_page_link(); + $style = isset( $_GET['table_ID'] ) ? "display:inline;": ''; + $html .= 'x'; + $html .= '
'; //End of .search_box_singles + $html .= ''; $html .= '';//End of .search_box_fixer $html .= '';//End of .wpt_search_box @@ -1365,7 +1370,7 @@ function wpt_search_box($temp_number, $search_box_texonomiy_keyword = array( 'pr /** * Total Search box Generator * - * @param type $temp_number It's a Temporay Number for each Table, + * @param type $temp_number It's a Temporary Number for each Table, * @param type $search_box_texonomiy_keyword Obviously should be a Array, for product_cat tag etc * @return string */ From ac335c2309feca543a254035bce975c7b32c8351 Mon Sep 17 00:00:00 2001 From: Saiful Islam Date: Mon, 24 May 2021 21:10:11 +0600 Subject: [PATCH 5/9] 2.8.9.0 --- woo-product-table.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/woo-product-table.php b/woo-product-table.php index d28715e7..643f1cb8 100644 --- a/woo-product-table.php +++ b/woo-product-table.php @@ -7,7 +7,7 @@ * Author URI: https://codecanyon.net/user/codeastrology * Tags: woocommerce product list,woocommerce product table, wc product table, product grid view, inventory, shop product table * - * Version: 2.8.8 + * Version: 2.8.9 * Requires at least: 4.0.0 * Tested up to: 5.7.2 * WC requires at least: 3.0.0 @@ -30,7 +30,7 @@ } if( !defined( 'WPT_DEV_VERSION' ) ){ - define( 'WPT_DEV_VERSION', '2.8.8.0' ); + define( 'WPT_DEV_VERSION', '2.8.9.0' ); } if( !defined( 'WPT_CAPABILITY' ) ){ From b050d783acef2f9a86d03a0160f9c70f387acda4 Mon Sep 17 00:00:00 2001 From: Saiful Islam Date: Mon, 24 May 2021 21:12:47 +0600 Subject: [PATCH 6/9] radius reduced --- assets/css/universal.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/css/universal.css b/assets/css/universal.css index 767374ee..fb754fe3 100644 --- a/assets/css/universal.css +++ b/assets/css/universal.css @@ -1561,7 +1561,7 @@ a.search_box_reset { font-weight: normal; color: #ff8989; background: black; - border-radius: 15px; + border-radius: 5px; line-height: 25px; font-size: 11px; transition: all .1s; From e165f69538e02959f61f5a08aeca529cc31af607 Mon Sep 17 00:00:00 2001 From: Saiful Islam Date: Tue, 25 May 2021 12:27:47 +0600 Subject: [PATCH 7/9] paged=number has been fixed --- assets/js/custom.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/assets/js/custom.js b/assets/js/custom.js index a564da29..7a58758e 100644 --- a/assets/js/custom.js +++ b/assets/js/custom.js @@ -121,6 +121,10 @@ loadMiniFilter(); //@Since 4.8 fixAfterAjaxLoad(); + + var current_link = window.location.href; + window.history.pushState('data', null, current_link.replace(/(paged=\d)+/, "paged=" + pageNumber)); + }, success: function(data) { targetTableBody.html(data); From 2b16b7ce06acc1cb036b689c2b0b8fc8cb579e77 Mon Sep 17 00:00:00 2001 From: Saiful Islam Date: Tue, 25 May 2021 12:42:12 +0600 Subject: [PATCH 8/9] paged=number has been fixed --- assets/js/custom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/custom.js b/assets/js/custom.js index 7a58758e..096c9119 100644 --- a/assets/js/custom.js +++ b/assets/js/custom.js @@ -123,7 +123,7 @@ fixAfterAjaxLoad(); var current_link = window.location.href; - window.history.pushState('data', null, current_link.replace(/(paged=\d)+/, "paged=" + pageNumber)); + window.history.pushState('data', null, current_link.replace(/(paged=\d)+/, "paged=" + (pageNumber-1))); }, success: function(data) { From 31c81ebb5fb1551f00f2806a8650f450fd9c719f Mon Sep 17 00:00:00 2001 From: Saiful Islam Date: Tue, 25 May 2021 16:51:02 +0600 Subject: [PATCH 9/9] page number issue also fixed when first click on first time on pagination --- assets/js/custom.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/assets/js/custom.js b/assets/js/custom.js index 096c9119..d09bcd6a 100644 --- a/assets/js/custom.js +++ b/assets/js/custom.js @@ -144,6 +144,15 @@ updateCheckBoxCount(temp_number); //Selection reArrange uncheckAllCheck(temp_number);//Uncheck All CheckBox after getting New pagination emptyInstanceSearchBox(temp_number);//CleanUp or do empty Instant Search + + + if($('#table_id_' + temp_number + ' table.wpt_product_table').attr('data-queried') !== 'true'){ + generat_url_by_search_query(temp_number); + $('#table_id_' + temp_number + ' table.wpt_product_table').attr('data-queried','true'); + } + + + pageNumber++; //Page Number Increasing 1 Plus targetTable.attr('data-page_number',pageNumber); @@ -1383,7 +1392,12 @@ if( !$.isEmptyObject(custom_field)){ extra_link_tax_cf = "meta=" + JSON.stringify(targetTableArgs.args.meta_query) } - + + //Set a Attr value in table tag, If already queried + $('#table_id_' + temp_number + ' table.wpt_product_table').attr('data-queried','true'); + /** + * Generate here where query + */ generat_url_by_search_query(temp_number, extra_link_tax_cf); $('#wpt_query_reset_button_' + temp_number).fadeIn('medium'); /**