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-button.php

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

255 lines 9.7 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");
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('You probably 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'><h4><?php _e("How to make your life easier","maxbuttons"); ?>
162 <span class="dashicons-before dashicons-arrow-down"></span>
163 </h4>
164
165 </span>
166
167 <div class="expanded">
168 <p class="example">
169 <strong><?php _e("Add a button by using the button name","maxbuttons"); ?></strong>
170 &nbsp; [maxbutton name="<?php echo $button_name; ?>"]
171 </p>
172 <p class="example">
173 <strong><?php _e("Same button with different link","maxbuttons"); ?></strong>
174 &nbsp; [maxbutton id="<?php echo $button_id ?>" url="http://yoururl"]
175 </p>
176
177 <p class="example"><strong><?php _e("Same button with diffent text","maxbuttons"); ?> </strong>
178 &nbsp; [maxbutton id="<?php echo $button_id ?>" text="yourtext"]
179 </p>
180 <p class="example"><strong><?php _e("All possible shortcode options","maxbuttons"); ?></strong>
181 &nbsp; [maxbutton id="<?php echo $button_id ?>" text="yourtext" url="http://yoururl" linktitle="tooltip" window="new" nofollow="true"]
182 </p>
183
184 <h4><?php _e("More tips","maxbuttons"); ?></h4>
185 <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 ",
186 "maxbuttons"); ?> <strong>[maxbutton name='my-buy-button' url='http://yoururl']</strong>.
187 </p>
188
189 <p> <?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. Easy!","maxbuttons"); ?>
190 </p>
191
192 </div>
193 </div>
194 <?php endif; ?>
195
196 <div class="output">
197 <div class="header"><?php _e('Preview', 'maxbuttons') ?>
198 <span class='preview-toggle dashicons dashicons-arrow-up'> </span>
199 </div>
200 <?php
201 // $border_box = get_option('maxbuttons_borderbox');
202 // $boxclass = '';
203 // if ($border_box == 1) // box-sizing option.
204 // $boxclass = 'preview-border-box';
205 ?>
206 <div class="inner">
207
208 <p><?php _e('The top is the normal button, the bottom one is the hover.', 'maxbuttons') ?></p>
209 <div class="result ">
210
211 <?php $button->display(array("mode" => 'editor', "load_css" => "element")); ?>
212
213 <p>&nbsp;</p>
214
215 <?php $button->display(array("mode" => 'editor', "preview_part" => ":hover", "load_css" => "element")); ?>
216
217 <?php $button->display_field_map(); ?>
218 </div>
219
220 <input type='hidden' id='colorpicker_current' value=''>
221
222 <div class="input mbcolor preview nodrag">
223 <input type="text" name="button_preview" id="button_preview" class="color-field">
224 </div>
225
226 <div class="note"><?php _e('Change this color to see your button on a different background.', 'maxbuttons') ?></div>
227 <input type="hidden" id="button_preview" value='' />
228 <input style="display: none;" type="text" id="button_output" name="button_output" value="" />
229
230 <div class="clear"></div>
231 </div> <!-- inner -->
232 </div> <!-- output -->
233
234 <?php #### STARTING FIELDS;
235
236 $button->admin_fields();
237
238 ?>
239
240 <div class="form-actions">
241 <a href="#" class="button-primary button-save"><?php _e('Save', 'maxbuttons') ?></a>
242 </div>
243 </form>
244
245 <?php // output the link dialog thing
246
247 if ( ! class_exists( '_WP_Editors', false ) )
248 require( ABSPATH . WPINC . '/class-wp-editor.php' );
249
250 //add the interface of the link picker.
251 \_WP_Editors::wp_link_dialog() ?>
252
253 </div>
254 <?php $admin->get_footer(); ?>
255