From 1c5bd280df2c87e04b51e00128b9557a48739f30 Mon Sep 17 00:00:00 2001 From: Codebard Date: Fri, 17 May 2024 20:49:40 +0200 Subject: [PATCH 1/2] Now reconnection feature can be used to repair a site's connection even if the connection is already broken. Updated Reconnection feature's text and button labels to be more informative for the new connect/reconnect format. Added gaussian blur filter. Updated readme. --- classes/patreon_options.php | 4 ++-- classes/patreon_protect.php | 10 ++++++---- classes/patreon_routing.php | 19 +++++++++++++++---- classes/patreon_wordpress.php | 6 ++++++ patreon.php | 8 ++++---- readme.txt | 26 ++++++++++++++++++++------ 6 files changed, 53 insertions(+), 20 deletions(-) diff --git a/classes/patreon_options.php b/classes/patreon_options.php index bcd3c02a..28e14745 100644 --- a/classes/patreon_options.php +++ b/classes/patreon_options.php @@ -134,7 +134,7 @@ function patreon_plugin_setup_page(){ && get_option( 'patreon-creators-access-token' , false ) != '' && get_option( 'patreon-creators-refresh-token' , false ) != '' ) { - ?> We will now reconnect your site to Patreon. This will refresh your site's connection to Patreon. Your settings and content gating values will remain unchanged. Patron only content will become accessible to everyone until you finish reconnecting your site to Patreon.

- + diff --git a/classes/patreon_protect.php b/classes/patreon_protect.php index 049094cf..a63f73e9 100644 --- a/classes/patreon_protect.php +++ b/classes/patreon_protect.php @@ -19,7 +19,7 @@ function __construct() { add_action( 'wp_ajax_patreon_catch_image_click', 'Patreon_Protect::CatchImageClick' ); } - // Only image-reader is left always on for backward compatibility in case a user already has images linked directly - it can be put into the conditional block above in later versios + // Only image-reader is left always on for backward compatibility in case a user already has images linked directly - it can be put into the conditional block above in later versions add_action( 'plugins_loaded', array( $this, 'servePatronOnlyImage' ) ); } function GalleryItemSavePatreonEdit( $form_fields, $post ) { @@ -408,14 +408,16 @@ public static function generateBlockedImagePlaceholder( $patreon_level, $attachm 'w' => intval( $width / 2 ), 'h' => intval( $height / 2 ) ) - ); + ); + + $gaussian_blur_value = apply_filters( 'ptrn/image_locking_gaussian_blur_value', 999 ); /* Scale by 25% and apply Gaussian blur */ $sm = imagecreatetruecolor( $size['sm']['w'], $size['sm']['h'] ); imagecopyresampled( $sm, $image, 0, 0, 0, 0, $size['sm']['w'], $size['sm']['h'], $width, $height ); for ( $x=1; $x <=30; $x++ ){ - imagefilter( $sm, IMG_FILTER_GAUSSIAN_BLUR, 999 ); + imagefilter( $sm, IMG_FILTER_GAUSSIAN_BLUR, $gaussian_blur_value ); } imagefilter( $sm, IMG_FILTER_SMOOTH,99 ); @@ -427,7 +429,7 @@ public static function generateBlockedImagePlaceholder( $patreon_level, $attachm imagedestroy($sm); for ( $x=1; $x <=64; $x++ ) { - imagefilter( $md, IMG_FILTER_GAUSSIAN_BLUR, 999 ); + imagefilter( $md, IMG_FILTER_GAUSSIAN_BLUR, $gaussian_blur_value ); } imagefilter( $md, IMG_FILTER_SMOOTH,99 ); diff --git a/classes/patreon_routing.php b/classes/patreon_routing.php index 31ad927b..40df5644 100644 --- a/classes/patreon_routing.php +++ b/classes/patreon_routing.php @@ -64,7 +64,7 @@ function query_vars( $public_query_vars ) { } function parse_request( &$wp ) { - + if ( strpos( $_SERVER['REQUEST_URI'],'/patreon-flow/' ) !== false ) { // First slap the noindex header so search engines wont index this page: @@ -252,7 +252,7 @@ function parse_request( &$wp ) { do_action( 'patreon_do_action_before_universal_flow', $filter_args ); $flow_link = Patreon_Frontend::MakeUniversalFlowLink( $send_pledge_level, $state, $client_id, $post, array('link_interface_item' => $link_interface_item ) ); - + wp_redirect( $flow_link ); exit; @@ -358,9 +358,19 @@ function parse_request( &$wp ) { } // All good. Update the client details locally + + $existing_client_id = get_option( 'patreon-client-id', false ); + + if ( $existing_client_id != $client_id ) { + $client_id_updated = update_option('patreon-client-id', sanitize_text_field( $client_id ) ); + $client_id_updated = false; + } + else { + $client_id_updated = true; + } - if ( update_option('patreon-client-id', sanitize_text_field( $client_id ) ) AND + if ( $client_id_updated AND update_option('patreon-client-secret', sanitize_text_field( $client_secret ) ) AND update_option('patreon-creators-access-token', sanitize_text_field( $creator_access_token ) ) AND update_option('patreon-creators-refresh-token', sanitize_text_field( $creator_refresh_token ) ) @@ -483,8 +493,9 @@ function parse_request( &$wp ) { // All good. Update the client details locally + $existing_client_id = get_option( 'patreon-client-id', false ); - if ( update_option('patreon-client-id', sanitize_text_field( $client_id ) ) AND + if ( $existing_client_id == $client_id AND update_option('patreon-client-secret', sanitize_text_field( $client_secret ) ) AND update_option('patreon-creators-access-token', sanitize_text_field( $creator_access_token ) ) AND update_option('patreon-creators-refresh-token', sanitize_text_field( $creator_refresh_token ) ) diff --git a/classes/patreon_wordpress.php b/classes/patreon_wordpress.php index 76d5b3a5..784efd53 100644 --- a/classes/patreon_wordpress.php +++ b/classes/patreon_wordpress.php @@ -2629,6 +2629,12 @@ public static function order_independent_actions_to_run_on_init_start() { if ( isset( $_REQUEST['patreon_wordpress_action'] ) AND $_REQUEST['patreon_wordpress_action'] == 'disconnect_site_from_patreon_for_reconnection' AND is_admin() AND current_user_can( 'manage_options' ) ) { + // We dont need to do this anymore. So for the time being, just redirect to the connection wizard for compatibility concerns. The entire block can be removed after a few versions + + // Redirect to connect wizard + wp_redirect( admin_url( 'admin.php?page=patreon_wordpress_setup_wizard&setup_stage=reconnect_0') ); + exit; + if ( !isset($_REQUEST['patreon_wordpress_reconnect_to_patreon_nonce']) OR !wp_verify_nonce( sanitize_key( $_REQUEST['patreon_wordpress_reconnect_to_patreon_nonce'] ) ) ) { wp_die('Form security field expired - please refresh the page and try again'); } diff --git a/patreon.php b/patreon.php index ae242319..c0e504fb 100644 --- a/patreon.php +++ b/patreon.php @@ -4,7 +4,7 @@ Plugin Name: Patreon Wordpress Plugin URI: https://www.patreon.com/apps/wordpress Description: Patron-only content, directly on your website. -Version: 1.8.9 +Version: 1.9.0 Author: Patreon Author URI: https://patreon.com */ @@ -68,7 +68,7 @@ define( "PATREON_CREATOR_BYPASSES_FILTER_MESSAGE", 'This content is for Patrons only, it\'s not locked for you because you are logged in as the Patreon creator' ); define( "PATREON_NO_LOCKING_LEVEL_SET_FOR_THIS_POST", 'Post is already public. If you would like to lock this post, please set a pledge level for it' ); define( "PATREON_NO_POST_ID_TO_UNLOCK_POST", 'Sorry - could not get the post id for this locked post' ); -define( "PATREON_WORDPRESS_VERSION", '1.8.9' ); +define( "PATREON_WORDPRESS_VERSION", '1.9.0' ); define( "PATREON_WORDPRESS_BETA_STRING", '' ); define( "PATREON_WORDPRESS_PLUGIN_SLUG", plugin_basename( __FILE__ ) ); define( "PATREON_PRIVACY_POLICY_ADDENDUM", '

Patreon features in this website

In order to enable you to use this website with Patreon services, we save certain functionally important Patreon information about you in this website if you log in with Patreon. @@ -110,14 +110,14 @@ define( "PATREON_NO_AUTH_FOR_CLIENT_CREATION", 'We weren\'t able to get the go ahead from Patreon while attempting to connect your site. Please wait a minute and try again. If this situation persists, contact support.' ); define( "PATREON_NO_ACQUIRE_CLIENT_DETAILS", 'We weren\'t able to get to get the token for connecting your site to Patreon for the time being. Please wait a while and try again and contact support if this situation persists.' ); define( "PATREON_NO_CREDENTIALS_RECEIVED", 'We weren\'t able to connect your site to Patreon because Patreon sent back empty credentials. Please wait a while and try again and contact support if this situation persists.' ); -define( "PATREON_RECONNECT_INITIAL_MESSAGE", 'We will now reconnect your site to Patreon. This will refresh your site\'s connection and all app credentials. Patron only content in your website will be accessible to everyone until reconnection is complete. We will now take you to Patreon in order to automatically reconnect your site. Please make sure you are logged into your creator account at Patreon before starting.' ); +define( "PATREON_RECONNECT_INITIAL_MESSAGE", 'We will now (re)connect your site to Patreon. This will refresh your site\'s connection and all app credentials. Patron only content in your website will be accessible to everyone until reconnection is complete. We will now take you to Patreon in order to automatically reconnect your site. Please make sure you are logged into your creator account at Patreon before starting.' ); define( "PATREON_ADMIN_MESSAGE_DEFAULT_TITLE", 'All\'s cool' ); define( "PATREON_ADMIN_MESSAGE_DEFAULT_CONTENT", 'Pretty much nothing to report.' ); define( "PATREON_ADMIN_MESSAGE_CLIENT_DELETE_ERROR_TITLE", 'Sorry, couldn\'t disconnect your site' ); define( "PATREON_ADMIN_MESSAGE_CLIENT_DELETE_ERROR_CONTENT", 'Please wait a few minutes and try again. If this issue persists, you can visit your your app/clients page and delete the app/client for this site. Then you can save empty values for details in "Connection details" tab in "Patreon settings" menu at your site. This would manually disconnect your site from Patreon. Then, you can reconnect your site to another Patreon account or to the same account.' ); define( "PATREON_ADMIN_MESSAGE_CLIENT_RECONNECT_DELETE_ERROR_TITLE", 'Sorry, couldn\'t disconnect your site before reconnecting it' ); define( "PATREON_TEXT_YOU_HAVE_NO_REWARDS_IN_THIS_CAMPAIGN", 'You have no tiers in this campaign' ); -define( "PATREON_ADMIN_MESSAGE_CLIENT_RECONNECT_DELETE_ERROR_CONTENT", 'Please wait a few minutes and try again. If this issue persists, you can visit your your app/clients page and delete the app/client for this site. Then you can save empty values for details in "Connection details" tab in "Patreon settings" menu at your site. This would manually disconnect your site from Patreon. Then, you can reconnect your site to another Patreon account or to the same account.' ); +define( "PATREON_ADMIN_MESSAGE_CLIENT_RECONNECT_DELETE_ERROR_CONTENT", 'Please wait a few minutes and try again. If this issue persists, you can visit your your app/clients page and delete the app/client for this site. Then you can save empty values for details in "Connection details" tab in "Patreon settings" menu at your site. This would manually disconnect your site from Patreon. Then, you can reconnect your site to another Patreon account or to the same account.' ); define( "PATREON_WP_SUPER_CACHE_LOGGED_IN_USERS_ENABLED_HEADING", 'WP Super Cache caches pages for logged in users' ); define( "PATREON_WP_SUPER_CACHE_LOGGED_IN_USERS_ENABLED", 'This could cause logged in patrons to see a content they unlocked still as locked because they may be served a cached version of the page.

Solution

Please visit this WP Super Cache settings page and turn the option "Disable caching for visitors who have a cookie set in their browser." or "Disable caching for logged in visitors. (Recommended)" on and click "Update Status" button to save WP Super Cache settings' ); define( "PATREON_WP_SUPER_CACHE_MAKE_KNOWN_ANON_ENABLED_HEADING", 'WP Super Cache caches treats logged in users as anonymous' ); diff --git a/readme.txt b/readme.txt index 0309df1d..c35585c3 100644 --- a/readme.txt +++ b/readme.txt @@ -1,21 +1,21 @@ === Patreon WordPress === -Contributors: wordpressorg@patreon.com, codebard +Contributors: patreon, codebard Tags: patreon, membership, members Requires at least: 4.0 Requires PHP: 7.4 -Tested up to: 6.5.2 -Stable tag: 1.8.9 +Tested up to: 6.5.3 +Stable tag: 1.9.0 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html -Connect your WordPress site and your Patreon to increase your patrons and pledges! +Connect your WordPress site to Patreon and increase your members and pledges! + +== Description == With Patreon WordPress, you can bring Patreon features to your WordPress website and integrate them to make them work together. You can even easily import your existing Patreon posts and keep your Patreon posts synced to your WP site automatically! Your patron-only content at your WordPress site will encourage your visitors to become your patrons to unlock your content. You can lock any single post or all of your posts! You can also lock any custom post type. Your visitors can log into your site via Patreon, making it easier for them to use your site in addition to accessing your locked content. -Read how Lawless French increased their income 50% in just 3 months using Patreon WordPress. - This plugin is developed and maintained by Patreon. = FEATURES FOR CREATORS = @@ -79,6 +79,13 @@ It is difficult to protect videos due the intensive bandwidth requirements of h == Upgrade Notice == += 1.9.0 = + +* Now the reconnection wizard can be used to refresh/repair the connection of the site to Patreon without having to disconnect the site even if the site connection is broken or lost +* Updated reconnection wizard info and button text to make it clear that now reconnection can be used to refresh connection or connect the site from scratch +* Updated the routing logic to update the client ids correctly in the new format for both connection and reconnection cases +* Added a Gaussian blur value filter to allow modifying the blur setting of image locking + = 1.8.9 = * Fixed the issue with Import next batch button not working immedieatly after starting a manual post import @@ -500,6 +507,13 @@ You can report security bugs through the Patchstack Vulnerability Disclosure Pro == Changelog == += 1.9.0 = + +* Now the reconnection wizard can be used to refresh/repair the connection of the site to Patreon without having to disconnect the site even if the site connection is broken or lost +* Updated reconnection wizard info and button text to make it clear that now reconnection can be used to refresh connection or connect the site from scratch +* Updated the routing logic to update the client ids correctly in the new format for both connection and reconnection cases +* Added a Gaussian blur value filter to allow modifying the blur setting of image locking + = 1.8.9 = * Fixed the issue with Import next batch button not working immedieatly after starting a manual post import From 51d93cc8b53a7c8965450c61565271a76f3b6dec Mon Sep 17 00:00:00 2001 From: Codebard Date: Fri, 17 May 2024 20:52:52 +0200 Subject: [PATCH 2/2] Removed unused code. --- classes/patreon_routing.php | 1 - 1 file changed, 1 deletion(-) diff --git a/classes/patreon_routing.php b/classes/patreon_routing.php index 40df5644..1b5fbeba 100644 --- a/classes/patreon_routing.php +++ b/classes/patreon_routing.php @@ -363,7 +363,6 @@ function parse_request( &$wp ) { if ( $existing_client_id != $client_id ) { $client_id_updated = update_option('patreon-client-id', sanitize_text_field( $client_id ) ); - $client_id_updated = false; } else { $client_id_updated = true;