Recipe_Post_Utilities::automator_recipe_scripts( $hook )

Enqueue scripts only on custom post type edit pages


Parameters Parameters

$hook

(Required)


Source Source

File: src/core/automator-post-types/uo-recipe/class-recipe-post-utilities.php

	public function automator_recipe_scripts( $hook ) {
		// Add global assets. Load in all admin pages
		Utilities::automator_enqueue_global_assets();

		// Add scripts ONLY to recipe custom post type
		if ( 'post-new.php' !== $hook && 'post.php' !== $hook ) {
			return;
		}
		if ( 'uo-recipe' !== (string) get_post_type() ) {
			return;
		}

		// Add Select2
		$this->assets_vendor_select2();

		// Add CodeMirror
		$this->assets_vendor_codemirror();

		// Add TinyMCE
		$this->assets_vendor_tinymce();

		// Recipe UI scripts
		wp_register_script(
			'uncanny-automator-ui',
			Utilities::automator_get_recipe_dist( 'bundle.min.js' ),
			array(
				'jquery',
				'uap-select2',
				'uap-codemirror',
				'uap-codemirror-autorefresh',
				'uap-codemirror-no-newlines',
				'uap-codemirror-searchcursor',
				'uap-codemirror-search',
				'uap-codemirror-placeholder',
			),
			Utilities::automator_get_version(),
			true
		);

		wp_localize_script(
			'uncanny-automator-ui',
			'UncannyAutomator',
			$this->assets_get_automator_main_object()
		);

		wp_enqueue_script( 'uncanny-automator-ui' );

		wp_enqueue_style(
			'uncanny-automator-ui',
			Utilities::automator_get_recipe_dist( 'bundle.min.css' ),
			array(
				'uap-codemirror',
			),
			Utilities::automator_get_version()
		);
	}