Restrict_Content_Helpers::get_membership_levels( null $label = null, string $option_code = null, $args = array() )
Contents
Parameters Parameters
- $label
-
(Optional)
Default value: null
- $option_code
-
(Optional)
Default value: null
- $type
-
(Required)
Return Return
(mixed|void)
Source Source
File: src/integrations/restrict-content/helpers/restrict-content-helpers.php
public function get_membership_levels( $label = null, $option_code = null, $args = array() ) { if ( ! $this->load_options ) { return Automator()->helpers->recipe->build_default_options_array( $label, $option_code ); } if ( null === $label ) { $label = esc_attr_x( 'Membership level', 'Restrict Content', 'uncanny-automator' ); } if ( null === $option_code ) { $option_code = 'RCMEMBERSHIPLEVEL'; } $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'] : ''; $any = key_exists( 'any', $args ) ? $args['any'] : false; $options = array(); if ( $any ) { $options['-1'] = esc_attr_x( 'Any membership', 'Restrict Content', 'uncanny-automator' ); } if ( function_exists( 'rcp_get_membership_levels' ) ) { // only available in Restrict Content Pro Version 3.4+ $levels = rcp_get_membership_levels( [ 'number' => 999 ] ); if ( ! empty( $levels ) ) { foreach ( $levels as $level ) { $options[ $level->get_id() ] = $level->get_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, ]; return apply_filters( 'uap_option_rc_get_membership_levels', $option ); }
Expand full source code Collapse full source code View on Github