| @@ -1,17 +1,60 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace MaxButtons; |
| 3 | 3 | defined('ABSPATH') or die('No direct access permitted'); |
| 4 | 4 | |
| 5 | -$button_id = $this->view->button_id; | |
| 6 | -$button = $this->view->button; | |
| 5 | +$button = MB()->getClass("button"); //new maxButton(); | |
| 6 | +$button_id = 0; | |
| 7 | 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 | + | |
| 8 | 51 | $admin = MB()->getClass('admin'); |
| 9 | 52 | $page_title = __("Button editor","maxbuttons"); |
| 10 | -$action = "<a class='page-title-action add-new-h2' href='" . $this->getButtonLink() . "'>" . __('Add New', 'maxbuttons') . "</a>"; | |
| 53 | +$action = "<a class='page-title-action add-new-h2' href='" . admin_url() . "admin.php?page=maxbuttons-controller&action=edit'>" . __('Add New', 'maxbuttons') . "</a>"; | |
| 11 | 54 | $admin->get_header(array("title" => $page_title, "title_action" => $action) ); |
| 12 | 55 | ?> |
| 13 | - <form id="new-button-form" action="<?php echo $this->getButtonLink($button_id, array('noheader' => true)); // echo admin_url('admin.php?page=maxbuttons-controller&action=button&noheader=true'); ?>" method="post"> | |
| 56 | + <form id="new-button-form" action="<?php echo admin_url('admin.php?page=maxbuttons-controller&action=button&noheader=true'); ?>" method="post"> | |
| 14 | 57 | <input type="hidden" name="button_id" value="<?php echo $button_id ?>"> |
| 15 | 58 | <?php wp_nonce_field("button-edit","maxbuttons_button") ?> |
| 16 | 59 | <?php wp_nonce_field("button-copy","copy_nonce"); ?> |
| 17 | 60 | <?php wp_nonce_field("button-delete","delete_nonce"); ?> |
| @@ -59,9 +102,9 @@ | ||
| 59 | 102 | <span class='title'><?php _e("Copy this button","maxbuttons"); ?></span> |
| 60 | 103 | <span class="content"> |
| 61 | 104 | |
| 62 | 105 | <div class='copy-warning'> |
| 63 | - <h3><?php _e('You probably don\'t want to copy your button!', 'maxbuttons'); ?></h3> | |
| 106 | + <h3><?php _e('Probably you don\'t want to copy your button!', 'maxbuttons'); ?></h3> | |
| 64 | 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> |
| 65 | 108 | |
| 66 | 109 | <p class="example"> |
| 67 | 110 | |
| @@ -79,10 +122,10 @@ | ||
| 79 | 122 | |
| 80 | 123 | </div> |
| 81 | 124 | |
| 82 | 125 | |
| 83 | - <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> | |
| 84 | - </div> | |
| 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> | |
| 85 | 128 | <p><?php _e("Do you want to copy this button to a new button?","maxbuttons"); ?></p> |
| 86 | 129 | </span> |
| 87 | 130 | <span class="controls"> |
| 88 | 131 | <button type="button" class='button-primary' data-buttonaction='copy' data-buttonid='<?php echo $button_id ?>'> |
| @@ -95,8 +138,10 @@ | ||
| 95 | 138 | <?php |
| 96 | 139 | /** Display admin notices [deprecated] |
| 97 | 140 | * @ignore |
| 98 | 141 | */ |
| 142 | + | |
| 143 | + | |
| 99 | 144 | /** Display admin notices |
| 100 | 145 | * |
| 101 | 146 | * Hook to display admin notices on error and other occurences in the editor. Follows WP guidelines on format. |
| 102 | 147 | * @since 4.20 |
| @@ -113,12 +158,10 @@ | ||
| 113 | 158 | <strong>[maxbutton id="<?php echo $button_id ?>"]</strong> |
| 114 | 159 | |
| 115 | 160 | <p><?php _e("Shortcode options can make using MaxButtons much easier! Check all possible options", 'maxbuttons'); ?> </p> |
| 116 | 161 | |
| 117 | - <span class='shortcode-expand closed'><h4><?php _e("How to make your life easier","maxbuttons"); ?> | |
| 118 | - <span class="dashicons-before dashicons-arrow-down"></span> | |
| 119 | - </h4> | |
| 120 | - | |
| 162 | + <span class='shortcode-expand closed'><?php _e("See more options","maxbuttons"); ?> | |
| 163 | + <span class="dashicons-before dashicons-arrow-down"></span> | |
| 121 | 164 | </span> |
| 122 | 165 | |
| 123 | 166 | <div class="expanded"> |
| 124 | 167 | <p class="example"> |
| @@ -136,14 +179,14 @@ | ||
| 136 | 179 | <p class="example"><strong><?php _e("All possible shortcode options","maxbuttons"); ?></strong> |
| 137 | 180 | [maxbutton id="<?php echo $button_id ?>" text="yourtext" url="http://yoururl" linktitle="tooltip" window="new" nofollow="true"] |
| 138 | 181 | </p> |
| 139 | 182 | |
| 140 | - <h4><?php _e("More tips","maxbuttons"); ?></h4> | |
| 183 | + <h4><?php _e("Some tips","maxbuttons"); ?></h4> | |
| 141 | 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 ", |
| 142 | 185 | "maxbuttons"); ?> <strong>[maxbutton name='my-buy-button' url='http://yoururl']</strong>. |
| 143 | - </p> | |
| 144 | 186 | |
| 145 | - <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"); ?> | |
| 187 | + | |
| 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"); ?> | |
| 146 | 189 | </p> |
| 147 | 190 | |
| 148 | 191 | </div> |
| 149 | 192 | </div> |
| @@ -153,17 +196,17 @@ | ||
| 153 | 196 | <div class="header"><?php _e('Preview', 'maxbuttons') ?> |
| 154 | 197 | <span class='preview-toggle dashicons dashicons-arrow-up'> </span> |
| 155 | 198 | </div> |
| 156 | 199 | <?php |
| 157 | - // $border_box = get_option('maxbuttons_borderbox'); | |
| 158 | - // $boxclass = ''; | |
| 159 | - // if ($border_box == 1) // box-sizing option. | |
| 160 | - // $boxclass = 'preview-border-box'; | |
| 200 | + $border_box = get_option('maxbuttons_borderbox'); | |
| 201 | + $boxclass = ''; | |
| 202 | + if ($border_box == 1) // box-sizing option. | |
| 203 | + $boxclass = 'preview-border-box'; | |
| 161 | 204 | ?> |
| 162 | 205 | <div class="inner"> |
| 163 | 206 | |
| 164 | 207 | <p><?php _e('The top is the normal button, the bottom one is the hover.', 'maxbuttons') ?></p> |
| 165 | - <div class="result "> | |
| 208 | + <div class="result <?php echo $boxclass ?>"> | |
| 166 | 209 | |
| 167 | 210 | <?php $button->display(array("mode" => 'editor', "load_css" => "element")); ?> |
| 168 | 211 | |
| 169 | 212 | <p> </p> |
| @@ -175,9 +218,9 @@ | ||
| 175 | 218 | |
| 176 | 219 | <input type='hidden' id='colorpicker_current' value=''> |
| 177 | 220 | |
| 178 | 221 | <div class="input mbcolor preview nodrag"> |
| 179 | - <input type="text" name="button_preview" id="button_preview" class="color-field" value="#ffffff"> | |
| 222 | + <input type="text" name="button_preview" id="button_preview" class="color-field"> | |
| 180 | 223 | </div> |
| 181 | 224 | |
| 182 | 225 | <div class="note"><?php _e('Change this color to see your button on a different background.', 'maxbuttons') ?></div> |
| 183 | 226 | <input type="hidden" id="button_preview" value='' /> |
| @@ -186,36 +229,19 @@ | ||
| 186 | 229 | <div class="clear"></div> |
| 187 | 230 | </div> <!-- inner --> |
| 188 | 231 | </div> <!-- output --> |
| 189 | 232 | |
| 190 | - <div class='editor'> | |
| 191 | - <div id='normal_screen'> | |
| 192 | - <!-- <span class='dashicons dashicons-admin-home'> </span> --> | |
| 233 | + <?php #### STARTING FIELDS; | |
| 193 | 234 | |
| 194 | - <?php #### STARTING FIELDS; | |
| 235 | + | |
| 195 | 236 | $button->admin_fields(); |
| 237 | + | |
| 196 | 238 | ?> |
| 197 | - </div> | |
| 198 | - <!-- | |
| 199 | - <div id='mobile_screen1'> | |
| 200 | - <span class='dashicons dashicons-admin-home'> </span> | |
| 201 | - - Screen 2 (wohoe) | |
| 202 | - </div> | |
| 203 | - --> | |
| 204 | 239 | |
| 205 | - </div> | |
| 206 | 240 | <div class="form-actions"> |
| 207 | 241 | <a href="#" class="button-primary button-save"><?php _e('Save', 'maxbuttons') ?></a> |
| 208 | 242 | </div> |
| 209 | - | |
| 210 | 243 | </form> |
| 211 | 244 | |
| 212 | - <?php // output the link dialog thing | |
| 213 | - | |
| 214 | - if ( ! class_exists( '_WP_Editors', false ) ) | |
| 215 | - require( ABSPATH . WPINC . '/class-wp-editor.php' ); | |
| 216 | - | |
| 217 | - //add the interface of the link picker. | |
| 218 | - \_WP_Editors::wp_link_dialog() ?> | |
| 219 | 245 | |
| 220 | 246 | </div> |
| 221 | 247 | <?php $admin->get_footer(); ?> |