Disable activation page when switching themes

Is there a cleaner way to disable activation theme page when switching out themes?

Is there a way to do it with say, function in custom.php?

Right now I edit out and replace it everytime I setup it up for clients (since I already define Roots as default theme in wp-config).

Any advise is welcomed and appreciated.

1 Like

I ran into the same thing recently. I did the following but I have to do it at the start of every project (only two since I did it though!):

First, in wp-config.php I added a new constant:

Then in /roots/lib/activation.php I added a little check:

if (is_admin() && isset($_GET['activated']) && 'themes.php' == $GLOBALS['pagenow']) {
    if ( ROOTS_ACTIVATION || !defined('ROOTS_ACTIVATION') ){
     } else{

Not sure if this is the best way to do it but it’s working for me. I’d love to not set it every time. @ben any interest in something like this? Happy to fork and PR if so.

1 Like

Definitely useful - please make a PR

Thanks, this is a really good idea.

Three quick points:

1 . The order you check the conditions needs to be reversed i.e. check that the definition does not exist before checking if it’s true.
2. Can you also double check if you need the else statement if you move the exit immediately following the redirect. There’s no point in a redirect to themes if it’s going there anyway.
3. Finally, the white space needs fixing to match the rest of Roots.

hey @willthemoor

Oh wow that’s gonna save some of us a lot of manual work! Thanks for sharing this!

@Foxaii Good stuff. Working on it now. Should I document in the source the what/how of adding a constant to wp-config.php?

Done. https://github.com/roots/roots/pull/950


1 Like