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

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