Skip to content

Commit

Permalink
Merge branch 'release/2.2' into release/2.3
Browse files Browse the repository at this point in the history
* release/2.2:
  fix(admin-tools): return array data type
  fix(form): stop comment moderation emails
  fix(admin-tools): fix PHP notices
  fix(admin-donor): added first option of title prefix to disabled
  fix(admin-setting): fix error with admin setting title prefix
  fix(admin-form): improve code using sprintf and double quotes
  fix(admin-setting): fix admin setting title prefix notice
  fix(admin-setting): remove unnecessary double quotes
  fix(admin-form): fix empty title prefixes saving issue
  Revert "fix(admin-form): 2.2 ensure name title prefixes can be removed once saved #3466"
  fix(admin-form): fix php notice related when value is not array
  • Loading branch information
DevinWalker committed Jul 16, 2018
2 parents 310e01b + 68a1a81 commit 9377bec
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 20 deletions.
32 changes: 17 additions & 15 deletions includes/admin/admin-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,17 +547,17 @@ function give_donation_import_callback() {
$import_setting = array();
$fields = isset( $_POST['fields'] ) ? $_POST['fields'] : null;

parse_str( $fields );
parse_str( $fields, $output );

$import_setting['create_user'] = $create_user;
$import_setting['mode'] = $mode;
$import_setting['delimiter'] = $delimiter;
$import_setting['csv'] = $csv;
$import_setting['delete_csv'] = $delete_csv;
$import_setting['dry_run'] = $dry_run;
$import_setting['create_user'] = $output['create_user'];
$import_setting['mode'] = $output['mode'];
$import_setting['delimiter'] = $output['delimiter'];
$import_setting['csv'] = $output['csv'];
$import_setting['delete_csv'] = $output['delete_csv'];
$import_setting['dry_run'] = $output['dry_run'];

// Parent key id.
$main_key = maybe_unserialize( $main_key );
$main_key = maybe_unserialize( $output['main_key'] );

$current = absint( $_REQUEST['current'] );
$total_ajax = absint( $_REQUEST['total_ajax'] );
Expand All @@ -566,17 +566,19 @@ function give_donation_import_callback() {
$next = absint( $_REQUEST['next'] );
$total = absint( $_REQUEST['total'] );
$per_page = absint( $_REQUEST['per_page'] );
if ( empty( $delimiter ) ) {
if ( empty( $output['delimiter'] ) ) {
$delimiter = ',';
} else {
$delimiter = $output['delimiter'];
}

// Processing done here.
$raw_data = give_get_donation_data_from_csv( $csv, $start, $end, $delimiter );
$raw_key = maybe_unserialize( $mapto );
$raw_data = give_get_donation_data_from_csv( $output['csv'], $start, $end, $delimiter );
$raw_key = maybe_unserialize( $output['mapto'] );
$import_setting['raw_key'] = $raw_key;

if ( ! empty( $dry_run ) ) {
$import_setting['csv_raw_data'] = give_get_donation_data_from_csv( $csv, 1, $end, $delimiter );
if ( ! empty( $output['dry_run'] ) ) {
$import_setting['csv_raw_data'] = give_get_donation_data_from_csv( $output['csv'], 1, $end, $delimiter );

$import_setting['donors_list'] = Give()->donors->get_donors( array(
'number' => - 1,
Expand Down Expand Up @@ -634,11 +636,11 @@ function give_donation_import_callback() {
$url = give_import_page_url( array(
'step' => '4',
'importer-type' => 'import_donations',
'csv' => $csv,
'csv' => $output['csv'],
'total' => $total,
'delete_csv' => $import_setting['delete_csv'],
'success' => ( isset( $json_data['success'] ) ? $json_data['success'] : '' ),
'dry_run' => $dry_run,
'dry_run' => $output['dry_run'],
) );
$json_data['url'] = $url;

Expand Down
2 changes: 1 addition & 1 deletion includes/admin/class-admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_att

// Get option value.
$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
$option_value = array_fill_keys( $option_value, 'selected' );
$option_value = is_array( $option_value ) ? array_fill_keys( $option_value, 'selected' ) : $option_value;
$wrapper_class = ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '';
$type = '';
$allow_new_values = '';
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/donors/donors.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ function give_donor_view( $donor ) {
<div id="donor-name-wrap" class="left">
<span class="donor-name info-item edit-item">
<select name="donor_info[title]">
<option value="0"><?php esc_html_e( 'Title', 'give' ); ?></option>
<option disabled value="0"><?php esc_html_e( 'Title', 'give' ); ?></option>
<?php
if ( is_array( $title_prefixes ) && count( $title_prefixes ) > 0 ) {
foreach ( $title_prefixes as $title ) {
Expand Down
7 changes: 5 additions & 2 deletions includes/admin/give-metabox-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,17 @@ function give_chosen_input( $field ) {
$thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
$field['style'] = isset( $field['style'] ) ? $field['style'] : '';
$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
$field['value'] = array_filter( give_get_field_value( $field, $thepostid ) );
$field['value'] = array_fill_keys( $field['value'], 'selected' );
$field['value'] = give_get_field_value( $field, $thepostid );
$field['before_field'] = '';
$field['after_field'] = '';
$placeholder = isset( $field['placeholder'] ) ? 'data-placeholder="' . $field['placeholder'] . '"' : '';
$data_type = ! empty( $field['data_type'] ) ? $field['data_type'] : '';
$type = '';
$allow_new_values = '';
$field['value'] = give_get_field_value( $field, $thepostid );
$field['value'] = is_array( $field['value'] ) ?
array_fill_keys( array_filter( $field['value'] ), 'selected' ) :
$field['value'];
$title_prefixes_value = ( is_array( $field['value'] ) && count( $field['value'] ) > 0 ) ?
array_merge( $field['options'], $field['value'] ) :
$field['options'];
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/tools/data/class-give-tools-reset-stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ private function get_stored_data( $key ) {
$value = json_decode( $value, true );
}

return $value;
return (array) $value;
}

/**
Expand Down
8 changes: 8 additions & 0 deletions includes/class-give-comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,18 @@ public static function add( $id, $note, $comment_type, $comment_args = array() )
return $error;
}

// Remove moderation emails when comment posted.
remove_action( 'comment_post', 'wp_new_comment_notify_moderator' );
remove_action( 'comment_post', 'wp_new_comment_notify_postauthor' );

$comment_id = $is_existing_comment
? wp_update_comment( $comment_args )
: wp_new_comment( $comment_args, true );

// Add moderation emails when comment posted.
add_action( 'comment_post', 'wp_new_comment_notify_moderator' );
add_action( 'comment_post', 'wp_new_comment_notify_postauthor' );

update_comment_meta( $comment_id, "_give_{$comment_type}_id", $id );

/**
Expand Down

0 comments on commit 9377bec

Please sign in to comment.