PluginProbe
Insert Html Snippet / 1.3
Insert Html Snippet v1.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, at admin/snippets.php

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