Skip to content

Commit

Permalink
Merge pull request #9064 from awesomemotive/release/2.11.5
Browse files Browse the repository at this point in the history
Release/2.11.5
  • Loading branch information
ashleyfae authored Jan 27, 2022
2 parents 6d0713f + 9d41c49 commit e7ed0b1
Show file tree
Hide file tree
Showing 22 changed files with 2,875 additions and 209 deletions.
25 changes: 25 additions & 0 deletions assets/js/admin-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2138,6 +2138,31 @@ jQuery(document).ready(function ($) {
}
});

/**
* Deletes the debug log file and disables logging.
*/
$( document.body ).on( 'click', '#edd-disable-debug-log', function ( e ) {
e.preventDefault();
$( this ).attr( 'disabled', true );
var notice = $( '#edd-debug-log-notice' );
$.ajax( {
type: "GET",
data: {
action: 'edd_disable_debugging',
nonce: $( '#edd_debug_log_delete' ).val(),
},
url: ajaxurl,
success: function ( response ) {
notice.empty().append( response.data );
setTimeout( function () {
notice.slideUp();
}, 3000 );
}
} ).fail( function ( response ) {
notice.empty().append( response.responseJSON.data );
} );
} );

});

// Graphing Helper Functions
Expand Down
2 changes: 1 addition & 1 deletion assets/js/admin-scripts.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions easy-digital-downloads.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: The easiest way to sell digital products with WordPress.
* Author: Easy Digital Downloads
* Author URI: https://easydigitaldownloads.com
* Version: 2.11.4.1
* Version: 2.11.5
* Text Domain: easy-digital-downloads
* Domain Path: languages
*
Expand All @@ -25,7 +25,7 @@
* @package EDD
* @category Core
* @author Easy Digital Downloads
* @version 2.11.4.1
* @version 2.11.5
*/

// Exit if accessed directly.
Expand Down Expand Up @@ -231,7 +231,7 @@ private function setup_constants() {

// Plugin version.
if ( ! defined( 'EDD_VERSION' ) ) {
define( 'EDD_VERSION', '2.11.4.1' );
define( 'EDD_VERSION', '2.11.5' );
}

// Plugin Folder Path.
Expand Down
59 changes: 59 additions & 0 deletions includes/admin/class-edd-notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class EDD_Notices {
public function __construct() {
add_action( 'admin_notices', array( $this, 'show_notices' ) );
add_action( 'edd_dismiss_notices', array( $this, 'dismiss_notices' ) );
add_action( 'wp_ajax_edd_disable_debugging', array( $this, 'edd_disable_debugging' ) );
}

/**
Expand Down Expand Up @@ -171,6 +172,8 @@ public function show_notices() {
echo '</div>';
}

$this->show_debugging_notice();

/* Commented out per https://github.com/easydigitaldownloads/Easy-Digital-Downloads/issues/3475
if( ! edd_test_ajax_works() && ! get_user_meta( get_current_user_id(), '_edd_admin_ajax_inaccessible_dismissed', true ) && current_user_can( 'manage_shop_settings' ) ) {
echo '<div class="error">';
Expand Down Expand Up @@ -310,6 +313,62 @@ public function show_notices() {
settings_errors( 'edd-notices' );
}

/**
* Show a notice if debugging is enabled in the EDD settings.
* Does not show if only the `EDD_DEBUG_MODE` constant is defined.
*
* @since 2.11.5
* @return void
*/
private function show_debugging_notice() {
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
return;
}
if ( ! current_user_can( 'manage_shop_settings' ) ) {
return;
}
if ( ! edd_get_option( 'debug_mode', false ) ) {
return;
}
$view_url = add_query_arg(
array(
'post_type' => 'download',
'page' => 'edd-tools',
'tab' => 'debug_log',
),
admin_url( 'edit.php' )
);
?>
<div id="edd-debug-log-notice" class="notice notice-warning">
<p>
<?php esc_html_e( 'Easy Digital Downloads debug logging is enabled. Please only leave it enabled for as long as it is needed for troubleshooting.', 'easy-digital-downloads' ); ?>
</p>
<p>
<a class="button button-secondary" href="<?php echo esc_url( $view_url ); ?>"><?php esc_html_e( 'View Debug Log', 'easy-digital-downloads' ); ?></a>
<button class="button button-primary" id="edd-disable-debug-log"><?php esc_html_e( 'Delete Log File and Disable Logging', 'easy-digital-downloads' ); ?></button>
<?php wp_nonce_field( 'edd_debug_log_delete', 'edd_debug_log_delete' ); ?>
</p>
</div>
<?php
}

/**
* Disables the debug log setting and deletes the existing log file.
*
* @since 2.11.5
* @return void
*/
public function edd_disable_debugging() {
$validate_nonce = ! empty( $_GET['nonce'] ) && wp_verify_nonce( $_GET['nonce'], 'edd_debug_log_delete' );
if ( ! current_user_can( 'manage_shop_settings' ) || ! $validate_nonce ) {
wp_send_json_error( wpautop( __( 'You do not have permission to perform this action.', 'easy-digital-downloads' ) ), 403 );
}
edd_update_option( 'debug_mode', false );
global $edd_logs;
$edd_logs->clear_log_file();
wp_send_json_success( wpautop( __( 'The debug log has been cleared and logging has been disabled.', 'easy-digital-downloads' ) ) );
}

/**
* Dismiss admin notices when Dismiss links are clicked
*
Expand Down
17 changes: 11 additions & 6 deletions includes/admin/downloads/metabox.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,16 @@ function edd_download_meta_box_save( $post_id, $post ) {

} else {

$new = false;
if ( ! empty( $_POST[ $field ] ) ) {
$new = apply_filters( 'edd_metabox_save_' . $field, $_POST[ $field ] );
}
if ( ! empty( $new ) ) {
update_post_meta( $post_id, $field, $new );
} else {
delete_post_meta( $post_id, $field );
}
}

}

if ( edd_has_variable_prices( $post_id ) ) {
Expand All @@ -180,10 +182,11 @@ function edd_sanitize_bundled_products_save( $products = array() ) {

global $post;

$self = array_search( $post->ID, $products );

if( $self !== false )
unset( $products[ $self ] );
foreach ( $products as $key => $product_id ) {
if ( in_array( $product_id, array( 0, $post->ID ) ) ) {
unset( $products[ $key ] );
}
}

return array_values( array_unique( $products ) );
}
Expand Down Expand Up @@ -628,7 +631,9 @@ function edd_render_products_field( $post_id ) {
}

$price_assignments = edd_get_bundle_pricing_variations( $post_id );
$price_assignments = $price_assignments[0];
if ( ! empty( $price_assignments[0] ) ) {
$price_assignments = $price_assignments[0];
}

$selected = isset( $price_assignments[ $index ] ) ? $price_assignments[ $index ] : null;

Expand Down
13 changes: 10 additions & 3 deletions includes/admin/extensions/abstract-extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ abstract class Extension {
*/
protected $manager;

/**
* The settings section for this item.
*
* @since 2.11.5
* @var string
*/
protected $settings_section = 'general';

public function __construct() {
$this->manager = new \EDD\Admin\Extensions\Extension_Manager( static::PASS_LEVEL );
}
Expand Down Expand Up @@ -267,12 +275,11 @@ protected function get_button_parameters( ProductData $product_data, $item_id =
* @return string
*/
private function get_upgrade_url( ProductData $product_data, $item_id, $has_access = false ) {
$url = 'https://easydigitaldownloads.com';
$tab = ! empty( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : '';
$url = 'https://easydigitaldownloads.com/pricing';
$utm_parameters = array(
'p' => urlencode( $item_id ),
'utm_source' => 'settings',
'utm_medium' => urlencode( $tab ),
'utm_medium' => urlencode( $this->settings_section ),
'utm_campaign' => 'admin',
'utm_term' => urlencode( $product_data->slug ),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ class EmailMarketing extends Extension {
*/
protected $settings_tab = 'marketing';

/**
* The settings section for this item.
*
* @since 2.11.5
* @var string
*/
protected $settings_section = 'email_marketing';

public function __construct() {
add_filter( 'edd_settings_sections_marketing', array( $this, 'add_section' ) );
add_action( 'edd_settings_tab_top_marketing_email_marketing', array( $this, 'field' ) );
Expand All @@ -46,7 +54,7 @@ public function add_section( $sections ) {
if ( ! $product_data || ! is_array( $product_data ) ) {
return $sections;
}
$sections['email_marketing'] = __( 'Email Marketing', 'easy-digital-downloads' );
$sections[ $this->settings_section ] = __( 'Email Marketing', 'easy-digital-downloads' );

return $sections;
}
Expand Down
10 changes: 9 additions & 1 deletion includes/admin/extensions/product-education/class-invoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ class Invoices extends Extension {
*/
protected $settings_tab = 'gateways';

/**
* The settings section for this item.
*
* @since 2.11.5
* @var string
*/
protected $settings_section = 'invoices';

/**
* The pass level required to access this extension.
*/
Expand Down Expand Up @@ -92,7 +100,7 @@ public function add_section( $sections ) {
return $sections;
}

$sections['invoices'] = __( 'Invoices', 'easy-digital-downloads' );
$sections[ $this->settings_section ] = __( 'Invoices', 'easy-digital-downloads' );

return $sections;
}
Expand Down
10 changes: 9 additions & 1 deletion includes/admin/extensions/product-education/class-recurring.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ class Recurring extends Extension {
*/
const PASS_LEVEL = \EDD\Admin\Pass_Manager::EXTENDED_PASS_ID;

/**
* The settings section for this item.
*
* @since 2.11.5
* @var string
*/
protected $settings_section = 'recurring';

public function __construct() {
add_filter( 'edd_settings_sections_gateways', array( $this, 'add_section' ) );
add_action( 'edd_settings_tab_top_gateways_recurring', array( $this, 'settings_field' ) );
Expand Down Expand Up @@ -92,7 +100,7 @@ public function add_section( $sections ) {
return $sections;
}

$sections['recurring'] = __( 'Recurring Payments', 'easy-digital-downloads' );
$sections[ $this->settings_section ] = __( 'Recurring Payments', 'easy-digital-downloads' );

return $sections;
}
Expand Down
10 changes: 9 additions & 1 deletion includes/admin/extensions/product-education/class-reviews.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ class Reviews extends Extension {
*/
protected $settings_tab = 'marketing';

/**
* The settings section for this item.
*
* @since 2.11.5
* @var string
*/
protected $settings_section = 'reviews';

/**
* The pass level required to access this extension.
*/
Expand Down Expand Up @@ -97,7 +105,7 @@ public function add_section( $sections ) {
return $sections;
}

$sections['reviews'] = __( 'Reviews', 'easy-digital-downloads' );
$sections[ $this->settings_section ] = __( 'Reviews', 'easy-digital-downloads' );

return $sections;
}
Expand Down
4 changes: 2 additions & 2 deletions includes/admin/import/class-batch-import-downloads.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ public function process_step() {
unlink( $this->file );
}

if( ! $this->done && $this->csv->data ) {
if( ! $this->done && $this->csv ) {

$more = true;

foreach( $this->csv->data as $key => $row ) {
foreach( $this->csv as $key => $row ) {

// Skip all rows until we pass our offset
if( $key + 1 <= $offset ) {
Expand Down
19 changes: 13 additions & 6 deletions includes/admin/import/class-batch-import-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ public function process_step() {
unlink( $this->file );
}

if( ! $this->done && $this->csv->data ) {
if( ! $this->done && $this->csv ) {

$more = true;

foreach( $this->csv->data as $key => $row ) {
foreach( $this->csv as $key => $row ) {

// Skip all rows until we pass our offset
if( $key + 1 <= $offset ) {
Expand Down Expand Up @@ -393,6 +393,9 @@ private function set_customer( $row ) {

global $wpdb;

$customer = false;
$email = '';

if( ! empty( $this->field_mapping['email'] ) && ! empty( $row[ $this->field_mapping['email'] ] ) ) {

$email = sanitize_text_field( $row[ $this->field_mapping['email'] ] );
Expand Down Expand Up @@ -435,7 +438,7 @@ private function set_customer( $row ) {

// Now compare customer records. If they don't match, customer_id will be stored in meta and we will use the customer that matches the email

if( ( empty( $customer_by_id ) || $customer_by_id->id !== $customer_by_email->id ) && ! empty( $customer_by_email ) ) {
if ( ! empty( $customer_by_email ) && ( empty( $customer_by_id ) || $customer_by_id->id !== $customer_by_email->id ) ) {

$customer = $customer_by_email;

Expand Down Expand Up @@ -543,7 +546,10 @@ public function get_downloads_from_edd( $data_str ) {

foreach( $downloads as $key => $download ) {

$d = (array) explode( '|', $download );
$d = (array) explode( '|', $download );
if ( ! array_key_exists( 1, $d ) ) {
continue;
}
preg_match_all( '/\{(\d|(\d+(\.\d+|\d+)))\}/', $d[1], $matches );

if( false !== strpos( $d[1], '{' ) ) {
Expand All @@ -555,7 +561,8 @@ public function get_downloads_from_edd( $data_str ) {
$price = trim( $d[1] );
}

$tax = isset( $matches[1][0] ) ? trim( $matches[1][0] ) : 0;
$price = floatval( $price );
$tax = isset( $matches[1][0] ) ? floatval( trim( $matches[1][0] ) ) : 0;
$price_id = isset( $matches[1][1] ) ? trim( $matches[1][1] ) : false;

$d_array[] = array(
Expand All @@ -581,7 +588,7 @@ public function get_downloads_from_edd( $data_str ) {
*/
public function get_percentage_complete() {

$total = count( $this->csv->data );
$total = count( $this->csv );

if( $total > 0 ) {
$percentage = ( $this->step * $this->per_step / $total ) * 100;
Expand Down
Loading

0 comments on commit e7ed0b1

Please sign in to comment.