| 1 |
<?php |
| 2 |
if (!empty($_POST['update_style_change']) && $_POST['update_style_change'] == 'Save' && $_POST['id'] != '') { |
| 3 |
$nonce = $_REQUEST['_wpnonce']; |
| 4 |
if (!wp_verify_nonce($nonce, 'imh_6310_nonce_field_form')) { |
| 5 |
die('You do not have sufficient permissions to access this pagess.'); |
| 6 |
} else { |
| 7 |
$id = sanitize_text_field($_POST['id']); |
| 8 |
$name = sanitize_text_field($_POST['name']); |
| 9 |
$css = imh_6310_extract_data($_POST); |
| 10 |
if ($id) { |
| 11 |
$wpdb->query($wpdb->prepare("UPDATE $style_table SET name = %s, css = %s WHERE id = %d", $name, $css, $id)); |
| 12 |
} else { |
| 13 |
$wpdb->query($wpdb->prepare("INSERT into $style_table SET name = %s, css = %s", $name, $css)); |
| 14 |
$redirect_id = $wpdb->insert_id; |
| 15 |
$url = admin_url("admin.php?page=imh-6310-image-map-hotspot&action=preview&styleid=$redirect_id"); |
| 16 |
wp_register_script('imh-6310-redirect-script', ''); |
| 17 |
wp_enqueue_script('imh-6310-redirect-script'); |
| 18 |
wp_add_inline_script('imh-6310-redirect-script', "document.location.href = '" . $url . "';"); |
| 19 |
} |
| 20 |
} |
| 21 |
} |
| 22 |
$cssData = []; |
| 23 |
if ($ids) { |
| 24 |
$styledata = $wpdb->get_row($wpdb->prepare("SELECT * FROM $style_table WHERE id = %d ", $ids), ARRAY_A); |
| 25 |
$css = explode("!!##!!", $styledata['css']); |
| 26 |
$key = explode(",", $css[0]); |
| 27 |
$value = explode("||##||", $css[1]); |
| 28 |
$filterKey = []; |
| 29 |
$filterValue = []; |
| 30 |
for ($i = 0; $i < count($key); $i++) { |
| 31 |
$filterKey[] = esc_attr($key[$i]); |
| 32 |
} |
| 33 |
for ($i = 0; $i < count($value); $i++) { |
| 34 |
$filterValue[] = esc_attr($value[$i]); |
| 35 |
} |
| 36 |
$cssData = array_combine($filterKey, $filterValue); |
| 37 |
} |
| 38 |
$jsonData = isset($cssData['json_data']) ? json_decode(stripslashes(html_entity_decode($cssData['json_data']))) : []; |