wp-content/plugins/fakerpress/providers/image/500px.php
/**
	 * Makes a request to the 500px api
	 *
	 * @since 0.2.2
	 *
	 * @see  https://github.com/500px/api-documentation For more information on Endpoints
	 *
	 * @param  string $endpoint Which endpoint we are going to request
	 * @param  array  $args     Arguments use to request
	 * @return object|bool      The Body of the response or false if fail
	 */
Makes a request to the 500px api
@since 0.2.2



@param  string $endpoint Which endpoint we are going to request
@param  array  $args     Arguments use to request
@return object|bool      The Body of the response or false if fail
Makes a request to the 500px api @since 0 . 2 . 2 @param string $endpoint Which endpoint we are going to request @param array $args Arguments use to request @return object|bool The Body of the response or false if fail
protected function request( $endpoint = 'photos', $args = array() ){
		$key = \FakerPress\Plugin::get( array( '500px', 'key' ), false );
		if ( ! $key ) {
			return false;
		}
		$defaults = array(
			'consumer_key' => $key,
		);
		$args = wp_parse_args( $args, $defaults );
		array_multisort( $args );
		$hashed_id = substr( md5( json_encode( $args ) ), 0, 10 );
		$transient_id = Plugin::$slug . '-request-500px-' . $endpoint . '-' . $hashed_id;
		$expiration = apply_filters( 'fakerpress.provider.image.500px.request_expiration', 6 * HOUR_IN_SECONDS, $endpoint, $args, $this );
		if ( ! $expiration || false === ( $response = get_transient( $transient_id ) ) ) {
			$response = wp_remote_get( add_query_arg( $args, self::$base_url . $endpoint ) );
			$response = wp_remote_retrieve_body( $response );
			if ( ! $response ){
				return false;
			}
			$response = json_decode( $response );
			set_transient( $transient_id, $response, 6 * HOUR_IN_SECONDS );
		}
		return $response;
	}
protected function request ( $ endpoint = 'photos' , $ args = array ( ) ) { $ key = \ FakerPress \ Plugin :: get ( array ( '500px' , 'key' ) , false ) ; if ( ! $ key ) { return false ; } $ defaults = array ( 'consumer_key' => $ key , ) ; $ args = wp_parse_args ( $ args , $ defaults ) ; array_multisort ( $ args ) ; $ hashed_id = substr ( md5 ( json_encode ( $ args ) ) , 0 , 10 ) ; $ transient_id = Plugin :: $ slug . '-request-500px-' . $ endpoint . '-' . $ hashed_id ; $ expiration = apply_filters ( 'fakerpress.provider.image.500px.request_expiration' , 6 * HOUR_IN_SECONDS , $ endpoint , $ args , $ this ) ; if ( ! $ expiration || false === ( $ response = get_transient ( $ transient_id ) ) ) { $ response = wp_remote_get ( add_query_arg ( $ args , self :: $ base_url . $ endpoint ) ) ; $ response = wp_remote_retrieve_body ( $ response ) ; if ( ! $ response ) { return false ; } $ response = json_decode ( $ response ) ; set_transient ( $ transient_id , $ response , 6 * HOUR_IN_SECONDS ) ; } return $ response ; }
Makes a request to the 500px api
 @since 0.2.2
Makes a request to the 500px api @since 0 . 2 . 2
// Determine the Transient Key // Creates as transient key for the 500px request /**
		 * Filter how many seconds we keep the 500px requests in a transient
		 * Set to false or 0 to avoid caching
		 *
		 * @since  0.4.9
		 *
		 * @param  int     $expiration  How long we should hold to the a result of images from 500px
		 * @param  string  $endpoint    Which endpoint we are fetching
		 * @param  array   $args        Arguments for the Request to 500px
		 * @param  self    $provider    Instance of the Current class
		 */