Skip to content

Commit

Permalink
Merge pull request #23 from codersaiful/2.7.0.34
Browse files Browse the repository at this point in the history
2.7.0.34 Some action and filter hook spelling fix
  • Loading branch information
codersaiful authored Sep 16, 2020
2 parents 6a5353f + 7cc5f0e commit d82d167
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 6 deletions.
2 changes: 1 addition & 1 deletion includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ function wpt_column_add_extra_items( $keyword, $column_settings, $columns_array,
* To add Any Items for [Select multiple inner items]
* Remember: It's only for Admin Product Table Edit. and data will debend on Save Only
*/
$items = apply_filters( 'wpto_inside_thecked_item_arr', $items, $keyword, $column_settings, $columns_array );
$items = apply_filters( 'wpto_inside_checked_item_arr', $items, $keyword, $column_settings, $columns_array );
if( is_array( $items ) && count( $items ) > 0 ){

//array_merge(array_flip($items),$columns_array)
Expand Down
2 changes: 1 addition & 1 deletion includes/row_manager.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

$table_row_loc = WPT_BASE_DIR . 'includes/table_row.php';
$table_row_loc = apply_filters( 'wpo_table_row_loc', $table_row_loc, $column_settings,$table_column_keywords, $args, $table_ID, $product );
$table_row_loc = apply_filters( 'wpto_table_row_loc', $table_row_loc, $column_settings,$table_column_keywords, $args, $table_ID, $product );
if( file_exists( $table_row_loc ) ){
include $table_row_loc;
}
2 changes: 1 addition & 1 deletion includes/shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ function wpt_shortcode_generator( $atts = false ) {
* Do Detect Page number, When Table will be display.
*
*/
$page_number = apply_filters( 'wpt_page_number', $page_number, $table_ID, $args, $column_settings, $enabled_column_array, $column_array );
$page_number = apply_filters( 'wpto_page_number', $page_number, $table_ID, $args, $column_settings, $enabled_column_array, $column_array );
$args['paged'] =( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : $page_number;

$args = array_merge( $args, $basics_args );
Expand Down
81 changes: 78 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,82 @@
![Woo Product Table](https://raw.githubusercontent.com/codersaiful/woo-product-table/master/assets/images/wpt-logo.png)

# Woo Product Table - A WooCommerce Product Table Plugin
Woo Product Table has Tiny Shortcode. Easy to use and No need programming knowledge to use. Easily able to handle by Graphical User Interface. Just like following:
```[Product_Table id='123']```

## Available Filter Hook List
## Features
- Withing a minute, User able to make a table and using shortcode, able to display anywhere
- Most popular and Fastest
- Developer Friendly - Available lots of Filter and Action Hook
- Support all theme and plugin
- Displaying product list as table within a minute.
- So many lots of features [Read More](https://www.wcproducttable.xyz/)

### Available Filter Hook List
https://docs.google.com/spreadsheets/d/1RwnzuupIYC-ao2R3_P3hZU__R-8nA3p7o2XoWWntNig/edit?usp=sharing

## Available Action Hook List
https://docs.google.com/spreadsheets/d/1aK2__VKTZbPk8HMTfck4RjdFq6Z7nV7yyZOnZ0hUkK4/edit?usp=sharing
### Available Action Hook List
https://docs.google.com/spreadsheets/d/1aK2__VKTZbPk8HMTfck4RjdFq6Z7nV7yyZOnZ0hUkK4/edit?usp=sharing

# Making a sample Addons
Here I will show, how a user can make a addon for **Woo Product Table** using our Hook. As example, I will show, how to add new column in our table.

### Using hooks
There are variety of ways to add your custom code to manipulate code by hooks:
- To a custom child theme’s functions.php file.
- Using a plugin such as [Code Snippets](https://wordpress.org/plugins/code-snippets/)

### Using action hooks
To execute your own code, you hook in by using the action hook ```do_action('action_name');```. Here is where to place your code:
```
add_action( 'action_name', 'your_function_name' );
function your_function_name() {
// Your code
}
```
## Start Procedure of adding new Collumn
First we have to our custom column in default column array using ```wpto_default_column_arr``` filter.
```
<?php
if( !function_exists( 'new_shortcode_column' ) ){
function new_shortcode_column( $column_array ) {
$column_array['new_shortcode'] = 'New Shortcode';
return $column_array;
}
}
add_filter( 'wpto_default_column_arr', 'new_shortcode_column' );
```
We have added our new shortcode column to default column array. Now we need a file where we can add the content for that custom shortcode.

Below we have used ```wpto_template_loc_item_ . $keyword``` filter.
```
<?php
if( !function_exists( 'temp_file_for_new_shortcode' ) ){
function temp_file_for_new_shortcode( $file ){
//$file = __DIR__ . '/../file/my_shortcode.php';
$file = $your_file_location;
return $file;
}
}
add_filter( 'wpto_template_loc_item_new_shortcode', 'temp_file_for_new_shortcode', 10 );
```

Now we need to add a input field for get the custom shortcode from user. here we have used ```wpto_column_setting_form_ . $keyword``` action to add the input field inside column area in column tab.
```
<?php
function input_for_new_shortcode($column_settings){
$text = isset( $column_settings['new_shortcode']['text'] ) ? $column_settings['new_shortcode']['text'] : false;
?>
<input class="ua_input" name="column_settings[new_shortcode]" value="<?php echo esc_attr( $text ); ?>">
<?php
}
add_action( 'wpto_column_setting_form_new_shortcode', 'input_for_new_shortcode' );
```
Now we have to show the shortcode content using our custom file. Here we create a file ```my_shortcode.php``` with following code.
```
<?php
$my_shortcode = isset( $settings['text'] ) ? $settings['text'] : '';
echo do_shortcode( $settings['text'] );
```

0 comments on commit d82d167

Please sign in to comment.