# maxbuttons/7.13/includes/maxbuttons-button.php

MaxButtons – Create buttons, version 7.13. 222 lines.

- Page: https://pluginprobe.com/plugins/maxbuttons/7.13/code/includes/maxbuttons-button.php
- Raw: https://pluginprobe.com/plugins/maxbuttons/7.13/raw/includes/maxbuttons-button.php
- Modified: 2019-10-11T11:32:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/maxbuttons/7.13/code/includes/maxbuttons-button.php#L10-L20`.

```php
<?php
namespace MaxButtons;
defined('ABSPATH') or die('No direct access permitted');

$button_id = $this->view->button_id;
$button = $this->view->button;

$admin = MB()->getClass('admin');
$page_title = __("Button editor","maxbuttons");
$action = "<a class='page-title-action add-new-h2' href='" . $this->getButtonLink() . "'>" . __('Add New', 'maxbuttons') . "</a>";
$admin->get_header(array("title" => $page_title, "title_action" => $action) );
 ?>
		<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">
			<input type="hidden" name="button_id" value="<?php echo $button_id ?>">
			<?php wp_nonce_field("button-edit","maxbuttons_button") ?>
			<?php wp_nonce_field("button-copy","copy_nonce"); ?>
			<?php wp_nonce_field("button-delete","delete_nonce"); ?>
			<?php wp_nonce_field('button-trash', 'trash_nonce'); ?>

			<div class="form-actions">
				<a class="button-primary button button-save" href='javascript:void(0);'><?php _e('Save', 'maxbuttons') ?></a>
				<?php if ($button_id > 0): ?>
				<a id="button-copy" class="maxmodal button" data-modal='copy-button' href="javascript:void(0)"><?php _e('Copy', 'maxbuttons') ?></a>
				<a id="button-trash" class="maxmodal button" data-modal = 'trash-button' href="javascript:void(0);"><?php _e('Move to Trash', 'maxbuttons') ?></a>
				<a class="button maxmodal" href="javascript:void(0);" data-modal='delete-button'><?php _e("Delete","maxbuttons"); ?> </a>
				<?php endif; // button_id > 0 ?>

				<?php do_action('mb/editor/form-actions', $button); ?>
			</div>

			<!-- delete modal -->
			<div class="maxmodal-data" id="delete-button">
				<span class='title'><?php _e("Removing button","maxbuttons"); ?></span>
				<span class="content"><p><?php _e("You are about to permanently remove this button. Are you sure?", "maxbuttons"); ?></p></span>
					<div class='controls'>
						<button type="button" class='button-primary' data-buttonaction='delete' data-buttonid='<?php echo $button_id ?>'>
						<?php _e('Yes','maxbuttons'); ?></button>

						<a class="modal_close button-primary"><?php _e("No", "maxbuttons"); ?></a>

					</div>
			</div>

			<!-- trash modal -->
			<div class="maxmodal-data" id="trash-button">
				<span class='title'><?php _e("Trash button","maxbuttons"); ?></span>
				<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>
					<div class='controls'>
						<button type="button" class='button-primary' data-buttonaction='trash' data-buttonid='<?php echo $button_id ?>'>
						<?php _e('Yes','maxbuttons'); ?></button>

						<a class="modal_close button-primary"><?php _e("No", "maxbuttons"); ?></a>

					</div>
			</div>

			<!-- copy modal -->
			<div class='maxmodal-data' id='copy-button' data-load='window.maxFoundry.maxadmin.checkCopyModal'>
				<span class='title'><?php _e("Copy this button","maxbuttons"); ?></span>
				<span class="content">

						<div class='copy-warning'>
						<h3><?php _e('You probably don\'t want to copy your button!', 'maxbuttons'); ?></h3>
						<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>

						<p class="example">

						<strong><?php _e("Add the same button with different link","maxbuttons");  ?></strong><br>
							&nbsp; [maxbutton id="<?php echo $button_id ?>" url="http://yoururl"]
						</p>

						<p class="example"><strong><?php _e("Use the same button but change the text","maxbuttons"); ?> </strong><br />
							&nbsp; [maxbutton id="<?php echo $button_id ?>" text="yourtext"]
						</p>

						<p class="example"><strong><?php _e("Both","maxbuttons"); ?> </strong><br />
							&nbsp; [maxbutton id="<?php echo $button_id ?>" text="yourtext" url="http://yoururl"]
						</p>

						</div>


				<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>
				</div>
				<p><?php _e("Do you want to copy this button to a new button?","maxbuttons"); ?></p>
				</span>
				<span class="controls">
				<button type="button" class='button-primary' data-buttonaction='copy' data-buttonid='<?php echo $button_id ?>'>
				<?php _e('Copy','maxbuttons'); ?></button>

				<a class='button modal_close'><?php _e("Cancel",'maxbuttons'); ?></a>
				</span>
			</div>

			<?php
			/** Display admin notices [deprecated]
			* @ignore
			*/
			/** Display admin notices
			*
			*   Hook to display admin notices on error and other occurences in the editor. Follows WP guidelines on format.
			*   @since 4.20
			*/
			do_action("mb/editor/display_notices");
			?>

			<?php if ($button_id > 0): ?>
			<div class="mb-message shortcode">
				<?php $button_name = $button->getName();

				 ?>
				<?php _e('To use this button, place the following shortcode anywhere you want it to appear in your site content:', 'maxbuttons') ?>
				<strong>[maxbutton id="<?php echo $button_id ?>"]</strong>

				<p><?php _e("Shortcode options can make using MaxButtons much easier! Check all possible options", 'maxbuttons'); ?> </p>

				<span class='shortcode-expand closed'><h4><?php _e("How to make your life easier","maxbuttons"); ?>
							<span class="dashicons-before dashicons-arrow-down"></span>
				</h4>

				</span>

				<div class="expanded">
					<p class="example">
						<strong><?php _e("Add a button by using the button name","maxbuttons"); ?></strong>
						&nbsp; [maxbutton name="<?php echo $button_name; ?>"]
					</p>
					<p class="example">
					<strong><?php _e("Same button with different link","maxbuttons");  ?></strong>
						&nbsp; [maxbutton id="<?php echo $button_id ?>" url="http://yoururl"]
					</p>

					<p class="example"><strong><?php _e("Same button with diffent text","maxbuttons"); ?> </strong>
						&nbsp; [maxbutton id="<?php echo $button_id ?>" text="yourtext"]
					</p>
					<p class="example"><strong><?php _e("All possible shortcode options","maxbuttons"); ?></strong>
						&nbsp; [maxbutton id="<?php echo $button_id ?>" text="yourtext" url="http://yoururl" linktitle="tooltip" window="new" nofollow="true"]
					</p>

					<h4><?php _e("More tips","maxbuttons"); ?></h4>
					<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 ",
						"maxbuttons"); ?>  <strong>[maxbutton name='my-buy-button' url='http://yoururl']</strong>.
					</p>

					<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"); ?>
				 	</p>

				</div>
			</div>
			<?php endif; ?>

		<div class="output">
			<div class="header"><?php _e('Preview', 'maxbuttons') ?>
				<span class='preview-toggle dashicons dashicons-arrow-up'> </span>
			</div>
			<?php
		//	$border_box = get_option('maxbuttons_borderbox');
		//	$boxclass = '';
		//	if ($border_box == 1)  // box-sizing option.
			//	$boxclass = 'preview-border-box';
			?>
			<div class="inner">

				<p><?php _e('The top is the normal button, the bottom one is the hover.', 'maxbuttons') ?></p>
				<div class="result ">

					<?php $button->display(array("mode" => 'editor', "load_css" => "element"));  ?>

					<p>&nbsp;</p>

					<?php $button->display(array("mode" => 'editor', "preview_part" => ":hover", "load_css" => "element")); ?>

					<?php $button->display_field_map(); ?>
				</div>

				<input type='hidden' id='colorpicker_current' value=''>

				<div class="input mbcolor preview nodrag">
					<input type="text" name="button_preview" id="button_preview" class="color-field" value="#ffffff">
				</div>

				<div class="note"><?php _e('Change this color to see your button on a different background.', 'maxbuttons') ?></div>
				<input  type="hidden" id="button_preview" value='' />
				<input style="display: none;" type="text" id="button_output" name="button_output" value="" />

				<div class="clear"></div>
			</div> <!-- inner -->
		</div> <!-- output -->

     <div class='editor'>
      <div id='normal_screen'>
        <!--  <span class='dashicons dashicons-admin-home'>&nbsp;</span> -->

      <?php #### STARTING FIELDS;
			$button->admin_fields();
			?>
      </div>
      <!--
      <div id='mobile_screen1'>
          <span class='dashicons dashicons-admin-home'>&nbsp;</span>
          - Screen 2 (wohoe)
      </div>
    -->

    </div>
			<div class="form-actions">
				<a href="#" class="button-primary button-save"><?php _e('Save', 'maxbuttons') ?></a>
			</div>

		</form>

		<?php // output the link dialog thing

		if ( ! class_exists( '_WP_Editors', false ) )
        require( ABSPATH . WPINC . '/class-wp-editor.php' );

		//add the interface of the link picker.
		\_WP_Editors::wp_link_dialog() ?>

	</div>
<?php $admin->get_footer(); ?>

```
