Created
June 12, 2017 03:12
-
-
Save davemac/69ead9072bc84e95a52aab5c4e1d70a6 to your computer and use it in GitHub Desktop.
Preloading Advanced Custom Fields Pro license key https://anchor.host/2017/05/16/preloading-advanced-custom-fields-pro-license-key/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Preload ACF key from wp-config.php into database | |
function anchor_acf_auto_set_license_keys() { | |
// Check if ACF is running and ACF Pro key found in wp-config.php | |
if ( class_exists('acf') && defined('ACF_PRO_KEY') ) { | |
$save = array( | |
'key' => ACF_PRO_KEY, | |
'url' => home_url() | |
); | |
$save = maybe_serialize($save); | |
$save = base64_encode($save); | |
update_option('acf_pro_license', $save); | |
} | |
} | |
// Runs 'Preload ACF key' if WP-CLI runs a search-replace | |
if ( defined( 'WP_CLI' ) && WP_CLI ) { | |
WP_CLI::add_hook( 'after_invoke:search-replace', 'anchor_acf_auto_set_license_keys' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment