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

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