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-button.php +104 -101 6.236.28 View file →
@@ -2,42 +2,42 @@
2 2 namespace MaxButtons;
3 3 defined('ABSPATH') or die('No direct access permitted');
4 4
5 5 $button = MB()->getClass("button"); //new maxButton();
6 -$button_id = 0;
6 +$button_id = 0;
7 7
8 8 if ($_POST) {
9 9 if (! check_admin_referer("button-edit","maxbuttons_button"))
10 10 {
11 - exit("Request not valid");
12 - }
13 -
14 - $button_id = intval($_POST["button_id"]);
11 + exit("Request not valid");
12 + }
15 13
16 - if ($button_id > 0)
14 + $button_id = intval($_POST["button_id"]);
15 +
16 + if ($button_id > 0)
17 17 $button->set($button_id);
18 - $return = $button->save($_POST);
19 - if (is_int($return) && $button_id <= 0)
18 + $return = $button->save($_POST);
19 + if (is_int($return) && $button_id <= 0)
20 20 $button_id = $return;
21 -
22 - if ($button_id === 0)
21 +
22 + if ($button_id === 0)
23 23 {
24 - error_log(__("Maxbuttons Error: Button id should never be zero","maxbuttons"));
25 -
24 + error_log(__("Maxbuttons Error: Button id should never be zero","maxbuttons"));
25 +
26 26 }
27 -
28 - $button->set($button_id);
27 +
28 + $button->set($button_id);
29 29 wp_redirect(admin_url('admin.php?page=maxbuttons-controller&action=button&id=' . $button_id));
30 30 exit();
31 31 }
32 -
33 -if (isset($_GET['id']) && $_GET['id'] != '') {
32 +
33 +if (isset($_GET['id']) && $_GET['id'] != '') {
34 34 $button = MB()->getClass('button'); // reset
35 - $button_id = intval($_GET["id"]);
36 - if ($button_id == 0)
35 + $button_id = intval($_GET["id"]);
36 + if ($button_id == 0)
37 37 {
38 38 $error = __("Maxbuttons button id is zero. Your data is not saved correctly! Please check your database.","maxbuttons");
39 - MB()->add_notice('error', $error);
39 + MB()->add_notice('error', $error);
40 40 }
41 41 // returns bool
42 42 $return = $button->set($button_id);
43 43 if ($return === false)
@@ -42,34 +42,34 @@
42 42 $return = $button->set($button_id);
43 43 if ($return === false)
44 44 {
45 45 $error = __("MaxButtons could not find this button in the database. It might not be possible to save this button! Please check your database or contact support! ", "maxbuttons");
46 - MB()->add_notice('error', $error);
46 + MB()->add_notice('error', $error);
47 47 }
48 48 }
49 49
50 -
51 -$admin = MB()->getClass('admin');
52 -$page_title = __("Button editor","maxbuttons");
50 +
51 +$admin = MB()->getClass('admin');
52 +$page_title = __("Button editor","maxbuttons");
53 53 $action = "<a class='page-title-action add-new-h2' href='" . admin_url() . "admin.php?page=maxbuttons-controller&action=edit'>" . __('Add New', 'maxbuttons') . "</a>";
54 54 $admin->get_header(array("title" => $page_title, "title_action" => $action) );
55 - ?>
55 + ?>
56 56 <form id="new-button-form" action="<?php echo admin_url('admin.php?page=maxbuttons-controller&action=button&noheader=true'); ?>" method="post">
57 - <input type="hidden" name="button_id" value="<?php echo $button_id ?>">
57 + <input type="hidden" name="button_id" value="<?php echo $button_id ?>">
58 58 <?php wp_nonce_field("button-edit","maxbuttons_button") ?>
59 - <?php wp_nonce_field("button-copy","copy_nonce"); ?>
60 - <?php wp_nonce_field("button-delete","delete_nonce"); ?>
61 - <?php wp_nonce_field('button-trash', 'trash_nonce'); ?>
62 -
63 - <div class="form-actions">
59 + <?php wp_nonce_field("button-copy","copy_nonce"); ?>
60 + <?php wp_nonce_field("button-delete","delete_nonce"); ?>
61 + <?php wp_nonce_field('button-trash', 'trash_nonce'); ?>
62 +
63 + <div class="form-actions">
64 64 <a class="button-primary button button-save" href='javascript:void(0);'><?php _e('Save', 'maxbuttons') ?></a>
65 - <?php if ($button_id > 0): ?>
65 + <?php if ($button_id > 0): ?>
66 66 <a id="button-copy" class="maxmodal button" data-modal='copy-button' href="javascript:void(0)"><?php _e('Copy', 'maxbuttons') ?></a>
67 67 <a id="button-trash" class="maxmodal button" data-modal = 'trash-button' href="javascript:void(0);"><?php _e('Move to Trash', 'maxbuttons') ?></a>
68 68 <a class="button maxmodal" href="javascript:void(0);" data-modal='delete-button'><?php _e("Delete","maxbuttons"); ?> </a>
69 - <?php endif; // button_id > 0 ?>
70 -
71 - <?php do_action('mb/editor/form-actions', $button); ?>
69 + <?php endif; // button_id > 0 ?>
70 +
71 + <?php do_action('mb/editor/form-actions', $button); ?>
72 72 </div>
73 73
74 74 <!-- delete modal -->
75 75 <div class="maxmodal-data" id="delete-button">
@@ -77,11 +77,11 @@
77 77 <span class="content"><p><?php _e("You are about to permanently remove this button. Are you sure?", "maxbuttons"); ?></p></span>
78 78 <div class='controls'>
79 79 <button type="button" class='button-primary' data-buttonaction='delete' data-buttonid='<?php echo $button_id ?>'>
80 80 <?php _e('Yes','maxbuttons'); ?></button>
81 -
81 +
82 82 <a class="modal_close button-primary"><?php _e("No", "maxbuttons"); ?></a>
83 -
83 +
84 84 </div>
85 85 </div>
86 86
87 87 <!-- trash modal -->
@@ -90,40 +90,40 @@
90 90 <span class="content"><p><?php _e("The button will be moved to trash. It can be recovered from the trash bin later. Continue?", "maxbuttons"); ?></p></span>
91 91 <div class='controls'>
92 92 <button type="button" class='button-primary' data-buttonaction='trash' data-buttonid='<?php echo $button_id ?>'>
93 93 <?php _e('Yes','maxbuttons'); ?></button>
94 -
94 +
95 95 <a class="modal_close button-primary"><?php _e("No", "maxbuttons"); ?></a>
96 -
96 +
97 97 </div>
98 98 </div>
99 -
99 +
100 100 <!-- copy modal -->
101 - <div class='maxmodal-data' id='copy-button' data-load='window.maxFoundry.maxadmin.checkCopyModal'>
101 + <div class='maxmodal-data' id='copy-button' data-load='window.maxFoundry.maxadmin.checkCopyModal'>
102 102 <span class='title'><?php _e("Copy this button","maxbuttons"); ?></span>
103 103 <span class="content">
104 -
105 - <div class='copy-warning'>
104 +
105 + <div class='copy-warning'>
106 106 <h3><?php _e('Probably you don\'t want to copy your button!', 'maxbuttons'); ?></h3>
107 107 <p><?php _e( sprintf("Changing %sText%s and %sURL%s can be done with the same button. %s This will save you time in the near future", "<b>","</b>","<b>","</b>","<br>"),'maxbuttons'); ?> </p>
108 -
108 +
109 109 <p class="example">
110 -
110 +
111 111 <strong><?php _e("Add the same button with different link","maxbuttons"); ?></strong><br>
112 112 &nbsp; [maxbutton id="<?php echo $button_id ?>" url="http://yoururl"]
113 113 </p>
114 -
114 +
115 115 <p class="example"><strong><?php _e("Use the same button but change the text","maxbuttons"); ?> </strong><br />
116 116 &nbsp; [maxbutton id="<?php echo $button_id ?>" text="yourtext"]
117 - </p>
117 + </p>
118 118
119 119 <p class="example"><strong><?php _e("Both","maxbuttons"); ?> </strong><br />
120 120 &nbsp; [maxbutton id="<?php echo $button_id ?>" text="yourtext" url="http://yoururl"]
121 - </p>
122 -
121 + </p>
122 +
123 123 </div>
124 124
125 -
125 +
126 126 <div class='mb-message mb-notice copy-notice hidden'><p><?php _e('Your button has not been saved. Any changes will be lost!','maxbuttons'); ?></p>
127 127 </div>
128 128 <p><?php _e("Do you want to copy this button to a new button?","maxbuttons"); ?></p>
129 129 </span>
@@ -133,23 +133,23 @@
133 133
134 134 <a class='button modal_close'><?php _e("Cancel",'maxbuttons'); ?></a>
135 135 </span>
136 136 </div>
137 -
137 +
138 138 <?php
139 139 /** Display admin notices [deprecated]
140 140 * @ignore
141 141 */
142 -
143 -
144 - /** Display admin notices
142 +
143 +
144 + /** Display admin notices
145 145 *
146 - * Hook to display admin notices on error and other occurences in the editor. Follows WP guidelines on format.
147 - * @since 4.20
146 + * Hook to display admin notices on error and other occurences in the editor. Follows WP guidelines on format.
147 + * @since 4.20
148 148 */
149 - do_action("mb/editor/display_notices");
150 - ?>
151 -
149 + do_action("mb/editor/display_notices");
150 + ?>
151 +
152 152 <?php if ($button_id > 0): ?>
153 153 <div class="mb-message shortcode">
154 154 <?php $button_name = $button->getName();
155 155
@@ -154,38 +154,41 @@
154 154 <?php $button_name = $button->getName();
155 155
156 156 ?>
157 157 <?php _e('To use this button, place the following shortcode anywhere you want it to appear in your site content:', 'maxbuttons') ?>
158 - <strong>[maxbutton id="<?php echo $button_id ?>"]</strong>
159 - <span class='shortcode-expand closed'><?php _e("See more examples","maxbuttons"); ?>
158 + <strong>[maxbutton id="<?php echo $button_id ?>"]</strong>
159 +
160 + <p><?php _e("Shortcode options can make using MaxButtons much easier! Check all possible options", 'maxbuttons'); ?> </p>
161 +
162 + <span class='shortcode-expand closed'><?php _e("See more options","maxbuttons"); ?>
160 163 <span class="dashicons-before dashicons-arrow-down"></span>
161 - </span>
162 -
164 + </span>
165 +
163 166 <div class="expanded">
164 - <p class="example">
167 + <p class="example">
165 168 <strong><?php _e("Add a button by using the button name","maxbuttons"); ?></strong>
166 - &nbsp; [maxbutton name="<?php echo $button_name; ?>"]
167 - </p>
169 + &nbsp; [maxbutton name="<?php echo $button_name; ?>"]
170 + </p>
168 171 <p class="example">
169 - <strong><?php _e("Add the same button with different link","maxbuttons"); ?></strong>
172 + <strong><?php _e("Same button with different link","maxbuttons"); ?></strong>
170 173 &nbsp; [maxbutton id="<?php echo $button_id ?>" url="http://yoururl"]
171 174 </p>
172 -
173 - <p class="example"><strong><?php _e("Use the same button but change the text","maxbuttons"); ?> </strong>
175 +
176 + <p class="example"><strong><?php _e("Same button with diffent text","maxbuttons"); ?> </strong>
174 177 &nbsp; [maxbutton id="<?php echo $button_id ?>" text="yourtext"]
175 178 </p>
176 179 <p class="example"><strong><?php _e("All possible shortcode options","maxbuttons"); ?></strong>
177 - &nbsp; [maxbutton id="<?php echo $button_id ?>" text="yourtext" url="http://yoururl" window="new" nofollow="true"]
180 + &nbsp; [maxbutton id="<?php echo $button_id ?>" text="yourtext" url="http://yoururl" linktitle="tooltip" window="new" nofollow="true"]
178 181 </p>
179 -
182 +
180 183 <h4><?php _e("Some tips","maxbuttons"); ?></h4>
181 - <p><?php _e("If you use this button on a static page, on multiple pages, or upload your theme to another WordPress installation choose an unique name and use ",
184 + <p><?php _e("If you use this button on a static page, on multiple pages, or upload your theme to another WordPress installation choose an unique name and use ",
182 185 "maxbuttons"); ?> <strong>[maxbutton name='my-buy-button' url='http://yoururl']</strong>.
183 186
184 -
187 +
185 188 <?php _e("By using this syntax when you edit and save your button it will be changed everywhere it is used on your site. If you delete the button and create a new one with the same name the new button will be used on your site.","maxbuttons"); ?>
186 189 </p>
187 -
190 +
188 191 </div>
189 192 </div>
190 193 <?php endif; ?>
191 194
@@ -190,55 +193,55 @@
190 193 <?php endif; ?>
191 194
192 195 <div class="output">
193 196 <div class="header"><?php _e('Preview', 'maxbuttons') ?>
194 - <span class='preview-toggle dashicons dashicons-arrow-up'> </span>
197 + <span class='preview-toggle dashicons dashicons-arrow-up'> </span>
195 198 </div>
196 - <?php
197 - $border_box = get_option('maxbuttons_borderbox');
198 - $boxclass = '';
199 + <?php
200 + $border_box = get_option('maxbuttons_borderbox');
201 + $boxclass = '';
199 202 if ($border_box == 1) // box-sizing option.
200 - $boxclass = 'preview-border-box';
203 + $boxclass = 'preview-border-box';
201 204 ?>
202 205 <div class="inner">
203 -
206 +
204 207 <p><?php _e('The top is the normal button, the bottom one is the hover.', 'maxbuttons') ?></p>
205 208 <div class="result <?php echo $boxclass ?>">
206 209
207 - <?php $button->display(array("mode" => 'editor', "load_css" => "element")); ?>
208 -
210 + <?php $button->display(array("mode" => 'editor', "load_css" => "element")); ?>
211 +
209 212 <p>&nbsp;</p>
210 -
211 - <?php $button->display(array("mode" => 'editor', "preview_part" => ":hover", "load_css" => "element")); ?>
212 -
213 - <?php $button->display_field_map(); ?>
213 +
214 + <?php $button->display(array("mode" => 'editor', "preview_part" => ":hover", "load_css" => "element")); ?>
215 +
216 + <?php $button->display_field_map(); ?>
214 217 </div>
215 -
218 +
216 219 <input type='hidden' id='colorpicker_current' value=''>
217 -
218 - <div class="input mbcolor preview nodrag">
219 - <input type="text" name="button_preview" id="button_preview" class="color-field">
220 +
221 + <div class="input mbcolor preview nodrag">
222 + <input type="text" name="button_preview" id="button_preview" class="color-field">
220 223 </div>
221 -
224 +
222 225 <div class="note"><?php _e('Change this color to see your button on a different background.', 'maxbuttons') ?></div>
223 226 <input type="hidden" id="button_preview" value='' />
224 227 <input style="display: none;" type="text" id="button_output" name="button_output" value="" />
225 228
226 229 <div class="clear"></div>
227 - </div> <!-- inner -->
228 - </div> <!-- output -->
229 -
230 - <?php #### STARTING FIELDS;
231 -
232 -
230 + </div> <!-- inner -->
231 + </div> <!-- output -->
232 +
233 + <?php #### STARTING FIELDS;
234 +
235 +
233 236 $button->admin_fields();
234 -
235 - ?>
236 237
237 - <div class="form-actions">
238 + ?>
239 +
240 + <div class="form-actions">
238 241 <a href="#" class="button-primary button-save"><?php _e('Save', 'maxbuttons') ?></a>
239 242 </div>
240 243 </form>
241 244
242 -
245 +
243 246 </div>
244 -<?php $admin->get_footer(); ?>
247 +<?php $admin->get_footer(); ?>