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