Tribe__PUE__Checker::do_license_key_fields( array $fields )

Inserts license key fields on license key page


Parameters

$fields

(array) (Required) List of fields.


Top ↑

Return

(array) Modified list of fields.


Top ↑

Source

File: src/Tribe/PUE/Checker.php

		public function do_license_key_fields( $fields ) {
			// common fields whether licenses should be hidden or not
			$to_insert = array(
				$this->pue_install_key . '-heading' => array(
					'type'  => 'heading',
					'label' => $this->get_plugin_name(),
				),
			);

			$no_license_tooltip = esc_html__( 'A valid license key is required for support and updates', 'tribe-common' );
			if ( 'event-aggregator' === $this->get_slug() ) {
				$no_license_tooltip = sprintf(
					esc_html__( '%1$sBuy a license%2$s for the Event Aggregator service to access additional import features.', 'tribe-common' ),
					'<a href="https://m.tri.be/196y" target="_blank">',
					'</a>'
				);
			}

			// we want to inject the following license settings at the end of the licenses tab
			if ( $this->should_show_network_editable_license() ) {
				$to_insert[ $this->pue_install_key ] = array(
					'type'            => 'license_key',
					'size'            => 'large',
					'validation_type' => 'license_key',
					'label'           => sprintf( esc_attr__( 'License Key', 'tribe-common' ) ),
					'default'         => $this->get_key( 'default' ),
					'tooltip'         => $no_license_tooltip,
					'parent_option'   => false,
					'network_option'  => true,
				);
			} elseif ( $this->should_show_subsite_editable_license() ) {
				$to_insert[ $this->pue_install_key ] = array(
					'type'            => 'license_key',
					'size'            => 'large',
					'validation_type' => 'license_key',
					'label'           => sprintf( esc_attr__( 'License Key', 'tribe-common' ) ),
					'default'         => $this->get_key( 'default' ),
					'tooltip'         => $no_license_tooltip,
					'parent_option'   => false,
					'network_option'  => false,
				);
			} elseif ( $this->should_show_overrideable_license() ) {
				$to_insert[ $this->pue_install_key . '-state' ] = array(
					'type'  => 'html',
					'label' => sprintf( esc_attr__( 'License Key Status:', 'tribe-common' ) ),
					'label_attributes' => array( 'style' => 'width:auto;' ),
					'html'  => sprintf( '<p>%s</p>', $this->get_network_license_state_string() ),
				);

				$override_id = $this->pue_install_key . '-override';

				$to_insert[ $override_id ] = array(
					'type'            => 'checkbox_bool',
					'label'           => esc_html__( 'Override network license key', 'tribe-common' ),
					'tooltip'         => esc_html__( 'Check this box if you wish to override the network license key with your own', 'tribe-common' ),
					'default'         => false,
					'validation_type' => 'boolean',
					'parent_option'   => false,
					'attributes'      => array( 'id' => $override_id . '-field' ),
				);

				$to_insert[ $this->pue_install_key ] = array(
					'type'                => 'license_key',
					'size'                => 'large',
					'validation_type'     => 'license_key',
					'label'               => sprintf( esc_attr__( 'Site License Key', 'tribe-common' ) ),
					'tooltip'             => $no_license_tooltip,
					'parent_option'       => false,
					'network_option'      => false,
					'class'               => 'tribe-dependent',
					'fieldset_attributes' => array(
						'data-depends'           => '#' . $override_id . '-field',
						'data-condition-checked' => true,
					),
				);
			} else {
				$to_insert[ $this->pue_install_key . '-state' ] = array(
					'type'  => 'html',
					'label' => sprintf( esc_attr__( 'License Key Status:', 'tribe-common' ) ),
					'label_attributes' => array( 'style' => 'width:auto;' ),
					'html'  => sprintf( '<p>%s</p>', $this->get_network_license_state_string() ),
				);
			}

			$fields    = self::array_insert_after_key( 'tribe-form-content-start', $fields, $to_insert );

			return $fields;
		}