WC_Admin_Assets::enqueue_block_editor_assets()publicWC 1.0

Enqueue block editor assets.

Метод класса: WC_Admin_Assets{}

Возвращает

null. Ничего (null).

Использование

$WC_Admin_Assets = new WC_Admin_Assets();
$WC_Admin_Assets->enqueue_block_editor_assets();

Код WC_Admin_Assets::enqueue_block_editor_assets() WC 9.4.2

public function enqueue_block_editor_assets() {
	$settings_tabs = apply_filters('woocommerce_settings_tabs_array', []);

	if ( is_array( $settings_tabs ) && count( $settings_tabs ) > 0  ) {
		$formatted_settings_tabs = array();
		foreach ($settings_tabs as $key => $label) {
			if (
				is_string( $key ) && $key !== "" &&
				is_string( $label ) && $label !== ""
			) {
				$formatted_settings_tabs[] = array(
					'key'   => $key,
					'label' => wp_strip_all_tags( $label ),
				);
			}
		}

		self::enqueue_block_editor_script( 'wp-admin-scripts', 'command-palette' );
		wp_localize_script(
			'wc-admin-command-palette',
			'wcCommandPaletteSettings',
			array(
				'settingsTabs'    => $formatted_settings_tabs,
			)
		);
	}

	$admin_features_disabled = apply_filters( 'woocommerce_admin_disabled', false );
	if ( ! $admin_features_disabled ) {
		$analytics_reports = Analytics::get_report_pages();
		if ( is_array( $analytics_reports ) && count( $analytics_reports ) > 0 ) {
			$formatted_analytics_reports = array_map( function( $report ) {
				if ( ! is_array( $report ) ) {
					return null;
				}
				$title = array_key_exists( 'title', $report ) ? $report['title'] : '';
				$path = array_key_exists( 'path', $report ) ? $report['path'] : '';
				if (
					is_string( $title ) && $title !== "" &&
					is_string( $path ) && $path !== ""
				) {
					return array(
						'title' => wp_strip_all_tags( $title ),
						'path' => $path,
					);
				}
				return null;
			}, $analytics_reports );
			$formatted_analytics_reports = array_filter( $formatted_analytics_reports, 'is_array' );

			self::enqueue_block_editor_script( 'wp-admin-scripts', 'command-palette-analytics' );
			wp_localize_script(
				'wc-admin-command-palette-analytics',
				'wcCommandPaletteAnalytics',
				array(
					'reports'    => $formatted_analytics_reports,
				)
			);
		}
	}
}