Exemplo n.º 1
0
 public function update($data)
 {
     $return = false;
     $fields = array();
     foreach ($this->blocks as $block) {
         if (isset($data[$block])) {
             $blockData = $data[$block];
             $fields[$block] = serialize($blockData);
         }
     }
     if (isset($data["name"])) {
         // other fields.
         $fields["name"] = $data["name"];
     }
     if (isset($data["status"])) {
         $fields["status"] = $data["status"];
     }
     $where = array('id' => $this->id);
     if ($this->id > 0) {
         $where = array('id' => $this->id);
         $where_format = array('%d');
         $result = $this->wpdb->update(maxButtonsUtils::get_buttons_table_name(), $fields, $where, null, $where_format);
         $return = true;
     } else {
         $result = $this->wpdb->insert(maxButtonsUtils::get_buttons_table_name(), $fields);
         $id = $this->wpdb->insert_id;
         $this->id = $id;
         $return = $id;
     }
     if ($result === 0) {
         $error = "Database error " . $this->wpdb->last_error;
         maxButtons::add_notice('error', $error);
     }
     // update the cache
     //$css = $this->parse_css('normal', true); // force compile
     $this->cache = '';
     // empty cache
     $result = $this->set($this->id);
     // set the newest values
     if (!$result) {
         return false;
     }
     $this->display(array("echo" => false, "load_css" => "element"));
     // do display routing to compile.
     $css = $this->parsed_css;
     $this->update_cache($css);
     return $return;
 }
Exemplo n.º 2
0
    wp_redirect(admin_url('admin.php?page=maxbuttons-controller&action=button&id=' . $button_id));
    exit;
}
if (isset($_GET['id']) && $_GET['id'] != '') {
    $button = MB()->getClass('button');
    // reset
    $button_id = intval($_GET["id"]);
    if ($button_id == 0) {
        $error = __("Maxbuttons button id is zero. Your data is not saved correctly! Please check your database.", "maxbuttons");
        maxButtons::add_notice('error', $error);
    }
    // returns bool
    $return = $button->set($button_id);
    if ($return === false) {
        $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");
        maxButtons::add_notice('error', $error);
    }
}
?>
<div id="maxbuttons">
	<div class="wrap">
		<div class="icon32">
			<a href="http://maxbuttons.com" target="_blank"><img src="<?php 
echo maxButtons::get_plugin_url();
?>
/images/mb-peach-icon.png" alt="MaxButtons" /></a>
		</div>
		
		<h2 class="title"><?php 
_e('MaxButtons: Add/Edit Button', 'maxbuttons');
?>