acf_pro_display_activation_error()ACF 5.11.0

Display the stored activation error

Хуков нет.

Возвращает

null. Ничего (null).

Использование

acf_pro_display_activation_error( $screen );
$screen(обязательный)
.

Список изменений

С версии 5.11.0 Введена.

Код acf_pro_display_activation_error() ACF 6.4.2

function acf_pro_display_activation_error( $screen ) {
	// Return if we're not in admin, or are doing an AJAX request.
	if ( ! is_admin() || acf_is_ajax() ) {
		return;
	}

	// Return if the current user cannot view ACF settings.
	if ( ! acf_current_user_can_admin() ) {
		return;
	}

	// Check if the transient exists.
	$activation_data = acf_pro_get_activation_failure_transient();

	// Return if the transient does not exist.
	if ( ! $activation_data ) {
		return;
	}

	// Return if on an ACF admin screen - we handle those notices differently.
	if ( acf_is_acf_admin_screen() ) {
		return;
	}

	// Check if the license key is defined. If not, delete the transient.
	if ( ! defined( 'ACF_PRO_LICENSE' ) || empty( ACF_PRO_LICENSE ) || ! is_string( ACF_PRO_LICENSE ) ) {
		acf_pro_delete_license_transient( 'acf_activation_error' );
		return;
	}

	// Prepend ACF PRO for context since we're not in an ACF PRO admin screen.
	$activation_data['error'] = __( '<strong>ACF PRO &mdash;</strong>', 'acf' ) . ' ' . $activation_data['error'];

	// Append a retry link if we don't already have a link from upstream.
	if ( strpos( $activation_data['error'], 'http' ) === false ) {
		$nonce           = wp_create_nonce( 'acf_retry_activation' );
		$check_again_url = 'edit.php?post_type=acf-field-group';
		if ( acf_pro_is_updates_page_visible() ) {
			$check_again_url .= '&page=acf-settings-updates';
		}
		$activation_data['error'] = $activation_data['error'] . ' <a href="' . admin_url( $check_again_url . '&acf_retry_nonce=' . $nonce ) . '">' . __( 'Check again', 'acf' ) . '</a>';
	}

	// Add a non-dismissible error message with the activation error.
	acf_add_admin_notice( acf_esc_html( $activation_data['error'] ), 'error', false );
}