PluginProbe
Insert Html Snippet / 1.1
Insert Html Snippet v1.1
1.4.6 trunk 1.0 1.0.1 1.1 1.1.1 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.4 1.4.1 1.4.2 1.4.3 All 27 releases
insert-html-snippet / admin / snippet-edit.php

snippet-edit.php in Insert Html Snippet 1.1, at admin/snippet-edit.php

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