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