Created
January 17, 2020 02:54
-
-
Save ipokkel/2d22e1bc0dcc949db5ac171d4e147f02 to your computer and use it in GitHub Desktop.
Rebuilds key values for array $pmpro_pages if empty in a multisite network.
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 | |
/** | |
* pmpro_multisite_membership_pmpro_pages | |
* | |
* Rebuilds key values if empty in a multisite network | |
* | |
* @requires Multisite Membership Add On [pmpro-network-subsites] | |
* | |
* @return array global $pmpro_pages | |
*/ | |
function pmpro_multisite_membership_pmpro_pages() { | |
if ( ! function_exists( 'pmpro_multisite_membership_init' ) || ! is_multisite() ) { | |
return; | |
} | |
global $pmpro_pages; | |
$primary_network_site = get_current_site(); | |
foreach ( $pmpro_pages as $pmpro_page => $pmpro_page_id ) { | |
if ( ! $pmpro_page_id || empty( $pmpro_page_id ) ) { | |
$pmpro_pages[ $pmpro_page ] = get_blog_option( $primary_network_site->blog_id, 'pmpro_' . $pmpro_page . '_page_id' ); | |
} | |
} | |
} | |
add_action( 'init', 'pmpro_multisite_membership_pmpro_pages' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment