예제 #1
0
 /**
  * Retrieve attachment objects for list table display
  *
  * Supports prepare_items in class-mla-list-table.php.
  * Modeled after wp_edit_attachments_query in wp-admin/post.php
  *
  * @since 0.1
  *
  * @param	array	query parameters from web page, usually found in $_REQUEST
  * @param	int		number of rows to skip over to reach desired page
  * @param	int		number of rows on each page
  *
  * @return	array	attachment objects (posts) including parent data, meta data and references
  */
 public static function mla_query_list_table_items($request, $offset, $count)
 {
     if (NULL == self::$mla_list_table_items) {
         $request = self::_prepare_list_table_query($request, $offset, $count);
         $request = apply_filters('mla_list_table_query_final_terms', $request);
         self::$mla_list_table_items = apply_filters('mla_list_table_query_custom_items', NULL, $request);
         if (is_null(self::$mla_list_table_items)) {
             self::$mla_list_table_items = self::_execute_list_table_query($request);
         }
     }
     $attachments = self::$mla_list_table_items->posts;
     foreach ($attachments as $index => $attachment) {
         /*
          * Add parent data
          */
         $parent_data = self::mla_fetch_attachment_parent_data($attachment->post_parent);
         foreach ($parent_data as $parent_key => $parent_value) {
             $attachments[$index]->{$parent_key} = $parent_value;
         }
         /*
          * Add meta data
          */
         $meta_data = self::mla_fetch_attachment_metadata($attachment->ID);
         foreach ($meta_data as $meta_key => $meta_value) {
             $attachments[$index]->{$meta_key} = $meta_value;
         }
     }
     /*
      * Add references
      */
     self::mla_attachment_array_fetch_references($attachments);
     return $attachments;
 }