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-add.php

snippet-add.php in Insert Html Snippet trunk, at admin/snippet-add.php

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