PluginProbe
Insert Html Snippet / 1.4
Insert Html Snippet v1.4
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.4, at admin/snippet-edit.php

244 lines 9.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) )
3 exit;
4
5 global $wpdb;
6 $goback=1;
7 $xyz_ihs_snippetId = intval($_GET['snippetId']);
8
9 $xyz_ihs_message = '';
10 if(isset($_GET['xyz_ihs_msg'])){
11 $xyz_ihs_message = intval($_GET['xyz_ihs_msg']);
12 }
13 if($xyz_ihs_message == 1){
14
15 ?>
16 <div class="xyz_system_notice_area_style1" id="xyz_system_notice_area">
17 HTML Snippet successfully updated.&nbsp;&nbsp;&nbsp;<span
18 id="xyz_system_notice_area_dismiss">Dismiss</span>
19 </div>
20 <?php
21 }
22
23 if(isset($_GET['goback']))
24 $goback= intval($_GET['goback']);
25
26
27 $xyz_ihs_snippetId = intval($_GET['snippetId']);
28 if(isset($_POST) && isset($_POST['updateSubmit'])){
29 if (!isset($_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'ihs-edit_'.$xyz_ihs_snippetId )) {
30 wp_nonce_ays( 'ihs-edit_'.$xyz_ihs_snippetId );
31 exit;
32 }
33 $goback=intval($_POST['goback']);
34 $goback++;
35
36 $_POST = stripslashes_deep($_POST);
37 $_POST = xyz_trim_deep($_POST);
38
39
40
41 $temp_xyz_ihs_title = str_replace(' ', '', $_POST['snippetTitle']);
42 $temp_xyz_ihs_title = str_replace('-', '', $temp_xyz_ihs_title);
43
44 $xyz_ihs_title = str_replace(' ', '-', $_POST['snippetTitle']);
45 $xyz_ihs_content = $_POST['snippetContent'];
46 $xyz_ihs_insertionMethod = intval($_POST['xyz_ihs_insertionMethod']);
47 $xyz_ihs_insertionLocation = intval($_POST['xyz_ihs_insertionLocation']);
48
49 if ($xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['ADMIN_RUN_ON_HEADER'] || $xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['ADMIN_RUN_ON_FOOTER']) {
50 $xyz_ihs_insertionLocationType = XYZ_IHS_INSERTION_LOCATION_TYPE['ADMIN'];
51 }
52 else if($xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['FRONTEND_RUN_ON_HEADER'] || $xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['FRONTEND_RUN_ON_FOOTER']){
53 $xyz_ihs_insertionLocationType = XYZ_IHS_INSERTION_LOCATION_TYPE['FRONT_END'];
54 }
55 else{
56 $xyz_ihs_insertionLocationType = 0;
57 }
58
59 if($xyz_ihs_title != "" && $xyz_ihs_content != ""){
60
61 if(ctype_alnum($temp_xyz_ihs_title))
62 {
63 $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)) ;
64
65 if($snippet_count == 0){
66 $xyz_shortCode = '[xyz-ihs snippet="'.$xyz_ihs_title.'"]';
67
68 $wpdb->update($wpdb->prefix.'xyz_ihs_short_code', array('title'=>$xyz_ihs_title,'insertionMethod' => $xyz_ihs_insertionMethod, 'insertionLocation' => $xyz_ihs_insertionLocation, 'insertionLocationType' => $xyz_ihs_insertionLocationType,'content'=>$xyz_ihs_content,'short_code'=>$xyz_shortCode,), array('id'=>$xyz_ihs_snippetId));
69
70 header("Location:".admin_url('admin.php?page=insert-html-snippet-manage&action=snippet-edit&snippetId='.$xyz_ihs_snippetId.'&xyz_ihs_msg=1'.'&goback='.$goback));
71
72 }
73 else{
74 ?>
75 <div class="xyz_system_notice_area_style0" id="xyz_system_notice_area">
76 HTML Snippet already exists. &nbsp;&nbsp;&nbsp;<span id="xyz_system_notice_area_dismiss">Dismiss</span>
77 </div>
78 <?php
79
80 }
81 }
82 else
83 {
84 ?>
85 <div class="xyz_system_notice_area_style0" id="xyz_system_notice_area">
86 HTML Snippet title can have only alphabets,numbers or hyphen. &nbsp;&nbsp;&nbsp;<span id="xyz_system_notice_area_dismiss">Dismiss</span>
87 </div>
88 <?php
89
90 }
91
92
93 }else{
94 ?>
95 <div class="xyz_system_notice_area_style0" id="xyz_system_notice_area">
96 Fill all mandatory fields. &nbsp;&nbsp;&nbsp;<span id="xyz_system_notice_area_dismiss">Dismiss</span>
97 </div>
98 <?php
99 }
100
101
102 }
103
104 global $wpdb;
105
106
107 $snippetDetails = $wpdb->get_results($wpdb->prepare( 'SELECT * FROM '.$wpdb->prefix.'xyz_ihs_short_code WHERE id=%d LIMIT 0,1',$xyz_ihs_snippetId )) ;
108 $snippetDetails = $snippetDetails[0];
109
110 $xyz_ihs_insertionMethod = $snippetDetails->insertionMethod;
111 $xyz_ihs_insertionLocation = $snippetDetails->insertionLocation;
112 ?>
113
114 <div >
115 <fieldset
116 style="width: 99%; border: 1px solid #F7F7F7; padding: 10px 0px;">
117 <legend>
118 <b>Edit HTML Snippet</b>
119 </legend>
120 <form name="frmmainForm" id="frmmainForm" method="post">
121 <?php wp_nonce_field( 'ihs-edit_'.$xyz_ihs_snippetId ); ?>
122
123 <input type="hidden" id="snippetId" name="snippetId"
124 value="<?php if(isset($_POST['snippetId'])){ echo esc_attr($_POST['snippetId']);}else{ echo esc_attr($snippetDetails->id); }?>">
125 <div>
126 <input type="hidden" name="goback" value= <?php echo $goback;?>>
127 <table
128 style="width: 99%; background-color: #F9F9F9; border: 1px solid #E4E4E4; border-width: 1px;margin: 0 auto">
129 <tr><td><br/>
130 <div id="shortCode"></div>
131 <br/></td></tr>
132 <tr valign="top">
133 <td style="border-bottom: none;width:20%;">&nbsp;&nbsp;&nbsp;Tracking Name&nbsp;<font color="red">*</font></td>
134 <td style="border-bottom: none;width:1px;">&nbsp;:&nbsp;</td>
135 <td><input style="width:80%;"
136 type="text" name="snippetTitle" id="snippetTitle"
137 value="<?php if(isset($_POST['snippetTitle'])){ echo esc_attr($_POST['snippetTitle']);}else{ echo esc_attr($snippetDetails->title); }?>"></td>
138 </tr>
139 <tr valign="top">
140 <td style="border-bottom: none;width:20%;">
141 &nbsp;&nbsp;&nbsp;Placement Methods &nbsp;
142 <font color="red">
143 *
144 </font>
145 </td>
146 <td style="border-bottom: none;width:1px;">
147 &nbsp;&nbsp;
148 </td>
149 <td>
150 <select class="xyz_ihs_uniq_select" name="xyz_ihs_insertionMethod"
151 id="xyz_ihs_insertionMethod">
152 <option value="<?php echo XYZ_IHS_INSERTION_METHOD['AUTOMATIC']; ?>" <?php if ($xyz_ihs_insertionMethod == XYZ_IHS_INSERTION_METHOD['AUTOMATIC']) {
153 echo "selected";
154 } ?>>Automatic</option>
155 <option value="<?php echo XYZ_IHS_INSERTION_METHOD['SHORT_CODE']; ?>" <?php if ($xyz_ihs_insertionMethod == XYZ_IHS_INSERTION_METHOD['SHORT_CODE']) {
156 echo "selected";
157 } ?>>Short code (Manual)</option>
158
159 </select>
160 </td>
161 </tr>
162
163
164 <tr valign="top" id="xyz_ihs_insertionLocationTR">
165 <td style="border-bottom: none;width:20%;">
166 &nbsp;&nbsp;&nbsp;Insertion Location &nbsp;
167 <font color="red">
168 *
169 </font>
170 </td>
171 <td style="border-bottom: none;width:1px;">
172 &nbsp;&nbsp;
173 </td>
174 <td>
175 <div>
176 <div class="xyz_ihs_insertionLocationDiv">
177 <span id="xyz_ihs_insertion-location-txt">Select Insertion Location </span><span><i class="fa fa-angle-down" aria-hidden="true"></i> <i class="fa fa-angle-up" aria-hidden="true"></i></span>
178
179 </div>
180 <input type="hidden" id="xyz_ihs_insertionLocation" name="xyz_ihs_insertionLocation" value="<?php echo $xyz_ihs_insertionLocation;?>">
181 <ul id="xyz_ihs_uniq_list" class="xyz_ihs_uniq_list">
182 <div class="xyz_ihs_left-column">
183
184 <li class="xyz_ihs_li_h2"><label>Admin</label></li>
185 <li class="xyz_ihs_li_option <?php echo ($xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['ADMIN_RUN_ON_HEADER']) ? 'selected' : ''; ?>"
186 data-value="<?php echo XYZ_IHS_INSERTION_LOCATION['ADMIN_RUN_ON_HEADER']; ?>">
187 Run on header
188 </li>
189 <li class="xyz_ihs_li_option <?php echo ($xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['ADMIN_RUN_ON_FOOTER']) ? 'selected' : ''; ?>"
190 data-value="<?php echo XYZ_IHS_INSERTION_LOCATION['ADMIN_RUN_ON_FOOTER']; ?>">
191 Run on footer
192 </li>
193
194 <li class="xyz_ihs_li_h2"><label>Front end</label></li>
195
196 <li class="xyz_ihs_li_option <?php echo ($xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['FRONTEND_RUN_ON_HEADER']) ? 'selected' : ''; ?>"
197 data-value="<?php echo XYZ_IHS_INSERTION_LOCATION['FRONTEND_RUN_ON_HEADER']; ?>">
198 Run on header
199 </li>
200 <li class="xyz_ihs_li_option <?php echo ($xyz_ihs_insertionLocation == XYZ_IHS_INSERTION_LOCATION['FRONTEND_RUN_ON_FOOTER']) ? 'selected' : ''; ?>"
201 data-value="<?php echo XYZ_IHS_INSERTION_LOCATION['FRONTEND_RUN_ON_FOOTER']; ?>">
202 Run on footer
203 </li>
204
205 </div>
206 <div class="xyz_ihs_right-column">
207
208 </div>
209 </ul>
210 </div>
211
212 </td>
213 </tr>
214 <tr>
215 <td style="border-bottom: none;width:20%; ">&nbsp;&nbsp;&nbsp;HTML code &nbsp;<font color="red">*</font></td>
216 <td style="border-bottom: none;width:1px;">&nbsp;:&nbsp;</td>
217 <td >
218 <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>
219 </td>
220 </tr>
221
222 <tr>
223 <td></td>
224 <td>
225
226
227 <input class="button-primary" style="cursor: pointer;"
228 type="button" name="back" onclick=" window.history.go(-<?php echo $goback;?>);" value="Back" >
229 </td>
230 <td><input class="button-primary" style="cursor: pointer;" type="submit" name="updateSubmit" value="Update"></td>
231
232 </tr>
233 <tr><td><br/></td></tr>
234 </table>
235 </div>
236
237 </form>
238 </fieldset>
239
240 </div>
241 <?php
242 require( dirname( __FILE__ ) . '/snippet-js.php' );
243 ?>
244