Skip to content

Commit

Permalink
Merge pull request #3042 from kimcoleman/detect-frontend-css-local-no…
Browse files Browse the repository at this point in the history
…tice

Adding notice if we detect a custom frontend.css loaded via theme files
  • Loading branch information
kimcoleman authored Jul 5, 2024
2 parents 3156b6b + a6f40ca commit 1acaa7b
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions includes/deprecated.php
Original file line number Diff line number Diff line change
Expand Up @@ -1017,3 +1017,53 @@ function pmpro_get_plugin_duplicates() {

return $multiple_installations;
}

/**
* Show admin notice if site was using a custom-loaded frontend.css file.
* We no longer enqueue the frontend.css override file by default.
*
* @since TBD
*/
function pmpro_was_loading_frontend_css_notice() {
global $current_user;

// If we are not on a PMPro admin page, don't show the notice.
if ( ! isset( $_REQUEST['page'] ) || ( isset( $_REQUEST['page'] ) && 'pmpro-' !== substr( $_REQUEST['page'], 0, 6 ) ) ) {
return;
}

// Determine if this site was loading a custom frontend.css override file.
if ( ! file_exists( get_stylesheet_directory() . '/paid-memberships-pro/css/frontend.css' ) && ! file_exists( get_template_directory() . '/paid-memberships-pro/frontend.css' ) ) {
// No custom frontend.css override file was found. Don't show the notice.
return;
}

// Get notifications that have been archived.
$archived_notifications = get_user_meta( $current_user->ID, 'pmpro_archived_notifications', true );

// If the user hasn't dismissed the notice, show it.
if ( ! is_array( $archived_notifications ) || ! array_key_exists( 'was_loading_frontend_css_notice', $archived_notifications ) ) {
?>
<div id="was_loading_frontend_css_notice" class="notice notice-error pmpro_notification pmpro_notification-error">
<button type="button" class="pmpro-notice-button notice-dismiss" value="was_loading_frontend_css_notice"><span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice.', 'paid-memberships-pro' ); ?></span></button>
<div class="pmpro_notification-icon">
<span class="dashicons dashicons-warning"></span>
</div>
<div class="pmpro_notification-content">
<h3><?php esc_html_e( 'Custom Frontend Stylesheet Detected', 'paid-memberships-pro' ); ?></h3>
<p>
<?php
printf(
wp_kses_post(
__( 'Paid Memberships Pro detected that you were using a custom override for the frontend stylesheet. As of v3.1 and later, we no longer load your custom stylesheet. For more information, read our <a href="%s">v3.1 release notes post here</a>.', 'paid-memberships-pro' )
),
esc_url( 'https://www.paidmembershipspro.com/pmpro-update-3-1/' )
);
?>
</p>
</div>
</div>
<?php
}
}
add_action( 'admin_notices', 'pmpro_was_loading_frontend_css_notice' );

0 comments on commit 1acaa7b

Please sign in to comment.