has_errors() ) {
return;
}
foreach ( $error->get_error_codes() as $error_code ) {
// Extract the "error" type.
$data = $error->get_error_data( $error_code );
$type = empty( $data ) || ! is_string( $data ) ? 'error' : $data;
$message = wp_kses(
implode( '
', $error->get_error_messages( $error_code ) ),
array(
'a' => array( 'href' => true ),
'br' => array(),
'code' => array(),
'em' => array(),
)
);
add_settings_error( 'polylang', $error_code, $message, $type );
}
}
/**
* Tells if the given REST request is in the edit context.
*
* @since 3.5
*
* @param WP_REST_Request $request A REST request.
* @return bool
*
* @phpstan-param WP_REST_Request $request
*/
function pll_is_edit_rest_request( WP_REST_Request $request ): bool {
if ( in_array( $request->get_method(), array( 'PATCH', 'POST', 'PUT' ), true ) ) {
return true;
}
return 'GET' === $request->get_method() && 'edit' === $request->get_param( 'context' );
}