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

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

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