public static function makeWhere($filtros)
 {
     if ($filtros == NULL || !is_array($filtros)) {
         return false;
     }
     include_once WP_PLUGIN_DIR . '/doconline/class/fechas.class.php';
     global $wpdb;
     $res = NULL;
     foreach ($filtros as $campo => $atributos) {
         if ($atributos['valor'] != NULL) {
             $txt = $res == NULL ? ' where ' : ' and ';
             switch ($atributos['tipo']) {
                 case 'like':
                     $res .= $txt . $campo . " like '%" . $atributos['valor'] . "%'";
                     break;
                 case 'menor':
                     $res .= $txt . $campo . " < ";
                     if ($atributos['comillas'] == 'S') {
                         $res .= "'";
                     }
                     $res .= $atributos['valor'];
                     if ($atributos['comillas'] == 'S') {
                         $res .= "'";
                     }
                     break;
                 case 'menor-igual':
                 case 'date-menor-igual':
                     $patron = '/\\_hasta/';
                     if (preg_match($patron, $campo)) {
                         $campo = preg_replace($patron, '', $campo);
                     }
                     if ($atributos['tipo'] == 'date-menor-igual') {
                         $atributos['valor'] = Fechas::formatoFechaPgSQL($atributos['valor']) . " 23:59:59";
                     }
                     $res .= $txt . $campo . " <= ";
                     if ($atributos['comillas'] == 'S') {
                         $res .= "'";
                     }
                     $res .= $atributos['valor'];
                     if ($atributos['comillas'] == 'S') {
                         $res .= "'";
                     }
                     break;
                 case 'mayor':
                     $res .= $txt . $campo . " > ";
                     if ($atributos['comillas'] == 'S') {
                         $res .= "'";
                     }
                     $res .= $atributos['valor'];
                     if ($atributos['comillas'] == 'S') {
                         $res .= "'";
                     }
                     break;
                 case 'mayor-igual':
                 case 'date-mayor-igual':
                     $patron = '/\\_desde/';
                     if (preg_match($patron, $campo)) {
                         $campo = preg_replace($patron, '', $campo);
                     }
                     if ($atributos['tipo'] == 'date-mayor-igual') {
                         $atributos['valor'] = Fechas::formatoFechaPgSQL($atributos['valor']) . " 00:00:00";
                     }
                     $res .= $txt . $campo . " >= ";
                     if ($atributos['comillas'] == 'S') {
                         $res .= "'";
                     }
                     $res .= $atributos['valor'];
                     if ($atributos['comillas'] == 'S') {
                         $res .= "'";
                     }
                     break;
                 case 'diferente':
                     $res .= $txt . $campo . " < ";
                     if ($atributos['comillas'] == 'S') {
                         $res .= "'";
                     }
                     $res .= $atributos['valor'];
                     if ($atributos['comillas'] == 'S') {
                         $res .= "'";
                     }
                     break;
                 case 'meta-si':
                     $res .= $txt . $atributos['pk'] . " in (";
                     $res .= "select " . $atributos['fk'] . " from " . $atributos['tabla'] . " where meta_key='" . $campo . "' and meta_value='" . $atributos['valor'] . "'";
                     $res .= ")";
                     break;
                 case 'meta-no':
                     $res .= $txt . $atributos['pk'] . " not in (";
                     $res .= "select " . $atributos['fk'] . " from " . $atributos['tabla'] . " where meta_key='" . $campo . "' and meta_value='" . $atributos['valor'] . "'";
                     $res .= ")";
                     break;
                 case 'fk-like-usuario':
                     $res .= $txt . " id_usuario in (select ID from " . $wpdb->prefix . "users where display_name like '%" . $atributos['valor'] . "%' and meta_value like '%" . $atributos['valor'] . "%')";
                     break;
                 case 'orderBy':
                 case 'ascDesc':
                     // no se tienen en cuenta...
                     break;
                 default:
                     $res .= $txt . $campo . " = ";
                     if ($atributos['comillas'] == 'S') {
                         $res .= "'";
                     }
                     $res .= $atributos['valor'];
                     if ($atributos['comillas'] == 'S') {
                         $res .= "'";
                     }
                     break;
             }
         }
     }
     return $res;
 }