lean filtered result whether classic search is enabled. */ if ( apply_filters( 'jetpack_search_classic_search_enabled', ! $is_instant_search_enabled ) ) { // Enable the classic search experience. $success = static::init_classic_search( $blog_id ); } if ( $success ) { // registers Jetpack Search widget. add_action( 'widgets_init', array( static::class, 'jetpack_search_widget_init' ) ); } return $success; } /** * Init Instant Search and its dependencies. * * @param int $blog_id WPCOM blog ID. */ protected static function init_instant_search( $blog_id ) { /** * The filter allows abortion of the Instant Search initialization. * * @since 0.11.2 * * @param boolean $init_instant_search Default value is true. */ if ( ! apply_filters( 'jetpack_search_init_instant_search', true ) ) { return; } // Enable the instant search experience. Instant_Search::initialize( $blog_id ); // Register instant search configurables as WordPress settings. new Settings(); // Instantiate "Customberg", the live search configuration interface. Customberg::instance(); // Enable configuring instant search within the Customizer iff it's not using a block theme. if ( ! wp_is_block_theme() ) { new Customizer(); } return true; } /** * Init Classic Search. * * @param int $blog_id WPCOM blog ID. */ protected static function init_classic_search( $blog_id ) { /** * The filter allows abortion of the Classic Search initialization. * * @since 0.11.2 * * @param boolean $init_instant_search Default value is true. */ if ( ! apply_filters( 'jetpack_search_init_classic_search', true ) ) { return; } Classic_Search::initialize( $blog_id ); return true; } /** * Register jetpack-search CLI if `\CLI` exists. * * @return void */ protected static function init_cli() { if ( defined( 'WP_CLI' ) && \WP_CLI ) { // @phan-suppress-next-line PhanUndeclaredFunctionInCallable -- https://github.com/phan/phan/issues/4763 \WP_CLI::add_command( 'jetpack-search', __NAMESPACE__ . '\CLI' ); } } /** * Register the widget if Jetpack Search is available and enabled. */ public static function jetpack_search_widget_init() { register_widget( 'Automattic\Jetpack\Search\Search_Widget' ); } /** * Check if site has been connected. */ protected static function is_connected() { return ( new Connection_Manager( Package::SLUG ) )->is_connected(); } /** * Check if search is supported by current plan. */ protected static function is_search_supported() { return ( new Plan() )->supports_search(); } /** * Perform necessary initialization steps for classic and instant search in the constructor. * * @deprecated */ public static function initialize() { return new WP_Error( 'invalid-method', /* translators: %s: Method name. */ sprintf( __( "Method '%s' not implemented. Must be overridden in subclass.", 'jetpack-search-pkg' ), __METHOD__ ), array( 'status' => 405 ) ); } } just set the specs transient with expired time to 3 hours. WCPayPromotionDataSourcePoller::get_instance()->set_specs_transient( array( $locale => $specs ), 3 * HOUR_IN_SECONDS ); self::log_errors( $results['errors'] ); } return $results['suggestions']; } /** * Get merchant WooPay eligibility. */ public static function is_woopay_eligible() { $wcpay_promotion = self::get_wc_pay_promotion_spec(); return $wcpay_promotion && 'woocommerce_payments:woopay' === $wcpay_promotion->id; } /** * Delete the specs transient. */ public static function delete_specs_transient() { WCPayPromotionDataSourcePoller::get_instance()->delete_specs_transient(); } /** * Get specs or fetch remotely if they don't exist. */ public static function get_specs() { if ( get_option( 'woocommerce_show_marketplace_suggestions', 'yes' ) === 'no' ) { return array(); } return WCPayPromotionDataSourcePoller::get_instance()->get_specs_from_data_sources(); } /** * Loads the payment method promotions scripts and styles. */ public static function load_payment_method_promotions() { WCAdminAssets::register_style( 'payment-method-promotions', 'style', array( 'wp-components' ) ); WCAdminAssets::register_script( 'wp-admin-scripts', 'payment-method-promotions', true ); } }
Warning: Class "Automattic\WooCommerce\Internal\Admin\WCPayPromotion\Init" not found in /htdocs/wp-content/plugins/woocommerce/src/Admin/Features/Features.php on line 363
_data ) ) { continue; } $reference_file = $chunk_data['source']; // Only combine "app" files (not scripts registered with WP). if ( false === strpos( $reference_file, WC_ADMIN_DIST_JS_FOLDER . 'app/index.js' ) && false === strpos( $reference_file, WC_ADMIN_DIST_JS_FOLDER . 'chunks/' ) ) { continue; } if ( empty( $combined_translation_data ) ) { // Use the first translation file as the base structure. $combined_translation_data = $chunk_data; } else { // Combine all messages from all chunk files. $combined_translation_data['locale_data']['woocommerce'] = array_merge( $combined_translation_data['locale_data']['woocommerce'], $chunk_data['locale_data']['woocommerce'] ); } } // Remove inaccurate reference comment. unset( $combined_translation_data['source'] ); return $combined_translation_data; } /** * Find and combine translation chunk files. * * Only targets files that aren't represented by a registered script (e.g. not passed to wp_register_script()). * * @param string $lang_dir Path to language files. * @param string $domain Text domain. * @param string $locale Locale being retrieved. * @return array Combined translation chunk data. */ private function get_translation_chunk_data( $lang_dir, $domain, $locale ) { // So long as this function is called during the 'upgrader_process_complete' action, // the filesystem object should be hooked up. global $wp_filesystem; // Grab all JSON files in the current language pack. $json_i18n_filenames = glob( $lang_dir . $domain . '-' . $locale . '-*.json' ); $combined_translation_data = array(); if ( false === $json_i18n_filenames ) { return $combined_translation_data; } // Use first JSON file to determine file format. This check is required due to // file format difference between official language files and user translated files. $format_determine_file = reset( $json_i18n_filenames ); if ( ! $wp_filesystem->is_readable( $format_determine_file ) ) { return $combined_translation_data; } $file_contents = $wp_filesystem->get_contents( $format_determine_file ); $format_determine_data = \json_decode( $file_contents, true ); if ( empty( $format_determine_data ) ) { return $combined_translation_data; } if ( isset( $format_determine_data['comment'] ) ) { return $this->combine_official_translation_chunks( $json_i18n_filenames ); } elseif ( isset( $format_determine_data['source'] ) ) { return $this->combine_user_translation_chunks( $json_i18n_filenames ); } else { return $combined_translation_data; } } /** * Combine and save translations for a specific locale. * * Note that this assumes \WP_Filesystem is already initialized with write access. * * @param string $language_dir Path to language files. * @param string $plugin_domain Text domain. * @param string $locale Locale being retrieved. */ private function build_and_save_translations( $language_dir, $plugin_domain, $locale ) { global $wp_filesystem; $translations_from_chunks = $this->get_translation_chunk_data( $language_dir, $plugin_domain, $locale ); if ( empty( $translations_from_chunks ) ) { return; } $cache_filename = $this->get_combined_translation_filename( $plugin_domain, $locale ); $chunk_translations_json = wp_json_encode( $translations_from_chunks ); // Cache combined translations strings to a file. $wp_filesystem->put_contents( $language_dir . $cache_filename, $chunk_translations_json ); } /** * Combine translation chunks when plugin is activated. * * This function combines JSON translation data auto-extracted by GlotPress * from Webpack-generated JS chunks into a single file. This is necessary * since the JS chunks are not known to WordPress via wp_register_script() * and wp_set_script_translations(). */ private function generate_translation_strings() { $plugin_domain = explode( '/', plugin_basename( __FILE__ ) )[0]; $locale = determine_locale(); $lang_dir = WP_LANG_DIR . '/plugins/'; // Bail early if not localized. if ( 'en_US' === $locale ) { return; } if ( ! function_exists( 'get_filesystem_method' ) ) { require_once ABSPATH . 'wp-admin/includes/file.php'; } $access_type = get_filesystem_method(); if ( 'direct' === $access_type ) { \WP_Filesystem(); $this->build_and_save_translations( $lang_dir, $plugin_domain, $locale ); } else { // I'm reluctant to add support for other filesystems here as it would require // user's input on activating plugin - which I don't think is common. return; } } /** * Loads the required translation scripts on the correct pages. */ public function potentially_load_translation_script_file() { if ( ! PageController::is_admin_or_embed_page() ) { return; } // Grab translation strings from Webpack-generated chunks. add_filter( 'load_script_translation_file', array( $this, 'load_script_translation_file' ), 10, 3 ); } /** * Load translation strings from language packs for dynamic imports. * * @param string $file File location for the script being translated. * @param string $handle Script handle. * @param string $domain Text domain. * * @return string New file location for the script being translated. */ public function load_script_translation_file( $file, $handle, $domain ) { // Make sure the main app script is being loaded. if ( WC_ADMIN_APP !== $handle ) { return $file; } // Make sure we're handing the correct domain (could be woocommerce or woocommerce-admin). $plugin_domain = explode( '/', plugin_basename( __FILE__ ) )[0]; if ( $plugin_domain !== $domain ) { return $file; } $locale = determine_locale(); $cache_filename = $this->get_combined_translation_filename( $domain, $locale ); return WP_LANG_DIR . '/plugins/' . $cache_filename; } /** * Run when plugin is activated (can be WooCommerce or WooCommerce Admin). * * @param string $filename Activated plugin filename. */ public function potentially_generate_translation_strings( $filename ) { $plugin_domain = explode( '/', plugin_basename( __FILE__ ) )[0]; $activated_plugin_domain = explode( '/', $filename )[0]; // Ensure we're only running only on activation hook that originates from our plugin. if ( $plugin_domain === $activated_plugin_domain ) { $this->generate_translation_strings(); } } /** * Combine translation chunks when files are updated. * * This function combines JSON translation data auto-extracted by GlotPress * from Webpack-generated JS chunks into a single file that can be used in * subsequent requests. This is necessary since the JS chunks are not known * to WordPress via wp_register_script() and wp_set_script_translations(). * * @param Language_Pack_Upgrader $instance Upgrader instance. * @param array $hook_extra Info about the upgraded language packs. */ public function combine_translation_chunk_files( $instance, $hook_extra ) { if ( ! is_a( $instance, 'Language_Pack_Upgrader' ) || ! isset( $hook_extra['translations'] ) || ! is_array( $hook_extra['translations'] ) ) { return; } // Make sure we're handing the correct domain (could be woocommerce or woocommerce-admin). $plugin_domain = explode( '/', plugin_basename( __FILE__ ) )[0]; $locales = array(); $language_dir = WP_LANG_DIR . '/plugins/'; // Gather the locales that were updated in this operation. foreach ( $hook_extra['translations'] as $translation ) { if ( 'plugin' === $translation['type'] && $plugin_domain === $translation['slug'] ) { $locales[] = $translation['language']; } } // Build combined translation files for all updated locales. foreach ( $locales as $locale ) { // So long as this function is hooked to the 'upgrader_process_complete' action, // WP_Filesystem should be hooked up to be able to call build_and_save_translations. $this->build_and_save_translations( $language_dir, $plugin_domain, $locale ); } } }
Fatal error: Uncaught Error: Class "Automattic\WooCommerce\Internal\Admin\Translations" not found in /htdocs/wp-content/plugins/woocommerce/src/Internal/Admin/Loader.php:67 Stack trace: #0 /htdocs/wp-content/plugins/woocommerce/src/Internal/Admin/Loader.php(55): Automattic\WooCommerce\Internal\Admin\Loader->__construct() #1 /htdocs/wp-content/plugins/woocommerce/src/Internal/Admin/FeaturePlugin.php(192): Automattic\WooCommerce\Internal\Admin\Loader::get_instance() #2 /htdocs/wp-content/plugins/woocommerce/src/Internal/Admin/FeaturePlugin.php(97): Automattic\WooCommerce\Internal\Admin\FeaturePlugin->hooks() #3 /htdocs/wp-content/plugins/woocommerce/src/Internal/Admin/FeaturePlugin.php(81): Automattic\WooCommerce\Internal\Admin\FeaturePlugin->on_plugins_loaded() #4 /htdocs/wp-content/plugins/woocommerce/src/Admin/Composer/Package.php(65): Automattic\WooCommerce\Internal\Admin\FeaturePlugin->init() #5 [internal function]: Automattic\WooCommerce\Admin\Composer\Package::init() #6 /htdocs/wp-content/plugins/woocommerce/src/Packages.php(128): call_user_func(Array) #7 /htdocs/wp-content/plugins/woocommerce/src/Packages.php(64): Automattic\WooCommerce\Packages::initialize_packages() #8 /htdocs/wp-includes/class-wp-hook.php(324): Automattic\WooCommerce\Packages::on_init('') #9 /htdocs/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #10 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #11 /htdocs/wp-settings.php(559): do_action('plugins_loaded') #12 /htdocs/wp-config.php(85): require_once('/htdocs/wp-sett...') #13 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #14 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #15 /htdocs/index.php(17): require('/htdocs/wp-blog...') #16 {main} thrown in /htdocs/wp-content/plugins/woocommerce/src/Internal/Admin/Loader.php on line 67