acf_pro_activate_license()
Activates the submitted license key Formally ACF_Admin_Updates::activate_pro_licence since 5.0.0
Хуков нет.
Возвращает
Разное
. $response A wp-error instance, or an array with a boolean success key, and string message key
Использование
acf_pro_activate_license( $license_key, $silent );
- $license_key(строка) (обязательный)
- License key to activate
- $silent(true|false)
- Return errors rather than displaying them
По умолчанию: false
Список изменений
С версии 5.11.0 | Введена. |
Код acf_pro_activate_license() acf pro activate license ACF 6.0.4
function acf_pro_activate_license( $license_key, $silent = false ) { // Connect to API. $post = array( 'acf_license' => trim( $license_key ), 'acf_version' => acf_get_setting( 'version' ), 'wp_name' => get_bloginfo( 'name' ), 'wp_url' => acf_get_home_url(), 'wp_version' => get_bloginfo( 'version' ), 'wp_language' => get_bloginfo( 'language' ), 'wp_timezone' => get_option( 'timezone_string' ), 'php_version' => PHP_VERSION, 'block_count' => acf_pro_get_registered_block_count(), ); $response = acf_updates()->request( 'v2/plugins/activate?p=pro', $post ); // Check response is expected JSON array (not string). if ( is_string( $response ) ) { $response = new WP_Error( 'server_error', esc_html( $response ) ); } // Display error. if ( is_wp_error( $response ) ) { if ( ! $silent ) { display_wp_activation_error( $response ); } return $response; } $success = false; // On success. if ( $response['status'] == 1 ) { // Update license. acf_pro_update_license( $response['license'] ); // Refresh plugins transient to fetch new update data. acf_updates()->refresh_plugins_transient(); // Show notice. if ( ! $silent ) { acf_add_admin_notice( acf_esc_html( $response['message'] ), 'success' ); } $success = true; // On failure. } else { // Show notice. if ( ! $silent ) { acf_add_admin_notice( acf_esc_html( $response['message'] ), 'warning' ); } } // Return status array for automated activation error notices return array( 'success' => $success, 'message' => $response['message'], ); }