Merged in feature/280-dev-dev01 (pull request #21)
auto-patch 280-dev-dev01-2024-01-19T16_41_58 * auto-patch 280-dev-dev01-2024-01-19T16_41_58
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
use Automattic\Jetpack\Constants;
|
||||
use Automattic\WooCommerce\Admin\Features\Features;
|
||||
use Automattic\WooCommerce\Internal\Admin\Analytics;
|
||||
use Automattic\WooCommerce\Internal\Admin\WCAdminAssets;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
@@ -27,6 +28,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
||||
public function __construct() {
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
|
||||
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -554,6 +556,73 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue block editor assets.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
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 ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
WCAdminAssets::register_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' );
|
||||
|
||||
WCAdminAssets::register_script( 'wp-admin-scripts', 'command-palette-analytics' );
|
||||
wp_localize_script(
|
||||
'wc-admin-command-palette-analytics',
|
||||
'wcCommandPaletteAnalytics',
|
||||
array(
|
||||
'reports' => $formatted_analytics_reports,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to determine whether the current screen is an order edit screen.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user