@@ -10,7 +10,7 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -33,11 +33,11 @@ discard block |
||
| 33 | 33 | /* @var WPDB $wpdb */ |
| 34 | 34 | global $wpdb; |
| 35 | 35 | |
| 36 | - $this->table_name = $wpdb->prefix . 'give_customermeta'; |
|
| 36 | + $this->table_name = $wpdb->prefix.'give_customermeta'; |
|
| 37 | 37 | $this->primary_key = 'meta_id'; |
| 38 | 38 | $this->version = '1.0'; |
| 39 | 39 | |
| 40 | - add_action( 'plugins_loaded', array( $this, 'register_table' ), 11 ); |
|
| 40 | + add_action('plugins_loaded', array($this, 'register_table'), 11); |
|
| 41 | 41 | |
| 42 | 42 | } |
| 43 | 43 | |
@@ -85,13 +85,13 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
| 87 | 87 | */ |
| 88 | - public function get_meta( $customer_id = 0, $meta_key = '', $single = false ) { |
|
| 89 | - $customer_id = $this->sanitize_customer_id( $customer_id ); |
|
| 90 | - if ( false === $customer_id ) { |
|
| 88 | + public function get_meta($customer_id = 0, $meta_key = '', $single = false) { |
|
| 89 | + $customer_id = $this->sanitize_customer_id($customer_id); |
|
| 90 | + if (false === $customer_id) { |
|
| 91 | 91 | return false; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - return get_metadata( 'customer', $customer_id, $meta_key, $single ); |
|
| 94 | + return get_metadata('customer', $customer_id, $meta_key, $single); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -109,13 +109,13 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @return bool False for failure. True for success. |
| 111 | 111 | */ |
| 112 | - public function add_meta( $customer_id = 0, $meta_key = '', $meta_value, $unique = false ) { |
|
| 113 | - $customer_id = $this->sanitize_customer_id( $customer_id ); |
|
| 114 | - if ( false === $customer_id ) { |
|
| 112 | + public function add_meta($customer_id = 0, $meta_key = '', $meta_value, $unique = false) { |
|
| 113 | + $customer_id = $this->sanitize_customer_id($customer_id); |
|
| 114 | + if (false === $customer_id) { |
|
| 115 | 115 | return false; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - return add_metadata( 'customer', $customer_id, $meta_key, $meta_value, $unique ); |
|
| 118 | + return add_metadata('customer', $customer_id, $meta_key, $meta_value, $unique); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -138,13 +138,13 @@ discard block |
||
| 138 | 138 | * |
| 139 | 139 | * @return bool False on failure, true if success. |
| 140 | 140 | */ |
| 141 | - public function update_meta( $customer_id = 0, $meta_key = '', $meta_value, $prev_value = '' ) { |
|
| 142 | - $customer_id = $this->sanitize_customer_id( $customer_id ); |
|
| 143 | - if ( false === $customer_id ) { |
|
| 141 | + public function update_meta($customer_id = 0, $meta_key = '', $meta_value, $prev_value = '') { |
|
| 142 | + $customer_id = $this->sanitize_customer_id($customer_id); |
|
| 143 | + if (false === $customer_id) { |
|
| 144 | 144 | return false; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - return update_metadata( 'customer', $customer_id, $meta_key, $meta_value, $prev_value ); |
|
| 147 | + return update_metadata('customer', $customer_id, $meta_key, $meta_value, $prev_value); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -165,8 +165,8 @@ discard block |
||
| 165 | 165 | * |
| 166 | 166 | * @return bool False for failure. True for success. |
| 167 | 167 | */ |
| 168 | - public function delete_meta( $customer_id = 0, $meta_key = '', $meta_value = '' ) { |
|
| 169 | - return delete_metadata( 'customer', $customer_id, $meta_key, $meta_value ); |
|
| 168 | + public function delete_meta($customer_id = 0, $meta_key = '', $meta_value = '') { |
|
| 169 | + return delete_metadata('customer', $customer_id, $meta_key, $meta_value); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | public function create_table() { |
| 181 | 181 | |
| 182 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 182 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 183 | 183 | |
| 184 | 184 | $sql = "CREATE TABLE {$this->table_name} ( |
| 185 | 185 | meta_id bigint(20) NOT NULL AUTO_INCREMENT, |
@@ -191,9 +191,9 @@ discard block |
||
| 191 | 191 | KEY meta_key (meta_key) |
| 192 | 192 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
| 193 | 193 | |
| 194 | - dbDelta( $sql ); |
|
| 194 | + dbDelta($sql); |
|
| 195 | 195 | |
| 196 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
| 196 | + update_option($this->table_name.'_db_version', $this->version); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | /** |
@@ -206,23 +206,23 @@ discard block |
||
| 206 | 206 | * |
| 207 | 207 | * @return int|bool The normalized customer ID or false if it's found to not be valid. |
| 208 | 208 | */ |
| 209 | - private function sanitize_customer_id( $customer_id ) { |
|
| 210 | - if ( ! is_numeric( $customer_id ) ) { |
|
| 209 | + private function sanitize_customer_id($customer_id) { |
|
| 210 | + if ( ! is_numeric($customer_id)) { |
|
| 211 | 211 | return false; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | $customer_id = (int) $customer_id; |
| 215 | 215 | |
| 216 | 216 | // We were given a non positive number |
| 217 | - if ( absint( $customer_id ) !== $customer_id ) { |
|
| 217 | + if (absint($customer_id) !== $customer_id) { |
|
| 218 | 218 | return false; |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - if ( empty( $customer_id ) ) { |
|
| 221 | + if (empty($customer_id)) { |
|
| 222 | 222 | return false; |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - return absint( $customer_id ); |
|
| 225 | + return absint($customer_id); |
|
| 226 | 226 | |
| 227 | 227 | } |
| 228 | 228 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -93,19 +93,19 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function get_predefined_dates() { |
| 95 | 95 | $predefined = array( |
| 96 | - 'today' => esc_html__( 'Today', 'give' ), |
|
| 97 | - 'yesterday' => esc_html__( 'Yesterday', 'give' ), |
|
| 98 | - 'this_week' => esc_html__( 'This Week', 'give' ), |
|
| 99 | - 'last_week' => esc_html__( 'Last Week', 'give' ), |
|
| 100 | - 'this_month' => esc_html__( 'This Month', 'give' ), |
|
| 101 | - 'last_month' => esc_html__( 'Last Month', 'give' ), |
|
| 102 | - 'this_quarter' => esc_html__( 'This Quarter', 'give' ), |
|
| 103 | - 'last_quarter' => esc_html__( 'Last Quarter', 'give' ), |
|
| 104 | - 'this_year' => esc_html__( 'This Year', 'give' ), |
|
| 105 | - 'last_year' => esc_html__( 'Last Year', 'give' ) |
|
| 96 | + 'today' => esc_html__('Today', 'give'), |
|
| 97 | + 'yesterday' => esc_html__('Yesterday', 'give'), |
|
| 98 | + 'this_week' => esc_html__('This Week', 'give'), |
|
| 99 | + 'last_week' => esc_html__('Last Week', 'give'), |
|
| 100 | + 'this_month' => esc_html__('This Month', 'give'), |
|
| 101 | + 'last_month' => esc_html__('Last Month', 'give'), |
|
| 102 | + 'this_quarter' => esc_html__('This Quarter', 'give'), |
|
| 103 | + 'last_quarter' => esc_html__('Last Quarter', 'give'), |
|
| 104 | + 'this_year' => esc_html__('This Year', 'give'), |
|
| 105 | + 'last_year' => esc_html__('Last Year', 'give') |
|
| 106 | 106 | ); |
| 107 | 107 | |
| 108 | - return apply_filters( 'give_stats_predefined_dates', $predefined ); |
|
| 108 | + return apply_filters('give_stats_predefined_dates', $predefined); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -121,18 +121,18 @@ discard block |
||
| 121 | 121 | * |
| 122 | 122 | * @return void |
| 123 | 123 | */ |
| 124 | - public function setup_dates( $_start_date = 'this_month', $_end_date = false ) { |
|
| 124 | + public function setup_dates($_start_date = 'this_month', $_end_date = false) { |
|
| 125 | 125 | |
| 126 | - if ( empty( $_start_date ) ) { |
|
| 126 | + if (empty($_start_date)) { |
|
| 127 | 127 | $_start_date = 'this_month'; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - if ( empty( $_end_date ) ) { |
|
| 130 | + if (empty($_end_date)) { |
|
| 131 | 131 | $_end_date = $_start_date; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - $this->start_date = $this->convert_date( $_start_date ); |
|
| 135 | - $this->end_date = $this->convert_date( $_end_date, true ); |
|
| 134 | + $this->start_date = $this->convert_date($_start_date); |
|
| 135 | + $this->end_date = $this->convert_date($_end_date, true); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -148,26 +148,26 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @return array|WP_Error If the date is invalid, a WP_Error object will be returned. |
| 150 | 150 | */ |
| 151 | - public function convert_date( $date, $end_date = false ) { |
|
| 151 | + public function convert_date($date, $end_date = false) { |
|
| 152 | 152 | |
| 153 | 153 | $this->timestamp = false; |
| 154 | 154 | $second = $end_date ? 59 : 0; |
| 155 | 155 | $minute = $end_date ? 59 : 0; |
| 156 | 156 | $hour = $end_date ? 23 : 0; |
| 157 | 157 | $day = 1; |
| 158 | - $month = date( 'n', current_time( 'timestamp' ) ); |
|
| 159 | - $year = date( 'Y', current_time( 'timestamp' ) ); |
|
| 158 | + $month = date('n', current_time('timestamp')); |
|
| 159 | + $year = date('Y', current_time('timestamp')); |
|
| 160 | 160 | |
| 161 | - if ( array_key_exists( $date, $this->get_predefined_dates() ) ) { |
|
| 161 | + if (array_key_exists($date, $this->get_predefined_dates())) { |
|
| 162 | 162 | |
| 163 | 163 | // This is a predefined date rate, such as last_week |
| 164 | - switch ( $date ) { |
|
| 164 | + switch ($date) { |
|
| 165 | 165 | |
| 166 | 166 | case 'this_month' : |
| 167 | 167 | |
| 168 | - if ( $end_date ) { |
|
| 168 | + if ($end_date) { |
|
| 169 | 169 | |
| 170 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 170 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 171 | 171 | $hour = 23; |
| 172 | 172 | $minute = 59; |
| 173 | 173 | $second = 59; |
@@ -177,28 +177,28 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | case 'last_month' : |
| 179 | 179 | |
| 180 | - if ( $month == 1 ) { |
|
| 180 | + if ($month == 1) { |
|
| 181 | 181 | |
| 182 | 182 | $month = 12; |
| 183 | - $year --; |
|
| 183 | + $year--; |
|
| 184 | 184 | |
| 185 | 185 | } else { |
| 186 | 186 | |
| 187 | - $month --; |
|
| 187 | + $month--; |
|
| 188 | 188 | |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - if ( $end_date ) { |
|
| 192 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 191 | + if ($end_date) { |
|
| 192 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | break; |
| 196 | 196 | |
| 197 | 197 | case 'today' : |
| 198 | 198 | |
| 199 | - $day = date( 'd', current_time( 'timestamp' ) ); |
|
| 199 | + $day = date('d', current_time('timestamp')); |
|
| 200 | 200 | |
| 201 | - if ( $end_date ) { |
|
| 201 | + if ($end_date) { |
|
| 202 | 202 | $hour = 23; |
| 203 | 203 | $minute = 59; |
| 204 | 204 | $second = 59; |
@@ -208,23 +208,23 @@ discard block |
||
| 208 | 208 | |
| 209 | 209 | case 'yesterday' : |
| 210 | 210 | |
| 211 | - $day = date( 'd', current_time( 'timestamp' ) ) - 1; |
|
| 211 | + $day = date('d', current_time('timestamp')) - 1; |
|
| 212 | 212 | |
| 213 | 213 | // Check if Today is the first day of the month (meaning subtracting one will get us 0) |
| 214 | - if ( $day < 1 ) { |
|
| 214 | + if ($day < 1) { |
|
| 215 | 215 | |
| 216 | 216 | // If current month is 1 |
| 217 | - if ( 1 == $month ) { |
|
| 217 | + if (1 == $month) { |
|
| 218 | 218 | |
| 219 | 219 | $year -= 1; // Today is January 1, so skip back to last day of December |
| 220 | 220 | $month = 12; |
| 221 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 221 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 222 | 222 | |
| 223 | 223 | } else { |
| 224 | 224 | |
| 225 | 225 | // Go back one month and get the last day of the month |
| 226 | 226 | $month -= 1; |
| 227 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 227 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 228 | 228 | |
| 229 | 229 | } |
| 230 | 230 | } |
@@ -233,12 +233,12 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | case 'this_week' : |
| 235 | 235 | |
| 236 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
| 237 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
| 236 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
| 237 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
| 238 | 238 | |
| 239 | - if ( $today < $days_to_week_start ) { |
|
| 239 | + if ($today < $days_to_week_start) { |
|
| 240 | 240 | |
| 241 | - if ( $month > 1 ) { |
|
| 241 | + if ($month > 1) { |
|
| 242 | 242 | $month -= 1; |
| 243 | 243 | } else { |
| 244 | 244 | $month = 12; |
@@ -246,19 +246,19 @@ discard block |
||
| 246 | 246 | |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - if ( ! $end_date ) { |
|
| 249 | + if ( ! $end_date) { |
|
| 250 | 250 | |
| 251 | 251 | // Getting the start day |
| 252 | 252 | |
| 253 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
| 254 | - $day += get_option( 'start_of_week' ); |
|
| 253 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
| 254 | + $day += get_option('start_of_week'); |
|
| 255 | 255 | |
| 256 | 256 | } else { |
| 257 | 257 | |
| 258 | 258 | // Getting the end day |
| 259 | 259 | |
| 260 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
| 261 | - $day += get_option( 'start_of_week' ) + 6; |
|
| 260 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
| 261 | + $day += get_option('start_of_week') + 6; |
|
| 262 | 262 | |
| 263 | 263 | } |
| 264 | 264 | |
@@ -266,12 +266,12 @@ discard block |
||
| 266 | 266 | |
| 267 | 267 | case 'last_week' : |
| 268 | 268 | |
| 269 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
| 270 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
| 269 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
| 270 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
| 271 | 271 | |
| 272 | - if ( $today < $days_to_week_start ) { |
|
| 272 | + if ($today < $days_to_week_start) { |
|
| 273 | 273 | |
| 274 | - if ( $month > 1 ) { |
|
| 274 | + if ($month > 1) { |
|
| 275 | 275 | $month -= 1; |
| 276 | 276 | } else { |
| 277 | 277 | $month = 12; |
@@ -279,19 +279,19 @@ discard block |
||
| 279 | 279 | |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - if ( ! $end_date ) { |
|
| 282 | + if ( ! $end_date) { |
|
| 283 | 283 | |
| 284 | 284 | // Getting the start day |
| 285 | 285 | |
| 286 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
| 287 | - $day += get_option( 'start_of_week' ); |
|
| 286 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
| 287 | + $day += get_option('start_of_week'); |
|
| 288 | 288 | |
| 289 | 289 | } else { |
| 290 | 290 | |
| 291 | 291 | // Getting the end day |
| 292 | 292 | |
| 293 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
| 294 | - $day += get_option( 'start_of_week' ) + 6; |
|
| 293 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
| 294 | + $day += get_option('start_of_week') + 6; |
|
| 295 | 295 | |
| 296 | 296 | } |
| 297 | 297 | |
@@ -299,39 +299,39 @@ discard block |
||
| 299 | 299 | |
| 300 | 300 | case 'this_quarter' : |
| 301 | 301 | |
| 302 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
| 302 | + $month_now = date('n', current_time('timestamp')); |
|
| 303 | 303 | |
| 304 | - if ( $month_now <= 3 ) { |
|
| 304 | + if ($month_now <= 3) { |
|
| 305 | 305 | |
| 306 | - if ( ! $end_date ) { |
|
| 306 | + if ( ! $end_date) { |
|
| 307 | 307 | $month = 1; |
| 308 | 308 | } else { |
| 309 | 309 | $month = 3; |
| 310 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 310 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 311 | 311 | $hour = 23; |
| 312 | 312 | $minute = 59; |
| 313 | 313 | $second = 59; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - } else if ( $month_now <= 6 ) { |
|
| 316 | + } else if ($month_now <= 6) { |
|
| 317 | 317 | |
| 318 | - if ( ! $end_date ) { |
|
| 318 | + if ( ! $end_date) { |
|
| 319 | 319 | $month = 4; |
| 320 | 320 | } else { |
| 321 | 321 | $month = 6; |
| 322 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 322 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 323 | 323 | $hour = 23; |
| 324 | 324 | $minute = 59; |
| 325 | 325 | $second = 59; |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - } else if ( $month_now <= 9 ) { |
|
| 328 | + } else if ($month_now <= 9) { |
|
| 329 | 329 | |
| 330 | - if ( ! $end_date ) { |
|
| 330 | + if ( ! $end_date) { |
|
| 331 | 331 | $month = 7; |
| 332 | 332 | } else { |
| 333 | 333 | $month = 9; |
| 334 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 334 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 335 | 335 | $hour = 23; |
| 336 | 336 | $minute = 59; |
| 337 | 337 | $second = 59; |
@@ -339,11 +339,11 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | } else { |
| 341 | 341 | |
| 342 | - if ( ! $end_date ) { |
|
| 342 | + if ( ! $end_date) { |
|
| 343 | 343 | $month = 10; |
| 344 | 344 | } else { |
| 345 | 345 | $month = 12; |
| 346 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 346 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 347 | 347 | $hour = 23; |
| 348 | 348 | $minute = 59; |
| 349 | 349 | $second = 59; |
@@ -355,40 +355,40 @@ discard block |
||
| 355 | 355 | |
| 356 | 356 | case 'last_quarter' : |
| 357 | 357 | |
| 358 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
| 358 | + $month_now = date('n', current_time('timestamp')); |
|
| 359 | 359 | |
| 360 | - if ( $month_now <= 3 ) { |
|
| 360 | + if ($month_now <= 3) { |
|
| 361 | 361 | |
| 362 | - if ( ! $end_date ) { |
|
| 362 | + if ( ! $end_date) { |
|
| 363 | 363 | $month = 10; |
| 364 | 364 | } else { |
| 365 | 365 | $year -= 1; |
| 366 | 366 | $month = 12; |
| 367 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 367 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 368 | 368 | $hour = 23; |
| 369 | 369 | $minute = 59; |
| 370 | 370 | $second = 59; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - } else if ( $month_now <= 6 ) { |
|
| 373 | + } else if ($month_now <= 6) { |
|
| 374 | 374 | |
| 375 | - if ( ! $end_date ) { |
|
| 375 | + if ( ! $end_date) { |
|
| 376 | 376 | $month = 1; |
| 377 | 377 | } else { |
| 378 | 378 | $month = 3; |
| 379 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 379 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 380 | 380 | $hour = 23; |
| 381 | 381 | $minute = 59; |
| 382 | 382 | $second = 59; |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - } else if ( $month_now <= 9 ) { |
|
| 385 | + } else if ($month_now <= 9) { |
|
| 386 | 386 | |
| 387 | - if ( ! $end_date ) { |
|
| 387 | + if ( ! $end_date) { |
|
| 388 | 388 | $month = 4; |
| 389 | 389 | } else { |
| 390 | 390 | $month = 6; |
| 391 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 391 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 392 | 392 | $hour = 23; |
| 393 | 393 | $minute = 59; |
| 394 | 394 | $second = 59; |
@@ -396,11 +396,11 @@ discard block |
||
| 396 | 396 | |
| 397 | 397 | } else { |
| 398 | 398 | |
| 399 | - if ( ! $end_date ) { |
|
| 399 | + if ( ! $end_date) { |
|
| 400 | 400 | $month = 7; |
| 401 | 401 | } else { |
| 402 | 402 | $month = 9; |
| 403 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 403 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 404 | 404 | $hour = 23; |
| 405 | 405 | $minute = 59; |
| 406 | 406 | $second = 59; |
@@ -412,11 +412,11 @@ discard block |
||
| 412 | 412 | |
| 413 | 413 | case 'this_year' : |
| 414 | 414 | |
| 415 | - if ( ! $end_date ) { |
|
| 415 | + if ( ! $end_date) { |
|
| 416 | 416 | $month = 1; |
| 417 | 417 | } else { |
| 418 | 418 | $month = 12; |
| 419 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 419 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 420 | 420 | $hour = 23; |
| 421 | 421 | $minute = 59; |
| 422 | 422 | $second = 59; |
@@ -427,11 +427,11 @@ discard block |
||
| 427 | 427 | case 'last_year' : |
| 428 | 428 | |
| 429 | 429 | $year -= 1; |
| 430 | - if ( ! $end_date ) { |
|
| 430 | + if ( ! $end_date) { |
|
| 431 | 431 | $month = 1; |
| 432 | 432 | } else { |
| 433 | 433 | $month = 12; |
| 434 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 434 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 435 | 435 | $hour = 23; |
| 436 | 436 | $minute = 59; |
| 437 | 437 | $second = 59; |
@@ -442,30 +442,30 @@ discard block |
||
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | |
| 445 | - } else if ( is_numeric( $date ) ) { |
|
| 445 | + } else if (is_numeric($date)) { |
|
| 446 | 446 | |
| 447 | 447 | // return $date unchanged since it is a timestamp |
| 448 | 448 | $this->timestamp = true; |
| 449 | 449 | |
| 450 | - } else if ( false !== strtotime( $date ) ) { |
|
| 450 | + } else if (false !== strtotime($date)) { |
|
| 451 | 451 | |
| 452 | - $date = strtotime( $date, current_time( 'timestamp' ) ); |
|
| 453 | - $year = date( 'Y', $date ); |
|
| 454 | - $month = date( 'm', $date ); |
|
| 455 | - $day = date( 'd', $date ); |
|
| 452 | + $date = strtotime($date, current_time('timestamp')); |
|
| 453 | + $year = date('Y', $date); |
|
| 454 | + $month = date('m', $date); |
|
| 455 | + $day = date('d', $date); |
|
| 456 | 456 | |
| 457 | 457 | } else { |
| 458 | 458 | |
| 459 | - return new WP_Error( 'invalid_date', esc_html__( 'Improper date provided.', 'give' ) ); |
|
| 459 | + return new WP_Error('invalid_date', esc_html__('Improper date provided.', 'give')); |
|
| 460 | 460 | |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | - if ( false === $this->timestamp ) { |
|
| 463 | + if (false === $this->timestamp) { |
|
| 464 | 464 | // Create an exact timestamp |
| 465 | - $date = mktime( $hour, $minute, $second, $month, $day, $year ); |
|
| 465 | + $date = mktime($hour, $minute, $second, $month, $day, $year); |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - return apply_filters( 'give_stats_date', $date, $end_date, $this ); |
|
| 468 | + return apply_filters('give_stats_date', $date, $end_date, $this); |
|
| 469 | 469 | |
| 470 | 470 | } |
| 471 | 471 | |
@@ -481,33 +481,33 @@ discard block |
||
| 481 | 481 | * |
| 482 | 482 | * @return string |
| 483 | 483 | */ |
| 484 | - public function count_where( $where = '' ) { |
|
| 484 | + public function count_where($where = '') { |
|
| 485 | 485 | // Only get payments in our date range |
| 486 | 486 | |
| 487 | 487 | $start_where = ''; |
| 488 | 488 | $end_where = ''; |
| 489 | 489 | |
| 490 | - if ( $this->start_date ) { |
|
| 490 | + if ($this->start_date) { |
|
| 491 | 491 | |
| 492 | - if ( $this->timestamp ) { |
|
| 492 | + if ($this->timestamp) { |
|
| 493 | 493 | $format = 'Y-m-d H:i:s'; |
| 494 | 494 | } else { |
| 495 | 495 | $format = 'Y-m-d 00:00:00'; |
| 496 | 496 | } |
| 497 | 497 | |
| 498 | - $start_date = date( $format, $this->start_date ); |
|
| 498 | + $start_date = date($format, $this->start_date); |
|
| 499 | 499 | $start_where = " AND p.post_date >= '{$start_date}'"; |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | - if ( $this->end_date ) { |
|
| 502 | + if ($this->end_date) { |
|
| 503 | 503 | |
| 504 | - if ( $this->timestamp ) { |
|
| 504 | + if ($this->timestamp) { |
|
| 505 | 505 | $format = 'Y-m-d H:i:s'; |
| 506 | 506 | } else { |
| 507 | 507 | $format = 'Y-m-d 23:59:59'; |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | - $end_date = date( $format, $this->end_date ); |
|
| 510 | + $end_date = date($format, $this->end_date); |
|
| 511 | 511 | |
| 512 | 512 | $end_where = " AND p.post_date <= '{$end_date}'"; |
| 513 | 513 | } |
@@ -529,34 +529,34 @@ discard block |
||
| 529 | 529 | * |
| 530 | 530 | * @return string |
| 531 | 531 | */ |
| 532 | - public function payments_where( $where = '' ) { |
|
| 532 | + public function payments_where($where = '') { |
|
| 533 | 533 | |
| 534 | 534 | global $wpdb; |
| 535 | 535 | |
| 536 | 536 | $start_where = ''; |
| 537 | 537 | $end_where = ''; |
| 538 | 538 | |
| 539 | - if ( ! is_wp_error( $this->start_date ) ) { |
|
| 539 | + if ( ! is_wp_error($this->start_date)) { |
|
| 540 | 540 | |
| 541 | - if ( $this->timestamp ) { |
|
| 541 | + if ($this->timestamp) { |
|
| 542 | 542 | $format = 'Y-m-d H:i:s'; |
| 543 | 543 | } else { |
| 544 | 544 | $format = 'Y-m-d 00:00:00'; |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | - $start_date = date( $format, $this->start_date ); |
|
| 547 | + $start_date = date($format, $this->start_date); |
|
| 548 | 548 | $start_where = " AND $wpdb->posts.post_date >= '{$start_date}'"; |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | - if ( ! is_wp_error( $this->end_date ) ) { |
|
| 551 | + if ( ! is_wp_error($this->end_date)) { |
|
| 552 | 552 | |
| 553 | - if ( $this->timestamp ) { |
|
| 553 | + if ($this->timestamp) { |
|
| 554 | 554 | $format = 'Y-m-d 00:00:00'; |
| 555 | 555 | } else { |
| 556 | 556 | $format = 'Y-m-d 23:59:59'; |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | - $end_date = date( $format, $this->end_date ); |
|
| 559 | + $end_date = date($format, $this->end_date); |
|
| 560 | 560 | |
| 561 | 561 | $end_where = " AND $wpdb->posts.post_date <= '{$end_date}'"; |
| 562 | 562 | } |
@@ -7,12 +7,12 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // Exit if accessed directly. |
| 10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 10 | +if ( ! defined('ABSPATH')) { |
|
| 11 | 11 | exit; |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | // Add give command. |
| 15 | -WP_CLI::add_command( 'give', 'GIVE_CLI_COMMAND' ); |
|
| 15 | +WP_CLI::add_command('give', 'GIVE_CLI_COMMAND'); |
|
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | /** |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @subcommand logo |
| 70 | 70 | */ |
| 71 | - public function ascii( $args, $assoc_args ) { |
|
| 72 | - WP_CLI::log( file_get_contents( GIVE_PLUGIN_DIR . 'assets/images/give-ascii-logo.txt' ) ); |
|
| 71 | + public function ascii($args, $assoc_args) { |
|
| 72 | + WP_CLI::log(file_get_contents(GIVE_PLUGIN_DIR.'assets/images/give-ascii-logo.txt')); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | |
@@ -94,54 +94,54 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @subcommand details |
| 96 | 96 | */ |
| 97 | - public function details( $args, $assoc_args ) { |
|
| 97 | + public function details($args, $assoc_args) { |
|
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * Plugin Information |
| 101 | 101 | */ |
| 102 | - WP_CLI::log( $this->color_message( __( 'Give Version: ', 'give' ) ) . GIVE_VERSION ); |
|
| 102 | + WP_CLI::log($this->color_message(__('Give Version: ', 'give')).GIVE_VERSION); |
|
| 103 | 103 | |
| 104 | 104 | /** |
| 105 | 105 | * General Information. |
| 106 | 106 | */ |
| 107 | - WP_CLI::log( "\n#### " . $this->color_message( __( 'General information', 'give' ) ) . ' ####' ); |
|
| 107 | + WP_CLI::log("\n#### ".$this->color_message(__('General information', 'give')).' ####'); |
|
| 108 | 108 | |
| 109 | - $success_page = give_get_option( 'success_page' ); |
|
| 110 | - $failure_page = give_get_option( 'failure_page' ); |
|
| 111 | - $history_page = give_get_option( 'history_page' ); |
|
| 109 | + $success_page = give_get_option('success_page'); |
|
| 110 | + $failure_page = give_get_option('failure_page'); |
|
| 111 | + $history_page = give_get_option('history_page'); |
|
| 112 | 112 | |
| 113 | - WP_CLI::log( $this->color_message( sprintf( __( 'Success Page: ', 'give' ) ) ) . ( $success_page ? "[{$success_page}] " . get_permalink( $success_page ) : __( 'Not Set', 'give' ) ) ); |
|
| 114 | - WP_CLI::log( $this->color_message( __( 'Failed Donation Page: ', 'give' ) ) . ( $failure_page ? "[{$failure_page}] " . get_permalink( $failure_page ) : __( 'Not Set', 'give' ) ) ); |
|
| 115 | - WP_CLI::log( $this->color_message( __( 'Donation History Page: ', 'give' ) ) . ( $history_page ? "[{$history_page}] " . get_permalink( $history_page ) : __( 'Not Set', 'give' ) ) ); |
|
| 116 | - WP_CLI::log( $this->color_message( __( 'Country: ', 'give' ) ) . give_get_country() ); |
|
| 113 | + WP_CLI::log($this->color_message(sprintf(__('Success Page: ', 'give'))).($success_page ? "[{$success_page}] ".get_permalink($success_page) : __('Not Set', 'give'))); |
|
| 114 | + WP_CLI::log($this->color_message(__('Failed Donation Page: ', 'give')).($failure_page ? "[{$failure_page}] ".get_permalink($failure_page) : __('Not Set', 'give'))); |
|
| 115 | + WP_CLI::log($this->color_message(__('Donation History Page: ', 'give')).($history_page ? "[{$history_page}] ".get_permalink($history_page) : __('Not Set', 'give'))); |
|
| 116 | + WP_CLI::log($this->color_message(__('Country: ', 'give')).give_get_country()); |
|
| 117 | 117 | |
| 118 | 118 | /** |
| 119 | 119 | * Currency Information. |
| 120 | 120 | */ |
| 121 | - $default_gateway = give_get_option( 'default_gateway' ); |
|
| 121 | + $default_gateway = give_get_option('default_gateway'); |
|
| 122 | 122 | |
| 123 | - WP_CLI::log( "\n#### " . $this->color_message( __( 'Currency Information', 'give' ) ) . ' ####' ); |
|
| 123 | + WP_CLI::log("\n#### ".$this->color_message(__('Currency Information', 'give')).' ####'); |
|
| 124 | 124 | |
| 125 | - WP_CLI::log( $this->color_message( __( 'Currency: ', 'give' ), give_get_currency() ) ); |
|
| 126 | - WP_CLI::log( $this->color_message( __( 'Currency Position: ', 'give' ), give_get_currency_position() ) ); |
|
| 127 | - WP_CLI::log( $this->color_message( __( 'Thousand Separator: ', 'give' ), give_get_price_thousand_separator() ) ); |
|
| 128 | - WP_CLI::log( $this->color_message( __( 'Decimal Separator: ', 'give' ), give_get_price_decimal_separator() ) ); |
|
| 129 | - WP_CLI::log( $this->color_message( __( 'Number of Decimals: ', 'give' ), give_get_price_decimals() ) ); |
|
| 130 | - WP_CLI::log( $this->color_message( __( 'Test Mode: ', 'give' ), ( give_get_option( 'test_mode' ) ? __( 'Yes', 'give' ) : __( 'No', 'give' ) ) ) ); |
|
| 131 | - WP_CLI::log( $this->color_message( __( 'Default Gateway: ', 'give' ), ( $default_gateway ? $default_gateway : __( 'Not Set', 'give' ) ) ) ); |
|
| 125 | + WP_CLI::log($this->color_message(__('Currency: ', 'give'), give_get_currency())); |
|
| 126 | + WP_CLI::log($this->color_message(__('Currency Position: ', 'give'), give_get_currency_position())); |
|
| 127 | + WP_CLI::log($this->color_message(__('Thousand Separator: ', 'give'), give_get_price_thousand_separator())); |
|
| 128 | + WP_CLI::log($this->color_message(__('Decimal Separator: ', 'give'), give_get_price_decimal_separator())); |
|
| 129 | + WP_CLI::log($this->color_message(__('Number of Decimals: ', 'give'), give_get_price_decimals())); |
|
| 130 | + WP_CLI::log($this->color_message(__('Test Mode: ', 'give'), (give_get_option('test_mode') ? __('Yes', 'give') : __('No', 'give')))); |
|
| 131 | + WP_CLI::log($this->color_message(__('Default Gateway: ', 'give'), ($default_gateway ? $default_gateway : __('Not Set', 'give')))); |
|
| 132 | 132 | |
| 133 | 133 | // Payment gateways Information. |
| 134 | - $gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() ); |
|
| 135 | - WP_CLI::log( $this->color_message( __( 'Enabled Gateways: ', 'give' ) ) ); |
|
| 134 | + $gateways = give_get_ordered_payment_gateways(give_get_payment_gateways()); |
|
| 135 | + WP_CLI::log($this->color_message(__('Enabled Gateways: ', 'give'))); |
|
| 136 | 136 | |
| 137 | - if ( ! empty( $gateways ) ) { |
|
| 137 | + if ( ! empty($gateways)) { |
|
| 138 | 138 | self::$counter = 1; |
| 139 | - foreach ( $gateways as $gateway ) { |
|
| 140 | - WP_CLI::log( ' ' . $this->color_message( self::$counter, $gateway['admin_label'] ) ); |
|
| 141 | - self::$counter ++; |
|
| 139 | + foreach ($gateways as $gateway) { |
|
| 140 | + WP_CLI::log(' '.$this->color_message(self::$counter, $gateway['admin_label'])); |
|
| 141 | + self::$counter++; |
|
| 142 | 142 | } |
| 143 | 143 | } else { |
| 144 | - WP_CLI::log( __( 'Not any payment gateways found', 'give' ) ); |
|
| 144 | + WP_CLI::log(__('Not any payment gateways found', 'give')); |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
@@ -173,15 +173,15 @@ discard block |
||
| 173 | 173 | * |
| 174 | 174 | * @subcommand forms |
| 175 | 175 | */ |
| 176 | - public function forms( $args, $assoc_args ) { |
|
| 176 | + public function forms($args, $assoc_args) { |
|
| 177 | 177 | global $wp_query; |
| 178 | - $form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false; |
|
| 179 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? absint( $assoc_args['number'] ) : 10; |
|
| 178 | + $form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false; |
|
| 179 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? absint($assoc_args['number']) : 10; |
|
| 180 | 180 | $start = time(); |
| 181 | 181 | |
| 182 | 182 | // Cache previous number query var. |
| 183 | 183 | $is_set_number = $cache_per_page = false; |
| 184 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
| 184 | + if (isset($wp_query->query_vars['number'])) { |
|
| 185 | 185 | $cache_per_page = $wp_query->query_vars['number']; |
| 186 | 186 | $is_set_number = true; |
| 187 | 187 | } |
@@ -190,22 +190,22 @@ discard block |
||
| 190 | 190 | $wp_query->query_vars['number'] = $number; |
| 191 | 191 | |
| 192 | 192 | // Get forms. |
| 193 | - $forms = $form_id ? $this->api->get_forms( $form_id ) : $this->api->get_forms(); |
|
| 193 | + $forms = $form_id ? $this->api->get_forms($form_id) : $this->api->get_forms(); |
|
| 194 | 194 | |
| 195 | 195 | // Reset number query var. |
| 196 | - if ( $is_set_number ) { |
|
| 196 | + if ($is_set_number) { |
|
| 197 | 197 | $wp_query->query_vars['number'] = $cache_per_page; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | // Bailout. |
| 201 | - if ( array_key_exists( 'error', $forms ) ) { |
|
| 201 | + if (array_key_exists('error', $forms)) { |
|
| 202 | 202 | |
| 203 | - WP_CLI::warning( $forms['error'] ); |
|
| 203 | + WP_CLI::warning($forms['error']); |
|
| 204 | 204 | |
| 205 | 205 | return; |
| 206 | - } elseif ( empty( $forms['forms'] ) ) { |
|
| 206 | + } elseif (empty($forms['forms'])) { |
|
| 207 | 207 | |
| 208 | - WP_CLI::error( __( 'No forms found.', 'give' ) ); |
|
| 208 | + WP_CLI::error(__('No forms found.', 'give')); |
|
| 209 | 209 | |
| 210 | 210 | return; |
| 211 | 211 | } |
@@ -213,25 +213,25 @@ discard block |
||
| 213 | 213 | // Param to check if form typeis already showed or not. |
| 214 | 214 | $is_show_form_type = false; |
| 215 | 215 | |
| 216 | - if ( 1 === count( $forms ) && $form_id ) { |
|
| 216 | + if (1 === count($forms) && $form_id) { |
|
| 217 | 217 | // Show single form. |
| 218 | - foreach ( $forms['forms'][0] as $key => $info ) { |
|
| 219 | - switch ( $key ) { |
|
| 218 | + foreach ($forms['forms'][0] as $key => $info) { |
|
| 219 | + switch ($key) { |
|
| 220 | 220 | case 'stats': |
| 221 | - $this->color_main_heading( ucfirst( $key ) ); |
|
| 221 | + $this->color_main_heading(ucfirst($key)); |
|
| 222 | 222 | |
| 223 | - foreach ( $info as $heading => $data ) { |
|
| 224 | - $this->color_sub_heading( ucfirst( $heading ) ); |
|
| 225 | - switch ( $heading ) { |
|
| 223 | + foreach ($info as $heading => $data) { |
|
| 224 | + $this->color_sub_heading(ucfirst($heading)); |
|
| 225 | + switch ($heading) { |
|
| 226 | 226 | default: |
| 227 | - foreach ( $data as $subheading => $subdata ) { |
|
| 227 | + foreach ($data as $subheading => $subdata) { |
|
| 228 | 228 | |
| 229 | - switch ( $subheading ) { |
|
| 229 | + switch ($subheading) { |
|
| 230 | 230 | case 'earnings': |
| 231 | - WP_CLI::log( $this->color_message( $subheading . ': ', give_currency_filter( $subdata ) ) ); |
|
| 231 | + WP_CLI::log($this->color_message($subheading.': ', give_currency_filter($subdata))); |
|
| 232 | 232 | break; |
| 233 | 233 | default: |
| 234 | - WP_CLI::log( $this->color_message( $subheading . ': ', $subdata ) ); |
|
| 234 | + WP_CLI::log($this->color_message($subheading.': ', $subdata)); |
|
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | } |
@@ -241,26 +241,26 @@ discard block |
||
| 241 | 241 | case 'pricing': |
| 242 | 242 | case 'info': |
| 243 | 243 | default: |
| 244 | - $this->color_main_heading( ucfirst( $key ) ); |
|
| 244 | + $this->color_main_heading(ucfirst($key)); |
|
| 245 | 245 | |
| 246 | 246 | // Show form type. |
| 247 | - if ( ! $is_show_form_type ) { |
|
| 248 | - $form = new Give_Donate_Form( $form_id ); |
|
| 247 | + if ( ! $is_show_form_type) { |
|
| 248 | + $form = new Give_Donate_Form($form_id); |
|
| 249 | 249 | $is_show_form_type = true; |
| 250 | 250 | |
| 251 | - WP_CLI::log( $this->color_message( __( 'form type', 'give' ), $form->get_type() ) ); |
|
| 251 | + WP_CLI::log($this->color_message(__('form type', 'give'), $form->get_type())); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - foreach ( $info as $heading => $data ) { |
|
| 254 | + foreach ($info as $heading => $data) { |
|
| 255 | 255 | |
| 256 | - switch ( $heading ) { |
|
| 256 | + switch ($heading) { |
|
| 257 | 257 | case 'id': |
| 258 | - WP_CLI::log( $this->color_message( $heading, $data ) ); |
|
| 258 | + WP_CLI::log($this->color_message($heading, $data)); |
|
| 259 | 259 | break; |
| 260 | 260 | |
| 261 | 261 | default: |
| 262 | - $data = empty( $data ) ? __( 'Not set', 'give' ) : $data; |
|
| 263 | - WP_CLI::log( $this->color_message( $heading, $data ) ); |
|
| 262 | + $data = empty($data) ? __('Not set', 'give') : $data; |
|
| 263 | + WP_CLI::log($this->color_message($heading, $data)); |
|
| 264 | 264 | } |
| 265 | 265 | } |
| 266 | 266 | } |
@@ -271,37 +271,37 @@ discard block |
||
| 271 | 271 | $is_table_first_row_set = false; |
| 272 | 272 | $table_column_count = 0; |
| 273 | 273 | |
| 274 | - WP_CLI::line( $this->color_message( sprintf( __( '%d donation forms found', 'give' ), count( $forms['forms'] ) ), '', false ) ); |
|
| 274 | + WP_CLI::line($this->color_message(sprintf(__('%d donation forms found', 'give'), count($forms['forms'])), '', false)); |
|
| 275 | 275 | |
| 276 | - foreach ( $forms['forms'] as $index => $form_data ) { |
|
| 276 | + foreach ($forms['forms'] as $index => $form_data) { |
|
| 277 | 277 | |
| 278 | 278 | // Default table data. |
| 279 | 279 | $table_first_row = array(); |
| 280 | 280 | $table_row = array(); |
| 281 | 281 | |
| 282 | - foreach ( $form_data['info'] as $key => $form ) { |
|
| 282 | + foreach ($form_data['info'] as $key => $form) { |
|
| 283 | 283 | |
| 284 | 284 | // Do not show thumbnail, content and link in table. |
| 285 | - if ( in_array( $key, array( 'content', 'thumbnail', 'link' ), true ) ) { |
|
| 285 | + if (in_array($key, array('content', 'thumbnail', 'link'), true)) { |
|
| 286 | 286 | continue; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - if ( ! $is_table_first_row_set ) { |
|
| 289 | + if ( ! $is_table_first_row_set) { |
|
| 290 | 290 | $table_first_row[] = $key; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | $table_row[] = $form; |
| 294 | 294 | |
| 295 | - if ( 'status' === $key ) { |
|
| 295 | + if ('status' === $key) { |
|
| 296 | 296 | // First array item will be an form id in our case. |
| 297 | - $form = new Give_Donate_Form( absint( $table_row[0] ) ); |
|
| 297 | + $form = new Give_Donate_Form(absint($table_row[0])); |
|
| 298 | 298 | |
| 299 | 299 | $table_row[] = $form->get_type(); |
| 300 | 300 | } |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | // Set table first row. |
| 304 | - if ( ! $is_table_first_row_set ) { |
|
| 304 | + if ( ! $is_table_first_row_set) { |
|
| 305 | 305 | |
| 306 | 306 | // Add extra column to table. |
| 307 | 307 | $table_first_row[] = 'type'; |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | $table_data[] = $table_row; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - $this->display_table( $table_data ); |
|
| 317 | + $this->display_table($table_data); |
|
| 318 | 318 | } |
| 319 | 319 | } |
| 320 | 320 | |
@@ -366,37 +366,37 @@ discard block |
||
| 366 | 366 | * |
| 367 | 367 | * @subcommand donors |
| 368 | 368 | */ |
| 369 | - public function donors( $args, $assoc_args ) { |
|
| 369 | + public function donors($args, $assoc_args) { |
|
| 370 | 370 | global $wp_query; |
| 371 | - $donor_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false; |
|
| 372 | - $email = isset( $assoc_args ) && array_key_exists( 'email', $assoc_args ) ? $assoc_args['email'] : false; |
|
| 373 | - $name = isset( $assoc_args ) && array_key_exists( 'name', $assoc_args ) ? $assoc_args['name'] : ''; |
|
| 374 | - $create = isset( $assoc_args ) && array_key_exists( 'create', $assoc_args ) ? $assoc_args['create'] : false; |
|
| 375 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10; |
|
| 376 | - $form_id = isset( $assoc_args ) && array_key_exists( 'form-id', $assoc_args ) ? $assoc_args['form-id'] : 0; |
|
| 377 | - $format = isset( $assoc_args ) && array_key_exists( 'format', $assoc_args ) ? $assoc_args['format'] : 'table'; |
|
| 371 | + $donor_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false; |
|
| 372 | + $email = isset($assoc_args) && array_key_exists('email', $assoc_args) ? $assoc_args['email'] : false; |
|
| 373 | + $name = isset($assoc_args) && array_key_exists('name', $assoc_args) ? $assoc_args['name'] : ''; |
|
| 374 | + $create = isset($assoc_args) && array_key_exists('create', $assoc_args) ? $assoc_args['create'] : false; |
|
| 375 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10; |
|
| 376 | + $form_id = isset($assoc_args) && array_key_exists('form-id', $assoc_args) ? $assoc_args['form-id'] : 0; |
|
| 377 | + $format = isset($assoc_args) && array_key_exists('format', $assoc_args) ? $assoc_args['format'] : 'table'; |
|
| 378 | 378 | $start = time(); |
| 379 | 379 | |
| 380 | - if ( $create ) { |
|
| 380 | + if ($create) { |
|
| 381 | 381 | $number = 1; |
| 382 | 382 | |
| 383 | - if ( isset( $assoc_args['email'] ) && ! is_email( $email ) ) { |
|
| 384 | - WP_CLI::warning( 'Wrong email address provided.', 'give' ); |
|
| 383 | + if (isset($assoc_args['email']) && ! is_email($email)) { |
|
| 384 | + WP_CLI::warning('Wrong email address provided.', 'give'); |
|
| 385 | 385 | |
| 386 | 386 | return; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | // Create one or more donors. |
| 390 | - if ( ! $email ) { |
|
| 390 | + if ( ! $email) { |
|
| 391 | 391 | // If no email is specified, look to see if we are generating arbitrary donor accounts. |
| 392 | - $number = is_numeric( $create ) ? absint( $create ) : 1; |
|
| 392 | + $number = is_numeric($create) ? absint($create) : 1; |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | - for ( $i = 0; $i < $number; $i ++ ) { |
|
| 396 | - if ( ! $email ) { |
|
| 395 | + for ($i = 0; $i < $number; $i++) { |
|
| 396 | + if ( ! $email) { |
|
| 397 | 397 | |
| 398 | 398 | // Generate fake email. |
| 399 | - $email = 'customer-' . uniqid() . '@test.com'; |
|
| 399 | + $email = 'customer-'.uniqid().'@test.com'; |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | $args = array( |
@@ -404,19 +404,19 @@ discard block |
||
| 404 | 404 | 'name' => $name, |
| 405 | 405 | ); |
| 406 | 406 | |
| 407 | - $customer_id = Give()->customers->add( $args ); |
|
| 407 | + $customer_id = Give()->customers->add($args); |
|
| 408 | 408 | |
| 409 | - if ( $customer_id ) { |
|
| 410 | - WP_CLI::line( $this->color_message( sprintf( __( 'Donor #%d created successfully', 'give' ), $customer_id ) ) ); |
|
| 409 | + if ($customer_id) { |
|
| 410 | + WP_CLI::line($this->color_message(sprintf(__('Donor #%d created successfully', 'give'), $customer_id))); |
|
| 411 | 411 | } else { |
| 412 | - WP_CLI::error( __( 'Failed to create donor', 'give' ) ); |
|
| 412 | + WP_CLI::error(__('Failed to create donor', 'give')); |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | // Reset email to false so it is generated on the next loop (if creating donors). |
| 416 | 416 | $email = false; |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - WP_CLI::line( $this->color_message( sprintf( __( '%1$d donors created in %2$d seconds', 'give' ), $number, time() - $start ) ) ); |
|
| 419 | + WP_CLI::line($this->color_message(sprintf(__('%1$d donors created in %2$d seconds', 'give'), $number, time() - $start))); |
|
| 420 | 420 | |
| 421 | 421 | } else { |
| 422 | 422 | // Counter. |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | */ |
| 431 | 431 | // Cache previous number query var. |
| 432 | 432 | $is_set_number = $cache_per_page = false; |
| 433 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
| 433 | + if (isset($wp_query->query_vars['number'])) { |
|
| 434 | 434 | $cache_per_page = $wp_query->query_vars['number']; |
| 435 | 435 | $is_set_number = true; |
| 436 | 436 | } |
@@ -439,24 +439,24 @@ discard block |
||
| 439 | 439 | $wp_query->query_vars['number'] = $number; |
| 440 | 440 | |
| 441 | 441 | // Get donors. |
| 442 | - if ( $form_id ) { |
|
| 442 | + if ($form_id) { |
|
| 443 | 443 | // @TODO: Allow user to get a list of donors by donation status. |
| 444 | - $donors = $this->get_donors_by_form_id( $form_id ); |
|
| 444 | + $donors = $this->get_donors_by_form_id($form_id); |
|
| 445 | 445 | } else { |
| 446 | - $donors = $this->api->get_customers( $search ); |
|
| 446 | + $donors = $this->api->get_customers($search); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | // Reset number query var. |
| 450 | - if ( $is_set_number ) { |
|
| 450 | + if ($is_set_number) { |
|
| 451 | 451 | $wp_query->query_vars['number'] = $cache_per_page; |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | - if ( isset( $donors['error'] ) ) { |
|
| 455 | - WP_CLI::error( $donors['error'] ); |
|
| 454 | + if (isset($donors['error'])) { |
|
| 455 | + WP_CLI::error($donors['error']); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | - if ( empty( $donors ) ) { |
|
| 459 | - WP_CLI::error( __( 'No donors found.', 'give' ) ); |
|
| 458 | + if (empty($donors)) { |
|
| 459 | + WP_CLI::error(__('No donors found.', 'give')); |
|
| 460 | 460 | |
| 461 | 461 | return; |
| 462 | 462 | } |
@@ -464,24 +464,24 @@ discard block |
||
| 464 | 464 | $table_data = array(); |
| 465 | 465 | $is_table_first_row_set = false; |
| 466 | 466 | |
| 467 | - foreach ( $donors['donors'] as $donor_data ) { |
|
| 467 | + foreach ($donors['donors'] as $donor_data) { |
|
| 468 | 468 | // Set default table row data. |
| 469 | - $table_first_row = array( __( 's_no', 'give' ) ); |
|
| 470 | - $table_row = array( self::$counter ); |
|
| 469 | + $table_first_row = array(__('s_no', 'give')); |
|
| 470 | + $table_row = array(self::$counter); |
|
| 471 | 471 | |
| 472 | - foreach ( $donor_data as $key => $donor ) { |
|
| 473 | - switch ( $key ) { |
|
| 472 | + foreach ($donor_data as $key => $donor) { |
|
| 473 | + switch ($key) { |
|
| 474 | 474 | case 'stats': |
| 475 | - foreach ( $donor as $heading => $data ) { |
|
| 475 | + foreach ($donor as $heading => $data) { |
|
| 476 | 476 | |
| 477 | 477 | // Get first row. |
| 478 | - if ( ! $is_table_first_row_set ) { |
|
| 478 | + if ( ! $is_table_first_row_set) { |
|
| 479 | 479 | $table_first_row[] = $heading; |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | - switch ( $heading ) { |
|
| 482 | + switch ($heading) { |
|
| 483 | 483 | case 'total_spent': |
| 484 | - $table_row[] = give_currency_filter( $data ); |
|
| 484 | + $table_row[] = give_currency_filter($data); |
|
| 485 | 485 | break; |
| 486 | 486 | |
| 487 | 487 | default: |
@@ -492,10 +492,10 @@ discard block |
||
| 492 | 492 | |
| 493 | 493 | case 'info': |
| 494 | 494 | default: |
| 495 | - foreach ( $donor as $heading => $data ) { |
|
| 495 | + foreach ($donor as $heading => $data) { |
|
| 496 | 496 | |
| 497 | 497 | // Get first row. |
| 498 | - if ( ! $is_table_first_row_set ) { |
|
| 498 | + if ( ! $is_table_first_row_set) { |
|
| 499 | 499 | $table_first_row[] = $heading; |
| 500 | 500 | } |
| 501 | 501 | |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | // Add first row data to table data. |
| 508 | - if ( ! $is_table_first_row_set ) { |
|
| 508 | + if ( ! $is_table_first_row_set) { |
|
| 509 | 509 | $table_data[] = $table_first_row; |
| 510 | 510 | $is_table_first_row_set = true; |
| 511 | 511 | } |
@@ -514,44 +514,44 @@ discard block |
||
| 514 | 514 | $table_data[] = $table_row; |
| 515 | 515 | |
| 516 | 516 | // Increase counter. |
| 517 | - self::$counter ++; |
|
| 517 | + self::$counter++; |
|
| 518 | 518 | } |
| 519 | 519 | |
| 520 | - switch ( $format ) { |
|
| 520 | + switch ($format) { |
|
| 521 | 521 | case 'json': |
| 522 | 522 | $table_column_name = $table_data[0]; |
| 523 | - unset( $table_data[0] ); |
|
| 523 | + unset($table_data[0]); |
|
| 524 | 524 | |
| 525 | 525 | $new_table_data = array(); |
| 526 | - foreach ( $table_data as $index => $data ) { |
|
| 527 | - foreach ( $data as $key => $value ) { |
|
| 528 | - $new_table_data[ $index ][ $table_column_name[ $key ] ] = $value; |
|
| 526 | + foreach ($table_data as $index => $data) { |
|
| 527 | + foreach ($data as $key => $value) { |
|
| 528 | + $new_table_data[$index][$table_column_name[$key]] = $value; |
|
| 529 | 529 | } |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | - WP_CLI::log( json_encode( $new_table_data ) ); |
|
| 532 | + WP_CLI::log(json_encode($new_table_data)); |
|
| 533 | 533 | break; |
| 534 | 534 | |
| 535 | 535 | case 'csv': |
| 536 | - $file_path = trailingslashit( WP_CONTENT_DIR ) . 'uploads/give_donors_' . date( 'Y_m_d_s', current_time( 'timestamp' ) ) . '.csv'; |
|
| 537 | - $fp = fopen( $file_path, 'w' ); |
|
| 536 | + $file_path = trailingslashit(WP_CONTENT_DIR).'uploads/give_donors_'.date('Y_m_d_s', current_time('timestamp')).'.csv'; |
|
| 537 | + $fp = fopen($file_path, 'w'); |
|
| 538 | 538 | |
| 539 | - if ( is_writable( $file_path ) ) { |
|
| 540 | - foreach ( $table_data as $fields ) { |
|
| 541 | - fputcsv( $fp, $fields ); |
|
| 539 | + if (is_writable($file_path)) { |
|
| 540 | + foreach ($table_data as $fields) { |
|
| 541 | + fputcsv($fp, $fields); |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | - fclose( $fp ); |
|
| 544 | + fclose($fp); |
|
| 545 | 545 | |
| 546 | - WP_CLI::success( "Donors list csv created successfully: {$file_path}" ); |
|
| 546 | + WP_CLI::success("Donors list csv created successfully: {$file_path}"); |
|
| 547 | 547 | } else { |
| 548 | - WP_CLI::warning( "Unable to create donors list csv file: {$file_path} (May folder do not have write permission)" ); |
|
| 548 | + WP_CLI::warning("Unable to create donors list csv file: {$file_path} (May folder do not have write permission)"); |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | break; |
| 552 | 552 | |
| 553 | 553 | default: |
| 554 | - $this->display_table( $table_data ); |
|
| 554 | + $this->display_table($table_data); |
|
| 555 | 555 | } |
| 556 | 556 | } |
| 557 | 557 | } |
@@ -581,13 +581,13 @@ discard block |
||
| 581 | 581 | * |
| 582 | 582 | * @subcommand donations |
| 583 | 583 | */ |
| 584 | - public function donations( $args, $assoc_args ) { |
|
| 584 | + public function donations($args, $assoc_args) { |
|
| 585 | 585 | global $wp_query; |
| 586 | - $number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10; |
|
| 586 | + $number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10; |
|
| 587 | 587 | |
| 588 | 588 | // Cache previous number query var. |
| 589 | 589 | $is_set_number = $cache_per_page = false; |
| 590 | - if ( isset( $wp_query->query_vars['number'] ) ) { |
|
| 590 | + if (isset($wp_query->query_vars['number'])) { |
|
| 591 | 591 | $cache_per_page = $wp_query->query_vars['number']; |
| 592 | 592 | $is_set_number = true; |
| 593 | 593 | } |
@@ -599,46 +599,46 @@ discard block |
||
| 599 | 599 | $donations = $this->api->get_recent_donations(); |
| 600 | 600 | |
| 601 | 601 | // Reset number query var. |
| 602 | - if ( $is_set_number ) { |
|
| 602 | + if ($is_set_number) { |
|
| 603 | 603 | $wp_query->query_vars['number'] = $cache_per_page; |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | - if ( empty( $donations ) ) { |
|
| 607 | - WP_CLI::error( __( 'No donations found.', 'give' ) ); |
|
| 606 | + if (empty($donations)) { |
|
| 607 | + WP_CLI::error(__('No donations found.', 'give')); |
|
| 608 | 608 | |
| 609 | 609 | return; |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | self::$counter = 1; |
| 613 | 613 | |
| 614 | - foreach ( $donations['donations'] as $key => $donation ) { |
|
| 615 | - $this->color_main_heading( sprintf( __( '%1$s. Donation #%2$s', 'give' ), self::$counter, $donation['ID'] ), 'Y' ); |
|
| 616 | - self::$counter ++; |
|
| 614 | + foreach ($donations['donations'] as $key => $donation) { |
|
| 615 | + $this->color_main_heading(sprintf(__('%1$s. Donation #%2$s', 'give'), self::$counter, $donation['ID']), 'Y'); |
|
| 616 | + self::$counter++; |
|
| 617 | 617 | |
| 618 | - foreach ( $donation as $column => $data ) { |
|
| 618 | + foreach ($donation as $column => $data) { |
|
| 619 | 619 | |
| 620 | - if ( is_array( $data ) ) { |
|
| 621 | - $this->color_sub_heading( $column ); |
|
| 622 | - foreach ( $data as $subcolumn => $subdata ) { |
|
| 620 | + if (is_array($data)) { |
|
| 621 | + $this->color_sub_heading($column); |
|
| 622 | + foreach ($data as $subcolumn => $subdata) { |
|
| 623 | 623 | |
| 624 | 624 | // Decode html codes. |
| 625 | - switch ( $subcolumn ) { |
|
| 625 | + switch ($subcolumn) { |
|
| 626 | 626 | case 'name': |
| 627 | - $subdata = html_entity_decode( $subdata ); |
|
| 627 | + $subdata = html_entity_decode($subdata); |
|
| 628 | 628 | break; |
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | // @TODO Check if multi dimension array information is importent to show or not. For example inside donation array we have array for fees data inside payment meta. |
| 632 | - if ( is_array( $subdata ) ) { |
|
| 632 | + if (is_array($subdata)) { |
|
| 633 | 633 | continue; |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | - WP_CLI::log( $this->color_message( $subcolumn, $subdata ) ); |
|
| 636 | + WP_CLI::log($this->color_message($subcolumn, $subdata)); |
|
| 637 | 637 | } |
| 638 | 638 | continue; |
| 639 | 639 | } |
| 640 | 640 | |
| 641 | - WP_CLI::log( $this->color_message( $column, $data ) ); |
|
| 641 | + WP_CLI::log($this->color_message($column, $data)); |
|
| 642 | 642 | } |
| 643 | 643 | } |
| 644 | 644 | } |
@@ -677,27 +677,27 @@ discard block |
||
| 677 | 677 | * |
| 678 | 678 | * @return void |
| 679 | 679 | */ |
| 680 | - public function report( $args, $assoc_args ) { |
|
| 680 | + public function report($args, $assoc_args) { |
|
| 681 | 681 | $stats = new Give_Payment_Stats(); |
| 682 | - $date = isset( $assoc_args ) && array_key_exists( 'date', $assoc_args ) ? $assoc_args['date'] : false; |
|
| 683 | - $start_date = isset( $assoc_args ) && array_key_exists( 'start-date', $assoc_args ) ? $assoc_args['start-date'] : false; |
|
| 684 | - $end_date = isset( $assoc_args ) && array_key_exists( 'end-date', $assoc_args ) ? $assoc_args['end-date'] : false; |
|
| 685 | - $form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? $assoc_args['id'] : 0; |
|
| 682 | + $date = isset($assoc_args) && array_key_exists('date', $assoc_args) ? $assoc_args['date'] : false; |
|
| 683 | + $start_date = isset($assoc_args) && array_key_exists('start-date', $assoc_args) ? $assoc_args['start-date'] : false; |
|
| 684 | + $end_date = isset($assoc_args) && array_key_exists('end-date', $assoc_args) ? $assoc_args['end-date'] : false; |
|
| 685 | + $form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? $assoc_args['id'] : 0; |
|
| 686 | 686 | |
| 687 | - if ( ! empty( $date ) ) { |
|
| 687 | + if ( ! empty($date)) { |
|
| 688 | 688 | $start_date = $date; |
| 689 | 689 | $end_date = false; |
| 690 | - } elseif ( empty( $date ) && empty( $start_date ) ) { |
|
| 690 | + } elseif (empty($date) && empty($start_date)) { |
|
| 691 | 691 | $start_date = 'this_month'; |
| 692 | 692 | $end_date = false; |
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | // Get stats. |
| 696 | - $earnings = $stats->get_earnings( $form_id, $start_date, $end_date ); |
|
| 697 | - $sales = $stats->get_sales( $form_id, $start_date, $end_date ); |
|
| 696 | + $earnings = $stats->get_earnings($form_id, $start_date, $end_date); |
|
| 697 | + $sales = $stats->get_sales($form_id, $start_date, $end_date); |
|
| 698 | 698 | |
| 699 | - WP_CLI::line( $this->color_message( __( 'Earnings', 'give' ), give_currency_filter( $earnings ) ) ); |
|
| 700 | - WP_CLI::line( $this->color_message( __( 'Sales', 'give' ), $sales ) ); |
|
| 699 | + WP_CLI::line($this->color_message(__('Earnings', 'give'), give_currency_filter($earnings))); |
|
| 700 | + WP_CLI::line($this->color_message(__('Sales', 'give'), $sales)); |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | |
@@ -724,27 +724,27 @@ discard block |
||
| 724 | 724 | * |
| 725 | 725 | * @subcommand cache |
| 726 | 726 | */ |
| 727 | - public function cache( $args, $assoc_args ) { |
|
| 728 | - $action = isset( $assoc_args ) && array_key_exists( 'action', $assoc_args ) ? $assoc_args['action'] : false; |
|
| 727 | + public function cache($args, $assoc_args) { |
|
| 728 | + $action = isset($assoc_args) && array_key_exists('action', $assoc_args) ? $assoc_args['action'] : false; |
|
| 729 | 729 | |
| 730 | 730 | // Bailout. |
| 731 | - if ( ! $action || ! in_array( $action, array( 'delete' ), true ) ) { |
|
| 732 | - WP_CLI::warning( __( 'Type wp give cache --action=delete to delete all stat transients', 'give' ) ); |
|
| 731 | + if ( ! $action || ! in_array($action, array('delete'), true)) { |
|
| 732 | + WP_CLI::warning(__('Type wp give cache --action=delete to delete all stat transients', 'give')); |
|
| 733 | 733 | |
| 734 | 734 | return; |
| 735 | 735 | } |
| 736 | 736 | |
| 737 | - switch ( $action ) { |
|
| 737 | + switch ($action) { |
|
| 738 | 738 | case 'delete' : |
| 739 | 739 | // Reset counter. |
| 740 | 740 | self::$counter = 1; |
| 741 | 741 | |
| 742 | - if ( $this->delete_stats_transients() ) { |
|
| 742 | + if ($this->delete_stats_transients()) { |
|
| 743 | 743 | // Report .eading. |
| 744 | - WP_CLI::success( 'Give cache deleted.' ); |
|
| 744 | + WP_CLI::success('Give cache deleted.'); |
|
| 745 | 745 | } else { |
| 746 | 746 | // Report .eading. |
| 747 | - WP_CLI::warning( 'We did not find any Give plugin cache to delete :)' ); |
|
| 747 | + WP_CLI::warning('We did not find any Give plugin cache to delete :)'); |
|
| 748 | 748 | } |
| 749 | 749 | break; |
| 750 | 750 | } |
@@ -773,27 +773,27 @@ discard block |
||
| 773 | 773 | ARRAY_A |
| 774 | 774 | ); |
| 775 | 775 | |
| 776 | - if ( ! empty( $stat_option_names ) ) { |
|
| 776 | + if ( ! empty($stat_option_names)) { |
|
| 777 | 777 | |
| 778 | - foreach ( $stat_option_names as $option_name ) { |
|
| 778 | + foreach ($stat_option_names as $option_name) { |
|
| 779 | 779 | $error = false; |
| 780 | 780 | $option_name = $option_name['option_name']; |
| 781 | 781 | |
| 782 | - switch ( true ) { |
|
| 783 | - case ( false !== strpos( $option_name, 'transient' ) ): |
|
| 784 | - $option_name = str_replace( '_transient_', '', $option_name ); |
|
| 785 | - $error = delete_transient( $option_name ); |
|
| 782 | + switch (true) { |
|
| 783 | + case (false !== strpos($option_name, 'transient')): |
|
| 784 | + $option_name = str_replace('_transient_', '', $option_name); |
|
| 785 | + $error = delete_transient($option_name); |
|
| 786 | 786 | break; |
| 787 | 787 | |
| 788 | 788 | default: |
| 789 | - $error = delete_option( $option_name ); |
|
| 789 | + $error = delete_option($option_name); |
|
| 790 | 790 | } |
| 791 | 791 | |
| 792 | - if ( $error ) { |
|
| 793 | - WP_CLI::log( $this->color_message( self::$counter, $option_name ) ); |
|
| 794 | - self::$counter ++; |
|
| 792 | + if ($error) { |
|
| 793 | + WP_CLI::log($this->color_message(self::$counter, $option_name)); |
|
| 794 | + self::$counter++; |
|
| 795 | 795 | } else { |
| 796 | - WP_CLI::log( $this->color_message( __( 'Error while deleting this transient', 'give' ), $option_name ) ); |
|
| 796 | + WP_CLI::log($this->color_message(__('Error while deleting this transient', 'give'), $option_name)); |
|
| 797 | 797 | } |
| 798 | 798 | } |
| 799 | 799 | |
@@ -814,13 +814,13 @@ discard block |
||
| 814 | 814 | * |
| 815 | 815 | * @return string |
| 816 | 816 | */ |
| 817 | - private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) { |
|
| 817 | + private function color_message($heading, $message = '', $colon = true, $color = 'g') { |
|
| 818 | 818 | // Add colon. |
| 819 | - if ( $colon ) { |
|
| 820 | - $heading = $heading . ': '; |
|
| 819 | + if ($colon) { |
|
| 820 | + $heading = $heading.': '; |
|
| 821 | 821 | } |
| 822 | 822 | |
| 823 | - return WP_CLI::colorize( "%{$color}" . $heading . '%n' ) . $message; |
|
| 823 | + return WP_CLI::colorize("%{$color}".$heading.'%n').$message; |
|
| 824 | 824 | } |
| 825 | 825 | |
| 826 | 826 | |
@@ -835,8 +835,8 @@ discard block |
||
| 835 | 835 | * |
| 836 | 836 | * @return void |
| 837 | 837 | */ |
| 838 | - private function color_main_heading( $heading, $color = 'g' ) { |
|
| 839 | - WP_CLI::log( "\n###### " . $this->color_message( $heading, '', false, $color ) . ' ######' ); |
|
| 838 | + private function color_main_heading($heading, $color = 'g') { |
|
| 839 | + WP_CLI::log("\n###### ".$this->color_message($heading, '', false, $color).' ######'); |
|
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | /** |
@@ -849,8 +849,8 @@ discard block |
||
| 849 | 849 | * |
| 850 | 850 | * @return void |
| 851 | 851 | */ |
| 852 | - private function color_sub_heading( $subheading ) { |
|
| 853 | - WP_CLI::log( "\n--->" . $subheading . '', '', false ); |
|
| 852 | + private function color_sub_heading($subheading) { |
|
| 853 | + WP_CLI::log("\n--->".$subheading.'', '', false); |
|
| 854 | 854 | } |
| 855 | 855 | |
| 856 | 856 | |
@@ -864,17 +864,17 @@ discard block |
||
| 864 | 864 | * |
| 865 | 865 | * @return void |
| 866 | 866 | */ |
| 867 | - private function display_table( $data ) { |
|
| 867 | + private function display_table($data) { |
|
| 868 | 868 | $table = new \cli\Table(); |
| 869 | 869 | |
| 870 | 870 | // Set table header. |
| 871 | - $table->setHeaders( $data[0] ); |
|
| 871 | + $table->setHeaders($data[0]); |
|
| 872 | 872 | |
| 873 | 873 | // Remove table header. |
| 874 | - unset( $data[0] ); |
|
| 874 | + unset($data[0]); |
|
| 875 | 875 | |
| 876 | 876 | // Set table data. |
| 877 | - $table->setRows( $data ); |
|
| 877 | + $table->setRows($data); |
|
| 878 | 878 | |
| 879 | 879 | // Display table. |
| 880 | 880 | $table->display(); |
@@ -891,14 +891,14 @@ discard block |
||
| 891 | 891 | * @return array |
| 892 | 892 | */ |
| 893 | 893 | |
| 894 | - private function get_donors_by_form_id( $form_id ) { |
|
| 894 | + private function get_donors_by_form_id($form_id) { |
|
| 895 | 895 | $donors = array(); |
| 896 | 896 | |
| 897 | 897 | $donations = new Give_Payments_Query( |
| 898 | 898 | array( |
| 899 | - 'give_forms' => array( $form_id ), |
|
| 900 | - 'number' => - 1, |
|
| 901 | - 'status' => array( 'publish' ), |
|
| 899 | + 'give_forms' => array($form_id), |
|
| 900 | + 'number' => -1, |
|
| 901 | + 'status' => array('publish'), |
|
| 902 | 902 | ) |
| 903 | 903 | ); |
| 904 | 904 | |
@@ -906,16 +906,16 @@ discard block |
||
| 906 | 906 | $skip_donors = array(); |
| 907 | 907 | |
| 908 | 908 | /* @var Give_Payment|object $donation Payment object. */ |
| 909 | - foreach ( $donations as $donation ) { |
|
| 909 | + foreach ($donations as $donation) { |
|
| 910 | 910 | |
| 911 | - if ( in_array( $donation->customer_id, $skip_donors ) ) { |
|
| 911 | + if (in_array($donation->customer_id, $skip_donors)) { |
|
| 912 | 912 | continue; |
| 913 | 913 | } |
| 914 | 914 | |
| 915 | - if ( ! empty( $donors ) ) { |
|
| 916 | - $donors['donors'][] = current( current( $this->api->get_customers( (int) $donation->customer_id ) ) ); |
|
| 915 | + if ( ! empty($donors)) { |
|
| 916 | + $donors['donors'][] = current(current($this->api->get_customers((int) $donation->customer_id))); |
|
| 917 | 917 | } else { |
| 918 | - $donors = array_merge( $donors, $this->api->get_customers( (int) $donation->customer_id ) ); |
|
| 918 | + $donors = array_merge($donors, $this->api->get_customers((int) $donation->customer_id)); |
|
| 919 | 919 | } |
| 920 | 920 | |
| 921 | 921 | $skip_donors[] = $donation->customer_id; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -26,29 +26,29 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @return void |
| 28 | 28 | */ |
| 29 | -function give_set_settings_with_disable_prefix( $old_settings, $settings ) { |
|
| 29 | +function give_set_settings_with_disable_prefix($old_settings, $settings) { |
|
| 30 | 30 | // Get old setting names. |
| 31 | - $old_settings = array_flip( give_v18_renamed_core_settings() ); |
|
| 31 | + $old_settings = array_flip(give_v18_renamed_core_settings()); |
|
| 32 | 32 | $update_setting = false; |
| 33 | 33 | |
| 34 | - foreach ( $settings as $key => $value ) { |
|
| 34 | + foreach ($settings as $key => $value) { |
|
| 35 | 35 | |
| 36 | 36 | // Check 1. Check if new option is really updated or not. |
| 37 | 37 | // Check 2. Continue if key is not renamed. |
| 38 | - if ( ! isset( $old_settings[ $key ] ) ) { |
|
| 38 | + if ( ! isset($old_settings[$key])) { |
|
| 39 | 39 | continue; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | // Set old setting. |
| 43 | - $settings[ $old_settings[ $key ] ] = 'on'; |
|
| 43 | + $settings[$old_settings[$key]] = 'on'; |
|
| 44 | 44 | |
| 45 | 45 | // Do not need to set old setting if new setting is not set. |
| 46 | 46 | if ( |
| 47 | - ( give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'disable_' ) ) ) |
|
| 48 | - || ( ! give_is_setting_enabled( $value ) && ( false !== strpos( $old_settings[ $key ], 'enable_' ) ) ) |
|
| 47 | + (give_is_setting_enabled($value) && (false !== strpos($old_settings[$key], 'disable_'))) |
|
| 48 | + || ( ! give_is_setting_enabled($value) && (false !== strpos($old_settings[$key], 'enable_'))) |
|
| 49 | 49 | |
| 50 | 50 | ) { |
| 51 | - unset( $settings[ $old_settings[ $key ] ] ); |
|
| 51 | + unset($settings[$old_settings[$key]]); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // Tell bot to update setting. |
@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // Update setting if any old setting set. |
| 59 | - if ( $update_setting ) { |
|
| 60 | - update_option( 'give_settings', $settings ); |
|
| 59 | + if ($update_setting) { |
|
| 60 | + update_option('give_settings', $settings); |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | -add_action( 'update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2 ); |
|
| 63 | +add_action('update_option_give_settings', 'give_set_settings_with_disable_prefix', 10, 2); |
|
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -21,14 +21,14 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @param $data |
| 23 | 23 | */ |
| 24 | -function give_process_gateway_select( $data ) { |
|
| 25 | - if ( isset( $_POST['gateway_submit'] ) ) { |
|
| 26 | - wp_redirect( esc_url( add_query_arg( 'payment-mode', $_POST['payment-mode'] ) ) ); |
|
| 24 | +function give_process_gateway_select($data) { |
|
| 25 | + if (isset($_POST['gateway_submit'])) { |
|
| 26 | + wp_redirect(esc_url(add_query_arg('payment-mode', $_POST['payment-mode']))); |
|
| 27 | 27 | exit; |
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | -add_action( 'give_gateway_select', 'give_process_gateway_select' ); |
|
| 31 | +add_action('give_gateway_select', 'give_process_gateway_select'); |
|
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * Loads a payment gateway via AJAX. |
@@ -38,20 +38,20 @@ discard block |
||
| 38 | 38 | * @return void |
| 39 | 39 | */ |
| 40 | 40 | function give_load_ajax_gateway() { |
| 41 | - if ( isset( $_POST['give_payment_mode'] ) ) { |
|
| 41 | + if (isset($_POST['give_payment_mode'])) { |
|
| 42 | 42 | /** |
| 43 | 43 | * Fire to render donation form. |
| 44 | 44 | * |
| 45 | 45 | * @since 1.7 |
| 46 | 46 | */ |
| 47 | - do_action( 'give_donation_form', $_POST['give_form_id'] ); |
|
| 47 | + do_action('give_donation_form', $_POST['give_form_id']); |
|
| 48 | 48 | |
| 49 | 49 | exit(); |
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | -add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' ); |
|
| 54 | -add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' ); |
|
| 53 | +add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway'); |
|
| 54 | +add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway'); |
|
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * Sets an error within the donation form if no gateways are enabled. |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | function give_no_gateway_error() { |
| 64 | 64 | $gateways = give_get_enabled_payment_gateways(); |
| 65 | 65 | |
| 66 | - if ( empty( $gateways ) ) { |
|
| 67 | - give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) ); |
|
| 66 | + if (empty($gateways)) { |
|
| 67 | + give_set_error('no_gateways', esc_html__('You must enable a payment gateway to use Give.', 'give')); |
|
| 68 | 68 | } else { |
| 69 | - give_unset_error( 'no_gateways' ); |
|
| 69 | + give_unset_error('no_gateways'); |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | -add_action( 'init', 'give_no_gateway_error' ); |
|
| 73 | +add_action('init', 'give_no_gateway_error'); |
|
@@ -143,7 +143,7 @@ |
||
| 143 | 143 | * |
| 144 | 144 | * @access public |
| 145 | 145 | * @since 1.0 |
| 146 | - * @return mixed string If search is present, false otherwise |
|
| 146 | + * @return string|false string If search is present, false otherwise |
|
| 147 | 147 | */ |
| 148 | 148 | public function get_search() { |
| 149 | 149 | return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
@@ -185,8 +185,8 @@ |
||
| 185 | 185 | |
| 186 | 186 | case 'num_donations' : |
| 187 | 187 | $value = '<a href="' . |
| 188 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] ) |
|
| 189 | - ) . '">' . esc_html( $item['num_donations'] ) . '</a>'; |
|
| 188 | + admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] ) |
|
| 189 | + ) . '">' . esc_html( $item['num_donations'] ) . '</a>'; |
|
| 190 | 190 | break; |
| 191 | 191 | |
| 192 | 192 | case 'amount_spent' : |
@@ -10,13 +10,13 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // Load WP_List_Table if not loaded |
| 18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
| 19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
| 18 | +if ( ! class_exists('WP_List_Table')) { |
|
| 19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -62,11 +62,11 @@ discard block |
||
| 62 | 62 | global $status, $page; |
| 63 | 63 | |
| 64 | 64 | // Set parent defaults |
| 65 | - parent::__construct( array( |
|
| 66 | - 'singular' => esc_html__( 'Donor', 'give' ), // Singular name of the listed records |
|
| 67 | - 'plural' => esc_html__( 'Donors', 'give' ), // Plural name of the listed records |
|
| 68 | - 'ajax' => false,// Does this table support ajax? |
|
| 69 | - ) ); |
|
| 65 | + parent::__construct(array( |
|
| 66 | + 'singular' => esc_html__('Donor', 'give'), // Singular name of the listed records |
|
| 67 | + 'plural' => esc_html__('Donors', 'give'), // Plural name of the listed records |
|
| 68 | + 'ajax' => false, // Does this table support ajax? |
|
| 69 | + )); |
|
| 70 | 70 | |
| 71 | 71 | } |
| 72 | 72 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * |
| 84 | 84 | * @return false |
| 85 | 85 | */ |
| 86 | - public function search_box( $text, $input_id ) { |
|
| 86 | + public function search_box($text, $input_id) { |
|
| 87 | 87 | return false; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -98,20 +98,20 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * @return void |
| 100 | 100 | */ |
| 101 | - public function give_search_box( $text, $input_id ) { |
|
| 102 | - $input_id = $input_id . '-search-input'; |
|
| 101 | + public function give_search_box($text, $input_id) { |
|
| 102 | + $input_id = $input_id.'-search-input'; |
|
| 103 | 103 | |
| 104 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
| 105 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
| 104 | + if ( ! empty($_REQUEST['orderby'])) { |
|
| 105 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
| 106 | 106 | } |
| 107 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
| 108 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
| 107 | + if ( ! empty($_REQUEST['order'])) { |
|
| 108 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
| 109 | 109 | } |
| 110 | 110 | ?> |
| 111 | 111 | <p class="search-box donor-search" role="search"> |
| 112 | 112 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
| 113 | 113 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
| 114 | - <?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?> |
|
| 114 | + <?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?> |
|
| 115 | 115 | </p> |
| 116 | 116 | <?php |
| 117 | 117 | } |
@@ -124,33 +124,33 @@ discard block |
||
| 124 | 124 | * |
| 125 | 125 | * @param string $which |
| 126 | 126 | */ |
| 127 | - protected function display_tablenav( $which ) { |
|
| 127 | + protected function display_tablenav($which) { |
|
| 128 | 128 | |
| 129 | - if ( 'top' === $which ) { |
|
| 130 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
| 129 | + if ('top' === $which) { |
|
| 130 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
| 131 | 131 | } |
| 132 | 132 | ?> |
| 133 | - <div class="tablenav give-clearfix <?php echo esc_attr( $which ); ?>"> |
|
| 133 | + <div class="tablenav give-clearfix <?php echo esc_attr($which); ?>"> |
|
| 134 | 134 | |
| 135 | - <?php if ( 'top' === $which ) { ?> |
|
| 135 | + <?php if ('top' === $which) { ?> |
|
| 136 | 136 | <h3 class="alignleft reports-earnings-title"> |
| 137 | - <span><?php esc_html_e( 'Donors Report', 'give' ); ?></span> |
|
| 137 | + <span><?php esc_html_e('Donors Report', 'give'); ?></span> |
|
| 138 | 138 | </h3> |
| 139 | 139 | <?php } ?> |
| 140 | 140 | |
| 141 | 141 | <div class="alignright tablenav-right"> |
| 142 | 142 | <div class="actions bulkactions"> |
| 143 | 143 | <?php |
| 144 | - if ( 'top' === $which ) { |
|
| 145 | - $this->give_search_box( esc_html__( 'Search Donors', 'give' ), 'give-donors-report-search' ); |
|
| 144 | + if ('top' === $which) { |
|
| 145 | + $this->give_search_box(esc_html__('Search Donors', 'give'), 'give-donors-report-search'); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - $this->bulk_actions( $which ); ?> |
|
| 148 | + $this->bulk_actions($which); ?> |
|
| 149 | 149 | |
| 150 | 150 | </div> |
| 151 | 151 | <?php |
| 152 | - $this->extra_tablenav( $which ); |
|
| 153 | - $this->pagination( $which ); |
|
| 152 | + $this->extra_tablenav($which); |
|
| 153 | + $this->pagination($which); |
|
| 154 | 154 | ?> |
| 155 | 155 | </div> |
| 156 | 156 | |
@@ -172,33 +172,33 @@ discard block |
||
| 172 | 172 | * |
| 173 | 173 | * @return string Column Name |
| 174 | 174 | */ |
| 175 | - public function column_default( $item, $column_name ) { |
|
| 175 | + public function column_default($item, $column_name) { |
|
| 176 | 176 | |
| 177 | - switch ( $column_name ) { |
|
| 177 | + switch ($column_name) { |
|
| 178 | 178 | |
| 179 | 179 | case 'name' : |
| 180 | - $name = '#' . $item['id'] . ' '; |
|
| 181 | - $name .= ! empty( $item['name'] ) ? $item['name'] : '<em>' . esc_html__( 'Unnamed Donor', 'give' ) . '</em>'; |
|
| 182 | - $view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $item['id'] ); |
|
| 183 | - $value = '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>'; |
|
| 180 | + $name = '#'.$item['id'].' '; |
|
| 181 | + $name .= ! empty($item['name']) ? $item['name'] : '<em>'.esc_html__('Unnamed Donor', 'give').'</em>'; |
|
| 182 | + $view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$item['id']); |
|
| 183 | + $value = '<a href="'.esc_url($view_url).'">'.$name.'</a>'; |
|
| 184 | 184 | break; |
| 185 | 185 | |
| 186 | 186 | case 'num_donations' : |
| 187 | - $value = '<a href="' . |
|
| 188 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] ) |
|
| 189 | - ) . '">' . esc_html( $item['num_donations'] ) . '</a>'; |
|
| 187 | + $value = '<a href="'. |
|
| 188 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.urlencode($item['email']) |
|
| 189 | + ).'">'.esc_html($item['num_donations']).'</a>'; |
|
| 190 | 190 | break; |
| 191 | 191 | |
| 192 | 192 | case 'amount_spent' : |
| 193 | - $value = give_currency_filter( give_format_amount( $item[ $column_name ] ) ); |
|
| 193 | + $value = give_currency_filter(give_format_amount($item[$column_name])); |
|
| 194 | 194 | break; |
| 195 | 195 | |
| 196 | 196 | default: |
| 197 | - $value = isset( $item[ $column_name ] ) ? $item[ $column_name ] : null; |
|
| 197 | + $value = isset($item[$column_name]) ? $item[$column_name] : null; |
|
| 198 | 198 | break; |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - return apply_filters( "give_report_column_{$column_name}", $value, $item['id'] ); |
|
| 201 | + return apply_filters("give_report_column_{$column_name}", $value, $item['id']); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -210,13 +210,13 @@ discard block |
||
| 210 | 210 | */ |
| 211 | 211 | public function get_columns() { |
| 212 | 212 | $columns = array( |
| 213 | - 'name' => esc_html__( 'Name', 'give' ), |
|
| 214 | - 'email' => esc_html__( 'Email', 'give' ), |
|
| 215 | - 'num_donations' => esc_html__( 'Donations', 'give' ), |
|
| 216 | - 'amount_spent' => esc_html__( 'Total Donated', 'give' ), |
|
| 213 | + 'name' => esc_html__('Name', 'give'), |
|
| 214 | + 'email' => esc_html__('Email', 'give'), |
|
| 215 | + 'num_donations' => esc_html__('Donations', 'give'), |
|
| 216 | + 'amount_spent' => esc_html__('Total Donated', 'give'), |
|
| 217 | 217 | ); |
| 218 | 218 | |
| 219 | - return apply_filters( 'give_report_donor_columns', $columns ); |
|
| 219 | + return apply_filters('give_report_donor_columns', $columns); |
|
| 220 | 220 | |
| 221 | 221 | } |
| 222 | 222 | |
@@ -229,10 +229,10 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | public function get_sortable_columns() { |
| 231 | 231 | return array( |
| 232 | - 'id' => array( 'id', true ), |
|
| 233 | - 'name' => array( 'name', true ), |
|
| 234 | - 'num_donations' => array( 'purchase_count', false ), |
|
| 235 | - 'amount_spent' => array( 'purchase_value', false ), |
|
| 232 | + 'id' => array('id', true), |
|
| 233 | + 'name' => array('name', true), |
|
| 234 | + 'num_donations' => array('purchase_count', false), |
|
| 235 | + 'amount_spent' => array('purchase_value', false), |
|
| 236 | 236 | ); |
| 237 | 237 | } |
| 238 | 238 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * @since 1.0 |
| 244 | 244 | * @return void |
| 245 | 245 | */ |
| 246 | - public function bulk_actions( $which = '' ) { |
|
| 246 | + public function bulk_actions($which = '') { |
|
| 247 | 247 | |
| 248 | 248 | } |
| 249 | 249 | |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | * @return int Current page number |
| 256 | 256 | */ |
| 257 | 257 | public function get_paged() { |
| 258 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
| 258 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /** |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | * @return mixed string If search is present, false otherwise |
| 267 | 267 | */ |
| 268 | 268 | public function get_search() { |
| 269 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
| 269 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | /** |
@@ -285,15 +285,15 @@ discard block |
||
| 285 | 285 | |
| 286 | 286 | // Get donor query. |
| 287 | 287 | $args = $this->get_donor_query(); |
| 288 | - $donors = Give()->customers->get_customers( $args ); |
|
| 288 | + $donors = Give()->customers->get_customers($args); |
|
| 289 | 289 | |
| 290 | - if ( $donors ) { |
|
| 290 | + if ($donors) { |
|
| 291 | 291 | |
| 292 | - $this->count = count( $donors ); |
|
| 292 | + $this->count = count($donors); |
|
| 293 | 293 | |
| 294 | - foreach ( $donors as $donor ) { |
|
| 294 | + foreach ($donors as $donor) { |
|
| 295 | 295 | |
| 296 | - $user_id = ! empty( $donor->user_id ) ? absint( $donor->user_id ) : 0; |
|
| 296 | + $user_id = ! empty($donor->user_id) ? absint($donor->user_id) : 0; |
|
| 297 | 297 | |
| 298 | 298 | $data[] = array( |
| 299 | 299 | 'id' => $donor->id, |
@@ -320,9 +320,9 @@ discard block |
||
| 320 | 320 | $_donor_query = $this->get_donor_query(); |
| 321 | 321 | |
| 322 | 322 | $_donor_query['number'] = -1; |
| 323 | - $donors = Give()->customers->get_customers( $_donor_query ); |
|
| 323 | + $donors = Give()->customers->get_customers($_donor_query); |
|
| 324 | 324 | |
| 325 | - return count( $donors ); |
|
| 325 | + return count($donors); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | /** |
@@ -334,10 +334,10 @@ discard block |
||
| 334 | 334 | */ |
| 335 | 335 | public function get_donor_query() { |
| 336 | 336 | $paged = $this->get_paged(); |
| 337 | - $offset = $this->per_page * ( $paged - 1 ); |
|
| 337 | + $offset = $this->per_page * ($paged - 1); |
|
| 338 | 338 | $search = $this->get_search(); |
| 339 | - $order = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC'; |
|
| 340 | - $orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id'; |
|
| 339 | + $order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC'; |
|
| 340 | + $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id'; |
|
| 341 | 341 | |
| 342 | 342 | $args = array( |
| 343 | 343 | 'number' => $this->per_page, |
@@ -346,10 +346,10 @@ discard block |
||
| 346 | 346 | 'orderby' => $orderby, |
| 347 | 347 | ); |
| 348 | 348 | |
| 349 | - if( $search ) { |
|
| 350 | - if ( is_email( $search ) ) { |
|
| 349 | + if ($search) { |
|
| 350 | + if (is_email($search)) { |
|
| 351 | 351 | $args['email'] = $search; |
| 352 | - } elseif ( is_numeric( $search ) ) { |
|
| 352 | + } elseif (is_numeric($search)) { |
|
| 353 | 353 | $args['id'] = $search; |
| 354 | 354 | } else { |
| 355 | 355 | $args['name'] = $search; |
@@ -376,16 +376,16 @@ discard block |
||
| 376 | 376 | $hidden = array(); // No hidden columns |
| 377 | 377 | $sortable = $this->get_sortable_columns(); |
| 378 | 378 | |
| 379 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
| 379 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
| 380 | 380 | |
| 381 | 381 | $this->items = $this->reports_data(); |
| 382 | 382 | |
| 383 | 383 | $this->total = $this->get_donor_count(); |
| 384 | 384 | |
| 385 | - $this->set_pagination_args( array( |
|
| 385 | + $this->set_pagination_args(array( |
|
| 386 | 386 | 'total_items' => $this->total, |
| 387 | 387 | 'per_page' => $this->per_page, |
| 388 | - 'total_pages' => ceil( $this->total / $this->per_page ), |
|
| 389 | - ) ); |
|
| 388 | + 'total_pages' => ceil($this->total / $this->per_page), |
|
| 389 | + )); |
|
| 390 | 390 | } |
| 391 | 391 | } |
@@ -9,11 +9,11 @@ discard block |
||
| 9 | 9 | * @since 1.8 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; // Exit if accessed directly |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -if ( ! class_exists( 'Give_Settings_Page' ) ) : |
|
| 16 | +if ( ! class_exists('Give_Settings_Page')) : |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Give_Settings_Page. |
@@ -62,11 +62,11 @@ discard block |
||
| 62 | 62 | // Get current setting page. |
| 63 | 63 | $this->current_setting_page = give_get_current_setting_page(); |
| 64 | 64 | |
| 65 | - add_filter( "give_default_setting_tab_section_{$this->id}", array( $this, 'set_default_setting_tab' ), 10 ); |
|
| 66 | - add_filter( "{$this->current_setting_page}_tabs_array", array( $this, 'add_settings_page' ), 20 ); |
|
| 67 | - add_action( "{$this->current_setting_page}_sections_{$this->id}_page", array( $this, 'output_sections' ) ); |
|
| 68 | - add_action( "{$this->current_setting_page}_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
| 69 | - add_action( "{$this->current_setting_page}_save_{$this->id}", array( $this, 'save' ) ); |
|
| 65 | + add_filter("give_default_setting_tab_section_{$this->id}", array($this, 'set_default_setting_tab'), 10); |
|
| 66 | + add_filter("{$this->current_setting_page}_tabs_array", array($this, 'add_settings_page'), 20); |
|
| 67 | + add_action("{$this->current_setting_page}_sections_{$this->id}_page", array($this, 'output_sections')); |
|
| 68 | + add_action("{$this->current_setting_page}_settings_{$this->id}_page", array($this, 'output')); |
|
| 69 | + add_action("{$this->current_setting_page}_save_{$this->id}", array($this, 'save')); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * |
| 79 | 79 | * @return string |
| 80 | 80 | */ |
| 81 | - function set_default_setting_tab( $setting_tab ) { |
|
| 81 | + function set_default_setting_tab($setting_tab) { |
|
| 82 | 82 | return $this->default_tab; |
| 83 | 83 | } |
| 84 | 84 | |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | * |
| 92 | 92 | * @return array |
| 93 | 93 | */ |
| 94 | - public function add_settings_page( $pages ) { |
|
| 95 | - $pages[ $this->id ] = $this->label; |
|
| 94 | + public function add_settings_page($pages) { |
|
| 95 | + $pages[$this->id] = $this->label; |
|
| 96 | 96 | |
| 97 | 97 | return $pages; |
| 98 | 98 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * |
| 112 | 112 | * @param array $settings |
| 113 | 113 | */ |
| 114 | - $settings = apply_filters( 'give_get_settings_' . $this->id, array() ); |
|
| 114 | + $settings = apply_filters('give_get_settings_'.$this->id, array()); |
|
| 115 | 115 | |
| 116 | 116 | // Output. |
| 117 | 117 | return $settings; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * @return array |
| 125 | 125 | */ |
| 126 | 126 | public function get_sections() { |
| 127 | - return apply_filters( 'give_get_sections_' . $this->id, array() ); |
|
| 127 | + return apply_filters('give_get_sections_'.$this->id, array()); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** |
@@ -141,29 +141,29 @@ discard block |
||
| 141 | 141 | $sections = $this->get_sections(); |
| 142 | 142 | |
| 143 | 143 | // Show section settings only if setting section exist. |
| 144 | - if ( $current_section && ! in_array( $current_section, array_keys( $sections ) ) ) { |
|
| 145 | - echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; |
|
| 144 | + if ($current_section && ! in_array($current_section, array_keys($sections))) { |
|
| 145 | + echo '<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>'; |
|
| 146 | 146 | $GLOBALS['give_hide_save_button'] = true; |
| 147 | 147 | |
| 148 | 148 | return; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Bailout. |
| 152 | - if ( empty( $sections ) ) { |
|
| 152 | + if (empty($sections)) { |
|
| 153 | 153 | return; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - if ( is_null( $this->current_setting_page ) ) { |
|
| 156 | + if (is_null($this->current_setting_page)) { |
|
| 157 | 157 | $this->current_setting_page = give_get_current_setting_page(); |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | echo '<ul class="subsubsub">'; |
| 161 | 161 | |
| 162 | 162 | // Get section keys. |
| 163 | - $array_keys = array_keys( $sections ); |
|
| 163 | + $array_keys = array_keys($sections); |
|
| 164 | 164 | |
| 165 | - foreach ( $sections as $id => $label ) { |
|
| 166 | - echo '<li><a href="' . admin_url( 'edit.php?post_type=give_forms&page=' . $this->current_setting_page . '&tab=' . $this->id . '§ion=' . sanitize_title( $id ) ) . '" class="' . ( $current_section == $id ? 'current' : '' ) . '">' . $label . '</a> ' . ( end( $array_keys ) == $id ? '' : '|' ) . ' </li>'; |
|
| 165 | + foreach ($sections as $id => $label) { |
|
| 166 | + echo '<li><a href="'.admin_url('edit.php?post_type=give_forms&page='.$this->current_setting_page.'&tab='.$this->id.'§ion='.sanitize_title($id)).'" class="'.($current_section == $id ? 'current' : '').'">'.$label.'</a> '.(end($array_keys) == $id ? '' : '|').' </li>'; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | echo '</ul><br class="clear" /><hr>'; |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | public function output() { |
| 179 | 179 | $settings = $this->get_settings(); |
| 180 | 180 | |
| 181 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
| 181 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
@@ -191,14 +191,14 @@ discard block |
||
| 191 | 191 | $settings = $this->get_settings(); |
| 192 | 192 | $current_section = give_get_current_setting_section(); |
| 193 | 193 | |
| 194 | - Give_Admin_Settings::save_fields( $settings, 'give_settings' ); |
|
| 194 | + Give_Admin_Settings::save_fields($settings, 'give_settings'); |
|
| 195 | 195 | |
| 196 | 196 | /** |
| 197 | 197 | * Trigger Action |
| 198 | 198 | * |
| 199 | 199 | * @since 1.8 |
| 200 | 200 | */ |
| 201 | - do_action( 'give_update_options_' . $this->id . '_' . $current_section ); |
|
| 201 | + do_action('give_update_options_'.$this->id.'_'.$current_section); |
|
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
@@ -9,11 +9,11 @@ discard block |
||
| 9 | 9 | * @since 1.8 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; // Exit if accessed directly |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -if ( ! class_exists( 'Give_Settings_Gateways' ) ) : |
|
| 16 | +if ( ! class_exists('Give_Settings_Gateways')) : |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Give_Settings_Gateways. |
@@ -43,16 +43,16 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function __construct() { |
| 45 | 45 | $this->id = 'gateways'; |
| 46 | - $this->label = esc_html__( 'Donation Methods', 'give' ); |
|
| 46 | + $this->label = esc_html__('Donation Methods', 'give'); |
|
| 47 | 47 | |
| 48 | - add_filter( 'give-reports_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
| 49 | - add_action( "give-reports_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
| 50 | - add_action( 'give_admin_field_report_gateways', array( $this, 'render_report_gateways_field' ), 10, 2 ); |
|
| 48 | + add_filter('give-reports_tabs_array', array($this, 'add_settings_page'), 20); |
|
| 49 | + add_action("give-reports_settings_{$this->id}_page", array($this, 'output')); |
|
| 50 | + add_action('give_admin_field_report_gateways', array($this, 'render_report_gateways_field'), 10, 2); |
|
| 51 | 51 | |
| 52 | 52 | // Do not use main form for this tab. |
| 53 | - if( give_get_current_setting_tab() === $this->id ) { |
|
| 54 | - add_action( 'give-reports_open_form', '__return_empty_string' ); |
|
| 55 | - add_action( 'give-reports_close_form', '__return_empty_string' ); |
|
| 53 | + if (give_get_current_setting_tab() === $this->id) { |
|
| 54 | + add_action('give-reports_open_form', '__return_empty_string'); |
|
| 55 | + add_action('give-reports_close_form', '__return_empty_string'); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | * @param array $pages Lst of pages. |
| 64 | 64 | * @return array |
| 65 | 65 | */ |
| 66 | - public function add_settings_page( $pages ) { |
|
| 67 | - $pages[ $this->id ] = $this->label; |
|
| 66 | + public function add_settings_page($pages) { |
|
| 67 | + $pages[$this->id] = $this->label; |
|
| 68 | 68 | |
| 69 | 69 | return $pages; |
| 70 | 70 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @param array $settings |
| 87 | 87 | */ |
| 88 | 88 | $settings = apply_filters( |
| 89 | - 'give_get_settings_' . $this->id, |
|
| 89 | + 'give_get_settings_'.$this->id, |
|
| 90 | 90 | array( |
| 91 | 91 | array( |
| 92 | 92 | 'id' => 'give_reports_gateways', |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | ), |
| 96 | 96 | array( |
| 97 | 97 | 'id' => 'gateways', |
| 98 | - 'name' => esc_html__( 'Gateways', 'give' ), |
|
| 98 | + 'name' => esc_html__('Gateways', 'give'), |
|
| 99 | 99 | 'type' => 'report_gateways', |
| 100 | 100 | ), |
| 101 | 101 | array( |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | public function output() { |
| 120 | 120 | $settings = $this->get_settings(); |
| 121 | 121 | |
| 122 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
| 122 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | * @param $field |
| 132 | 132 | * @param $option_value |
| 133 | 133 | */ |
| 134 | - public function render_report_gateways_field( $field, $option_value ) { |
|
| 135 | - do_action( 'give_reports_view_gateways'); |
|
| 134 | + public function render_report_gateways_field($field, $option_value) { |
|
| 135 | + do_action('give_reports_view_gateways'); |
|
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |