| 1 |
<?php |
| 2 |
|
| 3 |
global $wpdb; |
| 4 |
global $current_user; |
| 5 |
get_currentuserinfo(); |
| 6 |
|
| 7 |
$xyz_ihs_snippetId = $_GET['snippetId']; |
| 8 |
|
| 9 |
$xyz_ihs_message = ''; |
| 10 |
if(isset($_GET['xyz_ihs_msg'])){ |
| 11 |
$xyz_ihs_message = $_GET['xyz_ihs_msg']; |
| 12 |
} |
| 13 |
if($xyz_ihs_message == 1){ |
| 14 |
|
| 15 |
?> |
| 16 |
<div class="system_notice_area_style1" id="system_notice_area"> |
| 17 |
HTML Snippet successfully updated. <span |
| 18 |
id="system_notice_area_dismiss">Dismiss</span> |
| 19 |
</div> |
| 20 |
<?php |
| 21 |
} |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
if(isset($_POST) && isset($_POST['updateSubmit'])){ |
| 27 |
|
| 28 |
// echo '<pre>'; |
| 29 |
// print_r($_POST); |
| 30 |
// die("JJJ"); |
| 31 |
$_POST = stripslashes_deep($_POST); |
| 32 |
$_POST = xyz_trim_deep($_POST); |
| 33 |
|
| 34 |
$xyz_ihs_snippetId = $_GET['snippetId']; |
| 35 |
|
| 36 |
$temp_xyz_ihs_title = str_replace(' ', '', $_POST['snippetTitle']); |
| 37 |
$temp_xyz_ihs_title = str_replace('-', '', $temp_xyz_ihs_title); |
| 38 |
|
| 39 |
$xyz_ihs_title = str_replace(' ', '-', $_POST['snippetTitle']); |
| 40 |
$xyz_ihs_content = $_POST['snippetContent']; |
| 41 |
|
| 42 |
if($xyz_ihs_title != "" && $xyz_ihs_content != ""){ |
| 43 |
|
| 44 |
if(ctype_alnum($temp_xyz_ihs_title)) |
| 45 |
{ |
| 46 |
$snippet_count = $wpdb->query($wpdb->prepare( 'SELECT * FROM '.$wpdb->prefix.'xyz_ihs_short_code WHERE id!=%d AND title=%s LIMIT 0,1',$xyz_ihs_snippetId,$xyz_ihs_title)) ; |
| 47 |
|
| 48 |
if($snippet_count == 0){ |
| 49 |
$xyz_shortCode = '[xyz-ihs snippet="'.$xyz_ihs_title.'"]'; |
| 50 |
|
| 51 |
$wpdb->update($wpdb->prefix.'xyz_ihs_short_code', array('title'=>$xyz_ihs_title,'content'=>$xyz_ihs_content,'short_code'=>$xyz_shortCode,), array('id'=>$xyz_ihs_snippetId)); |
| 52 |
|
| 53 |
header("Location:".admin_url('admin.php?page=insert-html-snippet-manage&action=snippet-edit&snippetId='.$xyz_ihs_snippetId.'&xyz_ihs_msg=1')); |
| 54 |
|
| 55 |
} |
| 56 |
else{ |
| 57 |
?> |
| 58 |
<div class="system_notice_area_style0" id="system_notice_area"> |
| 59 |
HTML Snippet already exists. <span id="system_notice_area_dismiss">Dismiss</span> |
| 60 |
</div> |
| 61 |
<?php |
| 62 |
|
| 63 |
} |
| 64 |
} |
| 65 |
else |
| 66 |
{ |
| 67 |
?> |
| 68 |
<div class="system_notice_area_style0" id="system_notice_area"> |
| 69 |
HTML Snippet title can have only alphabets,numbers or hyphen. <span id="system_notice_area_dismiss">Dismiss</span> |
| 70 |
</div> |
| 71 |
<?php |
| 72 |
|
| 73 |
} |
| 74 |
|
| 75 |
|
| 76 |
}else{ |
| 77 |
?> |
| 78 |
<div class="system_notice_area_style0" id="system_notice_area"> |
| 79 |
Fill all mandatory fields. <span id="system_notice_area_dismiss">Dismiss</span> |
| 80 |
</div> |
| 81 |
<?php |
| 82 |
} |
| 83 |
|
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
global $wpdb; |
| 88 |
|
| 89 |
|
| 90 |
$snippetDetails = $wpdb->get_results($wpdb->prepare( 'SELECT * FROM '.$wpdb->prefix.'xyz_ihs_short_code WHERE id=%d LIMIT 0,1',$xyz_ihs_snippetId )) ; |
| 91 |
$snippetDetails = $snippetDetails[0]; |
| 92 |
|
| 93 |
?> |
| 94 |
|
| 95 |
<div > |
| 96 |
<fieldset |
| 97 |
style="width: 99%; border: 1px solid #F7F7F7; padding: 10px 0px;"> |
| 98 |
<legend> |
| 99 |
<b>Edit HTML Snippet</b> |
| 100 |
</legend> |
| 101 |
<form name="frmmainForm" id="frmmainForm" method="post"> |
| 102 |
<input type="hidden" id="snippetId" name="snippetId" |
| 103 |
value="<?php if(isset($_POST['snippetId'])){ echo esc_attr($_POST['snippetId']);}else{ echo esc_attr($snippetDetails->id); }?>"> |
| 104 |
<div> |
| 105 |
<table |
| 106 |
style="width: 99%; background-color: #F9F9F9; border: 1px solid #E4E4E4; border-width: 1px;margin: 0 auto"> |
| 107 |
<tr><td><br/> |
| 108 |
<div id="shortCode"></div> |
| 109 |
<br/></td></tr> |
| 110 |
<tr valign="top"> |
| 111 |
<td style="border-bottom: none;width:20%;"> Tracking Name <font color="red">*</font></td> |
| 112 |
<td style="border-bottom: none;width:1px;"> : </td> |
| 113 |
<td><input style="width:80%;" |
| 114 |
type="text" name="snippetTitle" id="snippetTitle" |
| 115 |
value="<?php if(isset($_POST['snippetTitle'])){ echo esc_attr($_POST['snippetTitle']);}else{ echo esc_attr($snippetDetails->title); }?>"></td> |
| 116 |
</tr> |
| 117 |
<tr> |
| 118 |
<td style="border-bottom: none;width:20%; "> HTML code <font color="red">*</font></td> |
| 119 |
<td style="border-bottom: none;width:1px;"> : </td> |
| 120 |
<td > |
| 121 |
<textarea name="snippetContent" style="width:80%;height:150px;"><?php if(isset($_POST['snippetContent'])){ echo esc_textarea($_POST['snippetContent']);}else{ echo esc_textarea($snippetDetails->content); }?></textarea> |
| 122 |
</td> |
| 123 |
</tr> |
| 124 |
|
| 125 |
<tr> |
| 126 |
<td></td><td></td> |
| 127 |
<td><input class="button-primary" style="cursor: pointer;" |
| 128 |
type="submit" name="updateSubmit" value="Update"></td> |
| 129 |
</tr> |
| 130 |
<tr><td><br/></td></tr> |
| 131 |
</table> |
| 132 |
</div> |
| 133 |
|
| 134 |
</form> |
| 135 |
</fieldset> |
| 136 |
|
| 137 |
</div> |
| 138 |
|