fahimmurshed

Enable the Featured Image on Learndash Topics/Lessons page

Jul 26th, 2021
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.21 KB | None | 0 0
  1. <?php
  2. /**
  3.  * LearnDash LD30 focus mode.
  4.  *
  5.  * @since 3.0.0
  6.  *
  7.  * @package LearnDash\Templates\LD30
  8.  */
  9.  
  10. if ( ! defined( 'ABSPATH' ) ) {
  11.     exit;
  12. }
  13.  
  14. if ( have_posts() ) :
  15.     while ( have_posts() ) :
  16.         the_post();
  17.  
  18.         $cuser     = wp_get_current_user();
  19.         $course_id = learndash_get_course_id();
  20.         $user_id   = ( is_user_logged_in() ? $cuser->ID : false );
  21.  
  22.         /**
  23.          * Fires before the header in the focus template.
  24.          *
  25.          * @since 3.0.0
  26.          *
  27.          * @param int $course_id Course ID.
  28.          * @param int $user_id   User ID.
  29.          */
  30.         do_action( 'learndash-focus-header-before', $course_id, $user_id );
  31.  
  32.         learndash_get_template_part(
  33.             'focus/header.php',
  34.             array(
  35.                 'course_id' => $course_id,
  36.                 'user_id'   => $user_id,
  37.                 'context'   => 'focus',
  38.             ),
  39.             true
  40.         );
  41.  
  42.         /**
  43.          * Fires before the sidebar in the focus template.
  44.          *
  45.          * @since 3.0.0
  46.          *
  47.          * @param int $course_id Course ID.
  48.          * @param int $user_id   User ID.
  49.          */
  50.         do_action( 'learndash-focus-sidebar-before', $course_id, $user_id );
  51.  
  52.         learndash_get_template_part(
  53.             'focus/sidebar.php',
  54.             array(
  55.                 'course_id' => $course_id,
  56.                 'user_id'   => $user_id,
  57.                 'context'   => 'focus',
  58.             ),
  59.             true
  60.         ); ?>
  61.  
  62.     <div class="ld-focus-main">
  63.  
  64.         <?php
  65.         /**
  66.          * Fires before the masthead in the focus template.
  67.          *
  68.          * @since 3.0.0
  69.          *
  70.          * @param int $course_id Course ID.
  71.          * @param int $user_id   User ID.
  72.          */
  73.         do_action( 'learndash-focus-masthead-before', $course_id, $user_id );
  74.  
  75.         learndash_get_template_part(
  76.             'focus/masthead.php',
  77.             array(
  78.                 'course_id' => $course_id,
  79.                 'user_id'   => $user_id,
  80.                 'context'   => 'focus',
  81.             ),
  82.             true
  83.         );
  84.  
  85.         /**
  86.          * Fires after the masthead in the focus template.
  87.          *
  88.          * @since 3.0.0
  89.          *
  90.          * @param int $course_id Course ID.
  91.          * @param int $user_id   User ID.
  92.          */
  93.         do_action( 'learndash-focus-masthead-after', $course_id, $user_id );
  94.         ?>
  95.  
  96.         <div class="ld-focus-content">
  97.  
  98.             <?php
  99.             /**
  100.              * Fires before the title in the focus template.
  101.              *
  102.              * @since 3.0.0
  103.              *
  104.              * @param int $course_id Course ID.
  105.              * @param int $user_id   User ID.
  106.              */
  107.             do_action( 'learndash-focus-content-title-before', $course_id, $user_id );
  108.             ?>
  109.  
  110.             <h1>
  111.                 <?php
  112.                     add_theme_support( 'post-thumbnails' );
  113.                     the_post_thumbnail();
  114.                     the_title();
  115.                 ?>
  116.             </h1>
  117.  
  118.             <?php
  119.             /**
  120.              * Fires before the content in the focus template.
  121.              *
  122.              * @since 3.0.0
  123.              *
  124.              * @param int $course_id Course ID.
  125.              * @param int $user_id   User ID.
  126.              */
  127.             do_action( 'learndash-focus-content-content-before', $course_id, $user_id );
  128.             ?>
  129.  
  130.             <?php the_content(); ?>
  131.  
  132.             <?php
  133.             /**
  134.              * Fires after the content in the focus template.
  135.              *
  136.              * @since 3.0.0
  137.              *
  138.              * @param int $course_id Course ID.
  139.              * @param int $user_id   User ID.
  140.              */
  141.             do_action( 'learndash-focus-content-content-after', $course_id, $user_id );
  142.             ?>
  143.  
  144.             <?php
  145.                 wp_link_pages(
  146.                     array(
  147.                         'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'learndash' ),
  148.                         'after'  => '</div>',
  149.                     )
  150.                 );
  151.             ?>
  152.  
  153.             <?php
  154.             /**
  155.              * Filters whether to show existing comments when comments are not enabled.
  156.              *
  157.              * @since 3.4.2
  158.              *
  159.              * @param boolean $show_existing_comments Whether to show existing comments.
  160.              */
  161.             if ( comments_open() || ( apply_filters( 'learndash_focus_mode_show_existing_comments', false ) ) ) {
  162.                 /**
  163.                  * Filters whether to load comments in focus mode or not.
  164.                  *
  165.                  * @since 3.1.4
  166.                  *
  167.                  * @param boolean $load_focus_comments Whether to show comments in focus mode or not.
  168.                  */
  169.                 if ( apply_filters( 'learndash_focus_mode_can_view_comments', is_user_logged_in() ) ) {
  170.                     learndash_get_template_part(
  171.                         'focus/comments.php',
  172.                         array(
  173.                             'course_id' => $course_id,
  174.                             'user_id'   => $user_id,
  175.                             'context'   => 'focus',
  176.                         ),
  177.                         true
  178.                     );
  179.                 }
  180.             }
  181.             ?>
  182.  
  183.             <?php
  184.             /**
  185.              * Fires at the focus mode content end.
  186.              *
  187.              * @since 3.1.4
  188.              *
  189.              * @param int $course_id Course ID.
  190.              * @param int $user_id   User ID.
  191.              */
  192.             do_action( 'learndash-focus-content-end', $course_id, $user_id );
  193.             ?>
  194.         </div> <!--/.ld-focus-content-->
  195.  
  196.     </div> <!--/.ld-focus-main-->
  197.  
  198.         <?php
  199.         /**
  200.          * Fires before the footer in the focus template.
  201.          *
  202.          * @since 3.0.0
  203.          *
  204.          * @param int $course_id Course ID.
  205.          * @param int $user_id   User ID.
  206.          */
  207.         do_action( 'learndash-focus-content-footer-before', $course_id, $user_id );
  208.  
  209.         learndash_get_template_part(
  210.             'focus/footer.php',
  211.             array(
  212.                 'course_id' => $course_id,
  213.                 'user_id'   => $user_id,
  214.                 'context'   => 'focus',
  215.             ),
  216.             true
  217.         );
  218.  
  219.         /**
  220.          * Fires after the footer in the focus template.
  221.          *
  222.          * @since 3.0.0
  223.          *
  224.          * @param int $course_id Course ID.
  225.          * @param int $user_id   User ID.
  226.          */
  227.         do_action( 'learndash-focus-content-footer-after', $course_id, $user_id );
  228.  
  229.     endwhile;
  230. else :
  231.  
  232.     learndash_get_template_part(
  233.         'modules/alert.php',
  234.         array(
  235.             'type'    => 'warning',
  236.             'icon'    => 'alert',
  237.             'message' => esc_html__( 'No content found at this address', 'learndash' ),
  238.         ),
  239.         true
  240.     );
  241.  
  242. endif; ?>
  243.  
Add Comment
Please, Sign In to add comment