PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.3
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.3
6.3 6.2.3 6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 All 157 releases
← All changes | class/class-mainwp-api-manager.php +9 -19 6.2 → 6.3 View file →
@@ -337,15 +337,16 @@
337 337 'software_slug' => $api_slug,
338 338 );
339 339
340 340 $activate_results = MainWP_Api_Manager_Key::instance()->activate( $args );
341 - if ( ! empty( $activate_results ) ) {
342 - $activate_results = json_decode( $activate_results, true );
343 - } else {
344 - $activate_results = array();
341 + $activate_results = is_string( $activate_results ) && '' !== $activate_results ? json_decode( $activate_results, true ) : false;
342 + if ( ! is_array( $activate_results ) ) {
343 + // Keep the stored key and status, so submitting the same key again goes straight back to activation.
344 + $activate_results = false;
345 + $return['error'] = esc_html__( 'Connection failed to the License Key API server. Try again later.', 'mainwp' );
345 346 }
346 347
347 - if ( true === $activate_results['activated'] ) {
348 + if ( is_array( $activate_results ) && isset( $activate_results['activated'] ) && true === $activate_results['activated'] ) {
348 349 $return['result'] = 'SUCCESS';
349 350 $mess = isset( $activate_results['message'] ) ? $activate_results['message'] : '';
350 351 $return['message'] = esc_html__( 'The extension has been activated. ', 'mainwp' ) . $mess;
351 352 $options['api_key'] = $api_key;
@@ -354,20 +355,8 @@
354 355 $options['mainwp_version'] = MainWP_System::instance()->get_dashboard_version();
355 356 MainWP_Utility::instance()->get_set_deactivated_licenses_alerted( $api_slug, 0, 'set' ); // so next time deactived it will alerted.
356 357 }
357 358
358 - if ( false === $activate_results ) {
359 - $apisslverify = get_option( 'mainwp_api_sslVerifyCertificate' );
360 - if ( 1 === $apisslverify ) {
361 - MainWP_Utility::update_option( 'mainwp_api_sslVerifyCertificate', 0 );
362 - $return['retry_action'] = 1;
363 - } else {
364 - $return['error'] = esc_html__( 'Connection failed to the License Key API server. Try again later.', 'mainwp' );
365 - }
366 - $options['api_key'] = '';
367 - $options['activated_key'] = 'Deactivated';
368 - }
369 -
370 359 $error = $this->check_response_for_api_errors( $activate_results );
371 360 if ( ! empty( $error ) ) {
372 361 $return['error'] = $error;
373 362 }
@@ -377,10 +366,11 @@
377 366 // The license slot was already consumed at mainwp.com; without the
378 367 // local persist the dashboard will offer to re-activate and burn a
379 368 // second slot. The encrypt filter only fails on broken installs
380 369 // (missing keyfile, un-writable uploads/mainwp/pk/), but when it
381 - // does the operator needs to know.
382 - if ( false === $this->set_activation_info( $api_slug, $options ) ) {
370 + // does the operator needs to know. A failed or refused activation keeps
371 + // its own error: nothing was activated upstream.
372 + if ( false === $this->set_activation_info( $api_slug, $options ) && isset( $return['result'] ) ) {
383 373 $return['error'] = esc_html__( 'License activated upstream but local state could not be saved. Check uploads/mainwp/pk/ permissions and try the activation again.', 'mainwp' );
384 374 }
385 375
386 376 return $return;