Commit 5e3b8a23 authored by Michael Iseard's avatar Michael Iseard
Browse files

Update campaigns

parent a14a6b04
......@@ -98,13 +98,11 @@ class CampaignsTable extends WP_List_Table {
$campaign_total = $this->campaigns::get_campaign_stats( $id );
$campaigns[ $key ]['date'] = date( "r", hexdec( substr( $id, 3, 8 ) ) );
$campaigns[ $key ]['transactions'] = 0;
$campaigns[ $key ]['goal'] = $campaign['campaign_goal'];
$campaigns[ $key ]['date'] = $campaign_total['last_donation'];
$campaigns[ $key ]['goal'] = !empty($campaign['campaign_goal']) ? $campaign['campaign_goal'] : null;
$campaigns[ $key ]['total'] = 0;
$campaigns[ $key ]['currency'] = 'EUR';
$campaigns[ $key ]['total'] = $campaign_total['total'];
$campaigns[ $key ]['last_donation'] = $campaign_total['last_donation'];
$campaigns[ $key ]['transactions'] = $campaign_total['count'];
}
......@@ -119,12 +117,11 @@ class CampaignsTable extends WP_List_Table {
*/
public function column_names(): array {
return [
'date' => __( 'Date', 'kudos-donations' ),
'name' => __( 'Name', 'kudos-donations' ),
'transactions' => __( 'Transactions', 'kudos-donations' ),
'total' => __( 'Total', 'kudos-donations' ),
'goal' => __( 'Goal', 'kudos-donations' ),
'last_donation' => __( 'Last Donation', 'kudos-donations' ),
'date' => __( 'Last donation', 'kudos-donations' ),
];
}
......@@ -136,7 +133,6 @@ class CampaignsTable extends WP_List_Table {
*/
public function get_hidden_columns(): array {
return [
'date',
'subscription_id',
'id',
];
......@@ -158,10 +154,6 @@ class CampaignsTable extends WP_List_Table {
'total',
false,
],
'last_donation' => [
'last_donation',
false,
],
];
}
......@@ -190,9 +182,9 @@ class CampaignsTable extends WP_List_Table {
*/
protected function column_date( array $item ): string {
return __( 'Added', 'kudos-donations' ) . '<br/>' .
wp_date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ),
strtotime( $item['date'] ) );
return isset( $item['date'] ) ? wp_date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ),
strtotime( $item['date'] ) ) : sprintf( "<i>%s</i>", __( 'None yet', 'kudos-donations' ) );
}
/**
......@@ -273,22 +265,7 @@ class CampaignsTable extends WP_List_Table {
$currency = ! empty( $item['currency'] ) ? Utils::get_currency_symbol( $item['currency'] ) : '';
$total = $item['goal'];
return $currency . ' ' . ( is_numeric( $total ) ? number_format_i18n( $total, 2 ) : '' );
}
/**
* Shows the date of the last translation
*
* @param array $item Array of results.
*
* @return string
* @since 2.0.5
*/
protected function column_last_donation( array $item ): string {
return isset( $item['last_donation'] ) ? wp_date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ),
strtotime( $item['last_donation'] ) ) : sprintf( "<i>%s</i>", __( 'None yet', 'kudos-donations' ) );
return $total ? $currency . ' ' . ( is_numeric( $total ) ? number_format_i18n( $total, 2 ) : '' ) : '';
}
}
......@@ -35,7 +35,7 @@ class Campaigns {
foreach ( $campaigns as $key => $form ) {
if ( ! array_search( 'id', $form ) ) {
$output[ $key ]['id'] = $this->generate_id( $form['name'] );
$output[ $key ]['id'] = $this->generate_id( $form['name'] );
}
foreach ( $form as $option => $value ) {
......
......@@ -99,7 +99,7 @@ class Settings {
],
'theme_colors' => [
'type' => 'object',
'default' => [
'default' => [
'primary' => '#ff9f1c',
'secondary' => '#2ec4b6',
],
......@@ -115,7 +115,7 @@ class Settings {
],
],
],
]
],
],
'address_enabled' => [
'type' => 'boolean',
......@@ -226,7 +226,7 @@ class Settings {
],
],
],
'default' => [
'default' => [
0 => [
'id' => 'default',
'name' => 'Default',
......@@ -236,6 +236,7 @@ class Settings {
'address_required' => true,
'amount_type' => 'both',
'fixed_amounts' => '1,5,20,50',
'campaign_goal' => '',
'donation_type' => 'both',
'protected' => true,
],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment