| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
global $current_user, $wpscfunction; |
| 7 |
|
| 8 |
if ( |
| 9 |
check_ajax_referer('clone_ticket_notification', '_ajax_nonce', false) != 1 |
| 10 |
) wp_send_json_error('Unauthorised request!', 400); |
| 11 |
|
| 12 |
if (!($current_user->ID && $current_user->has_cap('manage_options'))) { |
| 13 |
exit; |
| 14 |
} |
| 15 |
|
| 16 |
$term_id = isset($_POST) && isset($_POST['term_id']) ? intval($_POST['term_id']) : 0; |
| 17 |
if(!$term_id) die(); |
| 18 |
|
| 19 |
$source_term = get_term_by('id',$term_id,'wpsc_en'); |
| 20 |
|
| 21 |
// Title |
| 22 |
$title = $source_term->name.' clone'; |
| 23 |
$term = wp_insert_term( $title, 'wpsc_en' ); |
| 24 |
if($term && isset($term['term_id'])){ |
| 25 |
|
| 26 |
$type = get_term_meta($term_id,'type',true); |
| 27 |
add_term_meta ($term['term_id'], 'type', $type); |
| 28 |
|
| 29 |
$subject = get_term_meta($term_id,'subject',true); |
| 30 |
add_term_meta ($term['term_id'], 'subject', $subject); |
| 31 |
|
| 32 |
$body = get_term_meta($term_id,'body',true); |
| 33 |
add_term_meta ($term['term_id'], 'body', $body); |
| 34 |
|
| 35 |
$recipients = get_term_meta($term_id,'recipients',true); |
| 36 |
add_term_meta ($term['term_id'], 'recipients', $recipients); |
| 37 |
|
| 38 |
$extra_recipients = get_term_meta($term_id,'extra_recipients',true); |
| 39 |
add_term_meta ($term['term_id'], 'extra_recipients', $extra_recipients); |
| 40 |
|
| 41 |
$arr = get_term_meta($term_id,'conditions',true); |
| 42 |
add_term_meta ($term['term_id'], 'conditions', $arr); |
| 43 |
|
| 44 |
do_action('wpsc_clone_ticket_notification',$term,$source_term); |
| 45 |
echo '{ "sucess_status":"1","messege":"'.__('Email Notification clone successfull.','supportcandy').'" }'; |
| 46 |
|
| 47 |
} else { |
| 48 |
echo '{ "sucess_status":"0","messege":"'.__('An error occured while creating email notification.','supportcandy').'" }'; |
| 49 |
} |
| 50 |
|