| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
global $current_user, $wppmfunction; |
| 6 |
if ( check_ajax_referer( 'wppm_set_edit_email_notification', '_ajax_nonce', false ) != 1 ) { |
| 7 |
wp_send_json_error( 'Unauthorised request!', 401 ); |
| 8 |
} |
| 9 |
|
| 10 |
if ( ! current_user_can('wppm_admin') && ! current_user_can('manage_options') ) { |
| 11 |
wp_send_json_error( 'Permission denied', 403 ); |
| 12 |
} |
| 13 |
$wppm_email_notificatins = get_option('wppm_email_notification'); |
| 14 |
$term_id = isset($_POST['id']) |
| 15 |
? absint( wp_unslash( $_POST['id'] ) ) |
| 16 |
: 0; |
| 17 |
$term_id = isset($_POST) && isset($_POST['id']) ? absint(sanitize_text_field(wp_unslash($_POST['id']))) : 0; |
| 18 |
if(!$term_id) die(); |
| 19 |
$type = isset($_POST) && isset($_POST['wppm_en_type']) ? sanitize_text_field(wp_unslash($_POST['wppm_en_type'])) : ''; |
| 20 |
$subject = isset($_POST) && isset($_POST['wppm_en_subject']) ? sanitize_text_field(wp_unslash($_POST['wppm_en_subject'])) : ''; |
| 21 |
$allowed_tags = array( 'br' => array(), 'abbr' => array('title' => array(),), 'p' => array(), 'strong' => array(), 'a' => array('href' => array(), 'title' => array(),'target'=> array(), 'rel'=>array()),'em' =>array(),'span' =>array(), 'blockquote'=>array('cite' => array(),),'div' => array('class' => array(),'title' => array(),'style' => array(),),'ul'=>array(),'li'=>array(),'ol'=>array(),'img' => array( 'alt'=> array(),'class' => array(),'height' => array(),'src'=> array(),'width'=> array(),)); |
| 22 |
$body = ''; |
| 23 |
|
| 24 |
if ( !empty( $_POST['wppm_en_body'] ) ) { |
| 25 |
$body = wp_kses_post( |
| 26 |
wp_unslash( $_POST['wppm_en_body'] ) |
| 27 |
); |
| 28 |
} |
| 29 |
$recipients = isset($_POST) && isset($_POST['wppm_en_recipients']) ? $wppmfunction->sanitize_array($_POST['wppm_en_recipients']) : array(); |
| 30 |
foreach($wppm_email_notificatins as $key=>$val){ |
| 31 |
if($key==$term_id){ |
| 32 |
$val['type'] = $type; |
| 33 |
$val['subject'] = $subject; |
| 34 |
$val['body'] = $body; |
| 35 |
$val['recipients'] = $recipients; |
| 36 |
$wppm_email_notificatins[$key] = $val; |
| 37 |
update_option('wppm_email_notification',$wppm_email_notificatins); |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
do_action('wppm_set_edit_email_notification',$term_id); |
| 42 |
echo wp_json_encode( array( |
| 43 |
'sucess_status' => 1, |
| 44 |
'messege' => esc_html__( 'Email Notification updated successfully.', 'taskbuilder' ), |
| 45 |
) ); |
| 46 |
wp_die(); |