Advertisement
HarunRRayhan

Change LD VC Template Path

Aug 20th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1. /**
  2.  * Over Write LD Visual Customizer Defult Template
  3.  * Removed default filter
  4.  * Added new filter
  5.  *
  6.  * @author Harun R Rayhan
  7.  */
  8.  
  9. if(has_filter( 'learndash_template', 'lds_return_custom_templates' )){
  10.     // Removing LD Visual Customizer's Default templates
  11.     remove_filter( 'learndash_template', 'lds_return_custom_templates' ); // removing
  12.     add_filter( 'learndash_template', 'bg_ld_vc_custom_templates' ); // Adding new
  13.  
  14. }
  15. function bg_ld_vc_custom_templates( $filepath, $name = NULL, $args = NULL, $echo = NULL, $return_file_path = NULL ) {
  16.  
  17.     $style = get_option( 'lds_listing_style' );
  18.     if( !$style || empty($style) || $style == 'default' ) return $filepath;
  19.  
  20.     $matches = apply_filters( 'lds_custom_template_matches', array(
  21.         'course.php'    =>  '/ld-vc-templates/' . $style . '/course.php',
  22.         'lesson.php'    =>  '/ld-vc-templates/' . $style . '/lesson.php',
  23.         'topic.php'     =>  '/ld-vc-templates/' . $style . '/topic.php',
  24.     ) );
  25.  
  26.     foreach( $matches as $match => $new_template ) {
  27.         if( strpos( $filepath, $match ) ) return BGT_DIVI_CHILD_PATH  . $new_template;
  28.     }
  29.  
  30.     return $filepath;
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement