API_Action::enqueue_form_builder_assets( awsmug\Torro_Forms\Modules\Actions\Assets $assets )

Enqueues scripts and stylesheets on the form editing screen.

Description

See also

Parameters

$assets

(awsmug\Torro_Forms\Modules\Actions\Assets) (Required) The plugin assets instance.

Source

File: src/modules/actions/api-action.php

	public function enqueue_form_builder_assets( $assets ) {
		$prefixed_script_handle = str_replace( '_', '-', $assets()->get_prefix() ) . 'admin-api-element-mapping';

		if ( ! self::$script_enqueued ) {
			$assets->enqueue_script( 'admin-api-element-mapping' );

			wp_add_inline_script( $prefixed_script_handle, 'var torroAPIElementMappings = [];', 'before' );

			self::$script_enqueued = true;
		}

		$form = null;
		if ( ! empty( $_GET['post'] ) ) {
			$form = $this->module->manager()->forms()->get( absint( $_GET['post'] ) );
		}

		$output = 'torroAPIElementMappings.push(' . wp_json_encode( $this->get_js_data( $form ) ) . ');';
		wp_add_inline_script( $prefixed_script_handle, $output, 'before' );
	}

Changelog

Changelog
Version Description
1.0.0 Introduced.