[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@52.15.190.187: ~ $
<?php
/**
 * LearnDash Elementor template-related integration class.
 *
 * @since 1.0.5
 *
 * @package LearnDash\Elementor
 */

namespace LearnDash\Elementor;

use LearnDash\Elementor\Utilities\Post;

/**
 * Template-related integration class.
 *
 * @since 1.0.5
 */
class Templates {
	/**
	 * Check whether we need to import default templates or not.
	 *
	 * @since 1.0.5
	 *
	 * @return void
	 */
	public function check_import_templates(): void {
		$changes                  = false;
		$learndash_elementor_data = get_option( 'learndash_elementor_data', [] );

		if (
			! is_array( $learndash_elementor_data )
			|| empty( $learndash_elementor_data )
		) {
			$changes                  = true;
			$learndash_elementor_data = [];
		}

		if ( ! isset( $learndash_elementor_data['version'] ) ) {
			$changes                             = true;
			$learndash_elementor_data['version'] = LEARNDASH_ELEMENTOR_VERSION;
		}

		if ( ! isset( $learndash_elementor_data['templates_imported'] ) ) {
			$changes            = true;
			$templates_imported = $this->import_templates();

			if ( $templates_imported ) {
				$learndash_elementor_data['templates_imported'] = $templates_imported;
			}
		}

		if ( true === $changes ) {
			update_option( 'learndash_elementor_data', $learndash_elementor_data );
		}
	}

	/**
	 * Import default Course, Lesson, Topic and Quiz templates.
	 *
	 * Called from the admin_footer action hook.
	 *
	 * @since 1.0.5
	 * @since 1.0.6   Return bool value.
	 *
	 * @return bool True if import is successful, false otherwise.
	 */
	private function import_templates(): bool {
		$exports_dir = LEARNDASH_ELEMENTOR_PLUGIN_DIR . 'src/data/templates';

		if (
			! file_exists( $exports_dir )
			|| ! function_exists( 'learndash_scandir_recursive' )
		) {
			return false;
		}

		$import_files = learndash_scandir_recursive( $exports_dir );

		if ( empty( $import_files ) ) {
			return false;
		}

		$source = \Elementor\Plugin::$instance->templates_manager->get_source( 'local' );

		if ( ! $source instanceof \Elementor\TemplateLibrary\Source_Local ) {
			return false;
		}

		foreach ( $import_files as $import_file ) {
			if (
				'.' !== $import_file[0]
				&& '.json' === substr( $import_file, -1 * strlen( '.json' ), strlen( '.json' ) )
			) {
				$source->import_template( basename( $import_file ), $import_file );
			}
		}

		return true;
	}

	/**
	 * Filter LearnDash templates.
	 *
	 * @since 1.0.5
	 *
	 * @param string     $filepath         Template file path.
	 * @param string     $name             Template name.
	 * @param array|null $args             Template data.
	 * @param bool|null  $echo             Whether to echo the template output or not.
	 * @param bool       $return_file_path Whether to return file or path or not.
	 *
	 * @return string
	 */
	public function filter_learndash_template( $filepath, $name, $args, $echo, $return_file_path ): string {
		if ( ! Post::is_elementor() ) {
			return $filepath;
		}

		switch ( $name ) {
			case 'course':
				$filepath = LEARNDASH_ELEMENTOR_VIEWS_DIR . 'themes/ld30/course/index.php';
				break;

			case 'lesson':
				$filepath = LEARNDASH_ELEMENTOR_VIEWS_DIR . 'themes/ld30/lesson/index.php';
				break;

			case 'topic':
				$filepath = LEARNDASH_ELEMENTOR_VIEWS_DIR . 'themes/ld30/topic/index.php';
				break;

			case 'quiz':
				$filepath = LEARNDASH_ELEMENTOR_VIEWS_DIR . 'themes/ld30/quiz/index.php';
				break;

			case 'course/listing.php':
				if (
					(
						! isset( $args['source'] )
						|| $args['source'] !== 'elementor'
					) && (
						! isset( $args['context'] )
						|| ! strpos( $args['context'], 'shortcode' )
					)
				) {
					$filepath = '';
				}
				break;
		}

		return $filepath;
	}
}

Filemanager

Name Type Size Permission Actions
Admin Folder 0755
Documents Folder 0755
Settings Folder 0755
Shortcodes Folder 0755
Utilities Folder 0755
Widgets Folder 0755
App.php File 238 B 0644
Compatibility.php File 521 B 0644
Container.php File 244 B 0644
Dependency_Checker.php File 6.84 KB 0644
Documents.php File 1.2 KB 0644
Editor.php File 525 B 0644
Elements.php File 650 B 0644
Frontend.php File 6.78 KB 0644
Plugin.php File 2.56 KB 0644
Provider.php File 327 B 0644
Step.php File 696 B 0644
Templates.php File 3.63 KB 0644
Utilities.php File 1.32 KB 0644
Widgets.php File 3.19 KB 0644