Automattic\WooCommerce\Internal\Admin\Settings
PaymentProviders::hide_extension_suggestion()
Hide a payment extension suggestion.
Метод класса: PaymentProviders{}
Хуков нет.
Возвращает
true|false
. True if the suggestion was successfully hidden, false otherwise.
Использование
$PaymentProviders = new PaymentProviders(); $PaymentProviders->hide_extension_suggestion( $id ): bool;
- $id(строка) (обязательный)
- The ID of the payment extension suggestion to hide.
Код PaymentProviders::hide_extension_suggestion() PaymentProviders::hide extension suggestion WC 9.6.1
public function hide_extension_suggestion( string $id ): bool { // We may receive a suggestion ID that is actually an order map ID used in the settings page providers list. // Extract the suggestion ID from the order map ID. if ( $this->is_suggestion_order_map_id( $id ) ) { $id = $this->get_suggestion_id_from_order_map_id( $id ); } $suggestion = $this->get_extension_suggestion_by_id( $id ); if ( is_null( $suggestion ) ) { throw new Exception( esc_html__( 'Invalid suggestion ID.', 'woocommerce' ) ); } $user_payments_nox_profile = get_user_meta( get_current_user_id(), Payments::USER_PAYMENTS_NOX_PROFILE_KEY, true ); if ( empty( $user_payments_nox_profile ) ) { $user_payments_nox_profile = array(); } else { $user_payments_nox_profile = maybe_unserialize( $user_payments_nox_profile ); } // Mark the suggestion as hidden. if ( empty( $user_payments_nox_profile['hidden_suggestions'] ) ) { $user_payments_nox_profile['hidden_suggestions'] = array(); } // Check if it is already hidden. if ( in_array( $id, array_column( $user_payments_nox_profile['hidden_suggestions'], 'id' ), true ) ) { return true; } $user_payments_nox_profile['hidden_suggestions'][] = array( 'id' => $id, 'timestamp' => time(), ); $result = update_user_meta( get_current_user_id(), Payments::USER_PAYMENTS_NOX_PROFILE_KEY, $user_payments_nox_profile ); // Since we already check if the suggestion is already hidden, we should not get a false result // for trying to update with the same value. False means the update failed and the suggestion is not hidden. if ( false === $result ) { return false; } return true; }