updated plugin Easy Digital Downloads version 3.1.1.4.2

This commit is contained in:
2023-06-05 11:21:17 +00:00
committed by Gitium
parent e5482aabb7
commit b7bbe6d733
105 changed files with 3161 additions and 1326 deletions

View File

@ -35,6 +35,10 @@
"show_price": {
"type": "boolean",
"default": true
},
"direct": {
"type": "boolean",
"default": false
}
},
"example": {

View File

@ -1 +1 @@
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => 'd12364cb3d89217da0af');
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => '75153cfac5e884f38a28');

View File

@ -1 +1 @@
.edd-no-js{display:none!important}svg.edd-blocks__icon{fill:none!important}.editor-styles-wrapper .wp-block.wp-block-edd-buy-button .components-placeholder{align-items:center;background-color:#fefefe;border-radius:5px}.editor-styles-wrapper .wp-block.wp-block-edd-buy-button .components-placeholder__fieldset{justify-content:center}
.edd-no-js{display:none!important}svg.edd-blocks__icon{fill:none!important}.editor-styles-wrapper .components-placeholder a.components-button.edd-new-download{background-color:var(--wp-admin-theme-color)!important;color:#fff!important;line-height:1.5;margin:0 auto!important;padding:.5em 1em;text-decoration:none}.editor-styles-wrapper .wp-block.wp-block-edd-buy-button .components-placeholder{align-items:center;background-color:#fefefe;border-radius:5px}.editor-styles-wrapper .wp-block.wp-block-edd-buy-button .components-placeholder__fieldset{justify-content:center}

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => '44a7f6fcddb3d7a45761');
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => 'cf21706935ed810cf190');

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => 'f7eb0560b580188ab6f6');
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => 'a4b81968f6c606c084d6');

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => 'fbe222c67791f3db7f56');
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => '3ebd3d803f03e6d7cdb8');

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
.edd-blocks__row{align-items:center;display:grid;gap:1rem}.edd-blocks__row-label{font-weight:700}@media(min-width:480px){.edd-blocks__row{grid-template-columns:1fr 1fr}.edd-blocks__row>div:last-of-type:not(:first-of-type){text-align:right}.edd-blocks__row>div:only-child{grid-column:1/span 2}}.edd-blocks-receipt__items,.edd-blocks-receipt__totals{border:1px solid var(--edd-blocks-light-grey);display:grid;margin:0 auto 1.5rem;padding:1rem}.edd-blocks-receipt__row-item{border-bottom:1px solid var(--edd-blocks-light-grey);padding:.5rem 0}.edd-blocks-receipt__row-item:last-child{border-bottom:none!important}.edd-blocks-receipt__row-header{border-bottom:1px solid var(--edd-blocks-light-grey);font-size:1.1rem;font-weight:700;padding-bottom:.5rem}
.edd-blocks__row{align-items:center;display:grid;gap:1rem}.edd-blocks__row-label{font-weight:700}@media(min-width:480px){.edd-blocks__row{grid-template-columns:repeat(auto-fit,minmax(150px,1fr))}.edd-blocks__row>div:last-of-type:not(:first-of-type){text-align:right}.edd-blocks__row>div:only-child{grid-column:1/span 2}}.edd-blocks-receipt__items,.edd-blocks-receipt__totals{border:1px solid var(--edd-blocks-light-grey);display:grid;margin:0 auto 1.5rem;padding:1rem}.edd-blocks-receipt__row-item{border-bottom:1px solid var(--edd-blocks-light-grey);padding:.5rem 0}.edd-blocks-receipt__row-item:last-child{border-bottom:none!important}.edd-blocks-receipt__row-header{border-bottom:1px solid var(--edd-blocks-light-grey);font-size:1.1rem;font-weight:700;padding-bottom:.5rem}

View File

@ -1 +1 @@
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => '4dc61207e0bc9900907a');
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => '2066313c4795ca117892');

View File

@ -1 +1 @@
.edd-no-js{display:none!important}svg.edd-blocks__icon{fill:none!important}.edd-blocks-term-selector select{min-height:60px!important}.edd-blocks-term-selector svg{display:none!important}
.edd-no-js{display:none!important}svg.edd-blocks__icon{fill:none!important}.editor-styles-wrapper .components-placeholder a.components-button.edd-new-download{background-color:var(--wp-admin-theme-color)!important;color:#fff!important;line-height:1.5;margin:0 auto!important;padding:.5em 1em;text-decoration:none}.edd-blocks-term-selector select{min-height:60px!important}.edd-blocks-term-selector svg{display:none!important}

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '8022d11843870776cb71');
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => 'edc5631c889b13e0c385');

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => 'ba06ffbd66b5912e943d');
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => 'daec310e0801da6bedd7');

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => '5db7f26583a44b89219b');
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => '9c5caff2035d02a7827e');

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
.screen-reader-text{clip:rect(1px,1px,1px,1px);word-wrap:normal!important;border:0;-webkit-clip-path:inset(50%);clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.edd-blocks__row{align-items:center;display:grid;gap:1rem}.edd-blocks__row-label{font-weight:700}@media(min-width:480px){.edd-blocks__row{grid-template-columns:1fr 1fr}.edd-blocks__row>div:last-of-type:not(:first-of-type){text-align:right}.edd-blocks__row>div:only-child{grid-column:1/span 2}}.edd-blocks-form{border:1px solid var(--edd-blocks-light-grey);display:grid;gap:1.25rem;padding:2rem}.widget .edd-blocks-form{border:none;padding:0}.edd-blocks-form .edd-blocks-form__group,.edd-blocks-form legend{display:block;margin:0}.edd-blocks-form .edd-blocks-form__group>label{display:block;margin-bottom:.5rem!important}.edd-blocks-form input[type=email],.edd-blocks-form input[type=password],.edd-blocks-form input[type=text],.edd-blocks-form select{box-sizing:border-box;display:block;padding:4px 6px;width:100%}.edd-blocks-form .edd-blocks-form__halves{display:flex!important;gap:1rem;justify-content:space-between}@media(min-width:600px){.edd-blocks-form .edd-blocks-form__halves>*{flex-basis:50%}}p+.edd-blocks-form{margin-top:2rem}.edd-button-secondary,.edd-submit{transition:all .2s ease-in-out}.edd-button-secondary:active,.edd-button-secondary:hover,.edd-submit:active,.edd-submit:hover{transform:translateY(-1px)}.edd-button-secondary{background-color:var(--edd-blocks-light-grey);border:1px solid #ddd;border-radius:4px;color:unset;margin:0;padding:.5rem 1rem}.edd-button-secondary:disabled{opacity:.6}.edd-blocks-receipt__items,.edd-blocks-receipt__totals{border:1px solid var(--edd-blocks-light-grey);display:grid;margin:0 auto 1.5rem;padding:1rem}.edd-blocks-receipt__row-item{border-bottom:1px solid var(--edd-blocks-light-grey);padding:.5rem 0}.edd-blocks-receipt__row-item:last-child{border-bottom:none!important}.edd-blocks-receipt__row-header{border-bottom:1px solid var(--edd-blocks-light-grey);font-size:1.1rem;font-weight:700;padding-bottom:.5rem}.edd-blocks-receipt__items .edd-blocks__row{border-bottom:1px solid var(--edd-blocks-light-grey);padding:.5rem 0}
.screen-reader-text{clip:rect(1px,1px,1px,1px);word-wrap:normal!important;border:0;-webkit-clip-path:inset(50%);clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.edd-blocks__row{align-items:center;display:grid;gap:1rem}.edd-blocks__row-label{font-weight:700}@media(min-width:480px){.edd-blocks__row{grid-template-columns:repeat(auto-fit,minmax(150px,1fr))}.edd-blocks__row>div:last-of-type:not(:first-of-type){text-align:right}.edd-blocks__row>div:only-child{grid-column:1/span 2}}.edd-blocks-form{border:1px solid var(--edd-blocks-light-grey);display:grid;gap:1.25rem;padding:2rem}.widget .edd-blocks-form{border:none;padding:0}.edd-blocks-form .edd-blocks-form__group,.edd-blocks-form legend{display:block;margin:0}.edd-blocks-form .edd-blocks-form__group>label{display:block;margin-bottom:.5rem!important}.edd-blocks-form input[type=email],.edd-blocks-form input[type=password],.edd-blocks-form input[type=text],.edd-blocks-form select{box-sizing:border-box;display:block;padding:4px 6px;width:100%}.edd-blocks-form .edd-blocks-form__halves{display:flex!important;gap:1rem;justify-content:space-between}@media(min-width:600px){.edd-blocks-form .edd-blocks-form__halves>*{flex-basis:50%}}p+.edd-blocks-form{margin-top:2rem}.edd-button-secondary,.edd-submit{transition:all .2s ease-in-out}.edd-button-secondary:active,.edd-button-secondary:hover,.edd-submit:active,.edd-submit:hover{transform:translateY(-1px)}.edd-button-secondary{background-color:var(--edd-blocks-light-grey);border:1px solid #ddd;border-radius:4px;color:unset;margin:0;padding:.5rem 1rem}.edd-button-secondary:disabled{opacity:.6}.edd-blocks-receipt__items,.edd-blocks-receipt__totals{border:1px solid var(--edd-blocks-light-grey);display:grid;margin:0 auto 1.5rem;padding:1rem}.edd-blocks-receipt__row-item{border-bottom:1px solid var(--edd-blocks-light-grey);padding:.5rem 0}.edd-blocks-receipt__row-item:last-child{border-bottom:none!important}.edd-blocks-receipt__row-header{border-bottom:1px solid var(--edd-blocks-light-grey);font-size:1.1rem;font-weight:700;padding-bottom:.5rem}.edd-blocks-receipt__items .edd-blocks__row{border-bottom:1px solid var(--edd-blocks-light-grey);padding:.5rem 0}

View File

@ -1 +1 @@
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '0661e954af1bb187dd97');
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '48f22fda332b4e2cd8f3');

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => '1028b825bf11c1432c23');
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => 'b5c8776e3d561d9f287e');

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => '535d394ba6d83f8c0b16');
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => '323ff8718132587855ee');

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
.screen-reader-text{clip:rect(1px,1px,1px,1px);word-wrap:normal!important;border:0;-webkit-clip-path:inset(50%);clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.edd-pro-search__control{display:flex;justify-content:flex-end;margin-bottom:2em}.edd-pro-search__control input{max-width:100%;width:300px}.edd-pro-search__hidden{display:none!important}.edd-blocks__row{align-items:center;display:grid;gap:1rem}.edd-blocks__row-label{font-weight:700}@media(min-width:480px){.edd-blocks__row{grid-template-columns:1fr 1fr}.edd-blocks__row>div:last-of-type:not(:first-of-type){text-align:right}.edd-blocks__row>div:only-child{grid-column:1/span 2}}div.edd-blocks__user-downloads{border:1px solid var(--edd-blocks-light-grey);padding:1rem}div.edd-blocks__user-downloads .edd-order-item__product .edd-order-item__files,div.edd-blocks__user-downloads .edd-order-items__header .edd-blocks__row-label{text-align:left}.edd-order-item__product,.edd-order-items__header{border-bottom:1px solid var(--edd-blocks-light-grey);gap:1em;padding:.5em 0}.edd-order-item__product:last-child,.edd-order-items__header:last-child{border-bottom:none;padding-bottom:0}.edd-order-items__header{padding-top:0}
.screen-reader-text{clip:rect(1px,1px,1px,1px);word-wrap:normal!important;border:0;-webkit-clip-path:inset(50%);clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.edd-pro-search__control{display:flex;justify-content:flex-end;margin-bottom:2em}.edd-pro-search__control input{max-width:100%;width:300px}.edd-pro-search__hidden{display:none!important}.edd-blocks__row{align-items:center;display:grid;gap:1rem}.edd-blocks__row-label{font-weight:700}@media(min-width:480px){.edd-blocks__row{grid-template-columns:repeat(auto-fit,minmax(150px,1fr))}.edd-blocks__row>div:last-of-type:not(:first-of-type){text-align:right}.edd-blocks__row>div:only-child{grid-column:1/span 2}}div.edd-blocks__user-downloads{border:1px solid var(--edd-blocks-light-grey);padding:1rem}div.edd-blocks__user-downloads .edd-blocks__row-column{text-align:left}.edd-order-item__product,.edd-order-items__header{border-bottom:1px solid var(--edd-blocks-light-grey);gap:1em;padding:.5em 0}.edd-order-item__product:last-child,.edd-order-items__header:last-child{border-bottom:none;padding-bottom:0}.edd-order-items__header{padding-top:0}

View File

@ -4,7 +4,7 @@
* Description: Core blocks for Easy Digital Downloads.
* Requires at least: 5.8
* Requires PHP: 7.0
* Version: 2.0.5.1
* Version: 2.0.6
* Author: Easy Digital Downloads
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
@ -68,12 +68,9 @@ function init_core_blocks() {
}
if ( edd_is_pro() ) {
$pro_files = array(
'search',
);
foreach ( $pro_files as $file ) {
require_once trailingslashit( EDD_BLOCKS_DIR . 'pro' ) . $file . '.php';
if ( file_exists( EDD_BLOCKS_DIR . 'pro/pro.php' ) ) {
require_once EDD_BLOCKS_DIR . 'pro/pro.php';
Pro\init();
}
}
}

View File

@ -12,17 +12,28 @@ add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\localize' );
*/
function localize() {
$user = wp_get_current_user();
$user = wp_get_current_user();
$downloads = new \WP_Query(
array(
'post_type' => 'download',
'posts_per_page' => 1,
'post_status' => 'any',
'no_found_rows' => true,
)
);
wp_localize_script(
'wp-block-editor',
'EDDBlocks',
array(
'current_user' => md5( $user->user_email ),
'all_access' => function_exists( 'edd_all_access' ),
'recurring' => function_exists( 'EDD_Recurring' ),
'is_pro' => edd_is_pro(),
'no_redownload' => edd_no_redownload(),
'current_user' => md5( $user->user_email ),
'all_access' => function_exists( 'edd_all_access' ),
'recurring' => function_exists( 'EDD_Recurring' ),
'is_pro' => edd_is_pro(),
'no_redownload' => edd_no_redownload(),
'supports_buy_now' => edd_shop_supports_buy_now(),
'has_downloads' => $downloads->have_posts(),
'new_download' => add_query_arg( 'post_type', 'download', admin_url( 'post-new.php' ) ),
)
);
}

View File

@ -43,7 +43,7 @@ function get_personal_info_forms( $block_attributes, $customer_info_complete = t
if ( ! edd_no_guest_checkout() || ( ! $customer_info_complete && is_user_logged_in() ) ) {
$forms['guest'] = $options['guest'];
}
if ( ! empty( $block_attributes['show_register_form'] ) ) {
if ( ! empty( $block_attributes['show_register_form'] ) && ! is_user_logged_in() ) {
$setting = $block_attributes['show_register_form'];
if ( 'both' === $setting ) {
$forms['login'] = $options['login'];
@ -76,7 +76,7 @@ function do_personal_info_forms( $block_attributes ) {
if ( is_user_logged_in() ) {
include EDD_BLOCKS_DIR . 'views/checkout/purchase-form/logged-in.php';
if ( ! empty( $customer['email'] ) && ! empty( $customer['first_name'] ) ) {
if ( ! empty( $customer['email'] ) && ! empty( $customer['first_name'] ) && ! has_action( 'edd_purchase_form_user_info_fields' ) ) {
return;
}
$customer_info_complete = false;

View File

@ -131,6 +131,8 @@ function buy_button( $block_attributes = array() ) {
'download_id' => get_the_ID(),
'show_price' => true,
'align' => '',
'direct' => false,
'text' => edd_get_option( 'add_to_cart_text', __( 'Purchase', 'easy-digital-downloads' ) ),
)
);
if ( empty( $block_attributes['download_id'] ) || 'download' !== get_post_type( $block_attributes['download_id'] ) ) {
@ -148,14 +150,19 @@ function buy_button( $block_attributes = array() ) {
wp_enqueue_style( 'edd-styles' );
}
$output = sprintf( '<div class="%s">', esc_attr( implode( ' ', $classes ) ) );
$output .= edd_get_purchase_link(
array(
'class' => implode( ' ', get_purchase_link_classes( $block_attributes ) ),
'download_id' => absint( $block_attributes['download_id'] ),
'price' => (bool) $block_attributes['show_price'],
)
$args = array(
'class' => implode( ' ', get_purchase_link_classes( $block_attributes ) ),
'download_id' => absint( $block_attributes['download_id'] ),
'price' => (bool) $block_attributes['show_price'],
'text' => $block_attributes['text'],
);
if ( $block_attributes['direct'] && edd_shop_supports_buy_now() ) {
$args['direct'] = true;
$args['text'] = edd_get_option( 'buy_now_text', __( 'Buy Now', 'easy-digital-downloads' ) );
}
$output = sprintf( '<div class="%s">', esc_attr( implode( ' ', $classes ) ) );
$output .= edd_get_purchase_link( $args );
$output .= '</div>';
add_filter( 'edd_purchase_link_args', __NAMESPACE__ . '\maybe_update_purchase_links', 100 );

View File

@ -58,7 +58,15 @@ function login( $block_attributes = array() ) {
)
);
$action = ! empty( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : false;
$action = ! empty( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : false;
if ( 'rp' === $action ) {
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ 'wp-resetpass-' . COOKIEHASH ] ), 2 );
$user = check_password_reset_key( $rp_key, $rp_login );
if ( ! $user || is_wp_error( $user ) ) {
$action = 'lostpassword';
edd_set_error( 'invalidkey', __( 'Your password reset link appears to be invalid. Please request a new link below.', 'easy-digital-downloads' ) );
}
}
$block_classes = array( 'wp-block-edd-login' );
if ( $action ) {
$block_classes[] = "wp-block-edd-login__{$action}";
@ -75,7 +83,6 @@ function login( $block_attributes = array() ) {
if ( 'lostpassword' === $action ) {
include EDD_BLOCKS_DIR . 'views/forms/lost-password.php';
} elseif ( 'rp' === $action ) {
list( $rp_login, $rp_key ) = explode( ':', wp_unslash( $_COOKIE[ 'wp-resetpass-' . COOKIEHASH ] ), 2 );
include EDD_BLOCKS_DIR . 'views/forms/reset-password.php';
} else {
$redirect_url = get_redirect_url( $block_attributes, true );

View File

@ -347,10 +347,25 @@ function downloads( $block_attributes = array() ) {
}
?>
<div class="edd-blocks__row edd-blocks__row-header edd-order-items__header">
<div class="edd-blocks__row-label"><?php esc_html_e( 'Products', 'easy-digital-downloads' ); ?></div>
<?php if ( ! edd_no_redownload() ) : ?>
<div class="edd-blocks__row-label"><?php esc_html_e( 'Files', 'easy-digital-downloads' ); ?></div>
<?php endif; ?>
<?php
foreach ( get_user_downloads_block_columns() as $column_id => $column ) {
$header = $column['header'];
$header_classes = array(
'edd-blocks__row-label',
'edd-blocks__row-label--' . $column_id,
);
if ( ! empty( $header['classes'] ) ) {
$header_classes = array_merge( $header_classes, $header['classes'] );
}
?>
<div class="<?php echo esc_attr( implode( ' ', array_filter( $header_classes ) ) ); ?>">
<?php do_action( 'edd_blocks_user_downloads_block_header_' . $column_id, $block_attributes ); ?>
</div>
<?php
}
?>
</div>
<?php
ksort( $downloads );
@ -455,3 +470,127 @@ function get_purchased_products( $block_attributes ) {
return ! empty( $downloads ) ? $downloads : false;
}
/**
* Get the registered User Downloads block columns.
*
* @since 2.0.6
* @return array
*/
function get_user_downloads_block_columns() {
$columns = array(
'product' => array(
'header' => array(),
'row' => array(
'classes' => array( 'edd-blocks__row-label' ),
),
),
);
if ( ! edd_no_redownload() ) {
$columns['files'] = array(
'header' => array(),
'row' => array(
'classes' => array( 'edd-order-item__files' ),
),
);
}
/**
* Filters the registered User Downloads block columns.
*
* @since 2.0.6
*
* @param array $columns The registered columns.
* A column should have a unique array key and be an array with two keys 'header' and 'row'.
* Each of these can contain an array key 'classes' which should be an array of classes to add to the header or row.
*
* By default we add base classes as well as the columns array key to the header and row, so developers should only add additional
* classes they want.
*
* Developers will need to hook into the following actions to output the content for the header and column:
* - edd_blocks_user_downloads_block_header_{your_column_key}
* - edd_blocks_user_downloads_block_column_{your_column_key}
*
* @return array
*/
$columns = apply_filters( 'edd_blocks_user_downloads_block_columns', $columns );
// Ensure that all registered columns have the required keys.
foreach ( $columns as $column_id => $column ) {
$default_keys = array(
'header' => array(),
'row' => array(),
);
$columns[ $column_id ] = array_merge( $default_keys, $columns[ $column_id ] );
}
return $columns;
}
/**
* Render the User Downloads block product header
*
* @since 2.0.6
*
* @param array $block_attributes The block attributes.
*/
function render_user_downloads_product_header( $block_attributes = array() ) {
esc_html_e( 'Product', 'easy-digital-downloads' );
}
add_action( 'edd_blocks_user_downloads_block_header_product', __NAMESPACE__ . '\render_user_downloads_product_header', 10, 1 );
/**
* Render the User Downloads block product column.
*
* @since 2.0.6
*
* @param array $action_args The action arguments.
*/
function render_user_downloads_product_column( $action_args = array() ) {
echo esc_html( $action_args['name'] );
}
add_action( 'edd_blocks_user_downloads_block_column_product', __NAMESPACE__ . '\render_user_downloads_product_column', 10, 1 );
/**
* Render the User Downloads block files header
* This is only used if the 'Disable Redownload' option is not enabled.
*
* @since 2.0.6
*
* @param array $block_attributes The block attributes.
*/
function render_user_downloads_files_header( $block_attributes = array() ) {
echo esc_html( __( 'Files', 'easy-digital-downloads' ) );
}
add_action( 'edd_blocks_user_downloads_block_header_files', __NAMESPACE__ . '\render_user_downloads_files_header', 10, 1 );
/**
* Render the User Downloads block files column.
* This is only used if the 'Disable Redownload' option is not enabled.
*
* @since 2.0.6
*
* @param array $action_args The action arguments.
*/
function render_user_downloads_files_column( $action_args = array() ) {
// If there are no files, return early.
if ( empty( $action_args['download_files'] ) ) {
echo esc_html( $action_args['block_attributes']['nofiles'] );
}
foreach ( $action_args['download_files'] as $filekey => $file ) :
$order = $action_args['order'];
$item = $action_args['order_item'];
$download_url = edd_get_download_file_url( $order, $order->email, $filekey, $item->product_id, $item->price_id );
?>
<div class="edd-order-item__file">
<a href="<?php echo esc_url( $download_url ); ?>" class="edd-order-item__file-link">
<?php echo esc_html( edd_get_file_name( $file ) ); ?>
</a>
</div>
<?php
endforeach;
}
add_action( 'edd_blocks_user_downloads_block_column_files', __NAMESPACE__ . '\render_user_downloads_files_column', 10, 1 );

View File

@ -7,7 +7,7 @@
$is_checkout_block = empty( $is_cart_widget ) && ( edd_is_checkout() || edd_doing_ajax() );
?>
<div id="edd_checkout_cart" class="<?php echo esc_attr( implode( ' ', $cart_classes ) ); ?>">
<?php if ( edd_is_checkout() ) : ?>
<?php if ( $is_checkout_block ) : ?>
<div class="edd-blocks-cart__row edd-blocks-cart__row-header edd_cart_header_row">
<div class="edd_cart_item_name"><?php esc_html_e( 'Item Name', 'easy-digital-downloads' ); ?></div>
<div class="edd_cart_item_price"><?php esc_html_e( 'Item Price', 'easy-digital-downloads' ); ?></div>

View File

@ -44,5 +44,13 @@ if ( function_exists( 'EDD_CFM' ) ) {
<input class="edd-input" type="text" name="edd_last" id="edd-last" placeholder="<?php esc_html_e( 'Last name', 'easy-digital-downloads' ); ?>" value="<?php echo esc_attr( $customer['last_name'] ); ?>" aria-describedby="edd-last-description" <?php EDD\Blocks\Functions\mark_field_required( 'edd_last' ); ?>/>
<p class="edd-description" id="edd-last-description"><?php esc_html_e( 'We will use this as well to personalize your account experience.', 'easy-digital-downloads' ); ?></p>
</div>
<?php endif; ?>
<?php
endif;
/**
* Allow users to add additional fields to the checkout form.
*
* @param array $customer Customer information. Note that this parameter is not in the original shortcode hook.
*/
do_action( 'edd_purchase_form_user_info_fields', $customer );
?>
</fieldset>

View File

@ -4,7 +4,8 @@
'download_id' => get_the_ID(),
'align' => $block_attributes['purchase_link_align'],
'show_price' => (bool) $block_attributes['show_price'],
'direct' => 'direct' === edd_get_download_button_behavior( get_the_ID() ),
);
echo EDD\Blocks\Downloads\buy_button( $args );
echo EDD\Blocks\Downloads\buy_button( $args ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?>
</footer>

View File

@ -1,5 +1,4 @@
<?php
$price_id = $item->price_id;
$download_files = edd_get_download_files( $item->product_id, $item->price_id );
if ( $block_attributes['hide_empty'] && empty( $download_files ) ) {
return;
@ -12,28 +11,49 @@ $classes = array(
if ( $block_attributes['search'] && edd_is_pro() ) {
$classes[] = 'edd-pro-search__product';
}
$registered_columns = EDD\Blocks\Orders\get_user_downloads_block_columns();
?>
<div class="<?php echo esc_attr( implode( ' ', $classes ) ); ?>">
<div class="edd-blocks__row-label"><?php echo esc_html( $name ); ?></div>
<?php
foreach ( $registered_columns as $column_id => $column ) {
$row = $column['row'];
<?php if ( ! edd_no_redownload() ) : ?>
<div class="edd-order-item__files">
$classes = array(
'edd-blocks__row-column',
'edd-blocks__row-column--' . $column_id,
);
if ( ! empty( $row['classes'] ) ) {
$classes = array_merge( $classes, $row['classes'] );
}
?>
<div class="<?php echo esc_attr( implode( ' ', array_filter( $classes ) ) ); ?>">
<?php
if ( $download_files ) :
foreach ( $download_files as $filekey => $file ) :
$download_url = edd_get_download_file_url( $order, $order->email, $filekey, $item->product_id, $price_id );
?>
<div class="edd-order-item__file">
<a href="<?php echo esc_url( $download_url ); ?>" class="edd-order-item__file-link">
<?php echo esc_html( edd_get_file_name( $file ) ); ?>
</a>
</div>
<?php
endforeach;
else :
echo esc_html( $block_attributes['nofiles'] );
endif; // End $download_files
$action_args = array(
'name' => $name,
'order_item' => $item,
'order' => $order,
'block_attributes' => $block_attributes,
'download_files' => $download_files,
);
/**
* Renders a column in the user downloads block.
*
* To add a new column, use the `edd_blocks_user_download_columns` filter.
*
* @since 2.0.6
* @param array $action_args The arguments to pass to the hook.
* @param string $name The name of the product.
* @param EDD\Orders\Order_Item $item The order item.
* @param EDD\Orders\Order $order The order object.
* @param array $block_attributes The block attributes.
* @param array $download_files The download files.
*/
do_action( 'edd_blocks_user_downloads_block_column_' . $column_id, $action_args );
?>
</div>
<?php endif; ?>
<?php } ?>
</div>