there, I have noticed that there are a tonne of shortcodes

Hi there,

I have noticed that there are a tonne of shortcodes for this plugin but there is not a shortcode for individual units. For example, I have 4 units in my one course and I would like to display then in different areas using short codes. Is this possible?

  • Tyler Postle

    Hey Victor,

    Hope you're doing well today!

    Are you wanting to display the units so they can actually be worked through in these different areas?

    Right now it's not possible to do that; however, you can present the course structure using the [course_structure] shortcode. Then you could have links to the course itself.

    I'll mark this as a feature request though, to be able to display parts of a course via shortcode.

    If you have any further questions on this just let us know.

    Cheers,
    Tyler

  • Victor

    Hi there,

    This definitely helped a bit with my issue but now I am having a different issue.

    If you visit http://greenlearning.greenlivingstaging.com/programs/real-world-energy/ you'll notice that I was able to change "FREE" to "Preview this lesson". This only appears when the user is logged out because I have this set to be a free preview.

    The lessons below that are locked are just dead text. I would love if I could add test in the same "right-tree" for them that said "Signup to Unlock". I can't seem to find anywhere in the backend where this is possible.

    Also, is it possible to use font-awesome instead of text in these situations?

    Cheers,
    Victor

    Please see Attached image for more explanations.

  • Tyler Postle

    Hey Victor,

    Adding the signup to unlock and using fontawesome currently aren't supported.

    However, I'm going to flag one of our SLS staff(coding experts) on this so we can get their valuable feedback on both adding the text to the login required courses and adding in font-awesome. If it is something easily done then we can point you in the right direction or provide a snippet to help out :slight_smile:

    Keep in mind, SLS deal with more advanced issues so their responses can sometimes take a little longer. If you have any questions in the meantime just let us know.

    All the best,
    Tyler

  • Sajid

    Hi @Victor,

    Hope you are doing good today :slight_smile:

    If you want to override the output of course structure in child theme then just add the following code in functions.php file of your child theme and feel free to edit anything you want here without fear of losing changes when you will update the plugin.

    function remove_parent_theme_shortcode(){
    	//Remove parent shortcode
    	remove_shortcode( 'course_structure' );
    
    	//Now load the same shortocode in child them.
    	add_shortcode('course_structure', 'child_course_structure_cb');
    
    }
    add_action('init', 'remove_parent_theme_shortcode');
    
    function child_course_structure_cb( $atts ) {
    			extract( shortcode_atts( array(
    				'course_id'       => in_the_loop() ? get_the_ID() : '',
    				'course'          => false,
    				'free_text'       => __( 'Free', 'cp' ),
    				'free_show'       => 'true',
    				'show_title'      => 'no',
    				'show_label'      => 'no',
    				'label_delimeter' => ': ',
    				'label_tag'       => 'h2',
    				'show_divider'    => 'yes',
    				'label'           => __( 'Course Structure', 'cp' ),
    				'class'           => '',
    			), $atts, 'course_structure' ) );
    
    			$course_id       = (int) $course_id;
    			$free_text       = sanitize_text_field( $free_text );
    			$free_show       = sanitize_text_field( $free_show );
    			$free_show       = 'true' == $free_show ? true : false;
    			$show_title      = sanitize_html_class( $show_title );
    			$show_label      = sanitize_html_class( $show_label );
    			$label_delimeter = sanitize_html_class( $label_delimeter );
    			$label_tag       = sanitize_html_class( $label_tag );
    			$show_divider    = sanitize_html_class( $show_divider );
    			$label           = sanitize_text_field( $label );
    			$class           = sanitize_html_class( $class );
    
    			// Saves some overhead by not loading the post again if we don't need to.
    			$course          = empty( $course ) ? new Course( $course_id ) : object_decode( $course, 'Course' );
    			$class           = sanitize_html_class( $class );
    			$label_tag       = sanitize_html_class( $label_tag );
    			$label_delimeter = sanitize_html_class( $label_delimeter );
    
    			if ( $course->details->course_structure_options == 'on' ) {
    				$content = '';
    
    				$student          = new Student( get_current_user_id() );
    				$existing_student = $student->has_access_to_course( $course_id );
    
    				$show_unit    = $course->details->show_unit_boxes;
    				$preview_unit = $course->details->preview_unit_boxes;
    
    				$show_page    = $course->details->show_page_boxes;
    				$preview_page = $course->details->preview_page_boxes;
    
    				$current_time      = date( 'Y-m-d', current_time( 'timestamp', 0 ) );
    				$course_start_date = $course->details->course_start_date;
    
    				$enable_links = false;
    				if ( $current_time >= $course_start_date ) {
    					$enable_links = true;
    				}
    
    				$units = $course->get_units();
    
    				$content .= '<div class="course-structure-block course-structure-block-' . $course_id . '">';
    
    				if ( ! empty( $label ) ) {
    					$content .= '<' . $label_tag . ' class="label">' . $label . $label_delimeter . '</' . $label_tag . '>';
    				}
    
    				$content .= 'yes' == $show_title ? '<label>' . $this->details->post_title . '</label>' : '';
    
    				if ( $units ) {
    					ob_start();
    					?>
    					<ul class="tree">
    						<li>
    							<ul>
    								<?php
    								foreach ( $units as $unit ) {
    									$unit_id = $unit['post']->ID;
    									$unit_post = $unit['post'];
    									$unit_class = new Unit( $unit_id );
    
    									$unit_pagination = cp_unit_uses_new_pagination( $unit_id );
    
    									if ( $unit_pagination ) {
    										$unit_pages = coursepress_unit_pages( $unit_id, $unit_pagination );
    									} else {
    										$unit_pages = coursepress_unit_pages( $unit_id );
    									}
    
    									//$unit_pages	 = $unit_class->get_number_of_unit_pages();
    									//									$modules = Unit_Module::get_modules( $unit_id );
    									$unit_permalink = Unit::get_permalink( $unit_id );
    									if ( isset( $show_unit[ $unit_id ] ) && $show_unit[ $unit_id ] == 'on' && $unit_post->post_status == 'publish' ) {
    										?>
    										<li>
    											<label for="unit_<?php echo $unit_id; ?>" class="course_structure_unit_label <?php echo $existing_student ? 'single_column' : ''; ?>">
    												<?php
    												$title = '';
    												if ( $existing_student && $enable_links ) {
    													$title = '<a href="' . $unit_permalink . '">' . $unit_post->post_title . '</a>';
    												} else {
    													$title = $unit_post->post_title;
    												}
    												?>
    												<div class="tree-unit-left"><?php echo $title; ?></div>
    												<div class="tree-unit-right">
    
    													<?php if ( $course->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' && $unit_permalink && ! $existing_student ) {
    														?>
    														<a href="<?php echo $unit_permalink; ?>?try" class="preview_option"><?php echo $free_text; ?></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 echo $existing_student ? 'single_column' : ''; ?>">
    															<?php
    															$pages_num  = 1;
    															$page_title = $unit_class->get_unit_page_name( $i );
    															?>
    
    															<label for="page_<?php echo $unit_id . '_' . $i; ?>">
    																<?php
    																$title = '';
    																if ( $existing_student && $enable_links ) {
    																	$p_title = isset( $page_title ) && $page_title !== '' ? $page_title : __( 'Untitled Page', 'cp' );
    																	$title   = '<a href="' . trailingslashit( $unit_permalink ) . trailingslashit( 'page' ) . trailingslashit( $i ) . '">' . $p_title . '</a>';
    																} else {
    																	$title = isset( $page_title ) && $page_title !== '' ? $page_title : __( 'Untitled Page', 'cp' );
    																}
    																?>
    
    																<div class="tree-page-left">
    																	<?php echo $title; ?>
    																</div>
    																<div class="tree-page-right">
    
    																	<?php if ( $course->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' && $unit_permalink && ! $existing_student ) {
    																		?>
    																		<a href="<?php echo $unit_permalink; ?>page/<?php echo $i; ?>?try" class="preview_option"><?php echo $free_text; ?></a>
    																	<?php } ?>
    
    																</div>
    															</label>
    
    															<?php ?>
    														</li>
    													<?php
    													}
    												}//page visible
    												?>
    
    											</ul>
    										</li>
    									<?php
    									}//unit visible
    								} // foreach
    								?>
    							</ul>
    						</li>
    					</ul>
    
    					<?php if ( $show_divider == 'yes' ) { ?>
    						<div class="divider"></div>
    					<?php } ?>
    
    					<?php
    					$content .= trim( ob_get_clean() );
    				} else {
    
    				}
    
    				$content .= '</div>';
    
    				return $content;
    			}
    		}

    If you still need help with it feel free to post a reply here and I will be glad to assist :slight_smile:

    Cheers, Sajid

  • Sajid

    Hi @Victor,

    Hope you are doing good and glad that helped :slight_smile:

    For signup button find below code:

    <?php
    																	if ( isset( $preview_page[ $unit_id . '_' . $i ] ) && $preview_page[ $unit_id . '_' . $i ] == 'on' && $unit_permalink && ! $existing_student ) {
    																		?>
    																		<a href="<?php echo $unit_permalink; ?>page/<?php echo $i; ?>?try" class="preview_option"><?php echo $free_text; ?></a>
    																	<?php } ?>

    And replace it with this one:

    <?php
    																	if ( isset( $preview_page[ $unit_id . '_' . $i ] ) && $preview_page[ $unit_id . '_' . $i ] == 'on' && $unit_permalink && ! $existing_student ) {
    																		?>
    																		<a href="<?php echo $unit_permalink; ?>page/<?php echo $i; ?>?try" class="preview_option"><?php echo $free_text; ?></a>
    																	<?php }else{
    																			echo do_shortcode('[course_join_button class="custom_signup_button"]');
    																		} ?>

    Let me know how it goes :slight_smile:

    Cheers, Sajid

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.