Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewlimaza committed Mar 13, 2023
2 parents 4170827 + 12b0743 commit 011ccaf
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
Binary file added includes/images/pmpropdf-loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion includes/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ jQuery(document).ready(function ($) {
order_code: jQuery(this).attr('order_code'),
download_link: pmpro_pdf_admin.admin_url,
download_text: pmpro_pdf_admin.download_text,
loading_gif: pmpro_pdf_admin.loading_gif,
nonce: pmpro_pdf_admin.nonce
};

// Do loading on click.
jQuery(this).html('<img src="' + data.loading_gif + '" alt="loading gif" width="20px"/>');

jQuery.ajax({
url: ajaxurl,
type: 'POST',
Expand All @@ -20,7 +24,7 @@ jQuery(document).ready(function ($) {
},
success: function (responseHTML) {
if (responseHTML == 'error') {
alert('error');
jQuery(this).html('Error generating PDF. Please refresh and try again.');
} else {
jQuery('#pmpro-pdf-generate_' + data.order_code).replaceWith('<a href="' + data.download_link + data.order_code + '" target="_blank">' + data.download_text + '</a>');
}
Expand Down
36 changes: 33 additions & 3 deletions pmpro-pdf-invoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* Plugin URI: https://yoohooplugins.com/plugins/pmpro-pdf-invoices/
* Author: Yoohoo Plugins
* Author URI: https://yoohooplugins.com
* Version: 1.20
* Version: 1.21
* License: GPL2 or later
* Tested up to: 6.1
* Tested up to: 6.1.1
* Requires PHP: 7.2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: pmpro-pdf-invoices
Expand Down Expand Up @@ -37,7 +37,7 @@
define( 'YOOHOO_STORE', 'https://yoohooplugins.com/edd-sl-api/' );
}
define( 'PMPRO_PDF_PLUGIN_ID', 2117 );
define( 'PMPRO_PDF_VERSION', '1.20' );
define( 'PMPRO_PDF_VERSION', '1.21' );
define( 'PMPRO_PDF_DIR', dirname( __file__ ) );

define( 'PMPRO_PDF_LOGO_URL', 'PMPRO_PDF_LOGO_URL');
Expand Down Expand Up @@ -647,6 +647,35 @@ function pmpropdf_download_list_shortcode_handler(){
}
add_shortcode('pmpropdf_download_list', 'pmpropdf_download_list_shortcode_handler');

/**
* Shortcode handler for the download all as ZIP file
*/
function pmpropdf_download_all_zip_shortcode_handler( $atts ){
$title = __("Download all PDF's as ZIP", 'pmpro-pdf-invoices');
if(!empty($atts['title'])){
$title = sanitize_text_field($atts['title']);
}

if(class_exists('ZipArchive') && is_user_logged_in() ) {
global $wpdb, $current_user;

$invoices = $wpdb->get_results("
SELECT *, UNIX_TIMESTAMP(timestamp) as timestamp
FROM $wpdb->pmpro_membership_orders
WHERE user_id = '$current_user->ID'
AND status NOT
IN('review', 'token', 'error')
ORDER BY timestamp DESC"
);

if(!empty($invoices) && count($invoices) > 0){
return "<a href='?pmpro_pdf_invoices_action=download_zip' target='_BLANK'>$title</a>";
}
}
return '';

}
add_shortcode('pmpropdf_download_all_zip', 'pmpropdf_download_all_zip_shortcode_handler');

/**
* Checks if we received a request to perform a zip of the current users documents
Expand Down Expand Up @@ -900,6 +929,7 @@ function pmpropdf_enqueue_scripts_styles() {
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'admin_url' => esc_url( admin_url( '?pmpropdf=') ),
'download_text' => __( 'Download PDF', 'pmpro-pdf-invoices' ),
'loading_gif' => plugins_url( '/includes/images/pmpropdf-loading.gif', __FILE__ ),
'nonce' => wp_create_nonce( 'pmpro-pdf-invoices-single' ),
)
);
Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: andrewza, yoohooplugins
Tags: pdf, pdf invoice, invoices
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4GC4JEZH7KSKL
Requires at least: 5.0
Tested up to: 6.1
Tested up to: 6.1.1
Requires PHP: 7.2
Stable tag: 1.20
License: GPLv2 or later
Expand All @@ -25,6 +25,10 @@ Paid Memberships Pro PDF Invoices plugin will generate PDF Invoices for members
Yes the PDF templates are customizable and use general HTML code with custom tags to replace values in the template.

== Changelog ==
= 1.21 - 2023-03-13 =
* REFACTOR: Reverted the 'pmpropdf_download_all_zip' shortcode that went missing from previous update and neatened it up slightly.
* ENHANCEMENT: Added a small loading icon when generating the PDF from the Member Orders admin page.

= 1.20 - 2023-03-07 =
* ENHANCEMENT: Added new templates: green, blank and split.
* ENHANCEMENT: Adjusted logic for [pmpropdf_download_list], this now allows logged-in non-members to access past PDF invoices.
Expand Down

0 comments on commit 011ccaf

Please sign in to comment.