Skip to content

Commit

Permalink
Merge pull request #153 from Patreon/1.9.0
Browse files Browse the repository at this point in the history
1.9.0
  • Loading branch information
codebard authored May 17, 2024
2 parents d6d3cb0 + 51d93cc commit 41c0b13
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 20 deletions.
4 changes: 2 additions & 2 deletions classes/patreon_options.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function patreon_plugin_setup_page(){
&& get_option( 'patreon-creators-access-token' , false ) != ''
&& get_option( 'patreon-creators-refresh-token' , false ) != ''
) {
?> <button class="button button-primary button-large patreon_wordpress_interface_toggle" toggle="patreon_options_app_details_reconnect patreon_options_app_details_main" aria-label="Reconnect your site to Patreon">Reconnect site</button> <button class="button button-primary button-large patreon_wordpress_interface_toggle" toggle="patreon_options_app_details_disconnect patreon_options_app_details_main" aria-label="Disconnect your site from Patreon">Disconnect site</button> <?php
?> <button class="button button-primary button-large patreon_wordpress_interface_toggle" toggle="patreon_options_app_details_reconnect patreon_options_app_details_main" aria-label="Connect or Reconnect your site to Patreon">(re)Connect site</button> <button class="button button-primary button-large patreon_wordpress_interface_toggle" toggle="patreon_options_app_details_disconnect patreon_options_app_details_main" aria-label="Disconnect your site from Patreon">Disconnect site</button> <?php

}

Expand All @@ -151,7 +151,7 @@ function patreon_plugin_setup_page(){
<div id="patreon_options_app_details_reconnect">

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.<br /><br />
<button id="patreon_wordpress_disconnect_reconnect_to_patreon" class="button button-primary button-large" target="<?php echo admin_url( 'admin.php?page=patreon-plugin&patreon_wordpress_action=disconnect_site_from_patreon_for_reconnection&patreon_wordpress_reconnect_to_patreon_nonce=' . wp_create_nonce() ); ?>" aria-label="Confirm connection">Confirm reconnection</button> <button class="button button-primary button-large patreon_wordpress_interface_toggle" toggle="patreon_options_app_details_reconnect patreon_options_app_details_main" aria-label="Cancel">Cancel</button>
<button id="patreon_wordpress_disconnect_reconnect_to_patreon" class="button button-primary button-large" target="<?php echo admin_url( 'admin.php?page=patreon_wordpress_setup_wizard&setup_stage=reconnect_0&patreon_wordpress_reconnect_to_patreon_nonce=' . wp_create_nonce() ); ?>" aria-label="Confirm connection">Confirm</button> <button class="button button-primary button-large patreon_wordpress_interface_toggle" toggle="patreon_options_app_details_reconnect patreon_options_app_details_main" aria-label="Cancel">Cancel</button>

</div>

Expand Down
10 changes: 6 additions & 4 deletions classes/patreon_protect.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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 );
Expand All @@ -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 );
Expand Down
18 changes: 14 additions & 4 deletions classes/patreon_routing.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -358,9 +358,18 @@ 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 ) );
}
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 ) )
Expand Down Expand Up @@ -483,8 +492,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 ) )
Expand Down
6 changes: 6 additions & 0 deletions classes/patreon_wordpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
8 changes: 4 additions & 4 deletions patreon.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <platform@patreon.com>
Author URI: https://patreon.com
*/
Expand Down Expand Up @@ -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", '<h2>Patreon features in this website</h2>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.
Expand Down Expand Up @@ -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, <a href="https://www.patreondevelopers.com/c/patreon-wordpress-plugin-support?utm_source=' . urlencode( site_url() ) . '&utm_medium=patreon_wordpress_plugin&utm_campaign=&utm_content=no_auth_for_client_creation_warning_link&utm_term=" target="_blank">contact support</a>.' );
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 <a href="https://www.patreondevelopers.com/c/patreon-wordpress-plugin-support?utm_source=' . urlencode( site_url() ) . '&utm_medium=patreon_wordpress_plugin&utm_campaign=&utm_content=client_details_not_acquired_info_link&utm_term=" target="_blank">contact support</a> 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 <a href="https://www.patreondevelopers.com/c/patreon-wordpress-plugin-support?utm_source=' . urlencode( site_url() ) . '&utm_medium=patreon_wordpress_plugin&utm_campaign=&utm_content=no_credentials_received_info_link&utm_term=" target="_blank">contact support</a> 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 <a href="' . admin_url( 'admin.php?page=patreon-plugin&patreon_wordpress_action=disconnect_site_from_patreon' ) . '">try again</a>. If this issue persists, you can visit your <a href="https://www.patreon.com/portal/registration/register-clients?utm_source=' . urlencode( site_url() ) . '&utm_medium=patreon_wordpress_plugin&utm_campaign=&utm_content=client_delete_error_info_link&utm_term=" target="_blank">your app/clients page</a> 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 <a href="' . admin_url( 'admin.php?page=patreon-plugin&patreon_wordpress_action=disconnect_site_from_patreon_for_reconnection' ) . '">try again</a>. If this issue persists, you can visit your <a href="https://www.patreon.com/portal/registration/register-clients?utm_source=' . urlencode( site_url() ) . '&utm_medium=patreon_wordpress_plugin&utm_campaign=&utm_content=client_reconnect_delete_error_info_link&utm_term=" target="_blank">your app/clients page</a> 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 <a href="' . admin_url( 'admin.php?page=patreon_wordpress_setup_wizard&setup_stage=reconnect_0' ) . '">try again</a>. If this issue persists, you can visit your <a href="https://www.patreon.com/portal/registration/register-clients?utm_source=' . urlencode( site_url() ) . '&utm_medium=patreon_wordpress_plugin&utm_campaign=&utm_content=client_reconnect_delete_error_info_link&utm_term=" target="_blank">your app/clients page</a> 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.<h3>Solution</h3>Please visit <a target="_blank" href="' . admin_url( 'options-general.php?page=wpsupercache&tab=settings' ) . '">this WP Super Cache settings page</a> and turn the option <b>"Disable caching for visitors who have a cookie set in their browser."</b> or <b>"Disable caching for logged in visitors. (Recommended)"</b> 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' );
Expand Down
26 changes: 20 additions & 6 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -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 <a href="https://blog.patreon.com/patreon-wordpress-plugin" target="_blank">50% in just 3 months using Patreon WordPress</a>.

This plugin is developed and maintained by Patreon.

= FEATURES FOR CREATORS =
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 41c0b13

Please sign in to comment.