Skip to content

Commit

Permalink
Merge pull request #99 from codersaiful/2.8.9.1
Browse files Browse the repository at this point in the history
2.8.9.1
  • Loading branch information
codersaiful authored May 25, 2021
2 parents c4a12e3 + 31c81eb commit db97ddd
Show file tree
Hide file tree
Showing 5 changed files with 198 additions and 5 deletions.
31 changes: 31 additions & 0 deletions assets/css/universal.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
84 changes: 83 additions & 1 deletion assets/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1335,9 +1355,10 @@
targetTableArgs.args.meta_query = targetTableArgsBackup.args.meta_query;
}


//Display Loading on before load
targetTableBody.prepend("<div class='wpt_loader_text'>" + config_json.loading_more_text + "</div>"); //Laoding..
$(document.body).trigger('wpt_query_progress',targetTableArgs);
$.ajax({
type: 'POST',
url: ajax_url,// + get_data,
Expand All @@ -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) {

Expand Down Expand Up @@ -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");
},
});
Expand All @@ -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({
Expand Down
71 changes: 71 additions & 0 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) ){

/**
Expand Down
13 changes: 11 additions & 2 deletions includes/shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 .= "<div class='search_single search_single_direct'>";

$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 .= "<div class='search_single_column'>";
$html .= '<label class="search_keyword_label single_keyword" for="single_keyword_' . $temp_number . '">' . $single_keyword . '</label>';
$html .= '<input data-key="s" class="query_box_direct_value" id="single_keyword_' . $temp_number . '" value="" placeholder="' . $single_keyword . '"/>';
$html .= '<input data-key="s" value="' . $search_keyword . '" class="query_box_direct_value" id="single_keyword_' . $temp_number . '" value="" placeholder="' . $single_keyword . '"/>';
$html .= "</div>";// End of .search_single_column

$order_by_validation = apply_filters( 'wpto_searchbox_order_show', false,$temp_number, $config_value, $search_box_texonomiy_keyword );
Expand Down Expand Up @@ -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 .= '<a href="' . $cutnt_link . '" data-type="close-button" data-table_ID="' . $temp_number . '" id="wpt_query_reset_button_' . $temp_number . '" class="search_box_reset search_box_reset_' . $temp_number . '" style="' . $style . '">x</a>';

$html .= '</div>'; //End of .search_box_singles


$html .= '<button data-type="query" data-temp_number="' . $temp_number . '" id="wpt_query_search_button_' . $temp_number . '" class="button wpt_search_button query_button wpt_query_search_button wpt_query_search_button_' . $temp_number . '">' . $config_value['search_button_text'] . '</button>';
$html .= '</div>';//End of .search_box_fixer
$html .= '</div>';//End of .wpt_search_box
Expand All @@ -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
*/
Expand Down
4 changes: 2 additions & 2 deletions woo-product-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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' ) ){
Expand Down

0 comments on commit db97ddd

Please sign in to comment.