Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. <?php
  2. add_filter('wc_get_template','wholesaler_template'), 10, 5);
  3. add_filter( 'wc_get_template_part', 'wholesaler_template_parts'), 10, 3);
  4.  
  5. public function wholesaler_template($located, $template_name, $args, $template_path, $default_path) {
  6. global $woocommerce;
  7. $newpath = plugin_dir_path( __FILE__ ) . '/woocommerce/' . $template_name;
  8. return file_exists( $newpath ) ? $newpath : $located;
  9. }
  10.  
  11.  
  12. public function wholesaler_template_parts( $template, $slug, $name )
  13. {
  14. $plugin_path = plugin_dir_path( __FILE__ ) . '/woocommerce/';
  15. if ( $name ) {
  16. $newpath = $plugin_path . "{$slug}-{$name}.php";
  17. } else {
  18. $newpath = $plugin_path . "{$slug}.php";
  19. }
  20.  
  21. return file_exists( $newpath ) ? $newpath : $template;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement