Skip to content

Instantly share code, notes, and snippets.

@wpscholar
Last active October 31, 2022 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpscholar/c65523da12007c55962743bbd8eea1d9 to your computer and use it in GitHub Desktop.
Save wpscholar/c65523da12007c55962743bbd8eea1d9 to your computer and use it in GitHub Desktop.
An add-on plugin for the "Simple Website Redirect" plugin that prevents redirects from happening on the homepage.
<?php
/**
* Simple Website Redirect - Not Homepage
*
* @package SimpleWebsiteRedirectNotHomepage
* @author Micah Wood
* @copyright Copyright 2022 by Micah Wood - All rights reserved.
* @license GPL2.0-or-later
*
* @wordpress-plugin
* Plugin Name: Simple Website Redirect - Not Homepage
* Plugin URI: https://gist.github.com/wpscholar/c65523da12007c55962743bbd8eea1d9
* Description: An add-on plugin for the "Simple Website Redirect" plugin that prevents redirects from happening on the homepage.
* Version: 1.0
* Requires PHP: 5.4
* Requires at least: 4.0
* Author: Micah Wood
* Author URI: https://wpscholar.com
* Text Domain: simple-website-redirect-not-homepage
* Domain Path: /languages
* License: GPL V2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
add_filter(
'simple_website_redirect_should_redirect',
function ( $should_redirect, wpscholar\Url $url ) {
if ( $url->path === '/' && $url->query === '' ) {
$should_redirect = false;
}
return $should_redirect;
},
10,
2
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment