*/ public static function failing( $handshake ) { if ( ! is_array( $handshake ) || empty( $handshake['readiness'] ) || ! is_array( $handshake['readiness'] ) ) { return array(); } $rows = array(); foreach ( $handshake['readiness'] as $row ) { if ( ! is_array( $row ) || ( isset( $row['ok'] ) && true === $row['ok'] ) ) { continue; } $message = isset( $row['message'] ) ? self::message( $row['message'] ) : ''; // A row with nothing to say is a row nobody can act on. if ( '' === $message ) { continue; } $rows[] = array( 'key' => isset( $row['key'] ) && is_string( $row['key'] ) ? sanitize_key( $row['key'] ) : '', 'message' => $message, 'action_url' => isset( $row['action_url'] ) ? self::action_url( $row['action_url'] ) : '', ); } return $rows; } /** * The message as it will be shown: plain text, one line, capped. * * @param mixed $value Raw value. * @return string */ private static function message( $value ) { if ( ! is_string( $value ) ) { return ''; } $value = trim( (string) preg_replace( '/\s+/u', ' ', wp_strip_all_tags( $value ) ) ); return mb_substr( $value, 0, self::MAX_MESSAGE ); } /** * A link only when it leads to Send4. * * The same check that guards the Connect button's redirect: the API is * trusted with submissions, not with where the administrator's browser * goes next. * * @param mixed $value Raw value. * @return string The URL, or '' for no link. */ private static function action_url( $value ) { if ( ! is_string( $value ) || '' === $value ) { return ''; } return Send4_Settings::authorize_url_is_allowed( $value ) ? $value : ''; } }