Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect on theme activation is not allowed #61

Open
carolinan opened this issue Sep 28, 2021 · 1 comment
Open

Redirect on theme activation is not allowed #61

carolinan opened this issue Sep 28, 2021 · 1 comment

Comments

@carolinan
Copy link
Contributor

carolinan commented Sep 28, 2021

Redirecting the user away from the theme screen when a theme is activated is not allowed.

There are two ways to redirect on activation that are more common:

global $pagenow;

if (is_admin() && 'themes.php' == $pagenow && isset($_GET['activated'])) {
    $theme_info = wp_get_theme();
    $theme_name = $theme_info->get( 'Name' );
    if($theme_name =='THEME NAME'){
        wp_redirect(admin_url("themes.php?page=prefix_activation")); // Your admin page URL
    }
}
function prefix_after_switch_theme(){
    wp_redirect('admin.php?page=prefix-panel');
}

add_action( 'after_switch_theme', 'prefix_after_switch_theme' );

Note that neither wp_redirect or after_switch_theme on their own cause any problems.
This makes it difficult to test this requirement with a static code check.

A test could be set up to check if there is a redirect after theme activation.

@StevenDufresne
Copy link
Contributor

Can I get more information on how this is being abused? Maybe an example theme or some documentation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants