PluginProbe
MaxButtons – Create buttons / 7.10
MaxButtons – Create buttons v7.10
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.10, at includes/maxbuttons-list.php

330 lines 9.8 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 $args = array(
93 "orderby" => "id",
94 "order" => "DESC",
95
96 );
97
98 if (isset($_GET["orderby"]))
99 $args["orderby"] = sanitize_text_field($_GET["orderby"]);
100 if (isset($_GET["order"]))
101 $args["order"] = sanitize_text_field($_GET["order"]);
102
103 if (isset($_GET["paged"]) && $_GET["paged"] != '')
104 {
105 $page = intval($_GET["paged"]);
106 $args["paged"] = $page;
107 }
108
109 if ($view == 'trash')
110 $args["status"] = "trash";
111
112
113 $published_buttons = $mbadmin->getButtons($args);
114
115 $published_buttons_count = $mbadmin->getButtonCount(array());
116 $trashed_buttons_count = $mbadmin->getButtonCount(array("status" => "trash"));
117
118 $args["view"] = $view;
119
120 $page_args = $args;
121
122
123 ?>
124
125 <script type="text/javascript">
126 jQuery(document).ready(function() {
127 jQuery("#bulk-action-all").click(function() {
128 jQuery("#maxbuttons input[name='button-id[]']").each(function() {
129 if (jQuery("#bulk-action-all").is(":checked")) {
130 jQuery(this).attr("checked", "checked");
131 }
132 else {
133 jQuery(this).removeAttr("checked");
134 }
135 });
136 });
137
138 });
139 </script>
140
141 <?php
142 $page_title = __("Overview","maxbuttons");
143 $action = "<a class='page-title-action add-new-h2' href='" . admin_url() . "admin.php?page=maxbuttons-controller&action=edit'>" . __('Add New', 'maxbuttons') . "</a>";
144 $mbadmin->get_header(array("title" => $page_title, "title_action" => $action));
145 ?>
146
147 <div class="form-actions">
148 <a class="button-primary" href="<?php echo admin_url() ?>admin.php?page=maxbuttons-controller&action=edit"><?php _e('Add New', 'maxbuttons') ?></a>
149 </div>
150
151 <?php if ($result != '') { ?>
152 <div class="mb-notice mb-message"><?php echo $result ?></div>
153 <?php }
154
155 do_action('mb-display-reviewoffer');
156 ?>
157
158
159 <p class="status">
160 <?php
161 $url = admin_url() . "admin.php?page=maxbuttons-controller&action=list";
162 $trash_url = $url . "&view=trash";
163
164 if ($view == 'trash')
165 {
166 $all_line = "<strong><a href='$url'>" . __('All', 'maxbuttons') . "</strong></a>";
167 $trash_line = __("Trash", "maxbuttons");
168 }
169 else
170 {
171 $all_line = __("All","maxbuttons");
172 $trash_line = "<a href='$trash_url'>" . __("Trash","maxbuttons") . "</strong></a>";
173 }
174 ?>
175 <?php echo $all_line ?><span class="count"> (<?php echo $published_buttons_count ?>)</span>
176
177 <?php if ($trashed_buttons_count > 0) { ?>
178 <span class="separator">|</span>
179 <?php echo $trash_line ?> <span class="count">(<?php echo $trashed_buttons_count ?>)</span>
180 <?php } ?>
181 </p>
182 <?php
183 do_action("mb-display-meta");
184
185 ?>
186 <form method="post">
187 <?php wp_nonce_field("button-copy","copy_nonce"); ?>
188 <?php wp_nonce_field("button-delete","delete_nonce"); ?>
189 <?php wp_nonce_field('button-trash', 'trash_nonce'); ?>
190 <?php wp_nonce_field('button-restore', 'restore_nonce'); ?>
191
192 <input type="hidden" name="view" value="<?php echo $view ?>" />
193 <?php wp_nonce_field("mb-list","mb-list-nonce"); ?>
194
195 <select name="bulk-action-select" id="bulk-action-select">
196 <option value=""><?php _e('Bulk Actions', 'maxbuttons') ?></option>
197 <?php if ($view == 'all'): ?>
198
199 <option value="trash"><?php _e('Move to Trash', 'maxbuttons') ?></option>
200 <?php endif;
201 if ($view == 'trash'): ?>
202 <option value="restore"><?php _e('Restore', 'maxbuttons') ?></option>
203 <option value="delete"><?php _e('Delete Permanently', 'maxbuttons') ?></option>
204 <?php endif; ?>
205 </select>
206 <input type="submit" class="button" value="<?php _e('Apply', 'maxbuttons') ?>" />
207
208
209 <?php do_action("mb-display-pagination", $page_args, 'top'); ?>
210
211
212
213 <?php // Sorting
214
215
216 $link_order = (! isset($_GET["order"]) || $_GET["order"] == "DESC") ? "ASC" : 'DESC';
217
218 $name_sort_url = add_query_arg(array(
219 "orderby" => "name",
220 "order" => $link_order
221 ));
222 $id_sort_url = add_query_arg(array(
223 "orderby" => "id",
224 "order" => $link_order
225 ));
226
227 $sort_arrow = ( strtolower($args["order"]) == 'desc') ? 'dashicons-arrow-down' : 'dashicons-arrow-up'
228 ?>
229
230 <div class="button-list preview-buttons">
231
232 <div class="heading">
233 <span class='col col_check'><input type="checkbox" name="bulk-action-all" id="bulk-action-all" /></span>
234 <span class='col col_button'>
235 <a href="<?php echo $id_sort_url ?>">
236 <?php _e('Button', 'maxbuttons') ?>
237 <?php if ($args["orderby"] == 'id')
238 echo "<span class='dashicons $sort_arrow'></span>";
239 ?>
240 </a>
241 </span>
242 <span class="col col_name manage-column column-name sortable <?php echo strtolower($link_order) ?>">
243 <a href="<?php echo $name_sort_url ?>">
244 <span><?php _e('Name and Description', 'maxbuttons') ?></span>
245 <?php if ($args["orderby"] == 'name')
246 echo "<span class='dashicons $sort_arrow'></span>";
247 ?>
248
249 </a>
250 </span>
251 <span class='col col_shortcode'><?php _e('Shortcode', 'maxbuttons') ?></span>
252 </div> <!-- heading -->
253
254 <?php
255 foreach ($published_buttons as $b):
256 $id = $b['id'];
257 if($view == 'trash')
258 $button->set($id,'','trash');
259 else
260 $button->set($id);
261
262 //$inCollections = $collections::isButtonInCollection($id);
263 ?>
264 <div class='button-row'>
265 <span class="col col_check"><input type="checkbox" name="button-id[]" id="button-id-<?php echo $id ?>" value="<?php echo $id ?>" /></span>
266 <span class="col col_button"><div class="shortcode-container">
267 <?php
268 //echo do_shortcode('[maxbutton id="' . $id . '" externalcss="false" ignorecontainer="true"]');
269
270 $button->display( array("mode" => "preview") );
271 ?>
272 </div>
273 <div class="actions">
274 <?php if($view == 'all') : ?>
275 <a href="<?php admin_url() ?>admin.php?page=maxbuttons-controller&action=button&id=<?php echo $id ?>"><?php _e('Edit', 'maxbuttons') ?></a>
276 <span class="separator">|</span>
277 <a href='javascript:void(0);' data-buttonaction='copy' data-buttonid="<?php echo $id ?>"><?php _e('Copy', 'maxbuttons') ?></a>
278 <span class="separator">|</span>
279 <a href="javascript:void(0)" data-buttonaction='trash' data-buttonid="<?php echo $id ?>"><?php _e('Move to Trash', 'maxbuttons') ?></a>
280 <?php endif;
281 if ($view == 'trash'):
282 ?>
283 <a href="javascript:void(0);" data-buttonaction='restore' data-buttonid="<?php echo $id ?>"><?php _e('Restore', 'maxbuttons') ?></a>
284 <span class="separator">|</span>
285 <a href="javascript:void(0);" data-buttonaction='delete' data-buttonid="<?php echo $id ?>"><?php _e('Delete Permanently', 'maxbuttons') ?></a>
286 <?php endif; ?>
287 </div>
288
289
290 </span>
291 <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>
292 <br />
293 <p><?php echo $button->getDescription() ?></p>
294 </span>
295 <span class="col col_shortcode"> [maxbutton id="<?php echo $id ?>"] <br /><strong><?php _e('or', 'maxbuttons'); ?></strong><br />
296 [maxbutton name="<?php echo $button->getName() ?>"]
297
298 <?php
299 if ($button->getUpdated(false) > 0) : ?>
300 <span class='last-update'>Updated <?php echo $button->getUpdated(); ?></span>
301 <?php endif; ?>
302 </span>
303 </div>
304 <?php endforeach;
305
306 // buttons ?>
307
308 </div> <!-- button-list -->
309 </form>
310
311 <div class=''>
312 <?php
313 if (count($published_buttons) == 0):
314 include('maxbuttons-welcome.php');
315 endif;
316 ?>
317 </div>
318
319
320 <?php do_action("mb-display-pagination", $page_args, 'bottom'); ?>
321
322
323
324 </div>
325 <div class="ad-wrap">
326 <?php do_action("mb-display-ads"); ?>
327 </div>
328
329 <?php $mbadmin->get_footer(); ?>
330