-
Notifications
You must be signed in to change notification settings - Fork 18
How to Add Custom Column using Action and Filter Hooks
In Woo Product Table plugin, there are lots of column already we have added. But for you maybe those are not enough. You wanted to add more custom column. That’s why I am writing this tutorial.
First we have to our custom column in default column array using wpto_default_column_arr
filter.
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 this code is used in our addon plugin. Which you can find at branch New Shortcode Column – Link
Below we have used wpto_template_loc_item_ . $keyword filter.
if( !function_exists( 'temp_file_for_new_shortcode' ) ){
function temp_file_for_new_shortcode( $file ){
//$file = __DIR__ . '/../file/hello.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.
if( !function_exists( 'temp_file_for_new_shortcode' ) ){
function temp_file_for_new_shortcode( $file ){
//$file = __DIR__ . '/../file/hello.php';
$file = $your_file_location;
return $file;
}
}
add_filter( 'wpto_template_loc_item_new_shortcode', 'temp_file_for_new_shortcode', 10 );
Now we have to show the shortcode content using our custom file. Here we have used hello.php
$my_shortcode = isset( $settings['text'] ) ? $settings['text'] : '';
echo do_shortcode( $settings['text'] );
Still Need Help? Contact over Support
- wpto_admin_tab_array
- wpto_save_tab_array
- wpto_form_tab_validation_[tab_name]
- wpt_table_show_top
- wpto_column_arr
- wpto_column_settings
- wpto_enabled_column_array
- wpto_thumbs_size
- wpto_table_show
- woocommerce_add_to_cart_validation
- woocommerce_attribute
- woocommerce_loop_add_to_cart_link
- woocommerce_quantity_input_max
- woocommerce_quantity_input_min
- wpo_row_manager_loc
- wpt_action_variation
- wpt_admin_form_top_links
- wpt_menu_capability
- wpt_supported_terms
- wpto_action_start_table
- wpto_action_table_wrapper_top
- wpto_add_to_cart_text
- wpto_add_to_cart_url
- wpto_additional_variable
- wpto_addnew_col_arr
- wpto_admin_tab_file_loc
- wpto_admin_tab_file_loc_{$tab}
- wpto_admin_tab_folder_dir
- wpto_ajax_form_submit
- wpto_before_row
- wpto_blank_centent
- wpto_blank_type_column
- wpto_blank_type_column_{$keyword}
- wpto_checkbox_validation
- wpto_column_bottom
- wpto_column_top
- wpto_column_type
- wpto_configuration_settings
- wpto_curent_deteted_device
- wpto_default_column_arr
- wpto_default_configure
- wpto_default_enable_column_arr
- wpto_default_width_freeze_col
- wpto_defult_file_loc
- wpto_element_bottom
- wpto_element_top
- wpto_extra_items_arr
- wpto_form_tab_validation_{$tab}
- wpto_get_config_value
- wpto_inside_checked_item_arr
- wpto_inside_item_arr
- wpto_inside_item_arr_{$keyword}
- updating__
- updating__
- updating__
- updating__
- updating__