function getButtons()
 {
     // should maybe but a 'light init' of buttons?
     $selection = $this->data["selection"];
     $buttonsArray = array();
     if (count($selection) == 0) {
         return $buttonsArray;
     }
     $table = maxUtils::get_buttons_table_name();
     $query_selection = $selection;
     $selectstring = implode($query_selection, ",");
     $sql = "SELECT DISTINCT * FROM {$table} WHERE id in (" . $selectstring . ")";
     global $wpdb;
     $results = $wpdb->get_results($sql, ARRAY_A);
     $data_array = array();
     foreach ($results as $result) {
         $data_array[$result['id']] = $result;
     }
     foreach ($selection as $button_id) {
         $button = MB()->getClass("button");
         // performance: bypass the set ( = query ) for every button
         //$button->set($button_id);
         $data = isset($data_array[$button_id]) ? $data_array[$button_id] : array();
         if (count($data) > 0) {
             maxButtons::buttonLoad(array("button_id" => $button_id));
             // central registration - from button
             $button->setupData($data);
         }
         maxButtons::forceNextID();
         $buttonsArray[] = $button;
     }
     return $buttonsArray;
 }
function check_charset()
{
    global $maxbuttons_installed_version;
    global $wpdb;
    $check = "SHOW FULL COLUMNS FROM " . maxUtils::get_buttons_table_name();
    $charset = $wpdb->query($check);
    return $charset;
}
Exemplo n.º 3
0
 function getButtonCount($args = array())
 {
     $defaults = array("status" => "publish");
     $args = wp_parse_args($args, $defaults);
     $sql = "SELECT count(id) FROM " . maxUtils::get_buttons_table_name() . " WHERE status = '%s'";
     $sql = $this->wpdb->prepare($sql, $args["status"]);
     $result = $this->wpdb->get_var($sql);
     return $result;
 }
<?php

defined('ABSPATH') or die('No direct access permitted');
/*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 = maxUtils::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();
}
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();
 public static function upgradeUTF()
 {
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     if (!function_exists('maybe_convert_table_to_utf8mb4')) {
         return;
     }
     // Versions before 4.2.0
     $table_name = maxUtils::get_buttons_table_name();
     $collection_table_name = maxUtils::get_collection_table_name();
     maybe_convert_table_to_utf8mb4($table_name);
     maybe_convert_table_to_utf8mb4($collection_table_name);
 }
Exemplo n.º 6
0
 public function reset_cache()
 {
     global $wpdb;
     $fields = array("cache" => null);
     $where = array(1 => 1);
     //$where_format = array('%d');
     $sql = "UPDATE " . maxUtils::get_buttons_table_name() . " SET cache = NULL ";
     $wpdb->query($sql);
 }
 public function check_database($blocks)
 {
     maxUtils::addTime("Check database");
     $sql = "SELECT id,name,status,cache";
     foreach ($blocks as $block => $class) {
         $sql .= ", {$block}";
     }
     $sql .= " from " . maxUtils::get_buttons_table_name() . " limit 1";
     global $wpdb;
     $wpdb->hide_errors();
     $result = $wpdb->get_results($sql);
     // check this query for errors. If there is an error, one or more database fields are missing. Fix that.
     if (isset($wpdb->last_error) && $wpdb->last_error != '') {
         $install = $this->getClass("install");
         $install::create_database_table();
         $install::migrate();
     }
     maxUtils::addTime("End check database");
 }