Advertisement
mbis

Dokkan support for PMP

Nov 6th, 2019
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1. /**
  2.  * Dokan support
  3.  */
  4. function pm_dokan_support() {
  5.     global $post, $wp_query, $wp;
  6.  
  7.     // Check if Dokan is activated
  8.     if(!function_exists('dokan_get_option')) { return; }
  9.  
  10.     // Get Dokan dashboard page id
  11.     $dashboard_page = dokan_get_option('dashboard', 'dokan_pages');
  12.  
  13.     // Stop the redirect
  14.     if(!empty($dashboard_page) && !empty($post->ID) && ($post->ID == $dashboard_page)) {
  15.         $wp->query_vars['do_not_redirect'] = 1;
  16.  
  17.         // Detect dokan shortcode
  18.         if(empty($wp_query->query_vars['edit-account'])) {
  19.             $wp->query_vars['page'] = 1;
  20.         }
  21.     }
  22.  
  23.     // 2. Support "Edit Product" pages
  24.     if(isset($wp_query->query_vars['edit'])) {
  25.         $wp_query->query_vars['edit'] = 1;
  26.         $wp_query->query_vars['do_not_redirect'] = 1;
  27.     }
  28. }
  29. add_action('wp', 'pm_dokan_support', 999);
  30.  
  31. function pm_extra_dokan_endpoints($endpoints) {
  32.     $endpoints .= "|edit";
  33.  
  34.     return $endpoints;
  35. }
  36. add_filter('permalink-manager-endpoints', 'pm_extra_dokan_endpoints');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement