public/wordpress/wp-content/plugins/wp-courseware/includes/controllers/units.php
/**
	 * Exclude Post Type Course Units from Search.
	 *
	 * @since 4.3.0
	 *
	 * @param WP_Query $query The current query.
	 */
Exclude Post Type Course Units from Search.

@param WP_Query $query The current query.
Exclude Post Type Course Units from Search . @param WP_Query $query The current query .
public function post_type_exclude_from_search( $query ) {
		if ( is_admin() || ! $query->is_main_query() ) {
			return;
		}
		$current_post_type = $query->get( 'post_type' );
		if ( $current_post_type && 'course_unit' !== $current_post_type ) {
			return;
		}
		if ( $query->is_home() && apply_filters( 'wpcw_units_exclude_from_home_query', true ) ) {
			$query->set( 'post_type', '' );
		}
		if ( $query->is_search() && apply_filters( 'wpcw_units_exclude_from_search', true ) ) {
			$post_type_to_remove   = $this->post_type_slug;
			$searchable_post_types = get_post_types( array( 'exclude_from_search' => false ) );
			if ( is_array( $searchable_post_types ) && in_array( $post_type_to_remove, $searchable_post_types ) ) {
				unset( $searchable_post_types[ $post_type_to_remove ] );
				$query->set( 'post_type', $searchable_post_types );
			}
		}
	}
public function post_type_exclude_from_search ( $ query ) { if ( is_admin ( ) || ! $ query -> is_main_query ( ) ) { return ; } $ current_post_type = $ query -> get ( 'post_type' ) ; if ( $ current_post_type && 'course_unit' !== $ current_post_type ) { return ; } if ( $ query -> is_home ( ) && apply_filters ( 'wpcw_units_exclude_from_home_query' , true ) ) { $ query -> set ( 'post_type' , '' ) ; } if ( $ query -> is_search ( ) && apply_filters ( 'wpcw_units_exclude_from_search' , true ) ) { $ post_type_to_remove = $ this -> post_type_slug ; $ searchable_post_types = get_post_types ( array ( 'exclude_from_search' => false ) ) ; if ( is_array ( $ searchable_post_types ) && in_array ( $ post_type_to_remove , $ searchable_post_types ) ) { unset ( $ searchable_post_types [ $ post_type_to_remove ] ) ; $ query -> set ( 'post_type' , $ searchable_post_types ) ; } } }
Exclude Post Type Course Units from Search.
Exclude Post Type Course Units from Search .
// Current Post Type. // Check for post type. /**
		 * Filter: Units Exclude From Home Query.
		 *
		 * @since 4.4.2
		 *
		 * @param bool True if excluded, False otherwise.
		 *
		 * @return bool True if you want to exclude units from home query.
		 */ /**
		 * Filter: Units Exclude From Search
		 *
		 * @since 4.3.0
		 *
		 * @param bool True if excluded, False otherwise.
		 *
		 * @return bool True if you want to exclude units from search.
		 */