ACF_Assets::enqueue_scriptspublicACF 5.9.0

Enqueues and localizes scripts.

Method of the class: ACF_Assets{}

Returns

void. Nothing (null).

Usage

$ACF_Assets = new ACF_Assets();
$ACF_Assets->enqueue_scripts();

Changelog

Since 5.9.0 Introduced.

ACF_Assets::enqueue_scripts() code ACF 6.8.8

public function enqueue_scripts() {
	// Enqueue input scripts.
	if ( in_array( 'input', $this->enqueue, true ) ) {
		wp_enqueue_script( 'acf-input' );
		wp_enqueue_style( 'acf-input' );
	}

	// Enqueue media scripts.
	if ( in_array( 'uploader', $this->enqueue, true ) ) {
		$this->enqueue_uploader();
	}

	// Localize text.
	acf_localize_text(
		array(
			// Tooltip
			'Are you sure?' => esc_html__( 'Are you sure?', 'acf' ),
			'Yes'           => esc_html__( 'Yes', 'acf' ),
			'No'            => esc_html__( 'No', 'acf' ),
			'Remove'        => esc_html__( 'Remove', 'acf' ),
			'Cancel'        => esc_html__( 'Cancel', 'acf' ),
			'Close modal'   => esc_html__( 'Close modal', 'acf' ),
		)
	);

	// Localize "input" text.
	if ( wp_script_is( 'acf-input' ) ) {
		acf_localize_text(
			array(
				// Unload
				'The changes you made will be lost if you navigate away from this page' => esc_html__( 'The changes you made will be lost if you navigate away from this page', 'acf' ),

				// Metaboxes
				'Toggle panel'                => __( 'Toggle panel', 'acf' ),

				// Validation
				'Validation successful'       => esc_html__( 'Validation successful', 'acf' ),
				'Validation failed'           => esc_html__( 'Validation failed', 'acf' ),
				'1 field requires attention'  => esc_html__( '1 field requires attention', 'acf' ),
				/* translators: %d is the number of fields that require attention */
				'%d fields require attention' => esc_html__( '%d fields require attention', 'acf' ),

				// Block Validation
				'An ACF Block on this page requires attention before you can save.' => esc_html__( 'An ACF Block on this page requires attention before you can save.', 'acf' ),

				// Other
				'Edit field group'            => esc_html__( 'Edit field group', 'acf' ),
			)
		);

		/**
		 * Fires during "admin_enqueue_scripts" when ACF scripts are enqueued.
		 *
		 * @since 5.6.9
		 */
		do_action( 'acf/input/admin_enqueue_scripts' );
	}

	/**
	 * Fires during "admin_enqueue_scripts" when ACF scripts are enqueued.
	 *
	 * @since 5.6.9
	 */
	do_action( 'acf/admin_enqueue_scripts' );
	do_action( 'acf/enqueue_scripts' );

	// Filter i18n translations that differ from English and localize script.
	$text = array();
	foreach ( $this->text as $k => $v ) {
		if ( str_replace( '.verb', '', $k ) !== $v ) {
			$text[ $k ] = $v;
		}
	}

	if ( $text ) {
		wp_localize_script( 'acf', 'acfL10n', $text );
	}
}