LLMS_Shortcode_Courses::get_post__in()

Retrieve an array of post ids based on submitted ID parameter and the mine parameter


Return Return

(array)


Top ↑

Source Source

File: includes/shortcodes/class.llms.shortcode.courses.php

	protected function get_post__in() {

		$ids     = array();
		$post_id = $this->get_attribute( 'id' );
		if ( $post_id ) {
			$ids = explode( ',', $post_id ); // Allow multiple ids to be passed.
			$ids = array_map( 'trim', $ids );
		}

		$student = llms_get_student();

		$mine = $this->get_attribute( 'mine' );
		if ( in_array( $mine, array( 'any', 'cancelled', 'enrolled', 'expired' ), true ) ) {

			$courses = $student->get_courses(
				array(
					'limit'  => 1000,
					'status' => $this->get_attribute( 'mine' ),
				)
			);

			$ids = $ids ? array_intersect( $ids, $courses['results'] ) : $courses['results'];

		}

		/**
		 * Filter the array of IDs returned for use in querying courses to display.
		 *
		 * @since 4.16.0
		 *
		 * @param array        $ids     The IDs of courses that will be displayed.
		 * @param LLMS_Student $student The student object for the current user.
		 * @param string       $mine    The "mine" attribute of the shortcode.
		 */
		return apply_filters( 'llms_courses_shortcode_get_post__in', $ids, $student, $mine );
	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.37.17 Use strict comparisons for in_array().
3.31.0 Changed access from private to protected.
3.14.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.