plugin install
This commit is contained in:
@@ -182,7 +182,7 @@ function acf_pro_check_defined_license() {
|
||||
* Get translated upstream message
|
||||
*
|
||||
* @since 6.2.3
|
||||
* @param string $text server side message string.
|
||||
* @param string $text Server side message string.
|
||||
*
|
||||
* @return string a translated (or original, if unavailable), message string.
|
||||
*/
|
||||
@@ -250,14 +250,16 @@ function acf_pro_get_translated_connect_message( $text ) {
|
||||
$text .= ' ' . sprintf( __( '%1$s or %2$s.', 'acf' ), $view_license, $check_again );
|
||||
|
||||
return $text;
|
||||
} elseif ( strpos( $text, 'upstream API error' ) !== false ) {
|
||||
return __( 'An upstream API error occurred when checking your ACF PRO license status. We will retry again shortly.', 'acf' );
|
||||
} elseif ( strpos( $text, 'scheduled maintenance' ) !== false ) {
|
||||
return __( 'The ACF activation server is temporarily unavailable for scheduled maintenance. Please try again later.', 'acf' );
|
||||
return __( 'The ACF activation service is temporarily unavailable for scheduled maintenance. Please try again later.', 'acf' );
|
||||
} elseif ( strpos( $text, 'Something went wrong' ) !== false ) {
|
||||
return __( 'The ACF activation server is temporarily unavailable. Please try again later.', 'acf' );
|
||||
return __( 'The ACF activation service is temporarily unavailable. Please try again later.', 'acf' );
|
||||
}
|
||||
|
||||
/* translators: %s an untranslatable internal upstream error message */
|
||||
return sprintf( __( 'An unknown error occurred while trying to validate your license: %s.', 'acf' ), $text );
|
||||
return sprintf( __( 'An unknown error occurred while trying to communicate with the ACF activation service: %s.', 'acf' ), $text );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -546,7 +548,7 @@ function acf_pro_activate_license( $license_key, $silent = false, $automatic = f
|
||||
acf_pro_remove_license_status();
|
||||
|
||||
$response = acf_updates()->request( $activation_url, $post );
|
||||
$expiration = acf_updates()->get_expiration( $response, DAY_IN_SECONDS, MONTH_IN_SECONDS );
|
||||
$expiration = acf_updates()->get_expiration( $response, DAY_IN_SECONDS );
|
||||
|
||||
// Check response is expected JSON array (not string).
|
||||
if ( is_string( $response ) ) {
|
||||
@@ -722,40 +724,44 @@ function acf_pro_get_license_status( $force_check = false ) {
|
||||
|
||||
// Call the API if necessary, if we have a license.
|
||||
if ( ( empty( $status ) || $force_check || time() > $next_check ) && $license ) {
|
||||
$post = array(
|
||||
'acf_license' => $license,
|
||||
'wp_url' => acf_pro_get_home_url(),
|
||||
);
|
||||
if ( ! get_transient( 'acf_pro_validating_license' ) || $force_check ) {
|
||||
set_transient( 'acf_pro_validating_license', true, 15 * MINUTE_IN_SECONDS );
|
||||
|
||||
$response = acf_updates()->request( 'v2/plugins/validate?p=pro', $post );
|
||||
$expiration = acf_updates()->get_expiration( $response, DAY_IN_SECONDS, MONTH_IN_SECONDS );
|
||||
$post = array(
|
||||
'acf_license' => $license,
|
||||
'wp_url' => acf_pro_get_home_url(),
|
||||
);
|
||||
|
||||
if ( is_array( $response ) ) {
|
||||
if ( ! empty( $response['license_status'] ) ) {
|
||||
$status = $response['license_status'];
|
||||
}
|
||||
$response = acf_updates()->request( 'v2/plugins/validate?p=pro', $post );
|
||||
$expiration = acf_updates()->get_expiration( $response );
|
||||
|
||||
// Handle errors from connect.
|
||||
if ( ! empty( $response['code'] ) && 'activation_not_found' === $response['code'] ) {
|
||||
|
||||
// If our activation is no longer found and the user has a defined license, deactivate the license and let the automatic reactivation attempt happen.
|
||||
if ( defined( 'ACF_PRO_LICENSE' ) ) {
|
||||
acf_pro_update_license( '' );
|
||||
acf_pro_check_defined_license();
|
||||
} else {
|
||||
$status['error_msg'] = sprintf(
|
||||
/* translators: %s - URL to ACF updates page */
|
||||
__( 'Your license key is valid but not activated on this site. Please <a href="%s">deactivate</a> and then reactivate the license.', 'acf' ),
|
||||
esc_url( admin_url( 'edit.php?post_type=acf-field-group&page=acf-settings-updates#deactivate-license' ) )
|
||||
);
|
||||
if ( is_array( $response ) ) {
|
||||
if ( ! empty( $response['license_status'] ) ) {
|
||||
$status = $response['license_status'];
|
||||
}
|
||||
} elseif ( ! empty( $response['message'] ) ) {
|
||||
$status['error_msg'] = acf_esc_html( $response['message'] );
|
||||
}
|
||||
}
|
||||
|
||||
$status['next_check'] = time() + $expiration;
|
||||
acf_pro_update_license_status( $status );
|
||||
// Handle errors from connect.
|
||||
if ( ! empty( $response['code'] ) && 'activation_not_found' === $response['code'] ) {
|
||||
|
||||
// If our activation is no longer found and the user has a defined license, deactivate the license and let the automatic reactivation attempt happen.
|
||||
if ( defined( 'ACF_PRO_LICENSE' ) ) {
|
||||
acf_pro_update_license( '' );
|
||||
acf_pro_check_defined_license();
|
||||
} else {
|
||||
$status['error_msg'] = sprintf(
|
||||
/* translators: %s - URL to ACF updates page */
|
||||
__( 'Your license key is valid but not activated on this site. Please <a href="%s">deactivate</a> and then reactivate the license.', 'acf' ),
|
||||
esc_url( admin_url( 'edit.php?post_type=acf-field-group&page=acf-settings-updates#deactivate-license' ) )
|
||||
);
|
||||
}
|
||||
} elseif ( ! empty( $response['message'] ) ) {
|
||||
$status['error_msg'] = acf_esc_html( acf_pro_get_translated_connect_message( $response['message'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
$status['next_check'] = time() + $expiration;
|
||||
acf_pro_update_license_status( $status );
|
||||
}
|
||||
}
|
||||
|
||||
$status = acf_pro_parse_license_status( $status );
|
||||
|
||||
Reference in New Issue
Block a user