PluginProbe
MaxButtons – Create buttons / 7.11
MaxButtons – Create buttons v7.11
6.23 6.24 6.25 6.26 6.26.1 6.27 6.28 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.1.1 7.1.2 7.1.3 7.10 7.11 7.13 7.13.1 7.13.2 7.13.3 All 100 releases
maxbuttons / includes / maxbuttons-list.php

maxbuttons-list.php in MaxButtons – Create buttons 7.11, at includes/maxbuttons-list.php

340 lines 10.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace MaxButtons;
3 defined('ABSPATH') or die('No direct access permitted');
4
5 $result = '';
6 $button = MB()->getClass("button");
7 $mbadmin = MB()->getClass("admin");
8 $collections = MB()->getClass('collections');
9 $collection = MB()->getClass('collection');
10
11
12 $view = (isset($_GET["view"])) ? sanitize_text_field($_GET["view"]) : "all";
13
14 // submit
15 if (isset($_POST) && isset($_POST["mb-list-nonce"]) ) {
16 $verify = wp_verify_nonce( $_POST['mb-list-nonce'], 'mb-list' );
17 if (! $verify ) echo " Nonce not verifed";
18
19 if ($verify && isset($_POST['button-id']) && isset($_POST['bulk-action-select'])) {
20 if ($_POST['bulk-action-select'] == 'trash') {
21 $count = 0;
22
23 foreach ($_POST['button-id'] as $id) {
24 $id = intval($id);
25 $button->set($id);
26 $button->setStatus('trash');
27 $count++;
28 }
29
30 if ($count == 1) {
31 $result = __('Moved 1 button to the trash.', 'maxbuttons');
32 }
33
34 if ($count > 1) {
35 $result = __('Moved ', 'maxbuttons') . $count . __(' buttons to the trash.', 'maxbuttons');
36 }
37 }
38 }
39 if ($verify && $_POST['bulk-action-select'] == 'restore') {
40 $count = 0;
41
42 foreach ($_POST['button-id'] as $id) {
43 $id = intval($id);
44 $set = $button->set($id,'','trash');
45 $button->setStatus('publish');
46
47 //maxbuttons_button_restore($id);
48 $count++;
49 }
50
51 if ($count == 1) {
52 $result = __('Restored 1 button.', 'maxbuttons');
53 }
54
55 if ($count > 1) {
56 $result = __('Restored ', 'maxbuttons') . $count . __(' buttons.', 'maxbuttons');
57 }
58 $view = 'all'; // switch to normal list.
59 }
60
61 if ($verify && $_POST['bulk-action-select'] == 'delete') {
62 $count = 0;
63
64 foreach ($_POST['button-id'] as $id) {
65 $id = intval($id);
66 $button->delete($id);
67 $count++;
68 }
69
70 if ($count == 1) {
71 $result = __('Deleted 1 button.', 'maxbuttons');
72 }
73
74 if ($count > 1) {
75 $result = __('Deleted ', 'maxbuttons') . $count . __(' buttons.', 'maxbuttons');
76 }
77 }
78 }
79
80 if (isset($_GET['message']) && $_GET['message'] == '1') {
81 $result = __('Moved 1 button to the trash.', 'maxbuttons');
82 }
83
84 if (isset($_GET['message']) && $_GET['message'] == '1restore') {
85 $result = __('Restored 1 button.', 'maxbuttons');
86 }
87
88 if (isset($_GET['message']) && $_GET['message'] == '1delete') {
89 $result = __('Deleted 1 button.', 'maxbuttons');
90 }
91
92 if (isset($_GET['message']) && $_GET['message'] == 'empty-trash')
93 {
94 $result = __('Emptied Trash', 'maxbuttons');
95 }
96
97 $args = array(
98 "orderby" => "id",
99 "order" => "DESC",
100
101 );
102
103 if (isset($_GET["orderby"]))
104 $args["orderby"] = sanitize_text_field($_GET["orderby"]);
105 if (isset($_GET["order"]))
106 $args["order"] = sanitize_text_field($_GET["order"]);
107
108 if (isset($_GET["paged"]) && $_GET["paged"] != '')
109 {
110 $page = intval($_GET["paged"]);
111 $args["paged"] = $page;
112 }
113
114 if ($view == 'trash')
115 $args["status"] = "trash";
116
117
118 $published_buttons = $mbadmin->getButtons($args);
119
120 $published_buttons_count = $mbadmin->getButtonCount(array());
121 $trashed_buttons_count = $mbadmin->getButtonCount(array("status" => "trash"));
122
123 $args["view"] = $view;
124
125 $page_args = $args;
126
127
128 ?>
129
130 <script type="text/javascript">
131 jQuery(document).ready(function() {
132 jQuery("#bulk-action-all").click(function() {
133 jQuery("#maxbuttons input[name='button-id[]']").each(function() {
134 if (jQuery("#bulk-action-all").is(":checked")) {
135 jQuery(this).attr("checked", "checked");
136 }
137 else {
138 jQuery(this).removeAttr("checked");
139 }
140 });
141 });
142
143 });
144 </script>
145
146 <?php
147 $page_title = __("Overview","maxbuttons");
148 $action = "<a class='page-title-action add-new-h2' href='" . admin_url() . "admin.php?page=maxbuttons-controller&action=edit'>" . __('Add New', 'maxbuttons') . "</a>";
149 $mbadmin->get_header(array("title" => $page_title, "title_action" => $action));
150 ?>
151
152 <div class="form-actions">
153 <a class="button-primary" href="<?php echo admin_url() ?>admin.php?page=maxbuttons-controller&action=edit"><?php _e('Add New', 'maxbuttons') ?></a>
154 </div>
155
156 <?php if ($result != '') { ?>
157 <div class="mb-notice mb-message"><?php echo $result ?></div>
158 <?php }
159
160 do_action('mb-display-reviewoffer');
161 ?>
162
163
164 <p class="status">
165 <?php
166 $url = admin_url() . "admin.php?page=maxbuttons-controller&action=list";
167 $trash_url = $url . "&view=trash";
168
169 if ($view == 'trash')
170 {
171 $all_line = "<strong><a href='$url'>" . __('All', 'maxbuttons') . "</strong></a>";
172 $trash_line = __("Trash", "maxbuttons");
173 }
174 else
175 {
176 $all_line = __("All","maxbuttons");
177 $trash_line = "<a href='$trash_url'>" . __("Trash","maxbuttons") . "</strong></a>";
178 }
179 ?>
180 <?php echo $all_line ?><span class="count"> (<?php echo $published_buttons_count ?>)</span>
181
182 <?php if ($trashed_buttons_count > 0) { ?>
183 <span class="separator">|</span>
184 <?php echo $trash_line ?> <span class="count">(<?php echo $trashed_buttons_count ?>)</span>
185 <?php } ?>
186 </p>
187 <?php
188 do_action("mb-display-meta");
189
190 ?>
191 <form method="post">
192 <?php wp_nonce_field("button-copy","copy_nonce"); ?>
193 <?php wp_nonce_field("button-delete","delete_nonce"); ?>
194 <?php wp_nonce_field('button-trash', 'trash_nonce'); ?>
195 <?php wp_nonce_field('button-restore', 'restore_nonce'); ?>
196 <?php wp_nonce_field('button-empty-trash', 'empty-trash_nonce'); ?>
197
198 <?php if (isset($page_args['paged'])) : ?>
199 <input type="hidden" name="paged" value="<?php echo $page_args['paged'] ?>" />
200 <?php endif; ?>
201
202 <input type="hidden" name="view" value="<?php echo $view ?>" />
203 <?php wp_nonce_field("mb-list","mb-list-nonce"); ?>
204
205 <select name="bulk-action-select" id="bulk-action-select">
206 <option value=""><?php _e('Bulk Actions', 'maxbuttons') ?></option>
207 <?php if ($view == 'all'): ?>
208
209 <option value="trash"><?php _e('Move to Trash', 'maxbuttons') ?></option>
210 <?php endif;
211 if ($view == 'trash'): ?>
212 <option value="restore"><?php _e('Restore', 'maxbuttons') ?></option>
213 <option value="delete"><?php _e('Delete Permanently', 'maxbuttons') ?></option>
214 <?php endif; ?>
215 </select>
216 <input type="submit" class="button" value="<?php _e('Apply', 'maxbuttons') ?>" />
217
218 <?php if ($view == 'trash'): ?>
219 <button type="button" class='button alignright' value='empty-trash' data-buttonaction='empty-trash' data-confirm="<?php _e('Permanently delete all buttons in trash. Are you sure?', 'maxbuttons-pro') ?>"><?php _e('Empty Trash', 'maxbuttons'); ?></button>
220 <?php endif; ?>
221 <?php do_action("mb-display-pagination", $page_args, 'top'); ?>
222
223
224
225 <?php // Sorting
226
227
228 $link_order = (! isset($_GET["order"]) || $_GET["order"] == "DESC") ? "ASC" : 'DESC';
229
230 $name_sort_url = add_query_arg(array(
231 "orderby" => "name",
232 "order" => $link_order
233 ));
234 $id_sort_url = add_query_arg(array(
235 "orderby" => "id",
236 "order" => $link_order
237 ));
238
239 $sort_arrow = ( strtolower($args["order"]) == 'desc') ? 'dashicons-arrow-down' : 'dashicons-arrow-up'
240 ?>
241
242 <div class="button-list preview-buttons">
243
244 <div class="heading">
245 <span class='col col_check'><input type="checkbox" name="bulk-action-all" id="bulk-action-all" /></span>
246 <span class='col col_button'>
247 <a href="<?php echo $id_sort_url ?>">
248 <?php _e('Button', 'maxbuttons') ?>
249 <?php if ($args["orderby"] == 'id')
250 echo "<span class='dashicons $sort_arrow'></span>";
251 ?>
252 </a>
253 </span>
254 <span class="col col_name manage-column column-name sortable <?php echo strtolower($link_order) ?>">
255 <a href="<?php echo $name_sort_url ?>">
256 <span><?php _e('Name and Description', 'maxbuttons') ?></span>
257 <?php if ($args["orderby"] == 'name')
258 echo "<span class='dashicons $sort_arrow'></span>";
259 ?>
260
261 </a>
262 </span>
263 <span class='col col_shortcode'><?php _e('Shortcode', 'maxbuttons') ?></span>
264 </div> <!-- heading -->
265
266 <?php
267 foreach ($published_buttons as $b):
268 $id = $b['id'];
269 if($view == 'trash')
270 $button->set($id,'','trash');
271 else
272 $button->set($id);
273
274 //$inCollections = $collections::isButtonInCollection($id);
275 ?>
276 <div class='button-row'>
277 <span class="col col_check"><input type="checkbox" name="button-id[]" id="button-id-<?php echo $id ?>" value="<?php echo $id ?>" /></span>
278 <span class="col col_button"><div class="shortcode-container">
279 <?php
280 $button->display( array("mode" => "preview") );
281 ?>
282 </div>
283 <div class="actions">
284 <?php if($view == 'all') : ?>
285 <a href="<?php admin_url() ?>admin.php?page=maxbuttons-controller&action=button&id=<?php echo $id ?>"><?php _e('Edit', 'maxbuttons') ?></a>
286 <span class="separator">|</span>
287 <a href='javascript:void(0);' data-buttonaction='copy' data-buttonid="<?php echo $id ?>"><?php _e('Copy', 'maxbuttons') ?></a>
288 <span class="separator">|</span>
289 <a href="javascript:void(0)" data-buttonaction='trash' data-buttonid="<?php echo $id ?>"><?php _e('Move to Trash', 'maxbuttons') ?></a>
290 <?php endif;
291 if ($view == 'trash'):
292 ?>
293 <a href="javascript:void(0);" data-buttonaction='restore' data-buttonid="<?php echo $id ?>"><?php _e('Restore', 'maxbuttons') ?></a>
294 <span class="separator">|</span>
295 <a href="javascript:void(0);" data-buttonaction='delete' data-buttonid="<?php echo $id ?>"><?php _e('Delete Permanently', 'maxbuttons') ?></a>
296 <?php endif; ?>
297 </div>
298
299
300 </span>
301 <span class="col col_name"><a class="button-name" href="<?php admin_url() ?>admin.php?page=maxbuttons-controller&action=button&id=<?php echo $id ?>"><?php echo $button->getName() ?></a>
302 <br />
303 <p><?php echo $button->getDescription() ?></p>
304 </span>
305 <span class="col col_shortcode"> [maxbutton id="<?php echo $id ?>"] <br /><strong><?php _e('or', 'maxbuttons'); ?></strong><br />
306 [maxbutton name="<?php echo $button->getName() ?>"]
307
308 <?php
309 if ($button->getUpdated(false) > 0) : ?>
310 <span class='last-update'>Updated <?php echo $button->getUpdated(); ?></span>
311 <?php endif; ?>
312 </span>
313 </div>
314 <?php endforeach;
315
316 // buttons ?>
317
318 </div> <!-- button-list -->
319 </form>
320
321 <div class=''>
322 <?php
323 if (count($published_buttons) == 0):
324 include('maxbuttons-welcome.php');
325 endif;
326 ?>
327 </div>
328
329
330 <?php do_action("mb-display-pagination", $page_args, 'bottom'); ?>
331
332
333
334 </div>
335 <div class="ad-wrap">
336 <?php do_action("mb-display-ads"); ?>
337 </div>
338
339 <?php $mbadmin->get_footer(); ?>
340