Browse: Home / Snippets /

Template call sequence

Contents


Snippet #

// Add the following block of code to the LD file includes/class-ld-lms.php line 4651. This will output the parent paths when the get_template() function is called. 

$file_pathinfo = pathinfo( $filepath );
if ( ( 'php' === $file_pathinfo['extension'] ) && ( 'learndash_template_functions' !== $file_pathinfo['filename'] ) ) {
	$calling_functions_trace = array();
	$ld_file_found = false;
	$LEARNDASH_LMS_PLUGIN_DIR_tmp = str_replace( '\\', '/', LEARNDASH_LMS_PLUGIN_DIR );
				
	$calling_functions = debug_backtrace();
	if ( ! empty( $calling_functions ) ) {

		foreach ( $calling_functions as $idx => $calling_function ) {
			if ( ( isset( $calling_function['file'] ) ) && ( strncmp( $calling_function['file'], $LEARNDASH_LMS_PLUGIN_DIR_tmp, strlen( $LEARNDASH_LMS_PLUGIN_DIR_tmp ) ) == 0 ) ) {
				$ld_file_found = true;
				$calling_file = str_replace( $LEARNDASH_LMS_PLUGIN_DIR_tmp, '', $calling_function['file'] );
				$calling_functions_trace[] = $calling_file . ':' . $calling_function['line'];
			} else if ( true === $ld_file_found ) {
				$ld_file_found = false;
				break;
			}
		}
	}

	if ( ! empty( $calling_functions_trace ) ) {
		$calling_functions_trace = array_reverse( $calling_functions_trace, true );
		error_log( $name . ': ' . implode( ' > ', $calling_functions_trace ) . ' > ' . str_replace( $LEARNDASH_LMS_PLUGIN_DIR_tmp, '', $filepath ) );
	}
}

In the output it starts from the LD core file includes/class-ld-cpt-instance.php. This is the starting point for showing a Course, Lesson, Topic, or Quiz. 

Then from that file there is a call to the template file course.php. Then from within the course.php template at line 101, there is a call to the template infobar.php etc. And this cascades deep at some levels. 
---------------------------------------------------------------------------------

includes/class-ld-cpt-instance.php:424 > themes/ld30/templates/course.php

includes/class-ld-cpt-instance.php:426 > themes/ld30/templates/course.php:101 > themes/ld30/templates/modules/infobar.php

includes/class-ld-cpt-instance.php:426 > themes/ld30/templates/course.php:101 > themes/ld30/templates/modules/infobar.php:48 > themes/ld30/templates/modules/infobar/course.php

includes/class-ld-cpt-instance.php:426 > themes/ld30/templates/course.php:101 > themes/ld30/templates/modules/infobar.php:48 > themes/ld30/templates/modules/infobar/course.php:58 > themes/ld30/templates/modules/progress.php

includes/class-ld-cpt-instance.php:426 > themes/ld30/templates/course.php:127 > themes/ld30/templates/modules/tabs.php

includes/class-ld-cpt-instance.php:426 > themes/ld30/templates/course.php:242 > themes/ld30/templates/course/listing.php

includes/class-ld-cpt-instance.php:426 > themes/ld30/templates/course.php:242 > themes/ld30/templates/course/listing.php:87 > themes/ld30/templates/lesson/partials/row.php

includes/class-ld-cpt-instance.php:426 > themes/ld30/templates/course.php:242 > themes/ld30/templates/course/listing.php:87 > themes/ld30/templates/lesson/partials/row.php

includes/class-ld-cpt-instance.php:426 > themes/ld30/templates/course.php:242 > themes/ld30/templates/course/listing.php:87 > themes/ld30/templates/lesson/partials/row.php:281 > themes/ld30/templates/lesson/listing.php

includes/class-ld-cpt-instance.php:426 > themes/ld30/templates/course.php:242 > themes/ld30/templates/course/listing.php:87 > themes/ld30/templates/lesson/partials/row.php:281 > themes/ld30/templates/lesson/listing.php:135 > themes/ld30/templates/topic/partials/row.php

includes/class-ld-cpt-instance.php:426 > themes/ld30/templates/course.php:242 > themes/ld30/templates/course/listing.php:87 > themes/ld30/templates/lesson/partials/row.php:281 > themes/ld30/templates/lesson/listing.php:135 > themes/ld30/templates/topic/partials/row.php:94 > themes/ld30/templates/quiz/partials/row.php

includes/class-ld-cpt-instance.php:426 > themes/ld30/templates/course.php:242 > themes/ld30/templates/course/listing.php:87 > themes/ld30/templates/lesson/partials/row.php

includes/class-ld-cpt-instance.php:426 > themes/ld30/templates/course.php:242 > themes/ld30/templates/course/listing.php:87 > themes/ld30/templates/lesson/partials/row.php

includes/class-ld-cpt-instance.php:426 > themes/ld30/templates/course.php:242 > themes/ld30/templates/course/listing.php:87 > themes/ld30/templates/lesson/partials/row.php

includes/class-ld-cpt-instance.php:426 > themes/ld30/templates/course.php:242 > themes/ld30/templates/course/listing.php:87 > themes/ld30/templates/lesson/partials/row.php

includes/class-ld-cpt-instance.php:426 > themes/ld30/templates/course.php:242 > themes/ld30/templates/course/listing.php:87 > themes/ld30/templates/lesson/partials/row.php

includes/class-ld-cpt-instance.php:426 > themes/ld30/templates/course.php:242 > themes/ld30/templates/course/listing.php:87 > themes/ld30/templates/lesson/partials/row.php

includes/class-ld-cpt-instance.php:426 > themes/ld30/templates/course.php:242 > themes/ld30/templates/course/listing.php:87 > themes/ld30/templates/lesson/partials/row.php:281 > themes/ld30/templates/lesson/listing.php

includes/class-ld-cpt-instance.php:426 > themes/ld30/templates/course.php:242 > themes/ld30/templates/course/listing.php:87 > themes/ld30/templates/lesson/partials/row.php:281 > themes/ld30/templates/lesson/listing.php:135 > themes/ld30/templates/topic/partials/row.php

includes/class-ld-cpt-instance.php:426 > themes/ld30/templates/course.php:242 > themes/ld30/templates/course/listing.php:87 > themes/ld30/templates/lesson/partials/row.php

includes/class-ld-cpt-instance.php:426 > themes/ld30/templates/course.php:242 > themes/ld30/templates/course/listing.php:117 > themes/ld30/templates/quiz/partials/row.php

includes/class-ld-cpt-instance.php:426 > themes/ld30/templates/course.php:242 > themes/ld30/templates/course/listing.php:144 > themes/ld30/templates/modules/pagination.php