/get_email_notification.php Secret
Created
July 14, 2022 11:04
Send error response to REST endpoint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Send error response to REST endpoint. | |
* | |
* @return Error object | |
* @since 1.0 | |
* @author Lax Mariappan <lax@webdevstudios.com> | |
*/ | |
function get_email_notification() { | |
if ( isset( $_GET['id'] ) ) { | |
$id = sanitize_text_field( | |
wp_unslash( $_GET['id'] ) | |
); | |
$error = get_post_meta( $id, 'email_notification', true ); | |
if ( $error ) { | |
$data = json_decode( $error ); | |
return new \WP_REST_Response( | |
array( | |
'code' => $data->code, | |
'message' => wp_unslash( $data->message ), | |
) | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment