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);
 }
Пример #2
0
 static function getCollectionbyName($name)
 {
     //$collection = new maxCollection();
     global $wpdb;
     $sql = "select collection_id from " . maxUtils::get_collection_table_name() . " where collection_key = 'collection_name' and collection_value = %s ";
     $sql = $wpdb->prepare($sql, $name);
     $result = $wpdb->get_row($sql, ARRAY_A);
     // find first
     if (count($result) > 0) {
         if (isset($result["collection_id"])) {
             $usecol = self::getCollectionByID($result["collection_id"]);
             return $usecol;
         }
     }
     return false;
 }
Пример #3
0
 function get_meta($collection_id, $collection_key = '')
 {
     global $wpdb;
     $table = maxUtils::get_collection_table_name();
     $prepare = array($collection_id);
     $sql = "SELECT * from {$table} where collection_id = %d ";
     if ($collection_key != '') {
         $sql .= " and collection_key = %s ";
         array_push($prepare, $collection_key);
     }
     $sql = $wpdb->prepare($sql, $prepare);
     $results = $wpdb->get_results($sql, ARRAY_A);
     $result_array = array();
     // format array by field name = values to feed blocks and others.
     if (!is_null($results)) {
         $nr = array();
         foreach ($results as $row) {
             $key = $row["collection_key"];
             /* A field can be either plain text or JSON */
             if (json_decode($row["collection_value"])) {
                 $value = json_decode($row["collection_value"], true);
             } else {
                 $value = $row["collection_value"];
             }
             $result_array[$key] = $value;
             //$row["collection_value"] = unserialize($row["collection_value"]);
         }
         return $result_array;
     } else {
         return false;
     }
 }