From 535dbda6b48171f8115b455e54790de94d97d42a Mon Sep 17 00:00:00 2001 From: Murilo Ijanc Date: Sun, 26 Jul 2026 16:41:48 -0300 Subject: Initial import --- includes/class-cepis-woo-messages.php | 60 +++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 includes/class-cepis-woo-messages.php (limited to 'includes/class-cepis-woo-messages.php') diff --git a/includes/class-cepis-woo-messages.php b/includes/class-cepis-woo-messages.php new file mode 100644 index 0000000..201fe4e --- /dev/null +++ b/includes/class-cepis-woo-messages.php @@ -0,0 +1,60 @@ + Message per status kind or error code. + */ + public static function all(): array { + $messages = array( + 'idle' => '', + 'loading' => __( 'Looking the address up…', 'cepis-woocommerce' ), + 'found' => __( 'Address found.', 'cepis-woocommerce' ), + 'not_found' => __( 'CEP not found. Check the number or fill the address in by hand.', 'cepis-woocommerce' ), + 'invalid' => __( 'Invalid CEP. Type all 8 digits.', 'cepis-woocommerce' ), + 'rate_limited' => __( 'Too many lookups in a short time. Wait a few seconds and try again.', 'cepis-woocommerce' ), + 'server' => __( 'The CEP service is unavailable. Fill the address in by hand.', 'cepis-woocommerce' ), + 'network' => __( 'Could not look the CEP up. Check your connection and try again.', 'cepis-woocommerce' ), + 'timeout' => __( 'The CEP lookup took too long. Try again or fill the address in by hand.', 'cepis-woocommerce' ), + 'invalid_response' => __( 'Unexpected answer from the CEP service. Fill the address in by hand.', 'cepis-woocommerce' ), + ); + + /** + * Filters the messages shown at the checkout while a CEP is resolved. + * + * @param array $messages Message per status kind or error code. + */ + $messages = (array) apply_filters( 'cepis_woocommerce_messages', $messages ); + + $clean = array(); + foreach ( $messages as $key => $message ) { + if ( is_string( $key ) && is_scalar( $message ) ) { + $clean[ sanitize_key( $key ) ] = wp_strip_all_tags( (string) $message ); + } + } + + return $clean; + } +} -- cgit v1.3