Automattic\WooCommerce\Internal\Admin\Settings\PaymentProviders
PaymentGateway::standardize_recommended_payment_method()
Standardize a recommended payment method entry.
Метод класса: PaymentGateway{}
Хуков нет.
Возвращает
Массив
. The standardized recommended payment method entry.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->standardize_recommended_payment_method( $recommended_pm, $order ): array;
- $recommended_pm(массив) (обязательный)
- The recommended payment method entry to standardize.
- $order(int)
- The order of the recommended payment method.
По умолчанию: 0 if not provided
Код PaymentGateway::standardize_recommended_payment_method() PaymentGateway::standardize recommended payment method WC 9.6.0
protected function standardize_recommended_payment_method( array $recommended_pm, int $order = 0 ): array { $standard_details = array( 'id' => sanitize_key( $recommended_pm['id'] ), '_order' => $order, 'enabled' => (bool) ( $recommended_pm['enabled'] ?? true ), // Default to enabled if not explicit. 'required' => (bool) ( $recommended_pm['required'] ?? false ), // Default to not required if not explicit. 'title' => sanitize_text_field( $recommended_pm['title'] ), 'description' => '', 'icon' => '', ); // If the payment method has a description, sanitize it before use. if ( ! empty( $recommended_pm['description'] ) ) { $standard_details['description'] = $recommended_pm['description']; // Make sure that if we have HTML tags, we only allow stylistic tags and anchors. if ( preg_match( '/<[^>]+>/', $standard_details['description'] ) ) { // Only allow stylistic tags with a few modifications. $allowed_tags = wp_kses_allowed_html( 'data' ); $allowed_tags = array_merge( $allowed_tags, array( 'a' => array( 'href' => true, 'target' => true, ), ) ); $standard_details['description'] = wp_kses( $standard_details['description'], $allowed_tags ); } } // If the payment method has an icon, try to use it. if ( ! empty( $recommended_pm['icon'] ) && wc_is_valid_url( $recommended_pm['icon'] ) ) { $standard_details['icon'] = sanitize_url( $recommended_pm['icon'] ); } return $standard_details; }