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

Update meta-box-subscription-info.php #180

Merged
merged 5 commits into from
Sep 4, 2024
Merged
Changes from 1 commit
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
215 changes: 177 additions & 38 deletions views/meta-box-subscription-info.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,57 +260,196 @@
</tr>

<tr>
<th scope="row">
<?php esc_html_e( 'Cancel URL', 'pronamic_ideal' ); ?>
</th>
<td>
<th scope="row" rowspan="3">
<?php esc_html_e( 'Action links', 'pronamic_ideal' ); ?>

<span class="dashicons dashicons-editor-help pronamic-pay-tip" title="<?php echo esc_attr__( 'These actions links can be shared with the customer.', 'pronamic_ideal' ); ?>" tabindex="0"></span>

<?php

$url = $subscription->get_cancel_url();
/**
* Clipboard feature.
*
* @link https://github.com/WordPress/WordPress/blob/68e3310c024d7fceb84a5028e955ad163de6bd45/wp-includes/js/plupload/handlers.js#L364-L393
* @link https://translate.wordpress.org/projects/wp/dev/nl/default/?filters%5Bstatus%5D=either&filters%5Boriginal_id%5D=10763746&filters%5Btranslation_id%5D=91929960
* @link https://translate.wordpress.org/projects/wp/dev/nl/default/?filters%5Bstatus%5D=either&filters%5Boriginal_id%5D=6831324&filters%5Btranslation_id%5D=58732256
*/

printf(
'<a href="%s">%s</a>',
esc_attr( $url ),
esc_html( $url )
);
wp_enqueue_script( 'clipboard' );

?>
<script>
function pronamic_pay_action_links() {
var clipboard = new ClipboardJS( '.pronamic-pay-copy-url' ),
successTimeout;

clipboard.on( 'success', function( event ) {
var triggerElement = jQuery( event.trigger ),
successElement = jQuery( '.success', triggerElement.closest( '.pronamic-pay-action-link-clipboard' ) );

event.clearSelection();

clearTimeout( successTimeout );
remcotolsma marked this conversation as resolved.
Show resolved Hide resolved

successElement.removeClass( 'hidden' );

successTimeout = setTimeout( function() {
successElement.addClass( 'hidden' );
}, 3000 );
} );
}

addEventListener( 'DOMContentLoaded', function ( event ) {
pronamic_pay_action_links();
} );
</script>

<style>
.pronamic-pay-action-link {
display: flex;

flex-direction: column;

gap: 5px;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? Doesn't seem to have much effect on the styling, except for some random gap spacing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Random gap spacing? It's a fixed gap of 5px? It can also be done with margin/padding, I thought this was flex 😏

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, with ‘random gap’ I meant to say that a regular paragraph also adds some spacing if needed?


.pronamic-pay-action-link-tool {
align-items: center;

display: flex;

flex-direction: row;

justify-content: space-between;

gap: 5px;
}

.pronamic-pay-action-link-clipboard {
align-items: center;

display: flex;

flex-direction: row;

flex-wrap: no-wrap;

gap: 5px;
}

.pronamic-pay-action-link-clipboard .success {
color: #007017;
}

.pronamic-pay-action-link-anchor {
text-overflow: ellipsis;
}

.pronamic-pay-description {
color: #646970;
}
</style>
</th>
<td>
<div class="pronamic-pay-action-link">
<div>
<strong><?php esc_html_e( 'Cancel link', 'pronamic_ideal' ); ?></strong>
</div>

<div class="pronamic-pay-action-link-tool">
<div>
<?php

$url = $subscription->get_cancel_url();

printf(
'<a href="%s">%s</a>',
esc_attr( $url ),
esc_html( $url )
);

?>
</div>

<div class="pronamic-pay-action-link-clipboard">
<button type="button" class="button button-small pronamic-pay-copy-url" data-clipboard-text="<?php echo \esc_url( $url ); ?>"><?php \esc_html_e( 'Copy URL to clipboard', 'pronamic_ideal' ); ?></button>
<span class="success hidden" aria-hidden="true"><?php \esc_html_e( 'Copied!', 'pronamic_ideal' ); ?></span>
</div>
</div>

<div class="pronamic-pay-description">
This link can be shared with the customer and gives the customer the option to cancel this subscription.
</div>
</div>
</td>
</tr>
<tr>
<th scope="row">
<?php esc_html_e( 'Renewal URL', 'pronamic_ideal' ); ?>
</th>
<td>
<?php

$url = $subscription->get_renewal_url();

printf(
'<a href="%s">%s</a>',
esc_attr( $url ),
esc_html( $url )
);

?>
<div class="pronamic-pay-action-link">
<div>
<strong><?php esc_html_e( 'Renewal link', 'pronamic_ideal' ); ?></strong>
</div>

<div class="pronamic-pay-action-link-tool">
<div>
<?php

$url = $subscription->get_renewal_url();

printf(
'<a href="%s">%s</a>',
esc_attr( $url ),
esc_html( $url )
);

?>
</div>

<div class="pronamic-pay-action-link-clipboard">
<button type="button" class="button button-small pronamic-pay-copy-url" data-clipboard-text="<?php echo \esc_url( $url ); ?>"><?php \esc_html_e( 'Copy URL to clipboard', 'pronamic_ideal' ); ?></button>
<span class="success hidden" aria-hidden="true"><?php \esc_html_e( 'Copied!', 'pronamic_ideal' ); ?></span>
</div>
</div>

<div class="pronamic-pay-description">
This link can be shared with the customer and gives the customer the option to (early) renew the subscription.
</div>
</div>
</td>
</tr>
<tr>
<th scope="row">
<?php esc_html_e( 'Change payment method URL', 'pronamic_ideal' ); ?>
</th>
<td>
<?php

$url = $subscription->get_mandate_selection_url();

printf(
'<a href="%s">%s</a>',
esc_attr( $url ),
esc_html( $url )
);

?>
<div class="pronamic-pay-action-link">
<div>
<strong><?php esc_html_e( 'Change payment method link', 'pronamic_ideal' ); ?></strong>
</div>

<div class="pronamic-pay-action-link-tool">
<div>
<?php

$url = $subscription->get_mandate_selection_url();

printf(
'<a href="%s">%s</a>',
esc_attr( $url ),
esc_html( $url )
);

?>
</div>

<div class="pronamic-pay-action-link-clipboard">
<button type="button" class="button button-small pronamic-pay-copy-url" data-clipboard-text="<?php echo \esc_url( $url ); ?>"><?php \esc_html_e( 'Copy URL to clipboard', 'pronamic_ideal' ); ?></button>
<span class="success hidden" aria-hidden="true"><?php \esc_html_e( 'Copied!', 'pronamic_ideal' ); ?></span>
</div>
</div>

<div class="pronamic-pay-description">
This link can be shared with the customer and gives the customer the opportunity to change the payment method.<br>
This is useful if a credit card expires or if a customer wants to have the charge debited from another account.
</div>
</div>
</td>
</tr>

Expand Down
Loading