From 4f384fe3b4dc960d6ac8d27ecb794b6602490e4b Mon Sep 17 00:00:00 2001 From: Kim Coleman Date: Tue, 2 Jul 2024 07:42:10 -0400 Subject: [PATCH 1/2] Adding notice if we detect a custom frontend.css loaded via theme files --- includes/deprecated.php | 44 +++++++++++++++++++++++++++++++++++++++++ js/pmpro-admin.js | 8 ++++++-- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/includes/deprecated.php b/includes/deprecated.php index 3b1c6ecca..d6ea46289 100644 --- a/includes/deprecated.php +++ b/includes/deprecated.php @@ -1017,3 +1017,47 @@ 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_override_notice() { + global $current_user; + + // Only show on PMPro admin pages. + if ( empty( $_REQUEST['page'] ) || strpos( $_REQUEST['page'], 'pmpro' ) === false ) { + 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. + return; + } + + // Hide if the notice has been dismissed. + $archived_notifications = get_user_meta( $current_user->ID, 'pmpro_archived_notifications', true ); + if ( ! empty( $archived_notifications ) && in_array( 'pmpro_was_loading_frontend_css_notice', array_keys( $archived_notifications ) ) ) { + return; + } + + // Show a dismissable notice to the user. + ?> +
+

+ v3.1 release notes post here.', 'paid-memberships-pro' ) + ), + esc_url( 'https://www.paidmembershipspro.com/pmpro-update-3-1/' ) + ); + ?> +

+
+ 0 ) { + var notification_id = jQuery(this).val(); + } else { + var notification_id = jQuery(this).parent().attr('id'); + } var postData = { action: 'pmpro_hide_notice', From a6f40ca69920347afc726d041a1307ece5389e30 Mon Sep 17 00:00:00 2001 From: David Parker Date: Fri, 5 Jul 2024 09:32:10 -0400 Subject: [PATCH 2/2] Using same pattern as spamprotection notice --- includes/deprecated.php | 54 +++++++++++++++++++++++------------------ js/pmpro-admin.js | 8 ++---- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/includes/deprecated.php b/includes/deprecated.php index d6ea46289..404fff877 100644 --- a/includes/deprecated.php +++ b/includes/deprecated.php @@ -1024,40 +1024,46 @@ function pmpro_get_plugin_duplicates() { * * @since TBD */ -function pmpro_was_loading_frontend_css_override_notice() { +function pmpro_was_loading_frontend_css_notice() { global $current_user; - // Only show on PMPro admin pages. - if ( empty( $_REQUEST['page'] ) || strpos( $_REQUEST['page'], 'pmpro' ) === false ) { + // 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. + // No custom frontend.css override file was found. Don't show the notice. return; } - // Hide if the notice has been dismissed. + // Get notifications that have been archived. $archived_notifications = get_user_meta( $current_user->ID, 'pmpro_archived_notifications', true ); - if ( ! empty( $archived_notifications ) && in_array( 'pmpro_was_loading_frontend_css_notice', array_keys( $archived_notifications ) ) ) { - return; - } - // Show a dismissable notice to the user. - ?> -
-

- v3.1 release notes post here.', 'paid-memberships-pro' ) - ), - esc_url( 'https://www.paidmembershipspro.com/pmpro-update-3-1/' ) - ); - ?> -

-
- +
+ +
+ +
+
+

+

+ v3.1 release notes post here.', 'paid-memberships-pro' ) + ), + esc_url( 'https://www.paidmembershipspro.com/pmpro-update-3-1/' ) + ); + ?> +

+
+
+ 0 ) { - var notification_id = jQuery(this).val(); - } else { - var notification_id = jQuery(this).parent().attr('id'); - } + jQuery(document).on('click', '.pmpro-notice-button.notice-dismiss', function () { + var notification_id = jQuery(this).val(); var postData = { action: 'pmpro_hide_notice',