[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@3.135.218.67: ~ $
<?php
/**
 * LearnDash class to handle Search integration
 *
 * @package LearnDash\Search
 * @since 3.1.7
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

if ( ! class_exists( 'LearnDash_Search' ) ) {

	/**
	 * Class for handling the LearnDash Search.
	 */
	class LearnDash_Search {

		/**
		 * Is Search Query.
		 *
		 * @var boolean $is_search_query;
		 */
		private $is_search_query = false;

		/**
		 * User ID used for Search.
		 *
		 * @var integer $user_id;
		 */
		private $user_id = 0;

		/**
		 * User Enrolled Courses.
		 *
		 * @var array $enrolled_courses;
		 */
		private $enrolled_courses = array();

		/**
		 * Searchable LearnDash Post Types.
		 *
		 * @var array $searchable_post_types;
		 */
		private $searchable_post_types = array();

		/**
		 * Changed LearnDash Post Types.
		 *
		 * @var array $changed_post_types;
		 */
		private $changed_post_types = array();

		/**
		 * LearnDash_Search constructor.
		 */
		public function __construct() {

			add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ), 30, 1 );
			add_filter( 'posts_where_request', array( $this, 'posts_where_request' ), 30, 2 );
			add_filter( 'posts_join_request', array( $this, 'posts_join_request' ), 30, 2 );
			add_filter( 'posts_distinct_request', array( $this, 'posts_distinct_request' ), 30, 2 );
		}

		/**
		 * Filter WP_Query instance to add LD search logic.
		 *
		 * @param Object $query WP_Query object.
		 */
		public function pre_get_posts( $query ) {
			global $wp_post_types;

			$this->is_search_query = false;
			if ( ( $query->is_main_query() ) && ( ! is_admin() ) && ( $query->is_search ) ) {

				$in_search_post_types = get_post_types( array( 'exclude_from_search' => false ) );
				$ld_post_types        = learndash_get_post_types( 'course_steps' );

				$ld_post_types = array_intersect( $ld_post_types, $in_search_post_types );
				if ( ! empty( $ld_post_types ) ) {

					if ( is_user_logged_in() ) {
						$this->user_id          = get_current_user_id();
						$this->enrolled_courses = learndash_user_get_enrolled_courses( $this->user_id, array(), true );
						if ( ! empty( $this->enrolled_courses ) ) {
							foreach ( $ld_post_types as $ld_post_type ) {
								if ( isset( $wp_post_types[ $ld_post_type ] ) ) {
									if ( learndash_post_type_search_param( $ld_post_type, 'search_enrolled_only' ) ) {
										$this->searchable_post_types[] = $ld_post_type;
									}
								}
							}

							if ( ! empty( $this->searchable_post_types ) ) {
								$this->is_search_query = true;
							}
						} else {
							foreach ( $ld_post_types as $ld_post_type ) {
								if ( isset( $wp_post_types[ $ld_post_type ] ) ) {
									if ( learndash_post_type_search_param( $ld_post_type, 'search_enrolled_only' ) ) {
										$wp_post_types[ $ld_post_type ]->exclude_from_search = true;
									}
								}
							}
						}
					} else {
						// If we don't have any enrolled courses we remove the LearnDash CPTs from the search.
						foreach ( $ld_post_types as $ld_post_type ) {
							if ( isset( $wp_post_types[ $ld_post_type ] ) ) {
								if ( learndash_post_type_search_param( $ld_post_type, 'search_login_only' ) ) {
									$wp_post_types[ $ld_post_type ]->exclude_from_search = true;
								}
							}
						}
					}
				}
			}
		}

		/**
		 * Filter WP_Query 'where' string to add LD search logic.
		 *
		 * @param string $where SQL where part.
		 * @param Object $query WP_Query object.
		 * @return string $where.
		 */
		public function posts_where_request( $where, $query ) {
			global $wpdb;

			if ( ( true === $this->is_search_query ) && ( ! empty( $this->searchable_post_types ) ) ) {
				if ( ( ! isset( $query->query_vars['meta_query'] ) ) || ( empty( $query->query_vars['meta_query'] ) ) ) {
					$searchable_post_types_str = '';
					if ( ! empty( $this->searchable_post_types ) ) {
						foreach ( $this->searchable_post_types as $post_type ) {
							if ( ! empty( $searchable_post_types_str ) ) {
								$searchable_post_types_str .= ',';
							}
							$searchable_post_types_str .= "'" . esc_sql( $post_type ) . "'";
						}
					}

					$searchable_course_ids        = '';
					$searchable_shared_course_ids = '';
					if ( ! empty( $this->enrolled_courses ) ) {
						foreach ( $this->enrolled_courses as $course_id ) {
							if ( ! empty( $searchable_course_ids ) ) {
								$searchable_course_ids .= ',';
							}
							$searchable_course_ids .= absint( $course_id );
						}

						if ( 'yes' === LearnDash_Settings_Section::get_section_setting( 'LearnDash_Settings_Courses_Builder', 'shared_steps' ) ) {
							foreach ( $this->enrolled_courses as $course_id ) {
								if ( ! empty( $searchable_shared_course_ids ) ) {
									$searchable_shared_course_ids .= ',';
								}
								$searchable_shared_course_ids .= "'ld_course_" . absint( $course_id ) . "'";
							}
						}

						$where_ld = '';
						if ( ! empty( $searchable_post_types_str ) ) {
							$where_ld .= " ( {$wpdb->posts}.post_type NOT IN ( {$searchable_post_types_str} ) ) ";
							$where_ld .= ' OR (';
							$where_ld .= " ( {$wpdb->posts}.post_type IN ( {$searchable_post_types_str} ) ) ";

							if ( ! empty( $searchable_course_ids ) ) {
								$where_ld .= " AND ( ( {$wpdb->postmeta}.meta_key = 'course_id' AND {$wpdb->postmeta}.meta_value IN ( {$searchable_course_ids} ) ) ";
								if ( ! empty( $searchable_shared_course_ids ) ) {
									$where_ld .= " OR ( {$wpdb->postmeta}.meta_key IN ( {$searchable_shared_course_ids} ) ) ";
								}
								$where_ld .= ')';
							}
							$where_ld .= ') ';
						}

						if ( ! empty( $where_ld ) ) {
							$where .= ' AND (' . $where_ld . ')';
						}
					}
				} else {
					$this->is_search_query = false;
				}
			}
			return $where;
		}

		/**
		 * Filter WP_Query 'join' string to add LD search logic.
		 *
		 * @param string $join SQL join part.
		 * @param Object $query WP_Query object.
		 * @return string $join.
		 */
		public function posts_join_request( $join, $query ) {
			global $wpdb;

			if ( ( true === $this->is_search_query ) && ( ! empty( $this->searchable_post_types ) ) ) {
				if ( empty( $join ) ) {
					$join .= " LEFT JOIN {$wpdb->postmeta} as {$wpdb->postmeta} ON {$wpdb->posts}.ID={$wpdb->postmeta}.post_id ";
				}
			}
			return $join;
		}

		/**
		 * Filter WP_Query 'distinct' string to add LD search logic.
		 *
		 * @param string $distinct SQL distinct part.
		 * @param Object $query WP_Query object.
		 * @return string $distinct.
		 */
		public function posts_distinct_request( $distinct, $query ) {
			if ( ( true === $this->is_search_query ) && ( ! empty( $this->searchable_post_types ) ) ) {
				if ( empty( $distinct ) ) {
					$distinct .= ' DISTINCT ';
				}
			}
			return $distinct;
		}

		// End of functions.
	}
	$learndash_search = new LearnDash_Search();
}

Filemanager

Name Type Size Permission Actions
admin Folder 0755
classes Folder 0755
coupon Folder 0755
course Folder 0755
deprecated Folder 0755
dto Folder 0755
exam Folder 0755
group Folder 0755
gutenberg Folder 0755
helpers Folder 0755
import Folder 0755
interfaces Folder 0755
lib Folder 0755
licensing Folder 0755
loggers Folder 0755
models Folder 0755
payments Folder 0755
quiz Folder 0755
reports Folder 0755
rest-api Folder 0755
settings Folder 0755
shortcodes Folder 0755
site-health Folder 0755
views Folder 0755
widgets Folder 0755
class-ld-addons-updater.php File 35.03 KB 0644
class-ld-bitbucket-api.php File 59.32 KB 0644
class-ld-course-wizard.php File 29.51 KB 0644
class-ld-cpt-instance.php File 34.14 KB 0644
class-ld-cpt-widget.php File 198 B 0644
class-ld-cpt.php File 18.17 KB 0644
class-ld-custom-label.php File 24.3 KB 0644
class-ld-design-wizard.php File 37.05 KB 0644
class-ld-gdpr.php File 48.61 KB 0644
class-ld-lms.php File 224.76 KB 0644
class-ld-permalinks.php File 29.92 KB 0644
class-ld-search.php File 6.66 KB 0644
class-ld-semper-fi-module.php File 61.88 KB 0644
class-ld-setup-wizard.php File 23.09 KB 0644
class-ld-translations.php File 28.85 KB 0644
class-ldlms-db.php File 19.01 KB 0644
class-ldlms-post-types.php File 8.64 KB 0644
class-ldlms-transients.php File 5.04 KB 0644
ld-assignment-uploads.php File 38.35 KB 0644
ld-autoupdate.php File 241 B 0644
ld-certificates.php File 26.74 KB 0644
ld-convert-post-pdf.php File 31.07 KB 0644
ld-core-functions.php File 857 B 0644
ld-groups.php File 92.44 KB 0644
ld-license.php File 12.93 KB 0644
ld-misc-functions.php File 72.5 KB 0644
ld-reports.php File 59.38 KB 0644
ld-scripts.php File 6.89 KB 0644
ld-users.php File 47.6 KB 0644
ld-wp-editor.php File 3.46 KB 0644