Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional advanced settings to file rows #9595

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions includes/admin/downloads/metabox.php
Original file line number Diff line number Diff line change
Expand Up @@ -806,20 +806,29 @@ function edd_render_file_row( $key, $args, $post_id, $index ) {
'thumbnail_size' => null,
) );

$prices = edd_get_variable_prices( $post_id );
$variable_pricing = edd_has_variable_prices( $post_id );
$variable_display = $variable_pricing ? '' : ' style="display:none;"';
$variable_class = $variable_pricing ? ' has-variable-pricing' : ''; ?>
$prices = edd_get_variable_prices( $post_id );
$variable_pricing = edd_has_variable_prices( $post_id );
$variable_display = $variable_pricing ? '' : ' style="display:none;"';
$variable_class = $variable_pricing ? ' has-variable-pricing' : '';
$custom_file_options = has_action( 'edd_download_file_option_row' );
?>

<div class="edd-repeatable-row-header edd-draghandle-anchor">
<span class="edd-repeatable-row-title" title="<?php _e( 'Click and drag to re-order files', 'easy-digital-downloads' ); ?>">
<?php printf( esc_html__( '%1$s file ID: %2$s', 'easy-digital-downloads' ), esc_html( edd_get_label_singular() ), '<span class="edd_file_id">' . esc_html( $key ) . '</span>' ); ?>
<input type="hidden" name="edd_download_files[<?php echo esc_attr( $key ); ?>][index]" class="edd_repeatable_index" value="<?php echo esc_attr( $index ); ?>"/>
</span>
<span class="edd-repeatable-row-actions">
<a class="edd-remove-row edd-delete" data-type="file">
<?php esc_html_e( 'Remove', 'easy-digital-downloads' ); ?><span class="screen-reader-text"><?php printf( esc_html__( 'Remove file %s', 'easy-digital-downloads' ), esc_html( $key ) ); ?></span>
</a>
<?php
$actions = array(
'remove' => '<a class="edd-remove-row edd-delete" data-type="file">' . esc_html__( 'Remove', 'easy-digital-downloads' ) . '<span class="screen-reader-text">' . sprintf( __( 'Remove file %s', 'easy-digital-downloads' ), esc_html( $key ) ) . '</span></a>',
);
if ( $custom_file_options ) {
array_unshift( $actions, '<a class="toggle-custom-price-option-section">' . esc_html__( 'Show advanced settings', 'easy-digital-downloads' ) . '</a>' );
}

echo implode( '&nbsp;&#124;&nbsp;', $actions );
?>
</span>
</div>

Expand Down Expand Up @@ -885,9 +894,15 @@ function edd_render_file_row( $key, $args, $post_id, $index ) {
</div>

<?php do_action( 'edd_download_file_table_row', $post_id, $key, $args ); ?>

</div>
<?php
<?php if ( $custom_file_options ) { ?>
<div class="edd-custom-price-option-sections-wrap edd-download-file-option-sections-wrap">
<div class="edd-custom-price-option-sections edd-download-file-option-sections">
<?php do_action( 'edd_download_file_option_row', $post_id, $key, $args ); ?>
</div>
</div>
<?php
}
}
add_action( 'edd_render_file_row', 'edd_render_file_row', 10, 4 );

Expand Down