</div>
					<div class="discussion-archive-single">
						<h1 class="discussion-title"><a href="<?php 
        the_permalink();
        ?>
"><?php 
        the_title();
        ?>
</a></h1>

						<div class="discussion-meta">
							<?php 
        if ($discussion->details->unit_id == '') {
            $discussion_unit = esc_html($discussion->get_unit_name());
        } else {
            $discussion_unit = sprintf('<a href="%s">%s</a>', esc_url(Unit::get_permalink($discussion->details->unit_id)), esc_html($discussion->get_unit_name()));
        }
        ?>
							<span><?php 
        echo get_the_date();
        ?>
</span> | <span><?php 
        the_author();
        ?>
</span> |
							<span><?php 
        echo $discussion_unit;
        ?>
</span>
							<span><?php 
        echo get_comments_number();
 /**
  * Shows the course title.
  *
  * @since 1.0.0
  */
 function course_unit_title($atts)
 {
     extract(shortcode_atts(array('unit_id' => in_the_loop() ? get_the_ID() : '', 'title_tag' => '', 'link' => 'no', 'class' => '', 'last_page' => 'no'), $atts, 'course_unit_title'));
     $unit_id = (int) $unit_id;
     $title_tag = sanitize_html_class($title_tag);
     $link = sanitize_html_class($link);
     $last_page = sanitize_html_class($last_page);
     $class = sanitize_html_class($class);
     $title = get_the_title($unit_id);
     $draft = get_post_status() !== 'publish';
     $show_draft = $draft && cp_can_see_unit_draft();
     if ('yes' == $last_page) {
         $course_id = do_shortcode('[get_parent_course_id]');
         $course_id = (int) $course_id;
         $last_visited_page = cp_get_last_visited_unit_page($unit_id);
         $the_permalink = Unit::get_permalink($unit_id, $course_id) . 'page/' . trailingslashit($last_visited_page);
     } else {
         $the_permalink = Unit::get_permalink($unit_id, $course_id);
     }
     $content = '';
     if (!$draft || $draft && $show_draft) {
         $content = !empty($title_tag) ? '<' . $title_tag . ' class="course-unit-title course-unit-title-' . $unit_id . ' ' . $class . '">' : '';
         $content .= 'yes' == $link ? '<a href="' . esc_url($the_permalink) . '" title="' . $title . '" class="unit-archive-single-title">' : '';
         $content .= $title;
         $content .= 'yes' == $link ? '</a>' : '';
         $content .= !empty($title_tag) ? '</' . $title_tag . '>' : '';
     }
     // Return the html in the buffer.
     return $content;
 }
</span></div>
                        </div>
                        <div class="discussion-archive-single">
                            <h1 class="discussion-title"><a href="<?php 
        the_permalink();
        ?>
"><?php 
        the_title();
        ?>
</a></h1>
                            <div class="discussion-meta">
                                <?php 
        if ($discussion->details->unit_id == '') {
            $discussion_unit = $discussion->get_unit_name();
        } else {
            $discussion_unit = '<a href="' . Unit::get_permalink($discussion->details->unit_id) . '">' . $discussion->get_unit_name() . '</a>';
        }
        ?>
                                <span><?php 
        echo get_the_date();
        ?>
</span> | <span><?php 
        the_author();
        ?>
</span> | <span><?php 
        echo $discussion_unit;
        ?>
</span> | <span><?php 
        echo get_comments_number();
        ?>
 <?php 
Exemplo n.º 4
0
 function check_for_valid_post_type_permalinks($permalink, $post, $leavename)
 {
     if (get_post_type($post->ID) == 'discussions') {
         $course_id = get_post_meta($post->ID, 'course_id', true);
         if (!empty($course_id)) {
             $course_obj = new Course($course_id);
             $course = $course_obj->get_course();
             return str_replace('%course%', $course->post_name, $permalink);
         } else {
             return $permalink;
         }
     } else {
         if (get_post_type($post->ID) == 'notifications') {
             $course_id = get_post_meta($post->ID, 'course_id', true);
             if (!empty($course_id)) {
                 $course_obj = new Course($course_id);
                 $course = $course_obj->get_course();
                 return str_replace('%course%', $course->post_name, $permalink);
             } else {
                 return $permalink;
             }
         } else {
             if (get_post_type($post->ID) == 'unit') {
                 return Unit::get_permalink($post->ID);
             } else {
                 return $permalink;
             }
         }
     }
 }
        /**
         * Renders the course structure.
         *
         * Used in shortcodes on the front end to render the course hierarchy.
         *
         * @param string $try_title
         * @param bool $show_try
         * @param bool $hide_title
         * @param bool $echo
         */
        function course_structure_front($try_title = '', $show_try = true, $hide_title = false, $echo = true)
        {
            $show_unit = $this->details->show_unit_boxes;
            $preview_unit = $this->details->preview_unit_boxes;
            $show_page = $this->details->show_page_boxes;
            $preview_page = $this->details->preview_page_boxes;
            $units = $this->get_units();
            $content = '';
            if (!$echo) {
                ob_start();
            }
            echo $hide_title ? '' : '<label>' . $this->details->post_title . '</label>';
            ?>

			<ul class="tree">
				<li>
					<ul>
						<?php 
            foreach ($units as $unit) {
                $unit_class = new Unit($unit->ID);
                $unit_pages = $unit_class->get_number_of_unit_pages();
                //					$modules = Unit_Module::get_modules( $unit->ID );
                if (isset($show_unit[$unit->ID]) && $show_unit[$unit->ID] == 'on' && $unit->post_status == 'publish') {
                    ?>

								<li>

									<label for="unit_<?php 
                    echo $unit->ID;
                    ?>
" class="course_structure_unit_label">
										<div class="tree-unit-left"><?php 
                    echo $unit->post_title;
                    ?>
</div>
										<div class="tree-unit-right">

											<?php 
                    if ($this->details->course_structure_time_display == 'on') {
                        ?>
												<span><?php 
                        echo $unit_class->get_unit_time_estimation($unit->ID);
                        ?>
</span>
											<?php 
                    }
                    ?>

											<?php 
                    if (isset($preview_unit[$unit->ID]) && $preview_unit[$unit->ID] == 'on') {
                        ?>
												<a href="<?php 
                        echo Unit::get_permalink($unit->ID);
                        ?>
?try" class="preview_option"><?php 
                        if ($try_title == '') {
                            _e('Try Now', 'cp');
                        } else {
                            echo $try_title;
                        }
                        ?>
</a>
											<?php 
                    }
                    ?>
										</div>
									</label>

									<ul>
										<?php 
                    for ($i = 1; $i <= $unit_pages; $i++) {
                        if (isset($show_page[$unit->ID . '_' . $i]) && $show_page[$unit->ID . '_' . $i] == 'on') {
                            ?>

												<li class="course_structure_page_li">
													<?php 
                            $pages_num = 1;
                            $page_title = $unit_class->get_unit_page_name($i);
                            ?>

													<label for="page_<?php 
                            echo $unit->ID . '_' . $i;
                            ?>
">
														<div class="tree-page-left">
															<?php 
                            echo isset($page_title) && $page_title !== '' ? $page_title : __('Untitled Page', 'cp');
                            ?>
														</div>
														<div class="tree-page-right">
															<?php 
                            if ($this->details->course_structure_time_display == 'on') {
                                ?>
																<span><?php 
                                echo $unit_class->get_unit_page_time_estimation($unit->ID, $i);
                                ?>
</span>
															<?php 
                            }
                            ?>
															<?php 
                            if (isset($preview_page[$unit->ID . '_' . $i]) && $preview_page[$unit->ID . '_' . $i] == 'on') {
                                ?>
																<a href="<?php 
                                echo Unit::get_permalink($unit->ID);
                                ?>
page/<?php 
                                echo $i;
                                ?>
?try" class="preview_option"><?php 
                                if ($try_title == '') {
                                    _e('Try Now', 'cp');
                                } else {
                                    echo $try_title;
                                }
                                ?>
</a>
															<?php 
                            }
                            ?>

														</div>
													</label>

													<?php 
                            ?>
												</li>
												<?php 
                        }
                    }
                    //page visible
                    ?>

									</ul>
								</li>
								<?php 
                }
                //unit visible
                if (!$echo) {
                    trim(ob_get_clean());
                }
            }
            ?>

					</ul>
					<?php 
        }