Astra_Ext_Advanced_Headers_Loader::admin_enqueue_scripts()

Enqueues scripts and styles for the theme layout post type on the WordPress admin edit post screen.


Description


Return

(void)


Source

File: addons/advanced-headers/classes/class-astra-ext-advanced-headers-loader.php

		public function admin_enqueue_scripts() {

			global $pagenow;
			global $post;

			$screen = get_current_screen();

			if ( ( 'post-new.php' == $pagenow || 'post.php' == $pagenow ) && 'astra_adv_header' == $screen->post_type ) {
				$rtl = '';
				if ( is_rtl() ) {
					$rtl = '-rtl';
				}
				// Styles.
				wp_enqueue_media();

				/**
				 * Localize wp-color-picker & wpColorPickerL10n.
				 *
				 * This is only needed in WordPress version >= 5.5 because wpColorPickerL10n has been removed.
				 *
				 * @see https://github.com/WordPress/WordPress/commit/7e7b70cd1ae5772229abb769d0823411112c748b
				 *
				 * This is should be removed once the issue is fixed from wp-color-picker-alpha repo.
				 * @see https://github.com/kallookoo/wp-color-picker-alpha/issues/35
				 *
				 * @since 2.6.3
				 */
				global $wp_version;

				if ( version_compare( $wp_version, '5.4.99', '>=' ) ) {
					wp_localize_script(
						'wp-color-picker',
						'wpColorPickerL10n',
						array(
							'clear'            => __( 'Clear', 'astra-addon' ),
							'clearAriaLabel'   => __( 'Clear color', 'astra-addon' ),
							'defaultString'    => __( 'Default', 'astra-addon' ),
							'defaultAriaLabel' => __( 'Select default color', 'astra-addon' ),
							'pick'             => __( 'Select Color', 'astra-addon' ),
							'defaultLabel'     => __( 'Color value', 'astra-addon' ),
						)
					);
				}

				// Scripts.
				if ( SCRIPT_DEBUG ) {

					wp_enqueue_style( 'astra-advanced-headers-admin-edit', ASTRA_EXT_ADVANCED_HEADERS_URL . 'assets/css/unminified/astra-advanced-headers-admin-edit' . $rtl . '.css', array( 'wp-color-picker' ), ASTRA_EXT_VER );

					wp_enqueue_script( 'astra-advanced-headers-admin', ASTRA_EXT_ADVANCED_HEADERS_URL . 'assets/js/unminified/astra-advanced-headers-admin.js', array( 'jquery', 'wp-color-picker', 'astra-color-alpha', 'jquery-ui-tooltip' ), ASTRA_EXT_VER, false );

				} else {
					wp_enqueue_style( 'astra-advanced-headers-admin-edit', ASTRA_EXT_ADVANCED_HEADERS_URL . 'assets/css/minified/astra-advanced-headers-admin-edit' . $rtl . '.min.css', array( 'wp-color-picker' ), ASTRA_EXT_VER );

					wp_enqueue_script( 'astra-advanced-headers-admin', ASTRA_EXT_ADVANCED_HEADERS_URL . 'assets/js/minified/astra-advanced-headers-admin.min.js', array( 'jquery', 'wp-color-picker', 'astra-color-alpha', 'jquery-ui-tooltip' ), ASTRA_EXT_VER, false );
				}
			}
		}

Changelog

Changelog
Version Description
1.0.0 Introduced.


User Contributed Notes

You must log in before being able to contribute a note or feedback.