<?php if (isset($_GET['id']) && $_GET['id'] != '') { $button = new maxButton(); $button_id = intval($_GET["id"]); // validation $button->delete(intval($_GET['id'])); //maxbuttons_button_delete_permanently($_GET['id']); } ?> <script type="text/javascript"> window.location = "<?php admin_url(); ?> admin.php?page=maxbuttons-controller&action=list&status=trash&message=1delete"; </script>
$response = ''; } if (isset($_POST["reset_cache"])) { $button = new maxButton(); $button->reset_cache(); } if (isset($_POST["remigrate"])) { $install = MB()->getClass("install"); $install::create_database_table(); $install::migrate(); } if (isset($_POST["replace"]) && check_admin_referer('mb_bulk_edit', 'bulk_edit')) { $search = $_POST["search"]; $replace = $_POST["replace"]; $field = $_POST["replace_field"]; $button = new maxButton(); if ($field == '') { exit("FATAL"); } $admin = MB()->getClass('admin'); $buttonsIDS = $admin->getButtons(array('limit' => -1)); $data_found = false; foreach ($buttonsIDS as $row) { $button_id = $row["id"]; $button->set($button_id); $data = $button->get(); foreach ($data as $block => $fields) { if (isset($fields[$field])) { $value = $fields[$field]; $data[$block][$field] = str_replace($search, $replace, $value); $button->update($data);
<?php $result = ''; exit("Not used"); $button = new maxButton(); if ($_POST) { if (isset($_POST['button-id']) && isset($_POST['bulk-action-select'])) { if ($_POST['bulk-action-select'] == 'restore') { $count = 0; foreach ($_POST['button-id'] as $id) { $button->set($id); $button->setStatus('publish'); //maxbuttons_button_restore($id); $count++; } if ($count == 1) { $result = __('Restored 1 button.', 'maxbuttons'); } if ($count > 1) { $result = __('Restored ', 'maxbuttons') . $count . __(' buttons.', 'maxbuttons'); } } if ($_POST['bulk-action-select'] == 'delete') { $count = 0; foreach ($_POST['button-id'] as $id) { $button->delete($id); $count++; } if ($count == 1) { $result = __('Deleted 1 button.', 'maxbuttons'); }
static function create_database_table() { //global $maxbuttons_installed_version; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; $table_name = maxUtils::get_buttons_table_name(); $button = new maxButton(); $blocks = $button->getDefinedBlocks(); // IMPORTANT: There MUST be two spaces between the PRIMARY KEY keywords // and the column name, and the column name MUST be in parenthesis. $sql = "CREATE TABLE " . $table_name . " ( \n\t\t\t\t\tid int NOT NULL AUTO_INCREMENT, \n\t\t\t\t\t name varchar(100) NULL, \n\t\t\t\t\t status varchar(10) default 'publish' NOT NULL, \n\t\t\t\t\t cache text, \n\t\t\t\t"; foreach ($blocks as $block) { $sql .= "" . $block . " TEXT NULL, \n "; } $sql .= " PRIMARY KEY (id) )"; if (!static::maxbuttons_database_table_exists($table_name)) { //require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); $result = dbDelta($sql); } if (static::maxbuttons_database_table_exists($table_name) && (get_option(MAXBUTTONS_VERSION_KEY) != MAXBUTTONS_VERSION_NUM || get_option(MAXBUTTONS_VERSION_KEY) == '')) { //require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); } // Reset the cache if there were any left from before $button->reset_cache(); // Collection table $collection_table_name = maxUtils::get_collection_table_name(); $sql = "CREATE TABLE " . $collection_table_name . " ( \n\t\t\t\t\tmeta_id int NOT NULL AUTO_INCREMENT, \n\t\t\t\t\tcollection_id int NOT NULL, \n\t\t\t\t\tcollection_key varchar(255), \n\t\t\t\t\tcollection_value text, \n\t\t\t\t\tPRIMARY KEY(meta_id) ) \n\t\t\t\t\t\n\t\t\t\t"; dbDelta($sql); $collection_trans_table = maxUtils::get_coltrans_table_name(); $sql = "CREATE TABLE {$collection_trans_table} ( \n \t\t\t\tname varchar(1000), \n\t\t\t\tvalue varchar(255),\n\t\t\t\texpire int,\n\t\t\t\tKEY(name) ); \n\t\t"; $res = dbDelta($sql); //else exit( __("Something went wrong when creating database table", "maxbuttons") ); }
<?php if (isset($_GET['id']) && $_GET['id'] != '') { $button_id = intval($_GET["id"]); // validation $button = new maxButton(); $button->set($button_id); $new_id = $button->copy(); } ?> <script type="text/javascript"> <?php if (isset($new_id)) { ?> window.location = "<?php admin_url(); ?> admin.php?page=maxbuttons-controller&action=button&id=<?php echo $new_id; ?> "; <?php } else { ?> window.location = "<?php admin_url(); ?> admin.php?page=maxbuttons-controller&action=list"; <?php } ?>
/*if(is_admin()) { wp_enqueue_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css', '', '4.0.1', false); } */ if (isset($_POST['alter_charset'])) { global $maxbuttons_installed_version; global $wpdb; $table_name = maxButtonsUtils::get_buttons_table_name(); $sql = "ALTER TABLE " . $table_name . " CONVERT TO CHARACTER SET utf8"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; $wpdb->query($sql); $response = 'CHARSET now utf_8 COLLATE utf8_general_ci'; } else { $response = ''; } if (isset($_POST["reset_cache"])) { $button = new maxButton(); $button->reset_cache(); } if (isset($_POST["remigrate"])) { $install = MB()->getClass("install"); $install::create_database_table(); $install::migrate(); } ?> <div id="maxbuttons"> <div class="wrap"> <h2 class="title"><?php _e('MaxButtons: Settings', 'maxbuttons');
function shortcode($atts) { $button = new maxButton(); return $button->shortcode($atts); }
public function admin_fields() { $data = $this->data[$this->blockname]; foreach ($this->fields as $field => $options) { $default = isset($options["default"]) ? $options["default"] : ''; ${$field} = isset($data[$field]) ? $data[$field] : $default; ${$field . "_default"} = $default; global $maxbuttons_container_alignments; } ?> <div class="option-container"> <div class="title"><?php _e('Advanced', 'maxbuttons'); ?> </div> <div class="inside"> <div class="option-design"> <p class="note"><?php _e('Adding !important to the button styles can help avoid potential conflicts with your theme styles.', 'maxbuttons'); ?> </p> <div class="label"><?php _e('Use !important', 'maxbuttons'); ?> </div> <div class="input"><input type="checkbox" value="1" id="important_css" name="important_css" <?php checked($important_css, 1); ?> ></div> <div class="clear"></div> </div> <div class="spacer big"></div> <div class="option-design"> <p class="note"><?php _e('By default, the CSS styles for the button are rendered within a <style> block in the HTML body. Enabling the "Use External CSS" option allows you to put the CSS code for the button into your theme stylesheet instead.', 'maxbuttons'); ?> </p> <div class="label"><?php _e('Use External CSS', 'maxbuttons'); ?> </div> <div class="input"><input type="checkbox" id="external_css" name="external_css" value="1" <?php checked($external_css, 1); ?> ></div> <div class="clear"></div> </div> <div class="option-design"> <div class="label"> </div> <div class="input"><a id="view_css_modal" name="view_css" href="#view_css" class="button" rel="leanModal"><?php _e('View CSS', 'maxbuttons'); ?> </a></div> <div class="clear"></div> <div id="view_css" class="max-modal"> <div class="modal_header"> <?php _e("External CSS", "maxbuttons"); ?> <div class="modal_close tb-close-icon"></div> </div> <div class="note"> <p><?php _e('If the "Use External CSS" option is enabled for this button, copy and paste the CSS code below into your theme stylesheet.', 'maxbuttons'); ?> </p> </div> <textarea id="maxbutton-css"> <?php if (isset($this->data["id"])) { $id = $this->data["id"]; $b = new maxButton(); $b->set($id); $b->parse_button(); $b->parse_css("preview"); echo $b->getparsedCSS(); } else { _e("Please save the button first", "maxbuttons"); } ?> </textarea> </div> </div> </div> </div> <?php }
<?php if (isset($_GET['id']) && $_GET['id'] != '') { $button_id = intval($_GET["id"]); // validation $button = new maxButton(); $set = $button->set($button_id, '', 'trash'); if (!$set) { exit("Restore failed"); } $button->setStatus("publish"); } ?> <script type="text/javascript"> window.location = "<?php admin_url(); ?> admin.php?page=maxbuttons-controller&action=list&status=trash&message=1restore"; </script>
<?php if (isset($_GET['id']) && $_GET['id'] != '') { $button_id = intval($_GET["id"]); // validation $button = new maxButton(); $result = $button->set($button_id); if ($result) { $button->setStatus('trash'); } } ?> <script type="text/javascript"> window.location = "<?php admin_url(); ?> admin.php?page=maxbuttons-controller&action=list&message=1"; </script>
static function create_database_table() { //global $maxbuttons_installed_version; $table_name = maxButtonsUtils::get_buttons_table_name(); $button = new maxButton(); $blocks = $button->getDefinedBlocks(); // IMPORTANT: There MUST be two spaces between the PRIMARY KEY keywords // and the column name, and the column name MUST be in parenthesis. $sql = "CREATE TABLE " . $table_name . " ( \n\t\t\t\t\tid int NOT NULL AUTO_INCREMENT, \n\t\t\t\t\t name varchar(100) NULL, \n\t\t\t\t\t status varchar(10) default 'publish' NOT NULL, \n\t\t\t\t"; /* name VARCHAR(100) NULL, description VARCHAR(500) NULL, url VARCHAR(250) NULL, text VARCHAR(100) NULL, text_font_family VARCHAR(50) NULL, text_font_size VARCHAR(10) NULL, text_font_style VARCHAR(10) NULL, text_font_weight VARCHAR(10) NULL, text_color VARCHAR(10) NULL, text_color_hover VARCHAR(10) NULL, text_shadow_offset_left VARCHAR(10) NULL, text_shadow_offset_top VARCHAR(10) NULL, text_shadow_width VARCHAR(10) NULL, text_shadow_color VARCHAR(10) NULL, text_shadow_color_hover VARCHAR(10) NULL, text_padding_top VARCHAR(10) NULL, text_padding_bottom VARCHAR(10) NULL, text_padding_left VARCHAR(10) NULL, text_padding_right VARCHAR(10) NULL, border_radius_top_left VARCHAR(10) NULL, border_radius_top_right VARCHAR(10) NULL, border_radius_bottom_left VARCHAR(10) NULL, border_radius_bottom_right VARCHAR(10) NULL, border_style VARCHAR(10) NULL, border_width VARCHAR(10) NULL, border_color VARCHAR(10) NULL, border_color_hover VARCHAR(10) NULL, box_shadow_offset_left VARCHAR(10) NULL, box_shadow_offset_top VARCHAR(10) NULL, box_shadow_width VARCHAR(10) NULL, box_shadow_color VARCHAR(10) NULL, box_shadow_color_hover VARCHAR(10) NULL, gradient_start_color VARCHAR(10) NULL, gradient_start_color_hover VARCHAR(10) NULL, gradient_end_color VARCHAR(10) NULL, gradient_end_color_hover VARCHAR(10) NULL, gradient_stop VARCHAR(2) NULL, gradient_start_opacity VARCHAR(3) NULL, gradient_end_opacity VARCHAR(3) NULL, gradient_start_opacity_hover VARCHAR(3), gradient_end_opacity_hover VARCHAR(3), new_window VARCHAR(10) NULL, container_enabled VARCHAR(5) NULL, container_width VARCHAR(7) NULL, container_margin_top VARCHAR(7) NULL, container_margin_right VARCHAR(7) NULL, container_margin_bottom VARCHAR(7) NULL, container_margin_left VARCHAR(7) NULL, container_alignment VARCHAR(25) NULL, container_center_div_wrap_enabled VARCHAR(5) NULL, nofollow VARCHAR(5) NULL, status VARCHAR(10) DEFAULT 'publish' NOT NULL, external_css VARCHAR(5) NULL, important_css VARCHAR(5) NULL, );"; */ foreach ($blocks as $block) { $sql .= "" . $block . " TEXT NULL, \n "; } $sql .= " PRIMARY KEY (id) )"; if (!static::maxbuttons_database_table_exists($table_name)) { require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql); } if (static::maxbuttons_database_table_exists($table_name) && (get_option(MAXBUTTONS_VERSION_KEY) != MAXBUTTONS_VERSION_NUM || get_option(MAXBUTTONS_VERSION_KEY) == '')) { require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql); } //else exit( __("Something went wrong when creating database table", "maxbuttons") ); }