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

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