PluginProbe
Insert Html Snippet / 1.3.3
Insert Html Snippet v1.3.3
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 / snippets.php

snippets.php in Insert Html Snippet 1.3.3, at admin/snippets.php

325 lines 11.7 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 $_GET = stripslashes_deep($_GET);
7 $xyz_ihs_message = $search_name_db=$search_name='';
8
9 if(isset($_GET['xyz_ihs_msg'])){
10 $xyz_ihs_message = intval($_GET['xyz_ihs_msg']);
11 }
12 if($_POST)
13 {
14 if(isset($_POST['search']))
15 {
16 if(!isset($_REQUEST['_wpnonce'])||!wp_verify_nonce($_REQUEST['_wpnonce'],'snipp-manage_') ){
17 wp_nonce_ays( 'snipp-manage_' );
18 exit;
19 }
20 }
21 if(isset($_POST['textFieldButton2']))
22 {
23 if(!isset($_REQUEST['_wpnonce'])||!wp_verify_nonce($_REQUEST['_wpnonce'],'bulk_actions_ihs') ){
24 wp_nonce_ays( 'bulk_actions_ihs' );
25 exit;
26 }
27 }
28 if (isset($_POST['apply_ihs_bulk_actions'])){
29 if (isset($_POST['ihs_bulk_actions_snippet'])){
30 $ihs_bulk_actions_snippet=$_POST['ihs_bulk_actions_snippet'];
31 if (isset($_POST['xyz_ihs_snippet_ids']))
32 $xyz_ihs_snippet_ids = $_POST['xyz_ihs_snippet_ids'];
33 $xyz_ihs_pageno = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 1;
34
35 if (empty($xyz_ihs_snippet_ids))
36 {
37 header("Location:".admin_url('admin.php?page=insert-html-snippet-manage&xyz_ihs_msg=8&pagenum='.$xyz_ihs_pageno));
38 exit();
39 }
40 if ($ihs_bulk_actions_snippet==2)//bulk-delete
41 {
42 foreach ($xyz_ihs_snippet_ids as $snippet_id)
43 {
44 $wpdb->query($wpdb->prepare( 'DELETE FROM '.$wpdb->prefix.'xyz_ihs_short_code WHERE id=%d',$snippet_id)) ;
45 }
46 header("Location:".admin_url('admin.php?page=insert-html-snippet-manage&xyz_ihs_msg=3&pagenum='.$xyz_ihs_pageno));
47 exit();
48 }
49 elseif ($ihs_bulk_actions_snippet==0)//bulk-Deactivate
50 {
51 foreach ($xyz_ihs_snippet_ids as $xyz_ihs_snippetId)
52 $wpdb->update($wpdb->prefix.'xyz_ihs_short_code', array('status'=>2), array('id'=>$xyz_ihs_snippetId));
53 header("Location:".admin_url('admin.php?page=insert-html-snippet-manage&xyz_ihs_msg=4&pagenum='.$xyz_ihs_pageno));
54 exit();
55 }
56 elseif ($ihs_bulk_actions_snippet==1)//bulk-activate
57 {
58 foreach ($xyz_ihs_snippet_ids as $xyz_ihs_snippetId)
59 $wpdb->update($wpdb->prefix.'xyz_ihs_short_code', array('status'=>1), array('id'=>$xyz_ihs_snippetId));
60 header("Location:".admin_url('admin.php?page=insert-html-snippet-manage&xyz_ihs_msg=4&pagenum='.$xyz_ihs_pageno));
61 exit();
62 }
63 elseif ($ihs_bulk_actions_snippet==-1)//no action selected
64 {
65 header("Location:".admin_url('admin.php?page=insert-html-snippet-manage&xyz_ihs_msg=7&pagenum='.$xyz_ihs_pageno));
66 exit();
67 }
68 }
69
70 }
71
72
73 }
74 if($xyz_ihs_message == 1){
75 ?>
76 <div class="xyz_system_notice_area_style1" id="xyz_system_notice_area">
77 HTML Snippet successfully added.&nbsp;&nbsp;&nbsp;<span
78 id="xyz_system_notice_area_dismiss">Dismiss</span>
79 </div>
80 <?php
81
82 }
83 if($xyz_ihs_message == 2){
84
85 ?>
86 <div class="xyz_system_notice_area_style0" id="xyz_system_notice_area">
87 HTML Snippet not found.&nbsp;&nbsp;&nbsp;<span
88 id="xyz_system_notice_area_dismiss">Dismiss</span>
89 </div>
90 <?php
91
92 }
93 if($xyz_ihs_message == 3){
94
95 ?>
96 <div class="xyz_system_notice_area_style1" id="xyz_system_notice_area">
97 HTML Snippet successfully deleted.&nbsp;&nbsp;&nbsp;<span
98 id="xyz_system_notice_area_dismiss">Dismiss</span>
99 </div>
100 <?php
101
102 }
103 if($xyz_ihs_message == 4){
104
105 ?>
106 <div class="xyz_system_notice_area_style1" id="xyz_system_notice_area">
107 HTML Snippet status successfully changed.&nbsp;&nbsp;&nbsp;<span
108 id="xyz_system_notice_area_dismiss">Dismiss</span>
109 </div>
110 <?php
111
112 }
113 if($xyz_ihs_message == 5){
114
115 ?>
116 <div class="xyz_system_notice_area_style1" id="xyz_system_notice_area">
117 HTML Snippet successfully updated.&nbsp;&nbsp;&nbsp;<span
118 id="xyz_system_notice_area_dismiss">Dismiss</span>
119 </div>
120 <?php
121 }
122 if($xyz_ihs_message == 7)
123 {
124 ?>
125 <div class="xyz_system_notice_area_style1" id="xyz_system_notice_area">
126 Please select an action to apply.&nbsp;&nbsp;&nbsp;
127 <span id="xyz_system_notice_area_dismiss">Dismiss</span>
128 </div>
129 <?php
130 }
131 if($xyz_ihs_message == 8)
132 {
133 ?>
134 <div class="xyz_system_notice_area_style1" id="xyz_system_notice_area">
135 Please select at least one snippet to perform this action.&nbsp;&nbsp;&nbsp;
136 <span id="xyz_system_notice_area_dismiss">Dismiss</span>
137 </div>
138 <?php
139 }
140 ?>
141 <div >
142
143
144 <form method="post">
145 <?php wp_nonce_field( 'bulk_actions_ihs');?>
146 <fieldset
147 style="width: 99%; border: 1px solid #F7F7F7; padding: 10px 0px;">
148 <legend><h3>HTML Snippets</h3></legend>
149 <?php
150 global $wpdb;
151 $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 1;
152 $limit = get_option('xyz_ihs_limit');
153 $offset = ( $pagenum - 1 ) * $limit;
154 $field=get_option('xyz_ihs_sort_field_name');
155 $order=get_option('xyz_ihs_sort_order');
156 if(isset($_POST['snippet_name']))
157 {
158 $search_name=sanitize_text_field($_POST['snippet_name']);
159 $search_name_db=esc_sql($search_name);
160 }
161
162 $entries = $wpdb->get_results( "SELECT * FROM ".$wpdb->prefix."xyz_ihs_short_code WHERE title like '%".$search_name_db."%'"." ORDER BY $field $order LIMIT $offset,$limit" );
163
164 ?>
165
166
167
168 <input id="xyz_ihs_submit" style="cursor: pointer; margin-bottom:10px; margin-left:8px;" type="button" name="textFieldButton2" value="Add New HTML Snippet" onClick='document.location.href="<?php echo admin_url('admin.php?page=insert-html-snippet-manage&action=snippet-add');?>"'>
169 <br>
170
171
172
173
174
175 <span style="padding-left: 6px;color:#21759B;">With Selected : </span>
176 <select name="ihs_bulk_actions_snippet" id="ihs_bulk_actions_snippet" style="width:130px;height:29px;">
177 <option value="-1">Bulk Actions</option>
178 <option value="0">Deactivate</option>
179 <option value="1">Activate</option>
180 <option value="2">Delete</option>
181 </select>
182 <input type="submit" title="Apply" name="apply_ihs_bulk_actions" value="Apply" style="color:#21759B;cursor:pointer;padding: 5px;background:linear-gradient(to top, #ECECEC, #F9F9F9) repeat scroll 0 0 #F1F1F1;border: 2px solid #DFDFDF;">
183
184 </form>
185 <form name="manage_snippets" action="" method="post">
186 <?php wp_nonce_field('snipp-manage_');?>
187 <div class="xyz_ics_search_div" style="float:right;">
188 <table class="xyz_ics_search_div_table" style="width:100%;">
189 <tr>
190
191
192 <input type="text" name="snippet_name" value= "<?php if(isset($search_name)){echo esc_attr($search_name);}?>" placeholder="Search" >
193 <input type="submit" name="search" value="Go" />
194
195 </tr>
196 </table>
197 </div>
198 </form>
199
200
201 <table class="widefat" style="width: 99%; margin: 0 auto; border-bottom:none;">
202 <thead>
203 <tr>
204 <th scope="col" width="3%"><input type="checkbox" id="chkAllSnippets" /></th>
205 <th scope="col" >Tracking Name</th>
206 <th scope="col" >Snippet Short Code</th>
207 <th scope="col" >Status</th>
208 <th scope="col" colspan="3" style="text-align: center;">Action</th>
209 </tr>
210 </thead>
211 <tbody>
212 <?php
213
214 if( count($entries)>0 ) {
215
216 $count=1;
217 $class = '';
218 foreach( $entries as $entry ) {
219 $class = ( $count % 2 == 0 ) ? ' class="alternate"' : '';
220 $snippetId=intval($entry->id);
221 ?>
222 <tr <?php echo $class; ?>>
223 <td style="vertical-align: middle !important;padding-left: 18px;">
224 <input type="checkbox" class="chk" value="<?php echo $snippetId; ?>" name="xyz_ihs_snippet_ids[]" id="xyz_ihs_snippet_ids" />
225 </td>
226 <td id="xyz_ihs_vAlign"><?php
227 echo esc_html($entry->title);
228 ?></td>
229 <td id="xyz_ihs_vAlign"><?php
230 if($entry->status == 2){echo 'NA';}
231 else
232 echo '[xyz-ihs snippet="'.esc_html($entry->title).'"]';
233 ?></td>
234 <td id="xyz_ihs_vAlign">
235 <?php
236 if($entry->status == 2){
237 echo "Inactive";
238 }elseif ($entry->status == 1){
239 echo "Active";
240 }
241
242 ?>
243 </td>
244 <?php
245 if($entry->status == 2){
246 $stat1 = admin_url('admin.php?page=insert-html-snippet-manage&action=snippet-status&snippetId='.$snippetId.'&status=1&pageno='.$pagenum);
247 ?>
248 <td style="text-align: center;"><a
249 href='<?php echo wp_nonce_url($stat1,'ihs-stat_'.$snippetId); ?>'><img
250 id="xyz_ihs_img" title="Activate"
251 src="<?php echo plugins_url('images/activate.png', XYZ_INSERT_HTML_PLUGIN_FILE )?>">
252 </a>
253 </td>
254 <?php
255 }elseif ($entry->status == 1){
256 $stat2 = admin_url('admin.php?page=insert-html-snippet-manage&action=snippet-status&snippetId='.$snippetId.'&status=2&pageno='.$pagenum);
257 ?>
258 <td style="text-align: center;"><a
259 href='<?php echo wp_nonce_url($stat2,'ihs-stat_'.$snippetId); ?>'><img
260 id="xyz_ihs_img" title="Deactivate"
261 src="<?php echo plugins_url('images/pause.png',XYZ_INSERT_HTML_PLUGIN_FILE)?>">
262 </a>
263 </td>
264 <?php
265 }
266
267 ?>
268
269 <td style="text-align: center;"><a
270 href='<?php echo admin_url('admin.php?page=insert-html-snippet-manage&action=snippet-edit&snippetId='.$snippetId.'&pageno='.$pagenum); ?>'><img
271 id="xyz_ihs_img" title="Edit Snippet"
272 src="<?php echo plugins_url('images/edit.png',XYZ_INSERT_HTML_PLUGIN_FILE)?>">
273 </a>
274 </td>
275
276 <?php $delurl = admin_url('admin.php?page=insert-html-snippet-manage&action=snippet-delete&snippetId='.$snippetId.'&pageno='.$pagenum);?>
277 <td style="text-align: center;" ><a
278 href='<?php echo wp_nonce_url($delurl,'ihs-del_'.$snippetId); ?>'
279 onclick="javascript: return confirm('Please click \'OK\' to confirm ');"><img
280 id="xyz_ihs_img" title="Delete Snippet"
281 src="<?php echo plugins_url('images/delete.png',XYZ_INSERT_HTML_PLUGIN_FILE)?>">
282 </a></td>
283 </tr>
284 <?php
285 $count++;
286 }
287 } else { ?>
288 <tr>
289 <td colspan="6" >HTML Snippets not found</td>
290 </tr>
291 <?php } ?>
292 </tbody>
293 </table>
294
295 <input id="xyz_ihs_submit" style="cursor: pointer; margin-top:10px;margin-left:8px;" type="button" name="textFieldButton2" value="Add New HTML Snippet" onClick='document.location.href="<?php echo admin_url('admin.php?page=insert-html-snippet-manage&action=snippet-add');?>"'>
296
297 <?php
298 $total = $wpdb->get_var( "SELECT COUNT(`id`) FROM ".$wpdb->prefix."xyz_ihs_short_code" );
299 $num_of_pages = ceil( $total / $limit );
300
301 $page_links = paginate_links( array(
302 'base' => add_query_arg( 'pagenum','%#%'),
303 'format' => '',
304 'prev_text' => '&laquo;',
305 'next_text' => '&raquo;',
306 'total' => $num_of_pages,
307 'current' => $pagenum
308 ) );
309
310 if ( $page_links ) {
311 echo '<div class="tablenav" style="width:99%"><div class="tablenav-pages" style="margin: 1em 0">' . $page_links . '</div></div>';
312 }
313
314 ?>
315 </fieldset>
316
317 </div>
318 <script type="text/javascript">
319 jQuery(document).ready(function(){
320 jQuery("#chkAllSnippets").click(function(){
321 jQuery(".chk").prop("checked",jQuery("#chkAllSnippets").prop("checked"));
322 });
323 });
324 </script>
325