Skip to content

Commit

Permalink
Merge pull request #315 from codersaiful/3.4.7.4
Browse files Browse the repository at this point in the history
3.4.7.4 - Added: Displaying tabl without atts - feature added. It's actually for sample table
  • Loading branch information
codersaiful authored Jan 18, 2024
2 parents 7a7f9b3 + fc7111c commit 3372220
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 5 deletions.
23 changes: 22 additions & 1 deletion inc/features/basics.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Basics extends Shortcode_Base{
public function run(){
$this->filter('body_class');
$this->action('wpt_bottom', 1, 10, 'edit_button');
$this->action('wpt_bottom', 1, 10, 'add_new_button');
$this->action('woocommerce_widget_shopping_cart_buttons', 1, 10, 'empty_cart_button');
}

Expand All @@ -36,7 +37,7 @@ public function body_class( $class ){
}

public function edit_button( Shortcode $shortcode ){

if( $shortcode->fake_property ) return;
if( ! current_user_can( WPT_CAPABILITY ) ) return;

?>
Expand All @@ -52,6 +53,26 @@ public function edit_button( Shortcode $shortcode ){

<?php
}
public function add_new_button( Shortcode $shortcode ){
if( ! $shortcode->fake_property ) return;
if( ! current_user_can( WPT_CAPABILITY ) ) return;

?>
<div title="<?php echo esc_attr( 'ONLY FOR ADMIN USER', 'woo-product-table' ); ?>" class="wpt_edit_table">
<a href="<?php echo esc_attr( admin_url( 'post-new.php?post_type=wpt_product_table' ) ); ?>"
target="_blank"
title="<?php echo esc_attr( '[ONLY FOR ADMIN USER] You have to create new table, If not.', 'woo-product-table' ); ?>"
>
<?php echo esc_html__( 'Add a Product Table', 'woo-product-table' ); ?>

</a>
<div class="wpt-if-already">
To get More feature, Please create a table by following button. <a href="https://wooproducttable.com/docs/doc/gating-start/how-to-create-woocommerce-product-table/" target="_blank">How to create a Product Table</a>
</div>
</div>

<?php
}

public function empty_cart_button(){

Expand Down
2 changes: 1 addition & 1 deletion inc/handle/search-box.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Search_Box{
public static $fields;
public static function render( Shortcode $shortcode ){
$behavior = $shortcode->atts['behavior'] ?? '';
if( $behavior !== 'normal' && ( is_shop() || is_product_taxonomy() || is_product_category() ) ) return;
// if( $behavior !== 'normal' && ( is_shop() || is_product_taxonomy() || is_product_category() ) ) return;
self::$reset_button = "<button class='wpt-query-reset-button' title='" . __('Reset','woo-product-table') . "'> <i class='wpt-spin3'></i></button>"; //end of .search_single
self::$cf_search_box = $shortcode->search_n_filter['cf_search_box'] ?? '';
self::$taxonomy_keywords = $shortcode->search_n_filter['taxonomy_keywords'] ?? [];
Expand Down
49 changes: 47 additions & 2 deletions inc/shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ public function shortcode($atts){
extract( shortcode_atts( $pairs, $atts ) );

$this->assing_property($atts);



//Obviously should load on after starup. Even already checked on overr there
$this->startup_loader($atts);
Expand Down Expand Up @@ -505,7 +507,7 @@ public function assing_property( $atts ){
set_query_var( $this->req_post_type, $this->table_id );

$this->is_table = $this->table_id && $this->post_type == $this->req_post_type && $this->status == 'publish';
if( ! $this->is_table ){
if( ! $this->is_table && ! empty( $this->atts ) ){
return Msg::not_found($this);
}

Expand Down Expand Up @@ -698,10 +700,53 @@ public function assing_property( $atts ){
$this->is_column_label = $this->table_style['tr.wpt_table_head th']['auto-responsive-column-label'] ?? false;

$this->assing_property = true;

if( empty( $this->atts ) ){
$this->fake_assing_property();//Msg::not_found($this);
}
return $this;
}

/**
* Sometime user just page shortcode [Product_Table]
* without atts,
* then we will use this actually
*
* @return void
*/
public function fake_assing_property(){
$this->fake_property = true;

$this->args = [
'post_type' => 'product',
'posts_per_page' => 30,
'wpt_query_type' => 'default',
'pagination' => '1',
'suppress_filters' => '1',
'orderby' => 'menu_order',
'order' => 'DESC',
'paged' => $this->args['paged'] ?? 1,
];
$this->_enable_cols = [
// '_price' => '_price',
'product_title' => 'product_title',
'stock' => 'stock',
'price' => 'price',
'category' => 'category',
'short_description' => 'short_description',
// 'quantity' => 'quantity',
// 'action' => 'action',
];
foreach($this->_enable_cols as $en_col_key => $en_col){
$this->column_settings[$en_col_key] = [
'type' => 'default',
'type_name' => 'Default',
'tag_class' => "auto_item_$en_col_key item_$en_col_key",
];
}

$this->is_table_head = true;
}

public function enqueue(){
$this->assets_element_url = $this->assets_url . 'css/elements/';

Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ You can easily show specific category products. While creating new table click o
* Added: New filter hook added for Inner Item. hook: `wpt_item_content`.
* Fixed: Search Result has been fixed based on 'relevance'.
* Fixed: Sorting Icon fixed and updated to latest icon.
* Added: Displaying tabl without atts - feature added. It's actually for sample table.

= 3.4.6 =
* Fixed: Asc/Desc icon fixed (Table Title)
Expand Down
2 changes: 1 addition & 1 deletion woo-product-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
}

if( ! defined( 'WPT_DEV_VERSION' ) ){
define( 'WPT_DEV_VERSION', '3.4.7.2' );
define( 'WPT_DEV_VERSION', '3.4.7.4' );
}

if( ! defined( 'WPT_CAPABILITY' ) ){
Expand Down

0 comments on commit 3372220

Please sign in to comment.