Skip to content

Commit

Permalink
Merge pull request #147 from Patreon/1_8_7
Browse files Browse the repository at this point in the history
1.8.7
  • Loading branch information
codebard authored Nov 24, 2023
2 parents 4692da8 + 344509e commit a8b6e21
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 71 deletions.
53 changes: 37 additions & 16 deletions assets/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,25 @@

jQuery(document).on( 'click', '.patreon-wordpress .notice-dismiss', function(e) {


var patreon_wordpress_nonce_disconnect_success_notice = jQuery( this ).parent().attr( 'patreon_wordpress_nonce_disconnect_success_notice' );
var patreon_wordpress_nonce_setup_needed = jQuery( this ).parent().attr( 'patreon_wordpress_nonce_setup_needed' );
var patreon_wordpress_nonce_patron_pro_addon_notice_shown = jQuery( this ).parent().attr( 'patreon_wordpress_nonce_patron_pro_addon_notice_shown' );
var patreon_wordpress_nonce_patron_content_manager_addon_notice_shown = jQuery( this ).parent().attr( 'patreon_wordpress_nonce_patron_content_manager_addon_notice_shown' );
var patreon_wordpress_nonce_rate_plugin_notice = jQuery( this ).parent().attr( 'patreon_wordpress_nonce_rate_plugin_notice' );
var patreon_wordpress_nonce_plugin_critical_issues = jQuery( this ).parent().attr( 'patreon_wordpress_nonce_plugin_critical_issues' );
jQuery.ajax({
url: ajaxurl,
type:"POST",
dataType : 'html',
data: {
action: 'patreon_wordpress_dismiss_admin_notice',
notice_id: jQuery( this ).parent().attr( "id" ),
patreon_wordpress_nonce_disconnect_success_notice: patreon_wordpress_nonce_disconnect_success_notice,
patreon_wordpress_nonce_setup_needed: patreon_wordpress_nonce_setup_needed,
patreon_wordpress_nonce_patron_pro_addon_notice_shown: patreon_wordpress_nonce_patron_pro_addon_notice_shown,
patreon_wordpress_nonce_patron_content_manager_addon_notice_shown: patreon_wordpress_nonce_patron_content_manager_addon_notice_shown,
patreon_wordpress_nonce_plugin_critical_issues: patreon_wordpress_nonce_plugin_critical_issues,
}
});
});
Expand Down Expand Up @@ -77,13 +89,15 @@

e.preventDefault();
var pw_input_target = jQuery( this ).attr( 'pw_input_target' );
var patreon_wordpress_nonce_post_sync = jQuery( this ).attr( 'patreon_wordpress_nonce_post_sync' );

jQuery.ajax({
url: ajaxurl,
type:"POST",
dataType : 'html',
data: {
action: 'patreon_wordpress_start_post_import',
patreon_wordpress_nonce_post_sync: patreon_wordpress_nonce_post_sync,
},
success: function( response ) {

Expand Down Expand Up @@ -113,13 +127,15 @@

e.preventDefault();
var pw_input_target = jQuery( this ).attr( 'pw_input_target' );
var patreon_wordpress_nonce_post_sync = jQuery( this ).attr( 'patreon_wordpress_nonce_post_sync' );

jQuery.ajax({
url: ajaxurl,
type:"POST",
dataType : 'html',
data: {
action: 'patreon_wordpress_import_next_batch_of_posts',
patreon_wordpress_nonce_post_sync: patreon_wordpress_nonce_post_sync,
},
beforeSend: function(e) {
jQuery( '#patreon_wp_post_import_status' ).html( 'Importing next batch...' );
Expand Down Expand Up @@ -263,7 +279,7 @@

e.preventDefault();
var pw_input_target = jQuery( this ).attr( 'pw_input_target' );
var patreon_wordpress_save_post_sync_category_nonce = jQuery( this ).attr( 'patreon_wordpress_save_post_sync_category_nonce' );
var patreon_wordpress_nonce_save_post_sync_options = jQuery( this ).attr( 'patreon_wordpress_nonce_save_post_sync_options' );
var patreon_sync_post_type = jQuery('#patreon_sync_post_type').val();
var patreon_sync_post_category = jQuery('#patreon_sync_post_category').val();
var patreon_sync_post_term = jQuery('#patreon_sync_post_term').val();
Expand All @@ -277,7 +293,7 @@
patreon_sync_post_type: patreon_sync_post_type,
patreon_sync_post_category: patreon_sync_post_category,
patreon_sync_post_term: patreon_sync_post_term,
patreon_wordpress_save_post_sync_category_nonce: patreon_wordpress_save_post_sync_category_nonce,
patreon_wordpress_nonce_save_post_sync_options: patreon_wordpress_nonce_save_post_sync_options,
},
beforeSend: function( xhr ) {
jQuery( '#patreon_wordpress_post_import_category_status' ).empty();
Expand Down Expand Up @@ -323,8 +339,8 @@
// Just in case
e.preventDefault();
var pw_input_target = jQuery( this ).attr( 'pw_input_target' );
var option_value = jQuery(this).val();

var option_value = jQuery(this).val();
var patreon_wordpress_nonce_save_post_sync_options = jQuery( this ).attr( 'patreon_wordpress_nonce_save_post_sync_options' );
if ( option_value == '' ) {
// Do nothing if value is empty
jQuery( pw_input_target ).html('');
Expand All @@ -339,17 +355,18 @@
data: {
action: 'patreon_wordpress_set_update_posts_option',
update_posts_option_value: option_value,
patreon_wordpress_nonce_save_post_sync_options: patreon_wordpress_nonce_save_post_sync_options,
},
beforeSend: function( e ) {
},
success: function( response ) {
jQuery( pw_input_target ).empty();
jQuery( pw_input_target ).html( 'Saved!' );
jQuery( pw_input_target ).html( response );

},
error: function( response ) {
jQuery( pw_input_target ).empty();
jQuery( pw_input_target ).html( 'Sorry - could not save' );
jQuery( pw_input_target ).html( response );
},
statusCode: {
500: function(error) {
Expand All @@ -362,12 +379,12 @@
});

// Save patreon post author option upon change in post sync wizard screens
jQuery( "#patreon_post_author_for_synced_posts" ).on( 'change', function(e) {
jQuery( "#patreon-post-author-for-synced-posts" ).on( 'change', function(e) {

// Just in case
e.preventDefault();
var pw_input_target = jQuery( this ).attr( 'pw_input_target' );
var patreon_wordpress_set_post_author_for_post_sync_nonce = jQuery( this ).attr( 'patreon_wordpress_set_post_author_for_post_sync_nonce' );
var patreon_wordpress_nonce_save_post_sync_options = jQuery( this ).attr( 'patreon_wordpress_nonce_save_post_sync_options' );
var option_value = jQuery(this).val();

if ( option_value == '' ) {
Expand All @@ -385,18 +402,18 @@
data: {
action: 'patreon_wordpress_set_post_author_for_post_sync',
patreon_post_author_for_post_sync: option_value,
patreon_wordpress_set_post_author_for_post_sync_nonce: patreon_wordpress_set_post_author_for_post_sync_nonce,
patreon_wordpress_nonce_save_post_sync_options: patreon_wordpress_nonce_save_post_sync_options,
},
beforeSend: function( e ) {
},
success: function( response ) {
jQuery( pw_input_target ).empty();
jQuery( pw_input_target ).html( 'Saved!' );
jQuery( pw_input_target ).html( response );

},
error: function( response ) {
jQuery( pw_input_target ).empty();
jQuery( pw_input_target ).html( 'Sorry - could not save' );
jQuery( pw_input_target ).html( response );
},
statusCode: {
500: function(error) {
Expand All @@ -415,7 +432,8 @@
e.preventDefault();
var pw_input_target = jQuery( this ).attr( 'pw_input_target' );
var option_value = jQuery(this).val();

var patreon_wordpress_nonce_save_post_sync_options = jQuery( this ).attr( 'patreon_wordpress_nonce_save_post_sync_options' );

if ( option_value == '' ) {
// Do nothing if value is empty
jQuery( pw_input_target ).html('');
Expand All @@ -430,17 +448,18 @@
data: {
action: 'patreon_wordpress_set_delete_posts_option',
delete_posts_option_value: option_value,
patreon_wordpress_nonce_save_post_sync_options: patreon_wordpress_nonce_save_post_sync_options,
},
beforeSend: function( e ) {
},
success: function( response ) {
jQuery( pw_input_target ).empty();
jQuery( pw_input_target ).html( 'Saved!' );
jQuery( pw_input_target ).html( response );

},
error: function( response ) {
jQuery( pw_input_target ).empty();
jQuery( pw_input_target ).html( 'Sorry - could not save' );
jQuery( pw_input_target ).html( response );
},
statusCode: {
500: function(error) {
Expand Down Expand Up @@ -595,8 +614,9 @@
jQuery(document).on( 'click', '#patreon_level_refresh', function(e) {

var pw_input_target = jQuery( "#patreon_level_select" );
var pw_post_id = pw_input_target.attr( 'pw_post_id' );

var pw_post_id = pw_input_target.attr( 'pw_post_id' );
var patreon_wordpress_nonce_populate_tier_dropdown = jQuery( this ).attr( 'patreon_wordpress_nonce_populate_tier_dropdown' );

jQuery.ajax({
url: ajaxurl,
async: true, // Just to make sure
Expand All @@ -605,6 +625,7 @@
data: {
action: 'patreon_wordpress_populate_patreon_level_select',
pw_post_id: pw_post_id,
patreon_wordpress_nonce_populate_tier_dropdown: patreon_wordpress_nonce_populate_tier_dropdown,
},
beforeSend: function( e ) {
jQuery( pw_input_target ).html( '<option value="">Loading...</option>' );
Expand Down
10 changes: 5 additions & 5 deletions classes/patreon_frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public static function getLabelOverUniversalButton( $patreon_level, $args = fals
global $post;
}

if ( $args['reason'] == 'user_not_logged_in' ) {
if ( isset( $args['reason'] ) AND $args['reason'] == 'user_not_logged_in' ) {

$label = PATREON_TEXT_OVER_BUTTON_1;

Expand All @@ -285,7 +285,7 @@ public static function getLabelOverUniversalButton( $patreon_level, $args = fals

}

if ( $args['reason'] == 'not_a_patron' ) {
if ( isset( $args['reason'] ) AND $args['reason'] == 'not_a_patron' ) {

$label = PATREON_TEXT_OVER_BUTTON_1;

Expand All @@ -304,11 +304,11 @@ public static function getLabelOverUniversalButton( $patreon_level, $args = fals

}

if ( $args['reason'] == 'payment_declined' ) {
if ( isset( $args['reason'] ) AND $args['reason'] == 'payment_declined' ) {
$label = PATREON_TEXT_OVER_BUTTON_3;
}

if ( $args['reason'] == 'active_pledge_not_enough' ) {
if ( isset( $args['reason'] ) AND $args['reason'] == 'active_pledge_not_enough' ) {

$label = PATREON_TEXT_OVER_BUTTON_1A;

Expand All @@ -328,7 +328,7 @@ public static function getLabelOverUniversalButton( $patreon_level, $args = fals

}

if ( $args['reason'] == 'not_active_patron_at_post_date' ) {
if ( isset( $args['reason'] ) AND $args['reason'] == 'not_active_patron_at_post_date' ) {

$label = PATREON_TEXT_OVER_BUTTON_8;

Expand Down
2 changes: 1 addition & 1 deletion classes/patreon_metabox.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function patreon_plugin_meta_box( $object, $box ) {
<p>
<label for="patreon-level"><?php _e( $label, '1' ); ?></label>
<br><br>
<div id="patreon_level_select_wrapper"><select id="patreon_level_select" name="patreon-level"<?php echo $disabled ?> pw_post_id="<?php echo $object->ID; ?>"><option value="<?php echo get_post_meta( $object->ID, 'patreon-level', true ); ?>"><?php echo Patreon_Wordpress::make_tiers_select( $post ); ?></option></select> <img id="patreon_level_refresh" src="<?php echo PATREON_PLUGIN_ASSETS; ?>/img/refresh_tiers_18.png" style="width: 18px; height: 18px;" /></div>
<div id="patreon_level_select_wrapper"><select id="patreon_level_select" name="patreon-level"<?php echo $disabled ?> pw_post_id="<?php echo $object->ID; ?>"><option value="<?php echo get_post_meta( $object->ID, 'patreon-level', true ); ?>"><?php echo Patreon_Wordpress::make_tiers_select( $post ); ?></option></select> <img id="patreon_level_refresh" src="<?php echo PATREON_PLUGIN_ASSETS; ?>/img/refresh_tiers_18.png" style="width: 18px; height: 18px;" patreon_wordpress_nonce_populate_tier_dropdown="<?php echo wp_create_nonce( 'patreon_wordpress_nonce_populate_tier_dropdown' ); ?>" /></div>
</p>

<?php
Expand Down
10 changes: 5 additions & 5 deletions classes/patreon_options.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function patreon_plugin_setup(){

add_submenu_page( '', 'Patreon Settings', 'Patreon Settings', 'administrator', 'patreon_wordpress_setup_wizard', array('Patreon_Wordpress', 'setup_wizard') );

add_submenu_page( null, 'Patreon WordPress Admin Message', 'Admin message', 'manage_options', 'patreon-plugin-admin-message', array( $this, 'patreon_plugin_admin_message_page' ) );
add_submenu_page( '', 'Patreon WordPress Admin Message', 'Admin message', 'manage_options', 'patreon-plugin-admin-message', array( $this, 'patreon_plugin_admin_message_page' ) );

add_submenu_page( 'patreon-plugin', 'Patreon WordPress Post Sync', 'Post Sync', 'manage_options', 'patreon_wordpress_setup_wizard&setup_stage=post_sync_1', array( $this, 'patreon_plugin_post_sync_page' ) );

Expand Down Expand Up @@ -502,7 +502,7 @@ function patreon_plugin_setup_page(){
<select name="patreon_sync_post_term" id="patreon_sync_post_term" style="display: inline-block; margin-right: 5px;">
<?php echo $term_select ?>
</select>
<button id="patreon_wordpress_save_post_sync_category" patreon_wordpress_save_post_sync_category_nonce="<?php echo wp_create_nonce() ?>" class="button button-primary button-large" pw_input_target="#patreon_wordpress_post_import_category_status" target="">Save</button><div id="patreon_wordpress_post_import_category_status" style="color: #<?php echo $post_sync_category_status_color ?>;"></div>
<button id="patreon_wordpress_save_post_sync_category" patreon_wordpress_nonce_save_post_sync_options="<?php echo wp_create_nonce() ?>" class="button button-primary button-large" pw_input_target="#patreon_wordpress_post_import_category_status" target="">Save</button><div id="patreon_wordpress_post_import_category_status" style="color: #<?php echo $post_sync_category_status_color ?>;"></div>
</div>

</div>
Expand Down Expand Up @@ -610,7 +610,7 @@ function patreon_plugin_setup_page(){
</th>
<td>
<?php

$update_posts_selected = '';
$update_posts_unselected = '';

Expand Down Expand Up @@ -684,14 +684,14 @@ function patreon_plugin_setup_page(){

$post_import_status = 'No post import ongoing';
$post_import_status_color = "9d9d9d";
$post_import_button = '<button id="patreon_wordpress_start_post_import" class="button button-primary button-large" pw_input_target="#patreon_wp_post_import_status" target="">Start an import</button>';
$post_import_button = '<button id="patreon_wordpress_start_post_import" class="button button-primary button-large" pw_input_target="#patreon_wp_post_import_status" target="" patreon_wordpress_nonce_post_sync="' . wp_create_nonce('patreon_wordpress_nonce_post_sync') .'">Start an import</button>';
$import_post_info_text = "Start an import of your posts from Patreon if you haven't done it before. After import of existing posts is complete, new posts will automatically be imported and existing posts automatically updated so you don't need to do this again.";
$import_post_info_header = "Start a post import";

if ( get_option( 'patreon-post-import-in-progress', false ) ) {
$post_import_status = "There is an ongoing post import";
$post_import_status_color = "129500";
$post_import_button = '<button id="patreon_wordpress_import_next_batch_of_posts" class="button button-primary button-large" pw_input_target="#patreon_wp_post_import_status" target="">Import next batch</button>';
$post_import_button = '<button id="patreon_wordpress_import_next_batch_of_posts" class="button button-primary button-large" pw_input_target="#patreon_wp_post_import_status" target="" patreon_wordpress_nonce_post_sync="' . wp_create_nonce('patreon_wordpress_nonce_post_sync') .'">Import next batch</button>';
$import_post_info_text = "Posts will be imported automatically every 5 minutes. If they are not, or you want to do it faster, click to import next batch of posts. This will import the next batch of posts in the queue. You can do this every 10 seconds.";
$import_post_info_header = "Ongoing post import";
}
Expand Down
Loading

0 comments on commit a8b6e21

Please sign in to comment.