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 ) ); } } elds = $this->checkout_fields_controller->get_fields_for_location( 'address' ); if ( ! $fields || ! $customer ) { return; } foreach ( $fields as $key => $field ) { $value = $this->checkout_fields_controller->format_additional_field_value( $this->checkout_fields_controller->get_field_from_object( $key, $customer, $address_type ), $field ); if ( ! $value ) { continue; } printf( '
%s: %s', wp_kses_post( $field['label'] ), wp_kses_post( $value ) ); } } /** * Register required additional contact fields. * * @param array $fields Required fields. * @return array */ public function edit_account_form_required_fields( $fields ) { $additional_fields = $this->checkout_fields_controller->get_fields_for_location( 'contact' ); foreach ( $additional_fields as $key => $field ) { if ( ! empty( $field['required'] ) ) { $fields[ $key ] = $field['label']; } } return $fields; } /** * Adds additional contact fields to the My Account edit account form. */ public function edit_account_form_fields() { $customer = new WC_Customer( get_current_user_id() ); $fields = $this->checkout_fields_controller->get_fields_for_location( 'contact' ); foreach ( $fields as $key => $field ) { $field_key = CheckoutFields::get_group_key( 'other' ) . $key; $form_field = $field; $form_field['id'] = $field_key; $form_field['value'] = $this->checkout_fields_controller->get_field_from_object( $key, $customer, 'contact' ); if ( 'select' === $field['type'] ) { $form_field['options'] = array_column( $field['options'], 'label', 'value' ); } if ( 'checkbox' === $field['type'] ) { $form_field['checked_value'] = '1'; $form_field['unchecked_value'] = '0'; } woocommerce_form_field( $key, $form_field, wc_get_post_data_by_key( $key, $form_field['value'] ) ); } } /** * Validates and saves additional address fields to the customer object on the My Account page. * * Customer is not provided by this hook so we handle save here. * * @param integer $user_id User ID. */ public function save_account_form_fields( $user_id ) { // phpcs:disable WordPress.Security.NonceVerification.Missing $customer = new WC_Customer( $user_id ); $additional_fields = $this->checkout_fields_controller->get_fields_for_location( 'contact' ); $field_values = array(); foreach ( array_keys( $additional_fields ) as $key ) { $post_key = CheckoutFields::get_group_key( 'other' ) . $key; if ( ! isset( $_POST[ $post_key ] ) ) { continue; } $field_value = $this->checkout_fields_controller->sanitize_field( $key, wc_clean( wp_unslash( $_POST[ $post_key ] ) ) ); $validation = $this->checkout_fields_controller->validate_field( $key, $field_value ); if ( is_wp_error( $validation ) && $validation->has_errors() ) { wc_add_notice( $validation->get_error_message(), 'error' ); continue; } $field_values[ $key ] = $field_value; } // Persist individual additional fields to customer. foreach ( $field_values as $key => $value ) { $this->checkout_fields_controller->persist_field_for_customer( $key, $value, $customer, 'other' ); } // Validate all fields for this location. $location_validation = $this->checkout_fields_controller->validate_fields_for_location( $field_values, 'contact', 'other' ); if ( is_wp_error( $location_validation ) && $location_validation->has_errors() ) { wc_add_notice( $location_validation->get_error_message(), 'error' ); } // phpcs:enable WordPress.Security.NonceVerification.Missing $customer->save(); } /** * Adds additional address fields to the My Account edit address form. * * @param array $address Address fields. * @param string $address_type Type of address (billing or shipping). * @return array Updated address fields. */ public function edit_address_fields( $address, $address_type ) { $customer = new WC_Customer( get_current_user_id() ); $fields = $this->checkout_fields_controller->get_fields_for_location( 'address' ); foreach ( $fields as $key => $field ) { $field_key = CheckoutFields::get_group_key( $address_type ) . $key; $address[ $field_key ] = $field; $address[ $field_key ]['value'] = $this->checkout_fields_controller->get_field_from_object( $key, $customer, $address_type ); if ( 'select' === $field['type'] ) { $address[ $field_key ]['options'] = array_column( $field['options'], 'label', 'value' ); } if ( 'checkbox' === $field['type'] ) { $address[ $field_key ]['checked_value'] = '1'; $address[ $field_key ]['unchecked_value'] = '0'; } } return $address; } /** * For the My Account page, save address fields. This uses the Store API endpoint for saving addresses so * extensibility hooks are consistent across the codebase. * * The caller saves the customer object if there are no errors. Nonces are checked before this method executes. * * @param integer $user_id User ID. * @param string $address_type Type of address (billing or shipping). * @param array $address Address fields. * @param WC_Customer $customer Customer object. */ public function save_address_fields( $user_id, $address_type, $address, $customer ) { // phpcs:disable WordPress.Security.NonceVerification.Missing $additional_fields = $this->checkout_fields_controller->get_fields_for_location( 'address' ); $field_values = array(); foreach ( array_keys( $additional_fields ) as $key ) { $post_key = CheckoutFields::get_group_key( $address_type ) . $key; if ( ! isset( $_POST[ $post_key ] ) ) { continue; } $field_value = $this->checkout_fields_controller->sanitize_field( $key, wc_clean( wp_unslash( $_POST[ $post_key ] ) ) ); $validation = $this->checkout_fields_controller->validate_field( $key, $field_value ); if ( is_wp_error( $validation ) && $validation->has_errors() ) { wc_add_notice( $validation->get_error_message(), 'error' ); continue; } $field_values[ $key ] = $field_value; } // Persist individual additional fields to customer. foreach ( $field_values as $key => $value ) { $this->checkout_fields_controller->persist_field_for_customer( $key, $value, $customer, $address_type ); } // Validate all fields for this location. $location_validation = $this->checkout_fields_controller->validate_fields_for_location( array_merge( $address, $field_values ), 'address', $address_type ); if ( is_wp_error( $location_validation ) && $location_validation->has_errors() ) { wc_add_notice( $location_validation->get_error_message(), 'error' ); } // phpcs:enable WordPress.Security.NonceVerification.Missing } }
Fatal error: Uncaught Error: Class "Automattic\WooCommerce\Blocks\Domain\Services\CheckoutFieldsFrontend" not found in /htdocs/wp-content/plugins/woocommerce/src/Blocks/Domain/Bootstrap.php:330 Stack trace: #0 /htdocs/wp-content/plugins/woocommerce/src/Blocks/Registry/AbstractDependencyType.php(42): Automattic\WooCommerce\Blocks\Domain\Bootstrap->Automattic\WooCommerce\Blocks\Domain\{closure}(Object(Automattic\WooCommerce\Blocks\Registry\Container)) #1 /htdocs/wp-content/plugins/woocommerce/src/Blocks/Registry/SharedType.php(28): Automattic\WooCommerce\Blocks\Registry\AbstractDependencyType->resolve_value(Object(Automattic\WooCommerce\Blocks\Registry\Container)) #2 /htdocs/wp-content/plugins/woocommerce/src/Blocks/Registry/Container.php(96): Automattic\WooCommerce\Blocks\Registry\SharedType->get(Object(Automattic\WooCommerce\Blocks\Registry\Container)) #3 /htdocs/wp-content/plugins/woocommerce/src/Blocks/Domain/Bootstrap.php(141): Automattic\WooCommerce\Blocks\Registry\Container->get('Automattic\\WooC...') #4 /htdocs/wp-content/plugins/woocommerce/src/Blocks/Domain/Bootstrap.php(80): Automattic\WooCommerce\Blocks\Domain\Bootstrap->init() #5 /htdocs/wp-content/plugins/woocommerce/src/Blocks/Package.php(124): Automattic\WooCommerce\Blocks\Domain\Bootstrap->__construct(Object(Automattic\WooCommerce\Blocks\Registry\Container)) #6 /htdocs/wp-content/plugins/woocommerce/src/Blocks/Registry/AbstractDependencyType.php(42): Automattic\WooCommerce\Blocks\Package::Automattic\WooCommerce\Blocks\{closure}(Object(Automattic\WooCommerce\Blocks\Registry\Container)) #7 /htdocs/wp-content/plugins/woocommerce/src/Blocks/Registry/SharedType.php(28): Automattic\WooCommerce\Blocks\Registry\AbstractDependencyType->resolve_value(Object(Automattic\WooCommerce\Blocks\Registry\Container)) #8 /htdocs/wp-content/plugins/woocommerce/src/Blocks/Registry/Container.php(96): Automattic\WooCommerce\Blocks\Registry\SharedType->get(Object(Automattic\WooCommerce\Blocks\Registry\Container)) #9 /htdocs/wp-content/plugins/woocommerce/src/Blocks/Package.php(44): Automattic\WooCommerce\Blocks\Registry\Container->get('Automattic\\WooC...') #10 [internal function]: Automattic\WooCommerce\Blocks\Package::init() #11 /htdocs/wp-content/plugins/woocommerce/src/Packages.php(128): call_user_func(Array) #12 /htdocs/wp-content/plugins/woocommerce/src/Packages.php(64): Automattic\WooCommerce\Packages::initialize_packages() #13 /htdocs/wp-includes/class-wp-hook.php(324): Automattic\WooCommerce\Packages::on_init('') #14 /htdocs/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #15 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #16 /htdocs/wp-settings.php(559): do_action('plugins_loaded') #17 /htdocs/wp-config.php(85): require_once('/htdocs/wp-sett...') #18 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #19 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #20 /htdocs/index.php(17): require('/htdocs/wp-blog...') #21 {main} thrown in /htdocs/wp-content/plugins/woocommerce/src/Blocks/Domain/Bootstrap.php on line 330