Skip to content

Commit

Permalink
Merge pull request #6 from WordImpress/release/1.7
Browse files Browse the repository at this point in the history
Merge updates
  • Loading branch information
ramiy committed Aug 17, 2016
2 parents 0e1c8cc + 8ee3538 commit d2e8041
Show file tree
Hide file tree
Showing 15 changed files with 145 additions and 46 deletions.
11 changes: 4 additions & 7 deletions assets/css/give-admin.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/css/give-admin.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/frontend/give.all.min.js

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions assets/js/frontend/give.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jQuery( function ( $ ) {
// Trigger float-labels
give_fl_trigger();

// Set custom validation message.
give_change_html5_form_field_validation_message();

doc.on( 'give_gateway_loaded', function ( ev, response, form_id ) {
// Trigger float-labels
give_fl_trigger();
Expand Down Expand Up @@ -126,3 +129,41 @@ function give_fl_custom_events( el ) {
el.after( '<span class="off card-type"/>' );
}
}


/**
* Change localize html5 form validation message
*/
function give_change_html5_form_field_validation_message() {
var $forms = jQuery( '.give-form' ),
$input_fields;

// Bailout if no any donation from exist.
if( ! $forms.length ) {
return;
}

jQuery.each( $forms, function( index, $form ){
// Get form input fields.
$input_fields = jQuery( 'input', $form );

// Bailout.
if( ! $input_fields.length ) {
return;
}

jQuery.each( $input_fields, function( index, item ){
item = jQuery( item ).get(0);

// Set custom message only if translation exit in give global object.
if( give_global_vars.form_translation.hasOwnProperty( item.name ) ) {
item.oninvalid = function (e) {
e.target.setCustomValidity('');
if ( ! e.target.validity.valid ){
e.target.setCustomValidity( give_global_vars.form_translation[ item.name ] );
}
};
}
});
});
}
2 changes: 1 addition & 1 deletion assets/js/frontend/give.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions assets/scss/admin/forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ div.cmb-type-levels-repeater-header + div.cmb-repeat-group-wrap {

.give-money-symbol-after {
border-left: 0;
margin-left: -4px;
}

.give-underline {
Expand Down
8 changes: 3 additions & 5 deletions assets/scss/admin/payment-history.scss
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,6 @@ Responsiveness
font-weight: 600;
}

#give-donation-overview .inside {
padding: 12px;
}

input.give-price-field {
width: 80px;
padding: 3px 5px;
Expand Down Expand Up @@ -413,10 +409,12 @@ input.give-price-field {
}
}


//------------------------------------------
//Donation Details
//------------------------------------------
#give-donor-details .inside, #give-donation-overview .inside {
margin-top: 0;
}

.give_forms_page_give-payment-history #give-dashboard-widgets-wrap #side-sortables {
padding-top: 0;
Expand Down
2 changes: 1 addition & 1 deletion assets/sourcemaps/give-admin.css.map

Large diffs are not rendered by default.

25 changes: 11 additions & 14 deletions includes/admin/forms/metabox.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ function give_single_forms_cmb2_metaboxes( array $meta_boxes ) {
'id' => $prefix . 'set_price',
'type' => 'text_small',
'row_classes' => 'give-subfield',
'before_field' => give_get_option( 'currency_position' ) == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '',
'after_field' => give_get_option( 'currency_position' ) == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '',
'sanitization_cb' => 'give_sanitize_price_field_value',
'render_row_cb' => 'give_cmb_amount_field_render_row_cb',
'sanitization_cb' => 'give_sanitize_price_field_value',
'attributes' => array(
'placeholder' => give_format_decimal( '1.00' ),
'value' => give_format_decimal( $price ),
Expand Down Expand Up @@ -159,15 +158,14 @@ function give_single_forms_cmb2_metaboxes( array $meta_boxes ) {
),
),
array(
'name' => esc_html__( 'Custom Amount Minimum', 'give' ),
'description' => esc_html__( 'If you would like to set a minimum custom donation amount please enter it here.', 'give' ),
'id' => $prefix . 'custom_amount_minimum',
'type' => 'text_small',
'row_classes' => 'give-subfield',
'before_field' => give_get_option( 'currency_position' ) == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '',
'after_field' => give_get_option( 'currency_position' ) == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '',
'sanitization_cb' => 'give_sanitize_price_field_value',
'attributes' => array(
'name' => esc_html__( 'Custom Amount Minimum', 'give' ),
'description' => esc_html__( 'If you would like to set a minimum custom donation amount please enter it here.', 'give' ),
'id' => $prefix . 'custom_amount_minimum',
'type' => 'text_small',
'row_classes' => 'give-subfield',
'render_row_cb' => 'give_cmb_amount_field_render_row_cb',
'sanitization_cb' => 'give_sanitize_price_field_value',
'attributes' => array(
'placeholder' => give_format_decimal('1.00'),
'value' => give_format_decimal( $custom_amount_minimum ),
'class' => 'cmb-type-text-small give-money-field',
Expand Down Expand Up @@ -202,8 +200,7 @@ function give_single_forms_cmb2_metaboxes( array $meta_boxes ) {
'id' => $prefix . 'set_goal',
'type' => 'text_small',
'row_classes' => 'give-subfield',
'before_field' => give_get_option( 'currency_position' ) == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '',
'after_field' => give_get_option( 'currency_position' ) == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '',
'render_row_cb' => 'give_cmb_amount_field_render_row_cb',
'sanitization_cb' => 'give_sanitize_price_field_value',
'attributes' => array(
'placeholder' => give_format_decimal( '0.00' ),
Expand Down
1 change: 0 additions & 1 deletion includes/admin/payments/payments-history.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* @return void
*/
function give_payment_history_page() {
global $give_options;

$give_payment = get_post_type_object( 'give_payment' );

Expand Down
7 changes: 4 additions & 3 deletions includes/admin/payments/view-order-details.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@
<?php
//Transaction Date
$date_format = get_option( 'date_format' );
echo date_i18n( $date_format, strtotime( $payment_date ) );
echo date_i18n( $date_format, $payment_date );
?>
</p>
<p>
Expand Down Expand Up @@ -422,6 +422,7 @@
*/
do_action( 'give_donation_details_thead_before', $payment_id );


/**
* Fires in order details page, in the donation-information metabox, after the head elements.
*
Expand Down Expand Up @@ -476,7 +477,7 @@
do_action( 'give_view_order_details_files_after', $payment_id );
?>

<div id="give-customer-details" class="postbox">
<div id="give-donor-details" class="postbox">
<h3 class="hndle"><?php esc_html_e( 'Donor Details', 'give' ); ?></h3>

<div class="inside">
Expand Down Expand Up @@ -578,7 +579,7 @@
</div>
<!-- /.inside -->
</div>
<!-- /#give-customer-details -->
<!-- /#give-donor-details -->

<?php
/**
Expand Down
51 changes: 51 additions & 0 deletions includes/formatting.php
Original file line number Diff line number Diff line change
Expand Up @@ -438,4 +438,55 @@ function give_sanitize_number_decimals( $value, $field_args, $field ){
*/
function give_sanitize_price_field_value( $value, $field_args, $field ){
return give_sanitize_amount( $value );
}


/**
* Manually render amount field.
*
* @since 1.7
*
* @param array $field_args Array of field arguments.
* @param CMB2_Field $field The field object
*
* @return void
*/
function give_cmb_amount_field_render_row_cb( $field_args, $field ) {

// Get args.
$id = $field->args('id');
$label = $field->args( 'name' );
$name = $field->args( '_name' );
$description = $field->args( 'description' );
$attributes = $field->args( 'attributes' );
$attributes_string = '';
$row_class = $field->row_classes();

// Get attributes.
if( ! empty( $attributes ) ) {
foreach ( $attributes as $attribute_name => $attribute_val ) {
$attributes_string[] = "$attribute_name=\"$attribute_val\"";
}

$attributes_string = implode( ' ', $attributes_string );
}

// Get row class.
if( ! empty( $row_class ) && is_array( $row_class ) ) {
$row_class = implode( ' ', $row_class );
}
?>
<div class="cmb-row <?php echo $row_class; ?>">
<div class="cmb-th">
<label for="<?php echo $id; ?>"><?php echo $label; ?></label>
</div>
<div class="cmb-td">
<?php echo ( give_get_option( 'currency_position' ) == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '' ); ?>
<input id="<?php echo $id; ?>" type="text" name="<?php echo $name; ?>" <?php echo $attributes_string?>/>
<?php echo ( give_get_option( 'currency_position' ) == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '' ); ?>

<span class="cmb2-metabox-description"><?php echo $description; ?></span>
</div>
</div>
<?php
}
20 changes: 9 additions & 11 deletions includes/forms/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -810,10 +810,14 @@ function give_get_register_fields( $form_id ) {
<?php do_action( 'give_register_fields_before', $form_id ); ?>

<fieldset id="give-register-account-fields-<?php echo $form_id; ?>">
<legend><?php echo apply_filters( 'give_create_account_fieldset_heading', esc_html__( 'Create an account', 'give' ) );
<legend>
<?php
echo apply_filters( 'give_create_account_fieldset_heading', esc_html__( 'Create an account', 'give' ) );
if ( ! give_logged_in_only( $form_id ) ) {
echo ' <span class="sub-text">' . esc_html__( '(optional)', 'give' ) . '</span>';
} ?></legend>
}
?>
</legend>
<?php do_action( 'give_register_account_fields_before', $form_id ); ?>
<div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-one-third form-row-first">
<label for="give-user-login-<?php echo $form_id; ?>">
Expand All @@ -824,9 +828,7 @@ function give_get_register_fields( $form_id ) {
<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The username you will use to log into your account.', 'give' ); ?>"></span>
</label>

<input name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" class="<?php if ( give_logged_in_only( $form_id ) ) {
echo 'required ';
} ?>give-input" type="text" placeholder="<?php esc_attr_e( 'Username', 'give' ); ?>"/>
<input name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" class="give-input" type="text" placeholder="<?php esc_attr_e( 'Username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required ' : ''; ?>/>
</div>

<div id="give-user-pass-wrap-<?php echo $form_id; ?>" class="form-row form-row-one-third">
Expand All @@ -838,9 +840,7 @@ function give_get_register_fields( $form_id ) {
<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The password used to access your account.', 'give' ); ?>"></span>
</label>

<input name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" class="<?php if ( give_logged_in_only( $form_id ) ) {
echo 'required ';
} ?>give-input" placeholder="<?php esc_attr_e( 'Password', 'give' ); ?>" type="password"/>
<input name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" class="give-input" placeholder="<?php esc_attr_e( 'Password', 'give' ); ?>" type="password"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required ' : ''; ?>/>
</div>

<div id="give-user-pass-confirm-wrap-<?php echo $form_id; ?>" class="give-register-password form-row form-row-one-third">
Expand All @@ -852,9 +852,7 @@ function give_get_register_fields( $form_id ) {
<span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'Please retype your password to confirm.', 'give' ); ?>"></span>
</label>

<input name="give_user_pass_confirm" id="give-user-pass-confirm-<?php echo $form_id; ?>" class="<?php if ( give_logged_in_only( $form_id ) ) {
echo 'required ';
} ?>give-input" placeholder="<?php esc_attr_e( 'Confirm password', 'give' ); ?>" type="password"/>
<input name="give_user_pass_confirm" id="give-user-pass-confirm-<?php echo $form_id; ?>" class="give-input" placeholder="<?php esc_attr_e( 'Confirm password', 'give' ); ?>" type="password"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required ' : ''; ?>/>
</div>
<?php do_action( 'give_register_account_fields_after', $form_id ); ?>
</fieldset>
Expand Down
14 changes: 13 additions & 1 deletion includes/scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,19 @@ function give_load_scripts() {
'general_loading' => esc_html__( 'Loading...', 'give' ),
'purchase_loading' => esc_html__( 'Please Wait...', 'give' ),
'number_decimals' => give_get_price_decimals(),
'give_version' => GIVE_VERSION
'give_version' => GIVE_VERSION,
'form_translation' => apply_filters(
'give_form_translation_js',
array(
// Field name Validation message.
'payment-mode' => esc_html__( 'Please select payment mode.', 'give' ),
'give_first' => esc_html__( 'Please enter your first name.', 'give' ),
'give_email' => esc_html__( 'Please enter a valid email address.', 'give' ),
'give_user_login' => esc_html__( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ),
'give_user_pass' => esc_html__( 'Enter a password.', 'give' ),
'give_user_pass_confirm' => esc_html__( 'Enter a confirm password.', 'give' ),
)
)
) );
$localize_give_ajax = apply_filters( 'give_global_ajax_vars', array(
'ajaxurl' => give_get_ajax_url(),
Expand Down
4 changes: 4 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ We also really like WooCommerce. It's hands-down the most robust eCommerce platf

== Changelog ==

= 1.6.1 =
* Fix: Donation date discrepancy in transaction details view - https://github.com/WordImpress/Give/issues/898


= 1.6: August 11, 2016 =
* New: Added email tag support to Offline Donation Admin Notification - https://github.com/WordImpress/Give/issues/846
* New: Added a "Reset Password" option to the donation form if the user is prompted to login - https://github.com/WordImpress/Give/issues/723
Expand Down

0 comments on commit d2e8041

Please sign in to comment.