Astra_Ext_Nav_Menu_Loader::admin_scripts()

Include admin scripts on navigation menu screen.


Description


Return

(void)


Source

File: addons/nav-menu/classes/class-astra-ext-nav-menu-loader.php

		public function admin_scripts() {

			if ( current_user_can( 'edit_theme_options' ) ) {
				global $pagenow;
				$rtl = '';
				if ( is_rtl() ) {
					$rtl = '-rtl';
				}
				if ( 'nav-menus.php' == $pagenow || 'widgets.php' == $pagenow ) {

					wp_enqueue_media();
					wp_enqueue_style( 'wp-color-picker' );

					/**
					 * 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' ),
							)
						);
					}

					if ( SCRIPT_DEBUG ) {
						wp_enqueue_style( 'astra-mm-opts-style', ASTRA_EXT_NAV_MENU_URL . 'assets/css/unminified/megamenu-options' . $rtl . '.css', array(), ASTRA_EXT_VER );
						wp_enqueue_script( 'astra-megamenu-opts', ASTRA_EXT_NAV_MENU_URL . 'assets/js/unminified/megamenu-options.js', array( 'jquery', 'astra-color-alpha' ), ASTRA_EXT_VER, true );
					} else {
						wp_enqueue_style( 'astra-mm-opts-style', ASTRA_EXT_NAV_MENU_URL . 'assets/css/minified/megamenu-options' . $rtl . '.min.css', array(), ASTRA_EXT_VER );
						wp_enqueue_script( 'astra-megamenu-opts', ASTRA_EXT_NAV_MENU_URL . 'assets/js/minified/megamenu-options.min.js', array( 'jquery', 'astra-color-alpha' ), ASTRA_EXT_VER, true );
					}

					$has_wp_block_suport = post_type_exists( 'wp_block' );

					if ( $has_wp_block_suport ) {
						$select2_placeholder = __( 'Search Pages/ Posts / Reusable Blocks', 'astra-addon' );
					} else {
						$select2_placeholder = __( 'Search Pages/ Posts', 'astra-addon' );
					}

					wp_localize_script(
						'astra-megamenu-opts',
						'astMegamenuVars',
						array(
							'select2_placeholder' => $select2_placeholder,
							'saving_text'         => __( 'Saving ..', 'astra-addon' ),
							'saved_text'          => __( 'Saved', 'astra-addon' ),
						)
					);
				}
			}
		}

User Contributed Notes

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