2 years ago
#74133

Web Design
Woocommerce dokan plugin how can I fire a filter hook in a certain page URL?
I wrote a filter hook for wp_handle_upload_prefilter
to crop and add watermark simultaneously when upload new image to wordpress media. It works in every page that there is wp media upload
, but I want to execute this filter hook just in a certain page. (i.e. in Dokan dashboard)
/dashboard/upload_image
URL link.
Thank you for helping me...
codes to create new item and page in Dokan dahsboard:
add_filter( 'dokan_query_var_filter',
'dokan_load_document_menu_add_product' );
function dokan_load_document_menu_add_product($query_vars){
$query_vars['upload_image'] = 'upload_image';
return $query_vars;
}
add_filter( 'dokan_get_dashboard_nav', 'dokan_add_new_product_menu' );
function dokan_add_new_product_menu( $urls ) {
$urls['upload_image'] = array(
'title' => __( 'Upload Image', 'dokan'),
'icon' => '<i class="fa fa-user"></i>',
'url' => dokan_get_navigation_url( 'upload_image' ),
'pos' => 42
);
return $urls;
}
add_action( 'dokan_load_custom_template', 'dokan_load_template' );
function dokan_load_template( $query_vars ) {
if ( isset( $query_vars['upload_image'] ) ) {
include YDE_INC.'upload_image.php';
}
}
YDE_INC is plugin_dir_path to folder in which upload_image.php
exists.
Filter to modify uploading image:
add_filter('wp_handle_upload_prefilter', 'custom_upload_filter' );
function custom_upload_filter( $file ){
...Codes to crop and watermark the new image for uploading...
}
wordpress
woocommerce
custom-wordpress-pages
woocommerce-theming
dokan
0 Answers
Your Answer