Example #1
0
  public function __construct($item) {
    
    global $wf;
    
    parent::__construct($item);
    
    $id = $this->id();
    
    $file_url = wp_get_attachment_url( $id );
    $file_path = WOOF_File::infer_content_path($file_url);

    if (wp_attachment_is_image( $id ) ) {
      $c = $wf->get_image_class();
      $this->file = new $c( $file_path, $file_url );
    } else {
      $c = $wf->get_file_class();
      $this->file = new $c( $file_path, $file_url );
    }

  }
Example #2
0
  public function ep_term() {
    
    global $wf;
    
    if ($wf->has_qv("taxonomy")) {
      $tax = $wf->taxonomy($wf->qv("taxonomy"));

      if ($tax->exists()) {
    
        // check for the term
        $tax_name = $tax->name();
    
        $term_slug = $wf->qv($tax_name);
    
        if ($term_slug) {

          $term = $wf->term($term_slug, $tax_name);
      
          if ($term->exists()) {
      
            $term_fields = $wf->parse_field_list( apply_filters( "mp_rest_term_fields", MEOW_Term::json_fields() , $tax_name ) );

            $json = $term->json($term_fields);
          
            // override the current href
            $json["href"] = $wf->current_url();


            // output the posts
              
            if ($wf->has_qv("post_type")) {
          
              $pt = $wf->qv("post_type");
          
              $json["posts"] = array();
                
              $fields = $wf->parse_field_list( apply_filters( "mp_rest_archive_fields", MEOW_Post::json_fields() , $pt ) );

              $args = $wf->types($pt)->in_the($term->slug, $tax_name, "args=1");
                
              $args["ep"] = $this->endpoint_url( $wf->types($pt)->rewrite_slug(true) . "/" . $tax->rewrite_slug( true ) . "/" . $term_slug );
              $args["sub"] = true;
              
              $json["posts"] = $this->posts( $args, "tax_query,type" );
              
              
            } else {
          
              // TODO, fill in this endpoint
          
            }
        
            return $json;

          }
      
        }
    
      }
      
    }
  
  } // ep_term