true, 'id' => true, 'role' => true, 'hidden' => true, 'title' => true, 'style' => true, 'tabindex' => true, 'data-*' => true, 'aria-hidden' => true, 'aria-label' => true, 'aria-labelledby' => true, 'aria-describedby' => true, 'aria-live' => true, 'aria-current' => true, 'aria-expanded' => true, 'aria-controls' => true, 'aria-invalid' => true, 'aria-required' => true, ); $field = array( 'name' => true, 'value' => true, 'disabled' => true, 'required' => true, 'form' => true, 'autocomplete' => true, ); $tags = array( 'form' => array( 'method' => true, 'action' => true, 'enctype' => true, 'novalidate' => true, ), 'input' => $field + array( 'type' => true, 'checked' => true, 'readonly' => true, 'placeholder' => true, 'min' => true, 'max' => true, 'step' => true, 'size' => true, 'maxlength' => true, 'pattern' => true, 'inputmode' => true, 'accept' => true, ), 'select' => $field + array( 'multiple' => true ), 'option' => array( 'value' => true, 'selected' => true, 'disabled' => true, ), 'optgroup' => array( 'label' => true ), 'textarea' => $field + array( 'rows' => true, 'cols' => true, 'placeholder' => true, 'maxlength' => true, ), 'button' => $field + array( 'type' => true, 'formnovalidate' => true, ), 'label' => array( 'for' => true ), 'fieldset' => array(), 'legend' => array(), 'details' => array( 'open' => true ), 'summary' => array(), 'time' => array( 'datetime' => true ), 'bdi' => array(), 'img' => array( 'src' => true, 'srcset' => true, 'sizes' => true, 'alt' => true, 'width' => true, 'height' => true, 'loading' => true, 'decoding' => true, 'fetchpriority' => true, ), 'svg' => array( 'xmlns' => true, 'viewbox' => true, 'width' => true, 'height' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true, 'stroke-linecap' => true, 'stroke-linejoin' => true, 'focusable' => true, ), 'g' => array( 'fill' => true, 'stroke' => true, ), 'path' => array( 'd' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true, ), 'circle' => array( 'cx' => true, 'cy' => true, 'r' => true, 'fill' => true, ), 'rect' => array( 'x' => true, 'y' => true, 'width' => true, 'height' => true, 'rx' => true, 'fill' => true, ), 'polyline' => array( 'points' => true, 'fill' => true, ), 'line' => array( 'x1' => true, 'y1' => true, 'x2' => true, 'y2' => true, ), ); $allowed = wp_kses_allowed_html( 'post' ); foreach ( $tags as $tag => $attributes ) { $allowed[ $tag ] = array_merge( isset( $allowed[ $tag ] ) ? $allowed[ $tag ] : array(), $global, $attributes ); } foreach ( $allowed as $tag => $attributes ) { $allowed[ $tag ] = array_merge( $global, (array) $attributes ); } /** * HTML allowed in ReturnKit's front-end output (escaped with wp_kses()). * * @param array $allowed Tags and attributes. */ $allowed = (array) apply_filters( 'rtkt_allowed_html', $allowed ); return $allowed; } /** * Render a template to a string. Callers escape it with * wp_kses( $html, Template::allowed_html() ) when they print it. * * @param string $name Template path relative to templates/. * @param array $args Variables. * @return string */ public static function render( $name, array $args = array() ) { ob_start(); wc_get_template( $name, $args, 'woocommerce/returnkit/', RTKT_DIR . 'templates/' ); return (string) ob_get_clean(); } /** * Queue a notice for the current page. * * @param string $text Text. * @param string $type error | success | notice. * @return void */ public static function notice( $text, $type = 'error' ) { self::$notices[] = array( (string) $text, $type ); } /** * Queued notices plus one carried over a redirect (?rtkt_notice=…). * * @return string HTML. */ public static function notices() { $map = array( 'created' => array( __( 'Thank you, your request has been received. We\'ve emailed you a confirmation.', 'returnkit' ), 'success' ), 'withdrawn' => array( __( 'Your withdrawal has been received. We\'ve emailed you an acknowledgement with the date and time.', 'returnkit' ), 'success' ), 'withdrawn_general' => array( __( 'Your withdrawal has been received. We\'ve emailed the acknowledgement, with the date and time and a link to follow it, to the address you gave.', 'returnkit' ), 'success' ), 'cancelled' => array( __( 'Your request has been cancelled.', 'returnkit' ), 'success' ), 'sent' => array( __( 'If those details match an order, we\'ve emailed a link to manage it. It can take a few minutes to arrive.', 'returnkit' ), 'success' ), ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- display only, fixed messages. $key = isset( $_GET['rtkt_notice'] ) ? sanitize_key( wp_unslash( $_GET['rtkt_notice'] ) ) : ''; $queue = self::$notices; if ( isset( $map[ $key ] ) ) { array_unshift( $queue, $map[ $key ] ); } self::$notices = array(); $html = ''; foreach ( $queue as $notice ) { $class = 'success' === $notice[1] ? 'woocommerce-message' : ( 'notice' === $notice[1] ? 'woocommerce-info' : 'woocommerce-error' ); $html .= '