PK œqhYî¶J‚ßFßF)nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/ $#$#$#

Dir : /home/trave494/photostockmall.online/wp-content/plugins/edd-commissions/includes/
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
IP: 209.182.202.254
Choose File :

Url:
Dir : //home/trave494/photostockmall.online/wp-content/plugins/edd-commissions/includes/rest-api.php

<?php

// extends the default EDD REST API to provide an endpoint for commissions
class EDDC_REST_API {

	public function __construct() {

		add_filter( 'edd_api_valid_query_modes', array( $this, 'query_mode'  ) );
		add_filter( 'edd_api_output_data',       array( $this, 'output_data' ), 10, 3 );
	}

	public function query_mode( $query_modes ) {

		$query_modes[] = 'commissions';

		return $query_modes;
	}

	public function output_data( $data, $query_mode, $api_object ) {

		if( 'commissions' != $query_mode )
			return $data;

		$user_id = $api_object->get_user();

		$data['unpaid'] = array();
		$data['paid']   = array();

		$unpaid = eddc_get_unpaid_commissions( array( 'user_id' => $user_id, 'number' => 30, 'paged' => $api_object->get_paged() ) );
		if( ! empty( $unpaid ) ) {
			foreach( $unpaid as $commission ) {

				$commission_meta = get_post_meta( $commission->ID, '_edd_commission_info', true );

				$data['unpaid'][] = array(
					'amount'   => edd_sanitize_amount( $commission_meta['amount'] ),
					'rate'     => $commission_meta['rate'],
					'currency' => $commission_meta['currency'],
					'item'     => get_the_title( get_post_meta( $commission->ID, '_download_id', true ) ),
					'date'     => $commission->post_date
				);
			}
		}

		$paid = eddc_get_paid_commissions( array( 'user_id' => $user_id, 'number' => 30, 'paged' => $api_object->get_paged() ) );
		if( ! empty( $paid ) ) {
			foreach( $paid as $commission ) {

				$commission_meta = get_post_meta( $commission->ID, '_edd_commission_info', true );

				$data['paid'][] = array(
					'amount'   => edd_sanitize_amount( $commission_meta['amount'] ),
					'rate'     => $commission_meta['rate'],
					'currency' => $commission_meta['currency'],
					'item'     => get_the_title( get_post_meta( $commission->ID, '_download_id', true ) ),
					'date'     => $commission->post_date
				);
			}
		}

		$data['totals'] = array(
			'unpaid'    => eddc_get_unpaid_totals( $user_id ),
			'paid'      => eddc_get_paid_totals( $user_id )
		);

		return $data;

	}

}
new EDDC_REST_API;