PluginProbe
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services / 5.4.2
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services v5.4.2
8.7.8 8.7.7 8.7.6 8.7.5 8.7.4 8.7.3 8.7.2 8.7.1 8.7.0 8.6.9 8.6.8 8.6.7 8.6.6 8.6.5 8.6.4 8.6.2 8.6.1 8.6.0 8.5.9 8.5.8 8.5.7 8.5.6 8.5.5 8.5.4 8.5.3 All 534 releases
← All changes | includes/openai/plugin-upgrader/classes/plugin-upgrader.php +194 -195 8.5.45.4.2 View file →
@@ -1,196 +1,195 @@
1 -<?php
2 -if (!defined('ABSPATH')) exit; // Exit if accessed directly
3 -class QCLD_openaiaddon_AutoUpdate
4 -{
5 - /**
6 - * The plugin current version
7 - * @var string
8 - */
9 - private $current_version;
10 -
11 - /**
12 - * The plugin remote update path
13 - * @var string
14 - */
15 - private $update_path;
16 -
17 - /**
18 - * Plugin Slug (plugin_directory/plugin_file.php)
19 - * @var string
20 - */
21 - private $plugin_slug;
22 -
23 - /**
24 - * Plugin name (plugin_file)
25 - * @var string
26 - */
27 - private $slug;
28 -
29 - /**
30 - * License User
31 - * @var string
32 - */
33 - private $license_user;
34 -
35 - /**
36 - * License Key
37 - * @var string
38 - */
39 - private $license_key;
40 -
41 - /**
42 - * Initialize a new instance of the WordPress Auto-Update class
43 - * @param string $current_version
44 - * @param string $update_path
45 - * @param string $plugin_slug
46 - */
47 - public function __construct( $current_version, $update_path, $plugin_slug, $license_user = '', $license_key = '' )
48 - {
49 - $qcld_renew_subscription = get_openaiaddon_renew_transient();
50 -
51 - // Set the class public variables
52 - $this->current_version = $current_version;
53 - $this->update_path = $update_path;
54 -
55 - // Set the License
56 - $this->license_user = $license_user;
57 - $this->license_key = $license_key;
58 -
59 - // Set the Plugin Slug
60 - $this->plugin_slug = $plugin_slug;
61 - list ($t1, $t2) = explode( '/', $plugin_slug );
62 - $this->slug = $t1;
63 -
64 - // define the alternative API for updating checking
65 - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
66 -
67 - // Define the alternative response for information checking
68 - add_filter( 'plugins_api', array( $this, 'check_info' ), 10, 3 );
69 -
70 - if( $qcld_renew_subscription ){
71 - add_action("after_plugin_row_{$this->plugin_slug}", array($this, 'show_upgrade_subscription_on_plugin_row'), 10, 3 );
72 - }
73 -
74 - }
75 -
76 - /**
77 - * Add our self-hosted autoupdate plugin to the filter transient
78 - *
79 - * @param $transient
80 - * @return object $ transient
81 - */
82 - public function check_update( $transient )
83 - {
84 - if ( empty( $transient->checked ) ) {
85 - return $transient;
86 - }
87 -
88 -
89 - // Get the remote version
90 - $remote_version = $this->getRemote('info');
91 -
92 -
93 - // If a newer version is available, add the update
94 - if ( version_compare( $this->current_version, $remote_version->new_version, '<' ) ) {
95 - if(isset($remote_version->subscription_enable->plugin_name) ){
96 - $subscription_enable = $remote_version->subscription_enable->plugin_name;
97 - }else{
98 - $subscription_enable = '';
99 - }
100 -
101 -
102 -
103 - if( $this->slug == $subscription_enable ){
104 - $obj = new stdClass();
105 - $obj->slug = $this->slug;
106 - $obj->new_version = $remote_version->new_version;
107 - $obj->url = $remote_version->url;
108 - $obj->plugin = $this->plugin_slug;
109 - $obj->package = $remote_version->package;
110 - $obj->tested = $remote_version->tested;
111 - $obj->requires = $remote_version->requires;
112 - $obj->last_updated = $remote_version->last_updated;
113 - $obj->sections = $remote_version->sections;
114 -
115 - setqc_openaiaddon_update_transient($obj);
116 - deleteqc_openaiaddon_renew_transient();
117 -
118 - $transient->response[$this->plugin_slug] = $obj;
119 - }else{
120 - $obj = new stdClass();
121 - setqc_openaiaddon_renew_transient($obj);
122 - $qcld_renew_subscription = get_openaiaddon_renew_transient();
123 - if( $qcld_renew_subscription ){
124 - add_action("after_plugin_row_{$this->plugin_slug}", array($this, 'show_upgrade_subscription_on_plugin_row'), 10, 3 );
125 - }
126 - }
127 -
128 - }
129 - return $transient;
130 - }
131 -
132 - public function show_upgrade_subscription_on_plugin_row( $plugin_file, $plugin_data, $status ) {
133 - $qcld_renew_subscription = get_openaiaddon_renew_transient();
134 -
135 - if( $qcld_renew_subscription ){
136 - echo '<tr class="plugin-update-tr">
137 - <td colspan="3" class="plugin-update colspanchange">
138 - <div class="update-message notice inline notice-warning notice-alt">
139 - <p>There is a new version available. <a href="'.esc_url('https://www.ultrawebmedia.com/li/plugins/live-chat-addon/changelog.txt').'" target="_blank">View version details</a>. Automatic update is unavailable for this plugin. To receive automatic updates, valid license is required.</p>
140 - </div>
141 - </td>
142 - </tr>';
143 - }
144 - }
145 -
146 - /**
147 - * Add our self-hosted description to the filter
148 - *
149 - * @param boolean $false
150 - * @param array $action
151 - * @param object $arg
152 - * @return bool|object
153 - */
154 - public function check_info($obj, $action, $arg)
155 - {
156 - if (($action=='query_plugins' || $action=='plugin_information') &&
157 - isset($arg->slug) && $arg->slug === $this->slug) {
158 - return $this->getRemote('info');
159 - }
160 -
161 - return $obj;
162 - }
163 -
164 - /**
165 - * Return the remote version
166 - *
167 - * @return string $remote_version
168 - */
169 - public function getRemote($action = '')
170 - {
171 - $qcld_update_plugin = get_openaiaddon_update_transient();
172 -
173 -
174 -
175 - $params = array(
176 - 'body' => array(
177 - 'action' => $action,
178 - 'plugin-slug' => $this->slug,
179 - 'license_user' => $this->license_user,
180 - 'license_key' => $this->license_key,
181 - ),
182 - );
183 -
184 - // Make the POST request
185 - $request = wp_remote_post($this->update_path, $params );
186 - // Check if response is valid
187 -
188 - if ( !is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) === 200 ) {
189 -
190 - return @unserialize( $request['body'] );
191 - }
192 -
193 -
194 - return false;
195 - }
1 +<?php
2 +class QCLD_openaiaddon_AutoUpdate
3 +{
4 + /**
5 + * The plugin current version
6 + * @var string
7 + */
8 + private $current_version;
9 +
10 + /**
11 + * The plugin remote update path
12 + * @var string
13 + */
14 + private $update_path;
15 +
16 + /**
17 + * Plugin Slug (plugin_directory/plugin_file.php)
18 + * @var string
19 + */
20 + private $plugin_slug;
21 +
22 + /**
23 + * Plugin name (plugin_file)
24 + * @var string
25 + */
26 + private $slug;
27 +
28 + /**
29 + * License User
30 + * @var string
31 + */
32 + private $license_user;
33 +
34 + /**
35 + * License Key
36 + * @var string
37 + */
38 + private $license_key;
39 +
40 + /**
41 + * Initialize a new instance of the WordPress Auto-Update class
42 + * @param string $current_version
43 + * @param string $update_path
44 + * @param string $plugin_slug
45 + */
46 + public function __construct( $current_version, $update_path, $plugin_slug, $license_user = '', $license_key = '' )
47 + {
48 + $qcld_renew_subscription = get_openaiaddon_renew_transient();
49 +
50 + // Set the class public variables
51 + $this->current_version = $current_version;
52 + $this->update_path = $update_path;
53 +
54 + // Set the License
55 + $this->license_user = $license_user;
56 + $this->license_key = $license_key;
57 +
58 + // Set the Plugin Slug
59 + $this->plugin_slug = $plugin_slug;
60 + list ($t1, $t2) = explode( '/', $plugin_slug );
61 + $this->slug = $t1;
62 +
63 + // define the alternative API for updating checking
64 + add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
65 +
66 + // Define the alternative response for information checking
67 + add_filter( 'plugins_api', array( $this, 'check_info' ), 10, 3 );
68 +
69 + if( $qcld_renew_subscription ){
70 + add_action("after_plugin_row_{$this->plugin_slug}", array($this, 'show_upgrade_subscription_on_plugin_row'), 10, 3 );
71 + }
72 +
73 + }
74 +
75 + /**
76 + * Add our self-hosted autoupdate plugin to the filter transient
77 + *
78 + * @param $transient
79 + * @return object $ transient
80 + */
81 + public function check_update( $transient )
82 + {
83 + if ( empty( $transient->checked ) ) {
84 + return $transient;
85 + }
86 +
87 +
88 + // Get the remote version
89 + $remote_version = $this->getRemote('info');
90 +
91 +
92 + // If a newer version is available, add the update
93 + if ( version_compare( $this->current_version, $remote_version->new_version, '<' ) ) {
94 + if(isset($remote_version->subscription_enable->plugin_name) ){
95 + $subscription_enable = $remote_version->subscription_enable->plugin_name;
96 + }else{
97 + $subscription_enable = '';
98 + }
99 +
100 +
101 +
102 + if( $this->slug == $subscription_enable ){
103 + $obj = new stdClass();
104 + $obj->slug = $this->slug;
105 + $obj->new_version = $remote_version->new_version;
106 + $obj->url = $remote_version->url;
107 + $obj->plugin = $this->plugin_slug;
108 + $obj->package = $remote_version->package;
109 + $obj->tested = $remote_version->tested;
110 + $obj->requires = $remote_version->requires;
111 + $obj->last_updated = $remote_version->last_updated;
112 + $obj->sections = $remote_version->sections;
113 +
114 + setqc_openaiaddon_update_transient($obj);
115 + deleteqc_openaiaddon_renew_transient();
116 +
117 + $transient->response[$this->plugin_slug] = $obj;
118 + }else{
119 + $obj = new stdClass();
120 + setqc_openaiaddon_renew_transient($obj);
121 + $qcld_renew_subscription = get_openaiaddon_renew_transient();
122 + if( $qcld_renew_subscription ){
123 + add_action("after_plugin_row_{$this->plugin_slug}", array($this, 'show_upgrade_subscription_on_plugin_row'), 10, 3 );
124 + }
125 + }
126 +
127 + }
128 + return $transient;
129 + }
130 +
131 + public function show_upgrade_subscription_on_plugin_row( $plugin_file, $plugin_data, $status ) {
132 + $qcld_renew_subscription = get_openaiaddon_renew_transient();
133 +
134 + if( $qcld_renew_subscription ){
135 + echo '<tr class="plugin-update-tr">
136 + <td colspan="3" class="plugin-update colspanchange">
137 + <div class="update-message notice inline notice-warning notice-alt">
138 + <p>There is a new version available. <a href="'.esc_url('https://www.ultrawebmedia.com/li/plugins/live-chat-addon/changelog.txt').'" target="_blank">View version details</a>. Automatic update is unavailable for this plugin. To receive automatic updates, valid license is required.</p>
139 + </div>
140 + </td>
141 + </tr>';
142 + }
143 + }
144 +
145 + /**
146 + * Add our self-hosted description to the filter
147 + *
148 + * @param boolean $false
149 + * @param array $action
150 + * @param object $arg
151 + * @return bool|object
152 + */
153 + public function check_info($obj, $action, $arg)
154 + {
155 + if (($action=='query_plugins' || $action=='plugin_information') &&
156 + isset($arg->slug) && $arg->slug === $this->slug) {
157 + return $this->getRemote('info');
158 + }
159 +
160 + return $obj;
161 + }
162 +
163 + /**
164 + * Return the remote version
165 + *
166 + * @return string $remote_version
167 + */
168 + public function getRemote($action = '')
169 + {
170 + $qcld_update_plugin = get_openaiaddon_update_transient();
171 +
172 +
173 +
174 + $params = array(
175 + 'body' => array(
176 + 'action' => $action,
177 + 'plugin-slug' => $this->slug,
178 + 'license_user' => $this->license_user,
179 + 'license_key' => $this->license_key,
180 + ),
181 + );
182 +
183 + // Make the POST request
184 + $request = wp_remote_post($this->update_path, $params );
185 + // Check if response is valid
186 +
187 + if ( !is_wp_error( $request ) || wp_remote_retrieve_response_code( $request ) === 200 ) {
188 +
189 + return @unserialize( $request['body'] );
190 + }
191 +
192 +
193 + return false;
194 + }
196 195 }