Ejemplo n.º 1
0
 protected static function get_mural_id()
 {
     global $curauth;
     if (tnb_cache_exists('MURAL_ID', $curauth->ID)) {
         return tnb_cache_get('MURAL_ID', $curauth->ID);
     }
     global $wpdb;
     $mural_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_author = {$curauth->ID} AND post_type = 'mural' LIMIT 1");
     if (!$mural_id) {
         $post = array('post_type' => 'mural', 'post_author' => $curauth->ID, 'post_title' => 'Mural de ' . $curauth->user_login, 'post_status' => 'publish', 'comment_status' => 'open');
         $mural_id = wp_insert_post($post);
         $mural_id = !is_wp_error($mural_id) ? $mural_id : false;
     }
     if ($mural_id) {
         tnb_cache_set('MURAL_ID', $curauth->ID, $mural_id);
     }
     return $mural_id;
 }
 protected static function getOportunidadesSelecionado()
 {
     global $wpdb, $curauth;
     if (tnb_cache_exists('ARTISTA_EVENTOS_SELECIONADOS', $curauth->ID)) {
         return tnb_cache_get('ARTISTA_EVENTOS_SELECIONADOS', $curauth->ID);
     }
     $query_subevents_arovados = " AND (post_parent = 0 OR ID IN (SELECT DISTINCT post_id FROM {$wpdb->postmeta} WHERE meta_key = 'aprovado_para_superevento') ) ";
     $query = "\r\n        SELECT \r\n            ID \r\n        FROM \r\n            {$wpdb->posts} \r\n        WHERE\r\n            post_type = 'eventos' AND\r\n            post_status = 'publish' AND\r\n            ID in (SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = 'selecionado' AND meta_value = '{$curauth->ID}' )\r\n            {$query_subevents_arovados}";
     //echo " QUERY { $query } ";
     $oportunidadesID = $wpdb->get_col($query);
     if (sizeof($oportunidadesID) == 0) {
         // se não vier nada, temos que colocar alguma coisa que impeça a query de trazer todos
         $oportunidadesID = array(0);
     }
     $query_args = array('post_type' => 'eventos', 'post__in' => $oportunidadesID, 'meta_key' => 'evento_inicio', 'orderby' => 'meta_value', 'order' => 'DESC');
     $result = get_posts($query_args);
     tnb_cache_set('ARTISTA_EVENTOS_SELECIONADOS', $curauth->ID, $result);
     return $result;
 }
Ejemplo n.º 3
0
function tnb_cache_get($type, $id)
{
    global $TNB_RUNTIME_CACHE;
    if (tnb_cache_exists($type, $id)) {
        return $TNB_RUNTIME_CACHE[$type][$id];
    } else {
        return null;
    }
}