Advertisement
nwtd

CoursePress single unit on a Genesis theme

Feb 17th, 2015
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.95 KB | None | 0 0
  1. <?php
  2.  
  3. add_action( 'genesis_meta', 'pactems_course_permission_queries' );
  4. function pactems_course_permission_queries() {
  5.     global $coursepress, $wp, $wp_query;
  6.  
  7.     $course_id = do_shortcode('[get_parent_course_id]');
  8.  
  9.     add_thickbox();
  10.  
  11.     $paged = ! empty( $wp->query_vars['paged'] ) ? absint($wp->query_vars['paged']) : 1;
  12.     //redirect to the parent course page if not enrolled or not preview unit/page
  13.     while ( have_posts() ) : the_post();
  14.         $coursepress->check_access($course_id, get_the_ID());
  15.     endwhile;
  16.  
  17.     $post = $unit->details;
  18. }
  19.  
  20.  
  21. //* Replace Genesis loop
  22. remove_action( 'genesis_loop', 'genesis_do_loop' );    
  23. add_action( 'genesis_loop', 'pactems_course_single_unit' );
  24. function pactems_course_single_unit(){  ?>
  25.    
  26.     <div id="primary" class="content-area">
  27.         <main id="main" class="site-main" role="main">
  28.             <?php while ( have_posts() ) : the_post(); ?>
  29.                 <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  30.                     <header class="entry-header">
  31.                         <h3 class="entry-title"><?php echo do_shortcode('[course_title course_id="' . $course_id . '"]'); ?></h3>
  32.                         <?php
  33.                         echo do_shortcode('[course_unit_details unit_id="' . get_the_ID() . '" field="parent_course"]');
  34.                         ?>
  35.                     </header><!-- .entry-header -->
  36.                     <div class="instructors-content"></div>
  37.                     <?php
  38.                     echo do_shortcode('[course_unit_archive_submenu course_id="' . $course_id . '"]');
  39.                     ?>
  40.  
  41.                     <div class="clearfix"></div>
  42.  
  43.                     <?php echo do_shortcode('[course_unit_details unit_id="' . $course_id . '" field="unit_page_title" unit_title="'.get_the_title().'"]'); ?>
  44.  
  45.                     <div class="entry-content">
  46.                         <?php
  47.                         if ( $paged == 1 ) { //Unit introduction will be shown only on the first page
  48.                             the_content();
  49.                         }
  50.                         ?>
  51.                     </div>
  52.                     <?php Unit_Module::get_modules_front($unit->details->$course_id);?>
  53.                 </article>
  54.             <?php endwhile; // end of the loop. ?>
  55.         </main><!-- #main -->
  56.     </div><!-- #primary -->
  57.  
  58. <?php }
  59.  
  60. genesis();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement