LLMS_Beaver_Builder::add_visibility_settings( array $form, string $id )

Add custom visibility settings for enrollments to the BB “Visibility” section.


Parameters Parameters

$form

(array) (Required) Settings form array.

$id

(string) (Required) ID of the row/module/col/etc.


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/class-llms-beaver-builder.php

	public function add_visibility_settings( $form, $id ) {

		$options = array(
			'llms_enrolled'     => esc_html__( 'Enrolled Students', 'lifterlms' ),
			'llms_not_enrolled' => esc_html__( 'Non-Enrolled Students and Visitors', 'lifterlms' ),
		);

		$toggle = array(
			'llms_enrolled'     => array(
				'fields' => array( 'llms_enrollment_type' ),
			),
			'llms_not_enrolled' => array(
				'fields' => array( 'llms_enrollment_type' ),
			),
		);

		$fields = array(
			'llms_enrollment_type'  => array(
				'type'    => 'select',
				'label'   => esc_html__( 'In', 'lifterlms' ),
				'options' => array(
					''         => esc_html__( 'Current Course or Membership', 'lifterlms' ),
					'any'      => esc_html__( 'Any Course(s) or Membership(s)', 'lifterlms' ),
					'specific' => esc_html__( 'Specific Course(s) and/or Membership(s)', 'lifterlms' ),
				),
				'toggle'  => array(
					'specific' => array(
						'fields' => array( 'llms_enrollment_match', 'llms_course_ids', 'llms_membership_ids' ),
					),
				),
				'help'    => esc_html__( 'Select how to check the enrollment status of the current student.', 'lifterlms' ),
				'preview' => array(
					'type' => 'none',
				),
			),
			'llms_enrollment_match' => array(
				'type'    => 'select',
				'label'   => esc_html__( 'Match', 'lifterlms' ),
				'options' => array(
					''    => esc_html__( 'Any of the following', 'lifterlms' ),
					'all' => esc_html__( 'All of the following', 'lifterlms' ),
				),
				'help'    => esc_html__( 'Select how to check the enrollment status of the current student.', 'lifterlms' ),
				'preview' => array(
					'type' => 'none',
				),
			),
			'llms_course_ids'       => array(
				'type'    => 'suggest',
				'action'  => 'fl_as_posts',
				'data'    => 'course',
				'label'   => esc_html__( 'Courses', 'lifterlms' ),
				'help'    => esc_html__( 'Choose which course(s) the student must be enrolled (or not enrolled) in to view this element.', 'lifterlms' ),
				'preview' => array(
					'type' => 'none',
				),
			),
			'llms_membership_ids'   => array(
				'type'    => 'suggest',
				'action'  => 'fl_as_posts',
				'data'    => 'llms_membership',
				'label'   => esc_html__( 'Memberships', 'lifterlms' ),
				'help'    => esc_html__( 'Choose which membership(s) the student must be enrolled (or not enrolled) in to view this element.', 'lifterlms' ),
				'preview' => array(
					'type' => 'none',
				),
			),
		);

		// Rows.
		if (
			isset( $form['tabs'] ) &&
			isset( $form['tabs']['advanced'] ) &&
			isset( $form['tabs']['advanced']['sections'] ) &&
			isset( $form['tabs']['advanced']['sections']['visibility'] )
		) {

			$form['tabs']['advanced']['sections']['visibility']['fields']['visibility_display']['options'] = array_merge( $form['tabs']['advanced']['sections']['visibility']['fields']['visibility_display']['options'], $options );
			$form['tabs']['advanced']['sections']['visibility']['fields']['visibility_display']['toggle']  = array_merge( $form['tabs']['advanced']['sections']['visibility']['fields']['visibility_display']['toggle'], $toggle );
			$form['tabs']['advanced']['sections']['visibility']['fields']                                  = array_merge( $form['tabs']['advanced']['sections']['visibility']['fields'], $fields );

			// Modules.
		} elseif (
			isset( $form['sections'] ) &&
			isset( $form['sections']['visibility'] )
		) {

			$form['sections']['visibility']['fields']['visibility_display']['options'] = array_merge( $form['sections']['visibility']['fields']['visibility_display']['options'], $options );
			$form['sections']['visibility']['fields']['visibility_display']['toggle']  = array_merge( $form['sections']['visibility']['fields']['visibility_display']['toggle'], $toggle );
			$form['sections']['visibility']['fields']                                  = array_merge( $form['sections']['visibility']['fields'], $fields );

		}

		return $form;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.7.0 Escaped strings.
1.5.3 Fixed localization textdomain.
1.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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