Wishlist_Member_Helpers::wm_get_all_membership_levels( null $label = null, string $option_code = 'WMMEMBERSHIPLEVELS',  $args = array() )


Parameters Parameters

$label

(null) (Optional)

Default value: null

$option_code

(string) (Optional)

Default value: 'WMMEMBERSHIPLEVELS'

$type

(string) (Required)


Top ↑

Return Return

(mixed|void)


Source Source

File: src/integrations/wishlist-member/helpers/wishlist-member-helpers.php

	public function wm_get_all_membership_levels( $label = null, $option_code = 'WMMEMBERSHIPLEVELS', $args = array() ) {
		if ( ! $this->load_options ) {


			return Automator()->helpers->recipe->build_default_options_array( $label, $option_code );
		}

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

		$token        = key_exists( 'token', $args ) ? $args['token'] : false;
		$is_ajax      = key_exists( 'is_ajax', $args ) ? $args['is_ajax'] : false;
		$target_field = key_exists( 'target_field', $args ) ? $args['target_field'] : '';
		$end_point    = key_exists( 'endpoint', $args ) ? $args['endpoint'] : '';
		$include_all  = key_exists( 'include_all', $args ) ? $args['include_all'] : false;
		$any          = key_exists( 'any', $args ) ? $args['any'] : false;

		$options = array();
		if ( $include_all ) {
			$options['-1'] = esc_attr__( 'All levels', 'uncanny-automator' );
		}

		if ( $any ) {
			$options['-1'] = esc_attr__( 'Any level', 'uncanny-automator' );
		}
		$levels = wlmapi_get_levels();

		if ( ! empty( $levels['levels']['level'] ) ) {
			foreach ( $levels['levels']['level'] as $level ) {
				$options[ $level['id'] ] = $level['name'];
			}
		}

		$option = [
			'option_code'     => $option_code,
			'label'           => $label,
			'input_type'      => 'select',
			'required'        => true,
			'supports_tokens' => $token,
			'is_ajax'         => $is_ajax,
			'fill_values_in'  => $target_field,
			'endpoint'        => $end_point,
			'options'         => $options,
			'relevant_tokens' => [
				$option_code => esc_attr__( 'Membership Level', 'uncanny-automator' ),
			],
		];

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