Esempio n. 1
0
  public function posts($args = array()) {
    global $wf;
    
    $post_types = $this->field()->info->type_options["post_types"];
    
    if (WOOF::args_empty($args)) { // we simply want the posts in the UI
      
      if (!isset($this->_posts)) {
        $value = $this->value();
    
        if (!is_array($value)) {
          $value = array($value);
        }
    
        
        $r = wp_parse_args($args);
        $r["cache_results"] = false;
        $r["post_type"] = $post_types;
      
        $posts = $wf->posts_in($value, $r);

        $this->_posts = $posts->sort_to("id", $value);  
      }
    
    } else { // we want a specialisation of the posts in the UI.
    
      $r = wp_parse_args($args);
      
      $value = $this->value();
  
      if (!is_array($value)) {
        $value = array($value);
      }
  
      $r["cache_results"] = false;
      $r["post_type"] = $post_types;

      $posts = $wf->posts_in($value, $r);
      
      if (!isset($r["orderby"])) {
        return $posts->sort_to("id", $value);  
      }
      
      return $posts;
      
    }
    
    return $this->_posts;
  }