You appear to be a bot. Output may be restricted
Description
Given a download post object, generate the data for the API output
Usage
$array = EDD_API::get_product_data( $product_info );
Parameters
- $product_info
- ( object ) required – The Download Post Object
Returns
array Array of post data to return back in the API
Source
File name: easy-digital-downloads/includes/api/class-edd-api.php
Lines:
1 to 42 of 42
public function get_product_data( $product_info ) { $product = array(); $product['info']['id'] = $product_info->ID; $product['info']['slug'] = $product_info->post_name; $product['info']['title'] = $product_info->post_title; $product['info']['create_date'] = $product_info->post_date; $product['info']['modified_date'] = $product_info->post_modified; $product['info']['status'] = $product_info->post_status; $product['info']['link'] = html_entity_decode( $product_info->guid ); $product['info']['content'] = $product_info->post_content; $product['info']['excerpt'] = $product_info->post_excerpt; $product['info']['thumbnail'] = wp_get_attachment_url( get_post_thumbnail_id( $product_info->ID ) ); $product['info']['category'] = get_the_terms( $product_info, 'download_category' ); $product['info']['tags'] = get_the_terms( $product_info, 'download_tag' ); if( user_can( $this->user_id, 'view_shop_reports' ) || $this->override ) { $product['stats']['total']['sales'] = edd_get_download_sales_stats( $product_info->ID ); $product['stats']['total']['earnings'] = edd_get_download_earnings_stats( $product_info->ID ); $product['stats']['monthly_average']['sales'] = edd_get_average_monthly_download_sales( $product_info->ID ); $product['stats']['monthly_average']['earnings'] = edd_get_average_monthly_download_earnings( $product_info->ID ); } if ( edd_has_variable_prices( $product_info->ID ) ) { foreach ( edd_get_variable_prices( $product_info->ID ) as $price ) { $product['pricing'][ sanitize_key( $price['name'] ) ] = $price['amount']; } } else { $product['pricing']['amount'] = edd_get_download_price( $product_info->ID ); } if( user_can( $this->user_id, 'view_shop_sensitive_data' ) || $this->override ) { foreach ( edd_get_download_files( $product_info->ID ) as $file ) { $product['files'][] = $file; } $product['notes'] = edd_get_product_notes( $product_info->ID ); } return apply_filters( 'edd_api_products_product', $product ); }