Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Update site info and activate plugins that I only need local
if ( defined( 'WP_LOCAL_DEV' ) && WP_LOCAL_DEV ) {
function activate_local_plugin( $plugin ) {
$current = get_option( 'active_plugins' );
$plugin = plugin_basename( trim( $plugin ) );
if ( !in_array( $plugin, $current ) ) {
$current[] = $plugin;
sort( $current );
do_action( 'activate_plugin', trim( $plugin ) );
update_option( 'active_plugins', $current );
do_action( 'activate_' . trim( $plugin ) );
do_action( 'activated_plugin', trim( $plugin) );
return null;

This comment has been minimized.

Copy link

@qant qant commented May 6, 2021

i wonder why so many trim()?


This comment has been minimized.

Copy link
Owner Author

@mustafauysal mustafauysal commented May 7, 2021

@qant It seems like a rookie mistake, and absolutely no making sense at all. Btw I'm wondering, how did you found a secret gist from 2014? 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment