Advertisement
mbis

Dokkan - %store% tag

Jun 8th, 2020
1,270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.61 KB | None | 0 0
  1. /**
  2.  * Use %store% in Products' permastructure settings
  3.  */
  4. function pm_dokan_store_field($default_uri, $native_slug, $post, $slug, $native_uri) {
  5.     // Do not affect native URIs
  6.     if($native_uri == true || empty($post->post_type) || $post->post_type !== 'product') { return $default_uri; }
  7.  
  8.     if(strpos($default_uri, '%store%') !== false) {
  9.         $store_name = get_user_meta($post->post_author, 'dokan_store_name', true);
  10.         $default_uri = str_replace('%store%', sanitize_title($store_name), $default_uri);
  11.     }
  12.  
  13.     return $default_uri;
  14. }
  15. add_filter('permalink_manager_filter_default_post_uri', 'pm_dokan_store_field', 3, 5);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement