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

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