PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 2.5.8
Shortcodes and extra features for Phlox theme v2.5.8
2.17.21 2.17.20 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.6 1.0.9 1.1.0 1.3.0 1.3.1 1.3.10 1.3.14 1.3.2 1.3.3 1.3.6 1.4.0 1.4.1 1.4.2 1.5.0 1.5.2 1.6.0 1.6.2 1.6.4 1.7.0 1.7.2 2.10.0 2.10.1 2.10.3 2.10.5 2.10.7 2.10.8 2.10.9 2.11.0 2.11.1 2.11.2 2.12.0 2.14.0 2.15.0 2.15.2 2.15.4 2.15.5 2.15.6 2.15.7 2.15.8 2.15.9 2.16.0 2.16.1 2.16.2 2.16.3 2.16.4 2.17.0 2.17.1 2.17.12 2.17.13 2.17.14 2.17.15 2.17.16 2.17.2 2.17.3 2.17.4 2.17.5 2.17.6 2.17.8 2.17.9 2.4.12 2.4.13 2.4.14 2.4.16 2.4.18 2.4.19 2.4.9 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.14 2.5.15 2.5.16 2.5.17 2.5.19 2.5.2 2.5.20 2.5.3 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.10 2.6.12 2.6.13 2.6.14 2.6.15 2.6.16 2.6.17 2.6.19 2.6.2 2.6.20 2.6.4 2.6.5 2.6.7 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.9 2.9.0 2.9.12 2.9.14 2.9.15 2.9.16 2.9.17 2.9.18 2.9.19 2.9.2 2.9.20 2.9.21 2.9.22 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8
auxin-elements / admin / includes / classes / class-auxin-upgrader-http-api.php
auxin-elements / admin / includes / classes Last commit date
class-auxels-plugin-check-update.php 6 years ago class-auxin-dashboard-notice.php 7 years ago class-auxin-license-activation.php 7 years ago class-auxin-notices.php 6 years ago class-auxin-upgrader-ajax-handlers.php 7 years ago class-auxin-upgrader-http-api.php 6 years ago class-auxin-upgrader-plugin.php 7 years ago class-auxin-upgrader-prepare.php 6 years ago class-auxin-upgrader-theme.php 7 years ago
class-auxin-upgrader-http-api.php
126 lines
1 <?php
2
3 class Auxin_Upgrader_Http_Api {
4
5 protected $api = 'http://api.averta.net/envato/items/';
6
7 function __construct(){}
8
9 /**
10 * Get single setting value
11 *
12 * @param string $option
13 * @param string $section
14 * @param string $default
15 * @return string
16 */
17 private function get_setting( $option, $section, $default = '' ) {
18 $options = get_site_option( $section );
19
20 if ( isset( $options[$option] ) ) {
21 return $options[$option];
22 }
23 return $default;
24 }
25
26 /**
27 * Make a wordpress remote post request on averta API
28 *
29 * @param array $args
30 * @return void
31 */
32 private function remote_post( $args ){
33 global $wp_version;
34
35 $request_string = array(
36 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url'),
37 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30: 3),
38 'body' => $args
39 );
40
41 // Start checking for an update
42 $request = wp_remote_post( $this->api, $request_string );
43
44 if ( is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) !== 200 ) {
45 return false;
46 }
47
48 return $request;
49 }
50
51 /**
52 * Get our non official items list
53 *
54 * @return array
55 */
56 private function get_non_official_items(){
57 return apply_filters( 'auxin_set_non_official_items', array(
58 '3909293' => 'phlox-pro',
59 '3909293-03' => 'auxin-shop',
60 '3909293-04' => 'auxin-the-news',
61 '3909293-05' => 'auxin-pro-tools',
62 '3909293-06' => 'masterslider',
63 '3909293-07' => 'js_composer',
64 '3909293-08' => 'bdthemes-element-pack',
65 '3909293-09' => 'Ultimate_VC_Addons',
66 '3909293-10' => 'waspthemes-yellow-pencil',
67 '3909293-11' => 'LayerSlider',
68 '3909293-12' => 'revslider',
69 '3909293-13' => 'go_pricing',
70 '3909293-14' => 'convertplug'
71 ) );
72 }
73
74 /**
75 * Get download link from averta API
76 *
77 * @return void
78 */
79 public function get_download_link( $key ){
80
81 $token = $this->get_setting( 'token' , AUXELS_PURCHASE_KEY );
82 $token = empty( $token ) ? $this->get_setting( 'token' , THEME_ID . '_license' ) : $token;
83
84 if( empty( $token ) ) {
85 return new WP_Error( 'no_credentials',
86 __( 'Envato username, API key and your item purchase code are required for downloading updates from Envato marketplace.', 'auxin-elements' )
87 );
88 }
89
90 $items = $this->get_non_official_items();
91
92 if( ! in_array( $key, $items ) ) {
93 return new WP_Error( 'no_credentials',
94 '"' . $key . '" ' . __( 'Is not exist in our non official list. ', 'auxin-elements' )
95 );
96 }
97 $item_ID = array_search( $key, $items );
98
99 $request = $this->remote_post( array(
100 'cat' => 'download-purchase',
101 'action' => 'token',
102 'item-id' => $item_ID,
103 'token' => $token,
104 'url' => get_site_url()
105 ) );
106
107 if( $request === false ){
108 return new WP_Error( 'process_faild',
109 __( 'Error in getting download link.', 'auxin-elements' )
110 );
111 }
112
113 $response = wp_remote_retrieve_body( $request );
114 $response = json_decode( $response, true );
115
116 if( ! isset( $response['download_url'] ) || empty( $response['download_url'] ) ) {
117 // Envato API error ..
118 return new WP_Error( 'no_credentials',
119 __( 'Error on connecting to download API...', 'auxin-elements' )
120 );
121 }
122
123 return $response['download_url'];
124 }
125
126 }