roles ) ) { $block = true; } else { $block = false; } $block = apply_filters( 'pmpro_block_dashboard', $block ); /** * Allow filtering whether to block Dashboard access. * * @param bool $block Whether to block Dashboard access. */ return apply_filters( 'pmpro_block_dashboard', $block ); } /** * Initialize our Site Health integration and add hooks. * * @since 2.6.2 */ function pmpro_init_site_health_integration() { $site_health = PMPro_Site_Health::init(); $site_health->hook(); } add_action( 'admin_init', 'pmpro_init_site_health_integration' ); /** * Compare stored and current site URL and decide if we should go into pause mode * * @since 2.10 */ function pmpro_site_url_check() { if ( pmpro_is_paused() ) { //We are paused, show a notice. add_action( 'admin_notices', 'pmpro_pause_mode_notice' ); } } add_action( 'admin_init', 'pmpro_site_url_check' ); /** * Allows a user to deactivate pause mode and update the last known URL * * @since 2.10 */ function pmpro_handle_pause_mode_actions() { // Can the current user view the dashboard? if ( current_user_can( 'pmpro_manage_pause_mode' ) ) { //We're attempting to reactivate all services. if( ! empty( $_REQUEST['pmpro-reactivate-services'] ) ) { delete_option( 'pmpro_last_known_url' ); } } } add_action( 'admin_init', 'pmpro_handle_pause_mode_actions' ); /** * Display a notice about pause mode being enabled * * @since 2.10 */ function pmpro_pause_mode_notice() { global $current_user; if ( isset( $_REQUEST[ 'show_pause_notification' ] ) ) { $pmpro_show_pause_notification = (bool)$_REQUEST['show_pause_notification']; } else { $pmpro_show_pause_notification = false; } // Remove notice from dismissed user meta if URL parameter is set. $archived_notifications = get_user_meta( $current_user->ID, 'pmpro_archived_notifications', true ); if ( ! is_array( $archived_notifications ) ) { $archived_notifications = array(); } if ( array_key_exists( 'hide_pause_notification', $archived_notifications ) ) { $show_notice = false; if ( ! empty( $pmpro_show_pause_notification ) ) { unset( $archived_notifications['hide_pause_notification'] ); update_user_meta( $current_user->ID, 'pmpro_archived_notifications', $archived_notifications ); $show_notice = true; } } else { $show_notice = true; } if ( pmpro_is_paused() && ! empty( $show_notice ) ) { // Site is paused. Show the notice. ?>

Warning: We have detected that your site URL has changed. All PMPro-related cron jobs and automated services have been disabled. Paid Memberships Pro considers %s to be the site URL.', 'paid-memberships-pro' ), '' . esc_url( get_option( 'pmpro_last_known_url' ) ) . '' ) ); ?>

' class='button button-secondary'>

pmpro_manage_pause_mode capability are able to deactivate pause mode.', 'paid-memberships-pro' ) ); ?>

ID, 'pmpro_archived_notifications', true ); // If the user hasn't dismissed the notice, show it. if ( ! is_array( $archived_notifications ) || ! array_key_exists( 'hide_spamprotection_notification', $archived_notifications ) ) { ?>

' class='button button-secondary'>

Valid License', 'paid-memberships-pro' ), esc_url( add_query_arg( array( 'page' => 'pmpro-license' ), admin_url( 'admin.php' ) ) ) ) ); ?> No License', 'paid-memberships-pro' ), esc_url( add_query_arg( array( 'page' => 'pmpro-license' ), admin_url( 'admin.php' ) ) ) ) ); ?>
rate us %2$s on WordPress.org to help others find %3$s. Thank you from the %4$s team!', 'paid-memberships-pro' ), [ 'a' => [ 'href' => [], 'target' => [], 'rel' => [], ], 'p' => [ 'class' => [], ], ] ), 'https://wordpress.org/support/plugin/paid-memberships-pro/reviews/?filter=5#new-post', '★★★★★', 'Paid Memberships Pro', 'PMPro' ); } add_filter( 'admin_footer_text', 'pmpro_admin_footer_text' ); /** * Hide non-PMPro notices from PMPro dashboard pages. * @since 3.0 */ function pmpro_hide_non_pmpro_notices() { global $wp_filter; // Make sure we're on a PMPro page. if ( ! isset( $_REQUEST['page'] ) || substr( sanitize_text_field( $_REQUEST['page'] ), 0, 6 ) !== 'pmpro-' ) { return; } // Handle notices added through these hooks. $hooks = ['admin_notices', 'all_admin_notices']; foreach ($hooks as $hook) { // If no callbacks are registered, skip. if ( ! isset( $wp_filter[$hook] ) ) { continue; } // Loop through the callbacks and remove any that aren't PMPro. foreach ($wp_filter[$hook]->callbacks as $priority => $callbacks) { foreach ($callbacks as $key => $callback) { if ( is_string( $callback['function' ] ) ) { // Check the function name. // Ex. add_action( 'admin_notices', 'pmpro_admin_notice' ); $name_to_check = $callback['function']; } elseif ( is_array( $callback['function' ] ) && is_string( $callback['function'][0] ) ) { // Check the class name for the static method. // Ex. add_action( 'admin_notices', array( 'PMPro_Admin', 'admin_notice' ) ); $name_to_check = $callback['function'][0]; } elseif ( is_array( $callback['function' ] ) && is_object( $callback['function'][0] ) ) { // Check the class name for the non-static method. // Ex. add_action( 'admin_notices', array( $some_object, 'admin_notice' ) ); $name_to_check = get_class( $callback['function'][0] ); } else { // Ex. add_action( 'admin_notices', function() { echo 'Hello World'; } ); // We don't use closures in PMPro, so we don't need to check for them. $name_to_check = ''; } // Trim slashes for namespaces and lowercase the name. $name_to_check = strtolower( trim( $name_to_check, '\\' ) ); // If the function name starts with 'pmpro', then we don't want to remove it. // Not checking for 'pmpro_' because we have class names like PMProGateway_stripe and want to keep notices from add ons. if ( strpos( $name_to_check, 'pmpro' ) !== 0 ) { unset( $wp_filter[$hook]->callbacks[$priority][$key] ); } } } } } add_action( 'in_admin_header', 'pmpro_hide_non_pmpro_notices' );