Memberpress_Courses_Helpers::all_mp_courses( string $label = null, string $option_code = 'MPCOURSE', bool $any_option = true )


Parameters Parameters

$label

(Optional)

Default value: null

$option_code

(Optional)

Default value: 'MPCOURSE'

$any_option

(Optional)

Default value: true


Top ↑

Return Return

(mixed)


Source Source

File: src/integrations/memberpress-courses/helpers/memberpress-courses-helpers.php

	public function all_mp_courses( $label = null, $option_code = 'MPCOURSE', $any_option = true ) {
		if ( ! $this->load_options ) {
			return Automator()->helpers->recipe->build_default_options_array( $label, $option_code );
		}

		if ( ! $label ) {
			$label = esc_attr__( 'Course', 'uncanny-automator' );
		}

		$args = array(
			'post_type'      => models\Course::$cpt,
			'posts_per_page' => 9999,
			'orderby'        => 'title',
			'order'          => 'ASC',
		);

		$options = Automator()->helpers->recipe->options->wp_query( $args, $any_option, esc_attr__( 'Any course', 'uncanny-automator' ) );

		$option = array(
			'option_code'              => $option_code,
			'label'                    => $label,
			'input_type'               => 'select',
			'required'                 => true,
			'options'                  => $options,
			'relevant_tokens'          => array(
				$option_code                => esc_attr__( 'Course title', 'uncanny-automator' ),
				$option_code . '_ID'        => esc_attr__( 'Course ID', 'uncanny-automator' ),
				$option_code . '_URL'       => esc_attr__( 'Course URL', 'uncanny-automator' ),
				$option_code . '_THUMB_ID'  => esc_attr__( 'Course featured image ID', 'uncanny-automator' ),
				$option_code . '_THUMB_URL' => esc_attr__( 'Course featured image URL', 'uncanny-automator' ),
			),
			'custom_value_description' => _x( 'Course ID', 'Memberpress', 'uncanny-automator' ),
		);

		return apply_filters( 'uap_option_all_mp_courses', $option );
	}