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

issues/687 #951

Merged
merged 2 commits into from
Aug 26, 2016
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion includes/admin/customers/class-customer-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function column_default( $item, $column_name ) {
break;

case 'date_created' :
$value = date_i18n( get_option( 'date_format' ), strtotime( $item['date_created'] ) );
$value = date_i18n( give_date_format(), strtotime( $item['date_created'] ) );
break;

default:
Expand Down
4 changes: 2 additions & 2 deletions includes/admin/customers/customers.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ function give_customers_view( $customer ) {
</div>
<p class="customer-since info-item">
<?php esc_html_e( 'Donor since', 'give' ); ?>
<?php echo date_i18n( get_option( 'date_format' ), strtotime( $customer->date_created ) ) ?>
<?php echo date_i18n( give_date_format(), strtotime( $customer->date_created ) ) ?>
</p>
<?php if ( current_user_can( $customer_edit_role ) ): ?>
<a href="#" id="edit-customer" class="button info-item editable customer-edit-link"><?php esc_html_e( 'Edit Donor', 'give' ); ?></a>
Expand Down Expand Up @@ -458,7 +458,7 @@ function give_customers_view( $customer ) {
<tr>
<td><?php echo $payment->ID; ?></td>
<td><?php echo give_payment_amount( $payment->ID ); ?></td>
<td><?php echo date_i18n( get_option( 'date_format' ), strtotime( $payment->post_date ) ); ?></td>
<td><?php echo date_i18n( give_date_format(), strtotime( $payment->post_date ) ); ?></td>
<td><?php echo give_get_payment_status( $payment, true ); ?></td>
<td>
<a aria-label="<?php sprintf( esc_attr_e( 'View Details for Donation %s.', 'give' ), $payment->ID ); ?>" href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment->ID ); ?>">
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/payments/class-payments-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public function column_default( $payment, $column_name ) {

case 'date' :
$date = strtotime( $payment->date );
$value = date_i18n( get_option( 'date_format' ), $date );
$value = date_i18n( give_date_format(), $date );
break;

case 'status' :
Expand Down
4 changes: 2 additions & 2 deletions includes/admin/payments/view-order-details.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
<div class="column">
<p>
<strong><?php esc_html_e( 'Donation Date:', 'give' ); ?></strong><br>
<?php echo date_i18n( get_option( 'date_format' ), $payment_date ); ?>
<?php echo date_i18n( give_date_format(), $payment_date ); ?>
</p>
<p>
<strong><?php esc_html_e( 'Donation Level:', 'give' ); ?></strong><br>
Expand Down Expand Up @@ -498,7 +498,7 @@
</p>
<p>
<strong><?php esc_html_e( 'Donor Since:', 'give' ); ?></strong><br>
<?php echo date_i18n( get_option( 'date_format' ), strtotime( $customer->date_created ) ) ?>
<?php echo date_i18n( give_date_format(), strtotime( $customer->date_created ) ) ?>
</p>
</div>
<div class="column">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private function set_donor_data( $i, $data, $donor ) {
$data[ $i ]['userid'] = ! empty( $donor->user_id ) ? $donor->user_id : '';
}
if ( ! empty( $columns['date_first_donated'] ) ) {
$data[ $i ]['date_first_donated'] = date_i18n( get_option( 'date_format' ), strtotime( $donor->date_created ) );
$data[ $i ]['date_first_donated'] = date_i18n( give_date_format(), strtotime( $donor->date_created ) );
}
if ( ! empty( $columns['donations'] ) ) {
$data[ $i ]['donations'] = $donor->purchase_count;
Expand Down
4 changes: 2 additions & 2 deletions includes/admin/reporting/pdf-reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ function give_generate_pdf( $data ) {
sprintf(
/* translators: 1: start date 2: end date */
esc_html__( '%1$s to %2$s', 'give' ),
date_i18n( get_option( 'date_format' ), mktime( 0, 0, 0, 1, 1, date( 'Y' ) ) ),
date_i18n( get_option( 'date_format' ) )
date_i18n( give_date_format(), mktime( 0, 0, 0, 1, 1, date( 'Y' ) ) ),
date_i18n( give_date_format() )
)
);

Expand Down
2 changes: 1 addition & 1 deletion includes/emails/class-give-email-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ function give_email_tag_billing_address( $payment_id ) {
function give_email_tag_date( $payment_id ) {
$payment = new Give_Payment( $payment_id );

return date_i18n( get_option( 'date_format' ), strtotime( $payment->date ) );
return date_i18n( give_date_format(), strtotime( $payment->date ) );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion includes/emails/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function give_email_preview_template_tags( $message ) {
$message = str_replace( '{name}', $user->display_name, $message );
$message = str_replace( '{fullname}', $user->display_name, $message );
$message = str_replace( '{username}', $user->user_login, $message );
$message = str_replace( '{date}', date( get_option( 'date_format' ), current_time( 'timestamp' ) ), $message );
$message = str_replace( '{date}', date( give_date_format(), current_time( 'timestamp' ) ), $message );
$message = str_replace( '{price}', $price, $message );
$message = str_replace( '{donation}', esc_html__( 'Sample Donation Form Title', 'give' ), $message );
$message = str_replace( '{receipt_id}', $receipt_id, $message );
Expand Down
48 changes: 48 additions & 0 deletions includes/formatting.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,4 +480,52 @@ function give_cmb_amount_field_render_row_cb( $field_args, $field ) {
</div>
</div>
<?php
}


/**
* Get date format string on basis of given context.
*
*
* @since 1.7
*
* @param string $date_context Date format context name.
*
* @return string Date format string
*/
function give_date_format ( $date_context = '' ) {
/**
* Filter the date context
*
* You can add your own date context or use already exist context.
* For example:
* add_filter( 'give_date_format_contexts', 'add_new_date_contexts' );
* function add_new_date_contexts( $date_format_contexts ) {
* // You can add single context like this $date_format_contexts['checkout'] = 'F j, Y';
* // Instead add multiple date context at once.
* $new_date_format_contexts = array(
* 'checkout' => 'F j, Y',
* 'report' => 'Y-m-d',
* 'email' => 'm/d/Y',
* );
*
* // Merge date contexts array only if you are adding multiple date contexts at once otherwise return $date_format_contexts.
* return array_merge( $new_date_format_contexts, $date_format_contexts );
*
* }
*/
$date_format_contexts = apply_filters( 'give_date_format_contexts', array() );

// Set date format to default date format.
$date_format = get_option('date_format');


// Update date format if we have non empty date format context array and non empty date format string for that context.
if( $date_context && ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) {
$date_format = ! empty( $date_format_contexts[ $date_context ] )
? $date_format_contexts[ $date_context ]
: $date_format;
}

return apply_filters( 'give_date_format', $date_format );
}
2 changes: 1 addition & 1 deletion includes/payments/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1586,7 +1586,7 @@ function give_get_payment_note_html( $note, $payment_id = 0 ) {
$user = esc_html__( 'System', 'give' );
}

$date_format = get_option( 'date_format' ) . ', ' . get_option( 'time_format' );
$date_format = give_date_format() . ', ' . get_option( 'time_format' );

$delete_note_url = wp_nonce_url( add_query_arg( array(
'give-action' => 'delete_payment_note',
Expand Down
2 changes: 1 addition & 1 deletion templates/history-donations.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
do_action( 'give_purchase_history_row_start', $post->ID, $donation_data );
?>
<td class="give_purchase_id">#<?php echo give_get_payment_number( $post->ID ); ?></td>
<td class="give_purchase_date"><?php echo date_i18n( get_option( 'date_format' ), strtotime( get_post_field( 'post_date', $post->ID ) ) ); ?></td>
<td class="give_purchase_date"><?php echo date_i18n( give_date_format(), strtotime( get_post_field( 'post_date', $post->ID ) ) ); ?></td>
<td class="give_purchase_amount">
<span class="give_purchase_amount"><?php echo give_currency_filter( give_format_amount( give_get_payment_amount( $post->ID ) ) ); ?></span>
</td>
Expand Down
2 changes: 1 addition & 1 deletion templates/shortcode-receipt.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<?php if ( filter_var( $give_receipt_args['date'], FILTER_VALIDATE_BOOLEAN ) ) : ?>
<tr>
<td scope="row"><strong><?php esc_html_e( 'Date:', 'give' ); ?></strong></td>
<td><?php echo date_i18n( get_option( 'date_format' ), strtotime( $meta['date'] ) ); ?></td>
<td><?php echo date_i18n( give_date_format(), strtotime( $meta['date'] ) ); ?></td>
</tr>
<?php endif; ?>

Expand Down