| 1 |
protected function wdkit_put_save_template() { |
| 2 |
$email = isset( $_POST['email'] ) ? strtolower( sanitize_email( wp_unslash( $_POST['email'] ) ) ) : false; |
| 3 |
$response = ''; |
| 4 |
|
| 5 |
if ( empty( $email ) ) { |
| 6 |
$response = array( |
| 7 |
'id' => 0, |
| 8 |
'editpage' => '', |
| 9 |
'message' => $this->e_msg_login, |
| 10 |
'description' => $this->e_desc_login, |
| 11 |
'success' => false, |
| 12 |
); |
| 13 |
|
| 14 |
wp_send_json( $response ); |
| 15 |
wp_die(); |
| 16 |
} |
| 17 |
|
| 18 |
$args = $this->wdkit_parse_args( $_POST ); |
| 19 |
$args['token'] = $this->wdkit_login_user_token( $email ); |
| 20 |
unset( $args['email'] ); |
| 21 |
|
| 22 |
global $post; |
| 23 |
|
| 24 |
$post_id = get_the_ID(); |
| 25 |
$custom_fields = array(); |
| 26 |
if ( ! empty( $post_id ) ) { |
| 27 |
$meta_fields = get_post_custom( get_the_ID() ); |
| 28 |
|
| 29 |
foreach ( $meta_fields as $key => $value ) { |
| 30 |
if ( str_contains( $key, 'nxt-' ) ) { |
| 31 |
$custom_fields[ $key ] = $value; |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
if ( ! empty( $custom_fields ) ) { |
| 36 |
$data = json_decode( $args['data'], true ); |
| 37 |
$data['custom_meta'] = $custom_fields; |
| 38 |
$args['data'] = wp_json_encode( $data ); |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
$response = WDesignKit_Data_Query::get_data( 'save_template', $args ); |
| 43 |
|
| 44 |
wp_send_json( $response ); |
| 45 |
wp_die(); |
| 46 |
} |