PluginProbe
MaxButtons – Create buttons / 6.23
MaxButtons – Create buttons v6.23
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 6.23, at includes/maxbuttons-button.php

245 lines 9.6 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
28 $button->set($button_id);
29 wp_redirect(admin_url('admin.php?page=maxbuttons-controller&action=button&id=' . $button_id));
30 exit();
31 }
32
33 if (isset($_GET['id']) && $_GET['id'] != '') {
34 $button = MB()->getClass('button'); // reset
35 $button_id = intval($_GET["id"]);
36 if ($button_id == 0)
37 {
38 $error = __("Maxbuttons button id is zero. Your data is not saved correctly! Please check your database.","maxbuttons");
39 MB()->add_notice('error', $error);
40 }
41 // returns bool
42 $return = $button->set($button_id);
43 if ($return === false)
44 {
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);
47 }
48 }
49
50
51 $admin = MB()->getClass('admin');
52 $page_title = __("Button editor","maxbuttons");
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 $admin->get_header(array("title" => $page_title, "title_action" => $action) );
55 ?>
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 ?>">
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">
64 <a class="button-primary button button-save" href='javascript:void(0);'><?php _e('Save', 'maxbuttons') ?></a>
65 <?php if ($button_id > 0): ?>
66 <a id="button-copy" class="maxmodal button" data-modal='copy-button' href="javascript:void(0)"><?php _e('Copy', 'maxbuttons') ?></a>
67 <a id="button-trash" class="maxmodal button" data-modal = 'trash-button' href="javascript:void(0);"><?php _e('Move to Trash', 'maxbuttons') ?></a>
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); ?>
72 </div>
73
74 <!-- delete modal -->
75 <div class="maxmodal-data" id="delete-button">
76 <span class='title'><?php _e("Removing button","maxbuttons"); ?></span>
77 <span class="content"><p><?php _e("You are about to permanently remove this button. Are you sure?", "maxbuttons"); ?></p></span>
78 <div class='controls'>
79 <button type="button" class='button-primary' data-buttonaction='delete' data-buttonid='<?php echo $button_id ?>'>
80 <?php _e('Yes','maxbuttons'); ?></button>
81
82 <a class="modal_close button-primary"><?php _e("No", "maxbuttons"); ?></a>
83
84 </div>
85 </div>
86
87 <!-- trash modal -->
88 <div class="maxmodal-data" id="trash-button">
89 <span class='title'><?php _e("Trash button","maxbuttons"); ?></span>
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 <div class='controls'>
92 <button type="button" class='button-primary' data-buttonaction='trash' data-buttonid='<?php echo $button_id ?>'>
93 <?php _e('Yes','maxbuttons'); ?></button>
94
95 <a class="modal_close button-primary"><?php _e("No", "maxbuttons"); ?></a>
96
97 </div>
98 </div>
99
100 <!-- copy modal -->
101 <div class='maxmodal-data' id='copy-button' data-load='window.maxFoundry.maxadmin.checkCopyModal'>
102 <span class='title'><?php _e("Copy this button","maxbuttons"); ?></span>
103 <span class="content">
104
105 <div class='copy-warning'>
106 <h3><?php _e('Probably you don\'t want to copy your button!', 'maxbuttons'); ?></h3>
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
109 <p class="example">
110
111 <strong><?php _e("Add the same button with different link","maxbuttons"); ?></strong><br>
112 &nbsp; [maxbutton id="<?php echo $button_id ?>" url="http://yoururl"]
113 </p>
114
115 <p class="example"><strong><?php _e("Use the same button but change the text","maxbuttons"); ?> </strong><br />
116 &nbsp; [maxbutton id="<?php echo $button_id ?>" text="yourtext"]
117 </p>
118
119 <p class="example"><strong><?php _e("Both","maxbuttons"); ?> </strong><br />
120 &nbsp; [maxbutton id="<?php echo $button_id ?>" text="yourtext" url="http://yoururl"]
121 </p>
122
123 </div>
124
125
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 </div>
128 <p><?php _e("Do you want to copy this button to a new button?","maxbuttons"); ?></p>
129 </span>
130 <span class="controls">
131 <button type="button" class='button-primary' data-buttonaction='copy' data-buttonid='<?php echo $button_id ?>'>
132 <?php _e('Copy','maxbuttons'); ?></button>
133
134 <a class='button modal_close'><?php _e("Cancel",'maxbuttons'); ?></a>
135 </span>
136 </div>
137
138 <?php
139 /** Display admin notices [deprecated]
140 * @ignore
141 */
142
143
144 /** Display admin notices
145 *
146 * Hook to display admin notices on error and other occurences in the editor. Follows WP guidelines on format.
147 * @since 4.20
148 */
149 do_action("mb/editor/display_notices");
150 ?>
151
152 <?php if ($button_id > 0): ?>
153 <div class="mb-message shortcode">
154 <?php $button_name = $button->getName();
155
156 ?>
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"); ?>
160 <span class="dashicons-before dashicons-arrow-down"></span>
161 </span>
162
163 <div class="expanded">
164 <p class="example">
165 <strong><?php _e("Add a button by using the button name","maxbuttons"); ?></strong>
166 &nbsp; [maxbutton name="<?php echo $button_name; ?>"]
167 </p>
168 <p class="example">
169 <strong><?php _e("Add the same button with different link","maxbuttons"); ?></strong>
170 &nbsp; [maxbutton id="<?php echo $button_id ?>" url="http://yoururl"]
171 </p>
172
173 <p class="example"><strong><?php _e("Use the same button but change the text","maxbuttons"); ?> </strong>
174 &nbsp; [maxbutton id="<?php echo $button_id ?>" text="yourtext"]
175 </p>
176 <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"]
178 </p>
179
180 <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 ",
182 "maxbuttons"); ?> <strong>[maxbutton name='my-buy-button' url='http://yoururl']</strong>.
183
184
185 <?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 </p>
187
188 </div>
189 </div>
190 <?php endif; ?>
191
192 <div class="output">
193 <div class="header"><?php _e('Preview', 'maxbuttons') ?>
194 <span class='preview-toggle dashicons dashicons-arrow-up'> </span>
195 </div>
196 <?php
197 $border_box = get_option('maxbuttons_borderbox');
198 $boxclass = '';
199 if ($border_box == 1) // box-sizing option.
200 $boxclass = 'preview-border-box';
201 ?>
202 <div class="inner">
203
204 <p><?php _e('The top is the normal button, the bottom one is the hover.', 'maxbuttons') ?></p>
205 <div class="result <?php echo $boxclass ?>">
206
207 <?php $button->display(array("mode" => 'editor', "load_css" => "element")); ?>
208
209 <p>&nbsp;</p>
210
211 <?php $button->display(array("mode" => 'editor', "preview_part" => ":hover", "load_css" => "element")); ?>
212
213 <?php $button->display_field_map(); ?>
214 </div>
215
216 <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 </div>
221
222 <div class="note"><?php _e('Change this color to see your button on a different background.', 'maxbuttons') ?></div>
223 <input type="hidden" id="button_preview" value='' />
224 <input style="display: none;" type="text" id="button_output" name="button_output" value="" />
225
226 <div class="clear"></div>
227 </div> <!-- inner -->
228 </div> <!-- output -->
229
230 <?php #### STARTING FIELDS;
231
232
233 $button->admin_fields();
234
235 ?>
236
237 <div class="form-actions">
238 <a href="#" class="button-primary button-save"><?php _e('Save', 'maxbuttons') ?></a>
239 </div>
240 </form>
241
242
243 </div>
244 <?php $admin->get_footer(); ?>
245