-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from codersaiful/2.7.0.34
2.7.0.34 Some action and filter hook spelling fix
- Loading branch information
Showing
4 changed files
with
81 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] ); | ||
``` |