Last active
February 22, 2024 08:18
-
-
Save wpmudev-sls/1319eef0328cc1416f03433bbe1c47ba to your computer and use it in GitHub Desktop.
[Branda Pro] - Exclude hub pages from the website(maintenance) mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: [Branda Pro] Exclude hub pages from website mode | |
* Description: Exclude hub pages from website mode. | |
* Author: Prashant @ WPMUDEV | |
* Task: SLS-5779 | |
* Author URI: https://premium.wpmudev.org | |
* License: GPLv2 or later | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; // Exit if accessed directly. | |
} | |
add_filter( 'ub_get_value', function( $data, $module, $section, $name ) { | |
if ( is_admin() ) { | |
return $data; | |
} | |
if ( 'maintenance' !== $module && 'mode' !== $section ) { | |
return $data; | |
} | |
$auto_front_page = get_site_option( 'wpmudev_hub_auto_front_page', array() ); | |
$auto_front_page = is_array( $auto_front_page ) ? $auto_front_page : array(); | |
if ( ! empty( $auto_front_page['page_id'] ) ) { | |
$target_page = $auto_front_page['page_id']; | |
if ( $target_page == get_the_ID() ) { | |
return 'off'; | |
} | |
} | |
return $data; | |
}, 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment