Element_Type_Manager::enqueue_admin_scripts()

Enqueues form builder scripts for the available element types.

Description

Source

File: src/db-objects/elements/element-types/element-type-manager.php

	protected function enqueue_admin_scripts() {
		$services = array(
			'ajax'          => $this->elements()->ajax(),
			'assets'        => $this->elements()->assets(),
			'error_handler' => $this->elements()->error_handler(),
		);

		$dummy_manager = new Field_Manager( $this->get_prefix() . 'dummy_', $services, array(
			'get_value_callback'     => '__return_empty_array',
			'update_value_callback'  => '__return_empty_array',
			'name_prefix'            => $this->get_prefix() . 'dummy',
			'skip_js_initialization' => true,
		) );

		$added = array();
		foreach ( $this->element_types as $slug => $element_type ) {
			$fields = $element_type->get_settings_fields();
			foreach ( $fields as $field ) {
				if ( in_array( $field['type'], $added, true ) ) {
					continue;
				}

				$dummy_manager->add( 'dummy_' . $field['type'], $field['type'], array(
					'section' => 'main',
					'label'   => sprintf( 'Dummy %s', $field['type'] ),
				) );
				$added[] = $field['type'];
			}
		}

		$dummy_manager->enqueue();
	}

Changelog

Changelog
Version Description
1.0.0 Introduced.