@@ -10,11 +10,11 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if access directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | -if ( ! class_exists( 'Give_New_Donor_Register_Email' ) ) : |
|
| 17 | +if ( ! class_exists('Give_New_Donor_Register_Email')) : |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Give_New_Donor_Register_Email |
@@ -31,34 +31,34 @@ discard block |
||
| 31 | 31 | * @since 2.0 |
| 32 | 32 | */ |
| 33 | 33 | public function init() { |
| 34 | - $this->load( array( |
|
| 34 | + $this->load(array( |
|
| 35 | 35 | 'id' => 'new-donor-register', |
| 36 | - 'label' => __( 'New User Registration', 'give' ), |
|
| 37 | - 'description' => __( 'Sent to designated recipient(s) when a new user registers on the site via a donation form.', 'give' ), |
|
| 36 | + 'label' => __('New User Registration', 'give'), |
|
| 37 | + 'description' => __('Sent to designated recipient(s) when a new user registers on the site via a donation form.', 'give'), |
|
| 38 | 38 | 'has_recipient_field' => true, |
| 39 | 39 | 'notification_status' => 'enabled', |
| 40 | 40 | 'has_preview_header' => true, |
| 41 | - 'email_tag_context' => array( 'donor', 'general' ), |
|
| 41 | + 'email_tag_context' => array('donor', 'general'), |
|
| 42 | 42 | 'form_metabox_setting' => false, |
| 43 | 43 | 'default_email_subject' => sprintf( |
| 44 | 44 | /* translators: %s: site name */ |
| 45 | - esc_attr__( '[%s] New User Registration', 'give' ), |
|
| 46 | - get_bloginfo( 'name' ) |
|
| 45 | + esc_attr__('[%s] New User Registration', 'give'), |
|
| 46 | + get_bloginfo('name') |
|
| 47 | 47 | ), |
| 48 | 48 | 'default_email_message' => $this->get_default_email_message(), |
| 49 | - ) ); |
|
| 49 | + )); |
|
| 50 | 50 | |
| 51 | 51 | // Setup action hook. |
| 52 | 52 | add_action( |
| 53 | 53 | "give_{$this->config['id']}_email_notification", |
| 54 | - array( $this, 'setup_email_notification' ), |
|
| 54 | + array($this, 'setup_email_notification'), |
|
| 55 | 55 | 10, |
| 56 | 56 | 2 |
| 57 | 57 | ); |
| 58 | 58 | |
| 59 | 59 | add_filter( |
| 60 | 60 | 'give_email_preview_header', |
| 61 | - array( $this, 'email_preview_header' ), |
|
| 61 | + array($this, 'email_preview_header'), |
|
| 62 | 62 | 10, |
| 63 | 63 | 2 |
| 64 | 64 | ); |
@@ -73,9 +73,9 @@ discard block |
||
| 73 | 73 | * @return string |
| 74 | 74 | */ |
| 75 | 75 | function get_default_email_message() { |
| 76 | - $message = esc_attr__( 'New user registration on your site {sitename}:', 'give' ) . "\r\n\r\n"; |
|
| 77 | - $message .= esc_attr__( 'Username: {username}', 'give' ) . "\r\n\r\n"; |
|
| 78 | - $message .= esc_attr__( 'Email: {user_email}', 'give' ) . "\r\n"; |
|
| 76 | + $message = esc_attr__('New user registration on your site {sitename}:', 'give')."\r\n\r\n"; |
|
| 77 | + $message .= esc_attr__('Username: {username}', 'give')."\r\n\r\n"; |
|
| 78 | + $message .= esc_attr__('Email: {user_email}', 'give')."\r\n"; |
|
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * Filter the default email message |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @since 2.0 |
| 96 | 96 | */ |
| 97 | 97 | public function setup_email_data() { |
| 98 | - Give()->emails->__set( 'heading', esc_html__( 'New User Registration', 'give' ) ); |
|
| 98 | + Give()->emails->__set('heading', esc_html__('New User Registration', 'give')); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | |
@@ -110,12 +110,12 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @return string |
| 112 | 112 | */ |
| 113 | - public function setup_email_notification( $user_id, $user_data ) { |
|
| 113 | + public function setup_email_notification($user_id, $user_data) { |
|
| 114 | 114 | $this->setup_email_data(); |
| 115 | 115 | |
| 116 | - $this->send_email_notification( array( |
|
| 116 | + $this->send_email_notification(array( |
|
| 117 | 117 | 'user_id' => $user_id, |
| 118 | - ) ); |
|
| 118 | + )); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | |
@@ -129,42 +129,42 @@ discard block |
||
| 129 | 129 | * @param Give_New_Donor_Register_Email $email |
| 130 | 130 | * @return string |
| 131 | 131 | */ |
| 132 | - public function email_preview_header( $email_preview_header, $email ) { |
|
| 132 | + public function email_preview_header($email_preview_header, $email) { |
|
| 133 | 133 | // Bailout. |
| 134 | - if ( $this->config['id'] !== $email->config['id'] ) { |
|
| 134 | + if ($this->config['id'] !== $email->config['id']) { |
|
| 135 | 135 | return $email_preview_header; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | // Payment receipt switcher |
| 139 | - $user_id = give_check_variable( give_clean( $_GET ), 'isset', 0, 'user_id' ); |
|
| 139 | + $user_id = give_check_variable(give_clean($_GET), 'isset', 0, 'user_id'); |
|
| 140 | 140 | |
| 141 | 141 | // Get payments. |
| 142 | 142 | $donors = new Give_API(); |
| 143 | - $donors = give_check_variable( $donors->get_donors(), 'empty', array(), 'donors' ); |
|
| 143 | + $donors = give_check_variable($donors->get_donors(), 'empty', array(), 'donors'); |
|
| 144 | 144 | $options = array(); |
| 145 | 145 | |
| 146 | 146 | // Default option. |
| 147 | - $options[0] = esc_html__( 'No donor(s) found.', 'give' ); |
|
| 147 | + $options[0] = esc_html__('No donor(s) found.', 'give'); |
|
| 148 | 148 | |
| 149 | 149 | // Provide nice human readable options. |
| 150 | - if ( $donors ) { |
|
| 151 | - $options[0] = esc_html__( '- Select a donor -', 'give' ); |
|
| 152 | - foreach ( $donors as $donor ) { |
|
| 150 | + if ($donors) { |
|
| 151 | + $options[0] = esc_html__('- Select a donor -', 'give'); |
|
| 152 | + foreach ($donors as $donor) { |
|
| 153 | 153 | // Exclude customers for which wp user not exist. |
| 154 | - if ( ! $donor['info']['user_id'] ) { |
|
| 154 | + if ( ! $donor['info']['user_id']) { |
|
| 155 | 155 | continue; |
| 156 | 156 | } |
| 157 | - $options[ $donor['info']['user_id'] ] = esc_html( '#' . $donor['info']['donor_id'] . ' - ' . $donor['info']['email'] ); |
|
| 157 | + $options[$donor['info']['user_id']] = esc_html('#'.$donor['info']['donor_id'].' - '.$donor['info']['email']); |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - $request_url_data = wp_parse_url( $_SERVER['REQUEST_URI'] ); |
|
| 161 | + $request_url_data = wp_parse_url($_SERVER['REQUEST_URI']); |
|
| 162 | 162 | $query = $request_url_data['query']; |
| 163 | 163 | |
| 164 | 164 | // Remove user id query param if set from request url. |
| 165 | - $query = remove_query_arg( array( 'user_id' ), $query ); |
|
| 165 | + $query = remove_query_arg(array('user_id'), $query); |
|
| 166 | 166 | |
| 167 | - $request_url = home_url( '/?' . str_replace( '', '', $query ) ); |
|
| 167 | + $request_url = home_url('/?'.str_replace('', '', $query)); |
|
| 168 | 168 | ?> |
| 169 | 169 | <script type="text/javascript"> |
| 170 | 170 | function change_preview() { |
@@ -198,12 +198,12 @@ discard block |
||
| 198 | 198 | <div class="give_preview_email_user_id_main"> |
| 199 | 199 | |
| 200 | 200 | <label for="give_preview_email_user_id" class="give_preview_email_user_id_label"> |
| 201 | - <?php echo esc_html__( 'Preview email with a donor:', 'give' ); ?> |
|
| 201 | + <?php echo esc_html__('Preview email with a donor:', 'give'); ?> |
|
| 202 | 202 | </label> |
| 203 | 203 | |
| 204 | 204 | <?php |
| 205 | 205 | // The select field with 100 latest transactions |
| 206 | - echo Give()->html->select( array( |
|
| 206 | + echo Give()->html->select(array( |
|
| 207 | 207 | 'name' => 'preview_email_user_id', |
| 208 | 208 | 'selected' => $user_id, |
| 209 | 209 | 'id' => 'give_preview_email_user_id', |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | 'select_atts' => 'onchange="change_preview()"', |
| 214 | 214 | 'show_option_all' => false, |
| 215 | 215 | 'show_option_none' => false, |
| 216 | - ) ); |
|
| 216 | + )); |
|
| 217 | 217 | ?> |
| 218 | 218 | <!-- Closing tag--> |
| 219 | 219 | </div> |
@@ -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 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | /* @var WPDB $wpdb */ |
| 36 | 36 | global $wpdb; |
| 37 | 37 | |
| 38 | - $this->table_name = $wpdb->prefix . 'give_logs'; |
|
| 38 | + $this->table_name = $wpdb->prefix.'give_logs'; |
|
| 39 | 39 | $this->primary_key = 'ID'; |
| 40 | 40 | $this->version = '1.0'; |
| 41 | 41 | |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | * @return array Default column values. |
| 74 | 74 | */ |
| 75 | 75 | public function get_column_defaults() { |
| 76 | - $log_create_date = current_time( 'mysql', 0 ); |
|
| 77 | - $log_create_date_gmt = get_gmt_from_date( $log_create_date ); |
|
| 76 | + $log_create_date = current_time('mysql', 0); |
|
| 77 | + $log_create_date_gmt = get_gmt_from_date($log_create_date); |
|
| 78 | 78 | |
| 79 | 79 | return array( |
| 80 | 80 | 'ID' => 0, |
@@ -97,39 +97,39 @@ discard block |
||
| 97 | 97 | * |
| 98 | 98 | * @return bool|int |
| 99 | 99 | */ |
| 100 | - public function add( $data = array() ) { |
|
| 100 | + public function add($data = array()) { |
|
| 101 | 101 | // Valid table columns. |
| 102 | - $table_columns = array_keys( $this->get_columns() ); |
|
| 102 | + $table_columns = array_keys($this->get_columns()); |
|
| 103 | 103 | |
| 104 | 104 | // Filter data. |
| 105 | - foreach ( $data as $table_column => $column_data ) { |
|
| 106 | - if ( ! in_array( $table_column, $table_columns ) ) { |
|
| 107 | - unset( $data[ $table_column ] ); |
|
| 105 | + foreach ($data as $table_column => $column_data) { |
|
| 106 | + if ( ! in_array($table_column, $table_columns)) { |
|
| 107 | + unset($data[$table_column]); |
|
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | // Set default values. |
| 112 | - $current_log_data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
| 112 | + $current_log_data = wp_parse_args($data, $this->get_column_defaults()); |
|
| 113 | 113 | |
| 114 | 114 | // Log parent should be an int. |
| 115 | - $current_log_data['log_parent'] = absint( $current_log_data['log_parent'] ); |
|
| 115 | + $current_log_data['log_parent'] = absint($current_log_data['log_parent']); |
|
| 116 | 116 | |
| 117 | 117 | // Get log. |
| 118 | - $existing_log = $this->get_log_by( $current_log_data['ID'] ); |
|
| 118 | + $existing_log = $this->get_log_by($current_log_data['ID']); |
|
| 119 | 119 | |
| 120 | 120 | // Update an existing log. |
| 121 | - if ( $existing_log ) { |
|
| 121 | + if ($existing_log) { |
|
| 122 | 122 | |
| 123 | 123 | // Create new log data from existing and new log data. |
| 124 | - $current_log_data = array_merge( $current_log_data, $existing_log ); |
|
| 124 | + $current_log_data = array_merge($current_log_data, $existing_log); |
|
| 125 | 125 | |
| 126 | 126 | // Update log data. |
| 127 | - $this->update( $current_log_data['ID'], $current_log_data ); |
|
| 127 | + $this->update($current_log_data['ID'], $current_log_data); |
|
| 128 | 128 | |
| 129 | 129 | $log_id = $current_log_data['ID']; |
| 130 | 130 | |
| 131 | 131 | } else { |
| 132 | - $log_id = $this->insert( $current_log_data, 'log' ); |
|
| 132 | + $log_id = $this->insert($current_log_data, 'log'); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | return $log_id; |
@@ -147,20 +147,20 @@ discard block |
||
| 147 | 147 | * |
| 148 | 148 | * @return bool|null|array |
| 149 | 149 | */ |
| 150 | - public function get_log_by( $log_id = 0, $by = 'id' ) { |
|
| 150 | + public function get_log_by($log_id = 0, $by = 'id') { |
|
| 151 | 151 | /* @var WPDB $wpdb */ |
| 152 | 152 | global $wpdb; |
| 153 | 153 | $log = null; |
| 154 | 154 | |
| 155 | 155 | // Make sure $log_id is int. |
| 156 | - $log_id = absint( $log_id ); |
|
| 156 | + $log_id = absint($log_id); |
|
| 157 | 157 | |
| 158 | 158 | // Bailout. |
| 159 | - if ( empty( $log_id ) ) { |
|
| 159 | + if (empty($log_id)) { |
|
| 160 | 160 | return null; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - switch ( $by ) { |
|
| 163 | + switch ($by) { |
|
| 164 | 164 | case 'id': |
| 165 | 165 | $log = $wpdb->get_row( |
| 166 | 166 | $wpdb->prepare( |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | break; |
| 173 | 173 | |
| 174 | 174 | default: |
| 175 | - $log = apply_filters( "give_get_log_by_{$by}", $log, $log_id ); |
|
| 175 | + $log = apply_filters("give_get_log_by_{$by}", $log, $log_id); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | return $log; |
@@ -188,14 +188,14 @@ discard block |
||
| 188 | 188 | * |
| 189 | 189 | * @return mixed |
| 190 | 190 | */ |
| 191 | - public function get_logs( $args = array() ) { |
|
| 191 | + public function get_logs($args = array()) { |
|
| 192 | 192 | global $wpdb; |
| 193 | - $sql_query = $this->get_sql( $args ); |
|
| 193 | + $sql_query = $this->get_sql($args); |
|
| 194 | 194 | |
| 195 | 195 | // Get log. |
| 196 | - if ( ! ( $logs = Give_Cache::get( 'give_logs', true, $sql_query ) ) ) { |
|
| 197 | - $logs = $wpdb->get_results( $sql_query ); |
|
| 198 | - Give_Cache::set( 'give_logs', $logs, 3600, true, $sql_query ); |
|
| 196 | + if ( ! ($logs = Give_Cache::get('give_logs', true, $sql_query))) { |
|
| 197 | + $logs = $wpdb->get_results($sql_query); |
|
| 198 | + Give_Cache::set('give_logs', $logs, 3600, true, $sql_query); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | return $logs; |
@@ -212,21 +212,21 @@ discard block |
||
| 212 | 212 | * |
| 213 | 213 | * @return int |
| 214 | 214 | */ |
| 215 | - public function count( $args = array() ) { |
|
| 215 | + public function count($args = array()) { |
|
| 216 | 216 | /* @var WPDB $wpdb */ |
| 217 | 217 | global $wpdb; |
| 218 | 218 | $args['number'] = - 1; |
| 219 | 219 | $args['fields'] = 'ID'; |
| 220 | 220 | $args['count'] = true; |
| 221 | 221 | |
| 222 | - $sql_query = $this->get_sql( $args ); |
|
| 222 | + $sql_query = $this->get_sql($args); |
|
| 223 | 223 | |
| 224 | - if ( ! ( $count = Give_Cache::get( 'give_logs_count', true, $sql_query ) ) ) { |
|
| 225 | - $count = $wpdb->get_var( $sql_query ); |
|
| 226 | - Give_Cache::set( 'give_logs_count', $count, 3600, true, $args ); |
|
| 224 | + if ( ! ($count = Give_Cache::get('give_logs_count', true, $sql_query))) { |
|
| 225 | + $count = $wpdb->get_var($sql_query); |
|
| 226 | + Give_Cache::set('give_logs_count', $count, 3600, true, $args); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - return absint( $count ); |
|
| 229 | + return absint($count); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -252,10 +252,10 @@ discard block |
||
| 252 | 252 | PRIMARY KEY (ID) |
| 253 | 253 | ) {$charset_collate};"; |
| 254 | 254 | |
| 255 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 256 | - dbDelta( $sql ); |
|
| 255 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 256 | + dbDelta($sql); |
|
| 257 | 257 | |
| 258 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
| 258 | + update_option($this->table_name.'_db_version', $this->version); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | * |
| 270 | 270 | * @return string |
| 271 | 271 | */ |
| 272 | - public function get_sql( $args = array() ) { |
|
| 272 | + public function get_sql($args = array()) { |
|
| 273 | 273 | /* @var WPDB $wpdb */ |
| 274 | 274 | global $wpdb; |
| 275 | 275 | |
@@ -283,12 +283,12 @@ discard block |
||
| 283 | 283 | 'count' => false, |
| 284 | 284 | ); |
| 285 | 285 | |
| 286 | - $args = wp_parse_args( $args, $defaults ); |
|
| 286 | + $args = wp_parse_args($args, $defaults); |
|
| 287 | 287 | |
| 288 | 288 | // validate params. |
| 289 | - $this->validate_params( $args ); |
|
| 289 | + $this->validate_params($args); |
|
| 290 | 290 | |
| 291 | - if ( $args['number'] < 1 ) { |
|
| 291 | + if ($args['number'] < 1) { |
|
| 292 | 292 | $args['number'] = 99999999999; |
| 293 | 293 | } |
| 294 | 294 | |
@@ -296,78 +296,78 @@ discard block |
||
| 296 | 296 | $where = ''; |
| 297 | 297 | |
| 298 | 298 | // Get sql query for meta. |
| 299 | - if ( ! empty( $args['meta_query'] ) ) { |
|
| 300 | - $meta_query_object = new WP_Meta_Query( $args['meta_query'] ); |
|
| 301 | - $meta_query = $meta_query_object->get_sql( 'log', $this->table_name, 'id' ); |
|
| 302 | - $where = implode( '', $meta_query ); |
|
| 299 | + if ( ! empty($args['meta_query'])) { |
|
| 300 | + $meta_query_object = new WP_Meta_Query($args['meta_query']); |
|
| 301 | + $meta_query = $meta_query_object->get_sql('log', $this->table_name, 'id'); |
|
| 302 | + $where = implode('', $meta_query); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | $where .= ' WHERE 1=1 '; |
| 306 | 306 | |
| 307 | 307 | // Set offset. |
| 308 | - if ( empty( $args['offset'] ) && ( 0 < $args['paged'] ) ) { |
|
| 309 | - $args['offset'] = $args['number'] * ( $args['paged'] - 1 ); |
|
| 308 | + if (empty($args['offset']) && (0 < $args['paged'])) { |
|
| 309 | + $args['offset'] = $args['number'] * ($args['paged'] - 1); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | // Set fields. |
| 313 | 313 | $fields = "{$this->table_name}.*"; |
| 314 | - if ( is_string( $args['fields'] ) && ( 'all' !== $args['fields'] ) ) { |
|
| 314 | + if (is_string($args['fields']) && ('all' !== $args['fields'])) { |
|
| 315 | 315 | $fields = "{$this->table_name}.{$args['fields']}"; |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | // Set count. |
| 319 | - if ( $args['count'] ) { |
|
| 319 | + if ($args['count']) { |
|
| 320 | 320 | $fields = "COUNT({$fields})"; |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | // Specific logs. |
| 324 | - if ( ! empty( $args['ID'] ) ) { |
|
| 324 | + if ( ! empty($args['ID'])) { |
|
| 325 | 325 | |
| 326 | - if ( ! is_array( $args['ID'] ) ) { |
|
| 327 | - $args['ID'] = explode( ',', $args['ID'] ); |
|
| 326 | + if ( ! is_array($args['ID'])) { |
|
| 327 | + $args['ID'] = explode(',', $args['ID']); |
|
| 328 | 328 | } |
| 329 | - $log_ids = implode( ',', array_map( 'intval', $args['ID'] ) ); |
|
| 329 | + $log_ids = implode(',', array_map('intval', $args['ID'])); |
|
| 330 | 330 | |
| 331 | 331 | $where .= " AND {$this->table_name}.ID IN( {$log_ids} ) "; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | // Logs created for a specific date or in a date range |
| 335 | - if ( ! empty( $args['date_query'] ) ) { |
|
| 336 | - $date_query_object = new WP_Date_Query( $args['date_query'], "{$this->table_name}.log_date" ); |
|
| 337 | - $where .= $date_query_object->get_sql(); |
|
| 335 | + if ( ! empty($args['date_query'])) { |
|
| 336 | + $date_query_object = new WP_Date_Query($args['date_query'], "{$this->table_name}.log_date"); |
|
| 337 | + $where .= $date_query_object->get_sql(); |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | // Logs create for specific parent. |
| 341 | - if ( ! empty( $args['log_parent'] ) ) { |
|
| 342 | - if ( ! is_array( $args['log_parent'] ) ) { |
|
| 343 | - $args['log_parent'] = explode( ',', $args['log_parent'] ); |
|
| 341 | + if ( ! empty($args['log_parent'])) { |
|
| 342 | + if ( ! is_array($args['log_parent'])) { |
|
| 343 | + $args['log_parent'] = explode(',', $args['log_parent']); |
|
| 344 | 344 | } |
| 345 | - $parent_ids = implode( ',', array_map( 'intval', $args['log_parent'] ) ); |
|
| 345 | + $parent_ids = implode(',', array_map('intval', $args['log_parent'])); |
|
| 346 | 346 | |
| 347 | 347 | $where .= " AND {$this->table_name}.log_parent IN( {$parent_ids} ) "; |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | // Logs create for specific type. |
| 351 | 351 | // is_array check is for backward compatibility. |
| 352 | - if ( ! empty( $args['log_type'] ) && ! is_array( $args['log_type'] ) ) { |
|
| 353 | - if ( ! is_array( $args['log_type'] ) ) { |
|
| 354 | - $args['log_type'] = explode( ',', $args['log_type'] ); |
|
| 352 | + if ( ! empty($args['log_type']) && ! is_array($args['log_type'])) { |
|
| 353 | + if ( ! is_array($args['log_type'])) { |
|
| 354 | + $args['log_type'] = explode(',', $args['log_type']); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - $log_types = implode( '\',\'', array_map( 'trim', $args['log_type'] ) ); |
|
| 357 | + $log_types = implode('\',\'', array_map('trim', $args['log_type'])); |
|
| 358 | 358 | |
| 359 | 359 | $where .= " AND {$this->table_name}.log_type IN( '{$log_types}' ) "; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - $args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'log_date' : $args['orderby']; |
|
| 362 | + $args['orderby'] = ! array_key_exists($args['orderby'], $this->get_columns()) ? 'log_date' : $args['orderby']; |
|
| 363 | 363 | |
| 364 | - $args['orderby'] = esc_sql( $args['orderby'] ); |
|
| 365 | - $args['order'] = esc_sql( $args['order'] ); |
|
| 364 | + $args['orderby'] = esc_sql($args['orderby']); |
|
| 365 | + $args['order'] = esc_sql($args['order']); |
|
| 366 | 366 | |
| 367 | 367 | return $wpdb->prepare( |
| 368 | 368 | "SELECT {$fields} FROM {$this->table_name} {$where} ORDER BY {$this->table_name}.{$args['orderby']} {$args['order']} LIMIT %d,%d;", |
| 369 | - absint( $args['offset'] ), |
|
| 370 | - absint( $args['number'] ) |
|
| 369 | + absint($args['offset']), |
|
| 370 | + absint($args['number']) |
|
| 371 | 371 | ); |
| 372 | 372 | } |
| 373 | 373 | |
@@ -382,13 +382,11 @@ discard block |
||
| 382 | 382 | * |
| 383 | 383 | * @return mixed |
| 384 | 384 | */ |
| 385 | - private function validate_params( &$args ) { |
|
| 385 | + private function validate_params(&$args) { |
|
| 386 | 386 | // fields params |
| 387 | 387 | $args['fields'] = 'ids' === $args['fields'] ? |
| 388 | - 'ID' : |
|
| 389 | - $args['fields']; |
|
| 390 | - $args['fields'] = array_key_exists( $args['fields'], $this->get_columns() ) ? |
|
| 391 | - $args['fields'] : |
|
| 392 | - 'all'; |
|
| 388 | + 'ID' : $args['fields']; |
|
| 389 | + $args['fields'] = array_key_exists($args['fields'], $this->get_columns()) ? |
|
| 390 | + $args['fields'] : 'all'; |
|
| 393 | 391 | } |
| 394 | 392 | } |
@@ -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 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @param $args array The array of arguments that can be passed in and used for setting up this payment query. |
| 88 | 88 | */ |
| 89 | - public function __construct( $args = array() ) { |
|
| 89 | + public function __construct($args = array()) { |
|
| 90 | 90 | $defaults = array( |
| 91 | 91 | 'number' => 20, |
| 92 | 92 | 'offset' => 0, |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | // 'form' => array(), |
| 105 | 105 | ); |
| 106 | 106 | |
| 107 | - $this->args = wp_parse_args( $args, $defaults ); |
|
| 107 | + $this->args = wp_parse_args($args, $defaults); |
|
| 108 | 108 | $this->table_name = Give()->donors->table_name; |
| 109 | 109 | $this->meta_table_name = Give()->donor_meta->table_name; |
| 110 | 110 | $this->meta_type = Give()->donor_meta->meta_type; |
@@ -146,21 +146,21 @@ discard block |
||
| 146 | 146 | * |
| 147 | 147 | * @param Give_Donors_Query $this Donors query object. |
| 148 | 148 | */ |
| 149 | - do_action( 'give_pre_get_donors', $this ); |
|
| 149 | + do_action('give_pre_get_donors', $this); |
|
| 150 | 150 | |
| 151 | - $cache_key = Give_Cache::get_key( 'give_donor', $this->get_sql(), false ); |
|
| 151 | + $cache_key = Give_Cache::get_key('give_donor', $this->get_sql(), false); |
|
| 152 | 152 | |
| 153 | 153 | // Get donors from cache. |
| 154 | - $this->donors = Give_Cache::get_db_query( $cache_key ); |
|
| 154 | + $this->donors = Give_Cache::get_db_query($cache_key); |
|
| 155 | 155 | |
| 156 | - if ( is_null( $this->donors ) ) { |
|
| 157 | - if ( empty( $this->args['count'] ) ) { |
|
| 158 | - $this->donors = $wpdb->get_results( $this->get_sql() ); |
|
| 156 | + if (is_null($this->donors)) { |
|
| 157 | + if (empty($this->args['count'])) { |
|
| 158 | + $this->donors = $wpdb->get_results($this->get_sql()); |
|
| 159 | 159 | } else { |
| 160 | - $this->donors = $wpdb->get_var( $this->get_sql() ); |
|
| 160 | + $this->donors = $wpdb->get_var($this->get_sql()); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - Give_Cache::set_db_query( $cache_key, $this->donors ); |
|
| 163 | + Give_Cache::set_db_query($cache_key, $this->donors); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * |
| 172 | 172 | * @param Give_Donors_Query $this Donors query object. |
| 173 | 173 | */ |
| 174 | - do_action( 'give_post_get_donors', $this ); |
|
| 174 | + do_action('give_post_get_donors', $this); |
|
| 175 | 175 | |
| 176 | 176 | return $this->donors; |
| 177 | 177 | } |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | public function get_sql() { |
| 189 | 189 | global $wpdb; |
| 190 | 190 | |
| 191 | - if ( $this->args['number'] < 1 ) { |
|
| 191 | + if ($this->args['number'] < 1) { |
|
| 192 | 192 | $this->args['number'] = 99999999999; |
| 193 | 193 | } |
| 194 | 194 | |
@@ -196,22 +196,22 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | |
| 198 | 198 | // Set offset. |
| 199 | - if ( empty( $this->args['offset'] ) && ( 0 < $this->args['paged'] ) ) { |
|
| 200 | - $this->args['offset'] = $this->args['number'] * ( $this->args['paged'] - 1 ); |
|
| 199 | + if (empty($this->args['offset']) && (0 < $this->args['paged'])) { |
|
| 200 | + $this->args['offset'] = $this->args['number'] * ($this->args['paged'] - 1); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | // Set fields. |
| 204 | 204 | $fields = "{$this->table_name}.*"; |
| 205 | - if ( ! empty( $this->args['fields'] ) && 'all' !== $this->args['fields'] ) { |
|
| 206 | - if ( is_string( $this->args['fields'] ) ) { |
|
| 205 | + if ( ! empty($this->args['fields']) && 'all' !== $this->args['fields']) { |
|
| 206 | + if (is_string($this->args['fields'])) { |
|
| 207 | 207 | $fields = "{$this->table_name}.{$this->args['fields']}"; |
| 208 | - } elseif ( is_array( $this->args['fields'] ) ) { |
|
| 209 | - $fields = "{$this->table_name}." . implode( " , {$this->table_name}.", $this->args['fields'] ); |
|
| 208 | + } elseif (is_array($this->args['fields'])) { |
|
| 209 | + $fields = "{$this->table_name}.".implode(" , {$this->table_name}.", $this->args['fields']); |
|
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | // Set count. |
| 214 | - if ( ! empty( $this->args['count'] ) ) { |
|
| 214 | + if ( ! empty($this->args['count'])) { |
|
| 215 | 215 | $fields = "COUNT({$this->table_name}.id)"; |
| 216 | 216 | } |
| 217 | 217 | |
@@ -219,13 +219,13 @@ discard block |
||
| 219 | 219 | |
| 220 | 220 | $sql = $wpdb->prepare( |
| 221 | 221 | "SELECT {$fields} FROM {$this->table_name} LIMIT %d,%d;", |
| 222 | - absint( $this->args['offset'] ), |
|
| 223 | - absint( $this->args['number'] ) |
|
| 222 | + absint($this->args['offset']), |
|
| 223 | + absint($this->args['number']) |
|
| 224 | 224 | ); |
| 225 | 225 | |
| 226 | 226 | // $where, $orderby and order already prepared query they can generate notice if you re prepare them in above. |
| 227 | 227 | // WordPress consider LIKE condition as placeholder if start with s,f, or d. |
| 228 | - $sql = str_replace( 'LIMIT', "{$where} {$orderby} {$this->args['order']} LIMIT", $sql ); |
|
| 228 | + $sql = str_replace('LIMIT', "{$where} {$orderby} {$this->args['order']} LIMIT", $sql); |
|
| 229 | 229 | |
| 230 | 230 | return $sql; |
| 231 | 231 | } |
@@ -243,15 +243,15 @@ discard block |
||
| 243 | 243 | $where = ''; |
| 244 | 244 | |
| 245 | 245 | // Get sql query for meta. |
| 246 | - if ( ! empty( $this->args['meta_query'] ) ) { |
|
| 247 | - $meta_query_object = new WP_Meta_Query( $this->args['meta_query'] ); |
|
| 246 | + if ( ! empty($this->args['meta_query'])) { |
|
| 247 | + $meta_query_object = new WP_Meta_Query($this->args['meta_query']); |
|
| 248 | 248 | $meta_query = $meta_query_object->get_sql( |
| 249 | 249 | $this->meta_type, |
| 250 | 250 | $this->table_name, |
| 251 | 251 | 'id' |
| 252 | 252 | ); |
| 253 | 253 | |
| 254 | - $where = implode( '', $meta_query ); |
|
| 254 | + $where = implode('', $meta_query); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | $where .= 'WHERE 1=1 '; |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | $where .= $this->get_where_user(); |
| 262 | 262 | $where .= $this->get_where_date(); |
| 263 | 263 | |
| 264 | - return trim( $where ); |
|
| 264 | + return trim($where); |
|
| 265 | 265 | |
| 266 | 266 | } |
| 267 | 267 | |
@@ -279,17 +279,17 @@ discard block |
||
| 279 | 279 | |
| 280 | 280 | $where = ''; |
| 281 | 281 | |
| 282 | - if ( ! empty( $this->args['email'] ) ) { |
|
| 282 | + if ( ! empty($this->args['email'])) { |
|
| 283 | 283 | |
| 284 | - if ( is_array( $this->args['email'] ) ) { |
|
| 284 | + if (is_array($this->args['email'])) { |
|
| 285 | 285 | |
| 286 | - $emails_count = count( $this->args['email'] ); |
|
| 287 | - $emails_placeholder = array_fill( 0, $emails_count, '%s' ); |
|
| 288 | - $emails = implode( ', ', $emails_placeholder ); |
|
| 286 | + $emails_count = count($this->args['email']); |
|
| 287 | + $emails_placeholder = array_fill(0, $emails_count, '%s'); |
|
| 288 | + $emails = implode(', ', $emails_placeholder); |
|
| 289 | 289 | |
| 290 | - $where .= $wpdb->prepare( "AND {$this->table_name}.email IN( $emails )", $this->args['email'] ); |
|
| 290 | + $where .= $wpdb->prepare("AND {$this->table_name}.email IN( $emails )", $this->args['email']); |
|
| 291 | 291 | } else { |
| 292 | - $where .= $wpdb->prepare( "AND {$this->table_name}.email = %s", $this->args['email'] ); |
|
| 292 | + $where .= $wpdb->prepare("AND {$this->table_name}.email = %s", $this->args['email']); |
|
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | 295 | |
@@ -309,11 +309,11 @@ discard block |
||
| 309 | 309 | $where = ''; |
| 310 | 310 | |
| 311 | 311 | // Specific donors. |
| 312 | - if ( ! empty( $this->args['donor'] ) ) { |
|
| 313 | - if ( ! is_array( $this->args['donor'] ) ) { |
|
| 314 | - $this->args['donor'] = explode( ',', $this->args['donor'] ); |
|
| 312 | + if ( ! empty($this->args['donor'])) { |
|
| 313 | + if ( ! is_array($this->args['donor'])) { |
|
| 314 | + $this->args['donor'] = explode(',', $this->args['donor']); |
|
| 315 | 315 | } |
| 316 | - $donor_ids = implode( ',', array_map( 'intval', $this->args['donor'] ) ); |
|
| 316 | + $donor_ids = implode(',', array_map('intval', $this->args['donor'])); |
|
| 317 | 317 | |
| 318 | 318 | $where .= "AND {$this->table_name}.id IN( {$donor_ids} )"; |
| 319 | 319 | } |
@@ -334,9 +334,9 @@ discard block |
||
| 334 | 334 | $where = ''; |
| 335 | 335 | |
| 336 | 336 | // Donors created for a specific date or in a date range |
| 337 | - if ( ! empty( $this->args['date_query'] ) ) { |
|
| 337 | + if ( ! empty($this->args['date_query'])) { |
|
| 338 | 338 | $date_query_object = new WP_Date_Query( |
| 339 | - is_array( $this->args['date_query'] ) ? $this->args['date_query'] : wp_parse_args( $this->args['date_query'] ), |
|
| 339 | + is_array($this->args['date_query']) ? $this->args['date_query'] : wp_parse_args($this->args['date_query']), |
|
| 340 | 340 | "{$this->table_name}.date_created" |
| 341 | 341 | ); |
| 342 | 342 | |
@@ -371,11 +371,11 @@ discard block |
||
| 371 | 371 | $where = ''; |
| 372 | 372 | |
| 373 | 373 | // Donors created for a specific date or in a date range |
| 374 | - if ( ! empty( $this->args['s'] ) && false !== strpos( $this->args['s'], ':' ) ) { |
|
| 375 | - $search_parts = explode( ':', $this->args['s'] ); |
|
| 374 | + if ( ! empty($this->args['s']) && false !== strpos($this->args['s'], ':')) { |
|
| 375 | + $search_parts = explode(':', $this->args['s']); |
|
| 376 | 376 | |
| 377 | - if ( ! empty( $search_parts[0] ) ) { |
|
| 378 | - switch ( $search_parts[0] ) { |
|
| 377 | + if ( ! empty($search_parts[0])) { |
|
| 378 | + switch ($search_parts[0]) { |
|
| 379 | 379 | case 'name': |
| 380 | 380 | $where = "AND {$this->table_name}.name LIKE '%{$search_parts[1]}%'"; |
| 381 | 381 | break; |
@@ -403,11 +403,11 @@ discard block |
||
| 403 | 403 | $where = ''; |
| 404 | 404 | |
| 405 | 405 | // Donors create for specific wp user. |
| 406 | - if ( ! empty( $this->args['user'] ) ) { |
|
| 407 | - if ( ! is_array( $this->args['user'] ) ) { |
|
| 408 | - $this->args['user'] = explode( ',', $this->args['user'] ); |
|
| 406 | + if ( ! empty($this->args['user'])) { |
|
| 407 | + if ( ! is_array($this->args['user'])) { |
|
| 408 | + $this->args['user'] = explode(',', $this->args['user']); |
|
| 409 | 409 | } |
| 410 | - $user_ids = implode( ',', array_map( 'intval', $this->args['user'] ) ); |
|
| 410 | + $user_ids = implode(',', array_map('intval', $this->args['user'])); |
|
| 411 | 411 | |
| 412 | 412 | $where .= "AND {$this->table_name}.user_id IN( {$user_ids} )"; |
| 413 | 413 | } |
@@ -426,14 +426,13 @@ discard block |
||
| 426 | 426 | private function get_order_query() { |
| 427 | 427 | $table_columns = Give()->donors->get_columns(); |
| 428 | 428 | |
| 429 | - $this->args['orderby'] = ! array_key_exists( $this->args['orderby'], $table_columns ) ? |
|
| 430 | - 'id' : |
|
| 431 | - $this->args['orderby']; |
|
| 429 | + $this->args['orderby'] = ! array_key_exists($this->args['orderby'], $table_columns) ? |
|
| 430 | + 'id' : $this->args['orderby']; |
|
| 432 | 431 | |
| 433 | - $this->args['orderby'] = esc_sql( $this->args['orderby'] ); |
|
| 434 | - $this->args['order'] = esc_sql( $this->args['order'] ); |
|
| 432 | + $this->args['orderby'] = esc_sql($this->args['orderby']); |
|
| 433 | + $this->args['order'] = esc_sql($this->args['order']); |
|
| 435 | 434 | |
| 436 | - switch ( $table_columns[ $this->args['orderby'] ] ) { |
|
| 435 | + switch ($table_columns[$this->args['orderby']]) { |
|
| 437 | 436 | case '%d': |
| 438 | 437 | case '%f': |
| 439 | 438 | $query = "ORDER BY {$this->table_name}.{$this->args['orderby']}+0"; |
@@ -277,7 +277,7 @@ |
||
| 277 | 277 | /** |
| 278 | 278 | * Rename query clauses for new meta table |
| 279 | 279 | * |
| 280 | - * @param $clause |
|
| 280 | + * @param string $clause |
|
| 281 | 281 | * @param $filter |
| 282 | 282 | * |
| 283 | 283 | * @return mixed |
@@ -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 | |
@@ -75,40 +75,40 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | function __construct() { |
| 77 | 77 | // Bailout. |
| 78 | - if ( empty( $this->supports ) || ! $this->is_custom_meta_table_active() ) { |
|
| 78 | + if (empty($this->supports) || ! $this->is_custom_meta_table_active()) { |
|
| 79 | 79 | return; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if ( in_array( 'add_post_metadata', $this->supports ) ) { |
|
| 83 | - add_filter( 'add_post_metadata', array( $this, '__add_meta' ), 0, 5 ); |
|
| 82 | + if (in_array('add_post_metadata', $this->supports)) { |
|
| 83 | + add_filter('add_post_metadata', array($this, '__add_meta'), 0, 5); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - if ( in_array( 'get_post_metadata', $this->supports ) ) { |
|
| 87 | - add_filter( 'get_post_metadata', array( $this, '__get_meta' ), 0, 4 ); |
|
| 86 | + if (in_array('get_post_metadata', $this->supports)) { |
|
| 87 | + add_filter('get_post_metadata', array($this, '__get_meta'), 0, 4); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if ( in_array( 'update_post_metadata', $this->supports ) ) { |
|
| 91 | - add_filter( 'update_post_metadata', array( $this, '__update_meta' ), 0, 5 ); |
|
| 90 | + if (in_array('update_post_metadata', $this->supports)) { |
|
| 91 | + add_filter('update_post_metadata', array($this, '__update_meta'), 0, 5); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - if ( in_array( 'delete_post_metadata', $this->supports ) ) { |
|
| 95 | - add_filter( 'delete_post_metadata', array( $this, '__delete_meta' ), 0, 5 ); |
|
| 94 | + if (in_array('delete_post_metadata', $this->supports)) { |
|
| 95 | + add_filter('delete_post_metadata', array($this, '__delete_meta'), 0, 5); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if ( in_array( 'posts_where', $this->supports ) ) { |
|
| 99 | - add_filter( 'posts_where', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
| 98 | + if (in_array('posts_where', $this->supports)) { |
|
| 99 | + add_filter('posts_where', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - if ( in_array( 'posts_join', $this->supports ) ) { |
|
| 103 | - add_filter( 'posts_join', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
| 102 | + if (in_array('posts_join', $this->supports)) { |
|
| 103 | + add_filter('posts_join', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - if ( in_array( 'posts_groupby', $this->supports ) ) { |
|
| 107 | - add_filter( 'posts_groupby', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
| 106 | + if (in_array('posts_groupby', $this->supports)) { |
|
| 107 | + add_filter('posts_groupby', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if ( in_array( 'posts_orderby', $this->supports ) ) { |
|
| 111 | - add_filter( 'posts_orderby', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 ); |
|
| 110 | + if (in_array('posts_orderby', $this->supports)) { |
|
| 111 | + add_filter('posts_orderby', array($this, '__rename_meta_table_name_in_query'), 99999, 2); |
|
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
@@ -126,16 +126,16 @@ discard block |
||
| 126 | 126 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single |
| 127 | 127 | * is true. |
| 128 | 128 | */ |
| 129 | - public function get_meta( $id = 0, $meta_key = '', $single = false ) { |
|
| 130 | - $id = $this->sanitize_id( $id ); |
|
| 129 | + public function get_meta($id = 0, $meta_key = '', $single = false) { |
|
| 130 | + $id = $this->sanitize_id($id); |
|
| 131 | 131 | |
| 132 | 132 | // Bailout. |
| 133 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
| 133 | + if ( ! $this->is_valid_post_type($id)) { |
|
| 134 | 134 | return $this->check; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - if ( $this->raw_result ) { |
|
| 138 | - if ( ! ( $value = get_metadata( $this->meta_type, $id, $meta_key, false ) ) ) { |
|
| 137 | + if ($this->raw_result) { |
|
| 138 | + if ( ! ($value = get_metadata($this->meta_type, $id, $meta_key, false))) { |
|
| 139 | 139 | $value = ''; |
| 140 | 140 | } |
| 141 | 141 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | $this->raw_result = false; |
| 144 | 144 | |
| 145 | 145 | } else { |
| 146 | - $value = get_metadata( $this->meta_type, $id, $meta_key, $single ); |
|
| 146 | + $value = get_metadata($this->meta_type, $id, $meta_key, $single); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | return $value; |
@@ -165,18 +165,18 @@ discard block |
||
| 165 | 165 | * |
| 166 | 166 | * @return int|bool False for failure. True for success. |
| 167 | 167 | */ |
| 168 | - public function add_meta( $id = 0, $meta_key = '', $meta_value, $unique = false ) { |
|
| 169 | - $id = $this->sanitize_id( $id ); |
|
| 168 | + public function add_meta($id = 0, $meta_key = '', $meta_value, $unique = false) { |
|
| 169 | + $id = $this->sanitize_id($id); |
|
| 170 | 170 | |
| 171 | 171 | // Bailout. |
| 172 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
| 172 | + if ( ! $this->is_valid_post_type($id)) { |
|
| 173 | 173 | return $this->check; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - $meta_id = add_metadata( $this->meta_type, $id, $meta_key, $meta_value, $unique ); |
|
| 176 | + $meta_id = add_metadata($this->meta_type, $id, $meta_key, $meta_value, $unique); |
|
| 177 | 177 | |
| 178 | - if ( $meta_id ) { |
|
| 179 | - $this->delete_cache( $id ); |
|
| 178 | + if ($meta_id) { |
|
| 179 | + $this->delete_cache($id); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | return $meta_id; |
@@ -202,18 +202,18 @@ discard block |
||
| 202 | 202 | * |
| 203 | 203 | * @return int|bool False on failure, true if success. |
| 204 | 204 | */ |
| 205 | - public function update_meta( $id = 0, $meta_key = '', $meta_value, $prev_value = '' ) { |
|
| 206 | - $id = $this->sanitize_id( $id ); |
|
| 205 | + public function update_meta($id = 0, $meta_key = '', $meta_value, $prev_value = '') { |
|
| 206 | + $id = $this->sanitize_id($id); |
|
| 207 | 207 | |
| 208 | 208 | // Bailout. |
| 209 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
| 209 | + if ( ! $this->is_valid_post_type($id)) { |
|
| 210 | 210 | return $this->check; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - $meta_id = update_metadata( $this->meta_type, $id, $meta_key, $meta_value, $prev_value ); |
|
| 213 | + $meta_id = update_metadata($this->meta_type, $id, $meta_key, $meta_value, $prev_value); |
|
| 214 | 214 | |
| 215 | - if ( $meta_id ) { |
|
| 216 | - $this->delete_cache( $id ); |
|
| 215 | + if ($meta_id) { |
|
| 216 | + $this->delete_cache($id); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | return $meta_id; |
@@ -236,18 +236,18 @@ discard block |
||
| 236 | 236 | * |
| 237 | 237 | * @return bool False for failure. True for success. |
| 238 | 238 | */ |
| 239 | - public function delete_meta( $id = 0, $meta_key = '', $meta_value = '', $delete_all = '' ) { |
|
| 240 | - $id = $this->sanitize_id( $id ); |
|
| 239 | + public function delete_meta($id = 0, $meta_key = '', $meta_value = '', $delete_all = '') { |
|
| 240 | + $id = $this->sanitize_id($id); |
|
| 241 | 241 | |
| 242 | 242 | // Bailout. |
| 243 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
| 243 | + if ( ! $this->is_valid_post_type($id)) { |
|
| 244 | 244 | return $this->check; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - $is_meta_deleted = delete_metadata( $this->meta_type, $id, $meta_key, $meta_value, $delete_all ); |
|
| 247 | + $is_meta_deleted = delete_metadata($this->meta_type, $id, $meta_key, $meta_value, $delete_all); |
|
| 248 | 248 | |
| 249 | - if ( $is_meta_deleted ) { |
|
| 250 | - $this->delete_cache( $id ); |
|
| 249 | + if ($is_meta_deleted) { |
|
| 250 | + $this->delete_cache($id); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | return $is_meta_deleted; |
@@ -264,10 +264,10 @@ discard block |
||
| 264 | 264 | * |
| 265 | 265 | * @return string |
| 266 | 266 | */ |
| 267 | - public function __rename_meta_table_name_in_query( $clause, $wp_query ) { |
|
| 267 | + public function __rename_meta_table_name_in_query($clause, $wp_query) { |
|
| 268 | 268 | // Add new table to sql query. |
| 269 | - if ( $this->is_post_type_query( $wp_query ) && ! empty( $wp_query->meta_query->queries ) ) { |
|
| 270 | - $clause = $this->__rename_meta_table_name( $clause, current_filter() ); |
|
| 269 | + if ($this->is_post_type_query($wp_query) && ! empty($wp_query->meta_query->queries)) { |
|
| 270 | + $clause = $this->__rename_meta_table_name($clause, current_filter()); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | return $clause; |
@@ -282,39 +282,39 @@ discard block |
||
| 282 | 282 | * |
| 283 | 283 | * @return mixed |
| 284 | 284 | */ |
| 285 | - public function __rename_meta_table_name( $clause, $filter ){ |
|
| 285 | + public function __rename_meta_table_name($clause, $filter) { |
|
| 286 | 286 | global $wpdb; |
| 287 | 287 | |
| 288 | - $clause = str_replace( "{$wpdb->postmeta}.post_id", "{$this->table_name}.{$this->meta_type}_id", $clause ); |
|
| 289 | - $clause = str_replace( $wpdb->postmeta, $this->table_name, $clause ); |
|
| 288 | + $clause = str_replace("{$wpdb->postmeta}.post_id", "{$this->table_name}.{$this->meta_type}_id", $clause); |
|
| 289 | + $clause = str_replace($wpdb->postmeta, $this->table_name, $clause); |
|
| 290 | 290 | |
| 291 | - switch( $filter ) { |
|
| 291 | + switch ($filter) { |
|
| 292 | 292 | case 'posts_join': |
| 293 | - $joins = array( 'INNER JOIN', 'LEFT JOIN' ); |
|
| 293 | + $joins = array('INNER JOIN', 'LEFT JOIN'); |
|
| 294 | 294 | |
| 295 | - foreach ( $joins as $join ) { |
|
| 296 | - if( false !== strpos( $clause, $join ) ) { |
|
| 297 | - $clause = explode( $join, $clause ); |
|
| 295 | + foreach ($joins as $join) { |
|
| 296 | + if (false !== strpos($clause, $join)) { |
|
| 297 | + $clause = explode($join, $clause); |
|
| 298 | 298 | |
| 299 | - foreach ( $clause as $key => $clause_part ) { |
|
| 300 | - if( empty( $clause_part ) ) { |
|
| 299 | + foreach ($clause as $key => $clause_part) { |
|
| 300 | + if (empty($clause_part)) { |
|
| 301 | 301 | continue; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - preg_match( '/' . $wpdb->prefix . 'give_' . $this->meta_type . 'meta AS (.*) ON/', $clause_part, $alias_table_name ); |
|
| 304 | + preg_match('/'.$wpdb->prefix.'give_'.$this->meta_type.'meta AS (.*) ON/', $clause_part, $alias_table_name); |
|
| 305 | 305 | |
| 306 | - if( isset( $alias_table_name[1] ) ) { |
|
| 307 | - $clause[$key] = str_replace( "{$alias_table_name[1]}.post_id", "{$alias_table_name[1]}.{$this->meta_type}_id", $clause_part ); |
|
| 306 | + if (isset($alias_table_name[1])) { |
|
| 307 | + $clause[$key] = str_replace("{$alias_table_name[1]}.post_id", "{$alias_table_name[1]}.{$this->meta_type}_id", $clause_part); |
|
| 308 | 308 | } |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - $clause = implode( "{$join} ", $clause ); |
|
| 311 | + $clause = implode("{$join} ", $clause); |
|
| 312 | 312 | } |
| 313 | 313 | } |
| 314 | 314 | break; |
| 315 | 315 | |
| 316 | 316 | case 'posts_where': |
| 317 | - $clause = str_replace( array( 'mt2.post_id', 'mt1.post_id' ), array( "mt2.{$this->meta_type}_id", "mt1.{$this->meta_type}_id" ), $clause ); |
|
| 317 | + $clause = str_replace(array('mt2.post_id', 'mt1.post_id'), array("mt2.{$this->meta_type}_id", "mt1.{$this->meta_type}_id"), $clause); |
|
| 318 | 318 | break; |
| 319 | 319 | } |
| 320 | 320 | |
@@ -332,19 +332,19 @@ discard block |
||
| 332 | 332 | * |
| 333 | 333 | * @return bool |
| 334 | 334 | */ |
| 335 | - protected function is_post_type_query( $wp_query ) { |
|
| 335 | + protected function is_post_type_query($wp_query) { |
|
| 336 | 336 | $status = false; |
| 337 | 337 | |
| 338 | 338 | // Check if it is payment query. |
| 339 | - if ( ! empty( $wp_query->query['post_type'] ) ) { |
|
| 339 | + if ( ! empty($wp_query->query['post_type'])) { |
|
| 340 | 340 | if ( |
| 341 | - is_string( $wp_query->query['post_type'] ) && |
|
| 341 | + is_string($wp_query->query['post_type']) && |
|
| 342 | 342 | $this->post_type === $wp_query->query['post_type'] |
| 343 | 343 | ) { |
| 344 | 344 | $status = true; |
| 345 | 345 | } elseif ( |
| 346 | - is_array( $wp_query->query['post_type'] ) && |
|
| 347 | - in_array( $this->post_type, $wp_query->query['post_type'] ) |
|
| 346 | + is_array($wp_query->query['post_type']) && |
|
| 347 | + in_array($this->post_type, $wp_query->query['post_type']) |
|
| 348 | 348 | ) { |
| 349 | 349 | $status = true; |
| 350 | 350 | } |
@@ -363,8 +363,8 @@ discard block |
||
| 363 | 363 | * |
| 364 | 364 | * @return bool |
| 365 | 365 | */ |
| 366 | - protected function is_valid_post_type( $ID ) { |
|
| 367 | - return $ID && ( $this->post_type === get_post_type( $ID ) ); |
|
| 366 | + protected function is_valid_post_type($ID) { |
|
| 367 | + return $ID && ($this->post_type === get_post_type($ID)); |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | /** |
@@ -390,8 +390,8 @@ discard block |
||
| 390 | 390 | * |
| 391 | 391 | * @return void |
| 392 | 392 | */ |
| 393 | - private function delete_cache( $id, $meta_type = '' ) { |
|
| 394 | - $meta_type = empty( $meta_type ) ? $this->meta_type : $meta_type; |
|
| 393 | + private function delete_cache($id, $meta_type = '') { |
|
| 394 | + $meta_type = empty($meta_type) ? $this->meta_type : $meta_type; |
|
| 395 | 395 | |
| 396 | 396 | $group = array( |
| 397 | 397 | // 'form' => 'give-forms', |
@@ -401,8 +401,8 @@ discard block |
||
| 401 | 401 | // 'log' => 'give-logs', |
| 402 | 402 | ); |
| 403 | 403 | |
| 404 | - if ( array_key_exists( $meta_type, $group ) ) { |
|
| 405 | - Give_Cache::delete_group( $id, $group[ $meta_type ] ); |
|
| 404 | + if (array_key_exists($meta_type, $group)) { |
|
| 405 | + Give_Cache::delete_group($id, $group[$meta_type]); |
|
| 406 | 406 | } |
| 407 | 407 | } |
| 408 | 408 | |
@@ -417,8 +417,8 @@ discard block |
||
| 417 | 417 | * |
| 418 | 418 | * @return mixed |
| 419 | 419 | */ |
| 420 | - public function __call( $name, $arguments ) { |
|
| 421 | - switch ( $name ) { |
|
| 420 | + public function __call($name, $arguments) { |
|
| 421 | + switch ($name) { |
|
| 422 | 422 | case '__add_meta': |
| 423 | 423 | $this->check = $arguments[0]; |
| 424 | 424 | $id = $arguments[1]; |
@@ -427,11 +427,11 @@ discard block |
||
| 427 | 427 | $unique = $arguments[4]; |
| 428 | 428 | |
| 429 | 429 | // Bailout. |
| 430 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
| 430 | + if ( ! $this->is_valid_post_type($id)) { |
|
| 431 | 431 | return $this->check; |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | - return $this->add_meta( $id, $meta_key, $meta_value, $unique ); |
|
| 434 | + return $this->add_meta($id, $meta_key, $meta_value, $unique); |
|
| 435 | 435 | |
| 436 | 436 | case '__get_meta': |
| 437 | 437 | $this->check = $arguments[0]; |
@@ -440,13 +440,13 @@ discard block |
||
| 440 | 440 | $single = $arguments[3]; |
| 441 | 441 | |
| 442 | 442 | // Bailout. |
| 443 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
| 443 | + if ( ! $this->is_valid_post_type($id)) { |
|
| 444 | 444 | return $this->check; |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | $this->raw_result = true; |
| 448 | 448 | |
| 449 | - return $this->get_meta( $id, $meta_key, $single ); |
|
| 449 | + return $this->get_meta($id, $meta_key, $single); |
|
| 450 | 450 | |
| 451 | 451 | case '__update_meta': |
| 452 | 452 | $this->check = $arguments[0]; |
@@ -455,11 +455,11 @@ discard block |
||
| 455 | 455 | $meta_value = $arguments[3]; |
| 456 | 456 | |
| 457 | 457 | // Bailout. |
| 458 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
| 458 | + if ( ! $this->is_valid_post_type($id)) { |
|
| 459 | 459 | return $this->check; |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | - return $this->update_meta( $id, $meta_key, $meta_value ); |
|
| 462 | + return $this->update_meta($id, $meta_key, $meta_value); |
|
| 463 | 463 | |
| 464 | 464 | case '__delete_meta': |
| 465 | 465 | $this->check = $arguments[0]; |
@@ -469,11 +469,11 @@ discard block |
||
| 469 | 469 | $delete_all = $arguments[3]; |
| 470 | 470 | |
| 471 | 471 | // Bailout. |
| 472 | - if ( ! $this->is_valid_post_type( $id ) ) { |
|
| 472 | + if ( ! $this->is_valid_post_type($id)) { |
|
| 473 | 473 | return $this->check; |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | - return $this->delete_meta( $id, $meta_key, $meta_value, $delete_all ); |
|
| 476 | + return $this->delete_meta($id, $meta_key, $meta_value, $delete_all); |
|
| 477 | 477 | } |
| 478 | 478 | } |
| 479 | 479 | |
@@ -498,9 +498,9 @@ discard block |
||
| 498 | 498 | KEY meta_key (meta_key({$this->min_index_length})) |
| 499 | 499 | ) {$charset_collate};"; |
| 500 | 500 | |
| 501 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
| 502 | - dbDelta( $sql ); |
|
| 501 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
| 502 | + dbDelta($sql); |
|
| 503 | 503 | |
| 504 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
| 504 | + update_option($this->table_name.'_db_version', $this->version); |
|
| 505 | 505 | } |
| 506 | 506 | } |
| 507 | 507 | \ No newline at end of file |
@@ -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 | |
@@ -337,11 +337,11 @@ discard block |
||
| 337 | 337 | * @param int|bool $_id Post id. Default is false. |
| 338 | 338 | * @param array $_args Arguments passed. |
| 339 | 339 | */ |
| 340 | - public function __construct( $_id = false, $_args = array() ) { |
|
| 340 | + public function __construct($_id = false, $_args = array()) { |
|
| 341 | 341 | |
| 342 | - $donation_form = WP_Post::get_instance( $_id ); |
|
| 342 | + $donation_form = WP_Post::get_instance($_id); |
|
| 343 | 343 | |
| 344 | - return $this->setup_donation_form( $donation_form ); |
|
| 344 | + return $this->setup_donation_form($donation_form); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | /** |
@@ -354,23 +354,23 @@ discard block |
||
| 354 | 354 | * |
| 355 | 355 | * @return bool If the setup was successful or not. |
| 356 | 356 | */ |
| 357 | - private function setup_donation_form( $donation_form ) { |
|
| 357 | + private function setup_donation_form($donation_form) { |
|
| 358 | 358 | |
| 359 | - if ( ! is_object( $donation_form ) ) { |
|
| 359 | + if ( ! is_object($donation_form)) { |
|
| 360 | 360 | return false; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - if ( ! is_a( $donation_form, 'WP_Post' ) ) { |
|
| 363 | + if ( ! is_a($donation_form, 'WP_Post')) { |
|
| 364 | 364 | return false; |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - if ( 'give_forms' !== $donation_form->post_type ) { |
|
| 367 | + if ('give_forms' !== $donation_form->post_type) { |
|
| 368 | 368 | return false; |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - foreach ( $donation_form as $key => $value ) { |
|
| 371 | + foreach ($donation_form as $key => $value) { |
|
| 372 | 372 | |
| 373 | - switch ( $key ) { |
|
| 373 | + switch ($key) { |
|
| 374 | 374 | |
| 375 | 375 | default: |
| 376 | 376 | $this->$key = $value; |
@@ -394,16 +394,16 @@ discard block |
||
| 394 | 394 | * |
| 395 | 395 | * @return mixed |
| 396 | 396 | */ |
| 397 | - public function __get( $key ) { |
|
| 397 | + public function __get($key) { |
|
| 398 | 398 | |
| 399 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
| 399 | + if (method_exists($this, 'get_'.$key)) { |
|
| 400 | 400 | |
| 401 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
| 401 | + return call_user_func(array($this, 'get_'.$key)); |
|
| 402 | 402 | |
| 403 | 403 | } else { |
| 404 | 404 | |
| 405 | 405 | /* translators: %s: property key */ |
| 406 | - return new WP_Error( 'give-form-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
| 406 | + return new WP_Error('give-form-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
| 407 | 407 | |
| 408 | 408 | } |
| 409 | 409 | |
@@ -419,30 +419,30 @@ discard block |
||
| 419 | 419 | * |
| 420 | 420 | * @return bool|int False if data isn't passed and class not instantiated for creation, or New Form ID. |
| 421 | 421 | */ |
| 422 | - public function create( $data = array() ) { |
|
| 422 | + public function create($data = array()) { |
|
| 423 | 423 | |
| 424 | - if ( $this->id != 0 ) { |
|
| 424 | + if ($this->id != 0) { |
|
| 425 | 425 | return false; |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | $defaults = array( |
| 429 | 429 | 'post_type' => 'give_forms', |
| 430 | 430 | 'post_status' => 'draft', |
| 431 | - 'post_title' => __( 'New Donation Form', 'give' ), |
|
| 431 | + 'post_title' => __('New Donation Form', 'give'), |
|
| 432 | 432 | ); |
| 433 | 433 | |
| 434 | - $args = wp_parse_args( $data, $defaults ); |
|
| 434 | + $args = wp_parse_args($data, $defaults); |
|
| 435 | 435 | |
| 436 | 436 | /** |
| 437 | 437 | * Fired before a donation form is created |
| 438 | 438 | * |
| 439 | 439 | * @param array $args The post object arguments used for creation. |
| 440 | 440 | */ |
| 441 | - do_action( 'give_form_pre_create', $args ); |
|
| 441 | + do_action('give_form_pre_create', $args); |
|
| 442 | 442 | |
| 443 | - $id = wp_insert_post( $args, true ); |
|
| 443 | + $id = wp_insert_post($args, true); |
|
| 444 | 444 | |
| 445 | - $donation_form = WP_Post::get_instance( $id ); |
|
| 445 | + $donation_form = WP_Post::get_instance($id); |
|
| 446 | 446 | |
| 447 | 447 | /** |
| 448 | 448 | * Fired after a donation form is created |
@@ -450,9 +450,9 @@ discard block |
||
| 450 | 450 | * @param int $id The post ID of the created item. |
| 451 | 451 | * @param array $args The post object arguments used for creation. |
| 452 | 452 | */ |
| 453 | - do_action( 'give_form_post_create', $id, $args ); |
|
| 453 | + do_action('give_form_post_create', $id, $args); |
|
| 454 | 454 | |
| 455 | - return $this->setup_donation_form( $donation_form ); |
|
| 455 | + return $this->setup_donation_form($donation_form); |
|
| 456 | 456 | |
| 457 | 457 | } |
| 458 | 458 | |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | * @return string Donation form name. |
| 478 | 478 | */ |
| 479 | 479 | public function get_name() { |
| 480 | - return get_the_title( $this->ID ); |
|
| 480 | + return get_the_title($this->ID); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | /** |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | */ |
| 491 | 491 | public function get_price() { |
| 492 | 492 | |
| 493 | - if ( ! isset( $this->price ) ) { |
|
| 493 | + if ( ! isset($this->price)) { |
|
| 494 | 494 | |
| 495 | 495 | $this->price = give_maybe_sanitize_amount( |
| 496 | 496 | give_get_meta( |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | ) |
| 501 | 501 | ); |
| 502 | 502 | |
| 503 | - if ( ! $this->price ) { |
|
| 503 | + if ( ! $this->price) { |
|
| 504 | 504 | $this->price = 0; |
| 505 | 505 | } |
| 506 | 506 | |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | * @param string $price The donation form price. |
| 515 | 515 | * @param string|int $id The form ID. |
| 516 | 516 | */ |
| 517 | - return apply_filters( 'give_get_set_price', $this->price, $this->ID ); |
|
| 517 | + return apply_filters('give_get_set_price', $this->price, $this->ID); |
|
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | /** |
@@ -527,17 +527,17 @@ discard block |
||
| 527 | 527 | */ |
| 528 | 528 | public function get_minimum_price() { |
| 529 | 529 | |
| 530 | - if ( ! isset( $this->minimum_price ) ) { |
|
| 530 | + if ( ! isset($this->minimum_price)) { |
|
| 531 | 531 | |
| 532 | - $this->minimum_price = give_get_meta( $this->ID, '_give_custom_amount_minimum', true ); |
|
| 532 | + $this->minimum_price = give_get_meta($this->ID, '_give_custom_amount_minimum', true); |
|
| 533 | 533 | |
| 534 | - if ( ! $this->is_custom_price_mode() ) { |
|
| 534 | + if ( ! $this->is_custom_price_mode()) { |
|
| 535 | 535 | $this->minimum_price = 0; |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | - return apply_filters( 'give_get_set_minimum_price', $this->minimum_price, $this->ID ); |
|
| 540 | + return apply_filters('give_get_set_minimum_price', $this->minimum_price, $this->ID); |
|
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | /** |
@@ -550,9 +550,9 @@ discard block |
||
| 550 | 550 | */ |
| 551 | 551 | public function get_prices() { |
| 552 | 552 | |
| 553 | - if ( ! isset( $this->prices ) ) { |
|
| 553 | + if ( ! isset($this->prices)) { |
|
| 554 | 554 | |
| 555 | - $this->prices = give_get_meta( $this->ID, '_give_donation_levels', true ); |
|
| 555 | + $this->prices = give_get_meta($this->ID, '_give_donation_levels', true); |
|
| 556 | 556 | |
| 557 | 557 | } |
| 558 | 558 | |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | * @param array $prices The array of mulit-level prices. |
| 565 | 565 | * @param int|string $ID The ID of the form. |
| 566 | 566 | */ |
| 567 | - return apply_filters( 'give_get_donation_levels', $this->prices, $this->ID ); |
|
| 567 | + return apply_filters('give_get_donation_levels', $this->prices, $this->ID); |
|
| 568 | 568 | |
| 569 | 569 | } |
| 570 | 570 | |
@@ -578,21 +578,21 @@ discard block |
||
| 578 | 578 | */ |
| 579 | 579 | public function get_goal() { |
| 580 | 580 | |
| 581 | - if ( ! isset( $this->goal ) ) { |
|
| 581 | + if ( ! isset($this->goal)) { |
|
| 582 | 582 | |
| 583 | - if ( 'donation' === give_get_form_goal_format( $this->ID ) ) { |
|
| 584 | - $this->goal = give_get_meta( $this->ID, '_give_number_of_donation_goal', true ); |
|
| 583 | + if ('donation' === give_get_form_goal_format($this->ID)) { |
|
| 584 | + $this->goal = give_get_meta($this->ID, '_give_number_of_donation_goal', true); |
|
| 585 | 585 | } else { |
| 586 | - $this->goal = give_get_meta( $this->ID, '_give_set_goal', true ); |
|
| 586 | + $this->goal = give_get_meta($this->ID, '_give_set_goal', true); |
|
| 587 | 587 | } |
| 588 | 588 | |
| 589 | - if ( ! $this->goal ) { |
|
| 589 | + if ( ! $this->goal) { |
|
| 590 | 590 | $this->goal = 0; |
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - return apply_filters( 'give_get_set_goal', $this->goal, $this->ID ); |
|
| 595 | + return apply_filters('give_get_set_goal', $this->goal, $this->ID); |
|
| 596 | 596 | |
| 597 | 597 | } |
| 598 | 598 | |
@@ -606,10 +606,10 @@ discard block |
||
| 606 | 606 | */ |
| 607 | 607 | public function is_single_price_mode() { |
| 608 | 608 | |
| 609 | - $option = give_get_meta( $this->ID, '_give_price_option', true ); |
|
| 609 | + $option = give_get_meta($this->ID, '_give_price_option', true); |
|
| 610 | 610 | $ret = 0; |
| 611 | 611 | |
| 612 | - if ( empty( $option ) || $option === 'set' ) { |
|
| 612 | + if (empty($option) || $option === 'set') { |
|
| 613 | 613 | $ret = 1; |
| 614 | 614 | } |
| 615 | 615 | |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | * @param bool $ret Is donation form in single price mode? |
| 622 | 622 | * @param int|string $ID The ID of the donation form. |
| 623 | 623 | */ |
| 624 | - return (bool) apply_filters( 'give_single_price_option_mode', $ret, $this->ID ); |
|
| 624 | + return (bool) apply_filters('give_single_price_option_mode', $ret, $this->ID); |
|
| 625 | 625 | |
| 626 | 626 | } |
| 627 | 627 | |
@@ -635,10 +635,10 @@ discard block |
||
| 635 | 635 | */ |
| 636 | 636 | public function is_custom_price_mode() { |
| 637 | 637 | |
| 638 | - $option = give_get_meta( $this->ID, '_give_custom_amount', true ); |
|
| 638 | + $option = give_get_meta($this->ID, '_give_custom_amount', true); |
|
| 639 | 639 | $ret = 0; |
| 640 | 640 | |
| 641 | - if ( give_is_setting_enabled( $option ) ) { |
|
| 641 | + if (give_is_setting_enabled($option)) { |
|
| 642 | 642 | $ret = 1; |
| 643 | 643 | } |
| 644 | 644 | |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | * @param bool $ret Is donation form in custom price mode? |
| 651 | 651 | * @param int|string $ID The ID of the donation form. |
| 652 | 652 | */ |
| 653 | - return (bool) apply_filters( 'give_custom_price_option_mode', $ret, $this->ID ); |
|
| 653 | + return (bool) apply_filters('give_custom_price_option_mode', $ret, $this->ID); |
|
| 654 | 654 | |
| 655 | 655 | } |
| 656 | 656 | |
@@ -664,20 +664,20 @@ discard block |
||
| 664 | 664 | * |
| 665 | 665 | * @return bool |
| 666 | 666 | */ |
| 667 | - public function is_custom_price( $amount ) { |
|
| 667 | + public function is_custom_price($amount) { |
|
| 668 | 668 | $result = false; |
| 669 | - $amount = give_maybe_sanitize_amount( $amount ); |
|
| 669 | + $amount = give_maybe_sanitize_amount($amount); |
|
| 670 | 670 | |
| 671 | - if ( $this->is_custom_price_mode() ) { |
|
| 671 | + if ($this->is_custom_price_mode()) { |
|
| 672 | 672 | |
| 673 | - if ( 'set' === $this->get_type() ) { |
|
| 674 | - if ( $amount !== $this->get_price() ) { |
|
| 673 | + if ('set' === $this->get_type()) { |
|
| 674 | + if ($amount !== $this->get_price()) { |
|
| 675 | 675 | $result = true; |
| 676 | 676 | } |
| 677 | 677 | |
| 678 | - } elseif ( 'multi' === $this->get_type() ) { |
|
| 679 | - $level_amounts = array_map( 'give_maybe_sanitize_amount', wp_list_pluck( $this->get_prices(), '_give_amount' ) ); |
|
| 680 | - $result = ! in_array( $amount, $level_amounts ); |
|
| 678 | + } elseif ('multi' === $this->get_type()) { |
|
| 679 | + $level_amounts = array_map('give_maybe_sanitize_amount', wp_list_pluck($this->get_prices(), '_give_amount')); |
|
| 680 | + $result = ! in_array($amount, $level_amounts); |
|
| 681 | 681 | } |
| 682 | 682 | } |
| 683 | 683 | |
@@ -690,7 +690,7 @@ discard block |
||
| 690 | 690 | * |
| 691 | 691 | * @since 1.8.18 |
| 692 | 692 | */ |
| 693 | - return (bool) apply_filters( 'give_is_custom_price', $result, $amount, $this->ID ); |
|
| 693 | + return (bool) apply_filters('give_is_custom_price', $result, $amount, $this->ID); |
|
| 694 | 694 | } |
| 695 | 695 | |
| 696 | 696 | /** |
@@ -705,10 +705,10 @@ discard block |
||
| 705 | 705 | */ |
| 706 | 706 | public function has_variable_prices() { |
| 707 | 707 | |
| 708 | - $option = give_get_meta( $this->ID, '_give_price_option', true ); |
|
| 708 | + $option = give_get_meta($this->ID, '_give_price_option', true); |
|
| 709 | 709 | $ret = 0; |
| 710 | 710 | |
| 711 | - if ( $option === 'multi' ) { |
|
| 711 | + if ($option === 'multi') { |
|
| 712 | 712 | $ret = 1; |
| 713 | 713 | } |
| 714 | 714 | |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | * @param bool $ret Does donation form have variable prices? |
| 719 | 719 | * @param int|string $ID The ID of the donation form. |
| 720 | 720 | */ |
| 721 | - return (bool) apply_filters( 'give_has_variable_prices', $ret, $this->ID ); |
|
| 721 | + return (bool) apply_filters('give_has_variable_prices', $ret, $this->ID); |
|
| 722 | 722 | |
| 723 | 723 | } |
| 724 | 724 | |
@@ -732,17 +732,17 @@ discard block |
||
| 732 | 732 | */ |
| 733 | 733 | public function get_type() { |
| 734 | 734 | |
| 735 | - if ( ! isset( $this->type ) ) { |
|
| 735 | + if ( ! isset($this->type)) { |
|
| 736 | 736 | |
| 737 | - $this->type = give_get_meta( $this->ID, '_give_price_option', true ); |
|
| 737 | + $this->type = give_get_meta($this->ID, '_give_price_option', true); |
|
| 738 | 738 | |
| 739 | - if ( empty( $this->type ) ) { |
|
| 739 | + if (empty($this->type)) { |
|
| 740 | 740 | $this->type = 'set'; |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | - return apply_filters( 'give_get_form_type', $this->type, $this->ID ); |
|
| 745 | + return apply_filters('give_get_form_type', $this->type, $this->ID); |
|
| 746 | 746 | |
| 747 | 747 | } |
| 748 | 748 | |
@@ -758,23 +758,23 @@ discard block |
||
| 758 | 758 | * |
| 759 | 759 | * @return string |
| 760 | 760 | */ |
| 761 | - public function get_form_classes( $args ) { |
|
| 761 | + public function get_form_classes($args) { |
|
| 762 | 762 | |
| 763 | - $float_labels_option = give_is_float_labels_enabled( $args ) |
|
| 763 | + $float_labels_option = give_is_float_labels_enabled($args) |
|
| 764 | 764 | ? 'float-labels-enabled' |
| 765 | 765 | : ''; |
| 766 | 766 | |
| 767 | - $form_classes_array = apply_filters( 'give_form_classes', array( |
|
| 767 | + $form_classes_array = apply_filters('give_form_classes', array( |
|
| 768 | 768 | 'give-form', |
| 769 | - 'give-form-' . $this->ID, |
|
| 770 | - 'give-form-type-' . $this->get_type(), |
|
| 769 | + 'give-form-'.$this->ID, |
|
| 770 | + 'give-form-type-'.$this->get_type(), |
|
| 771 | 771 | $float_labels_option, |
| 772 | - ), $this->ID, $args ); |
|
| 772 | + ), $this->ID, $args); |
|
| 773 | 773 | |
| 774 | 774 | // Remove empty class names. |
| 775 | - $form_classes_array = array_filter( $form_classes_array ); |
|
| 775 | + $form_classes_array = array_filter($form_classes_array); |
|
| 776 | 776 | |
| 777 | - return implode( ' ', $form_classes_array ); |
|
| 777 | + return implode(' ', $form_classes_array); |
|
| 778 | 778 | |
| 779 | 779 | } |
| 780 | 780 | |
@@ -789,22 +789,22 @@ discard block |
||
| 789 | 789 | * |
| 790 | 790 | * @return string |
| 791 | 791 | */ |
| 792 | - public function get_form_wrap_classes( $args ) { |
|
| 792 | + public function get_form_wrap_classes($args) { |
|
| 793 | 793 | $custom_class = array( |
| 794 | 794 | 'give-form-wrap', |
| 795 | 795 | ); |
| 796 | 796 | |
| 797 | - if ( $this->is_close_donation_form() ) { |
|
| 797 | + if ($this->is_close_donation_form()) { |
|
| 798 | 798 | $custom_class[] = 'give-form-closed'; |
| 799 | - } else{ |
|
| 800 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
| 799 | + } else { |
|
| 800 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
| 801 | 801 | ? $args['display_style'] |
| 802 | - : give_get_meta( $this->ID, '_give_payment_display', true ); |
|
| 802 | + : give_get_meta($this->ID, '_give_payment_display', true); |
|
| 803 | 803 | |
| 804 | 804 | $custom_class[] = "give-display-{$display_option}"; |
| 805 | 805 | |
| 806 | 806 | // If admin want to show only button for form then user inbuilt modal functionality. |
| 807 | - if ( 'button' === $display_option ) { |
|
| 807 | + if ('button' === $display_option) { |
|
| 808 | 808 | $custom_class[] = 'give-display-button-only'; |
| 809 | 809 | } |
| 810 | 810 | } |
@@ -815,10 +815,10 @@ discard block |
||
| 815 | 815 | * |
| 816 | 816 | * @since 1.0 |
| 817 | 817 | */ |
| 818 | - $form_wrap_classes_array = (array) apply_filters( 'give_form_wrap_classes', $custom_class, $this->ID, $args ); |
|
| 818 | + $form_wrap_classes_array = (array) apply_filters('give_form_wrap_classes', $custom_class, $this->ID, $args); |
|
| 819 | 819 | |
| 820 | 820 | |
| 821 | - return implode( ' ', $form_wrap_classes_array ); |
|
| 821 | + return implode(' ', $form_wrap_classes_array); |
|
| 822 | 822 | |
| 823 | 823 | } |
| 824 | 824 | |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | public function is_set_type_donation_form() { |
| 834 | 834 | $form_type = $this->get_type(); |
| 835 | 835 | |
| 836 | - return ( 'set' === $form_type ? true : false ); |
|
| 836 | + return ('set' === $form_type ? true : false); |
|
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | /** |
@@ -847,7 +847,7 @@ discard block |
||
| 847 | 847 | public function is_multi_type_donation_form() { |
| 848 | 848 | $form_type = $this->get_type(); |
| 849 | 849 | |
| 850 | - return ( 'multi' === $form_type ? true : false ); |
|
| 850 | + return ('multi' === $form_type ? true : false); |
|
| 851 | 851 | |
| 852 | 852 | } |
| 853 | 853 | |
@@ -861,15 +861,15 @@ discard block |
||
| 861 | 861 | */ |
| 862 | 862 | public function get_sales() { |
| 863 | 863 | |
| 864 | - if ( ! isset( $this->sales ) ) { |
|
| 864 | + if ( ! isset($this->sales)) { |
|
| 865 | 865 | |
| 866 | - if ( '' == give_get_meta( $this->ID, '_give_form_sales', true ) ) { |
|
| 867 | - add_post_meta( $this->ID, '_give_form_sales', 0 ); |
|
| 866 | + if ('' == give_get_meta($this->ID, '_give_form_sales', true)) { |
|
| 867 | + add_post_meta($this->ID, '_give_form_sales', 0); |
|
| 868 | 868 | } // End if |
| 869 | 869 | |
| 870 | - $this->sales = give_get_meta( $this->ID, '_give_form_sales', true ); |
|
| 870 | + $this->sales = give_get_meta($this->ID, '_give_form_sales', true); |
|
| 871 | 871 | |
| 872 | - if ( $this->sales < 0 ) { |
|
| 872 | + if ($this->sales < 0) { |
|
| 873 | 873 | // Never let sales be less than zero. |
| 874 | 874 | $this->sales = 0; |
| 875 | 875 | } |
@@ -890,13 +890,13 @@ discard block |
||
| 890 | 890 | * |
| 891 | 891 | * @return int|false New number of total sales. |
| 892 | 892 | */ |
| 893 | - public function increase_sales( $quantity = 1 ) { |
|
| 893 | + public function increase_sales($quantity = 1) { |
|
| 894 | 894 | |
| 895 | - $sales = give_get_form_sales_stats( $this->ID ); |
|
| 896 | - $quantity = absint( $quantity ); |
|
| 895 | + $sales = give_get_form_sales_stats($this->ID); |
|
| 896 | + $quantity = absint($quantity); |
|
| 897 | 897 | $total_sales = $sales + $quantity; |
| 898 | 898 | |
| 899 | - if ( $this->update_meta( '_give_form_sales', $total_sales ) ) { |
|
| 899 | + if ($this->update_meta('_give_form_sales', $total_sales)) { |
|
| 900 | 900 | |
| 901 | 901 | $this->sales = $total_sales; |
| 902 | 902 | |
@@ -917,17 +917,17 @@ discard block |
||
| 917 | 917 | * |
| 918 | 918 | * @return int|false New number of total sales. |
| 919 | 919 | */ |
| 920 | - public function decrease_sales( $quantity = 1 ) { |
|
| 920 | + public function decrease_sales($quantity = 1) { |
|
| 921 | 921 | |
| 922 | - $sales = give_get_form_sales_stats( $this->ID ); |
|
| 922 | + $sales = give_get_form_sales_stats($this->ID); |
|
| 923 | 923 | |
| 924 | 924 | // Only decrease if not already zero |
| 925 | - if ( $sales > 0 ) { |
|
| 925 | + if ($sales > 0) { |
|
| 926 | 926 | |
| 927 | - $quantity = absint( $quantity ); |
|
| 927 | + $quantity = absint($quantity); |
|
| 928 | 928 | $total_sales = $sales - $quantity; |
| 929 | 929 | |
| 930 | - if ( $this->update_meta( '_give_form_sales', $total_sales ) ) { |
|
| 930 | + if ($this->update_meta('_give_form_sales', $total_sales)) { |
|
| 931 | 931 | |
| 932 | 932 | $this->sales = $sales; |
| 933 | 933 | |
@@ -951,15 +951,15 @@ discard block |
||
| 951 | 951 | */ |
| 952 | 952 | public function get_earnings() { |
| 953 | 953 | |
| 954 | - if ( ! isset( $this->earnings ) ) { |
|
| 954 | + if ( ! isset($this->earnings)) { |
|
| 955 | 955 | |
| 956 | - if ( '' == give_get_meta( $this->ID, '_give_form_earnings', true ) ) { |
|
| 957 | - add_post_meta( $this->ID, '_give_form_earnings', 0 ); |
|
| 956 | + if ('' == give_get_meta($this->ID, '_give_form_earnings', true)) { |
|
| 957 | + add_post_meta($this->ID, '_give_form_earnings', 0); |
|
| 958 | 958 | } |
| 959 | 959 | |
| 960 | - $this->earnings = give_get_meta( $this->ID, '_give_form_earnings', true ); |
|
| 960 | + $this->earnings = give_get_meta($this->ID, '_give_form_earnings', true); |
|
| 961 | 961 | |
| 962 | - if ( $this->earnings < 0 ) { |
|
| 962 | + if ($this->earnings < 0) { |
|
| 963 | 963 | // Never let earnings be less than zero |
| 964 | 964 | $this->earnings = 0; |
| 965 | 965 | } |
@@ -980,12 +980,12 @@ discard block |
||
| 980 | 980 | * |
| 981 | 981 | * @return float|false |
| 982 | 982 | */ |
| 983 | - public function increase_earnings( $amount = 0 ) { |
|
| 983 | + public function increase_earnings($amount = 0) { |
|
| 984 | 984 | |
| 985 | - $earnings = give_get_form_earnings_stats( $this->ID ); |
|
| 985 | + $earnings = give_get_form_earnings_stats($this->ID); |
|
| 986 | 986 | $new_amount = $earnings + (float) $amount; |
| 987 | 987 | |
| 988 | - if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) { |
|
| 988 | + if ($this->update_meta('_give_form_earnings', $new_amount)) { |
|
| 989 | 989 | |
| 990 | 990 | $this->earnings = $new_amount; |
| 991 | 991 | |
@@ -1007,16 +1007,16 @@ discard block |
||
| 1007 | 1007 | * |
| 1008 | 1008 | * @return float|false |
| 1009 | 1009 | */ |
| 1010 | - public function decrease_earnings( $amount ) { |
|
| 1010 | + public function decrease_earnings($amount) { |
|
| 1011 | 1011 | |
| 1012 | - $earnings = give_get_form_earnings_stats( $this->ID ); |
|
| 1012 | + $earnings = give_get_form_earnings_stats($this->ID); |
|
| 1013 | 1013 | |
| 1014 | - if ( $earnings > 0 ) { |
|
| 1014 | + if ($earnings > 0) { |
|
| 1015 | 1015 | // Only decrease if greater than zero |
| 1016 | 1016 | $new_amount = $earnings - (float) $amount; |
| 1017 | 1017 | |
| 1018 | 1018 | |
| 1019 | - if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) { |
|
| 1019 | + if ($this->update_meta('_give_form_earnings', $new_amount)) { |
|
| 1020 | 1020 | |
| 1021 | 1021 | $this->earnings = $new_amount; |
| 1022 | 1022 | |
@@ -1040,22 +1040,22 @@ discard block |
||
| 1040 | 1040 | * |
| 1041 | 1041 | * @return bool |
| 1042 | 1042 | */ |
| 1043 | - public function is_free( $price_id = false ) { |
|
| 1043 | + public function is_free($price_id = false) { |
|
| 1044 | 1044 | |
| 1045 | 1045 | $is_free = false; |
| 1046 | - $variable_pricing = give_has_variable_prices( $this->ID ); |
|
| 1046 | + $variable_pricing = give_has_variable_prices($this->ID); |
|
| 1047 | 1047 | |
| 1048 | - if ( $variable_pricing && ! is_null( $price_id ) && $price_id !== false ) { |
|
| 1049 | - $price = give_get_price_option_amount( $this->ID, $price_id ); |
|
| 1050 | - } elseif ( ! $variable_pricing ) { |
|
| 1051 | - $price = give_get_meta( $this->ID, '_give_set_price', true ); |
|
| 1048 | + if ($variable_pricing && ! is_null($price_id) && $price_id !== false) { |
|
| 1049 | + $price = give_get_price_option_amount($this->ID, $price_id); |
|
| 1050 | + } elseif ( ! $variable_pricing) { |
|
| 1051 | + $price = give_get_meta($this->ID, '_give_set_price', true); |
|
| 1052 | 1052 | } |
| 1053 | 1053 | |
| 1054 | - if ( isset( $price ) && (float) $price == 0 ) { |
|
| 1054 | + if (isset($price) && (float) $price == 0) { |
|
| 1055 | 1055 | $is_free = true; |
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | - return (bool) apply_filters( 'give_is_free_donation', $is_free, $this->ID, $price_id ); |
|
| 1058 | + return (bool) apply_filters('give_is_free_donation', $is_free, $this->ID, $price_id); |
|
| 1059 | 1059 | |
| 1060 | 1060 | } |
| 1061 | 1061 | |
@@ -1074,7 +1074,7 @@ discard block |
||
| 1074 | 1074 | */ |
| 1075 | 1075 | public function is_close_donation_form() { |
| 1076 | 1076 | |
| 1077 | - $goal_format = give_get_form_goal_format( $this->ID ); |
|
| 1077 | + $goal_format = give_get_form_goal_format($this->ID); |
|
| 1078 | 1078 | |
| 1079 | 1079 | /** |
| 1080 | 1080 | * Filter the close form result. |
@@ -1084,9 +1084,9 @@ discard block |
||
| 1084 | 1084 | $is_close_form = apply_filters( |
| 1085 | 1085 | 'give_is_close_donation_form', |
| 1086 | 1086 | ( |
| 1087 | - give_is_setting_enabled( give_get_meta( $this->ID, '_give_goal_option', true ) ) && |
|
| 1088 | - give_is_setting_enabled( give_get_meta( $this->ID, '_give_close_form_when_goal_achieved', true ) ) && |
|
| 1089 | - ( 'donation' === $goal_format ? $this->get_goal() <= $this->get_sales() : $this->get_goal() <= $this->get_earnings() ) |
|
| 1087 | + give_is_setting_enabled(give_get_meta($this->ID, '_give_goal_option', true)) && |
|
| 1088 | + give_is_setting_enabled(give_get_meta($this->ID, '_give_close_form_when_goal_achieved', true)) && |
|
| 1089 | + ('donation' === $goal_format ? $this->get_goal() <= $this->get_sales() : $this->get_goal() <= $this->get_earnings()) |
|
| 1090 | 1090 | ), |
| 1091 | 1091 | $this->ID |
| 1092 | 1092 | ); |
@@ -1105,17 +1105,17 @@ discard block |
||
| 1105 | 1105 | * |
| 1106 | 1106 | * @return bool The result of the update query. |
| 1107 | 1107 | */ |
| 1108 | - private function update_meta( $meta_key = '', $meta_value = '' ) { |
|
| 1108 | + private function update_meta($meta_key = '', $meta_value = '') { |
|
| 1109 | 1109 | |
| 1110 | 1110 | /* @var WPDB $wpdb */ |
| 1111 | 1111 | global $wpdb; |
| 1112 | 1112 | |
| 1113 | 1113 | // Bailout. |
| 1114 | - if ( empty( $meta_key ) ) { |
|
| 1114 | + if (empty($meta_key)) { |
|
| 1115 | 1115 | return false; |
| 1116 | 1116 | } |
| 1117 | 1117 | |
| 1118 | - if ( give_update_meta( $this->ID, $meta_key, $meta_value ) ) { |
|
| 1118 | + if (give_update_meta($this->ID, $meta_key, $meta_value)) { |
|
| 1119 | 1119 | return true; |
| 1120 | 1120 | } |
| 1121 | 1121 | |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | * |
| 566 | 566 | * @since 1.0 |
| 567 | 567 | * |
| 568 | - * @return int $earnings Earnings |
|
| 568 | + * @return double $earnings Earnings |
|
| 569 | 569 | */ |
| 570 | 570 | function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
| 571 | 571 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead. |
@@ -864,7 +864,7 @@ discard block |
||
| 864 | 864 | * |
| 865 | 865 | * @since 1.0 |
| 866 | 866 | * |
| 867 | - * @return array $user_info User Info Meta Values. |
|
| 867 | + * @return string $user_info User Info Meta Values. |
|
| 868 | 868 | */ |
| 869 | 869 | function give_get_payment_meta_user_info( $payment_id ) { |
| 870 | 870 | $payment = new Give_Payment( $payment_id ); |
@@ -881,7 +881,7 @@ discard block |
||
| 881 | 881 | * |
| 882 | 882 | * @since 1.0 |
| 883 | 883 | * |
| 884 | - * @return int $form_id Form ID. |
|
| 884 | + * @return string $form_id Form ID. |
|
| 885 | 885 | */ |
| 886 | 886 | function give_get_payment_form_id( $payment_id ) { |
| 887 | 887 | $payment = new Give_Payment( $payment_id ); |
@@ -1729,7 +1729,7 @@ discard block |
||
| 1729 | 1729 | * |
| 1730 | 1730 | * Retrieves the form title and appends the level name if present. |
| 1731 | 1731 | * |
| 1732 | - * @param int|Give_Payment $donation Donation Data Object. |
|
| 1732 | + * @param Give_Payment $donation Donation Data Object. |
|
| 1733 | 1733 | * @param array $args a. only_level = If set to true will only return the level name if multi-level enabled. |
| 1734 | 1734 | * b. separator = The separator between the Form Title and the Donation Level. |
| 1735 | 1735 | * |
@@ -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 | |
@@ -44,15 +44,15 @@ discard block |
||
| 44 | 44 | * |
| 45 | 45 | * @return array $payments Payments retrieved from the database |
| 46 | 46 | */ |
| 47 | -function give_get_payments( $args = array() ) { |
|
| 47 | +function give_get_payments($args = array()) { |
|
| 48 | 48 | |
| 49 | 49 | // Fallback to post objects to ensure backwards compatibility. |
| 50 | - if ( ! isset( $args['output'] ) ) { |
|
| 50 | + if ( ! isset($args['output'])) { |
|
| 51 | 51 | $args['output'] = 'posts'; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $args = apply_filters( 'give_get_payments_args', $args ); |
|
| 55 | - $payments = new Give_Payments_Query( $args ); |
|
| 54 | + $args = apply_filters('give_get_payments_args', $args); |
|
| 55 | + $payments = new Give_Payments_Query($args); |
|
| 56 | 56 | |
| 57 | 57 | return $payments->get_payments(); |
| 58 | 58 | } |
@@ -67,48 +67,48 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @return mixed |
| 69 | 69 | */ |
| 70 | -function give_get_payment_by( $field = '', $value = '' ) { |
|
| 70 | +function give_get_payment_by($field = '', $value = '') { |
|
| 71 | 71 | |
| 72 | - if ( empty( $field ) || empty( $value ) ) { |
|
| 72 | + if (empty($field) || empty($value)) { |
|
| 73 | 73 | return false; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - switch ( strtolower( $field ) ) { |
|
| 76 | + switch (strtolower($field)) { |
|
| 77 | 77 | |
| 78 | 78 | case 'id': |
| 79 | - $payment = new Give_Payment( $value ); |
|
| 79 | + $payment = new Give_Payment($value); |
|
| 80 | 80 | $id = $payment->ID; |
| 81 | 81 | |
| 82 | - if ( empty( $id ) ) { |
|
| 82 | + if (empty($id)) { |
|
| 83 | 83 | return false; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | break; |
| 87 | 87 | |
| 88 | 88 | case 'key': |
| 89 | - $payment = give_get_payments( array( |
|
| 89 | + $payment = give_get_payments(array( |
|
| 90 | 90 | 'meta_key' => '_give_payment_purchase_key', |
| 91 | 91 | 'meta_value' => $value, |
| 92 | 92 | 'posts_per_page' => 1, |
| 93 | 93 | 'fields' => 'ids', |
| 94 | - ) ); |
|
| 94 | + )); |
|
| 95 | 95 | |
| 96 | - if ( $payment ) { |
|
| 97 | - $payment = new Give_Payment( $payment[0] ); |
|
| 96 | + if ($payment) { |
|
| 97 | + $payment = new Give_Payment($payment[0]); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | break; |
| 101 | 101 | |
| 102 | 102 | case 'payment_number': |
| 103 | - $payment = give_get_payments( array( |
|
| 103 | + $payment = give_get_payments(array( |
|
| 104 | 104 | 'meta_key' => '_give_payment_number', |
| 105 | 105 | 'meta_value' => $value, |
| 106 | 106 | 'posts_per_page' => 1, |
| 107 | 107 | 'fields' => 'ids', |
| 108 | - ) ); |
|
| 108 | + )); |
|
| 109 | 109 | |
| 110 | - if ( $payment ) { |
|
| 111 | - $payment = new Give_Payment( $payment[0] ); |
|
| 110 | + if ($payment) { |
|
| 111 | + $payment = new Give_Payment($payment[0]); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | break; |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | return false; |
| 118 | 118 | }// End switch(). |
| 119 | 119 | |
| 120 | - if ( $payment ) { |
|
| 120 | + if ($payment) { |
|
| 121 | 121 | return $payment; |
| 122 | 122 | } |
| 123 | 123 | |
@@ -133,9 +133,9 @@ discard block |
||
| 133 | 133 | * |
| 134 | 134 | * @return int|bool Payment ID if payment is inserted, false otherwise. |
| 135 | 135 | */ |
| 136 | -function give_insert_payment( $payment_data = array() ) { |
|
| 136 | +function give_insert_payment($payment_data = array()) { |
|
| 137 | 137 | |
| 138 | - if ( empty( $payment_data ) ) { |
|
| 138 | + if (empty($payment_data)) { |
|
| 139 | 139 | return false; |
| 140 | 140 | } |
| 141 | 141 | |
@@ -146,25 +146,25 @@ discard block |
||
| 146 | 146 | * |
| 147 | 147 | * @param array $payment_data Arguments passed. |
| 148 | 148 | */ |
| 149 | - $payment_data = apply_filters( 'give_pre_insert_payment', $payment_data ); |
|
| 149 | + $payment_data = apply_filters('give_pre_insert_payment', $payment_data); |
|
| 150 | 150 | |
| 151 | 151 | $payment = new Give_Payment(); |
| 152 | - $gateway = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : ''; |
|
| 153 | - $gateway = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway; |
|
| 154 | - $form_id = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0; |
|
| 155 | - $price_id = give_get_payment_meta_price_id( $payment_data ); |
|
| 156 | - $form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id ); |
|
| 152 | + $gateway = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : ''; |
|
| 153 | + $gateway = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway; |
|
| 154 | + $form_id = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0; |
|
| 155 | + $price_id = give_get_payment_meta_price_id($payment_data); |
|
| 156 | + $form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id); |
|
| 157 | 157 | |
| 158 | 158 | // Set properties. |
| 159 | 159 | $payment->total = $payment_data['price']; |
| 160 | - $payment->status = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending'; |
|
| 161 | - $payment->currency = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency( $payment_data['give_form_id'], $payment_data ); |
|
| 160 | + $payment->status = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending'; |
|
| 161 | + $payment->currency = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency($payment_data['give_form_id'], $payment_data); |
|
| 162 | 162 | $payment->user_info = $payment_data['user_info']; |
| 163 | 163 | $payment->gateway = $gateway; |
| 164 | 164 | $payment->form_title = $form_title; |
| 165 | 165 | $payment->form_id = $form_id; |
| 166 | 166 | $payment->price_id = $price_id; |
| 167 | - $payment->donor_id = ( ! empty( $payment_data['donor_id'] ) ? $payment_data['donor_id'] : '' ); |
|
| 167 | + $payment->donor_id = ( ! empty($payment_data['donor_id']) ? $payment_data['donor_id'] : ''); |
|
| 168 | 168 | $payment->user_id = $payment_data['user_info']['id']; |
| 169 | 169 | $payment->email = $payment_data['user_email']; |
| 170 | 170 | $payment->first_name = $payment_data['user_info']['first_name']; |
@@ -172,8 +172,8 @@ discard block |
||
| 172 | 172 | $payment->email = $payment_data['user_info']['email']; |
| 173 | 173 | $payment->ip = give_get_ip(); |
| 174 | 174 | $payment->key = $payment_data['purchase_key']; |
| 175 | - $payment->mode = ( ! empty( $payment_data['mode'] ) ? (string) $payment_data['mode'] : ( give_is_test_mode() ? 'test' : 'live' ) ); |
|
| 176 | - $payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : ''; |
|
| 175 | + $payment->mode = ( ! empty($payment_data['mode']) ? (string) $payment_data['mode'] : (give_is_test_mode() ? 'test' : 'live')); |
|
| 176 | + $payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : ''; |
|
| 177 | 177 | |
| 178 | 178 | // Add the donation. |
| 179 | 179 | $args = array( |
@@ -181,19 +181,19 @@ discard block |
||
| 181 | 181 | 'price_id' => $payment->price_id, |
| 182 | 182 | ); |
| 183 | 183 | |
| 184 | - $payment->add_donation( $payment->form_id, $args ); |
|
| 184 | + $payment->add_donation($payment->form_id, $args); |
|
| 185 | 185 | |
| 186 | 186 | |
| 187 | 187 | // Set date if present. |
| 188 | - if ( isset( $payment_data['post_date'] ) ) { |
|
| 188 | + if (isset($payment_data['post_date'])) { |
|
| 189 | 189 | $payment->date = $payment_data['post_date']; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | // Handle sequential payments. |
| 193 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
| 193 | + if (give_get_option('enable_sequential')) { |
|
| 194 | 194 | $number = give_get_next_payment_number(); |
| 195 | - $payment->number = give_format_payment_number( $number ); |
|
| 196 | - update_option( 'give_last_payment_number', $number ); |
|
| 195 | + $payment->number = give_format_payment_number($number); |
|
| 196 | + update_option('give_last_payment_number', $number); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | // Save payment. |
@@ -207,10 +207,10 @@ discard block |
||
| 207 | 207 | * @param int $payment_id The payment ID. |
| 208 | 208 | * @param array $payment_data Arguments passed. |
| 209 | 209 | */ |
| 210 | - do_action( 'give_insert_payment', $payment->ID, $payment_data ); |
|
| 210 | + do_action('give_insert_payment', $payment->ID, $payment_data); |
|
| 211 | 211 | |
| 212 | 212 | // Return payment ID upon success. |
| 213 | - if ( ! empty( $payment->ID ) ) { |
|
| 213 | + if ( ! empty($payment->ID)) { |
|
| 214 | 214 | return $payment->ID; |
| 215 | 215 | } |
| 216 | 216 | |
@@ -226,10 +226,10 @@ discard block |
||
| 226 | 226 | * |
| 227 | 227 | * @return bool|int |
| 228 | 228 | */ |
| 229 | -function give_create_payment( $payment_data ) { |
|
| 229 | +function give_create_payment($payment_data) { |
|
| 230 | 230 | |
| 231 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
| 232 | - $price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : ''; |
|
| 231 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
| 232 | + $price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : ''; |
|
| 233 | 233 | |
| 234 | 234 | // Collect payment data. |
| 235 | 235 | $insert_payment_data = array( |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | 'date' => $payment_data['date'], |
| 241 | 241 | 'user_email' => $payment_data['user_email'], |
| 242 | 242 | 'purchase_key' => $payment_data['purchase_key'], |
| 243 | - 'currency' => give_get_currency( $form_id, $payment_data ), |
|
| 243 | + 'currency' => give_get_currency($form_id, $payment_data), |
|
| 244 | 244 | 'user_info' => $payment_data['user_info'], |
| 245 | 245 | 'status' => 'pending', |
| 246 | 246 | 'gateway' => 'paypal', |
@@ -253,10 +253,10 @@ discard block |
||
| 253 | 253 | * |
| 254 | 254 | * @param array $insert_payment_data |
| 255 | 255 | */ |
| 256 | - $insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data ); |
|
| 256 | + $insert_payment_data = apply_filters('give_create_payment', $insert_payment_data); |
|
| 257 | 257 | |
| 258 | 258 | // Record the pending payment. |
| 259 | - return give_insert_payment( $insert_payment_data ); |
|
| 259 | + return give_insert_payment($insert_payment_data); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | /** |
@@ -269,12 +269,12 @@ discard block |
||
| 269 | 269 | * |
| 270 | 270 | * @return bool |
| 271 | 271 | */ |
| 272 | -function give_update_payment_status( $payment_id, $new_status = 'publish' ) { |
|
| 272 | +function give_update_payment_status($payment_id, $new_status = 'publish') { |
|
| 273 | 273 | |
| 274 | 274 | $updated = false; |
| 275 | - $payment = new Give_Payment( $payment_id ); |
|
| 275 | + $payment = new Give_Payment($payment_id); |
|
| 276 | 276 | |
| 277 | - if ( $payment && $payment->ID > 0 ) { |
|
| 277 | + if ($payment && $payment->ID > 0) { |
|
| 278 | 278 | |
| 279 | 279 | $payment->status = $new_status; |
| 280 | 280 | $updated = $payment->save(); |
@@ -295,45 +295,45 @@ discard block |
||
| 295 | 295 | * |
| 296 | 296 | * @return void |
| 297 | 297 | */ |
| 298 | -function give_delete_donation( $payment_id = 0, $update_donor = true ) { |
|
| 299 | - $payment = new Give_Payment( $payment_id ); |
|
| 298 | +function give_delete_donation($payment_id = 0, $update_donor = true) { |
|
| 299 | + $payment = new Give_Payment($payment_id); |
|
| 300 | 300 | |
| 301 | 301 | // Bailout. |
| 302 | - if ( ! $payment->ID ) { |
|
| 302 | + if ( ! $payment->ID) { |
|
| 303 | 303 | return; |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - $amount = give_donation_amount( $payment_id ); |
|
| 306 | + $amount = give_donation_amount($payment_id); |
|
| 307 | 307 | $status = $payment->post_status; |
| 308 | - $donor_id = give_get_payment_donor_id( $payment_id ); |
|
| 309 | - $donor = new Give_Donor( $donor_id ); |
|
| 308 | + $donor_id = give_get_payment_donor_id($payment_id); |
|
| 309 | + $donor = new Give_Donor($donor_id); |
|
| 310 | 310 | |
| 311 | 311 | // Only undo donations that aren't these statuses. |
| 312 | - $dont_undo_statuses = apply_filters( 'give_undo_donation_statuses', array( |
|
| 312 | + $dont_undo_statuses = apply_filters('give_undo_donation_statuses', array( |
|
| 313 | 313 | 'pending', |
| 314 | 314 | 'cancelled', |
| 315 | - ) ); |
|
| 315 | + )); |
|
| 316 | 316 | |
| 317 | - if ( ! in_array( $status, $dont_undo_statuses ) ) { |
|
| 318 | - give_undo_donation( $payment_id ); |
|
| 317 | + if ( ! in_array($status, $dont_undo_statuses)) { |
|
| 318 | + give_undo_donation($payment_id); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | // Only undo donations that aren't these statuses. |
| 322 | - $status_to_decrease_stats = apply_filters( 'give_decrease_donor_statuses', array( 'publish' ) ); |
|
| 322 | + $status_to_decrease_stats = apply_filters('give_decrease_donor_statuses', array('publish')); |
|
| 323 | 323 | |
| 324 | - if ( in_array( $status, $status_to_decrease_stats ) ) { |
|
| 324 | + if (in_array($status, $status_to_decrease_stats)) { |
|
| 325 | 325 | |
| 326 | 326 | // Only decrease earnings if they haven't already been decreased (or were never increased for this payment). |
| 327 | - give_decrease_total_earnings( $amount ); |
|
| 327 | + give_decrease_total_earnings($amount); |
|
| 328 | 328 | |
| 329 | 329 | // @todo: Refresh only range related stat cache |
| 330 | 330 | give_delete_donation_stats(); |
| 331 | 331 | |
| 332 | - if ( $donor->id && $update_donor ) { |
|
| 332 | + if ($donor->id && $update_donor) { |
|
| 333 | 333 | |
| 334 | 334 | // Decrement the stats for the donor. |
| 335 | 335 | $donor->decrease_donation_count(); |
| 336 | - $donor->decrease_value( $amount ); |
|
| 336 | + $donor->decrease_value($amount); |
|
| 337 | 337 | |
| 338 | 338 | } |
| 339 | 339 | } |
@@ -345,18 +345,18 @@ discard block |
||
| 345 | 345 | * |
| 346 | 346 | * @since 1.0 |
| 347 | 347 | */ |
| 348 | - do_action( 'give_payment_delete', $payment_id ); |
|
| 348 | + do_action('give_payment_delete', $payment_id); |
|
| 349 | 349 | |
| 350 | - if ( $donor->id && $update_donor ) { |
|
| 350 | + if ($donor->id && $update_donor) { |
|
| 351 | 351 | // Remove the payment ID from the donor. |
| 352 | - $donor->remove_payment( $payment_id ); |
|
| 352 | + $donor->remove_payment($payment_id); |
|
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | // Remove the payment. |
| 356 | - wp_delete_post( $payment_id, true ); |
|
| 356 | + wp_delete_post($payment_id, true); |
|
| 357 | 357 | |
| 358 | 358 | // Remove related sale log entries. |
| 359 | - Give()->logs->delete_logs( $payment_id ); |
|
| 359 | + Give()->logs->delete_logs($payment_id); |
|
| 360 | 360 | |
| 361 | 361 | /** |
| 362 | 362 | * Fires after payment deleted. |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | * |
| 366 | 366 | * @since 1.0 |
| 367 | 367 | */ |
| 368 | - do_action( 'give_payment_deleted', $payment_id ); |
|
| 368 | + do_action('give_payment_deleted', $payment_id); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
@@ -380,20 +380,20 @@ discard block |
||
| 380 | 380 | * |
| 381 | 381 | * @return void |
| 382 | 382 | */ |
| 383 | -function give_undo_donation( $payment_id ) { |
|
| 383 | +function give_undo_donation($payment_id) { |
|
| 384 | 384 | |
| 385 | - $payment = new Give_Payment( $payment_id ); |
|
| 385 | + $payment = new Give_Payment($payment_id); |
|
| 386 | 386 | |
| 387 | - $maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id ); |
|
| 388 | - if ( true === $maybe_decrease_earnings ) { |
|
| 387 | + $maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id); |
|
| 388 | + if (true === $maybe_decrease_earnings) { |
|
| 389 | 389 | // Decrease earnings. |
| 390 | - give_decrease_form_earnings( $payment->form_id, $payment->total ); |
|
| 390 | + give_decrease_form_earnings($payment->form_id, $payment->total); |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - $maybe_decrease_donations = apply_filters( 'give_decrease_donations_on_undo', true, $payment, $payment->form_id ); |
|
| 394 | - if ( true === $maybe_decrease_donations ) { |
|
| 393 | + $maybe_decrease_donations = apply_filters('give_decrease_donations_on_undo', true, $payment, $payment->form_id); |
|
| 394 | + if (true === $maybe_decrease_donations) { |
|
| 395 | 395 | // Decrease donation count. |
| 396 | - give_decrease_donation_count( $payment->form_id ); |
|
| 396 | + give_decrease_donation_count($payment->form_id); |
|
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | } |
@@ -410,21 +410,21 @@ discard block |
||
| 410 | 410 | * |
| 411 | 411 | * @return object $stats Contains the number of payments per payment status. |
| 412 | 412 | */ |
| 413 | -function give_count_payments( $args = array() ) { |
|
| 413 | +function give_count_payments($args = array()) { |
|
| 414 | 414 | // Backward compatibility. |
| 415 | - if ( ! empty( $args['start-date'] ) ) { |
|
| 415 | + if ( ! empty($args['start-date'])) { |
|
| 416 | 416 | $args['start_date'] = $args['start-date']; |
| 417 | - unset( $args['start-date'] ); |
|
| 417 | + unset($args['start-date']); |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | - if ( ! empty( $args['end-date'] ) ) { |
|
| 420 | + if ( ! empty($args['end-date'])) { |
|
| 421 | 421 | $args['end_date'] = $args['end-date']; |
| 422 | - unset( $args['end-date'] ); |
|
| 422 | + unset($args['end-date']); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - if ( ! empty( $args['form_id'] ) ) { |
|
| 425 | + if ( ! empty($args['form_id'])) { |
|
| 426 | 426 | $args['give_forms'] = $args['form_id']; |
| 427 | - unset( $args['form_id'] ); |
|
| 427 | + unset($args['form_id']); |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | // Extract all donations |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | $args['group_by'] = 'post_status'; |
| 433 | 433 | $args['count'] = 'true'; |
| 434 | 434 | |
| 435 | - $donations_obj = new Give_Payments_Query( $args ); |
|
| 435 | + $donations_obj = new Give_Payments_Query($args); |
|
| 436 | 436 | $donations_count = $donations_obj->get_payment_by_group(); |
| 437 | 437 | |
| 438 | 438 | /** |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | * |
| 441 | 441 | * @since 1.0 |
| 442 | 442 | */ |
| 443 | - return (object) apply_filters( 'give_count_payments', $donations_count, $args, $donations_obj ); |
|
| 443 | + return (object) apply_filters('give_count_payments', $donations_count, $args, $donations_obj); |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | |
@@ -453,11 +453,11 @@ discard block |
||
| 453 | 453 | * |
| 454 | 454 | * @return bool $exists True if payment exists, false otherwise. |
| 455 | 455 | */ |
| 456 | -function give_check_for_existing_payment( $payment_id ) { |
|
| 456 | +function give_check_for_existing_payment($payment_id) { |
|
| 457 | 457 | $exists = false; |
| 458 | - $payment = new Give_Payment( $payment_id ); |
|
| 458 | + $payment = new Give_Payment($payment_id); |
|
| 459 | 459 | |
| 460 | - if ( $payment_id === $payment->ID && 'publish' === $payment->status ) { |
|
| 460 | + if ($payment_id === $payment->ID && 'publish' === $payment->status) { |
|
| 461 | 461 | $exists = true; |
| 462 | 462 | } |
| 463 | 463 | |
@@ -475,41 +475,41 @@ discard block |
||
| 475 | 475 | * |
| 476 | 476 | * @return bool|mixed True if payment status exists, false otherwise. |
| 477 | 477 | */ |
| 478 | -function give_get_payment_status( $payment, $return_label = false ) { |
|
| 478 | +function give_get_payment_status($payment, $return_label = false) { |
|
| 479 | 479 | |
| 480 | - if ( is_numeric( $payment ) ) { |
|
| 480 | + if (is_numeric($payment)) { |
|
| 481 | 481 | |
| 482 | - $payment = new Give_Payment( $payment ); |
|
| 482 | + $payment = new Give_Payment($payment); |
|
| 483 | 483 | |
| 484 | - if ( ! $payment->ID > 0 ) { |
|
| 484 | + if ( ! $payment->ID > 0) { |
|
| 485 | 485 | return false; |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) { |
|
| 490 | + if ( ! is_object($payment) || ! isset($payment->post_status)) { |
|
| 491 | 491 | return false; |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | $statuses = give_get_payment_statuses(); |
| 495 | 495 | |
| 496 | - if ( ! is_array( $statuses ) || empty( $statuses ) ) { |
|
| 496 | + if ( ! is_array($statuses) || empty($statuses)) { |
|
| 497 | 497 | return false; |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | // Get payment object if not already given. |
| 501 | - $payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID ); |
|
| 501 | + $payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID); |
|
| 502 | 502 | |
| 503 | - if ( array_key_exists( $payment->status, $statuses ) ) { |
|
| 504 | - if ( true === $return_label ) { |
|
| 503 | + if (array_key_exists($payment->status, $statuses)) { |
|
| 504 | + if (true === $return_label) { |
|
| 505 | 505 | // Return translated status label. |
| 506 | - return $statuses[ $payment->status ]; |
|
| 506 | + return $statuses[$payment->status]; |
|
| 507 | 507 | } else { |
| 508 | 508 | // Account that our 'publish' status is labeled 'Complete' |
| 509 | 509 | $post_status = 'publish' === $payment->status ? 'Complete' : $payment->post_status; |
| 510 | 510 | |
| 511 | 511 | // Make sure we're matching cases, since they matter |
| 512 | - return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) ); |
|
| 512 | + return array_search(strtolower($post_status), array_map('strtolower', $statuses)); |
|
| 513 | 513 | } |
| 514 | 514 | } |
| 515 | 515 | |
@@ -525,18 +525,18 @@ discard block |
||
| 525 | 525 | */ |
| 526 | 526 | function give_get_payment_statuses() { |
| 527 | 527 | $payment_statuses = array( |
| 528 | - 'pending' => __( 'Pending', 'give' ), |
|
| 529 | - 'publish' => __( 'Complete', 'give' ), |
|
| 530 | - 'refunded' => __( 'Refunded', 'give' ), |
|
| 531 | - 'failed' => __( 'Failed', 'give' ), |
|
| 532 | - 'cancelled' => __( 'Cancelled', 'give' ), |
|
| 533 | - 'abandoned' => __( 'Abandoned', 'give' ), |
|
| 534 | - 'preapproval' => __( 'Pre-Approved', 'give' ), |
|
| 535 | - 'processing' => __( 'Processing', 'give' ), |
|
| 536 | - 'revoked' => __( 'Revoked', 'give' ), |
|
| 528 | + 'pending' => __('Pending', 'give'), |
|
| 529 | + 'publish' => __('Complete', 'give'), |
|
| 530 | + 'refunded' => __('Refunded', 'give'), |
|
| 531 | + 'failed' => __('Failed', 'give'), |
|
| 532 | + 'cancelled' => __('Cancelled', 'give'), |
|
| 533 | + 'abandoned' => __('Abandoned', 'give'), |
|
| 534 | + 'preapproval' => __('Pre-Approved', 'give'), |
|
| 535 | + 'processing' => __('Processing', 'give'), |
|
| 536 | + 'revoked' => __('Revoked', 'give'), |
|
| 537 | 537 | ); |
| 538 | 538 | |
| 539 | - return apply_filters( 'give_payment_statuses', $payment_statuses ); |
|
| 539 | + return apply_filters('give_payment_statuses', $payment_statuses); |
|
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | /** |
@@ -549,10 +549,10 @@ discard block |
||
| 549 | 549 | * @return array $payment_status All the available payment statuses. |
| 550 | 550 | */ |
| 551 | 551 | function give_get_payment_status_keys() { |
| 552 | - $statuses = array_keys( give_get_payment_statuses() ); |
|
| 553 | - asort( $statuses ); |
|
| 552 | + $statuses = array_keys(give_get_payment_statuses()); |
|
| 553 | + asort($statuses); |
|
| 554 | 554 | |
| 555 | - return array_values( $statuses ); |
|
| 555 | + return array_values($statuses); |
|
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | /** |
@@ -567,44 +567,44 @@ discard block |
||
| 567 | 567 | * |
| 568 | 568 | * @return int $earnings Earnings |
| 569 | 569 | */ |
| 570 | -function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
|
| 570 | +function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) { |
|
| 571 | 571 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead. |
| 572 | 572 | |
| 573 | 573 | global $wpdb; |
| 574 | - $meta_table = __give_v20_bc_table_details( 'payment' ); |
|
| 574 | + $meta_table = __give_v20_bc_table_details('payment'); |
|
| 575 | 575 | |
| 576 | 576 | $args = array( |
| 577 | 577 | 'post_type' => 'give_payment', |
| 578 | 578 | 'nopaging' => true, |
| 579 | 579 | 'year' => $year, |
| 580 | 580 | 'monthnum' => $month_num, |
| 581 | - 'post_status' => array( 'publish' ), |
|
| 581 | + 'post_status' => array('publish'), |
|
| 582 | 582 | 'fields' => 'ids', |
| 583 | 583 | 'update_post_term_cache' => false, |
| 584 | 584 | ); |
| 585 | - if ( ! empty( $day ) ) { |
|
| 585 | + if ( ! empty($day)) { |
|
| 586 | 586 | $args['day'] = $day; |
| 587 | 587 | } |
| 588 | 588 | |
| 589 | - if ( isset( $hour ) ) { |
|
| 589 | + if (isset($hour)) { |
|
| 590 | 590 | $args['hour'] = $hour; |
| 591 | 591 | } |
| 592 | 592 | |
| 593 | - $args = apply_filters( 'give_get_earnings_by_date_args', $args ); |
|
| 594 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
| 593 | + $args = apply_filters('give_get_earnings_by_date_args', $args); |
|
| 594 | + $key = Give_Cache::get_key('give_stats', $args); |
|
| 595 | 595 | |
| 596 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
| 596 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
| 597 | 597 | $earnings = false; |
| 598 | 598 | } else { |
| 599 | - $earnings = Give_Cache::get( $key ); |
|
| 599 | + $earnings = Give_Cache::get($key); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | - if ( false === $earnings ) { |
|
| 603 | - $donations = get_posts( $args ); |
|
| 602 | + if (false === $earnings) { |
|
| 603 | + $donations = get_posts($args); |
|
| 604 | 604 | $earnings = 0; |
| 605 | - if ( $donations ) { |
|
| 606 | - $donations = implode( ',', $donations ); |
|
| 607 | - $earning_totals = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})" ); |
|
| 605 | + if ($donations) { |
|
| 606 | + $donations = implode(',', $donations); |
|
| 607 | + $earning_totals = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})"); |
|
| 608 | 608 | |
| 609 | 609 | /** |
| 610 | 610 | * Filter The earnings by dates. |
@@ -615,13 +615,13 @@ discard block |
||
| 615 | 615 | * @param array $donations Donations lists. |
| 616 | 616 | * @param array $args Donation query args. |
| 617 | 617 | */ |
| 618 | - $earnings = apply_filters( 'give_get_earnings_by_date', $earning_totals, $donations, $args ); |
|
| 618 | + $earnings = apply_filters('give_get_earnings_by_date', $earning_totals, $donations, $args); |
|
| 619 | 619 | } |
| 620 | 620 | // Cache the results for one hour. |
| 621 | - Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS ); |
|
| 621 | + Give_Cache::set($key, $earnings, HOUR_IN_SECONDS); |
|
| 622 | 622 | } |
| 623 | 623 | |
| 624 | - return round( $earnings, 2 ); |
|
| 624 | + return round($earnings, 2); |
|
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | /** |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | * |
| 637 | 637 | * @return int $count Sales |
| 638 | 638 | */ |
| 639 | -function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) { |
|
| 639 | +function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) { |
|
| 640 | 640 | |
| 641 | 641 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead. |
| 642 | 642 | $args = array( |
@@ -644,14 +644,14 @@ discard block |
||
| 644 | 644 | 'nopaging' => true, |
| 645 | 645 | 'year' => $year, |
| 646 | 646 | 'fields' => 'ids', |
| 647 | - 'post_status' => array( 'publish' ), |
|
| 647 | + 'post_status' => array('publish'), |
|
| 648 | 648 | 'update_post_meta_cache' => false, |
| 649 | 649 | 'update_post_term_cache' => false, |
| 650 | 650 | ); |
| 651 | 651 | |
| 652 | - $show_free = apply_filters( 'give_sales_by_date_show_free', true, $args ); |
|
| 652 | + $show_free = apply_filters('give_sales_by_date_show_free', true, $args); |
|
| 653 | 653 | |
| 654 | - if ( false === $show_free ) { |
|
| 654 | + if (false === $show_free) { |
|
| 655 | 655 | $args['meta_query'] = array( |
| 656 | 656 | array( |
| 657 | 657 | 'key' => '_give_payment_total', |
@@ -662,33 +662,33 @@ discard block |
||
| 662 | 662 | ); |
| 663 | 663 | } |
| 664 | 664 | |
| 665 | - if ( ! empty( $month_num ) ) { |
|
| 665 | + if ( ! empty($month_num)) { |
|
| 666 | 666 | $args['monthnum'] = $month_num; |
| 667 | 667 | } |
| 668 | 668 | |
| 669 | - if ( ! empty( $day ) ) { |
|
| 669 | + if ( ! empty($day)) { |
|
| 670 | 670 | $args['day'] = $day; |
| 671 | 671 | } |
| 672 | 672 | |
| 673 | - if ( isset( $hour ) ) { |
|
| 673 | + if (isset($hour)) { |
|
| 674 | 674 | $args['hour'] = $hour; |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | - $args = apply_filters( 'give_get_sales_by_date_args', $args ); |
|
| 677 | + $args = apply_filters('give_get_sales_by_date_args', $args); |
|
| 678 | 678 | |
| 679 | - $key = Give_Cache::get_key( 'give_stats', $args ); |
|
| 679 | + $key = Give_Cache::get_key('give_stats', $args); |
|
| 680 | 680 | |
| 681 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
| 681 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
| 682 | 682 | $count = false; |
| 683 | 683 | } else { |
| 684 | - $count = Give_Cache::get( $key ); |
|
| 684 | + $count = Give_Cache::get($key); |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | - if ( false === $count ) { |
|
| 688 | - $donations = new WP_Query( $args ); |
|
| 687 | + if (false === $count) { |
|
| 688 | + $donations = new WP_Query($args); |
|
| 689 | 689 | $count = (int) $donations->post_count; |
| 690 | 690 | // Cache the results for one hour. |
| 691 | - Give_Cache::set( $key, $count, HOUR_IN_SECONDS ); |
|
| 691 | + Give_Cache::set($key, $count, HOUR_IN_SECONDS); |
|
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | return $count; |
@@ -703,19 +703,19 @@ discard block |
||
| 703 | 703 | * |
| 704 | 704 | * @return bool $ret True if complete, false otherwise. |
| 705 | 705 | */ |
| 706 | -function give_is_payment_complete( $payment_id ) { |
|
| 707 | - $payment = new Give_Payment( $payment_id ); |
|
| 706 | +function give_is_payment_complete($payment_id) { |
|
| 707 | + $payment = new Give_Payment($payment_id); |
|
| 708 | 708 | |
| 709 | 709 | $ret = false; |
| 710 | 710 | |
| 711 | - if ( $payment->ID > 0 ) { |
|
| 711 | + if ($payment->ID > 0) { |
|
| 712 | 712 | |
| 713 | - if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) { |
|
| 713 | + if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) { |
|
| 714 | 714 | $ret = true; |
| 715 | 715 | } |
| 716 | 716 | } |
| 717 | 717 | |
| 718 | - return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status ); |
|
| 718 | + return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status); |
|
| 719 | 719 | } |
| 720 | 720 | |
| 721 | 721 | /** |
@@ -741,50 +741,50 @@ discard block |
||
| 741 | 741 | * |
| 742 | 742 | * @return float $total Total earnings. |
| 743 | 743 | */ |
| 744 | -function give_get_total_earnings( $recalculate = false ) { |
|
| 744 | +function give_get_total_earnings($recalculate = false) { |
|
| 745 | 745 | |
| 746 | - $total = get_option( 'give_earnings_total', 0 ); |
|
| 747 | - $meta_table = __give_v20_bc_table_details( 'payment' ); |
|
| 746 | + $total = get_option('give_earnings_total', 0); |
|
| 747 | + $meta_table = __give_v20_bc_table_details('payment'); |
|
| 748 | 748 | |
| 749 | 749 | // Calculate total earnings. |
| 750 | - if ( ! $total || $recalculate ) { |
|
| 750 | + if ( ! $total || $recalculate) { |
|
| 751 | 751 | global $wpdb; |
| 752 | 752 | |
| 753 | 753 | $total = (float) 0; |
| 754 | 754 | |
| 755 | - $args = apply_filters( 'give_get_total_earnings_args', array( |
|
| 755 | + $args = apply_filters('give_get_total_earnings_args', array( |
|
| 756 | 756 | 'offset' => 0, |
| 757 | - 'number' => - 1, |
|
| 758 | - 'status' => array( 'publish' ), |
|
| 757 | + 'number' => -1, |
|
| 758 | + 'status' => array('publish'), |
|
| 759 | 759 | 'fields' => 'ids', |
| 760 | - ) ); |
|
| 760 | + )); |
|
| 761 | 761 | |
| 762 | - $payments = give_get_payments( $args ); |
|
| 763 | - if ( $payments ) { |
|
| 762 | + $payments = give_get_payments($args); |
|
| 763 | + if ($payments) { |
|
| 764 | 764 | |
| 765 | 765 | /** |
| 766 | 766 | * If performing a donation, we need to skip the very last payment in the database, |
| 767 | 767 | * since it calls give_increase_total_earnings() on completion, |
| 768 | 768 | * which results in duplicated earnings for the very first donation. |
| 769 | 769 | */ |
| 770 | - if ( did_action( 'give_update_payment_status' ) ) { |
|
| 771 | - array_pop( $payments ); |
|
| 770 | + if (did_action('give_update_payment_status')) { |
|
| 771 | + array_pop($payments); |
|
| 772 | 772 | } |
| 773 | 773 | |
| 774 | - if ( ! empty( $payments ) ) { |
|
| 775 | - $payments = implode( ',', $payments ); |
|
| 776 | - $total += $wpdb->get_var( "SELECT SUM(meta_value) FROM {$meta_table['name']} WHERE meta_key = '_give_payment_total' AND {$meta_table['column']['id']} IN({$payments})" ); |
|
| 774 | + if ( ! empty($payments)) { |
|
| 775 | + $payments = implode(',', $payments); |
|
| 776 | + $total += $wpdb->get_var("SELECT SUM(meta_value) FROM {$meta_table['name']} WHERE meta_key = '_give_payment_total' AND {$meta_table['column']['id']} IN({$payments})"); |
|
| 777 | 777 | } |
| 778 | 778 | } |
| 779 | 779 | |
| 780 | - update_option( 'give_earnings_total', $total, 'no' ); |
|
| 780 | + update_option('give_earnings_total', $total, 'no'); |
|
| 781 | 781 | } |
| 782 | 782 | |
| 783 | - if ( $total < 0 ) { |
|
| 783 | + if ($total < 0) { |
|
| 784 | 784 | $total = 0; // Don't ever show negative earnings. |
| 785 | 785 | } |
| 786 | 786 | |
| 787 | - return apply_filters( 'give_total_earnings', round( $total, give_get_price_decimals() ), $total ); |
|
| 787 | + return apply_filters('give_total_earnings', round($total, give_get_price_decimals()), $total); |
|
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | /** |
@@ -796,10 +796,10 @@ discard block |
||
| 796 | 796 | * |
| 797 | 797 | * @return float $total Total earnings. |
| 798 | 798 | */ |
| 799 | -function give_increase_total_earnings( $amount = 0 ) { |
|
| 799 | +function give_increase_total_earnings($amount = 0) { |
|
| 800 | 800 | $total = give_get_total_earnings(); |
| 801 | 801 | $total += $amount; |
| 802 | - update_option( 'give_earnings_total', $total ); |
|
| 802 | + update_option('give_earnings_total', $total); |
|
| 803 | 803 | |
| 804 | 804 | return $total; |
| 805 | 805 | } |
@@ -813,13 +813,13 @@ discard block |
||
| 813 | 813 | * |
| 814 | 814 | * @return float $total Total earnings. |
| 815 | 815 | */ |
| 816 | -function give_decrease_total_earnings( $amount = 0 ) { |
|
| 816 | +function give_decrease_total_earnings($amount = 0) { |
|
| 817 | 817 | $total = give_get_total_earnings(); |
| 818 | 818 | $total -= $amount; |
| 819 | - if ( $total < 0 ) { |
|
| 819 | + if ($total < 0) { |
|
| 820 | 820 | $total = 0; |
| 821 | 821 | } |
| 822 | - update_option( 'give_earnings_total', $total ); |
|
| 822 | + update_option('give_earnings_total', $total); |
|
| 823 | 823 | |
| 824 | 824 | return $total; |
| 825 | 825 | } |
@@ -835,10 +835,10 @@ discard block |
||
| 835 | 835 | * |
| 836 | 836 | * @return mixed $meta Payment Meta. |
| 837 | 837 | */ |
| 838 | -function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) { |
|
| 839 | - $payment = new Give_Payment( $payment_id ); |
|
| 838 | +function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) { |
|
| 839 | + $payment = new Give_Payment($payment_id); |
|
| 840 | 840 | |
| 841 | - return $payment->get_meta( $meta_key, $single ); |
|
| 841 | + return $payment->get_meta($meta_key, $single); |
|
| 842 | 842 | } |
| 843 | 843 | |
| 844 | 844 | /** |
@@ -851,10 +851,10 @@ discard block |
||
| 851 | 851 | * |
| 852 | 852 | * @return mixed Meta ID if successful, false if unsuccessful. |
| 853 | 853 | */ |
| 854 | -function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
| 855 | - $payment = new Give_Payment( $payment_id ); |
|
| 854 | +function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') { |
|
| 855 | + $payment = new Give_Payment($payment_id); |
|
| 856 | 856 | |
| 857 | - return $payment->update_meta( $meta_key, $meta_value, $prev_value ); |
|
| 857 | + return $payment->update_meta($meta_key, $meta_value, $prev_value); |
|
| 858 | 858 | } |
| 859 | 859 | |
| 860 | 860 | /** |
@@ -866,8 +866,8 @@ discard block |
||
| 866 | 866 | * |
| 867 | 867 | * @return array $user_info User Info Meta Values. |
| 868 | 868 | */ |
| 869 | -function give_get_payment_meta_user_info( $payment_id ) { |
|
| 870 | - $payment = new Give_Payment( $payment_id ); |
|
| 869 | +function give_get_payment_meta_user_info($payment_id) { |
|
| 870 | + $payment = new Give_Payment($payment_id); |
|
| 871 | 871 | |
| 872 | 872 | return $payment->user_info; |
| 873 | 873 | } |
@@ -883,8 +883,8 @@ discard block |
||
| 883 | 883 | * |
| 884 | 884 | * @return int $form_id Form ID. |
| 885 | 885 | */ |
| 886 | -function give_get_payment_form_id( $payment_id ) { |
|
| 887 | - $payment = new Give_Payment( $payment_id ); |
|
| 886 | +function give_get_payment_form_id($payment_id) { |
|
| 887 | + $payment = new Give_Payment($payment_id); |
|
| 888 | 888 | |
| 889 | 889 | return $payment->form_id; |
| 890 | 890 | } |
@@ -898,8 +898,8 @@ discard block |
||
| 898 | 898 | * |
| 899 | 899 | * @return string $email User email. |
| 900 | 900 | */ |
| 901 | -function give_get_payment_user_email( $payment_id ) { |
|
| 902 | - $payment = new Give_Payment( $payment_id ); |
|
| 901 | +function give_get_payment_user_email($payment_id) { |
|
| 902 | + $payment = new Give_Payment($payment_id); |
|
| 903 | 903 | |
| 904 | 904 | return $payment->email; |
| 905 | 905 | } |
@@ -913,11 +913,11 @@ discard block |
||
| 913 | 913 | * |
| 914 | 914 | * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true) |
| 915 | 915 | */ |
| 916 | -function give_is_guest_payment( $payment_id ) { |
|
| 917 | - $payment_user_id = give_get_payment_user_id( $payment_id ); |
|
| 918 | - $is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true; |
|
| 916 | +function give_is_guest_payment($payment_id) { |
|
| 917 | + $payment_user_id = give_get_payment_user_id($payment_id); |
|
| 918 | + $is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true; |
|
| 919 | 919 | |
| 920 | - return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id ); |
|
| 920 | + return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id); |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | /** |
@@ -929,8 +929,8 @@ discard block |
||
| 929 | 929 | * |
| 930 | 930 | * @return int $user_id User ID. |
| 931 | 931 | */ |
| 932 | -function give_get_payment_user_id( $payment_id ) { |
|
| 933 | - $payment = new Give_Payment( $payment_id ); |
|
| 932 | +function give_get_payment_user_id($payment_id) { |
|
| 933 | + $payment = new Give_Payment($payment_id); |
|
| 934 | 934 | |
| 935 | 935 | return $payment->user_id; |
| 936 | 936 | } |
@@ -944,8 +944,8 @@ discard block |
||
| 944 | 944 | * |
| 945 | 945 | * @return int $payment->customer_id Donor ID. |
| 946 | 946 | */ |
| 947 | -function give_get_payment_donor_id( $payment_id ) { |
|
| 948 | - $payment = new Give_Payment( $payment_id ); |
|
| 947 | +function give_get_payment_donor_id($payment_id) { |
|
| 948 | + $payment = new Give_Payment($payment_id); |
|
| 949 | 949 | |
| 950 | 950 | return $payment->customer_id; |
| 951 | 951 | } |
@@ -959,8 +959,8 @@ discard block |
||
| 959 | 959 | * |
| 960 | 960 | * @return string $ip User IP. |
| 961 | 961 | */ |
| 962 | -function give_get_payment_user_ip( $payment_id ) { |
|
| 963 | - $payment = new Give_Payment( $payment_id ); |
|
| 962 | +function give_get_payment_user_ip($payment_id) { |
|
| 963 | + $payment = new Give_Payment($payment_id); |
|
| 964 | 964 | |
| 965 | 965 | return $payment->ip; |
| 966 | 966 | } |
@@ -974,8 +974,8 @@ discard block |
||
| 974 | 974 | * |
| 975 | 975 | * @return string $date The date the payment was completed. |
| 976 | 976 | */ |
| 977 | -function give_get_payment_completed_date( $payment_id = 0 ) { |
|
| 978 | - $payment = new Give_Payment( $payment_id ); |
|
| 977 | +function give_get_payment_completed_date($payment_id = 0) { |
|
| 978 | + $payment = new Give_Payment($payment_id); |
|
| 979 | 979 | |
| 980 | 980 | return $payment->completed_date; |
| 981 | 981 | } |
@@ -989,8 +989,8 @@ discard block |
||
| 989 | 989 | * |
| 990 | 990 | * @return string $gateway Gateway. |
| 991 | 991 | */ |
| 992 | -function give_get_payment_gateway( $payment_id ) { |
|
| 993 | - $payment = new Give_Payment( $payment_id ); |
|
| 992 | +function give_get_payment_gateway($payment_id) { |
|
| 993 | + $payment = new Give_Payment($payment_id); |
|
| 994 | 994 | |
| 995 | 995 | return $payment->gateway; |
| 996 | 996 | } |
@@ -1004,8 +1004,8 @@ discard block |
||
| 1004 | 1004 | * |
| 1005 | 1005 | * @return string $currency The currency code. |
| 1006 | 1006 | */ |
| 1007 | -function give_get_payment_currency_code( $payment_id = 0 ) { |
|
| 1008 | - $payment = new Give_Payment( $payment_id ); |
|
| 1007 | +function give_get_payment_currency_code($payment_id = 0) { |
|
| 1008 | + $payment = new Give_Payment($payment_id); |
|
| 1009 | 1009 | |
| 1010 | 1010 | return $payment->currency; |
| 1011 | 1011 | } |
@@ -1019,10 +1019,10 @@ discard block |
||
| 1019 | 1019 | * |
| 1020 | 1020 | * @return string $currency The currency name. |
| 1021 | 1021 | */ |
| 1022 | -function give_get_payment_currency( $payment_id = 0 ) { |
|
| 1023 | - $currency = give_get_payment_currency_code( $payment_id ); |
|
| 1022 | +function give_get_payment_currency($payment_id = 0) { |
|
| 1023 | + $currency = give_get_payment_currency_code($payment_id); |
|
| 1024 | 1024 | |
| 1025 | - return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id ); |
|
| 1025 | + return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id); |
|
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | 1028 | /** |
@@ -1034,8 +1034,8 @@ discard block |
||
| 1034 | 1034 | * |
| 1035 | 1035 | * @return string $key Donation key. |
| 1036 | 1036 | */ |
| 1037 | -function give_get_payment_key( $payment_id = 0 ) { |
|
| 1038 | - $payment = new Give_Payment( $payment_id ); |
|
| 1037 | +function give_get_payment_key($payment_id = 0) { |
|
| 1038 | + $payment = new Give_Payment($payment_id); |
|
| 1039 | 1039 | |
| 1040 | 1040 | return $payment->key; |
| 1041 | 1041 | } |
@@ -1051,8 +1051,8 @@ discard block |
||
| 1051 | 1051 | * |
| 1052 | 1052 | * @return string $number Payment order number. |
| 1053 | 1053 | */ |
| 1054 | -function give_get_payment_number( $payment_id = 0 ) { |
|
| 1055 | - $payment = new Give_Payment( $payment_id ); |
|
| 1054 | +function give_get_payment_number($payment_id = 0) { |
|
| 1055 | + $payment = new Give_Payment($payment_id); |
|
| 1056 | 1056 | |
| 1057 | 1057 | return $payment->number; |
| 1058 | 1058 | } |
@@ -1066,23 +1066,23 @@ discard block |
||
| 1066 | 1066 | * |
| 1067 | 1067 | * @return string The formatted payment number. |
| 1068 | 1068 | */ |
| 1069 | -function give_format_payment_number( $number ) { |
|
| 1069 | +function give_format_payment_number($number) { |
|
| 1070 | 1070 | |
| 1071 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
| 1071 | + if ( ! give_get_option('enable_sequential')) { |
|
| 1072 | 1072 | return $number; |
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | - if ( ! is_numeric( $number ) ) { |
|
| 1075 | + if ( ! is_numeric($number)) { |
|
| 1076 | 1076 | return $number; |
| 1077 | 1077 | } |
| 1078 | 1078 | |
| 1079 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
| 1080 | - $number = absint( $number ); |
|
| 1081 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
| 1079 | + $prefix = give_get_option('sequential_prefix'); |
|
| 1080 | + $number = absint($number); |
|
| 1081 | + $postfix = give_get_option('sequential_postfix'); |
|
| 1082 | 1082 | |
| 1083 | - $formatted_number = $prefix . $number . $postfix; |
|
| 1083 | + $formatted_number = $prefix.$number.$postfix; |
|
| 1084 | 1084 | |
| 1085 | - return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix ); |
|
| 1085 | + return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix); |
|
| 1086 | 1086 | } |
| 1087 | 1087 | |
| 1088 | 1088 | /** |
@@ -1096,17 +1096,17 @@ discard block |
||
| 1096 | 1096 | */ |
| 1097 | 1097 | function give_get_next_payment_number() { |
| 1098 | 1098 | |
| 1099 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
| 1099 | + if ( ! give_get_option('enable_sequential')) { |
|
| 1100 | 1100 | return false; |
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | - $number = get_option( 'give_last_payment_number' ); |
|
| 1104 | - $start = give_get_option( 'sequential_start', 1 ); |
|
| 1103 | + $number = get_option('give_last_payment_number'); |
|
| 1104 | + $start = give_get_option('sequential_start', 1); |
|
| 1105 | 1105 | $increment_number = true; |
| 1106 | 1106 | |
| 1107 | - if ( false !== $number ) { |
|
| 1107 | + if (false !== $number) { |
|
| 1108 | 1108 | |
| 1109 | - if ( empty( $number ) ) { |
|
| 1109 | + if (empty($number)) { |
|
| 1110 | 1110 | |
| 1111 | 1111 | $number = $start; |
| 1112 | 1112 | $increment_number = false; |
@@ -1115,24 +1115,24 @@ discard block |
||
| 1115 | 1115 | } else { |
| 1116 | 1116 | |
| 1117 | 1117 | // This case handles the first addition of the new option, as well as if it get's deleted for any reason. |
| 1118 | - $payments = new Give_Payments_Query( array( |
|
| 1118 | + $payments = new Give_Payments_Query(array( |
|
| 1119 | 1119 | 'number' => 1, |
| 1120 | 1120 | 'order' => 'DESC', |
| 1121 | 1121 | 'orderby' => 'ID', |
| 1122 | 1122 | 'output' => 'posts', |
| 1123 | 1123 | 'fields' => 'ids', |
| 1124 | - ) ); |
|
| 1124 | + )); |
|
| 1125 | 1125 | $last_payment = $payments->get_payments(); |
| 1126 | 1126 | |
| 1127 | - if ( ! empty( $last_payment ) ) { |
|
| 1127 | + if ( ! empty($last_payment)) { |
|
| 1128 | 1128 | |
| 1129 | - $number = give_get_payment_number( $last_payment[0] ); |
|
| 1129 | + $number = give_get_payment_number($last_payment[0]); |
|
| 1130 | 1130 | |
| 1131 | 1131 | } |
| 1132 | 1132 | |
| 1133 | - if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) { |
|
| 1133 | + if ( ! empty($number) && $number !== (int) $last_payment[0]) { |
|
| 1134 | 1134 | |
| 1135 | - $number = give_remove_payment_prefix_postfix( $number ); |
|
| 1135 | + $number = give_remove_payment_prefix_postfix($number); |
|
| 1136 | 1136 | |
| 1137 | 1137 | } else { |
| 1138 | 1138 | |
@@ -1141,13 +1141,13 @@ discard block |
||
| 1141 | 1141 | } |
| 1142 | 1142 | }// End if(). |
| 1143 | 1143 | |
| 1144 | - $increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number ); |
|
| 1144 | + $increment_number = apply_filters('give_increment_payment_number', $increment_number, $number); |
|
| 1145 | 1145 | |
| 1146 | - if ( $increment_number ) { |
|
| 1147 | - $number ++; |
|
| 1146 | + if ($increment_number) { |
|
| 1147 | + $number++; |
|
| 1148 | 1148 | } |
| 1149 | 1149 | |
| 1150 | - return apply_filters( 'give_get_next_payment_number', $number ); |
|
| 1150 | + return apply_filters('give_get_next_payment_number', $number); |
|
| 1151 | 1151 | } |
| 1152 | 1152 | |
| 1153 | 1153 | /** |
@@ -1159,25 +1159,25 @@ discard block |
||
| 1159 | 1159 | * |
| 1160 | 1160 | * @return string The new Payment number without prefix and postfix. |
| 1161 | 1161 | */ |
| 1162 | -function give_remove_payment_prefix_postfix( $number ) { |
|
| 1162 | +function give_remove_payment_prefix_postfix($number) { |
|
| 1163 | 1163 | |
| 1164 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
| 1165 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
| 1164 | + $prefix = give_get_option('sequential_prefix'); |
|
| 1165 | + $postfix = give_get_option('sequential_postfix'); |
|
| 1166 | 1166 | |
| 1167 | 1167 | // Remove prefix. |
| 1168 | - $number = preg_replace( '/' . $prefix . '/', '', $number, 1 ); |
|
| 1168 | + $number = preg_replace('/'.$prefix.'/', '', $number, 1); |
|
| 1169 | 1169 | |
| 1170 | 1170 | // Remove the postfix. |
| 1171 | - $length = strlen( $number ); |
|
| 1172 | - $postfix_pos = strrpos( $number, $postfix ); |
|
| 1173 | - if ( false !== $postfix_pos ) { |
|
| 1174 | - $number = substr_replace( $number, '', $postfix_pos, $length ); |
|
| 1171 | + $length = strlen($number); |
|
| 1172 | + $postfix_pos = strrpos($number, $postfix); |
|
| 1173 | + if (false !== $postfix_pos) { |
|
| 1174 | + $number = substr_replace($number, '', $postfix_pos, $length); |
|
| 1175 | 1175 | } |
| 1176 | 1176 | |
| 1177 | 1177 | // Ensure it's a whole number. |
| 1178 | - $number = intval( $number ); |
|
| 1178 | + $number = intval($number); |
|
| 1179 | 1179 | |
| 1180 | - return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix ); |
|
| 1180 | + return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix); |
|
| 1181 | 1181 | |
| 1182 | 1182 | } |
| 1183 | 1183 | |
@@ -1195,16 +1195,16 @@ discard block |
||
| 1195 | 1195 | * |
| 1196 | 1196 | * @return string $amount Fully formatted donation amount. |
| 1197 | 1197 | */ |
| 1198 | -function give_donation_amount( $donation, $format_args = array() ) { |
|
| 1198 | +function give_donation_amount($donation, $format_args = array()) { |
|
| 1199 | 1199 | /* @var Give_Payment $donation */ |
| 1200 | - if ( ! ( $donation instanceof Give_Payment ) ) { |
|
| 1201 | - $donation = new Give_Payment( absint( $donation ) ); |
|
| 1200 | + if ( ! ($donation instanceof Give_Payment)) { |
|
| 1201 | + $donation = new Give_Payment(absint($donation)); |
|
| 1202 | 1202 | } |
| 1203 | 1203 | |
| 1204 | 1204 | $amount = $donation->total; |
| 1205 | 1205 | $formatted_amount = $amount; |
| 1206 | 1206 | |
| 1207 | - if ( is_bool( $format_args ) ) { |
|
| 1207 | + if (is_bool($format_args)) { |
|
| 1208 | 1208 | $format_args = array( |
| 1209 | 1209 | 'currency' => (bool) $format_args, |
| 1210 | 1210 | 'amount' => (bool) $format_args, |
@@ -1227,27 +1227,25 @@ discard block |
||
| 1227 | 1227 | ) |
| 1228 | 1228 | ); |
| 1229 | 1229 | |
| 1230 | - if ( $format_args['amount'] || $format_args['currency'] ) { |
|
| 1230 | + if ($format_args['amount'] || $format_args['currency']) { |
|
| 1231 | 1231 | |
| 1232 | - if ( $format_args['amount'] ) { |
|
| 1232 | + if ($format_args['amount']) { |
|
| 1233 | 1233 | |
| 1234 | 1234 | $formatted_amount = give_format_amount( |
| 1235 | 1235 | $amount, |
| 1236 | - ! is_array( $format_args['amount'] ) ? |
|
| 1236 | + ! is_array($format_args['amount']) ? |
|
| 1237 | 1237 | array( |
| 1238 | 1238 | 'sanitize' => false, |
| 1239 | 1239 | 'currency' => $donation->currency, |
| 1240 | - ) : |
|
| 1241 | - $format_args['amount'] |
|
| 1240 | + ) : $format_args['amount'] |
|
| 1242 | 1241 | ); |
| 1243 | 1242 | } |
| 1244 | 1243 | |
| 1245 | - if ( $format_args['currency'] ) { |
|
| 1244 | + if ($format_args['currency']) { |
|
| 1246 | 1245 | $formatted_amount = give_currency_filter( |
| 1247 | 1246 | $formatted_amount, |
| 1248 | - ! is_array( $format_args['currency'] ) ? |
|
| 1249 | - array( 'currency_code' => $donation->currency ) : |
|
| 1250 | - $format_args['currency'] |
|
| 1247 | + ! is_array($format_args['currency']) ? |
|
| 1248 | + array('currency_code' => $donation->currency) : $format_args['currency'] |
|
| 1251 | 1249 | ); |
| 1252 | 1250 | } |
| 1253 | 1251 | } |
@@ -1262,7 +1260,7 @@ discard block |
||
| 1262 | 1260 | * @param int $donation_id Donation ID. |
| 1263 | 1261 | * @param string $type Donation amount type. |
| 1264 | 1262 | */ |
| 1265 | - return apply_filters( 'give_donation_amount', (string) $formatted_amount, $amount, $donation, $format_args ); |
|
| 1263 | + return apply_filters('give_donation_amount', (string) $formatted_amount, $amount, $donation, $format_args); |
|
| 1266 | 1264 | } |
| 1267 | 1265 | |
| 1268 | 1266 | /** |
@@ -1279,10 +1277,10 @@ discard block |
||
| 1279 | 1277 | * |
| 1280 | 1278 | * @return array Fully formatted payment subtotal. |
| 1281 | 1279 | */ |
| 1282 | -function give_payment_subtotal( $payment_id = 0 ) { |
|
| 1283 | - $subtotal = give_get_payment_subtotal( $payment_id ); |
|
| 1280 | +function give_payment_subtotal($payment_id = 0) { |
|
| 1281 | + $subtotal = give_get_payment_subtotal($payment_id); |
|
| 1284 | 1282 | |
| 1285 | - return give_currency_filter( give_format_amount( $subtotal, array( 'sanitize' => false ) ), array( 'currency_code' => give_get_payment_currency_code( $payment_id ) ) ); |
|
| 1283 | + return give_currency_filter(give_format_amount($subtotal, array('sanitize' => false)), array('currency_code' => give_get_payment_currency_code($payment_id))); |
|
| 1286 | 1284 | } |
| 1287 | 1285 | |
| 1288 | 1286 | /** |
@@ -1296,8 +1294,8 @@ discard block |
||
| 1296 | 1294 | * |
| 1297 | 1295 | * @return float $subtotal Subtotal for payment (non formatted). |
| 1298 | 1296 | */ |
| 1299 | -function give_get_payment_subtotal( $payment_id = 0 ) { |
|
| 1300 | - $payment = new Give_Payment( $payment_id ); |
|
| 1297 | +function give_get_payment_subtotal($payment_id = 0) { |
|
| 1298 | + $payment = new Give_Payment($payment_id); |
|
| 1301 | 1299 | |
| 1302 | 1300 | return $payment->subtotal; |
| 1303 | 1301 | } |
@@ -1311,8 +1309,8 @@ discard block |
||
| 1311 | 1309 | * |
| 1312 | 1310 | * @return string The donation ID. |
| 1313 | 1311 | */ |
| 1314 | -function give_get_payment_transaction_id( $payment_id = 0 ) { |
|
| 1315 | - $payment = new Give_Payment( $payment_id ); |
|
| 1312 | +function give_get_payment_transaction_id($payment_id = 0) { |
|
| 1313 | + $payment = new Give_Payment($payment_id); |
|
| 1316 | 1314 | |
| 1317 | 1315 | return $payment->transaction_id; |
| 1318 | 1316 | } |
@@ -1327,15 +1325,15 @@ discard block |
||
| 1327 | 1325 | * |
| 1328 | 1326 | * @return bool|mixed |
| 1329 | 1327 | */ |
| 1330 | -function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) { |
|
| 1328 | +function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') { |
|
| 1331 | 1329 | |
| 1332 | - if ( empty( $payment_id ) || empty( $transaction_id ) ) { |
|
| 1330 | + if (empty($payment_id) || empty($transaction_id)) { |
|
| 1333 | 1331 | return false; |
| 1334 | 1332 | } |
| 1335 | 1333 | |
| 1336 | - $transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
| 1334 | + $transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id); |
|
| 1337 | 1335 | |
| 1338 | - return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id ); |
|
| 1336 | + return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id); |
|
| 1339 | 1337 | } |
| 1340 | 1338 | |
| 1341 | 1339 | /** |
@@ -1348,10 +1346,10 @@ discard block |
||
| 1348 | 1346 | * |
| 1349 | 1347 | * @return int $purchase Donation ID. |
| 1350 | 1348 | */ |
| 1351 | -function give_get_donation_id_by_key( $key ) { |
|
| 1349 | +function give_get_donation_id_by_key($key) { |
|
| 1352 | 1350 | global $wpdb; |
| 1353 | 1351 | |
| 1354 | - $meta_table = __give_v20_bc_table_details( 'payment' ); |
|
| 1352 | + $meta_table = __give_v20_bc_table_details('payment'); |
|
| 1355 | 1353 | |
| 1356 | 1354 | $purchase = $wpdb->get_var( |
| 1357 | 1355 | $wpdb->prepare( |
@@ -1367,7 +1365,7 @@ discard block |
||
| 1367 | 1365 | ) |
| 1368 | 1366 | ); |
| 1369 | 1367 | |
| 1370 | - if ( $purchase != null ) { |
|
| 1368 | + if ($purchase != null) { |
|
| 1371 | 1369 | return $purchase; |
| 1372 | 1370 | } |
| 1373 | 1371 | |
@@ -1385,13 +1383,13 @@ discard block |
||
| 1385 | 1383 | * |
| 1386 | 1384 | * @return int $purchase Donation ID. |
| 1387 | 1385 | */ |
| 1388 | -function give_get_purchase_id_by_transaction_id( $key ) { |
|
| 1386 | +function give_get_purchase_id_by_transaction_id($key) { |
|
| 1389 | 1387 | global $wpdb; |
| 1390 | - $meta_table = __give_v20_bc_table_details( 'payment' ); |
|
| 1388 | + $meta_table = __give_v20_bc_table_details('payment'); |
|
| 1391 | 1389 | |
| 1392 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT {$meta_table['column']['id']} FROM {$meta_table['name']} WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) ); |
|
| 1390 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT {$meta_table['column']['id']} FROM {$meta_table['name']} WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key)); |
|
| 1393 | 1391 | |
| 1394 | - if ( $purchase != null ) { |
|
| 1392 | + if ($purchase != null) { |
|
| 1395 | 1393 | return $purchase; |
| 1396 | 1394 | } |
| 1397 | 1395 | |
@@ -1408,23 +1406,23 @@ discard block |
||
| 1408 | 1406 | * |
| 1409 | 1407 | * @return array $notes Donation Notes |
| 1410 | 1408 | */ |
| 1411 | -function give_get_payment_notes( $payment_id = 0, $search = '' ) { |
|
| 1409 | +function give_get_payment_notes($payment_id = 0, $search = '') { |
|
| 1412 | 1410 | |
| 1413 | - if ( empty( $payment_id ) && empty( $search ) ) { |
|
| 1411 | + if (empty($payment_id) && empty($search)) { |
|
| 1414 | 1412 | return false; |
| 1415 | 1413 | } |
| 1416 | 1414 | |
| 1417 | - remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
| 1418 | - remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 ); |
|
| 1415 | + remove_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
| 1416 | + remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10); |
|
| 1419 | 1417 | |
| 1420 | - $notes = get_comments( array( |
|
| 1418 | + $notes = get_comments(array( |
|
| 1421 | 1419 | 'post_id' => $payment_id, |
| 1422 | 1420 | 'order' => 'ASC', |
| 1423 | 1421 | 'search' => $search, |
| 1424 | - ) ); |
|
| 1422 | + )); |
|
| 1425 | 1423 | |
| 1426 | - add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
| 1427 | - add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
| 1424 | + add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
| 1425 | + add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
| 1428 | 1426 | |
| 1429 | 1427 | return $notes; |
| 1430 | 1428 | } |
@@ -1440,8 +1438,8 @@ discard block |
||
| 1440 | 1438 | * |
| 1441 | 1439 | * @return int The new note ID |
| 1442 | 1440 | */ |
| 1443 | -function give_insert_payment_note( $payment_id = 0, $note = '' ) { |
|
| 1444 | - if ( empty( $payment_id ) ) { |
|
| 1441 | +function give_insert_payment_note($payment_id = 0, $note = '') { |
|
| 1442 | + if (empty($payment_id)) { |
|
| 1445 | 1443 | return false; |
| 1446 | 1444 | } |
| 1447 | 1445 | |
@@ -1453,14 +1451,14 @@ discard block |
||
| 1453 | 1451 | * |
| 1454 | 1452 | * @since 1.0 |
| 1455 | 1453 | */ |
| 1456 | - do_action( 'give_pre_insert_payment_note', $payment_id, $note ); |
|
| 1454 | + do_action('give_pre_insert_payment_note', $payment_id, $note); |
|
| 1457 | 1455 | |
| 1458 | - $note_id = wp_insert_comment( wp_filter_comment( array( |
|
| 1456 | + $note_id = wp_insert_comment(wp_filter_comment(array( |
|
| 1459 | 1457 | 'comment_post_ID' => $payment_id, |
| 1460 | 1458 | 'comment_content' => $note, |
| 1461 | 1459 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
| 1462 | - 'comment_date' => current_time( 'mysql' ), |
|
| 1463 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
| 1460 | + 'comment_date' => current_time('mysql'), |
|
| 1461 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
| 1464 | 1462 | 'comment_approved' => 1, |
| 1465 | 1463 | 'comment_parent' => 0, |
| 1466 | 1464 | 'comment_author' => '', |
@@ -1469,7 +1467,7 @@ discard block |
||
| 1469 | 1467 | 'comment_author_email' => '', |
| 1470 | 1468 | 'comment_type' => 'give_payment_note', |
| 1471 | 1469 | |
| 1472 | - ) ) ); |
|
| 1470 | + ))); |
|
| 1473 | 1471 | |
| 1474 | 1472 | /** |
| 1475 | 1473 | * Fires after payment note inserted. |
@@ -1480,7 +1478,7 @@ discard block |
||
| 1480 | 1478 | * |
| 1481 | 1479 | * @since 1.0 |
| 1482 | 1480 | */ |
| 1483 | - do_action( 'give_insert_payment_note', $note_id, $payment_id, $note ); |
|
| 1481 | + do_action('give_insert_payment_note', $note_id, $payment_id, $note); |
|
| 1484 | 1482 | |
| 1485 | 1483 | return $note_id; |
| 1486 | 1484 | } |
@@ -1495,8 +1493,8 @@ discard block |
||
| 1495 | 1493 | * |
| 1496 | 1494 | * @return bool True on success, false otherwise. |
| 1497 | 1495 | */ |
| 1498 | -function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) { |
|
| 1499 | - if ( empty( $comment_id ) ) { |
|
| 1496 | +function give_delete_payment_note($comment_id = 0, $payment_id = 0) { |
|
| 1497 | + if (empty($comment_id)) { |
|
| 1500 | 1498 | return false; |
| 1501 | 1499 | } |
| 1502 | 1500 | |
@@ -1508,9 +1506,9 @@ discard block |
||
| 1508 | 1506 | * |
| 1509 | 1507 | * @since 1.0 |
| 1510 | 1508 | */ |
| 1511 | - do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id ); |
|
| 1509 | + do_action('give_pre_delete_payment_note', $comment_id, $payment_id); |
|
| 1512 | 1510 | |
| 1513 | - $ret = wp_delete_comment( $comment_id, true ); |
|
| 1511 | + $ret = wp_delete_comment($comment_id, true); |
|
| 1514 | 1512 | |
| 1515 | 1513 | /** |
| 1516 | 1514 | * Fires after donation note deleted. |
@@ -1520,7 +1518,7 @@ discard block |
||
| 1520 | 1518 | * |
| 1521 | 1519 | * @since 1.0 |
| 1522 | 1520 | */ |
| 1523 | - do_action( 'give_post_delete_payment_note', $comment_id, $payment_id ); |
|
| 1521 | + do_action('give_post_delete_payment_note', $comment_id, $payment_id); |
|
| 1524 | 1522 | |
| 1525 | 1523 | return $ret; |
| 1526 | 1524 | } |
@@ -1535,32 +1533,32 @@ discard block |
||
| 1535 | 1533 | * |
| 1536 | 1534 | * @return string |
| 1537 | 1535 | */ |
| 1538 | -function give_get_payment_note_html( $note, $payment_id = 0 ) { |
|
| 1536 | +function give_get_payment_note_html($note, $payment_id = 0) { |
|
| 1539 | 1537 | |
| 1540 | - if ( is_numeric( $note ) ) { |
|
| 1541 | - $note = get_comment( $note ); |
|
| 1538 | + if (is_numeric($note)) { |
|
| 1539 | + $note = get_comment($note); |
|
| 1542 | 1540 | } |
| 1543 | 1541 | |
| 1544 | - if ( ! empty( $note->user_id ) ) { |
|
| 1545 | - $user = get_userdata( $note->user_id ); |
|
| 1542 | + if ( ! empty($note->user_id)) { |
|
| 1543 | + $user = get_userdata($note->user_id); |
|
| 1546 | 1544 | $user = $user->display_name; |
| 1547 | 1545 | } else { |
| 1548 | - $user = __( 'System', 'give' ); |
|
| 1546 | + $user = __('System', 'give'); |
|
| 1549 | 1547 | } |
| 1550 | 1548 | |
| 1551 | - $date_format = give_date_format() . ', ' . get_option( 'time_format' ); |
|
| 1549 | + $date_format = give_date_format().', '.get_option('time_format'); |
|
| 1552 | 1550 | |
| 1553 | - $delete_note_url = wp_nonce_url( add_query_arg( array( |
|
| 1551 | + $delete_note_url = wp_nonce_url(add_query_arg(array( |
|
| 1554 | 1552 | 'give-action' => 'delete_payment_note', |
| 1555 | 1553 | 'note_id' => $note->comment_ID, |
| 1556 | 1554 | 'payment_id' => $payment_id, |
| 1557 | - ) ), 'give_delete_payment_note_' . $note->comment_ID ); |
|
| 1555 | + )), 'give_delete_payment_note_'.$note->comment_ID); |
|
| 1558 | 1556 | |
| 1559 | - $note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">'; |
|
| 1557 | + $note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">'; |
|
| 1560 | 1558 | $note_html .= '<p>'; |
| 1561 | - $note_html .= '<strong>' . $user . '</strong> – <span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>'; |
|
| 1559 | + $note_html .= '<strong>'.$user.'</strong> – <span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>'; |
|
| 1562 | 1560 | $note_html .= $note->comment_content; |
| 1563 | - $note_html .= ' – <a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . __( 'Delete this donation note.', 'give' ) . '">' . __( 'Delete', 'give' ) . '</a>'; |
|
| 1561 | + $note_html .= ' – <a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.__('Delete this donation note.', 'give').'">'.__('Delete', 'give').'</a>'; |
|
| 1564 | 1562 | $note_html .= '</p>'; |
| 1565 | 1563 | $note_html .= '</div>'; |
| 1566 | 1564 | |
@@ -1578,18 +1576,18 @@ discard block |
||
| 1578 | 1576 | * |
| 1579 | 1577 | * @return void |
| 1580 | 1578 | */ |
| 1581 | -function give_hide_payment_notes( $query ) { |
|
| 1582 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) { |
|
| 1583 | - $types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array(); |
|
| 1584 | - if ( ! is_array( $types ) ) { |
|
| 1585 | - $types = array( $types ); |
|
| 1579 | +function give_hide_payment_notes($query) { |
|
| 1580 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) { |
|
| 1581 | + $types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array(); |
|
| 1582 | + if ( ! is_array($types)) { |
|
| 1583 | + $types = array($types); |
|
| 1586 | 1584 | } |
| 1587 | 1585 | $types[] = 'give_payment_note'; |
| 1588 | 1586 | $query->query_vars['type__not_in'] = $types; |
| 1589 | 1587 | } |
| 1590 | 1588 | } |
| 1591 | 1589 | |
| 1592 | -add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
| 1590 | +add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
| 1593 | 1591 | |
| 1594 | 1592 | /** |
| 1595 | 1593 | * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets |
@@ -1601,15 +1599,15 @@ discard block |
||
| 1601 | 1599 | * |
| 1602 | 1600 | * @return array $clauses Updated comment clauses. |
| 1603 | 1601 | */ |
| 1604 | -function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) { |
|
| 1605 | - if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) { |
|
| 1602 | +function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) { |
|
| 1603 | + if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) { |
|
| 1606 | 1604 | $clauses['where'] .= ' AND comment_type != "give_payment_note"'; |
| 1607 | 1605 | } |
| 1608 | 1606 | |
| 1609 | 1607 | return $clauses; |
| 1610 | 1608 | } |
| 1611 | 1609 | |
| 1612 | -add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
| 1610 | +add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
| 1613 | 1611 | |
| 1614 | 1612 | |
| 1615 | 1613 | /** |
@@ -1622,15 +1620,15 @@ discard block |
||
| 1622 | 1620 | * |
| 1623 | 1621 | * @return string $where |
| 1624 | 1622 | */ |
| 1625 | -function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) { |
|
| 1623 | +function give_hide_payment_notes_from_feeds($where, $wp_comment_query) { |
|
| 1626 | 1624 | global $wpdb; |
| 1627 | 1625 | |
| 1628 | - $where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' ); |
|
| 1626 | + $where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note'); |
|
| 1629 | 1627 | |
| 1630 | 1628 | return $where; |
| 1631 | 1629 | } |
| 1632 | 1630 | |
| 1633 | -add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 ); |
|
| 1631 | +add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2); |
|
| 1634 | 1632 | |
| 1635 | 1633 | |
| 1636 | 1634 | /** |
@@ -1644,32 +1642,32 @@ discard block |
||
| 1644 | 1642 | * |
| 1645 | 1643 | * @return array|object Array of comment counts. |
| 1646 | 1644 | */ |
| 1647 | -function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) { |
|
| 1645 | +function give_remove_payment_notes_in_comment_counts($stats, $post_id) { |
|
| 1648 | 1646 | global $wpdb, $pagenow; |
| 1649 | 1647 | |
| 1650 | - if ( 'index.php' != $pagenow ) { |
|
| 1648 | + if ('index.php' != $pagenow) { |
|
| 1651 | 1649 | return $stats; |
| 1652 | 1650 | } |
| 1653 | 1651 | |
| 1654 | 1652 | $post_id = (int) $post_id; |
| 1655 | 1653 | |
| 1656 | - if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) { |
|
| 1654 | + if (apply_filters('give_count_payment_notes_in_comments', false)) { |
|
| 1657 | 1655 | return $stats; |
| 1658 | 1656 | } |
| 1659 | 1657 | |
| 1660 | - $stats = Give_Cache::get_group( "comments-{$post_id}", 'counts' ); |
|
| 1658 | + $stats = Give_Cache::get_group("comments-{$post_id}", 'counts'); |
|
| 1661 | 1659 | |
| 1662 | - if ( ! is_null( $stats ) ) { |
|
| 1660 | + if ( ! is_null($stats)) { |
|
| 1663 | 1661 | return $stats; |
| 1664 | 1662 | } |
| 1665 | 1663 | |
| 1666 | 1664 | $where = 'WHERE comment_type != "give_payment_note"'; |
| 1667 | 1665 | |
| 1668 | - if ( $post_id > 0 ) { |
|
| 1669 | - $where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id ); |
|
| 1666 | + if ($post_id > 0) { |
|
| 1667 | + $where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id); |
|
| 1670 | 1668 | } |
| 1671 | 1669 | |
| 1672 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
| 1670 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
| 1673 | 1671 | |
| 1674 | 1672 | $total = 0; |
| 1675 | 1673 | $approved = array( |
@@ -1679,30 +1677,30 @@ discard block |
||
| 1679 | 1677 | 'trash' => 'trash', |
| 1680 | 1678 | 'post-trashed' => 'post-trashed', |
| 1681 | 1679 | ); |
| 1682 | - foreach ( (array) $count as $row ) { |
|
| 1680 | + foreach ((array) $count as $row) { |
|
| 1683 | 1681 | // Don't count post-trashed toward totals. |
| 1684 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) { |
|
| 1682 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) { |
|
| 1685 | 1683 | $total += $row['num_comments']; |
| 1686 | 1684 | } |
| 1687 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
| 1688 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
| 1685 | + if (isset($approved[$row['comment_approved']])) { |
|
| 1686 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
| 1689 | 1687 | } |
| 1690 | 1688 | } |
| 1691 | 1689 | |
| 1692 | 1690 | $stats['total_comments'] = $total; |
| 1693 | - foreach ( $approved as $key ) { |
|
| 1694 | - if ( empty( $stats[ $key ] ) ) { |
|
| 1695 | - $stats[ $key ] = 0; |
|
| 1691 | + foreach ($approved as $key) { |
|
| 1692 | + if (empty($stats[$key])) { |
|
| 1693 | + $stats[$key] = 0; |
|
| 1696 | 1694 | } |
| 1697 | 1695 | } |
| 1698 | 1696 | |
| 1699 | 1697 | $stats = (object) $stats; |
| 1700 | - Give_Cache::set_group( "comments-{$post_id}", $stats, 'counts' ); |
|
| 1698 | + Give_Cache::set_group("comments-{$post_id}", $stats, 'counts'); |
|
| 1701 | 1699 | |
| 1702 | 1700 | return $stats; |
| 1703 | 1701 | } |
| 1704 | 1702 | |
| 1705 | -add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 ); |
|
| 1703 | +add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2); |
|
| 1706 | 1704 | |
| 1707 | 1705 | |
| 1708 | 1706 | /** |
@@ -1715,9 +1713,9 @@ discard block |
||
| 1715 | 1713 | * |
| 1716 | 1714 | * @return string $where Modified where clause. |
| 1717 | 1715 | */ |
| 1718 | -function give_filter_where_older_than_week( $where = '' ) { |
|
| 1716 | +function give_filter_where_older_than_week($where = '') { |
|
| 1719 | 1717 | // Payments older than one week. |
| 1720 | - $start = date( 'Y-m-d', strtotime( '-7 days' ) ); |
|
| 1718 | + $start = date('Y-m-d', strtotime('-7 days')); |
|
| 1721 | 1719 | $where .= " AND post_date <= '{$start}'"; |
| 1722 | 1720 | |
| 1723 | 1721 | return $where; |
@@ -1737,13 +1735,13 @@ discard block |
||
| 1737 | 1735 | * |
| 1738 | 1736 | * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title. |
| 1739 | 1737 | */ |
| 1740 | -function give_get_donation_form_title( $donation, $args = array() ) { |
|
| 1738 | +function give_get_donation_form_title($donation, $args = array()) { |
|
| 1741 | 1739 | |
| 1742 | - if ( ! $donation instanceof Give_Payment ) { |
|
| 1743 | - $donation = new Give_Payment( $donation ); |
|
| 1740 | + if ( ! $donation instanceof Give_Payment) { |
|
| 1741 | + $donation = new Give_Payment($donation); |
|
| 1744 | 1742 | } |
| 1745 | 1743 | |
| 1746 | - if( ! $donation->ID ) { |
|
| 1744 | + if ( ! $donation->ID) { |
|
| 1747 | 1745 | return ''; |
| 1748 | 1746 | } |
| 1749 | 1747 | |
@@ -1752,7 +1750,7 @@ discard block |
||
| 1752 | 1750 | 'separator' => '', |
| 1753 | 1751 | ); |
| 1754 | 1752 | |
| 1755 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1753 | + $args = wp_parse_args($args, $defaults); |
|
| 1756 | 1754 | |
| 1757 | 1755 | $form_id = $donation->form_id; |
| 1758 | 1756 | $price_id = $donation->price_id; |
@@ -1773,39 +1771,39 @@ discard block |
||
| 1773 | 1771 | , false |
| 1774 | 1772 | ); |
| 1775 | 1773 | |
| 1776 | - $form_title_html = Give_Cache::get_db_query( $cache_key ); |
|
| 1774 | + $form_title_html = Give_Cache::get_db_query($cache_key); |
|
| 1777 | 1775 | |
| 1778 | - if ( is_null( $form_title_html ) ) { |
|
| 1779 | - if ( true === $only_level ) { |
|
| 1776 | + if (is_null($form_title_html)) { |
|
| 1777 | + if (true === $only_level) { |
|
| 1780 | 1778 | $form_title = ''; |
| 1781 | 1779 | } |
| 1782 | 1780 | |
| 1783 | 1781 | $form_title_html = $form_title; |
| 1784 | 1782 | |
| 1785 | - if ( 'custom' === $price_id ) { |
|
| 1783 | + if ('custom' === $price_id) { |
|
| 1786 | 1784 | |
| 1787 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 1788 | - $level_label = ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' ); |
|
| 1785 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
| 1786 | + $level_label = ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give'); |
|
| 1789 | 1787 | |
| 1790 | 1788 | // Show custom amount level only in backend otherwise hide it. |
| 1791 | - if( 'set' === give_get_meta( $form_id, '_give_price_option', true ) && ! is_admin() ) { |
|
| 1789 | + if ('set' === give_get_meta($form_id, '_give_price_option', true) && ! is_admin()) { |
|
| 1792 | 1790 | $level_label = ''; |
| 1793 | 1791 | } |
| 1794 | 1792 | |
| 1795 | - } elseif ( give_has_variable_prices( $form_id ) ) { |
|
| 1796 | - $level_label = give_get_price_option_name( $form_id, $price_id, $donation->ID, false ); |
|
| 1793 | + } elseif (give_has_variable_prices($form_id)) { |
|
| 1794 | + $level_label = give_get_price_option_name($form_id, $price_id, $donation->ID, false); |
|
| 1797 | 1795 | } |
| 1798 | 1796 | |
| 1799 | 1797 | // Only add separator if there is a form title. |
| 1800 | 1798 | if ( |
| 1801 | - ! empty( $form_title_html ) && |
|
| 1802 | - ! empty( $level_label ) |
|
| 1799 | + ! empty($form_title_html) && |
|
| 1800 | + ! empty($level_label) |
|
| 1803 | 1801 | ) { |
| 1804 | 1802 | $form_title_html .= " {$separator} "; |
| 1805 | 1803 | } |
| 1806 | 1804 | |
| 1807 | 1805 | $form_title_html .= "<span class=\"donation-level-text-wrap\">{$level_label}</span>"; |
| 1808 | - Give_Cache::set_db_query( $cache_key, $form_title_html ); |
|
| 1806 | + Give_Cache::set_db_query($cache_key, $form_title_html); |
|
| 1809 | 1807 | } |
| 1810 | 1808 | |
| 1811 | 1809 | /** |
@@ -1813,7 +1811,7 @@ discard block |
||
| 1813 | 1811 | * |
| 1814 | 1812 | * @since 1.0 |
| 1815 | 1813 | */ |
| 1816 | - return apply_filters( 'give_get_donation_form_title', $form_title_html, $donation->payment_meta, $donation ); |
|
| 1814 | + return apply_filters('give_get_donation_form_title', $form_title_html, $donation->payment_meta, $donation); |
|
| 1817 | 1815 | } |
| 1818 | 1816 | |
| 1819 | 1817 | /** |
@@ -1826,19 +1824,19 @@ discard block |
||
| 1826 | 1824 | * |
| 1827 | 1825 | * @return string $price_id |
| 1828 | 1826 | */ |
| 1829 | -function give_get_price_id( $form_id, $price ) { |
|
| 1827 | +function give_get_price_id($form_id, $price) { |
|
| 1830 | 1828 | $price_id = null; |
| 1831 | 1829 | |
| 1832 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 1830 | + if (give_has_variable_prices($form_id)) { |
|
| 1833 | 1831 | |
| 1834 | - $levels = give_get_meta( $form_id, '_give_donation_levels', true ); |
|
| 1832 | + $levels = give_get_meta($form_id, '_give_donation_levels', true); |
|
| 1835 | 1833 | |
| 1836 | - foreach ( $levels as $level ) { |
|
| 1834 | + foreach ($levels as $level) { |
|
| 1837 | 1835 | |
| 1838 | - $level_amount = give_maybe_sanitize_amount( $level['_give_amount'] ); |
|
| 1836 | + $level_amount = give_maybe_sanitize_amount($level['_give_amount']); |
|
| 1839 | 1837 | |
| 1840 | 1838 | // Check that this indeed the recurring price. |
| 1841 | - if ( $level_amount == $price ) { |
|
| 1839 | + if ($level_amount == $price) { |
|
| 1842 | 1840 | |
| 1843 | 1841 | $price_id = $level['_give_id']['level_id']; |
| 1844 | 1842 | break; |
@@ -1846,13 +1844,13 @@ discard block |
||
| 1846 | 1844 | } |
| 1847 | 1845 | } |
| 1848 | 1846 | |
| 1849 | - if ( is_null( $price_id ) && give_is_custom_price_mode( $form_id ) ) { |
|
| 1847 | + if (is_null($price_id) && give_is_custom_price_mode($form_id)) { |
|
| 1850 | 1848 | $price_id = 'custom'; |
| 1851 | 1849 | } |
| 1852 | 1850 | } |
| 1853 | 1851 | |
| 1854 | 1852 | // Price ID must be numeric or string. |
| 1855 | - $price_id = ! is_numeric( $price_id ) && ! is_string( $price_id ) ? 0 : $price_id; |
|
| 1853 | + $price_id = ! is_numeric($price_id) && ! is_string($price_id) ? 0 : $price_id; |
|
| 1856 | 1854 | |
| 1857 | 1855 | /** |
| 1858 | 1856 | * Filter the price id |
@@ -1862,7 +1860,7 @@ discard block |
||
| 1862 | 1860 | * @param string $price_id |
| 1863 | 1861 | * @param int $form_id |
| 1864 | 1862 | */ |
| 1865 | - return apply_filters( 'give_get_price_id', $price_id, $form_id ); |
|
| 1863 | + return apply_filters('give_get_price_id', $price_id, $form_id); |
|
| 1866 | 1864 | } |
| 1867 | 1865 | |
| 1868 | 1866 | /** |
@@ -1878,10 +1876,10 @@ discard block |
||
| 1878 | 1876 | * |
| 1879 | 1877 | * @return string |
| 1880 | 1878 | */ |
| 1881 | -function give_get_form_dropdown( $args = array(), $echo = false ) { |
|
| 1882 | - $form_dropdown_html = Give()->html->forms_dropdown( $args ); |
|
| 1879 | +function give_get_form_dropdown($args = array(), $echo = false) { |
|
| 1880 | + $form_dropdown_html = Give()->html->forms_dropdown($args); |
|
| 1883 | 1881 | |
| 1884 | - if ( ! $echo ) { |
|
| 1882 | + if ( ! $echo) { |
|
| 1885 | 1883 | return $form_dropdown_html; |
| 1886 | 1884 | } |
| 1887 | 1885 | |
@@ -1898,17 +1896,17 @@ discard block |
||
| 1898 | 1896 | * |
| 1899 | 1897 | * @return string|bool |
| 1900 | 1898 | */ |
| 1901 | -function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) { |
|
| 1899 | +function give_get_form_variable_price_dropdown($args = array(), $echo = false) { |
|
| 1902 | 1900 | |
| 1903 | 1901 | // Check for give form id. |
| 1904 | - if ( empty( $args['id'] ) ) { |
|
| 1902 | + if (empty($args['id'])) { |
|
| 1905 | 1903 | return false; |
| 1906 | 1904 | } |
| 1907 | 1905 | |
| 1908 | - $form = new Give_Donate_Form( $args['id'] ); |
|
| 1906 | + $form = new Give_Donate_Form($args['id']); |
|
| 1909 | 1907 | |
| 1910 | 1908 | // Check if form has variable prices or not. |
| 1911 | - if ( ! $form->ID || ! $form->has_variable_prices() ) { |
|
| 1909 | + if ( ! $form->ID || ! $form->has_variable_prices()) { |
|
| 1912 | 1910 | return false; |
| 1913 | 1911 | } |
| 1914 | 1912 | |
@@ -1916,24 +1914,24 @@ discard block |
||
| 1916 | 1914 | $variable_price_options = array(); |
| 1917 | 1915 | |
| 1918 | 1916 | // Check if multi donation form support custom donation or not. |
| 1919 | - if ( $form->is_custom_price_mode() ) { |
|
| 1920 | - $variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' ); |
|
| 1917 | + if ($form->is_custom_price_mode()) { |
|
| 1918 | + $variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give'); |
|
| 1921 | 1919 | } |
| 1922 | 1920 | |
| 1923 | 1921 | // Get variable price and ID from variable price array. |
| 1924 | - foreach ( $variable_prices as $variable_price ) { |
|
| 1925 | - $variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) ) ); |
|
| 1922 | + foreach ($variable_prices as $variable_price) { |
|
| 1923 | + $variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount'], array('sanitize' => false))); |
|
| 1926 | 1924 | } |
| 1927 | 1925 | |
| 1928 | 1926 | // Update options. |
| 1929 | - $args = array_merge( $args, array( |
|
| 1927 | + $args = array_merge($args, array( |
|
| 1930 | 1928 | 'options' => $variable_price_options, |
| 1931 | - ) ); |
|
| 1929 | + )); |
|
| 1932 | 1930 | |
| 1933 | 1931 | // Generate select html. |
| 1934 | - $form_dropdown_html = Give()->html->select( $args ); |
|
| 1932 | + $form_dropdown_html = Give()->html->select($args); |
|
| 1935 | 1933 | |
| 1936 | - if ( ! $echo ) { |
|
| 1934 | + if ( ! $echo) { |
|
| 1937 | 1935 | return $form_dropdown_html; |
| 1938 | 1936 | } |
| 1939 | 1937 | |
@@ -1952,14 +1950,14 @@ discard block |
||
| 1952 | 1950 | * |
| 1953 | 1951 | * @return string |
| 1954 | 1952 | */ |
| 1955 | -function give_get_payment_meta_price_id( $payment_meta ) { |
|
| 1953 | +function give_get_payment_meta_price_id($payment_meta) { |
|
| 1956 | 1954 | |
| 1957 | - if ( isset( $payment_meta['give_price_id'] ) ) { |
|
| 1955 | + if (isset($payment_meta['give_price_id'])) { |
|
| 1958 | 1956 | $price_id = $payment_meta['give_price_id']; |
| 1959 | - } elseif ( isset( $payment_meta['price_id'] ) ) { |
|
| 1957 | + } elseif (isset($payment_meta['price_id'])) { |
|
| 1960 | 1958 | $price_id = $payment_meta['price_id']; |
| 1961 | 1959 | } else { |
| 1962 | - $price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] ); |
|
| 1960 | + $price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']); |
|
| 1963 | 1961 | } |
| 1964 | 1962 | |
| 1965 | 1963 | /** |
@@ -1970,6 +1968,6 @@ discard block |
||
| 1970 | 1968 | * @param string $price_id |
| 1971 | 1969 | * @param array $payment_meta |
| 1972 | 1970 | */ |
| 1973 | - return apply_filters( 'give_get_payment_meta_price_id', $price_id, $payment_meta ); |
|
| 1971 | + return apply_filters('give_get_payment_meta_price_id', $price_id, $payment_meta); |
|
| 1974 | 1972 | |
| 1975 | 1973 | } |
@@ -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 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | /* @var WPDB $wpdb */ |
| 51 | 51 | global $wpdb; |
| 52 | 52 | |
| 53 | - $wpdb->formmeta = $this->table_name = $wpdb->prefix . 'give_formmeta'; |
|
| 53 | + $wpdb->formmeta = $this->table_name = $wpdb->prefix.'give_formmeta'; |
|
| 54 | 54 | $this->primary_key = 'meta_id'; |
| 55 | 55 | $this->version = '1.0'; |
| 56 | 56 | |
@@ -84,6 +84,6 @@ discard block |
||
| 84 | 84 | * @return bool |
| 85 | 85 | */ |
| 86 | 86 | protected function is_custom_meta_table_active() { |
| 87 | - return give_has_upgrade_completed( 'v20_move_metadata_into_new_table' ); |
|
| 87 | + return give_has_upgrade_completed('v20_move_metadata_into_new_table'); |
|
| 88 | 88 | } |
| 89 | 89 | } |
@@ -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_Logs' ) ) : |
|
| 16 | +if ( ! class_exists('Give_Settings_Logs')) : |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Give_Settings_Logs. |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function __construct() { |
| 36 | 36 | $this->id = 'logs'; |
| 37 | - $this->label = __( 'Logs', 'give' ); |
|
| 37 | + $this->label = __('Logs', 'give'); |
|
| 38 | 38 | |
| 39 | 39 | $this->default_tab = 'sales'; |
| 40 | 40 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function get_settings() { |
| 52 | 52 | // Get settings. |
| 53 | - $settings = apply_filters( 'give_settings_logs', array( |
|
| 53 | + $settings = apply_filters('give_settings_logs', array( |
|
| 54 | 54 | array( |
| 55 | 55 | 'id' => 'give_tools_logs', |
| 56 | 56 | 'type' => 'title', |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | ), |
| 59 | 59 | array( |
| 60 | 60 | 'id' => 'logs', |
| 61 | - 'name' => __( 'Log', 'give' ), |
|
| 61 | + 'name' => __('Log', 'give'), |
|
| 62 | 62 | 'type' => 'logs', |
| 63 | 63 | |
| 64 | 64 | ), |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | 'type' => 'sectionend', |
| 68 | 68 | 'table_html' => false, |
| 69 | 69 | ), |
| 70 | - ) ); |
|
| 70 | + )); |
|
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | 73 | * Filter the settings. |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @param array $settings |
| 78 | 78 | */ |
| 79 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
| 79 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
| 80 | 80 | |
| 81 | 81 | // Output. |
| 82 | 82 | return $settings; |
@@ -90,15 +90,15 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function get_sections() { |
| 92 | 92 | $sections = array( |
| 93 | - 'sales' => __( 'Donations', 'give' ), |
|
| 94 | - 'gateway_errors' => __( 'Payment Errors', 'give' ), |
|
| 95 | - 'api_requests' => __( 'API Requests', 'give' ), |
|
| 96 | - 'updates' => __( 'Updates', 'give' ), |
|
| 93 | + 'sales' => __('Donations', 'give'), |
|
| 94 | + 'gateway_errors' => __('Payment Errors', 'give'), |
|
| 95 | + 'api_requests' => __('API Requests', 'give'), |
|
| 96 | + 'updates' => __('Updates', 'give'), |
|
| 97 | 97 | ); |
| 98 | 98 | |
| 99 | - $sections = apply_filters( 'give_log_views', $sections ); |
|
| 99 | + $sections = apply_filters('give_log_views', $sections); |
|
| 100 | 100 | |
| 101 | - return apply_filters( 'give_get_sections_' . $this->id, $sections ); |
|
| 101 | + return apply_filters('give_get_sections_'.$this->id, $sections); |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
@@ -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 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | function give_get_logs_tab() { |
| 24 | 24 | |
| 25 | - require( GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/logs.php' ); |
|
| 25 | + require(GIVE_PLUGIN_DIR.'includes/admin/tools/logs/logs.php'); |
|
| 26 | 26 | |
| 27 | 27 | // Get current section. |
| 28 | 28 | $current_section = $_GET['section'] = give_get_current_setting_section(); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @since 1.0 |
| 34 | 34 | */ |
| 35 | - do_action( "give_logs_view_{$current_section}" ); |
|
| 35 | + do_action("give_logs_view_{$current_section}"); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | function give_logs_view_sales() { |
| 48 | 48 | |
| 49 | - include GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/class-sales-logs-list-table.php'; |
|
| 49 | + include GIVE_PLUGIN_DIR.'includes/admin/tools/logs/class-sales-logs-list-table.php'; |
|
| 50 | 50 | |
| 51 | 51 | $logs_table = new Give_Sales_Log_Table(); |
| 52 | 52 | $logs_table->prepare_items(); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @since 1.8.12 |
| 61 | 61 | */ |
| 62 | - do_action( 'give_logs_donations_top' ); |
|
| 62 | + do_action('give_logs_donations_top'); |
|
| 63 | 63 | |
| 64 | 64 | $logs_table->display(); ?> |
| 65 | 65 | <input type="hidden" name="post_type" value="give_forms"/> |
@@ -73,14 +73,14 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @since 1.8.12 |
| 75 | 75 | */ |
| 76 | - do_action( 'give_logs_donations_bottom' ); |
|
| 76 | + do_action('give_logs_donations_bottom'); |
|
| 77 | 77 | ?> |
| 78 | 78 | |
| 79 | 79 | </div> |
| 80 | 80 | <?php |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | -add_action( 'give_logs_view_sales', 'give_logs_view_sales' ); |
|
| 83 | +add_action('give_logs_view_sales', 'give_logs_view_sales'); |
|
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | 86 | * Update Logs |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @return void |
| 91 | 91 | */ |
| 92 | 92 | function give_logs_view_updates() { |
| 93 | - include( GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/class-update-logs-list-table.php' ); |
|
| 93 | + include(GIVE_PLUGIN_DIR.'includes/admin/tools/logs/class-update-logs-list-table.php'); |
|
| 94 | 94 | |
| 95 | 95 | $logs_table = new Give_Update_Log_Table(); |
| 96 | 96 | $logs_table->prepare_items(); |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @since 2.0.1 |
| 105 | 105 | */ |
| 106 | - do_action( 'give_logs_update_top' ); |
|
| 106 | + do_action('give_logs_update_top'); |
|
| 107 | 107 | |
| 108 | 108 | $logs_table->display(); ?> |
| 109 | 109 | <input type="hidden" name="post_type" value="give_forms"/> |
@@ -117,14 +117,14 @@ discard block |
||
| 117 | 117 | * |
| 118 | 118 | * @since 2.0.1 |
| 119 | 119 | */ |
| 120 | - do_action( 'give_logs_update_bottom' ); |
|
| 120 | + do_action('give_logs_update_bottom'); |
|
| 121 | 121 | ?> |
| 122 | 122 | |
| 123 | 123 | </div> |
| 124 | 124 | <?php |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | -add_action( 'give_logs_view_updates', 'give_logs_view_updates' ); |
|
| 127 | +add_action('give_logs_view_updates', 'give_logs_view_updates'); |
|
| 128 | 128 | |
| 129 | 129 | /** |
| 130 | 130 | * Gateway Error Logs |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * @return void |
| 136 | 136 | */ |
| 137 | 137 | function give_logs_view_gateway_errors() { |
| 138 | - include( GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/class-gateway-error-logs-list-table.php' ); |
|
| 138 | + include(GIVE_PLUGIN_DIR.'includes/admin/tools/logs/class-gateway-error-logs-list-table.php'); |
|
| 139 | 139 | |
| 140 | 140 | $logs_table = new Give_Gateway_Error_Log_Table(); |
| 141 | 141 | $logs_table->prepare_items(); |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @since 1.8.12 |
| 150 | 150 | */ |
| 151 | - do_action( 'give_logs_payment_error_top' ); |
|
| 151 | + do_action('give_logs_payment_error_top'); |
|
| 152 | 152 | |
| 153 | 153 | $logs_table->display(); ?> |
| 154 | 154 | <input type="hidden" name="post_type" value="give_forms"/> |
@@ -162,14 +162,14 @@ discard block |
||
| 162 | 162 | * |
| 163 | 163 | * @since 1.8.12 |
| 164 | 164 | */ |
| 165 | - do_action( 'give_logs_payment_error_bottom' ); |
|
| 165 | + do_action('give_logs_payment_error_bottom'); |
|
| 166 | 166 | ?> |
| 167 | 167 | |
| 168 | 168 | </div> |
| 169 | 169 | <?php |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | -add_action( 'give_logs_view_gateway_errors', 'give_logs_view_gateway_errors' ); |
|
| 172 | +add_action('give_logs_view_gateway_errors', 'give_logs_view_gateway_errors'); |
|
| 173 | 173 | |
| 174 | 174 | /** |
| 175 | 175 | * API Request Logs |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * @return void |
| 181 | 181 | */ |
| 182 | 182 | function give_logs_view_api_requests() { |
| 183 | - include( GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/class-api-requests-logs-list-table.php' ); |
|
| 183 | + include(GIVE_PLUGIN_DIR.'includes/admin/tools/logs/class-api-requests-logs-list-table.php'); |
|
| 184 | 184 | |
| 185 | 185 | $logs_table = new Give_API_Request_Log_Table(); |
| 186 | 186 | $logs_table->prepare_items(); |
@@ -190,9 +190,9 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @since 1.0 |
| 192 | 192 | */ |
| 193 | - do_action( 'give_logs_api_requests_top' ); |
|
| 193 | + do_action('give_logs_api_requests_top'); |
|
| 194 | 194 | |
| 195 | - $logs_table->search_box( esc_html__( 'Search', 'give' ), 'give-api-requests' ); |
|
| 195 | + $logs_table->search_box(esc_html__('Search', 'give'), 'give-api-requests'); |
|
| 196 | 196 | $logs_table->display(); |
| 197 | 197 | ?> |
| 198 | 198 | <input type="hidden" name="post_type" value="give_forms"/> |
@@ -206,9 +206,9 @@ discard block |
||
| 206 | 206 | * |
| 207 | 207 | * @since 1.0 |
| 208 | 208 | */ |
| 209 | - do_action( 'give_logs_api_requests_bottom' ); |
|
| 209 | + do_action('give_logs_api_requests_bottom'); |
|
| 210 | 210 | } |
| 211 | -add_action( 'give_logs_view_api_requests', 'give_logs_view_api_requests' ); |
|
| 211 | +add_action('give_logs_view_api_requests', 'give_logs_view_api_requests'); |
|
| 212 | 212 | |
| 213 | 213 | /** |
| 214 | 214 | * Renders the log views drop down. |
@@ -220,11 +220,11 @@ discard block |
||
| 220 | 220 | $current_section = give_get_current_setting_section(); |
| 221 | 221 | |
| 222 | 222 | // If there are not any event attach to action then do not show form. |
| 223 | - if ( ! has_action( 'give_log_view_actions' ) ) { |
|
| 223 | + if ( ! has_action('give_log_view_actions')) { |
|
| 224 | 224 | return; |
| 225 | 225 | } |
| 226 | 226 | ?> |
| 227 | - <form id="give-logs-filter" method="get" action="<?php echo 'edit.php?post_type=give_forms&page=give-tools&tab=logs§ion=' . $current_section; ?>"> |
|
| 227 | + <form id="give-logs-filter" method="get" action="<?php echo 'edit.php?post_type=give_forms&page=give-tools&tab=logs§ion='.$current_section; ?>"> |
|
| 228 | 228 | <?php |
| 229 | 229 | /** |
| 230 | 230 | * Fires after displaying the reports page views drop down. |
@@ -233,14 +233,14 @@ discard block |
||
| 233 | 233 | * |
| 234 | 234 | * @since 1.0 |
| 235 | 235 | */ |
| 236 | - do_action( 'give_log_view_actions' ); |
|
| 236 | + do_action('give_log_view_actions'); |
|
| 237 | 237 | ?> |
| 238 | 238 | |
| 239 | 239 | <input type="hidden" name="post_type" value="give_forms"/> |
| 240 | 240 | <input type="hidden" name="page" value="give-tools"/> |
| 241 | 241 | <input type="hidden" name="tab" value="logs"/> |
| 242 | 242 | |
| 243 | - <?php submit_button( esc_html__( 'Apply', 'give' ), 'secondary', 'submit', false ); ?> |
|
| 243 | + <?php submit_button(esc_html__('Apply', 'give'), 'secondary', 'submit', false); ?> |
|
| 244 | 244 | </form> |
| 245 | 245 | <?php |
| 246 | 246 | } |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | * |
| 253 | 253 | * @return string |
| 254 | 254 | */ |
| 255 | -function give_tools_set_form_method( $method ) { |
|
| 255 | +function give_tools_set_form_method($method) { |
|
| 256 | 256 | return 'get'; |
| 257 | 257 | } |
| 258 | -add_filter( 'give-tools_form_method_tab_logs', 'give_tools_set_form_method', 10 ); |
|
| 258 | +add_filter('give-tools_form_method_tab_logs', 'give_tools_set_form_method', 10); |
|