diff --git a/assets/css/universal.css b/assets/css/universal.css index 974713a8..fb754fe3 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: 5px; + 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 2c3dc69b..d09bcd6a 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-1))); + }, success: function(data) { targetTableBody.html(data); @@ -140,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); @@ -1222,6 +1235,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 +1355,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 +1378,34 @@ 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) + } + + //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'); + /** + * 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 +1449,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 +1458,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({ diff --git a/includes/functions.php b/includes/functions.php index e92501b2..b412a481 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -1101,6 +1101,77 @@ 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( $args['tax_query'] ); + 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( $args['meta_query'] ); + 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' ) ){ /** diff --git a/includes/shortcode.php b/includes/shortcode.php index 171f92d7..ab836a36 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 ); @@ -1348,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 @@ -1361,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 */ 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' ) ){