Skip to content

Instantly share code, notes, and snippets.

@wpmudev-sls
Last active February 22, 2024 08:18
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 wpmudev-sls/1319eef0328cc1416f03433bbe1c47ba to your computer and use it in GitHub Desktop.
Save wpmudev-sls/1319eef0328cc1416f03433bbe1c47ba to your computer and use it in GitHub Desktop.
[Branda Pro] - Exclude hub pages from the website(maintenance) mode
<?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