lightspeedwp / lsx

LSX is an flexible, light-weight, minimalistic and responsive theme designed to empower makers to build beautifully rich websites with WordPress block editor. The theme displays perfectly on all desktop & mobile devices.
https://lsdev.biz/lsx/
GNU General Public License v3.0
34 stars 3 forks source link

Redirecting Sensei archive #167

Closed justintadlock closed 7 years ago

justintadlock commented 7 years ago

This code in inc/sensei.php probably doesn't belong in the theme:

function lsx_sensei_redirect_to_home( $query ){
    if ( ! is_admin() && is_post_type_archive( 'lesson' ) && $query->is_main_query() ) {
        wp_redirect( home_url() . '/courses-overview' );
        exit;
    }
}
add_action( 'parse_query', 'lsx_sensei_redirect_to_home' );

There's a few issues here, so I'll just cover them one at a time.

home_url()

First, wrap this in esc_url_raw() for redirects.

Correct use of home_url()

It should look like home_url( 'courses-overview' ).

Correct URL?

Is it OK to assume that sitehome/courses-overview is the absolute correct URL? I haven't tested Sensei, but I'd assume that any permalink could be very different.

Redirecting

Generally speaking, themes should not be redirecting anything. That's something best left to core and plugins.

ashleyshaw commented 7 years ago

@justintadlock our plan was to make the LSX theme compatible with the Woo Sensei LMS plugin, how would you add support to the theme if you didn't add the include file? Thx

justintadlock commented 7 years ago

I think there's a misunderstanding. I'm talking about redirecting the archive, not including the file.

nandotess commented 7 years ago

Resolved on LSX 2.0.0 branch.