Skip to content

Instantly share code, notes, and snippets.

@mustafauysal
Last active May 7, 2021 22:01
Show Gist options
  • Save mustafauysal/2487dc1ff3eceff2804e to your computer and use it in GitHub Desktop.
Save mustafauysal/2487dc1ff3eceff2804e to your computer and use it in GitHub Desktop.
Update site info and activate plugins that I only need local
<?php
if ( defined( 'WP_LOCAL_DEV' ) && WP_LOCAL_DEV ) {
update_option('siteurl','http://local.example.dev');
update_option('home','http://local.example.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;
}
activate_local_plugin('uploads-by-proxy/uploads-by-proxy.php');
}
@qant
Copy link

qant commented May 6, 2021

i wonder why so many trim()?

@mustafauysal
Copy link
Author

@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