nboarding/style', 'css' ), array(), $css_file_version ); wp_style_add_data( 'wc-onboarding', 'rtl', 'replace' ); } /** * Injects wp-shared-settings as a dependency if it's present. */ public function inject_wc_settings_dependencies() { if ( wp_script_is( 'wc-settings', 'registered' ) ) { $handles_for_injection = [ 'wc-admin-layout', 'wc-csv', 'wc-currency', 'wc-customer-effort-score', 'wc-navigation', // NOTE: This should be removed when Gutenberg is updated and // the notices package is removed from WooCommerce Admin. 'wc-notices', 'wc-number', 'wc-date', 'wc-components', 'wc-tracks', 'wc-block-templates', 'wc-product-editor', ]; foreach ( $handles_for_injection as $handle ) { $script = wp_scripts()->query( $handle, 'registered' ); if ( $script instanceof _WP_Dependency ) { $script->deps[] = 'wc-settings'; } } } } /** * Loads a script * * @param string $script_path_name The script path name. * @param string $script_name Filename of the script to load. * @param bool $need_translation Whether the script need translations. */ public static function register_script( $script_path_name, $script_name, $need_translation = false ) { $script_assets_filename = self::get_script_asset_filename( $script_path_name, $script_name ); $script_assets = require WC_ADMIN_ABSPATH . WC_ADMIN_DIST_JS_FOLDER . $script_path_name . '/' . $script_assets_filename; wp_enqueue_script( 'wc-admin-' . $script_name, self::get_url( $script_path_name . '/' . $script_name, 'js' ), array_merge( array( WC_ADMIN_APP ), $script_assets ['dependencies'] ), self::get_file_version( 'js' ), true ); if ( $need_translation ) { wp_set_script_translations( 'wc-admin-' . $script_name, 'woocommerce' ); } } }