File manager - Edit - /home/colomboelectrici/public_html/wp-content/plugins/page-generator-pro/includes/admin/500px.php
Back
<?php /** * 500px class * * @package Page_Generator_Pro * @author Tim Carr * @version 1.1.8 */ class Page_Generator_Pro_500px { /** * Holds the class object. * * @since 1.1.8 * * @var object */ public static $instance; /** * Holds the 500px Consumer Key * * @since 1.1.8 * * @var string */ private $consumer_key = 'NNCP2XjbRvOf946ln4JQo2kxb8DisunG4RakL5jQ'; /** * Holds the API endpoint * * @since 1.1.8 * * @var string */ private $endpoint = 'https://api.500px.com/v1/'; /** * Constructor * * @since 1.1.8 */ public function __construct() { } /** * Sets the oAuth Token and Secret for this class to use * * @since 1.1.8 * * @param string $oauth_token oAuth Access Token * @param string $oauth_token_secret oAuth Access Token Secret */ public function set_oauth_tokens( $oauth_token, $oauth_token_secret ) { $this->oauth_token = $oauth_token; $this->oauth_token_secret = $oauth_token_secret; } /** * Performs a search on 500px for photos based on the given criteria. * * @see https://github.com/500px/api-documentation/blob/master/endpoints/photo/GET_photos_search.md * * @since 1.1.8 * * @param int $image_size_id Image Size ID * @param int $limit Number of Images to return * @param string $term Term Search (false = no term search) * @param array $lat_lng Geo Search (lat + lng keys; false = no geo search) * @return array $images Images | WP_Error */ public function photos_search( $image_size_id = 600, $limit = 10, $term = false, $lat_lng = false ) { // Build array of arguments $args = array( 'rpp' => $limit, 'image_size'=> $image_size_id, 'license' => '1,2,3,4,5,6', // Anything CC-based 'sort' => '_score', // Return best matching images ); // Depending on the arguments passed to this function, add some additional array arguments if ( $term != false ) { $args['term'] = sanitize_text_field( $term ); } if ( $lat_lng != false ) { $args['geo'] = $lat_lng['lat'] . ',' . $lat_lng['lng'] . ',5mi'; } // Run the query $results = $this->get( 'photos/search', $args ); if ( is_wp_error( $results ) ) { return $results; } // Parse results $images = array(); foreach ( $results->photos as $photo ) { $images[] = array( 'url' => $photo->image_url, 'title' => $photo->name, 'caption' => $photo->description, ); } // Return array of images return $images; } /** * Performs an oAuth signed GET request * * @since 1.1.8 * * @param string $action Action * @param array $args Arguments * @return array $data Result Data */ private function get( $action, $args ) { // Add consumer key to args $args['consumer_key'] = $this->consumer_key; // Build URL $url = $this->endpoint . $action . '?' . http_build_query( $args ); // Run query $response = wp_remote_get( $url ); // Bail if an error occured if ( is_wp_error( $response ) ) { return $response; } // Get body $data = wp_remote_retrieve_body( $response ); $json = json_decode( $data ); return $json; } /** * Returns the singleton instance of the class. * * @since 1.1.3 * * @return object Class. */ public static function get_instance() { if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) { self::$instance = new self; } return self::$instance; } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.06 |
proxy
|
phpinfo
|
Settings