Skip to content

Instantly share code, notes, and snippets.

@davemac
Created June 12, 2017 03:12
Show Gist options
  • Save davemac/69ead9072bc84e95a52aab5c4e1d70a6 to your computer and use it in GitHub Desktop.
Save davemac/69ead9072bc84e95a52aab5c4e1d70a6 to your computer and use it in GitHub Desktop.
// 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