PluginProbe
Polylang / 2.6.2
Polylang v2.6.2
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | include/license.php +2 -126 2.7.22.6.2 View file →
@@ -131,16 +131,10 @@
131 131 * @param string $request check_license | activate_license | deactivate_license
132 132 */
133 133 private function api_request( $request ) {
134 134 $licenses = get_option( 'polylang_licenses' );
135 + unset( $licenses[ $this->id ], $this->license_data );
135 136
136 - if ( is_array( $licenses ) ) {
137 - unset( $licenses[ $this->id ] );
138 - } else {
139 - $licenses = array();
140 - }
141 - unset( $this->license_data );
142 -
143 137 if ( ! empty( $this->license_key ) ) {
144 138 // Data to send in our API request
145 139 $api_params = array(
146 140 'edd_action' => $request,
@@ -152,9 +146,9 @@
152 146 // Call the API
153 147 $response = wp_remote_post(
154 148 $this->api_url,
155 149 array(
156 - 'timeout' => 3,
150 + 'timeout' => 15,
157 151 'sslverify' => false,
158 152 'body' => $api_params,
159 153 )
160 154 );
@@ -173,124 +167,6 @@
173 167 }
174 168 }
175 169
176 170 update_option( 'polylang_licenses', $licenses ); // FIXME called multiple times when saving all licenses
177 - }
178 -
179 - /**
180 - * Get the html form field in a table row (one per license key) for display
181 - *
182 - * @since 2.7
183 - *
184 - * @return string
185 - */
186 - public function get_form_field() {
187 - if ( ! empty( $this->license_data ) ) {
188 - $license = $this->license_data;
189 - }
190 -
191 - $class = 'license-null';
192 -
193 - $out = sprintf(
194 - '<td><label for="pll-licenses[%1$s]">%2$s</label></td>' .
195 - '<td><input name="licenses[%1$s]" id="pll-licenses[%1$s]" type="text" value="%3$s" class="regular-text code" />',
196 - esc_attr( $this->id ),
197 - esc_attr( $this->name ),
198 - esc_html( $this->license_key )
199 - );
200 -
201 - if ( ! empty( $license ) && is_object( $license ) ) {
202 - $now = time();
203 - $expiration = isset( $license->expires ) ? strtotime( $license->expires ) : false;
204 -
205 - // Special case: the license expired after the last check
206 - if ( $license->success && $expiration && $expiration < $now ) {
207 - $license->success = false;
208 - $license->error = 'expired';
209 - }
210 -
211 - if ( false === $license->success ) {
212 - $class = 'notice-error notice-alt';
213 -
214 - switch ( $license->error ) {
215 - case 'expired':
216 - $message = sprintf(
217 - /* translators: %1$s is a date, %2$s is link start tag, %3$s is link end tag. */
218 - esc_html__( 'Your license key expired on %1$s. Please %2$srenew your license key%3$s.', 'polylang' ),
219 - esc_html( date_i18n( get_option( 'date_format' ), $expiration ) ),
220 - sprintf( '<a href="%s" target="_blank">', esc_url( 'https://polylang.pro/checkout/?edd_license_key=' . $this->license_key ) ),
221 - '</a>'
222 - );
223 - break;
224 -
225 - case 'disabled':
226 - case 'revoked':
227 - $message = esc_html__( 'Your license key has been disabled.', 'polylang' );
228 - break;
229 -
230 - case 'missing':
231 - $message = sprintf(
232 - /* translators: %1$s is link start tag, %2$s is link end tag. */
233 - esc_html__( 'Invalid license. Please %1$svisit your account page%2$s and verify it.', 'polylang' ),
234 - sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/account' ),
235 - '</a>'
236 - );
237 - break;
238 -
239 - case 'invalid':
240 - case 'site_inactive':
241 - $message = sprintf(
242 - /* translators: %1$s is a product name, %2$s is link start tag, %3$s is link end tag. */
243 - esc_html__( 'Your %1$s license key is not active for this URL. Please %2$svisit your account page%3$s to manage your license key URLs.', 'polylang' ),
244 - esc_html( $this->name ),
245 - sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/account' ),
246 - '</a>'
247 - );
248 - break;
249 -
250 - case 'item_name_mismatch':
251 - /* translators: %s is a product name */
252 - $message = sprintf( esc_html__( 'This is not a %s license key.', 'polylang' ), esc_html( $this->name ) );
253 - break;
254 -
255 - case 'no_activations_left':
256 - $message = sprintf(
257 - /* translators: %1$s is link start tag, %2$s is link end tag */
258 - esc_html__( 'Your license key has reached its activation limit. %1$sView possible upgrades%2$s now.', 'polylang' ),
259 - sprintf( '<a href="%s" target="_blank">', 'https://polylang.pro/account' ),
260 - '</a>'
261 - );
262 - break;
263 - }
264 - } else {
265 - $class = 'license-valid';
266 -
267 - $out .= sprintf( '<button id="deactivate_%s" type="button" class="button button-secondary pll-deactivate-license">%s</button>', esc_attr( $this->id ), esc_html__( 'Deactivate', 'polylang' ) );
268 -
269 - if ( 'lifetime' === $license->expires ) {
270 - $message = esc_html__( 'The license key never expires.', 'polylang' );
271 - } elseif ( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) {
272 - $class = 'notice-warning notice-alt';
273 - $message = sprintf(
274 - /* translators: %1$s is a date, %2$s is link start tag, %3$s is link end tag. */
275 - esc_html__( 'Your license key will expire soon! Precisely, it will expire on %1$s. %2$sRenew your license key today!%3$s.', 'polylang' ),
276 - esc_html( date_i18n( get_option( 'date_format' ), $expiration ) ),
277 - sprintf( '<a href="%s" target="_blank">', esc_url( 'https://polylang.pro/checkout/?edd_license_key=' . $this->license_key ) ),
278 - '</a>'
279 - );
280 - } else {
281 - $message = sprintf(
282 - /* translators: %s is a date */
283 - esc_html__( 'Your license key expires on %s.', 'polylang' ),
284 - esc_html( date_i18n( get_option( 'date_format' ), $expiration ) )
285 - );
286 - }
287 - }
288 - }
289 -
290 - if ( ! empty( $message ) ) {
291 - $out .= '<p>' . $message . '</p>';
292 - }
293 -
294 - return sprintf( '<tr id="pll-license-%s" class="%s">%s</tr>', esc_attr( $this->id ), $class, $out );
295 171 }
296 172 }