PluginProbe
MaxButtons – Create buttons / 6.28
MaxButtons – Create buttons v6.28
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 6.28, at includes/maxbuttons-list.php

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