public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/frontend/templates.php
/**
 * Intercept the code that chooses what template to show for the unit.
 *
 * @since 1.0.0
 *
 * @param string $template The current template.
 *
 * @return string The path of the template file to use.
 */
Intercept the code that chooses what template to show for the unit.

@param string $template The current template.

@return string The path of the template file to use.
Intercept the code that chooses what template to show for the unit . @param string $template The current template . @return string The path of the template file to use .
function WPCW_templates_units_filterTemplateForUnit( $template ) {
	global $post;
	if ( 'course_unit' != $post->post_type ) {
		return $template;
	}
	$templateFile = get_post_meta( $post->ID, WPCW_TEMPLATE_META_ID, true );
	if ( ! $templateFile || 'no-template.php' === $templateFile ) {
		return $template;
	}
	if ( file_exists( trailingslashit( STYLESHEETPATH ) . $templateFile ) ) {
		return STYLESHEETPATH . DIRECTORY_SEPARATOR . $templateFile;
	} else if ( file_exists( TEMPLATEPATH . DIRECTORY_SEPARATOR . $templateFile ) ) {
		return TEMPLATEPATH . DIRECTORY_SEPARATOR . $templateFile;
	}
	return $template;
}
function WPCW_templates_units_filterTemplateForUnit ( $ template ) { global $ post ; if ( 'course_unit' != $ post -> post_type ) { return $ template ; } $ templateFile = get_post_meta ( $ post -> ID , WPCW_TEMPLATE_META_ID , true ) ; if ( ! $ templateFile || 'no-template.php' === $ templateFile ) { return $ template ; } if ( file_exists ( trailingslashit ( STYLESHEETPATH ) . $ templateFile ) ) { return STYLESHEETPATH . DIRECTORY_SEPARATOR . $ templateFile ; } else if ( file_exists ( TEMPLATEPATH . DIRECTORY_SEPARATOR . $ templateFile ) ) { return TEMPLATEPATH . DIRECTORY_SEPARATOR . $ templateFile ; } return $ template ; }
Intercept the code that chooses what template to show for the unit.
Intercept the code that chooses what template to show for the unit .
// What type of post are we showing? Only interested in course units. // Now we know we have a course unit, we need to see if there's a post template associated with it. // If there's a tpl in a (child theme or theme with no child) // else // If there's a tpl in the parent of the current child theme