Astra_Admin_Settings::register_scripts( String $hook )

Register admin scripts.


Description


Parameters

$hook

(String) (Required) Screen name where the hook is fired.


Return

(void)


Source

File: inc/core/class-astra-admin-settings.php

		public static function register_scripts( $hook ) {

			if ( in_array( $hook, array( 'post.php', 'post-new.php' ) ) ) {
				$post_types = get_post_types( array( 'public' => true ) );
				$screen     = get_current_screen();
				$post_type  = $screen->id;

				if ( in_array( $post_type, (array) $post_types ) ) {

					echo '<style class="astra-meta-box-style">
						.block-editor-page #side-sortables #astra_settings_meta_box select { min-width: 84%; padding: 3px 24px 3px 8px; height: 20px; }
						.block-editor-page #normal-sortables #astra_settings_meta_box select { min-width: 200px; }
						.block-editor-page .edit-post-meta-boxes-area #poststuff #astra_settings_meta_box h2.hndle { border-bottom: 0; }
						.block-editor-page #astra_settings_meta_box .components-base-control__field, .block-editor-page #astra_settings_meta_box .block-editor-page .transparent-header-wrapper, .block-editor-page #astra_settings_meta_box .adv-header-wrapper, .block-editor-page #astra_settings_meta_box .stick-header-wrapper, .block-editor-page #astra_settings_meta_box .disable-section-meta div { margin-bottom: 8px; }
						.block-editor-page #astra_settings_meta_box .disable-section-meta div label { vertical-align: inherit; }
						.block-editor-page #astra_settings_meta_box .post-attributes-label-wrapper { margin-bottom: 4px; }
						#side-sortables #astra_settings_meta_box select { min-width: 100%; }
						#normal-sortables #astra_settings_meta_box select { min-width: 200px; }
					</style>';
				}
			}
			/* Add CSS for the Submenu for BSF plugins added in Appearance Menu */

			if ( ! is_customize_preview() ) {

				if ( ! current_user_can( 'manage_options' ) ) {
					return;
				}

				wp_register_script( 'astra-admin-settings', ASTRA_THEME_URI . 'inc/assets/js/astra-admin-menu-settings.js', array( 'jquery', 'wp-util', 'updates' ), ASTRA_THEME_VERSION, false );

				$localize = array(
					'ajaxUrl'                            => admin_url( 'admin-ajax.php' ),
					'btnActivating'                      => __( 'Activating Importer Plugin ', 'astra' ) . '&hellip;',
					'astraSitesLink'                     => admin_url( 'themes.php?page=' ),
					'astraSitesLinkTitle'                => __( 'See Library &#187;', 'astra' ),
					'recommendedPluiginActivatingText'   => __( 'Activating', 'astra' ) . '&hellip;',
					'recommendedPluiginDeactivatingText' => __( 'Deactivating', 'astra' ) . '&hellip;',
					'recommendedPluiginActivateText'     => __( 'Activate', 'astra' ),
					'recommendedPluiginDeactivateText'   => __( 'Deactivate', 'astra' ),
					'recommendedPluiginSettingsText'     => __( 'Settings', 'astra' ),
					'astraPluginManagerNonce'            => wp_create_nonce( 'astra-recommended-plugin-nonce' ),
					'ajax_nonce'                         => wp_create_nonce( 'astra-builder-module-nonce' ),
					'old_header_footer'                  => __( 'Use Old Header/Footer', 'astra' ),
					'migrate_to_builder'                 => __( 'Use New Header/Footer Builder', 'astra' ),
				);

				wp_localize_script( 'astra-admin-settings', 'astra', apply_filters( 'astra_theme_js_localize', $localize ) );
			}
		}

User Contributed Notes

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