PluginProbe
MaxButtons – Create buttons / 7.0
MaxButtons – Create buttons v7.0
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-button.php

maxbuttons-button.php in MaxButtons – Create buttons 7.0, at includes/maxbuttons-button.php

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