Navigation Menu

Skip to content

Commit

Permalink
fix(admin-tool): add live donation button impress-org#2419
Browse files Browse the repository at this point in the history
  • Loading branch information
raftaar1191 committed Apr 10, 2018
1 parent 265220f commit 41f5840
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 266 deletions.
12 changes: 8 additions & 4 deletions includes/admin/admin-actions.php
Expand Up @@ -627,14 +627,18 @@ function give_donation_import_callback() {
);
}

$url = give_import_page_url( array(
'step' => '4',
$url = give_import_page_url( array(
'importer-type' => 'import_donations',
'step' => '4',
'csv' => $csv,
'total' => $total,
'delimiter' => $delimiter,
'mode' => $mode,
'create_user' => $create_user,
'delete_csv' => $import_setting['delete_csv'],
'success' => ( isset( $json_data['success'] ) ? $json_data['success'] : '' ),
'per_page' => $per_page,
'dry_run' => $dry_run,
'total' => $total,
'success' => ( isset( $json_data['success'] ) ? $json_data['success'] : '' ),
) );
$json_data['url'] = $url;

Expand Down
31 changes: 21 additions & 10 deletions includes/admin/tools/import/class-give-import-donations.php
Expand Up @@ -239,7 +239,8 @@ public function import_success() {

$delete_csv = ( ! empty( $_GET['delete_csv'] ) ? absint( $_GET['delete_csv'] ) : false );
$csv = ( ! empty( $_GET['csv'] ) ? absint( $_GET['csv'] ) : false );
if ( ! empty( $delete_csv ) && ! empty( $csv ) ) {
$dry_run = isset( $_GET['dry_run'] ) ? absint( $_GET['dry_run'] ) : 1;
if ( ! empty( $delete_csv ) && ! empty( $csv ) && empty( $dry_run ) ) {
wp_delete_attachment( $csv, true );
}

Expand Down Expand Up @@ -280,7 +281,7 @@ public function import_success() {
$total = (int) $_GET['total'];
-- $total;
$success = (bool) $_GET['success'];
$dry_run = empty( $_GET['dry_run'] ) ? 0 : absint( $_GET['dry_run'] );

?>
<tr valign="top" class="give-import-dropdown">
<th colspan="2">
Expand Down Expand Up @@ -309,19 +310,30 @@ public function import_success() {

<?php
$text = __( 'Import Donation', 'give' );

$query_arg = array(
'post_type' => 'give_forms',
'page' => 'give-tools',
'tab' => 'import',
);

if ( $success ) {
$query_arg = array(
'post_type' => 'give_forms',
'page' => 'give-payment-history',
);
$text = __( 'View Donations', 'give' );
if ( $dry_run ) {
$text = __( 'Begin Actual Import', 'give' );
$query_arg['step'] = 2;
$query_arg['dry_run'] = 0;

} else {
$text = __( 'View Donations', 'give' );
$query_arg = array(
'post_type' => 'give_forms',
'page' => 'give-payment-history',
);
}
}

$url = add_query_arg( $query_arg );

foreach ( $report as $key => $value ) {
if ( array_key_exists( $key, $report_html ) && ! empty( $value ) ) {
?>
Expand All @@ -332,10 +344,9 @@ public function import_success() {
}
}
?>

<p>
<a class="button button-large button-secondary"
href="<?php echo add_query_arg( $query_arg, admin_url( 'edit.php' ) ); ?>"><?php echo $text; ?></a>
href="<?php echo $url; ?>"><?php echo $text; ?></a>
</p>
</th>
</tr>
Expand Down Expand Up @@ -974,7 +985,7 @@ public function save() {
'1' :
( give_is_setting_enabled( give_clean( $_POST['delete_csv'] ) ) ? '1' : '0' ),
'per_page' => isset( $_POST['per_page'] ) ? absint( $_POST['per_page'] ) : self::$per_page,
'dry_run' => isset( $_POST['dry_run'] ) ? absint( $_POST['dry_run'] ) : 0,
'dry_run' => isset( $_POST['dry_run'] ) ? absint( $_POST['dry_run'] ) : 1,
) ) );

$this->is_csv_valid = $url;
Expand Down

0 comments on commit 41f5840

Please sign in to comment.