@@ -9,13 +9,13 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | // Exit if accessed directly. |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | // Load WP_List_Table if not loaded. |
| 17 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
| 18 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
| 17 | +if ( ! class_exists('WP_List_Table')) { |
|
| 18 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -44,11 +44,11 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function __construct() { |
| 46 | 46 | // Set parent defaults. |
| 47 | - parent::__construct( array( |
|
| 48 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
| 49 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
| 47 | + parent::__construct(array( |
|
| 48 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records. |
|
| 49 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records. |
|
| 50 | 50 | 'ajax' => false // Does this table support ajax?. |
| 51 | - ) ); |
|
| 51 | + )); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -62,19 +62,19 @@ discard block |
||
| 62 | 62 | * |
| 63 | 63 | * @return string Column Name. |
| 64 | 64 | */ |
| 65 | - public function column_default( $item, $column_name ) { |
|
| 65 | + public function column_default($item, $column_name) { |
|
| 66 | 66 | |
| 67 | - switch ( $column_name ) { |
|
| 67 | + switch ($column_name) { |
|
| 68 | 68 | case 'ID' : |
| 69 | 69 | return $item['ID_label']; |
| 70 | 70 | case 'payment_id' : |
| 71 | - return empty( $item->payment_id ) ? esc_html__( 'n/a', 'give' ) : $item->payment_id; |
|
| 71 | + return empty($item->payment_id) ? esc_html__('n/a', 'give') : $item->payment_id; |
|
| 72 | 72 | case 'gateway' : |
| 73 | - return empty( $item->gateway ) ? esc_html__( 'n/a', 'give' ) : $item->gateway; |
|
| 73 | + return empty($item->gateway) ? esc_html__('n/a', 'give') : $item->gateway; |
|
| 74 | 74 | case 'error' : |
| 75 | - return get_the_title( $item['ID'] ) ? get_the_title( $item['ID'] ) : esc_html__( 'Payment Error', 'give' ); |
|
| 75 | + return get_the_title($item['ID']) ? get_the_title($item['ID']) : esc_html__('Payment Error', 'give'); |
|
| 76 | 76 | default: |
| 77 | - return $item[ $column_name ]; |
|
| 77 | + return $item[$column_name]; |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
@@ -88,27 +88,27 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @return void |
| 90 | 90 | */ |
| 91 | - public function column_message( $item ) { ?> |
|
| 92 | - <a href="#TB_inline?width=640&inlineId=log-message-<?php echo $item['ID']; ?>" class="thickbox give-error-log-details-link button button-small" data-tooltip="<?php esc_attr_e( 'View Log Message', 'give' ); ?>"><span class="dashicons dashicons-visibility"></span></a> |
|
| 91 | + public function column_message($item) { ?> |
|
| 92 | + <a href="#TB_inline?width=640&inlineId=log-message-<?php echo $item['ID']; ?>" class="thickbox give-error-log-details-link button button-small" data-tooltip="<?php esc_attr_e('View Log Message', 'give'); ?>"><span class="dashicons dashicons-visibility"></span></a> |
|
| 93 | 93 | <div id="log-message-<?php echo $item['ID']; ?>" style="display:none;"> |
| 94 | 94 | <?php |
| 95 | 95 | |
| 96 | - $log_message = get_post_field( 'post_content', $item['ID'] ); |
|
| 96 | + $log_message = get_post_field('post_content', $item['ID']); |
|
| 97 | 97 | |
| 98 | - $serialized = strpos( $log_message, '{"' ); |
|
| 98 | + $serialized = strpos($log_message, '{"'); |
|
| 99 | 99 | |
| 100 | 100 | // Check to see if the log message contains serialized information |
| 101 | - if ( $serialized !== false ) { |
|
| 102 | - $length = strlen( $log_message ) - $serialized; |
|
| 103 | - $intro = substr( $log_message, 0, - $length ); |
|
| 104 | - $data = substr( $log_message, $serialized, strlen( $log_message ) - 1 ); |
|
| 101 | + if ($serialized !== false) { |
|
| 102 | + $length = strlen($log_message) - $serialized; |
|
| 103 | + $intro = substr($log_message, 0, - $length); |
|
| 104 | + $data = substr($log_message, $serialized, strlen($log_message) - 1); |
|
| 105 | 105 | |
| 106 | - echo wpautop( $intro ); |
|
| 107 | - echo wpautop( '<strong>' . esc_html__( 'Log data:', 'give' ) . '</strong>' ); |
|
| 108 | - echo '<div style="word-wrap: break-word;">' . wpautop( $data ) . '</div>'; |
|
| 106 | + echo wpautop($intro); |
|
| 107 | + echo wpautop('<strong>'.esc_html__('Log data:', 'give').'</strong>'); |
|
| 108 | + echo '<div style="word-wrap: break-word;">'.wpautop($data).'</div>'; |
|
| 109 | 109 | } else { |
| 110 | 110 | // No serialized data found |
| 111 | - echo wpautop( $log_message ); |
|
| 111 | + echo wpautop($log_message); |
|
| 112 | 112 | } |
| 113 | 113 | ?> |
| 114 | 114 | </div> |
@@ -124,12 +124,12 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | public function get_columns() { |
| 126 | 126 | $columns = array( |
| 127 | - 'ID' => esc_html__( 'Log ID', 'give' ), |
|
| 128 | - 'error' => esc_html__( 'Error', 'give' ), |
|
| 129 | - 'gateway' => esc_html__( 'Gateway', 'give' ), |
|
| 130 | - 'payment_id' => esc_html__( 'Donation ID', 'give' ), |
|
| 131 | - 'date' => esc_html__( 'Date', 'give' ), |
|
| 132 | - 'message' => esc_html__( 'Details', 'give' ) |
|
| 127 | + 'ID' => esc_html__('Log ID', 'give'), |
|
| 128 | + 'error' => esc_html__('Error', 'give'), |
|
| 129 | + 'gateway' => esc_html__('Gateway', 'give'), |
|
| 130 | + 'payment_id' => esc_html__('Donation ID', 'give'), |
|
| 131 | + 'date' => esc_html__('Date', 'give'), |
|
| 132 | + 'message' => esc_html__('Details', 'give') |
|
| 133 | 133 | ); |
| 134 | 134 | |
| 135 | 135 | return $columns; |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * @return int Current page number |
| 144 | 144 | */ |
| 145 | 145 | public function get_paged() { |
| 146 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
| 146 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * @since 1.0 |
| 154 | 154 | * @return void |
| 155 | 155 | */ |
| 156 | - public function bulk_actions( $which = '' ) { |
|
| 156 | + public function bulk_actions($which = '') { |
|
| 157 | 157 | give_log_views(); |
| 158 | 158 | } |
| 159 | 159 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | // Prevent the queries from getting cached. |
| 173 | 173 | // Without this there are occasional memory issues for some installs. |
| 174 | - wp_suspend_cache_addition( true ); |
|
| 174 | + wp_suspend_cache_addition(true); |
|
| 175 | 175 | |
| 176 | 176 | $logs_data = array(); |
| 177 | 177 | $paged = $this->get_paged(); |
@@ -180,17 +180,17 @@ discard block |
||
| 180 | 180 | 'paged' => $paged |
| 181 | 181 | ); |
| 182 | 182 | |
| 183 | - $logs = $give_logs->get_connected_logs( $log_query ); |
|
| 183 | + $logs = $give_logs->get_connected_logs($log_query); |
|
| 184 | 184 | |
| 185 | - if ( $logs ) { |
|
| 186 | - foreach ( $logs as $log ) { |
|
| 185 | + if ($logs) { |
|
| 186 | + foreach ($logs as $log) { |
|
| 187 | 187 | |
| 188 | 188 | $logs_data[] = array( |
| 189 | 189 | 'ID' => $log->ID, |
| 190 | - 'ID_label' => '<span class=\'give-item-label give-item-label-gray\'>' . $log->ID . '</span>', |
|
| 190 | + 'ID_label' => '<span class=\'give-item-label give-item-label-gray\'>'.$log->ID.'</span>', |
|
| 191 | 191 | 'payment_id' => $log->post_parent, |
| 192 | 192 | 'error' => 'error', |
| 193 | - 'gateway' => give_get_payment_gateway( $log->post_parent ), |
|
| 193 | + 'gateway' => give_get_payment_gateway($log->post_parent), |
|
| 194 | 194 | 'date' => $log->post_date |
| 195 | 195 | ); |
| 196 | 196 | } |
@@ -212,19 +212,19 @@ discard block |
||
| 212 | 212 | * |
| 213 | 213 | * @param string $which |
| 214 | 214 | */ |
| 215 | - protected function display_tablenav( $which ) { |
|
| 216 | - if ( 'top' === $which ) { |
|
| 217 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
| 215 | + protected function display_tablenav($which) { |
|
| 216 | + if ('top' === $which) { |
|
| 217 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
| 218 | 218 | } |
| 219 | 219 | ?> |
| 220 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
| 220 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
| 221 | 221 | |
| 222 | 222 | <div class="alignleft actions bulkactions"> |
| 223 | - <?php $this->bulk_actions( $which ); ?> |
|
| 223 | + <?php $this->bulk_actions($which); ?> |
|
| 224 | 224 | </div> |
| 225 | 225 | <?php |
| 226 | - $this->extra_tablenav( $which ); |
|
| 227 | - $this->pagination( $which ); |
|
| 226 | + $this->extra_tablenav($which); |
|
| 227 | + $this->pagination($which); |
|
| 228 | 228 | ?> |
| 229 | 229 | |
| 230 | 230 | <br class="clear"/> |
@@ -251,14 +251,14 @@ discard block |
||
| 251 | 251 | $columns = $this->get_columns(); |
| 252 | 252 | $hidden = array(); // No hidden columns |
| 253 | 253 | $sortable = $this->get_sortable_columns(); |
| 254 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
| 254 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
| 255 | 255 | $this->items = $this->get_logs(); |
| 256 | - $total_items = $give_logs->get_log_count( 0, 'gateway_error' ); |
|
| 256 | + $total_items = $give_logs->get_log_count(0, 'gateway_error'); |
|
| 257 | 257 | |
| 258 | - $this->set_pagination_args( array( |
|
| 258 | + $this->set_pagination_args(array( |
|
| 259 | 259 | 'total_items' => $total_items, |
| 260 | 260 | 'per_page' => $this->per_page, |
| 261 | - 'total_pages' => ceil( $total_items / $this->per_page ) |
|
| 261 | + 'total_pages' => ceil($total_items / $this->per_page) |
|
| 262 | 262 | ) |
| 263 | 263 | ); |
| 264 | 264 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -38,16 +38,16 @@ discard block |
||
| 38 | 38 | * @return void |
| 39 | 39 | */ |
| 40 | 40 | public function headers() { |
| 41 | - ignore_user_abort( true ); |
|
| 41 | + ignore_user_abort(true); |
|
| 42 | 42 | |
| 43 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 44 | - set_time_limit( 0 ); |
|
| 43 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
| 44 | + set_time_limit(0); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | nocache_headers(); |
| 48 | - header( 'Content-Type: text/csv; charset=utf-8' ); |
|
| 49 | - header( 'Content-Disposition: attachment; filename=' . apply_filters( 'give_earnings_export_filename', 'give-export-' . $this->export_type . '-' . date( 'n' ) . '-' . date( 'Y' ) ) . '.csv' ); |
|
| 50 | - header( "Expires: 0" ); |
|
| 48 | + header('Content-Type: text/csv; charset=utf-8'); |
|
| 49 | + header('Content-Disposition: attachment; filename='.apply_filters('give_earnings_export_filename', 'give-export-'.$this->export_type.'-'.date('n').'-'.date('Y')).'.csv'); |
|
| 50 | + header("Expires: 0"); |
|
| 51 | 51 | |
| 52 | 52 | } |
| 53 | 53 | |
@@ -61,10 +61,10 @@ discard block |
||
| 61 | 61 | public function csv_cols() { |
| 62 | 62 | |
| 63 | 63 | $cols = array( |
| 64 | - 'date' => esc_html__( 'Date', 'give' ), |
|
| 65 | - 'donations' => esc_html__( 'Donations', 'give' ), |
|
| 64 | + 'date' => esc_html__('Date', 'give'), |
|
| 65 | + 'donations' => esc_html__('Donations', 'give'), |
|
| 66 | 66 | /* translators: %s: currency */ |
| 67 | - 'earnings' => sprintf( esc_html__( 'Income (%s)', 'give' ), html_entity_decode( give_currency_filter( '' ) ) ) |
|
| 67 | + 'earnings' => sprintf(esc_html__('Income (%s)', 'give'), html_entity_decode(give_currency_filter(''))) |
|
| 68 | 68 | ); |
| 69 | 69 | |
| 70 | 70 | return $cols; |
@@ -79,28 +79,28 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public function get_data() { |
| 81 | 81 | |
| 82 | - $start_year = isset( $_POST['start_year'] ) ? absint( $_POST['start_year'] ) : date( 'Y' ); |
|
| 83 | - $end_year = isset( $_POST['end_year'] ) ? absint( $_POST['end_year'] ) : date( 'Y' ); |
|
| 84 | - $start_month = isset( $_POST['start_month'] ) ? absint( $_POST['start_month'] ) : date( 'n' ); |
|
| 85 | - $end_month = isset( $_POST['end_month'] ) ? absint( $_POST['end_month'] ) : date( 'n' ); |
|
| 82 | + $start_year = isset($_POST['start_year']) ? absint($_POST['start_year']) : date('Y'); |
|
| 83 | + $end_year = isset($_POST['end_year']) ? absint($_POST['end_year']) : date('Y'); |
|
| 84 | + $start_month = isset($_POST['start_month']) ? absint($_POST['start_month']) : date('n'); |
|
| 85 | + $end_month = isset($_POST['end_month']) ? absint($_POST['end_month']) : date('n'); |
|
| 86 | 86 | |
| 87 | 87 | $data = array(); |
| 88 | 88 | $year = $start_year; |
| 89 | 89 | $stats = new Give_Payment_Stats; |
| 90 | 90 | |
| 91 | - while ( $year <= $end_year ) { |
|
| 91 | + while ($year <= $end_year) { |
|
| 92 | 92 | |
| 93 | - if ( $year == $start_year && $year == $end_year ) { |
|
| 93 | + if ($year == $start_year && $year == $end_year) { |
|
| 94 | 94 | |
| 95 | 95 | $m1 = $start_month; |
| 96 | 96 | $m2 = $end_month; |
| 97 | 97 | |
| 98 | - } elseif ( $year == $start_year ) { |
|
| 98 | + } elseif ($year == $start_year) { |
|
| 99 | 99 | |
| 100 | 100 | $m1 = $start_month; |
| 101 | 101 | $m2 = 12; |
| 102 | 102 | |
| 103 | - } elseif ( $year == $end_year ) { |
|
| 103 | + } elseif ($year == $end_year) { |
|
| 104 | 104 | |
| 105 | 105 | $m1 = 1; |
| 106 | 106 | $m2 = $end_month; |
@@ -112,28 +112,28 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - while ( $m1 <= $m2 ) { |
|
| 115 | + while ($m1 <= $m2) { |
|
| 116 | 116 | |
| 117 | - $date1 = mktime( 0, 0, 0, $m1, 1, $year ); |
|
| 118 | - $date2 = mktime( 0, 0, 0, $m1, cal_days_in_month( CAL_GREGORIAN, $m1, $year ), $year ); |
|
| 117 | + $date1 = mktime(0, 0, 0, $m1, 1, $year); |
|
| 118 | + $date2 = mktime(0, 0, 0, $m1, cal_days_in_month(CAL_GREGORIAN, $m1, $year), $year); |
|
| 119 | 119 | |
| 120 | 120 | $data[] = array( |
| 121 | - 'date' => date_i18n( 'F Y', $date1 ), |
|
| 122 | - 'donations' => $stats->get_sales( 0, $date1, $date2 ), |
|
| 123 | - 'earnings' => give_format_amount( $stats->get_earnings( 0, $date1, $date2 ) ), |
|
| 121 | + 'date' => date_i18n('F Y', $date1), |
|
| 122 | + 'donations' => $stats->get_sales(0, $date1, $date2), |
|
| 123 | + 'earnings' => give_format_amount($stats->get_earnings(0, $date1, $date2)), |
|
| 124 | 124 | ); |
| 125 | 125 | |
| 126 | - $m1 ++; |
|
| 126 | + $m1++; |
|
| 127 | 127 | |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | |
| 131 | - $year ++; |
|
| 131 | + $year++; |
|
| 132 | 132 | |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
| 136 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
| 135 | + $data = apply_filters('give_export_get_data', $data); |
|
| 136 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
| 137 | 137 | |
| 138 | 138 | return $data; |
| 139 | 139 | } |
@@ -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 | |
@@ -24,51 +24,51 @@ discard block |
||
| 24 | 24 | function give_hide_subscription_notices() { |
| 25 | 25 | |
| 26 | 26 | // Hide subscription notices permanently. |
| 27 | - if ( ! empty( $_GET['_give_hide_license_notices_permanently'] ) ) { |
|
| 27 | + if ( ! empty($_GET['_give_hide_license_notices_permanently'])) { |
|
| 28 | 28 | global $current_user; |
| 29 | 29 | |
| 30 | 30 | // check previously disabled notice ids. |
| 31 | - $already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) ) |
|
| 31 | + $already_dismiss_notices = ($already_dismiss_notices = get_user_meta($current_user->ID, '_give_hide_license_notices_permanently', true)) |
|
| 32 | 32 | ? $already_dismiss_notices |
| 33 | 33 | : array(); |
| 34 | 34 | |
| 35 | 35 | // Get notice id. |
| 36 | - $notice_id = sanitize_text_field( $_GET['_give_hide_license_notices_permanently'] ); |
|
| 36 | + $notice_id = sanitize_text_field($_GET['_give_hide_license_notices_permanently']); |
|
| 37 | 37 | |
| 38 | - if( ! in_array( $notice_id, $already_dismiss_notices ) ) { |
|
| 38 | + if ( ! in_array($notice_id, $already_dismiss_notices)) { |
|
| 39 | 39 | $already_dismiss_notices[] = $notice_id; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | // Store subscription ids. |
| 43 | - update_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', $already_dismiss_notices ); |
|
| 43 | + update_user_meta($current_user->ID, '_give_hide_license_notices_permanently', $already_dismiss_notices); |
|
| 44 | 44 | |
| 45 | 45 | // Redirect user. |
| 46 | - wp_safe_redirect( remove_query_arg( '_give_hide_license_notices_permanently', $_SERVER['REQUEST_URI'] ) ); |
|
| 46 | + wp_safe_redirect(remove_query_arg('_give_hide_license_notices_permanently', $_SERVER['REQUEST_URI'])); |
|
| 47 | 47 | exit(); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // Hide subscription notices shortly. |
| 51 | - if ( ! empty( $_GET['_give_hide_license_notices_shortly'] ) ) { |
|
| 51 | + if ( ! empty($_GET['_give_hide_license_notices_shortly'])) { |
|
| 52 | 52 | global $current_user; |
| 53 | 53 | |
| 54 | 54 | // Get notice id. |
| 55 | - $notice_id = sanitize_text_field( $_GET['_give_hide_license_notices_shortly'] ); |
|
| 55 | + $notice_id = sanitize_text_field($_GET['_give_hide_license_notices_shortly']); |
|
| 56 | 56 | |
| 57 | 57 | // Transient key name. |
| 58 | 58 | $transient_key = "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}"; |
| 59 | 59 | |
| 60 | - if( get_transient( $transient_key ) ) { |
|
| 60 | + if (get_transient($transient_key)) { |
|
| 61 | 61 | return; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
| 65 | 65 | // Hide notice for 24 hours. |
| 66 | - set_transient( $transient_key, true, 24 * HOUR_IN_SECONDS ); |
|
| 66 | + set_transient($transient_key, true, 24 * HOUR_IN_SECONDS); |
|
| 67 | 67 | |
| 68 | 68 | // Redirect user. |
| 69 | - wp_safe_redirect( remove_query_arg( '_give_hide_license_notices_shortly', $_SERVER['REQUEST_URI'] ) ); |
|
| 69 | + wp_safe_redirect(remove_query_arg('_give_hide_license_notices_shortly', $_SERVER['REQUEST_URI'])); |
|
| 70 | 70 | exit(); |
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | -add_action( 'admin_init', 'give_hide_subscription_notices' ); |
|
| 75 | 74 | \ No newline at end of file |
| 75 | +add_action('admin_init', 'give_hide_subscription_notices'); |
|
| 76 | 76 | \ No newline at end of file |
@@ -23,52 +23,52 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | function give_hide_subscription_notices() { |
| 25 | 25 | |
| 26 | - // Hide subscription notices permanently. |
|
| 27 | - if ( ! empty( $_GET['_give_hide_license_notices_permanently'] ) ) { |
|
| 28 | - $current_user = wp_get_current_user(); |
|
| 26 | + // Hide subscription notices permanently. |
|
| 27 | + if ( ! empty( $_GET['_give_hide_license_notices_permanently'] ) ) { |
|
| 28 | + $current_user = wp_get_current_user(); |
|
| 29 | 29 | |
| 30 | - // check previously disabled notice ids. |
|
| 31 | - $already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) ) |
|
| 32 | - ? $already_dismiss_notices |
|
| 33 | - : array(); |
|
| 30 | + // check previously disabled notice ids. |
|
| 31 | + $already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) ) |
|
| 32 | + ? $already_dismiss_notices |
|
| 33 | + : array(); |
|
| 34 | 34 | |
| 35 | - // Get notice id. |
|
| 36 | - $notice_id = sanitize_text_field( $_GET['_give_hide_license_notices_permanently'] ); |
|
| 35 | + // Get notice id. |
|
| 36 | + $notice_id = sanitize_text_field( $_GET['_give_hide_license_notices_permanently'] ); |
|
| 37 | 37 | |
| 38 | - if( ! in_array( $notice_id, $already_dismiss_notices ) ) { |
|
| 39 | - $already_dismiss_notices[] = $notice_id; |
|
| 40 | - } |
|
| 38 | + if( ! in_array( $notice_id, $already_dismiss_notices ) ) { |
|
| 39 | + $already_dismiss_notices[] = $notice_id; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - // Store subscription ids. |
|
| 43 | - update_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', $already_dismiss_notices ); |
|
| 42 | + // Store subscription ids. |
|
| 43 | + update_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', $already_dismiss_notices ); |
|
| 44 | 44 | |
| 45 | - // Redirect user. |
|
| 46 | - wp_safe_redirect( remove_query_arg( '_give_hide_license_notices_permanently', $_SERVER['REQUEST_URI'] ) ); |
|
| 47 | - exit(); |
|
| 48 | - } |
|
| 45 | + // Redirect user. |
|
| 46 | + wp_safe_redirect( remove_query_arg( '_give_hide_license_notices_permanently', $_SERVER['REQUEST_URI'] ) ); |
|
| 47 | + exit(); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - // Hide subscription notices shortly. |
|
| 51 | - if ( ! empty( $_GET['_give_hide_license_notices_shortly'] ) ) { |
|
| 52 | - $current_user = wp_get_current_user(); |
|
| 50 | + // Hide subscription notices shortly. |
|
| 51 | + if ( ! empty( $_GET['_give_hide_license_notices_shortly'] ) ) { |
|
| 52 | + $current_user = wp_get_current_user(); |
|
| 53 | 53 | |
| 54 | - // Get notice id. |
|
| 55 | - $notice_id = sanitize_text_field( $_GET['_give_hide_license_notices_shortly'] ); |
|
| 54 | + // Get notice id. |
|
| 55 | + $notice_id = sanitize_text_field( $_GET['_give_hide_license_notices_shortly'] ); |
|
| 56 | 56 | |
| 57 | - // Transient key name. |
|
| 58 | - $transient_key = "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}"; |
|
| 57 | + // Transient key name. |
|
| 58 | + $transient_key = "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}"; |
|
| 59 | 59 | |
| 60 | - if( get_transient( $transient_key ) ) { |
|
| 61 | - return; |
|
| 62 | - } |
|
| 60 | + if( get_transient( $transient_key ) ) { |
|
| 61 | + return; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | 64 | |
| 65 | - // Hide notice for 24 hours. |
|
| 66 | - set_transient( $transient_key, true, 24 * HOUR_IN_SECONDS ); |
|
| 65 | + // Hide notice for 24 hours. |
|
| 66 | + set_transient( $transient_key, true, 24 * HOUR_IN_SECONDS ); |
|
| 67 | 67 | |
| 68 | - // Redirect user. |
|
| 69 | - wp_safe_redirect( remove_query_arg( '_give_hide_license_notices_shortly', $_SERVER['REQUEST_URI'] ) ); |
|
| 70 | - exit(); |
|
| 71 | - } |
|
| 68 | + // Redirect user. |
|
| 69 | + wp_safe_redirect( remove_query_arg( '_give_hide_license_notices_shortly', $_SERVER['REQUEST_URI'] ) ); |
|
| 70 | + exit(); |
|
| 71 | + } |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | add_action( 'admin_init', 'give_hide_subscription_notices' ); |
| 75 | 75 | \ No newline at end of file |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | * and redirect back to the donor interface for feedback |
| 544 | 544 | * |
| 545 | 545 | * @since 1.7 |
| 546 | - * @return void|bool |
|
| 546 | + * @return false|null |
|
| 547 | 547 | */ |
| 548 | 548 | function give_remove_donor_email() { |
| 549 | 549 | if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
@@ -583,7 +583,7 @@ discard block |
||
| 583 | 583 | * and redirect back to the donor interface for feedback |
| 584 | 584 | * |
| 585 | 585 | * @since 1.7 |
| 586 | - * @return void|bool |
|
| 586 | + * @return false|null |
|
| 587 | 587 | */ |
| 588 | 588 | function give_set_donor_primary_email() { |
| 589 | 589 | if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -23,15 +23,15 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return array $output Response messages |
| 25 | 25 | */ |
| 26 | -function give_edit_customer( $args ) { |
|
| 26 | +function give_edit_customer($args) { |
|
| 27 | 27 | |
| 28 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
| 28 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
| 29 | 29 | |
| 30 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
| 31 | - wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 30 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
| 31 | + wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - if ( empty( $args ) ) { |
|
| 34 | + if (empty($args)) { |
|
| 35 | 35 | return; |
| 36 | 36 | } |
| 37 | 37 | |
@@ -39,12 +39,12 @@ discard block |
||
| 39 | 39 | $customer_id = (int) $args['customerinfo']['id']; |
| 40 | 40 | $nonce = $args['_wpnonce']; |
| 41 | 41 | |
| 42 | - if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) { |
|
| 43 | - wp_die( esc_html__( 'Cheatin’ uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
| 42 | + if ( ! wp_verify_nonce($nonce, 'edit-customer')) { |
|
| 43 | + wp_die(esc_html__('Cheatin’ uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - $customer = new Give_Customer( $customer_id ); |
|
| 47 | - if ( empty( $customer->id ) ) { |
|
| 46 | + $customer = new Give_Customer($customer_id); |
|
| 47 | + if (empty($customer->id)) { |
|
| 48 | 48 | return false; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -53,19 +53,19 @@ discard block |
||
| 53 | 53 | 'user_id' => 0 |
| 54 | 54 | ); |
| 55 | 55 | |
| 56 | - $customer_info = wp_parse_args( $customer_info, $defaults ); |
|
| 56 | + $customer_info = wp_parse_args($customer_info, $defaults); |
|
| 57 | 57 | |
| 58 | - if ( (int) $customer_info['user_id'] != (int) $customer->user_id ) { |
|
| 58 | + if ((int) $customer_info['user_id'] != (int) $customer->user_id) { |
|
| 59 | 59 | |
| 60 | 60 | // Make sure we don't already have this user attached to a customer |
| 61 | - if ( ! empty( $customer_info['user_id'] ) && false !== Give()->customers->get_customer_by( 'user_id', $customer_info['user_id'] ) ) { |
|
| 62 | - give_set_error( 'give-invalid-customer-user_id', sprintf( esc_html__( 'The User ID %d is already associated with a different donor.', 'give' ), $customer_info['user_id'] ) ); |
|
| 61 | + if ( ! empty($customer_info['user_id']) && false !== Give()->customers->get_customer_by('user_id', $customer_info['user_id'])) { |
|
| 62 | + give_set_error('give-invalid-customer-user_id', sprintf(esc_html__('The User ID %d is already associated with a different donor.', 'give'), $customer_info['user_id'])); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // Make sure it's actually a user |
| 66 | - $user = get_user_by( 'id', $customer_info['user_id'] ); |
|
| 67 | - if ( ! empty( $customer_info['user_id'] ) && false === $user ) { |
|
| 68 | - give_set_error( 'give-invalid-user_id', sprintf( esc_html__( 'The User ID %d does not exist. Please assign an existing user.', 'give' ), $customer_info['user_id'] ) ); |
|
| 66 | + $user = get_user_by('id', $customer_info['user_id']); |
|
| 67 | + if ( ! empty($customer_info['user_id']) && false === $user) { |
|
| 68 | + give_set_error('give-invalid-user_id', sprintf(esc_html__('The User ID %d does not exist. Please assign an existing user.', 'give'), $customer_info['user_id'])); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | } |
@@ -73,52 +73,52 @@ discard block |
||
| 73 | 73 | // Record this for later |
| 74 | 74 | $previous_user_id = $customer->user_id; |
| 75 | 75 | |
| 76 | - if ( give_get_errors() ) { |
|
| 76 | + if (give_get_errors()) { |
|
| 77 | 77 | return; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // Setup the customer address, if present |
| 81 | 81 | $address = array(); |
| 82 | - if ( intval( $customer_info['user_id'] ) > 0 ) { |
|
| 82 | + if (intval($customer_info['user_id']) > 0) { |
|
| 83 | 83 | |
| 84 | - $current_address = get_user_meta( $customer_info['user_id'], '_give_user_address', true ); |
|
| 84 | + $current_address = get_user_meta($customer_info['user_id'], '_give_user_address', true); |
|
| 85 | 85 | |
| 86 | - if ( false === $current_address ) { |
|
| 87 | - $address['line1'] = isset( $customer_info['line1'] ) ? $customer_info['line1'] : ''; |
|
| 88 | - $address['line2'] = isset( $customer_info['line2'] ) ? $customer_info['line2'] : ''; |
|
| 89 | - $address['city'] = isset( $customer_info['city'] ) ? $customer_info['city'] : ''; |
|
| 90 | - $address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : ''; |
|
| 91 | - $address['zip'] = isset( $customer_info['zip'] ) ? $customer_info['zip'] : ''; |
|
| 92 | - $address['state'] = isset( $customer_info['state'] ) ? $customer_info['state'] : ''; |
|
| 86 | + if (false === $current_address) { |
|
| 87 | + $address['line1'] = isset($customer_info['line1']) ? $customer_info['line1'] : ''; |
|
| 88 | + $address['line2'] = isset($customer_info['line2']) ? $customer_info['line2'] : ''; |
|
| 89 | + $address['city'] = isset($customer_info['city']) ? $customer_info['city'] : ''; |
|
| 90 | + $address['country'] = isset($customer_info['country']) ? $customer_info['country'] : ''; |
|
| 91 | + $address['zip'] = isset($customer_info['zip']) ? $customer_info['zip'] : ''; |
|
| 92 | + $address['state'] = isset($customer_info['state']) ? $customer_info['state'] : ''; |
|
| 93 | 93 | } else { |
| 94 | - $current_address = wp_parse_args( $current_address, array( |
|
| 94 | + $current_address = wp_parse_args($current_address, array( |
|
| 95 | 95 | 'line1', |
| 96 | 96 | 'line2', |
| 97 | 97 | 'city', |
| 98 | 98 | 'zip', |
| 99 | 99 | 'state', |
| 100 | 100 | 'country' |
| 101 | - ) ); |
|
| 102 | - $address['line1'] = isset( $customer_info['line1'] ) ? $customer_info['line1'] : $current_address['line1']; |
|
| 103 | - $address['line2'] = isset( $customer_info['line2'] ) ? $customer_info['line2'] : $current_address['line2']; |
|
| 104 | - $address['city'] = isset( $customer_info['city'] ) ? $customer_info['city'] : $current_address['city']; |
|
| 105 | - $address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : $current_address['country']; |
|
| 106 | - $address['zip'] = isset( $customer_info['zip'] ) ? $customer_info['zip'] : $current_address['zip']; |
|
| 107 | - $address['state'] = isset( $customer_info['state'] ) ? $customer_info['state'] : $current_address['state']; |
|
| 101 | + )); |
|
| 102 | + $address['line1'] = isset($customer_info['line1']) ? $customer_info['line1'] : $current_address['line1']; |
|
| 103 | + $address['line2'] = isset($customer_info['line2']) ? $customer_info['line2'] : $current_address['line2']; |
|
| 104 | + $address['city'] = isset($customer_info['city']) ? $customer_info['city'] : $current_address['city']; |
|
| 105 | + $address['country'] = isset($customer_info['country']) ? $customer_info['country'] : $current_address['country']; |
|
| 106 | + $address['zip'] = isset($customer_info['zip']) ? $customer_info['zip'] : $current_address['zip']; |
|
| 107 | + $address['state'] = isset($customer_info['state']) ? $customer_info['state'] : $current_address['state']; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | // Sanitize the inputs |
| 113 | 113 | $customer_data = array(); |
| 114 | - $customer_data['name'] = strip_tags( stripslashes( $customer_info['name'] ) ); |
|
| 114 | + $customer_data['name'] = strip_tags(stripslashes($customer_info['name'])); |
|
| 115 | 115 | $customer_data['user_id'] = $customer_info['user_id']; |
| 116 | 116 | |
| 117 | - $customer_data = apply_filters( 'give_edit_customer_info', $customer_data, $customer_id ); |
|
| 118 | - $address = apply_filters( 'give_edit_customer_address', $address, $customer_id ); |
|
| 117 | + $customer_data = apply_filters('give_edit_customer_info', $customer_data, $customer_id); |
|
| 118 | + $address = apply_filters('give_edit_customer_address', $address, $customer_id); |
|
| 119 | 119 | |
| 120 | - $customer_data = array_map( 'sanitize_text_field', $customer_data ); |
|
| 121 | - $address = array_map( 'sanitize_text_field', $address ); |
|
| 120 | + $customer_data = array_map('sanitize_text_field', $customer_data); |
|
| 121 | + $address = array_map('sanitize_text_field', $address); |
|
| 122 | 122 | |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -130,27 +130,27 @@ discard block |
||
| 130 | 130 | * @param array $customer_data The customer data. |
| 131 | 131 | * @param array $address The customer address. |
| 132 | 132 | */ |
| 133 | - do_action( 'give_pre_edit_customer', $customer_id, $customer_data, $address ); |
|
| 133 | + do_action('give_pre_edit_customer', $customer_id, $customer_data, $address); |
|
| 134 | 134 | |
| 135 | - $output = array(); |
|
| 135 | + $output = array(); |
|
| 136 | 136 | |
| 137 | - if ( $customer->update( $customer_data ) ) { |
|
| 137 | + if ($customer->update($customer_data)) { |
|
| 138 | 138 | |
| 139 | - if ( ! empty( $customer->user_id ) && $customer->user_id > 0 ) { |
|
| 140 | - update_user_meta( $customer->user_id, '_give_user_address', $address ); |
|
| 139 | + if ( ! empty($customer->user_id) && $customer->user_id > 0) { |
|
| 140 | + update_user_meta($customer->user_id, '_give_user_address', $address); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | // Update some donation meta if we need to |
| 144 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
| 144 | + $payments_array = explode(',', $customer->payment_ids); |
|
| 145 | 145 | |
| 146 | - if ( $customer->user_id != $previous_user_id ) { |
|
| 147 | - foreach ( $payments_array as $payment_id ) { |
|
| 148 | - give_update_payment_meta( $payment_id, '_give_payment_user_id', $customer->user_id ); |
|
| 146 | + if ($customer->user_id != $previous_user_id) { |
|
| 147 | + foreach ($payments_array as $payment_id) { |
|
| 148 | + give_update_payment_meta($payment_id, '_give_payment_user_id', $customer->user_id); |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | $output['success'] = true; |
| 153 | - $customer_data = array_merge( $customer_data, $address ); |
|
| 153 | + $customer_data = array_merge($customer_data, $address); |
|
| 154 | 154 | $output['customer_info'] = $customer_data; |
| 155 | 155 | |
| 156 | 156 | } else { |
@@ -167,11 +167,11 @@ discard block |
||
| 167 | 167 | * @param int $customer_id The ID of the customer. |
| 168 | 168 | * @param array $customer_data The customer data. |
| 169 | 169 | */ |
| 170 | - do_action( 'give_post_edit_customer', $customer_id, $customer_data ); |
|
| 170 | + do_action('give_post_edit_customer', $customer_id, $customer_data); |
|
| 171 | 171 | |
| 172 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
| 173 | - header( 'Content-Type: application/json' ); |
|
| 174 | - echo json_encode( $output ); |
|
| 172 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 173 | + header('Content-Type: application/json'); |
|
| 174 | + echo json_encode($output); |
|
| 175 | 175 | wp_die(); |
| 176 | 176 | } |
| 177 | 177 | |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | -add_action( 'give_edit-customer', 'give_edit_customer', 10, 1 ); |
|
| 182 | +add_action('give_edit-customer', 'give_edit_customer', 10, 1); |
|
| 183 | 183 | |
| 184 | 184 | /** |
| 185 | 185 | * Save a customer note being added |
@@ -190,36 +190,36 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @return int The Note ID that was saved, or 0 if nothing was saved |
| 192 | 192 | */ |
| 193 | -function give_customer_save_note( $args ) { |
|
| 193 | +function give_customer_save_note($args) { |
|
| 194 | 194 | |
| 195 | - $customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' ); |
|
| 195 | + $customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports'); |
|
| 196 | 196 | |
| 197 | - if ( ! is_admin() || ! current_user_can( $customer_view_role ) ) { |
|
| 198 | - wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 197 | + if ( ! is_admin() || ! current_user_can($customer_view_role)) { |
|
| 198 | + wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - if ( empty( $args ) ) { |
|
| 201 | + if (empty($args)) { |
|
| 202 | 202 | return; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - $customer_note = trim( sanitize_text_field( $args['customer_note'] ) ); |
|
| 205 | + $customer_note = trim(sanitize_text_field($args['customer_note'])); |
|
| 206 | 206 | $customer_id = (int) $args['customer_id']; |
| 207 | 207 | $nonce = $args['add_customer_note_nonce']; |
| 208 | 208 | |
| 209 | - if ( ! wp_verify_nonce( $nonce, 'add-customer-note' ) ) { |
|
| 210 | - wp_die( esc_html__( 'Cheatin’ uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
| 209 | + if ( ! wp_verify_nonce($nonce, 'add-customer-note')) { |
|
| 210 | + wp_die(esc_html__('Cheatin’ uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - if ( empty( $customer_note ) ) { |
|
| 214 | - give_set_error( 'empty-customer-note', esc_html__( 'A note is required.', 'give' ) ); |
|
| 213 | + if (empty($customer_note)) { |
|
| 214 | + give_set_error('empty-customer-note', esc_html__('A note is required.', 'give')); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - if ( give_get_errors() ) { |
|
| 217 | + if (give_get_errors()) { |
|
| 218 | 218 | return; |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - $customer = new Give_Customer( $customer_id ); |
|
| 222 | - $new_note = $customer->add_note( $customer_note ); |
|
| 221 | + $customer = new Give_Customer($customer_id); |
|
| 222 | + $new_note = $customer->add_note($customer_note); |
|
| 223 | 223 | |
| 224 | 224 | /** |
| 225 | 225 | * Fires before inserting customer note. |
@@ -229,22 +229,22 @@ discard block |
||
| 229 | 229 | * @param int $customer_id The ID of the customer. |
| 230 | 230 | * @param string $new_note Note content. |
| 231 | 231 | */ |
| 232 | - do_action( 'give_pre_insert_customer_note', $customer_id, $new_note ); |
|
| 232 | + do_action('give_pre_insert_customer_note', $customer_id, $new_note); |
|
| 233 | 233 | |
| 234 | - if ( ! empty( $new_note ) && ! empty( $customer->id ) ) { |
|
| 234 | + if ( ! empty($new_note) && ! empty($customer->id)) { |
|
| 235 | 235 | |
| 236 | 236 | ob_start(); |
| 237 | 237 | ?> |
| 238 | 238 | <div class="customer-note-wrapper dashboard-comment-wrap comment-item"> |
| 239 | 239 | <span class="note-content-wrap"> |
| 240 | - <?php echo stripslashes( $new_note ); ?> |
|
| 240 | + <?php echo stripslashes($new_note); ?> |
|
| 241 | 241 | </span> |
| 242 | 242 | </div> |
| 243 | 243 | <?php |
| 244 | 244 | $output = ob_get_contents(); |
| 245 | 245 | ob_end_clean(); |
| 246 | 246 | |
| 247 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
| 247 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 248 | 248 | echo $output; |
| 249 | 249 | exit; |
| 250 | 250 | } |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | -add_action( 'give_add-customer-note', 'give_customer_save_note', 10, 1 ); |
|
| 260 | +add_action('give_add-customer-note', 'give_customer_save_note', 10, 1); |
|
| 261 | 261 | |
| 262 | 262 | /** |
| 263 | 263 | * Delete a customer |
@@ -268,37 +268,37 @@ discard block |
||
| 268 | 268 | * |
| 269 | 269 | * @return int Whether it was a successful deletion |
| 270 | 270 | */ |
| 271 | -function give_customer_delete( $args ) { |
|
| 271 | +function give_customer_delete($args) { |
|
| 272 | 272 | |
| 273 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
| 273 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
| 274 | 274 | |
| 275 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
| 276 | - wp_die( esc_html__( 'You do not have permission to delete donors.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 275 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
| 276 | + wp_die(esc_html__('You do not have permission to delete donors.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - if ( empty( $args ) ) { |
|
| 279 | + if (empty($args)) { |
|
| 280 | 280 | return; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | $customer_id = (int) $args['customer_id']; |
| 284 | - $confirm = ! empty( $args['give-customer-delete-confirm'] ) ? true : false; |
|
| 285 | - $remove_data = ! empty( $args['give-customer-delete-records'] ) ? true : false; |
|
| 284 | + $confirm = ! empty($args['give-customer-delete-confirm']) ? true : false; |
|
| 285 | + $remove_data = ! empty($args['give-customer-delete-records']) ? true : false; |
|
| 286 | 286 | $nonce = $args['_wpnonce']; |
| 287 | 287 | |
| 288 | - if ( ! wp_verify_nonce( $nonce, 'delete-customer' ) ) { |
|
| 289 | - wp_die( esc_html__( 'Cheatin’ uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
| 288 | + if ( ! wp_verify_nonce($nonce, 'delete-customer')) { |
|
| 289 | + wp_die(esc_html__('Cheatin’ uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - if ( ! $confirm ) { |
|
| 293 | - give_set_error( 'customer-delete-no-confirm', esc_html__( 'Please confirm you want to delete this donor.', 'give' ) ); |
|
| 292 | + if ( ! $confirm) { |
|
| 293 | + give_set_error('customer-delete-no-confirm', esc_html__('Please confirm you want to delete this donor.', 'give')); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - if ( give_get_errors() ) { |
|
| 297 | - wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id ) ); |
|
| 296 | + if (give_get_errors()) { |
|
| 297 | + wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer_id)); |
|
| 298 | 298 | exit; |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - $customer = new Give_Customer( $customer_id ); |
|
| 301 | + $customer = new Give_Customer($customer_id); |
|
| 302 | 302 | |
| 303 | 303 | /** |
| 304 | 304 | * Fires before deleting customer. |
@@ -309,53 +309,53 @@ discard block |
||
| 309 | 309 | * @param bool $confirm Delete confirmation. |
| 310 | 310 | * @param bool $remove_data Records delete confirmation. |
| 311 | 311 | */ |
| 312 | - do_action( 'give_pre_delete_customer', $customer_id, $confirm, $remove_data ); |
|
| 312 | + do_action('give_pre_delete_customer', $customer_id, $confirm, $remove_data); |
|
| 313 | 313 | |
| 314 | - if ( $customer->id > 0 ) { |
|
| 314 | + if ($customer->id > 0) { |
|
| 315 | 315 | |
| 316 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
| 317 | - $success = Give()->customers->delete( $customer->id ); |
|
| 316 | + $payments_array = explode(',', $customer->payment_ids); |
|
| 317 | + $success = Give()->customers->delete($customer->id); |
|
| 318 | 318 | |
| 319 | - if ( $success ) { |
|
| 319 | + if ($success) { |
|
| 320 | 320 | |
| 321 | - if ( $remove_data ) { |
|
| 321 | + if ($remove_data) { |
|
| 322 | 322 | |
| 323 | 323 | // Remove all donations, logs, etc |
| 324 | - foreach ( $payments_array as $payment_id ) { |
|
| 325 | - give_delete_purchase( $payment_id ); |
|
| 324 | + foreach ($payments_array as $payment_id) { |
|
| 325 | + give_delete_purchase($payment_id); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | } else { |
| 329 | 329 | |
| 330 | 330 | // Just set the donations to customer_id of 0 |
| 331 | - foreach ( $payments_array as $payment_id ) { |
|
| 332 | - give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 ); |
|
| 331 | + foreach ($payments_array as $payment_id) { |
|
| 332 | + give_update_payment_meta($payment_id, '_give_payment_customer_id', 0); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted' ); |
|
| 337 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted'); |
|
| 338 | 338 | |
| 339 | 339 | } else { |
| 340 | 340 | |
| 341 | - give_set_error( 'give-donor-delete-failed', esc_html__( 'Error deleting donor.', 'give' ) ); |
|
| 342 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer_id ); |
|
| 341 | + give_set_error('give-donor-delete-failed', esc_html__('Error deleting donor.', 'give')); |
|
| 342 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$customer_id); |
|
| 343 | 343 | |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | } else { |
| 347 | 347 | |
| 348 | - give_set_error( 'give-customer-delete-invalid-id', esc_html__( 'Invalid Donor ID.', 'give' ) ); |
|
| 349 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); |
|
| 348 | + give_set_error('give-customer-delete-invalid-id', esc_html__('Invalid Donor ID.', 'give')); |
|
| 349 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors'); |
|
| 350 | 350 | |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | - wp_redirect( $redirect ); |
|
| 353 | + wp_redirect($redirect); |
|
| 354 | 354 | exit; |
| 355 | 355 | |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | -add_action( 'give_delete-customer', 'give_customer_delete', 10, 1 ); |
|
| 358 | +add_action('give_delete-customer', 'give_customer_delete', 10, 1); |
|
| 359 | 359 | |
| 360 | 360 | /** |
| 361 | 361 | * Disconnect a user ID from a donor |
@@ -366,27 +366,27 @@ discard block |
||
| 366 | 366 | * |
| 367 | 367 | * @return bool If the disconnect was successful |
| 368 | 368 | */ |
| 369 | -function give_disconnect_customer_user_id( $args ) { |
|
| 369 | +function give_disconnect_customer_user_id($args) { |
|
| 370 | 370 | |
| 371 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
| 371 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
| 372 | 372 | |
| 373 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
| 374 | - wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 373 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
| 374 | + wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - if ( empty( $args ) ) { |
|
| 377 | + if (empty($args)) { |
|
| 378 | 378 | return; |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | $customer_id = (int) $args['customer_id']; |
| 382 | 382 | $nonce = $args['_wpnonce']; |
| 383 | 383 | |
| 384 | - if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) { |
|
| 385 | - wp_die( esc_html__( 'Cheatin’ uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
| 384 | + if ( ! wp_verify_nonce($nonce, 'edit-customer')) { |
|
| 385 | + wp_die(esc_html__('Cheatin’ uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - $customer = new Give_Customer( $customer_id ); |
|
| 389 | - if ( empty( $customer->id ) ) { |
|
| 388 | + $customer = new Give_Customer($customer_id); |
|
| 389 | + if (empty($customer->id)) { |
|
| 390 | 390 | return false; |
| 391 | 391 | } |
| 392 | 392 | |
@@ -400,16 +400,16 @@ discard block |
||
| 400 | 400 | * @param int $customer_id The ID of the customer. |
| 401 | 401 | * @param int $user_id The ID of the user. |
| 402 | 402 | */ |
| 403 | - do_action( 'give_pre_customer_disconnect_user_id', $customer_id, $user_id ); |
|
| 403 | + do_action('give_pre_customer_disconnect_user_id', $customer_id, $user_id); |
|
| 404 | 404 | |
| 405 | 405 | $output = array(); |
| 406 | - $customer_args = array( 'user_id' => 0 ); |
|
| 406 | + $customer_args = array('user_id' => 0); |
|
| 407 | 407 | |
| 408 | - if ( $customer->update( $customer_args ) ) { |
|
| 408 | + if ($customer->update($customer_args)) { |
|
| 409 | 409 | global $wpdb; |
| 410 | 410 | |
| 411 | - if ( ! empty( $customer->payment_ids ) ) { |
|
| 412 | - $wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )" ); |
|
| 411 | + if ( ! empty($customer->payment_ids)) { |
|
| 412 | + $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )"); |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | $output['success'] = true; |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | } else { |
| 418 | 418 | |
| 419 | 419 | $output['success'] = false; |
| 420 | - give_set_error( 'give-disconnect-user-fail', esc_html__( 'Failed to disconnect user from donor.', 'give' ) ); |
|
| 420 | + give_set_error('give-disconnect-user-fail', esc_html__('Failed to disconnect user from donor.', 'give')); |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | /** |
@@ -427,11 +427,11 @@ discard block |
||
| 427 | 427 | * |
| 428 | 428 | * @param int $customer_id The ID of the customer. |
| 429 | 429 | */ |
| 430 | - do_action( 'give_post_customer_disconnect_user_id', $customer_id ); |
|
| 430 | + do_action('give_post_customer_disconnect_user_id', $customer_id); |
|
| 431 | 431 | |
| 432 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
| 433 | - header( 'Content-Type: application/json' ); |
|
| 434 | - echo json_encode( $output ); |
|
| 432 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 433 | + header('Content-Type: application/json'); |
|
| 434 | + echo json_encode($output); |
|
| 435 | 435 | wp_die(); |
| 436 | 436 | } |
| 437 | 437 | |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | -add_action( 'give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1 ); |
|
| 442 | +add_action('give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1); |
|
| 443 | 443 | |
| 444 | 444 | /** |
| 445 | 445 | * Add an email address to the donor from within the admin and log a donor note |
@@ -448,81 +448,81 @@ discard block |
||
| 448 | 448 | * @param array $args Array of arguments: nonce, customer id, and email address |
| 449 | 449 | * @return mixed If DOING_AJAX echos out JSON, otherwise returns array of success (bool) and message (string) |
| 450 | 450 | */ |
| 451 | -function give_add_donor_email( $args ) { |
|
| 452 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
| 451 | +function give_add_donor_email($args) { |
|
| 452 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
| 453 | 453 | |
| 454 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
| 455 | - wp_die( esc_html__( 'You do not have permission to edit this donor.', 'edit' ) ); |
|
| 454 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
| 455 | + wp_die(esc_html__('You do not have permission to edit this donor.', 'edit')); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | $output = array(); |
| 459 | - if ( empty( $args ) || empty( $args['email'] ) || empty( $args['customer_id'] ) ) { |
|
| 459 | + if (empty($args) || empty($args['email']) || empty($args['customer_id'])) { |
|
| 460 | 460 | $output['success'] = false; |
| 461 | - if ( empty( $args['email'] ) ) { |
|
| 462 | - $output['message'] = esc_html__( 'Email address is required.', 'give' ); |
|
| 463 | - } else if ( empty( $args['customer_id'] ) ) { |
|
| 464 | - $output['message'] = esc_html__( 'Customer ID is required.', 'give' ); |
|
| 461 | + if (empty($args['email'])) { |
|
| 462 | + $output['message'] = esc_html__('Email address is required.', 'give'); |
|
| 463 | + } else if (empty($args['customer_id'])) { |
|
| 464 | + $output['message'] = esc_html__('Customer ID is required.', 'give'); |
|
| 465 | 465 | } else { |
| 466 | - $output['message'] = esc_html__( 'An error has occurred. Please try again.', 'give' ); |
|
| 466 | + $output['message'] = esc_html__('An error has occurred. Please try again.', 'give'); |
|
| 467 | 467 | } |
| 468 | - } else if ( ! wp_verify_nonce( $args['_wpnonce'], 'give_add_donor_email' ) ) { |
|
| 468 | + } else if ( ! wp_verify_nonce($args['_wpnonce'], 'give_add_donor_email')) { |
|
| 469 | 469 | $output = array( |
| 470 | 470 | 'success' => false, |
| 471 | - 'message' => esc_html__( 'Nonce verification failed.', 'give' ), |
|
| 471 | + 'message' => esc_html__('Nonce verification failed.', 'give'), |
|
| 472 | 472 | ); |
| 473 | - } else if ( ! is_email( $args['email'] ) ) { |
|
| 473 | + } else if ( ! is_email($args['email'])) { |
|
| 474 | 474 | $output = array( |
| 475 | 475 | 'success' => false, |
| 476 | - 'message' => esc_html__( 'Invalid email.', 'give' ), |
|
| 476 | + 'message' => esc_html__('Invalid email.', 'give'), |
|
| 477 | 477 | ); |
| 478 | 478 | } else { |
| 479 | - $email = sanitize_email($args['email'] ); |
|
| 479 | + $email = sanitize_email($args['email']); |
|
| 480 | 480 | $customer_id = (int) $args['customer_id']; |
| 481 | 481 | $primary = 'true' === $args['primary'] ? true : false; |
| 482 | - $customer = new Give_Customer( $customer_id ); |
|
| 483 | - if ( false === $customer->add_email( $email, $primary ) ) { |
|
| 484 | - if ( in_array( $email, $customer->emails ) ) { |
|
| 482 | + $customer = new Give_Customer($customer_id); |
|
| 483 | + if (false === $customer->add_email($email, $primary)) { |
|
| 484 | + if (in_array($email, $customer->emails)) { |
|
| 485 | 485 | $output = array( |
| 486 | 486 | 'success' => false, |
| 487 | - 'message' => esc_html__( 'Email already associated with this donor.', 'give' ), |
|
| 487 | + 'message' => esc_html__('Email already associated with this donor.', 'give'), |
|
| 488 | 488 | ); |
| 489 | 489 | } else { |
| 490 | 490 | $output = array( |
| 491 | 491 | 'success' => false, |
| 492 | - 'message' => esc_html__( 'Email address is already associated with another donor.', 'give' ), |
|
| 492 | + 'message' => esc_html__('Email address is already associated with another donor.', 'give'), |
|
| 493 | 493 | ); |
| 494 | 494 | } |
| 495 | 495 | } else { |
| 496 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id . '&give-message=email-added' ); |
|
| 496 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer_id.'&give-message=email-added'); |
|
| 497 | 497 | $output = array( |
| 498 | 498 | 'success' => true, |
| 499 | - 'message' => esc_html__( 'Email successfully added to donor.', 'give' ), |
|
| 499 | + 'message' => esc_html__('Email successfully added to donor.', 'give'), |
|
| 500 | 500 | 'redirect' => $redirect, |
| 501 | 501 | ); |
| 502 | 502 | |
| 503 | 503 | $user = wp_get_current_user(); |
| 504 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' ); |
|
| 505 | - $customer_note = sprintf( __( 'Email address %s added by %s', 'give' ), $email, $user_login ); |
|
| 506 | - $customer->add_note( $customer_note ); |
|
| 504 | + $user_login = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give'); |
|
| 505 | + $customer_note = sprintf(__('Email address %s added by %s', 'give'), $email, $user_login); |
|
| 506 | + $customer->add_note($customer_note); |
|
| 507 | 507 | |
| 508 | - if ( $primary ) { |
|
| 509 | - $customer_note = sprintf( __( 'Email address %s set as primary by %s', 'give' ), $email, $user_login ); |
|
| 510 | - $customer->add_note( $customer_note ); |
|
| 508 | + if ($primary) { |
|
| 509 | + $customer_note = sprintf(__('Email address %s set as primary by %s', 'give'), $email, $user_login); |
|
| 510 | + $customer->add_note($customer_note); |
|
| 511 | 511 | } |
| 512 | 512 | } |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | - do_action( 'give_post_add_customer_email', $customer_id, $args ); |
|
| 515 | + do_action('give_post_add_customer_email', $customer_id, $args); |
|
| 516 | 516 | |
| 517 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
| 518 | - header( 'Content-Type: application/json' ); |
|
| 519 | - echo json_encode( $output ); |
|
| 517 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 518 | + header('Content-Type: application/json'); |
|
| 519 | + echo json_encode($output); |
|
| 520 | 520 | wp_die(); |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | 523 | return $output; |
| 524 | 524 | } |
| 525 | -add_action( 'give_add_donor_email', 'give_add_donor_email', 10, 1 ); |
|
| 525 | +add_action('give_add_donor_email', 'give_add_donor_email', 10, 1); |
|
| 526 | 526 | |
| 527 | 527 | |
| 528 | 528 | /** |
@@ -533,36 +533,36 @@ discard block |
||
| 533 | 533 | * @return void|bool |
| 534 | 534 | */ |
| 535 | 535 | function give_remove_donor_email() { |
| 536 | - if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
| 536 | + if (empty($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
| 537 | 537 | return false; |
| 538 | 538 | } |
| 539 | - if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) { |
|
| 539 | + if (empty($_GET['email']) || ! is_email($_GET['email'])) { |
|
| 540 | 540 | return false; |
| 541 | 541 | } |
| 542 | - if ( empty( $_GET['_wpnonce'] ) ) { |
|
| 542 | + if (empty($_GET['_wpnonce'])) { |
|
| 543 | 543 | return false; |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | $nonce = $_GET['_wpnonce']; |
| 547 | - if ( ! wp_verify_nonce( $nonce, 'give-remove-donor-email' ) ) { |
|
| 548 | - wp_die( esc_html__( 'Nonce verification failed', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 547 | + if ( ! wp_verify_nonce($nonce, 'give-remove-donor-email')) { |
|
| 548 | + wp_die(esc_html__('Nonce verification failed', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | - $customer = new Give_Customer( $_GET['id'] ); |
|
| 552 | - if ( $customer->remove_email( $_GET['email'] ) ) { |
|
| 553 | - $url = add_query_arg( 'give-message', 'email-removed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ) ); |
|
| 551 | + $customer = new Give_Customer($_GET['id']); |
|
| 552 | + if ($customer->remove_email($_GET['email'])) { |
|
| 553 | + $url = add_query_arg('give-message', 'email-removed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id)); |
|
| 554 | 554 | $user = wp_get_current_user(); |
| 555 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' ); |
|
| 556 | - $customer_note = sprintf( __( 'Email address %s removed by %s', 'give' ), $_GET['email'], $user_login ); |
|
| 557 | - $customer->add_note( $customer_note ); |
|
| 555 | + $user_login = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give'); |
|
| 556 | + $customer_note = sprintf(__('Email address %s removed by %s', 'give'), $_GET['email'], $user_login); |
|
| 557 | + $customer->add_note($customer_note); |
|
| 558 | 558 | } else { |
| 559 | - $url = add_query_arg( 'give-message', 'email-remove-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ) ); |
|
| 559 | + $url = add_query_arg('give-message', 'email-remove-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id)); |
|
| 560 | 560 | } |
| 561 | 561 | |
| 562 | - wp_safe_redirect( $url ); |
|
| 562 | + wp_safe_redirect($url); |
|
| 563 | 563 | exit; |
| 564 | 564 | } |
| 565 | -add_action( 'give_remove_donor_email', 'give_remove_donor_email', 10 ); |
|
| 565 | +add_action('give_remove_donor_email', 'give_remove_donor_email', 10); |
|
| 566 | 566 | |
| 567 | 567 | |
| 568 | 568 | /** |
@@ -573,38 +573,38 @@ discard block |
||
| 573 | 573 | * @return void|bool |
| 574 | 574 | */ |
| 575 | 575 | function give_set_donor_primary_email() { |
| 576 | - if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
| 576 | + if (empty($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
| 577 | 577 | return false; |
| 578 | 578 | } |
| 579 | 579 | |
| 580 | - if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) { |
|
| 580 | + if (empty($_GET['email']) || ! is_email($_GET['email'])) { |
|
| 581 | 581 | return false; |
| 582 | 582 | } |
| 583 | 583 | |
| 584 | - if ( empty( $_GET['_wpnonce'] ) ) { |
|
| 584 | + if (empty($_GET['_wpnonce'])) { |
|
| 585 | 585 | return false; |
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | $nonce = $_GET['_wpnonce']; |
| 589 | 589 | |
| 590 | - if ( ! wp_verify_nonce( $nonce, 'give-set-donor-primary-email' ) ) { |
|
| 591 | - wp_die( esc_html__( 'Nonce verification failed', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 590 | + if ( ! wp_verify_nonce($nonce, 'give-set-donor-primary-email')) { |
|
| 591 | + wp_die(esc_html__('Nonce verification failed', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | - $donor = new Give_Customer( $_GET['id'] ); |
|
| 594 | + $donor = new Give_Customer($_GET['id']); |
|
| 595 | 595 | |
| 596 | - if ( $donor->set_primary_email( $_GET['email'] ) ) { |
|
| 597 | - $url = add_query_arg( 'give-message', 'primary-email-updated', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
| 596 | + if ($donor->set_primary_email($_GET['email'])) { |
|
| 597 | + $url = add_query_arg('give-message', 'primary-email-updated', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
| 598 | 598 | $user = wp_get_current_user(); |
| 599 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' ); |
|
| 600 | - $donor_note = sprintf( __( 'Email address %s set as primary by %s', 'give' ), $_GET['email'], $user_login ); |
|
| 599 | + $user_login = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give'); |
|
| 600 | + $donor_note = sprintf(__('Email address %s set as primary by %s', 'give'), $_GET['email'], $user_login); |
|
| 601 | 601 | |
| 602 | - $donor->add_note( $donor_note ); |
|
| 602 | + $donor->add_note($donor_note); |
|
| 603 | 603 | } else { |
| 604 | - $url = add_query_arg( 'give-message', 'primary-email-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
| 604 | + $url = add_query_arg('give-message', 'primary-email-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
| 605 | 605 | } |
| 606 | 606 | |
| 607 | - wp_safe_redirect( $url ); |
|
| 607 | + wp_safe_redirect($url); |
|
| 608 | 608 | exit; |
| 609 | 609 | } |
| 610 | -add_action( 'give_set_donor_primary_email', 'give_set_donor_primary_email', 10 ); |
|
| 610 | +add_action('give_set_donor_primary_email', 'give_set_donor_primary_email', 10); |
|
@@ -890,7 +890,7 @@ discard block |
||
| 890 | 890 | * @access public |
| 891 | 891 | * |
| 892 | 892 | * @param string $meta_key Metadata name. Default is empty. |
| 893 | - * @param mixed $meta_value Metadata value. |
|
| 893 | + * @param string $meta_value Metadata value. |
|
| 894 | 894 | * @param bool $unique Optional. Whether the same key should not be added. Default is false. |
| 895 | 895 | * |
| 896 | 896 | * @return bool False for failure. True for success. |
@@ -922,7 +922,7 @@ discard block |
||
| 922 | 922 | * @access public |
| 923 | 923 | * |
| 924 | 924 | * @param string $meta_key Metadata name. Default is empty. |
| 925 | - * @param mixed $meta_value Optional. Metadata value. Default is empty. |
|
| 925 | + * @param string $meta_value Optional. Metadata value. Default is empty. |
|
| 926 | 926 | * |
| 927 | 927 | * @return bool False for failure. True for success. |
| 928 | 928 | */ |
@@ -714,12 +714,12 @@ discard block |
||
| 714 | 714 | |
| 715 | 715 | /** |
| 716 | 716 | * Decrease/Increase a customer's lifetime value. |
| 717 | - * |
|
| 718 | - * This function will update donation stat on basis of current amount and new amount donation difference. |
|
| 719 | - * Difference value can positive or negative. Negative value will decrease user donation stat while positive value increase donation stat. |
|
| 720 | - * |
|
| 717 | + * |
|
| 718 | + * This function will update donation stat on basis of current amount and new amount donation difference. |
|
| 719 | + * Difference value can positive or negative. Negative value will decrease user donation stat while positive value increase donation stat. |
|
| 720 | + * |
|
| 721 | 721 | * @since 1.0 |
| 722 | - * @access public |
|
| 722 | + * @access public |
|
| 723 | 723 | * |
| 724 | 724 | * @param float $curr_amount Current Donation amount. |
| 725 | 725 | * @param float $new_amount New (changed) Donation amount. |
@@ -727,35 +727,35 @@ discard block |
||
| 727 | 727 | * @return mixed If successful, the new donation stat value, otherwise false. |
| 728 | 728 | */ |
| 729 | 729 | public function update_donation_value( $curr_amount, $new_amount ) { |
| 730 | - /** |
|
| 731 | - * Payment total difference value can be: |
|
| 732 | - * zero (in case amount not change) |
|
| 733 | - * or -ve (in case amount decrease) |
|
| 734 | - * or +ve (in case amount increase) |
|
| 735 | - */ |
|
| 736 | - $payment_total_diff = $new_amount - $curr_amount; |
|
| 737 | - |
|
| 738 | - // We do not need to update donation stat if donation did not change. |
|
| 739 | - if( ! $payment_total_diff ) { |
|
| 740 | - return false; |
|
| 741 | - } |
|
| 742 | - |
|
| 743 | - |
|
| 744 | - if( $payment_total_diff > 0 ) { |
|
| 745 | - $this->increase_value( $payment_total_diff ); |
|
| 746 | - } else { |
|
| 747 | - // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
|
| 748 | - $this->decrease_value( -$payment_total_diff ); |
|
| 749 | - } |
|
| 750 | - |
|
| 751 | - return $this->purchase_value; |
|
| 730 | + /** |
|
| 731 | + * Payment total difference value can be: |
|
| 732 | + * zero (in case amount not change) |
|
| 733 | + * or -ve (in case amount decrease) |
|
| 734 | + * or +ve (in case amount increase) |
|
| 735 | + */ |
|
| 736 | + $payment_total_diff = $new_amount - $curr_amount; |
|
| 737 | + |
|
| 738 | + // We do not need to update donation stat if donation did not change. |
|
| 739 | + if( ! $payment_total_diff ) { |
|
| 740 | + return false; |
|
| 741 | + } |
|
| 742 | + |
|
| 743 | + |
|
| 744 | + if( $payment_total_diff > 0 ) { |
|
| 745 | + $this->increase_value( $payment_total_diff ); |
|
| 746 | + } else { |
|
| 747 | + // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
|
| 748 | + $this->decrease_value( -$payment_total_diff ); |
|
| 749 | + } |
|
| 750 | + |
|
| 751 | + return $this->purchase_value; |
|
| 752 | 752 | } |
| 753 | 753 | |
| 754 | 754 | /** |
| 755 | 755 | * Get the parsed notes for a customer as an array. |
| 756 | 756 | * |
| 757 | 757 | * @since 1.0 |
| 758 | - * @access public |
|
| 758 | + * @access public |
|
| 759 | 759 | * |
| 760 | 760 | * @param int $length The number of notes to get. |
| 761 | 761 | * @param int $paged What note to start at. |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | * Get the total number of notes we have after parsing. |
| 781 | 781 | * |
| 782 | 782 | * @since 1.0 |
| 783 | - * @access public |
|
| 783 | + * @access public |
|
| 784 | 784 | * |
| 785 | 785 | * @return int The number of notes for the customer. |
| 786 | 786 | */ |
@@ -797,7 +797,7 @@ discard block |
||
| 797 | 797 | * Add a note for the customer. |
| 798 | 798 | * |
| 799 | 799 | * @since 1.0 |
| 800 | - * @access public |
|
| 800 | + * @access public |
|
| 801 | 801 | * |
| 802 | 802 | * @param string $note The note to add. Default is empty. |
| 803 | 803 | * |
@@ -856,7 +856,7 @@ discard block |
||
| 856 | 856 | * Get the notes column for the customer |
| 857 | 857 | * |
| 858 | 858 | * @since 1.0 |
| 859 | - * @access private |
|
| 859 | + * @access private |
|
| 860 | 860 | * |
| 861 | 861 | * @return string The Notes for the customer, non-parsed. |
| 862 | 862 | */ |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | * Sanitize the data for update/create |
| 935 | 935 | * |
| 936 | 936 | * @since 1.0 |
| 937 | - * @access private |
|
| 937 | + * @access private |
|
| 938 | 938 | * |
| 939 | 939 | * @param array $data The data to sanitize. |
| 940 | 940 | * |
@@ -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 | |
@@ -144,29 +144,29 @@ discard block |
||
| 144 | 144 | * @param bool $_id_or_email |
| 145 | 145 | * @param bool $by_user_id |
| 146 | 146 | */ |
| 147 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
| 147 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
| 148 | 148 | |
| 149 | 149 | $this->db = new Give_DB_Customers; |
| 150 | 150 | |
| 151 | - if ( false === $_id_or_email || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) ) { |
|
| 151 | + if (false === $_id_or_email || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))) { |
|
| 152 | 152 | return false; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
| 155 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
| 156 | 156 | |
| 157 | - if ( is_numeric( $_id_or_email ) ) { |
|
| 157 | + if (is_numeric($_id_or_email)) { |
|
| 158 | 158 | $field = $by_user_id ? 'user_id' : 'id'; |
| 159 | 159 | } else { |
| 160 | 160 | $field = 'email'; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - $customer = $this->db->get_customer_by( $field, $_id_or_email ); |
|
| 163 | + $customer = $this->db->get_customer_by($field, $_id_or_email); |
|
| 164 | 164 | |
| 165 | - if ( empty( $customer ) || ! is_object( $customer ) ) { |
|
| 165 | + if (empty($customer) || ! is_object($customer)) { |
|
| 166 | 166 | return false; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - $this->setup_customer( $customer ); |
|
| 169 | + $this->setup_customer($customer); |
|
| 170 | 170 | |
| 171 | 171 | } |
| 172 | 172 | |
@@ -182,15 +182,15 @@ discard block |
||
| 182 | 182 | * |
| 183 | 183 | * @return bool If the setup was successful or not. |
| 184 | 184 | */ |
| 185 | - private function setup_customer( $customer ) { |
|
| 185 | + private function setup_customer($customer) { |
|
| 186 | 186 | |
| 187 | - if ( ! is_object( $customer ) ) { |
|
| 187 | + if ( ! is_object($customer)) { |
|
| 188 | 188 | return false; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - foreach ( $customer as $key => $value ) { |
|
| 191 | + foreach ($customer as $key => $value) { |
|
| 192 | 192 | |
| 193 | - switch ( $key ) { |
|
| 193 | + switch ($key) { |
|
| 194 | 194 | |
| 195 | 195 | case 'notes': |
| 196 | 196 | $this->$key = $this->get_notes(); |
@@ -205,11 +205,11 @@ discard block |
||
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | // Get donor's all email including primary email. |
| 208 | - $this->emails = (array) $this->get_meta( 'additional_email', false ); |
|
| 209 | - $this->emails = array( 'primary' => $this->email ) + $this->emails; |
|
| 208 | + $this->emails = (array) $this->get_meta('additional_email', false); |
|
| 209 | + $this->emails = array('primary' => $this->email) + $this->emails; |
|
| 210 | 210 | |
| 211 | 211 | // Customer ID and email are the only things that are necessary, make sure they exist. |
| 212 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
| 212 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
| 213 | 213 | return true; |
| 214 | 214 | } |
| 215 | 215 | |
@@ -223,16 +223,16 @@ discard block |
||
| 223 | 223 | * @since 1.0 |
| 224 | 224 | * @access public |
| 225 | 225 | */ |
| 226 | - public function __get( $key ) { |
|
| 226 | + public function __get($key) { |
|
| 227 | 227 | |
| 228 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
| 228 | + if (method_exists($this, 'get_'.$key)) { |
|
| 229 | 229 | |
| 230 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
| 230 | + return call_user_func(array($this, 'get_'.$key)); |
|
| 231 | 231 | |
| 232 | 232 | } else { |
| 233 | 233 | |
| 234 | 234 | /* translators: %s: property key */ |
| 235 | - return new WP_Error( 'give-customer-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
| 235 | + return new WP_Error('give-customer-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
| 236 | 236 | |
| 237 | 237 | } |
| 238 | 238 | |
@@ -248,9 +248,9 @@ discard block |
||
| 248 | 248 | * |
| 249 | 249 | * @return bool|int False if not a valid creation, customer ID if user is found or valid creation. |
| 250 | 250 | */ |
| 251 | - public function create( $data = array() ) { |
|
| 251 | + public function create($data = array()) { |
|
| 252 | 252 | |
| 253 | - if ( $this->id != 0 || empty( $data ) ) { |
|
| 253 | + if ($this->id != 0 || empty($data)) { |
|
| 254 | 254 | return false; |
| 255 | 255 | } |
| 256 | 256 | |
@@ -258,15 +258,15 @@ discard block |
||
| 258 | 258 | 'payment_ids' => '' |
| 259 | 259 | ); |
| 260 | 260 | |
| 261 | - $args = wp_parse_args( $data, $defaults ); |
|
| 262 | - $args = $this->sanitize_columns( $args ); |
|
| 261 | + $args = wp_parse_args($data, $defaults); |
|
| 262 | + $args = $this->sanitize_columns($args); |
|
| 263 | 263 | |
| 264 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
| 264 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
| 265 | 265 | return false; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
| 269 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
| 268 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
| 269 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | /** |
@@ -276,18 +276,18 @@ discard block |
||
| 276 | 276 | * |
| 277 | 277 | * @param array $args Customer attributes. |
| 278 | 278 | */ |
| 279 | - do_action( 'give_customer_pre_create', $args ); |
|
| 279 | + do_action('give_customer_pre_create', $args); |
|
| 280 | 280 | |
| 281 | 281 | $created = false; |
| 282 | 282 | |
| 283 | 283 | // The DB class 'add' implies an update if the customer being asked to be created already exists |
| 284 | - if ( $this->db->add( $data ) ) { |
|
| 284 | + if ($this->db->add($data)) { |
|
| 285 | 285 | |
| 286 | 286 | // We've successfully added/updated the customer, reset the class vars with the new data |
| 287 | - $customer = $this->db->get_customer_by( 'email', $args['email'] ); |
|
| 287 | + $customer = $this->db->get_customer_by('email', $args['email']); |
|
| 288 | 288 | |
| 289 | 289 | // Setup the customer data with the values from DB |
| 290 | - $this->setup_customer( $customer ); |
|
| 290 | + $this->setup_customer($customer); |
|
| 291 | 291 | |
| 292 | 292 | $created = $this->id; |
| 293 | 293 | } |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | * customer ID if user is found or valid creation. |
| 302 | 302 | * @param array $args Customer attributes. |
| 303 | 303 | */ |
| 304 | - do_action( 'give_customer_post_create', $created, $args ); |
|
| 304 | + do_action('give_customer_post_create', $created, $args); |
|
| 305 | 305 | |
| 306 | 306 | return $created; |
| 307 | 307 | |
@@ -317,13 +317,13 @@ discard block |
||
| 317 | 317 | * |
| 318 | 318 | * @return bool If the update was successful or not. |
| 319 | 319 | */ |
| 320 | - public function update( $data = array() ) { |
|
| 320 | + public function update($data = array()) { |
|
| 321 | 321 | |
| 322 | - if ( empty( $data ) ) { |
|
| 322 | + if (empty($data)) { |
|
| 323 | 323 | return false; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - $data = $this->sanitize_columns( $data ); |
|
| 326 | + $data = $this->sanitize_columns($data); |
|
| 327 | 327 | |
| 328 | 328 | /** |
| 329 | 329 | * Fires before updating customers. |
@@ -333,14 +333,14 @@ discard block |
||
| 333 | 333 | * @param int $customer_id Customer id. |
| 334 | 334 | * @param array $data Customer attributes. |
| 335 | 335 | */ |
| 336 | - do_action( 'give_customer_pre_update', $this->id, $data ); |
|
| 336 | + do_action('give_customer_pre_update', $this->id, $data); |
|
| 337 | 337 | |
| 338 | 338 | $updated = false; |
| 339 | 339 | |
| 340 | - if ( $this->db->update( $this->id, $data ) ) { |
|
| 340 | + if ($this->db->update($this->id, $data)) { |
|
| 341 | 341 | |
| 342 | - $customer = $this->db->get_customer_by( 'id', $this->id ); |
|
| 343 | - $this->setup_customer( $customer ); |
|
| 342 | + $customer = $this->db->get_customer_by('id', $this->id); |
|
| 343 | + $this->setup_customer($customer); |
|
| 344 | 344 | |
| 345 | 345 | $updated = true; |
| 346 | 346 | } |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | * @param int $customer_id Customer id. |
| 355 | 355 | * @param array $data Customer attributes. |
| 356 | 356 | */ |
| 357 | - do_action( 'give_customer_post_update', $updated, $this->id, $data ); |
|
| 357 | + do_action('give_customer_post_update', $updated, $this->id, $data); |
|
| 358 | 358 | |
| 359 | 359 | return $updated; |
| 360 | 360 | } |
@@ -372,27 +372,27 @@ discard block |
||
| 372 | 372 | * |
| 373 | 373 | * @return bool If the attachment was successfuly. |
| 374 | 374 | */ |
| 375 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
| 375 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
| 376 | 376 | |
| 377 | - if ( empty( $payment_id ) ) { |
|
| 377 | + if (empty($payment_id)) { |
|
| 378 | 378 | return false; |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - if ( empty( $this->payment_ids ) ) { |
|
| 381 | + if (empty($this->payment_ids)) { |
|
| 382 | 382 | |
| 383 | 383 | $new_payment_ids = $payment_id; |
| 384 | 384 | |
| 385 | 385 | } else { |
| 386 | 386 | |
| 387 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
| 387 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
| 388 | 388 | |
| 389 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
| 389 | + if (in_array($payment_id, $payment_ids)) { |
|
| 390 | 390 | $update_stats = false; |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | $payment_ids[] = $payment_id; |
| 394 | 394 | |
| 395 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
| 395 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
| 396 | 396 | |
| 397 | 397 | } |
| 398 | 398 | |
@@ -404,20 +404,20 @@ discard block |
||
| 404 | 404 | * @param int $payment_id Payment id. |
| 405 | 405 | * @param int $customer_id Customer id. |
| 406 | 406 | */ |
| 407 | - do_action( 'give_customer_pre_attach_payment', $payment_id, $this->id ); |
|
| 407 | + do_action('give_customer_pre_attach_payment', $payment_id, $this->id); |
|
| 408 | 408 | |
| 409 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
| 409 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
| 410 | 410 | |
| 411 | - if ( $payment_added ) { |
|
| 411 | + if ($payment_added) { |
|
| 412 | 412 | |
| 413 | 413 | $this->payment_ids = $new_payment_ids; |
| 414 | 414 | |
| 415 | 415 | // We added this payment successfully, increment the stats |
| 416 | - if ( $update_stats ) { |
|
| 417 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 416 | + if ($update_stats) { |
|
| 417 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 418 | 418 | |
| 419 | - if ( ! empty( $payment_amount ) ) { |
|
| 420 | - $this->increase_value( $payment_amount ); |
|
| 419 | + if ( ! empty($payment_amount)) { |
|
| 420 | + $this->increase_value($payment_amount); |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | $this->increase_purchase_count(); |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | * @param int $payment_id Payment id. |
| 435 | 435 | * @param int $customer_id Customer id. |
| 436 | 436 | */ |
| 437 | - do_action( 'give_customer_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
| 437 | + do_action('give_customer_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
| 438 | 438 | |
| 439 | 439 | return $payment_added; |
| 440 | 440 | } |
@@ -452,33 +452,33 @@ discard block |
||
| 452 | 452 | * |
| 453 | 453 | * @return boolean If the removal was successful. |
| 454 | 454 | */ |
| 455 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
| 455 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
| 456 | 456 | |
| 457 | - if ( empty( $payment_id ) ) { |
|
| 457 | + if (empty($payment_id)) { |
|
| 458 | 458 | return false; |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - $payment = new Give_Payment( $payment_id ); |
|
| 461 | + $payment = new Give_Payment($payment_id); |
|
| 462 | 462 | |
| 463 | - if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { |
|
| 463 | + if ('publish' !== $payment->status && 'revoked' !== $payment->status) { |
|
| 464 | 464 | $update_stats = false; |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | $new_payment_ids = ''; |
| 468 | 468 | |
| 469 | - if ( ! empty( $this->payment_ids ) ) { |
|
| 469 | + if ( ! empty($this->payment_ids)) { |
|
| 470 | 470 | |
| 471 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
| 471 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
| 472 | 472 | |
| 473 | - $pos = array_search( $payment_id, $payment_ids ); |
|
| 474 | - if ( false === $pos ) { |
|
| 473 | + $pos = array_search($payment_id, $payment_ids); |
|
| 474 | + if (false === $pos) { |
|
| 475 | 475 | return false; |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | - unset( $payment_ids[ $pos ] ); |
|
| 479 | - $payment_ids = array_filter( $payment_ids ); |
|
| 478 | + unset($payment_ids[$pos]); |
|
| 479 | + $payment_ids = array_filter($payment_ids); |
|
| 480 | 480 | |
| 481 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
| 481 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
| 482 | 482 | |
| 483 | 483 | } |
| 484 | 484 | |
@@ -490,20 +490,20 @@ discard block |
||
| 490 | 490 | * @param int $payment_id Payment id. |
| 491 | 491 | * @param int $customer_id Customer id. |
| 492 | 492 | */ |
| 493 | - do_action( 'give_customer_pre_remove_payment', $payment_id, $this->id ); |
|
| 493 | + do_action('give_customer_pre_remove_payment', $payment_id, $this->id); |
|
| 494 | 494 | |
| 495 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
| 495 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
| 496 | 496 | |
| 497 | - if ( $payment_removed ) { |
|
| 497 | + if ($payment_removed) { |
|
| 498 | 498 | |
| 499 | 499 | $this->payment_ids = $new_payment_ids; |
| 500 | 500 | |
| 501 | - if ( $update_stats ) { |
|
| 501 | + if ($update_stats) { |
|
| 502 | 502 | // We removed this payment successfully, decrement the stats |
| 503 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 503 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 504 | 504 | |
| 505 | - if ( ! empty( $payment_amount ) ) { |
|
| 506 | - $this->decrease_value( $payment_amount ); |
|
| 505 | + if ( ! empty($payment_amount)) { |
|
| 506 | + $this->decrease_value($payment_amount); |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | $this->decrease_purchase_count(); |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | * @param int $payment_id Payment id. |
| 521 | 521 | * @param int $customer_id Customer id. |
| 522 | 522 | */ |
| 523 | - do_action( 'give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
| 523 | + do_action('give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
| 524 | 524 | |
| 525 | 525 | return $payment_removed; |
| 526 | 526 | |
@@ -536,10 +536,10 @@ discard block |
||
| 536 | 536 | * |
| 537 | 537 | * @return int The donation count. |
| 538 | 538 | */ |
| 539 | - public function increase_purchase_count( $count = 1 ) { |
|
| 539 | + public function increase_purchase_count($count = 1) { |
|
| 540 | 540 | |
| 541 | 541 | // Make sure it's numeric and not negative. |
| 542 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
| 542 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
| 543 | 543 | return false; |
| 544 | 544 | } |
| 545 | 545 | |
@@ -553,9 +553,9 @@ discard block |
||
| 553 | 553 | * @param int $count The number to increase by. |
| 554 | 554 | * @param int $customer_id Customer id. |
| 555 | 555 | */ |
| 556 | - do_action( 'give_customer_pre_increase_purchase_count', $count, $this->id ); |
|
| 556 | + do_action('give_customer_pre_increase_purchase_count', $count, $this->id); |
|
| 557 | 557 | |
| 558 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
| 558 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
| 559 | 559 | $this->purchase_count = $new_total; |
| 560 | 560 | } |
| 561 | 561 | |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | * @param int $count The number increased by. |
| 569 | 569 | * @param int $customer_id Customer id. |
| 570 | 570 | */ |
| 571 | - do_action( 'give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id ); |
|
| 571 | + do_action('give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id); |
|
| 572 | 572 | |
| 573 | 573 | return $this->purchase_count; |
| 574 | 574 | } |
@@ -583,16 +583,16 @@ discard block |
||
| 583 | 583 | * |
| 584 | 584 | * @return mixed If successful, the new count, otherwise false. |
| 585 | 585 | */ |
| 586 | - public function decrease_purchase_count( $count = 1 ) { |
|
| 586 | + public function decrease_purchase_count($count = 1) { |
|
| 587 | 587 | |
| 588 | 588 | // Make sure it's numeric and not negative |
| 589 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
| 589 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
| 590 | 590 | return false; |
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | $new_total = (int) $this->purchase_count - (int) $count; |
| 594 | 594 | |
| 595 | - if ( $new_total < 0 ) { |
|
| 595 | + if ($new_total < 0) { |
|
| 596 | 596 | $new_total = 0; |
| 597 | 597 | } |
| 598 | 598 | |
@@ -604,9 +604,9 @@ discard block |
||
| 604 | 604 | * @param int $count The number to decrease by. |
| 605 | 605 | * @param int $customer_id Customer id. |
| 606 | 606 | */ |
| 607 | - do_action( 'give_customer_pre_decrease_purchase_count', $count, $this->id ); |
|
| 607 | + do_action('give_customer_pre_decrease_purchase_count', $count, $this->id); |
|
| 608 | 608 | |
| 609 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
| 609 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
| 610 | 610 | $this->purchase_count = $new_total; |
| 611 | 611 | } |
| 612 | 612 | |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | * @param int $count The number decreased by. |
| 620 | 620 | * @param int $customer_id Customer id. |
| 621 | 621 | */ |
| 622 | - do_action( 'give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id ); |
|
| 622 | + do_action('give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id); |
|
| 623 | 623 | |
| 624 | 624 | return $this->purchase_count; |
| 625 | 625 | } |
@@ -634,9 +634,9 @@ discard block |
||
| 634 | 634 | * |
| 635 | 635 | * @return mixed If successful, the new value, otherwise false. |
| 636 | 636 | */ |
| 637 | - public function increase_value( $value = 0.00 ) { |
|
| 637 | + public function increase_value($value = 0.00) { |
|
| 638 | 638 | |
| 639 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
| 639 | + $new_value = floatval($this->purchase_value) + $value; |
|
| 640 | 640 | |
| 641 | 641 | /** |
| 642 | 642 | * Fires before increasing customer lifetime value. |
@@ -646,9 +646,9 @@ discard block |
||
| 646 | 646 | * @param float $value The value to increase by. |
| 647 | 647 | * @param int $customer_id Customer id. |
| 648 | 648 | */ |
| 649 | - do_action( 'give_customer_pre_increase_value', $value, $this->id ); |
|
| 649 | + do_action('give_customer_pre_increase_value', $value, $this->id); |
|
| 650 | 650 | |
| 651 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
| 651 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
| 652 | 652 | $this->purchase_value = $new_value; |
| 653 | 653 | } |
| 654 | 654 | |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | * @param float $value The value increased by. |
| 662 | 662 | * @param int $customer_id Customer id. |
| 663 | 663 | */ |
| 664 | - do_action( 'give_customer_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
| 664 | + do_action('give_customer_post_increase_value', $this->purchase_value, $value, $this->id); |
|
| 665 | 665 | |
| 666 | 666 | return $this->purchase_value; |
| 667 | 667 | } |
@@ -676,11 +676,11 @@ discard block |
||
| 676 | 676 | * |
| 677 | 677 | * @return mixed If successful, the new value, otherwise false. |
| 678 | 678 | */ |
| 679 | - public function decrease_value( $value = 0.00 ) { |
|
| 679 | + public function decrease_value($value = 0.00) { |
|
| 680 | 680 | |
| 681 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
| 681 | + $new_value = floatval($this->purchase_value) - $value; |
|
| 682 | 682 | |
| 683 | - if ( $new_value < 0 ) { |
|
| 683 | + if ($new_value < 0) { |
|
| 684 | 684 | $new_value = 0.00; |
| 685 | 685 | } |
| 686 | 686 | |
@@ -692,9 +692,9 @@ discard block |
||
| 692 | 692 | * @param float $value The value to decrease by. |
| 693 | 693 | * @param int $customer_id Customer id. |
| 694 | 694 | */ |
| 695 | - do_action( 'give_customer_pre_decrease_value', $value, $this->id ); |
|
| 695 | + do_action('give_customer_pre_decrease_value', $value, $this->id); |
|
| 696 | 696 | |
| 697 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
| 697 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
| 698 | 698 | $this->purchase_value = $new_value; |
| 699 | 699 | } |
| 700 | 700 | |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | * @param float $value The value decreased by. |
| 708 | 708 | * @param int $customer_id Customer id. |
| 709 | 709 | */ |
| 710 | - do_action( 'give_customer_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
| 710 | + do_action('give_customer_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
| 711 | 711 | |
| 712 | 712 | return $this->purchase_value; |
| 713 | 713 | } |
@@ -726,7 +726,7 @@ discard block |
||
| 726 | 726 | * |
| 727 | 727 | * @return mixed If successful, the new donation stat value, otherwise false. |
| 728 | 728 | */ |
| 729 | - public function update_donation_value( $curr_amount, $new_amount ) { |
|
| 729 | + public function update_donation_value($curr_amount, $new_amount) { |
|
| 730 | 730 | /** |
| 731 | 731 | * Payment total difference value can be: |
| 732 | 732 | * zero (in case amount not change) |
@@ -736,13 +736,13 @@ discard block |
||
| 736 | 736 | $payment_total_diff = $new_amount - $curr_amount; |
| 737 | 737 | |
| 738 | 738 | // We do not need to update donation stat if donation did not change. |
| 739 | - if( ! $payment_total_diff ) { |
|
| 739 | + if ( ! $payment_total_diff) { |
|
| 740 | 740 | return false; |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | |
| 744 | - if( $payment_total_diff > 0 ) { |
|
| 745 | - $this->increase_value( $payment_total_diff ); |
|
| 744 | + if ($payment_total_diff > 0) { |
|
| 745 | + $this->increase_value($payment_total_diff); |
|
| 746 | 746 | } else { |
| 747 | 747 | // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
| 748 | 748 | $this->decrease_value( -$payment_total_diff ); |
@@ -762,15 +762,15 @@ discard block |
||
| 762 | 762 | * |
| 763 | 763 | * @return array The notes requested. |
| 764 | 764 | */ |
| 765 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
| 765 | + public function get_notes($length = 20, $paged = 1) { |
|
| 766 | 766 | |
| 767 | - $length = is_numeric( $length ) ? $length : 20; |
|
| 768 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
| 767 | + $length = is_numeric($length) ? $length : 20; |
|
| 768 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
| 769 | 769 | |
| 770 | 770 | $all_notes = $this->get_raw_notes(); |
| 771 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
| 771 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
| 772 | 772 | |
| 773 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
| 773 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
| 774 | 774 | |
| 775 | 775 | return $desired_notes; |
| 776 | 776 | |
@@ -787,9 +787,9 @@ discard block |
||
| 787 | 787 | public function get_notes_count() { |
| 788 | 788 | |
| 789 | 789 | $all_notes = $this->get_raw_notes(); |
| 790 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
| 790 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
| 791 | 791 | |
| 792 | - return count( $notes_array ); |
|
| 792 | + return count($notes_array); |
|
| 793 | 793 | |
| 794 | 794 | } |
| 795 | 795 | |
@@ -803,22 +803,22 @@ discard block |
||
| 803 | 803 | * |
| 804 | 804 | * @return string|boolean The new note if added successfully, false otherwise. |
| 805 | 805 | */ |
| 806 | - public function add_note( $note = '' ) { |
|
| 806 | + public function add_note($note = '') { |
|
| 807 | 807 | |
| 808 | - $note = trim( $note ); |
|
| 809 | - if ( empty( $note ) ) { |
|
| 808 | + $note = trim($note); |
|
| 809 | + if (empty($note)) { |
|
| 810 | 810 | return false; |
| 811 | 811 | } |
| 812 | 812 | |
| 813 | 813 | $notes = $this->get_raw_notes(); |
| 814 | 814 | |
| 815 | - if ( empty( $notes ) ) { |
|
| 815 | + if (empty($notes)) { |
|
| 816 | 816 | $notes = ''; |
| 817 | 817 | } |
| 818 | 818 | |
| 819 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
| 820 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
| 821 | - $notes .= "\n\n" . $new_note; |
|
| 819 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
| 820 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
| 821 | + $notes .= "\n\n".$new_note; |
|
| 822 | 822 | |
| 823 | 823 | /** |
| 824 | 824 | * Fires before customer note added. |
@@ -828,11 +828,11 @@ discard block |
||
| 828 | 828 | * @param string $new_note New note to add. |
| 829 | 829 | * @param int $customer_id Customer id. |
| 830 | 830 | */ |
| 831 | - do_action( 'give_customer_pre_add_note', $new_note, $this->id ); |
|
| 831 | + do_action('give_customer_pre_add_note', $new_note, $this->id); |
|
| 832 | 832 | |
| 833 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
| 833 | + $updated = $this->update(array('notes' => $notes)); |
|
| 834 | 834 | |
| 835 | - if ( $updated ) { |
|
| 835 | + if ($updated) { |
|
| 836 | 836 | $this->notes = $this->get_notes(); |
| 837 | 837 | } |
| 838 | 838 | |
@@ -845,7 +845,7 @@ discard block |
||
| 845 | 845 | * @param string $new_note New note added. |
| 846 | 846 | * @param int $customer_id Customer id. |
| 847 | 847 | */ |
| 848 | - do_action( 'give_customer_post_add_note', $this->notes, $new_note, $this->id ); |
|
| 848 | + do_action('give_customer_post_add_note', $this->notes, $new_note, $this->id); |
|
| 849 | 849 | |
| 850 | 850 | // Return the formatted note, so we can test, as well as update any displays |
| 851 | 851 | return $new_note; |
@@ -862,7 +862,7 @@ discard block |
||
| 862 | 862 | */ |
| 863 | 863 | private function get_raw_notes() { |
| 864 | 864 | |
| 865 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
| 865 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
| 866 | 866 | |
| 867 | 867 | return $all_notes; |
| 868 | 868 | |
@@ -879,8 +879,8 @@ discard block |
||
| 879 | 879 | * |
| 880 | 880 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
| 881 | 881 | */ |
| 882 | - public function get_meta( $meta_key = '', $single = true ) { |
|
| 883 | - return Give()->customer_meta->get_meta( $this->id, $meta_key, $single ); |
|
| 882 | + public function get_meta($meta_key = '', $single = true) { |
|
| 883 | + return Give()->customer_meta->get_meta($this->id, $meta_key, $single); |
|
| 884 | 884 | } |
| 885 | 885 | |
| 886 | 886 | /** |
@@ -895,8 +895,8 @@ discard block |
||
| 895 | 895 | * |
| 896 | 896 | * @return bool False for failure. True for success. |
| 897 | 897 | */ |
| 898 | - public function add_meta( $meta_key = '', $meta_value, $unique = false ) { |
|
| 899 | - return Give()->customer_meta->add_meta( $this->id, $meta_key, $meta_value, $unique ); |
|
| 898 | + public function add_meta($meta_key = '', $meta_value, $unique = false) { |
|
| 899 | + return Give()->customer_meta->add_meta($this->id, $meta_key, $meta_value, $unique); |
|
| 900 | 900 | } |
| 901 | 901 | |
| 902 | 902 | /** |
@@ -911,8 +911,8 @@ discard block |
||
| 911 | 911 | * |
| 912 | 912 | * @return bool False on failure, true if success. |
| 913 | 913 | */ |
| 914 | - public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) { |
|
| 915 | - return Give()->customer_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value ); |
|
| 914 | + public function update_meta($meta_key = '', $meta_value, $prev_value = '') { |
|
| 915 | + return Give()->customer_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value); |
|
| 916 | 916 | } |
| 917 | 917 | |
| 918 | 918 | /** |
@@ -926,8 +926,8 @@ discard block |
||
| 926 | 926 | * |
| 927 | 927 | * @return bool False for failure. True for success. |
| 928 | 928 | */ |
| 929 | - public function delete_meta( $meta_key = '', $meta_value = '' ) { |
|
| 930 | - return Give()->customer_meta->delete_meta( $this->id, $meta_key, $meta_value ); |
|
| 929 | + public function delete_meta($meta_key = '', $meta_value = '') { |
|
| 930 | + return Give()->customer_meta->delete_meta($this->id, $meta_key, $meta_value); |
|
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | /** |
@@ -940,51 +940,51 @@ discard block |
||
| 940 | 940 | * |
| 941 | 941 | * @return array The sanitized data, based off column defaults. |
| 942 | 942 | */ |
| 943 | - private function sanitize_columns( $data ) { |
|
| 943 | + private function sanitize_columns($data) { |
|
| 944 | 944 | |
| 945 | 945 | $columns = $this->db->get_columns(); |
| 946 | 946 | $default_values = $this->db->get_column_defaults(); |
| 947 | 947 | |
| 948 | - foreach ( $columns as $key => $type ) { |
|
| 948 | + foreach ($columns as $key => $type) { |
|
| 949 | 949 | |
| 950 | 950 | // Only sanitize data that we were provided |
| 951 | - if ( ! array_key_exists( $key, $data ) ) { |
|
| 951 | + if ( ! array_key_exists($key, $data)) { |
|
| 952 | 952 | continue; |
| 953 | 953 | } |
| 954 | 954 | |
| 955 | - switch ( $type ) { |
|
| 955 | + switch ($type) { |
|
| 956 | 956 | |
| 957 | 957 | case '%s': |
| 958 | - if ( 'email' == $key ) { |
|
| 959 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
| 960 | - } elseif ( 'notes' == $key ) { |
|
| 961 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
| 958 | + if ('email' == $key) { |
|
| 959 | + $data[$key] = sanitize_email($data[$key]); |
|
| 960 | + } elseif ('notes' == $key) { |
|
| 961 | + $data[$key] = strip_tags($data[$key]); |
|
| 962 | 962 | } else { |
| 963 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
| 963 | + $data[$key] = sanitize_text_field($data[$key]); |
|
| 964 | 964 | } |
| 965 | 965 | break; |
| 966 | 966 | |
| 967 | 967 | case '%d': |
| 968 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
| 969 | - $data[ $key ] = $default_values[ $key ]; |
|
| 968 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
| 969 | + $data[$key] = $default_values[$key]; |
|
| 970 | 970 | } else { |
| 971 | - $data[ $key ] = absint( $data[ $key ] ); |
|
| 971 | + $data[$key] = absint($data[$key]); |
|
| 972 | 972 | } |
| 973 | 973 | break; |
| 974 | 974 | |
| 975 | 975 | case '%f': |
| 976 | 976 | // Convert what was given to a float |
| 977 | - $value = floatval( $data[ $key ] ); |
|
| 977 | + $value = floatval($data[$key]); |
|
| 978 | 978 | |
| 979 | - if ( ! is_float( $value ) ) { |
|
| 980 | - $data[ $key ] = $default_values[ $key ]; |
|
| 979 | + if ( ! is_float($value)) { |
|
| 980 | + $data[$key] = $default_values[$key]; |
|
| 981 | 981 | } else { |
| 982 | - $data[ $key ] = $value; |
|
| 982 | + $data[$key] = $value; |
|
| 983 | 983 | } |
| 984 | 984 | break; |
| 985 | 985 | |
| 986 | 986 | default: |
| 987 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
| 987 | + $data[$key] = sanitize_text_field($data[$key]); |
|
| 988 | 988 | break; |
| 989 | 989 | |
| 990 | 990 | } |
@@ -1002,33 +1002,33 @@ discard block |
||
| 1002 | 1002 | * @param bool $primary Allows setting the email added as the primary |
| 1003 | 1003 | * @return bool If the email was added successfully |
| 1004 | 1004 | */ |
| 1005 | - public function add_email( $email = '', $primary = false ) { |
|
| 1006 | - if( ! is_email( $email ) ) { |
|
| 1005 | + public function add_email($email = '', $primary = false) { |
|
| 1006 | + if ( ! is_email($email)) { |
|
| 1007 | 1007 | return false; |
| 1008 | 1008 | } |
| 1009 | - $existing = new Give_Customer( $email ); |
|
| 1009 | + $existing = new Give_Customer($email); |
|
| 1010 | 1010 | |
| 1011 | - if( $existing->id > 0 ) { |
|
| 1011 | + if ($existing->id > 0) { |
|
| 1012 | 1012 | // Email address already belongs to another customer |
| 1013 | 1013 | return false; |
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | - if ( email_exists( $email ) ) { |
|
| 1017 | - $user = get_user_by( 'email', $email ); |
|
| 1018 | - if ( $user->ID != $this->user_id ) { |
|
| 1016 | + if (email_exists($email)) { |
|
| 1017 | + $user = get_user_by('email', $email); |
|
| 1018 | + if ($user->ID != $this->user_id) { |
|
| 1019 | 1019 | return false; |
| 1020 | 1020 | } |
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | - do_action( 'give_donor_pre_add_email', $email, $this->id, $this ); |
|
| 1023 | + do_action('give_donor_pre_add_email', $email, $this->id, $this); |
|
| 1024 | 1024 | |
| 1025 | 1025 | // Add is used to ensure duplicate emails are not added |
| 1026 | - $ret = (bool) $this->add_meta( 'additional_email', $email ); |
|
| 1026 | + $ret = (bool) $this->add_meta('additional_email', $email); |
|
| 1027 | 1027 | |
| 1028 | - do_action( 'give_donor_post_add_email', $email, $this->id, $this ); |
|
| 1028 | + do_action('give_donor_post_add_email', $email, $this->id, $this); |
|
| 1029 | 1029 | |
| 1030 | - if ( $ret && true === $primary ) { |
|
| 1031 | - $this->set_primary_email( $email ); |
|
| 1030 | + if ($ret && true === $primary) { |
|
| 1031 | + $this->set_primary_email($email); |
|
| 1032 | 1032 | } |
| 1033 | 1033 | |
| 1034 | 1034 | return $ret; |
@@ -1042,16 +1042,16 @@ discard block |
||
| 1042 | 1042 | * @param string $email The email address to remove from the customer |
| 1043 | 1043 | * @return bool If the email was removeed successfully |
| 1044 | 1044 | */ |
| 1045 | - public function remove_email( $email = '' ) { |
|
| 1046 | - if( ! is_email( $email ) ) { |
|
| 1045 | + public function remove_email($email = '') { |
|
| 1046 | + if ( ! is_email($email)) { |
|
| 1047 | 1047 | return false; |
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | - do_action( 'give_donor_pre_remove_email', $email, $this->id, $this ); |
|
| 1050 | + do_action('give_donor_pre_remove_email', $email, $this->id, $this); |
|
| 1051 | 1051 | |
| 1052 | - $ret = (bool) $this->delete_meta( 'additional_email', $email ); |
|
| 1052 | + $ret = (bool) $this->delete_meta('additional_email', $email); |
|
| 1053 | 1053 | |
| 1054 | - do_action( 'give_donor_post_remove_email', $email, $this->id, $this ); |
|
| 1054 | + do_action('give_donor_post_remove_email', $email, $this->id, $this); |
|
| 1055 | 1055 | |
| 1056 | 1056 | return $ret; |
| 1057 | 1057 | } |
@@ -1065,16 +1065,16 @@ discard block |
||
| 1065 | 1065 | * @param string $new_primary_email The email address to remove from the customer |
| 1066 | 1066 | * @return bool If the email was set as primary successfully |
| 1067 | 1067 | */ |
| 1068 | - public function set_primary_email( $new_primary_email = '' ) { |
|
| 1069 | - if( ! is_email( $new_primary_email ) ) { |
|
| 1068 | + public function set_primary_email($new_primary_email = '') { |
|
| 1069 | + if ( ! is_email($new_primary_email)) { |
|
| 1070 | 1070 | return false; |
| 1071 | 1071 | } |
| 1072 | 1072 | |
| 1073 | - do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this ); |
|
| 1073 | + do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this); |
|
| 1074 | 1074 | |
| 1075 | - $existing = new Give_Customer( $new_primary_email ); |
|
| 1075 | + $existing = new Give_Customer($new_primary_email); |
|
| 1076 | 1076 | |
| 1077 | - if( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) { |
|
| 1077 | + if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) { |
|
| 1078 | 1078 | // This email belongs to another customer |
| 1079 | 1079 | return false; |
| 1080 | 1080 | } |
@@ -1082,21 +1082,21 @@ discard block |
||
| 1082 | 1082 | $old_email = $this->email; |
| 1083 | 1083 | |
| 1084 | 1084 | // Update customer record with new email |
| 1085 | - $update = $this->update( array( 'email' => $new_primary_email ) ); |
|
| 1085 | + $update = $this->update(array('email' => $new_primary_email)); |
|
| 1086 | 1086 | |
| 1087 | 1087 | // Remove new primary from list of additional emails |
| 1088 | - $remove = $this->remove_email( $new_primary_email ); |
|
| 1088 | + $remove = $this->remove_email($new_primary_email); |
|
| 1089 | 1089 | |
| 1090 | 1090 | // Add old email to additional emails list |
| 1091 | - $add = $this->add_email( $old_email ); |
|
| 1091 | + $add = $this->add_email($old_email); |
|
| 1092 | 1092 | |
| 1093 | 1093 | $ret = $update && $remove && $add; |
| 1094 | 1094 | |
| 1095 | - if( $ret ) { |
|
| 1095 | + if ($ret) { |
|
| 1096 | 1096 | $this->email = $new_primary_email; |
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | - do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this ); |
|
| 1099 | + do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this); |
|
| 1100 | 1100 | |
| 1101 | 1101 | return $ret; |
| 1102 | 1102 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @param array $args An array of form arguments. |
| 23 | 23 | * |
| 24 | - * @return string Donation form. |
|
| 24 | + * @return false|null Donation form. |
|
| 25 | 25 | */ |
| 26 | 26 | function give_get_donation_form( $args = array() ) { |
| 27 | 27 | |
@@ -1359,7 +1359,7 @@ discard block |
||
| 1359 | 1359 | * |
| 1360 | 1360 | * @param int $form_id The form ID. |
| 1361 | 1361 | * |
| 1362 | - * @return void|bool |
|
| 1362 | + * @return false|null |
|
| 1363 | 1363 | */ |
| 1364 | 1364 | function give_terms_agreement( $form_id ) { |
| 1365 | 1365 | $form_option = get_post_meta( $form_id, '_give_terms_option', true ); |
@@ -1552,7 +1552,7 @@ discard block |
||
| 1552 | 1552 | * @param int $form_id The form ID. |
| 1553 | 1553 | * @param array $args An array of form arguments. |
| 1554 | 1554 | * |
| 1555 | - * @return mixed |
|
| 1555 | + * @return boolean |
|
| 1556 | 1556 | */ |
| 1557 | 1557 | function give_show_goal_progress( $form_id, $args ) { |
| 1558 | 1558 | |
@@ -1033,9 +1033,12 @@ |
||
| 1033 | 1033 | } |
| 1034 | 1034 | ?> |
| 1035 | 1035 | </select> |
| 1036 | - <?php else : ?> |
|
| 1036 | + <?php else { |
|
| 1037 | + : ?> |
|
| 1037 | 1038 | <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" |
| 1038 | - placeholder="<?php esc_attr_e( 'State / Province', 'give' ); ?>"/> |
|
| 1039 | + placeholder="<?php esc_attr_e( 'State / Province', 'give' ); |
|
| 1040 | +} |
|
| 1041 | +?>"/> |
|
| 1039 | 1042 | <?php endif; ?> |
| 1040 | 1043 | </p> |
| 1041 | 1044 | <?php |
@@ -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 | |
@@ -23,50 +23,50 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return string Donation form. |
| 25 | 25 | */ |
| 26 | -function give_get_donation_form( $args = array() ) { |
|
| 26 | +function give_get_donation_form($args = array()) { |
|
| 27 | 27 | |
| 28 | 28 | global $post; |
| 29 | 29 | |
| 30 | - $form_id = is_object( $post ) ? $post->ID : 0; |
|
| 30 | + $form_id = is_object($post) ? $post->ID : 0; |
|
| 31 | 31 | |
| 32 | - if ( isset( $args['id'] ) ) { |
|
| 32 | + if (isset($args['id'])) { |
|
| 33 | 33 | $form_id = $args['id']; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - $defaults = apply_filters( 'give_form_args_defaults', array( |
|
| 36 | + $defaults = apply_filters('give_form_args_defaults', array( |
|
| 37 | 37 | 'form_id' => $form_id, |
| 38 | - ) ); |
|
| 38 | + )); |
|
| 39 | 39 | |
| 40 | - $args = wp_parse_args( $args, $defaults ); |
|
| 40 | + $args = wp_parse_args($args, $defaults); |
|
| 41 | 41 | |
| 42 | - $form = new Give_Donate_Form( $args['form_id'] ); |
|
| 42 | + $form = new Give_Donate_Form($args['form_id']); |
|
| 43 | 43 | |
| 44 | 44 | //bail if no form ID. |
| 45 | - if ( empty( $form->ID ) ) { |
|
| 45 | + if (empty($form->ID)) { |
|
| 46 | 46 | return false; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - $payment_mode = give_get_chosen_gateway( $form->ID ); |
|
| 49 | + $payment_mode = give_get_chosen_gateway($form->ID); |
|
| 50 | 50 | |
| 51 | - $form_action = add_query_arg( apply_filters( 'give_form_action_args', array( |
|
| 51 | + $form_action = add_query_arg(apply_filters('give_form_action_args', array( |
|
| 52 | 52 | 'payment-mode' => $payment_mode, |
| 53 | - ) ), |
|
| 53 | + )), |
|
| 54 | 54 | give_get_current_page_url() |
| 55 | 55 | ); |
| 56 | 56 | |
| 57 | 57 | //Sanity Check: Donation form not published or user doesn't have permission to view drafts. |
| 58 | 58 | if ( |
| 59 | - ( 'publish' !== $form->post_status && ! current_user_can( 'edit_give_forms', $form->ID ) ) |
|
| 60 | - || ( 'trash' === $form->post_status ) |
|
| 59 | + ('publish' !== $form->post_status && ! current_user_can('edit_give_forms', $form->ID)) |
|
| 60 | + || ('trash' === $form->post_status) |
|
| 61 | 61 | ) { |
| 62 | 62 | return false; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | //Get the form wrap CSS classes. |
| 66 | - $form_wrap_classes = $form->get_form_wrap_classes( $args ); |
|
| 66 | + $form_wrap_classes = $form->get_form_wrap_classes($args); |
|
| 67 | 67 | |
| 68 | 68 | //Get the <form> tag wrap CSS classes. |
| 69 | - $form_classes = $form->get_form_classes( $args ); |
|
| 69 | + $form_classes = $form->get_form_classes($args); |
|
| 70 | 70 | |
| 71 | 71 | ob_start(); |
| 72 | 72 | |
@@ -78,23 +78,23 @@ discard block |
||
| 78 | 78 | * @param int $form_id The form ID. |
| 79 | 79 | * @param array $args An array of form arguments. |
| 80 | 80 | */ |
| 81 | - do_action( 'give_pre_form_output', $form->ID, $args ); |
|
| 81 | + do_action('give_pre_form_output', $form->ID, $args); |
|
| 82 | 82 | |
| 83 | 83 | ?> |
| 84 | 84 | <div id="give-form-<?php echo $form->ID; ?>-wrap" class="<?php echo $form_wrap_classes; ?>"> |
| 85 | 85 | |
| 86 | - <?php if ( $form->is_close_donation_form() ) { |
|
| 86 | + <?php if ($form->is_close_donation_form()) { |
|
| 87 | 87 | |
| 88 | 88 | //Get Goal thank you message. |
| 89 | - $display_thankyou_message = get_post_meta( $form->ID, '_give_form_goal_achieved_message', true ); |
|
| 90 | - $display_thankyou_message = ! empty( $display_thankyou_message ) ? $display_thankyou_message : esc_html__( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ); |
|
| 89 | + $display_thankyou_message = get_post_meta($form->ID, '_give_form_goal_achieved_message', true); |
|
| 90 | + $display_thankyou_message = ! empty($display_thankyou_message) ? $display_thankyou_message : esc_html__('Thank you to all our donors, we have met our fundraising goal.', 'give'); |
|
| 91 | 91 | |
| 92 | 92 | //Print thank you message. |
| 93 | - apply_filters( 'give_goal_closed_output', give_output_error( $display_thankyou_message, true, 'success' ) ); |
|
| 93 | + apply_filters('give_goal_closed_output', give_output_error($display_thankyou_message, true, 'success')); |
|
| 94 | 94 | |
| 95 | 95 | } else { |
| 96 | 96 | |
| 97 | - if ( isset( $args['show_title'] ) && $args['show_title'] == true ) { |
|
| 97 | + if (isset($args['show_title']) && $args['show_title'] == true) { |
|
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * Filter the title |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @param int $form_id |
| 105 | 105 | * @param Give_Donate_Form $form |
| 106 | 106 | */ |
| 107 | - echo apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>', $form_id, $form ); |
|
| 107 | + echo apply_filters('give_form_title', '<h2 class="give-form-title">'.get_the_title($form_id).'</h2>', $form_id, $form); |
|
| 108 | 108 | |
| 109 | 109 | } |
| 110 | 110 | |
@@ -116,19 +116,19 @@ discard block |
||
| 116 | 116 | * @param int $form_id The form ID. |
| 117 | 117 | * @param array $args An array of form arguments. |
| 118 | 118 | */ |
| 119 | - do_action( 'give_pre_form', $form->ID, $args ); |
|
| 119 | + do_action('give_pre_form', $form->ID, $args); |
|
| 120 | 120 | ?> |
| 121 | 121 | |
| 122 | 122 | <form id="give-form-<?php echo $form_id; ?>" class="<?php echo $form_classes; ?>" |
| 123 | - action="<?php echo esc_url_raw( $form_action ); ?>" method="post"> |
|
| 123 | + action="<?php echo esc_url_raw($form_action); ?>" method="post"> |
|
| 124 | 124 | <input type="hidden" name="give-form-id" value="<?php echo $form->ID; ?>"/> |
| 125 | - <input type="hidden" name="give-form-title" value="<?php echo htmlentities( $form->post_title ); ?>"/> |
|
| 125 | + <input type="hidden" name="give-form-title" value="<?php echo htmlentities($form->post_title); ?>"/> |
|
| 126 | 126 | <input type="hidden" name="give-current-url" |
| 127 | - value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
| 127 | + value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
| 128 | 128 | <input type="hidden" name="give-form-url" |
| 129 | - value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
| 129 | + value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
| 130 | 130 | <input type="hidden" name="give-form-minimum" |
| 131 | - value="<?php echo give_format_amount( give_get_form_minimum_price( $form->ID ) ); ?>"/> |
|
| 131 | + value="<?php echo give_format_amount(give_get_form_minimum_price($form->ID)); ?>"/> |
|
| 132 | 132 | |
| 133 | 133 | <!-- The following field is for robots only, invisible to humans: --> |
| 134 | 134 | <span class="give-hidden" style="display: none !important;"> |
@@ -140,13 +140,13 @@ discard block |
||
| 140 | 140 | <?php |
| 141 | 141 | |
| 142 | 142 | //Price ID hidden field for variable (mult-level) donation forms. |
| 143 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 143 | + if (give_has_variable_prices($form_id)) { |
|
| 144 | 144 | //get default selected price ID. |
| 145 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
| 145 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
| 146 | 146 | $price_id = 0; |
| 147 | 147 | //loop through prices. |
| 148 | - foreach ( $prices as $price ) { |
|
| 149 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
| 148 | + foreach ($prices as $price) { |
|
| 149 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
| 150 | 150 | $price_id = $price['_give_id']['level_id']; |
| 151 | 151 | }; |
| 152 | 152 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * @param int $form_id The form ID. |
| 163 | 163 | * @param array $args An array of form arguments. |
| 164 | 164 | */ |
| 165 | - do_action( 'give_checkout_form_top', $form->ID, $args ); |
|
| 165 | + do_action('give_checkout_form_top', $form->ID, $args); |
|
| 166 | 166 | |
| 167 | 167 | /** |
| 168 | 168 | * Fires while outputing donation form, for payment gatways fields. |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * @param int $form_id The form ID. |
| 173 | 173 | * @param array $args An array of form arguments. |
| 174 | 174 | */ |
| 175 | - do_action( 'give_payment_mode_select', $form->ID, $args ); |
|
| 175 | + do_action('give_payment_mode_select', $form->ID, $args); |
|
| 176 | 176 | |
| 177 | 177 | /** |
| 178 | 178 | * Fires while outputing donation form, after all other fields. |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * @param int $form_id The form ID. |
| 183 | 183 | * @param array $args An array of form arguments. |
| 184 | 184 | */ |
| 185 | - do_action( 'give_checkout_form_bottom', $form->ID, $args ); |
|
| 185 | + do_action('give_checkout_form_bottom', $form->ID, $args); |
|
| 186 | 186 | |
| 187 | 187 | ?> |
| 188 | 188 | </form> |
@@ -196,12 +196,12 @@ discard block |
||
| 196 | 196 | * @param int $form_id The form ID. |
| 197 | 197 | * @param array $args An array of form arguments. |
| 198 | 198 | */ |
| 199 | - do_action( 'give_post_form', $form->ID, $args ); |
|
| 199 | + do_action('give_post_form', $form->ID, $args); |
|
| 200 | 200 | |
| 201 | 201 | } |
| 202 | 202 | ?> |
| 203 | 203 | |
| 204 | - </div><!--end #give-form-<?php echo absint( $form->ID ); ?>--> |
|
| 204 | + </div><!--end #give-form-<?php echo absint($form->ID); ?>--> |
|
| 205 | 205 | <?php |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -212,11 +212,11 @@ discard block |
||
| 212 | 212 | * @param int $form_id The form ID. |
| 213 | 213 | * @param array $args An array of form arguments. |
| 214 | 214 | */ |
| 215 | - do_action( 'give_post_form_output', $form->ID, $args ); |
|
| 215 | + do_action('give_post_form_output', $form->ID, $args); |
|
| 216 | 216 | |
| 217 | 217 | $final_output = ob_get_clean(); |
| 218 | 218 | |
| 219 | - echo apply_filters( 'give_donate_form', $final_output, $args ); |
|
| 219 | + echo apply_filters('give_donate_form', $final_output, $args); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | /** |
@@ -233,11 +233,11 @@ discard block |
||
| 233 | 233 | * |
| 234 | 234 | * @return string |
| 235 | 235 | */ |
| 236 | -function give_show_purchase_form( $form_id ) { |
|
| 236 | +function give_show_purchase_form($form_id) { |
|
| 237 | 237 | |
| 238 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
| 238 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
| 239 | 239 | |
| 240 | - if ( ! isset( $form_id ) && isset( $_POST['give_form_id'] ) ) { |
|
| 240 | + if ( ! isset($form_id) && isset($_POST['give_form_id'])) { |
|
| 241 | 241 | $form_id = $_POST['give_form_id']; |
| 242 | 242 | } |
| 243 | 243 | |
@@ -246,33 +246,33 @@ discard block |
||
| 246 | 246 | * |
| 247 | 247 | * @since 1.7 |
| 248 | 248 | */ |
| 249 | - do_action( 'give_donation_form_top', $form_id ); |
|
| 249 | + do_action('give_donation_form_top', $form_id); |
|
| 250 | 250 | |
| 251 | - if ( give_can_checkout() && isset( $form_id ) ) { |
|
| 251 | + if (give_can_checkout() && isset($form_id)) { |
|
| 252 | 252 | |
| 253 | 253 | /** |
| 254 | 254 | * Fires while displaying donation form, before registration login. |
| 255 | 255 | * |
| 256 | 256 | * @since 1.7 |
| 257 | 257 | */ |
| 258 | - do_action( 'give_donation_form_before_register_login', $form_id ); |
|
| 258 | + do_action('give_donation_form_before_register_login', $form_id); |
|
| 259 | 259 | |
| 260 | 260 | /** |
| 261 | 261 | * Fire when register/login form fields render. |
| 262 | 262 | * |
| 263 | 263 | * @since 1.7 |
| 264 | 264 | */ |
| 265 | - do_action( 'give_donation_form_register_login_fields', $form_id ); |
|
| 265 | + do_action('give_donation_form_register_login_fields', $form_id); |
|
| 266 | 266 | |
| 267 | 267 | /** |
| 268 | 268 | * Fire when credit card form fields render. |
| 269 | 269 | * |
| 270 | 270 | * @since 1.7 |
| 271 | 271 | */ |
| 272 | - do_action( 'give_donation_form_before_cc_form', $form_id ); |
|
| 272 | + do_action('give_donation_form_before_cc_form', $form_id); |
|
| 273 | 273 | |
| 274 | 274 | // Load the credit card form and allow gateways to load their own if they wish. |
| 275 | - if ( has_action( 'give_' . $payment_mode . '_cc_form' ) ) { |
|
| 275 | + if (has_action('give_'.$payment_mode.'_cc_form')) { |
|
| 276 | 276 | /** |
| 277 | 277 | * Fires while displaying donation form, credit card form fields for a given gateway. |
| 278 | 278 | * |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | * |
| 281 | 281 | * @param int $form_id The form ID. |
| 282 | 282 | */ |
| 283 | - do_action( "give_{$payment_mode}_cc_form", $form_id ); |
|
| 283 | + do_action("give_{$payment_mode}_cc_form", $form_id); |
|
| 284 | 284 | } else { |
| 285 | 285 | /** |
| 286 | 286 | * Fires while displaying donation form, credit card form fields. |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | * |
| 290 | 290 | * @param int $form_id The form ID. |
| 291 | 291 | */ |
| 292 | - do_action( 'give_cc_form', $form_id ); |
|
| 292 | + do_action('give_cc_form', $form_id); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | * |
| 298 | 298 | * @since 1.7 |
| 299 | 299 | */ |
| 300 | - do_action( 'give_donation_form_after_cc_form', $form_id ); |
|
| 300 | + do_action('give_donation_form_after_cc_form', $form_id); |
|
| 301 | 301 | |
| 302 | 302 | } else { |
| 303 | 303 | /** |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | * |
| 306 | 306 | * @since 1.7 |
| 307 | 307 | */ |
| 308 | - do_action( 'give_donation_form_no_access', $form_id ); |
|
| 308 | + do_action('give_donation_form_no_access', $form_id); |
|
| 309 | 309 | |
| 310 | 310 | } |
| 311 | 311 | |
@@ -314,10 +314,10 @@ discard block |
||
| 314 | 314 | * |
| 315 | 315 | * @since 1.7 |
| 316 | 316 | */ |
| 317 | - do_action( 'give_donation_form_bottom', $form_id ); |
|
| 317 | + do_action('give_donation_form_bottom', $form_id); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | -add_action( 'give_donation_form', 'give_show_purchase_form' ); |
|
| 320 | +add_action('give_donation_form', 'give_show_purchase_form'); |
|
| 321 | 321 | |
| 322 | 322 | /** |
| 323 | 323 | * Give Show Login/Register Form Fields. |
@@ -328,11 +328,11 @@ discard block |
||
| 328 | 328 | * |
| 329 | 329 | * @return void |
| 330 | 330 | */ |
| 331 | -function give_show_register_login_fields( $form_id ) { |
|
| 331 | +function give_show_register_login_fields($form_id) { |
|
| 332 | 332 | |
| 333 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
| 333 | + $show_register_form = give_show_login_register_option($form_id); |
|
| 334 | 334 | |
| 335 | - if ( ( $show_register_form === 'registration' || ( $show_register_form === 'both' && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
| 335 | + if (($show_register_form === 'registration' || ($show_register_form === 'both' && ! isset($_GET['login']))) && ! is_user_logged_in()) : |
|
| 336 | 336 | ?> |
| 337 | 337 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
| 338 | 338 | <?php |
@@ -341,11 +341,11 @@ discard block |
||
| 341 | 341 | * |
| 342 | 342 | * @since 1.7 |
| 343 | 343 | */ |
| 344 | - do_action( 'give_donation_form_register_fields', $form_id ); |
|
| 344 | + do_action('give_donation_form_register_fields', $form_id); |
|
| 345 | 345 | ?> |
| 346 | 346 | </div> |
| 347 | 347 | <?php |
| 348 | - elseif ( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
| 348 | + elseif (($show_register_form === 'login' || ($show_register_form === 'both' && isset($_GET['login']))) && ! is_user_logged_in()) : |
|
| 349 | 349 | ?> |
| 350 | 350 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
| 351 | 351 | <?php |
@@ -354,23 +354,23 @@ discard block |
||
| 354 | 354 | * |
| 355 | 355 | * @since 1.7 |
| 356 | 356 | */ |
| 357 | - do_action( 'give_donation_form_login_fields', $form_id ); |
|
| 357 | + do_action('give_donation_form_login_fields', $form_id); |
|
| 358 | 358 | ?> |
| 359 | 359 | </div> |
| 360 | 360 | <?php |
| 361 | 361 | endif; |
| 362 | 362 | |
| 363 | - if ( ( ! isset( $_GET['login'] ) && is_user_logged_in() ) || ! isset( $show_register_form ) || 'none' === $show_register_form || 'login' === $show_register_form ) { |
|
| 363 | + if (( ! isset($_GET['login']) && is_user_logged_in()) || ! isset($show_register_form) || 'none' === $show_register_form || 'login' === $show_register_form) { |
|
| 364 | 364 | /** |
| 365 | 365 | * Fire when user info render. |
| 366 | 366 | * |
| 367 | 367 | * @since 1.7 |
| 368 | 368 | */ |
| 369 | - do_action( 'give_donation_form_after_user_info', $form_id ); |
|
| 369 | + do_action('give_donation_form_after_user_info', $form_id); |
|
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | -add_action( 'give_donation_form_register_login_fields', 'give_show_register_login_fields' ); |
|
| 373 | +add_action('give_donation_form_register_login_fields', 'give_show_register_login_fields'); |
|
| 374 | 374 | |
| 375 | 375 | /** |
| 376 | 376 | * Donation Amount Field. |
@@ -384,16 +384,16 @@ discard block |
||
| 384 | 384 | * |
| 385 | 385 | * @return void |
| 386 | 386 | */ |
| 387 | -function give_output_donation_amount_top( $form_id = 0, $args = array() ) { |
|
| 387 | +function give_output_donation_amount_top($form_id = 0, $args = array()) { |
|
| 388 | 388 | |
| 389 | 389 | $give_options = give_get_settings(); |
| 390 | - $variable_pricing = give_has_variable_prices( $form_id ); |
|
| 391 | - $allow_custom_amount = get_post_meta( $form_id, '_give_custom_amount', true ); |
|
| 392 | - $currency_position = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before'; |
|
| 393 | - $symbol = give_currency_symbol( give_get_currency() ); |
|
| 394 | - $currency_output = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>'; |
|
| 395 | - $default_amount = give_format_amount( give_get_default_form_amount( $form_id ) ); |
|
| 396 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 390 | + $variable_pricing = give_has_variable_prices($form_id); |
|
| 391 | + $allow_custom_amount = get_post_meta($form_id, '_give_custom_amount', true); |
|
| 392 | + $currency_position = isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before'; |
|
| 393 | + $symbol = give_currency_symbol(give_get_currency()); |
|
| 394 | + $currency_output = '<span class="give-currency-symbol give-currency-position-'.$currency_position.'">'.$symbol.'</span>'; |
|
| 395 | + $default_amount = give_format_amount(give_get_default_form_amount($form_id)); |
|
| 396 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
| 397 | 397 | |
| 398 | 398 | /** |
| 399 | 399 | * Fires while displaying donation form, before donation level fields. |
@@ -403,20 +403,20 @@ discard block |
||
| 403 | 403 | * @param int $form_id The form ID. |
| 404 | 404 | * @param array $args An array of form arguments. |
| 405 | 405 | */ |
| 406 | - do_action( 'give_before_donation_levels', $form_id, $args ); |
|
| 406 | + do_action('give_before_donation_levels', $form_id, $args); |
|
| 407 | 407 | |
| 408 | 408 | //Set Price, No Custom Amount Allowed means hidden price field. |
| 409 | - if ( $allow_custom_amount == 'no' ) { |
|
| 409 | + if ($allow_custom_amount == 'no') { |
|
| 410 | 410 | ?> |
| 411 | - <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
| 411 | + <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
| 412 | 412 | <input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount" |
| 413 | 413 | value="<?php echo $default_amount; ?>" required aria-required="true"/> |
| 414 | 414 | <div class="set-price give-donation-amount form-row-wide"> |
| 415 | - <?php if ( $currency_position == 'before' ) { |
|
| 415 | + <?php if ($currency_position == 'before') { |
|
| 416 | 416 | echo $currency_output; |
| 417 | 417 | } ?> |
| 418 | 418 | <span id="give-amount-text" class="give-text-input give-amount-top"><?php echo $default_amount; ?></span> |
| 419 | - <?php if ( $currency_position == 'after' ) { |
|
| 419 | + <?php if ($currency_position == 'after') { |
|
| 420 | 420 | echo $currency_output; |
| 421 | 421 | } ?> |
| 422 | 422 | </div> |
@@ -426,13 +426,13 @@ discard block |
||
| 426 | 426 | ?> |
| 427 | 427 | <div class="give-total-wrap"> |
| 428 | 428 | <div class="give-donation-amount form-row-wide"> |
| 429 | - <?php if ( $currency_position == 'before' ) { |
|
| 429 | + <?php if ($currency_position == 'before') { |
|
| 430 | 430 | echo $currency_output; |
| 431 | 431 | } ?> |
| 432 | - <label class="give-hidden" for="give-amount"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
| 432 | + <label class="give-hidden" for="give-amount"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
| 433 | 433 | <input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="tel" |
| 434 | 434 | placeholder="" value="<?php echo $default_amount; ?>" autocomplete="off"> |
| 435 | - <?php if ( $currency_position == 'after' ) { |
|
| 435 | + <?php if ($currency_position == 'after') { |
|
| 436 | 436 | echo $currency_output; |
| 437 | 437 | } ?> |
| 438 | 438 | </div> |
@@ -447,16 +447,16 @@ discard block |
||
| 447 | 447 | * @param int $form_id The form ID. |
| 448 | 448 | * @param array $args An array of form arguments. |
| 449 | 449 | */ |
| 450 | - do_action( 'give_after_donation_amount', $form_id, $args ); |
|
| 450 | + do_action('give_after_donation_amount', $form_id, $args); |
|
| 451 | 451 | |
| 452 | 452 | //Custom Amount Text. |
| 453 | - if ( ! $variable_pricing && $allow_custom_amount == 'yes' && ! empty( $custom_amount_text ) ) { ?> |
|
| 453 | + if ( ! $variable_pricing && $allow_custom_amount == 'yes' && ! empty($custom_amount_text)) { ?> |
|
| 454 | 454 | <p class="give-custom-amount-text"><?php echo $custom_amount_text; ?></p> |
| 455 | 455 | <?php } |
| 456 | 456 | |
| 457 | 457 | //Output Variable Pricing Levels. |
| 458 | - if ( $variable_pricing ) { |
|
| 459 | - give_output_levels( $form_id ); |
|
| 458 | + if ($variable_pricing) { |
|
| 459 | + give_output_levels($form_id); |
|
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | /** |
@@ -467,10 +467,10 @@ discard block |
||
| 467 | 467 | * @param int $form_id The form ID. |
| 468 | 468 | * @param array $args An array of form arguments. |
| 469 | 469 | */ |
| 470 | - do_action( 'give_after_donation_levels', $form_id, $args ); |
|
| 470 | + do_action('give_after_donation_levels', $form_id, $args); |
|
| 471 | 471 | } |
| 472 | 472 | |
| 473 | -add_action( 'give_checkout_form_top', 'give_output_donation_amount_top', 10, 2 ); |
|
| 473 | +add_action('give_checkout_form_top', 'give_output_donation_amount_top', 10, 2); |
|
| 474 | 474 | |
| 475 | 475 | /** |
| 476 | 476 | * Outputs the Donation Levels in various formats such as dropdown, radios, and buttons. |
@@ -481,32 +481,32 @@ discard block |
||
| 481 | 481 | * |
| 482 | 482 | * @return string Donation levels. |
| 483 | 483 | */ |
| 484 | -function give_output_levels( $form_id ) { |
|
| 484 | +function give_output_levels($form_id) { |
|
| 485 | 485 | |
| 486 | 486 | //Get variable pricing. |
| 487 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
| 488 | - $display_style = get_post_meta( $form_id, '_give_display_style', true ); |
|
| 489 | - $custom_amount = get_post_meta( $form_id, '_give_custom_amount', true ); |
|
| 490 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 491 | - if ( empty( $custom_amount_text ) ) { |
|
| 492 | - $custom_amount_text = esc_html__( 'Give a Custom Amount', 'give' ); |
|
| 487 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
| 488 | + $display_style = get_post_meta($form_id, '_give_display_style', true); |
|
| 489 | + $custom_amount = get_post_meta($form_id, '_give_custom_amount', true); |
|
| 490 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
| 491 | + if (empty($custom_amount_text)) { |
|
| 492 | + $custom_amount_text = esc_html__('Give a Custom Amount', 'give'); |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | $output = ''; |
| 496 | 496 | $counter = 0; |
| 497 | 497 | |
| 498 | - switch ( $display_style ) { |
|
| 498 | + switch ($display_style) { |
|
| 499 | 499 | case 'buttons': |
| 500 | 500 | |
| 501 | 501 | $output .= '<ul id="give-donation-level-button-wrap" class="give-donation-levels-wrap give-list-inline">'; |
| 502 | 502 | |
| 503 | - foreach ( $prices as $price ) { |
|
| 504 | - $counter ++; |
|
| 505 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ), $form_id, $price ); |
|
| 506 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-' . $counter . ' ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'give-default-level' : '' ), $form_id, $price ); |
|
| 503 | + foreach ($prices as $price) { |
|
| 504 | + $counter++; |
|
| 505 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'])), $form_id, $price); |
|
| 506 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-'.$counter.' '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'give-default-level' : ''), $form_id, $price); |
|
| 507 | 507 | |
| 508 | 508 | $output .= '<li>'; |
| 509 | - $output .= '<button type="button" data-price-id="' . $price['_give_id']['level_id'] . '" class=" ' . $level_classes . '" value="' . give_format_amount( $price['_give_amount'] ) . '">'; |
|
| 509 | + $output .= '<button type="button" data-price-id="'.$price['_give_id']['level_id'].'" class=" '.$level_classes.'" value="'.give_format_amount($price['_give_amount']).'">'; |
|
| 510 | 510 | $output .= $level_text; |
| 511 | 511 | $output .= '</button>'; |
| 512 | 512 | $output .= '</li>'; |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | } |
| 515 | 515 | |
| 516 | 516 | //Custom Amount. |
| 517 | - if ( $custom_amount === 'yes' && ! empty( $custom_amount_text ) ) { |
|
| 517 | + if ($custom_amount === 'yes' && ! empty($custom_amount_text)) { |
|
| 518 | 518 | $output .= '<li>'; |
| 519 | 519 | $output .= '<button type="button" data-price-id="custom" class="give-donation-level-btn give-btn give-btn-level-custom" value="custom">'; |
| 520 | 520 | $output .= $custom_amount_text; |
@@ -530,23 +530,23 @@ discard block |
||
| 530 | 530 | |
| 531 | 531 | $output .= '<ul id="give-donation-level-radio-list" class="give-donation-levels-wrap">'; |
| 532 | 532 | |
| 533 | - foreach ( $prices as $price ) { |
|
| 534 | - $counter ++; |
|
| 535 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ), $form_id, $price ); |
|
| 536 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-' . $counter . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
| 533 | + foreach ($prices as $price) { |
|
| 534 | + $counter++; |
|
| 535 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'])), $form_id, $price); |
|
| 536 | + $level_classes = apply_filters('give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-'.$counter.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
| 537 | 537 | |
| 538 | 538 | $output .= '<li>'; |
| 539 | - $output .= '<input type="radio" data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" name="give-radio-donation-level" id="give-radio-level-' . $counter . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'checked="checked"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'] ) . '">'; |
|
| 540 | - $output .= '<label for="give-radio-level-' . $counter . '">' . $level_text . '</label>'; |
|
| 539 | + $output .= '<input type="radio" data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" name="give-radio-donation-level" id="give-radio-level-'.$counter.'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'checked="checked"' : '').' value="'.give_format_amount($price['_give_amount']).'">'; |
|
| 540 | + $output .= '<label for="give-radio-level-'.$counter.'">'.$level_text.'</label>'; |
|
| 541 | 541 | $output .= '</li>'; |
| 542 | 542 | |
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | //Custom Amount. |
| 546 | - if ( $custom_amount === 'yes' && ! empty( $custom_amount_text ) ) { |
|
| 546 | + if ($custom_amount === 'yes' && ! empty($custom_amount_text)) { |
|
| 547 | 547 | $output .= '<li>'; |
| 548 | 548 | $output .= '<input type="radio" data-price-id="custom" class="give-radio-input give-radio-input-level give-radio-level-custom" name="give-radio-donation-level" id="give-radio-level-custom" value="custom">'; |
| 549 | - $output .= '<label for="give-radio-level-custom">' . $custom_amount_text . '</label>'; |
|
| 549 | + $output .= '<label for="give-radio-level-custom">'.$custom_amount_text.'</label>'; |
|
| 550 | 550 | $output .= '</li>'; |
| 551 | 551 | } |
| 552 | 552 | |
@@ -556,23 +556,23 @@ discard block |
||
| 556 | 556 | |
| 557 | 557 | case 'dropdown': |
| 558 | 558 | |
| 559 | - $output .= '<label for="give-donation-level" class="give-hidden">' . esc_html__( 'Choose Your Donation Amount', 'give' ) . ':</label>'; |
|
| 560 | - $output .= '<select id="give-donation-level-' . $form_id . '" class="give-select give-select-level give-donation-levels-wrap">'; |
|
| 559 | + $output .= '<label for="give-donation-level" class="give-hidden">'.esc_html__('Choose Your Donation Amount', 'give').':</label>'; |
|
| 560 | + $output .= '<select id="give-donation-level-'.$form_id.'" class="give-select give-select-level give-donation-levels-wrap">'; |
|
| 561 | 561 | |
| 562 | 562 | //first loop through prices. |
| 563 | - foreach ( $prices as $price ) { |
|
| 564 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ), $form_id, $price ); |
|
| 565 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-' . $form_id . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
| 563 | + foreach ($prices as $price) { |
|
| 564 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'])), $form_id, $price); |
|
| 565 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-'.$form_id.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
| 566 | 566 | |
| 567 | - $output .= '<option data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'selected="selected"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'] ) . '">'; |
|
| 567 | + $output .= '<option data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'selected="selected"' : '').' value="'.give_format_amount($price['_give_amount']).'">'; |
|
| 568 | 568 | $output .= $level_text; |
| 569 | 569 | $output .= '</option>'; |
| 570 | 570 | |
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | //Custom Amount. |
| 574 | - if ( $custom_amount === 'yes' && ! empty( $custom_amount_text ) ) { |
|
| 575 | - $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">' . $custom_amount_text . '</option>'; |
|
| 574 | + if ($custom_amount === 'yes' && ! empty($custom_amount_text)) { |
|
| 575 | + $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">'.$custom_amount_text.'</option>'; |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | $output .= '</select>'; |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | break; |
| 581 | 581 | } |
| 582 | 582 | |
| 583 | - echo apply_filters( 'give_form_level_output', $output, $form_id ); |
|
| 583 | + echo apply_filters('give_form_level_output', $output, $form_id); |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | /** |
@@ -595,26 +595,26 @@ discard block |
||
| 595 | 595 | * |
| 596 | 596 | * @return string Checkout button. |
| 597 | 597 | */ |
| 598 | -function give_display_checkout_button( $form_id, $args ) { |
|
| 598 | +function give_display_checkout_button($form_id, $args) { |
|
| 599 | 599 | |
| 600 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
| 600 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
| 601 | 601 | ? $args['display_style'] |
| 602 | - : get_post_meta( $form_id, '_give_payment_display', true ); |
|
| 602 | + : get_post_meta($form_id, '_give_payment_display', true); |
|
| 603 | 603 | |
| 604 | 604 | //no btn for onpage. |
| 605 | - if ( $display_option === 'onpage' ) { |
|
| 605 | + if ($display_option === 'onpage') { |
|
| 606 | 606 | return; |
| 607 | 607 | } |
| 608 | 608 | |
| 609 | - $display_label_field = get_post_meta( $form_id, '_give_reveal_label', true ); |
|
| 610 | - $display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
| 609 | + $display_label_field = get_post_meta($form_id, '_give_reveal_label', true); |
|
| 610 | + $display_label = ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
| 611 | 611 | |
| 612 | - $output = '<button type="button" class="give-btn give-btn-' . $display_option . '">' . $display_label . '</button>'; |
|
| 612 | + $output = '<button type="button" class="give-btn give-btn-'.$display_option.'">'.$display_label.'</button>'; |
|
| 613 | 613 | |
| 614 | - echo apply_filters( 'give_display_checkout_button', $output ); |
|
| 614 | + echo apply_filters('give_display_checkout_button', $output); |
|
| 615 | 615 | } |
| 616 | 616 | |
| 617 | -add_action( 'give_after_donation_levels', 'give_display_checkout_button', 10, 2 ); |
|
| 617 | +add_action('give_after_donation_levels', 'give_display_checkout_button', 10, 2); |
|
| 618 | 618 | |
| 619 | 619 | /** |
| 620 | 620 | * Shows the User Info fields in the Personal Info box, more fields can be added via the hooks provided. |
@@ -625,57 +625,57 @@ discard block |
||
| 625 | 625 | * |
| 626 | 626 | * @return void |
| 627 | 627 | */ |
| 628 | -function give_user_info_fields( $form_id ) { |
|
| 628 | +function give_user_info_fields($form_id) { |
|
| 629 | 629 | // Get user info. |
| 630 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
| 630 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
| 631 | 631 | |
| 632 | 632 | /** |
| 633 | 633 | * Fire before user personal information fields |
| 634 | 634 | * |
| 635 | 635 | * @since 1.7 |
| 636 | 636 | */ |
| 637 | - do_action( 'give_donation_form_before_personal_info', $form_id ); |
|
| 637 | + do_action('give_donation_form_before_personal_info', $form_id); |
|
| 638 | 638 | ?> |
| 639 | 639 | <fieldset id="give_checkout_user_info"> |
| 640 | - <legend><?php echo apply_filters( 'give_checkout_personal_info_text', esc_html__( 'Personal Info', 'give' ) ); ?></legend> |
|
| 640 | + <legend><?php echo apply_filters('give_checkout_personal_info_text', esc_html__('Personal Info', 'give')); ?></legend> |
|
| 641 | 641 | <p id="give-first-name-wrap" class="form-row form-row-first"> |
| 642 | 642 | <label class="give-label" for="give-first"> |
| 643 | - <?php esc_html_e( 'First Name', 'give' ); ?> |
|
| 644 | - <?php if ( give_field_is_required( 'give_first', $form_id ) ) : ?> |
|
| 643 | + <?php esc_html_e('First Name', 'give'); ?> |
|
| 644 | + <?php if (give_field_is_required('give_first', $form_id)) : ?> |
|
| 645 | 645 | <span class="give-required-indicator">*</span> |
| 646 | 646 | <?php endif ?> |
| 647 | 647 | <span class="give-tooltip give-icon give-icon-question" |
| 648 | - data-tooltip="<?php esc_attr_e( 'We will use this to personalize your account experience.', 'give' ); ?>"></span> |
|
| 648 | + data-tooltip="<?php esc_attr_e('We will use this to personalize your account experience.', 'give'); ?>"></span> |
|
| 649 | 649 | </label> |
| 650 | 650 | <input |
| 651 | 651 | class="give-input required" |
| 652 | 652 | type="text" |
| 653 | 653 | name="give_first" |
| 654 | - placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" |
|
| 654 | + placeholder="<?php esc_attr_e('First Name', 'give'); ?>" |
|
| 655 | 655 | id="give-first" |
| 656 | - value="<?php echo isset( $give_user_info['give_first'] ) ? $give_user_info['give_first'] : ''; ?>" |
|
| 657 | - <?php echo( give_field_is_required( 'give_first', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 656 | + value="<?php echo isset($give_user_info['give_first']) ? $give_user_info['give_first'] : ''; ?>" |
|
| 657 | + <?php echo(give_field_is_required('give_first', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 658 | 658 | /> |
| 659 | 659 | </p> |
| 660 | 660 | |
| 661 | 661 | <p id="give-last-name-wrap" class="form-row form-row-last"> |
| 662 | 662 | <label class="give-label" for="give-last"> |
| 663 | - <?php esc_html_e( 'Last Name', 'give' ); ?> |
|
| 664 | - <?php if ( give_field_is_required( 'give_last', $form_id ) ) : ?> |
|
| 663 | + <?php esc_html_e('Last Name', 'give'); ?> |
|
| 664 | + <?php if (give_field_is_required('give_last', $form_id)) : ?> |
|
| 665 | 665 | <span class="give-required-indicator">*</span> |
| 666 | 666 | <?php endif ?> |
| 667 | 667 | <span class="give-tooltip give-icon give-icon-question" |
| 668 | - data-tooltip="<?php esc_attr_e( 'We will use this as well to personalize your account experience.', 'give' ); ?>"></span> |
|
| 668 | + data-tooltip="<?php esc_attr_e('We will use this as well to personalize your account experience.', 'give'); ?>"></span> |
|
| 669 | 669 | </label> |
| 670 | 670 | |
| 671 | 671 | <input |
| 672 | - class="give-input<?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required' : '' ); ?>" |
|
| 672 | + class="give-input<?php echo(give_field_is_required('give_last', $form_id) ? ' required' : ''); ?>" |
|
| 673 | 673 | type="text" |
| 674 | 674 | name="give_last" |
| 675 | 675 | id="give-last" |
| 676 | - placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" |
|
| 677 | - value="<?php echo isset( $give_user_info['give_last'] ) ? $give_user_info['give_last'] : ''; ?>" |
|
| 678 | - <?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 676 | + placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" |
|
| 677 | + value="<?php echo isset($give_user_info['give_last']) ? $give_user_info['give_last'] : ''; ?>" |
|
| 678 | + <?php echo(give_field_is_required('give_last', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 679 | 679 | /> |
| 680 | 680 | </p> |
| 681 | 681 | |
@@ -685,26 +685,26 @@ discard block |
||
| 685 | 685 | * |
| 686 | 686 | * @since 1.7 |
| 687 | 687 | */ |
| 688 | - do_action( 'give_donation_form_before_email', $form_id ); |
|
| 688 | + do_action('give_donation_form_before_email', $form_id); |
|
| 689 | 689 | ?> |
| 690 | 690 | <p id="give-email-wrap" class="form-row form-row-wide"> |
| 691 | 691 | <label class="give-label" for="give-email"> |
| 692 | - <?php esc_html_e( 'Email Address', 'give' ); ?> |
|
| 693 | - <?php if ( give_field_is_required( 'give_email', $form_id ) ) { ?> |
|
| 692 | + <?php esc_html_e('Email Address', 'give'); ?> |
|
| 693 | + <?php if (give_field_is_required('give_email', $form_id)) { ?> |
|
| 694 | 694 | <span class="give-required-indicator">*</span> |
| 695 | 695 | <?php } ?> |
| 696 | 696 | <span class="give-tooltip give-icon give-icon-question" |
| 697 | - data-tooltip="<?php esc_attr_e( 'We will send the donation receipt to this address.', 'give' ); ?>"></span> |
|
| 697 | + data-tooltip="<?php esc_attr_e('We will send the donation receipt to this address.', 'give'); ?>"></span> |
|
| 698 | 698 | </label> |
| 699 | 699 | |
| 700 | 700 | <input |
| 701 | 701 | class="give-input required" |
| 702 | 702 | type="email" |
| 703 | 703 | name="give_email" |
| 704 | - placeholder="<?php esc_attr_e( 'Email Address', 'give' ); ?>" |
|
| 704 | + placeholder="<?php esc_attr_e('Email Address', 'give'); ?>" |
|
| 705 | 705 | id="give-email" |
| 706 | - value="<?php echo isset( $give_user_info['give_email'] ) ? $give_user_info['give_email'] : ''; ?>" |
|
| 707 | - <?php echo( give_field_is_required( 'give_email', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 706 | + value="<?php echo isset($give_user_info['give_email']) ? $give_user_info['give_email'] : ''; ?>" |
|
| 707 | + <?php echo(give_field_is_required('give_email', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 708 | 708 | /> |
| 709 | 709 | |
| 710 | 710 | </p> |
@@ -714,14 +714,14 @@ discard block |
||
| 714 | 714 | * |
| 715 | 715 | * @since 1.7 |
| 716 | 716 | */ |
| 717 | - do_action( 'give_donation_form_after_email', $form_id ); |
|
| 717 | + do_action('give_donation_form_after_email', $form_id); |
|
| 718 | 718 | |
| 719 | 719 | /** |
| 720 | 720 | * Fire after personal email field |
| 721 | 721 | * |
| 722 | 722 | * @since 1.7 |
| 723 | 723 | */ |
| 724 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
| 724 | + do_action('give_donation_form_user_info', $form_id); |
|
| 725 | 725 | ?> |
| 726 | 726 | </fieldset> |
| 727 | 727 | <?php |
@@ -730,11 +730,11 @@ discard block |
||
| 730 | 730 | * |
| 731 | 731 | * @since 1.7 |
| 732 | 732 | */ |
| 733 | - do_action( 'give_donation_form_after_personal_info', $form_id ); |
|
| 733 | + do_action('give_donation_form_after_personal_info', $form_id); |
|
| 734 | 734 | } |
| 735 | 735 | |
| 736 | -add_action( 'give_donation_form_after_user_info', 'give_user_info_fields' ); |
|
| 737 | -add_action( 'give_register_fields_before', 'give_user_info_fields' ); |
|
| 736 | +add_action('give_donation_form_after_user_info', 'give_user_info_fields'); |
|
| 737 | +add_action('give_register_fields_before', 'give_user_info_fields'); |
|
| 738 | 738 | |
| 739 | 739 | /** |
| 740 | 740 | * Renders the credit card info form. |
@@ -745,7 +745,7 @@ discard block |
||
| 745 | 745 | * |
| 746 | 746 | * @return void |
| 747 | 747 | */ |
| 748 | -function give_get_cc_form( $form_id ) { |
|
| 748 | +function give_get_cc_form($form_id) { |
|
| 749 | 749 | |
| 750 | 750 | ob_start(); |
| 751 | 751 | |
@@ -756,53 +756,53 @@ discard block |
||
| 756 | 756 | * |
| 757 | 757 | * @param int $form_id The form ID. |
| 758 | 758 | */ |
| 759 | - do_action( 'give_before_cc_fields', $form_id ); |
|
| 759 | + do_action('give_before_cc_fields', $form_id); |
|
| 760 | 760 | ?> |
| 761 | 761 | <fieldset id="give_cc_fields-<?php echo $form_id ?>" class="give-do-validate"> |
| 762 | - <legend><?php echo apply_filters( 'give_credit_card_fieldset_heading', esc_html__( 'Credit Card Info', 'give' ) ); ?></legend> |
|
| 763 | - <?php if ( is_ssl() ) : ?> |
|
| 762 | + <legend><?php echo apply_filters('give_credit_card_fieldset_heading', esc_html__('Credit Card Info', 'give')); ?></legend> |
|
| 763 | + <?php if (is_ssl()) : ?> |
|
| 764 | 764 | <div id="give_secure_site_wrapper-<?php echo $form_id ?>"> |
| 765 | 765 | <span class="give-icon padlock"></span> |
| 766 | - <span><?php esc_html_e( 'This is a secure SSL encrypted payment.', 'give' ); ?></span> |
|
| 766 | + <span><?php esc_html_e('This is a secure SSL encrypted payment.', 'give'); ?></span> |
|
| 767 | 767 | </div> |
| 768 | 768 | <?php endif; ?> |
| 769 | 769 | <p id="give-card-number-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds"> |
| 770 | 770 | <label for="card_number-<?php echo $form_id ?>" class="give-label"> |
| 771 | - <?php esc_html_e( 'Card Number', 'give' ); ?> |
|
| 771 | + <?php esc_html_e('Card Number', 'give'); ?> |
|
| 772 | 772 | <span class="give-required-indicator">*</span> |
| 773 | 773 | <span class="give-tooltip give-icon give-icon-question" |
| 774 | - data-tooltip="<?php esc_attr_e( 'The (typically) 16 digits on the front of your credit card.', 'give' ); ?>"></span> |
|
| 774 | + data-tooltip="<?php esc_attr_e('The (typically) 16 digits on the front of your credit card.', 'give'); ?>"></span> |
|
| 775 | 775 | <span class="card-type"></span> |
| 776 | 776 | </label> |
| 777 | 777 | |
| 778 | 778 | <input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" |
| 779 | - class="card-number give-input required" placeholder="<?php esc_attr_e( 'Card number', 'give' ); ?>" |
|
| 779 | + class="card-number give-input required" placeholder="<?php esc_attr_e('Card number', 'give'); ?>" |
|
| 780 | 780 | required aria-required="true"/> |
| 781 | 781 | </p> |
| 782 | 782 | |
| 783 | 783 | <p id="give-card-cvc-wrap-<?php echo $form_id ?>" class="form-row form-row-one-third"> |
| 784 | 784 | <label for="card_cvc-<?php echo $form_id ?>" class="give-label"> |
| 785 | - <?php esc_html_e( 'CVC', 'give' ); ?> |
|
| 785 | + <?php esc_html_e('CVC', 'give'); ?> |
|
| 786 | 786 | <span class="give-required-indicator">*</span> |
| 787 | 787 | <span class="give-tooltip give-icon give-icon-question" |
| 788 | - data-tooltip="<?php esc_attr_e( 'The 3 digit (back) or 4 digit (front) value on your card.', 'give' ); ?>"></span> |
|
| 788 | + data-tooltip="<?php esc_attr_e('The 3 digit (back) or 4 digit (front) value on your card.', 'give'); ?>"></span> |
|
| 789 | 789 | </label> |
| 790 | 790 | |
| 791 | 791 | <input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id ?>" |
| 792 | - class="card-cvc give-input required" placeholder="<?php esc_attr_e( 'Security code', 'give' ); ?>" |
|
| 792 | + class="card-cvc give-input required" placeholder="<?php esc_attr_e('Security code', 'give'); ?>" |
|
| 793 | 793 | required aria-required="true"/> |
| 794 | 794 | </p> |
| 795 | 795 | |
| 796 | 796 | <p id="give-card-name-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds"> |
| 797 | 797 | <label for="card_name-<?php echo $form_id ?>" class="give-label"> |
| 798 | - <?php esc_html_e( 'Name on the Card', 'give' ); ?> |
|
| 798 | + <?php esc_html_e('Name on the Card', 'give'); ?> |
|
| 799 | 799 | <span class="give-required-indicator">*</span> |
| 800 | 800 | <span class="give-tooltip give-icon give-icon-question" |
| 801 | - data-tooltip="<?php esc_attr_e( 'The name printed on the front of your credit card.', 'give' ); ?>"></span> |
|
| 801 | + data-tooltip="<?php esc_attr_e('The name printed on the front of your credit card.', 'give'); ?>"></span> |
|
| 802 | 802 | </label> |
| 803 | 803 | |
| 804 | 804 | <input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" |
| 805 | - class="card-name give-input required" placeholder="<?php esc_attr_e( 'Card name', 'give' ); ?>" |
|
| 805 | + class="card-name give-input required" placeholder="<?php esc_attr_e('Card name', 'give'); ?>" |
|
| 806 | 806 | required aria-required="true"/> |
| 807 | 807 | </p> |
| 808 | 808 | <?php |
@@ -813,14 +813,14 @@ discard block |
||
| 813 | 813 | * |
| 814 | 814 | * @param int $form_id The form ID. |
| 815 | 815 | */ |
| 816 | - do_action( 'give_before_cc_expiration' ); |
|
| 816 | + do_action('give_before_cc_expiration'); |
|
| 817 | 817 | ?> |
| 818 | 818 | <p class="card-expiration form-row form-row-one-third"> |
| 819 | 819 | <label for="card_expiry-<?php echo $form_id ?>" class="give-label"> |
| 820 | - <?php esc_html_e( 'Expiration', 'give' ); ?> |
|
| 820 | + <?php esc_html_e('Expiration', 'give'); ?> |
|
| 821 | 821 | <span class="give-required-indicator">*</span> |
| 822 | 822 | <span class="give-tooltip give-icon give-icon-question" |
| 823 | - data-tooltip="<?php esc_attr_e( 'The date your credit card expires, typically on the front of the card.', 'give' ); ?>"></span> |
|
| 823 | + data-tooltip="<?php esc_attr_e('The date your credit card expires, typically on the front of the card.', 'give'); ?>"></span> |
|
| 824 | 824 | </label> |
| 825 | 825 | |
| 826 | 826 | <input type="hidden" id="card_exp_month-<?php echo $form_id ?>" name="card_exp_month" |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | class="card-expiry-year"/> |
| 830 | 830 | |
| 831 | 831 | <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" |
| 832 | - class="card-expiry give-input required" placeholder="<?php esc_attr_e( 'MM / YY', 'give' ); ?>" |
|
| 832 | + class="card-expiry give-input required" placeholder="<?php esc_attr_e('MM / YY', 'give'); ?>" |
|
| 833 | 833 | required aria-required="true"/> |
| 834 | 834 | </p> |
| 835 | 835 | <?php |
@@ -840,7 +840,7 @@ discard block |
||
| 840 | 840 | * |
| 841 | 841 | * @param int $form_id The form ID. |
| 842 | 842 | */ |
| 843 | - do_action( 'give_after_cc_expiration', $form_id ); |
|
| 843 | + do_action('give_after_cc_expiration', $form_id); |
|
| 844 | 844 | ?> |
| 845 | 845 | </fieldset> |
| 846 | 846 | <?php |
@@ -851,12 +851,12 @@ discard block |
||
| 851 | 851 | * |
| 852 | 852 | * @param int $form_id The form ID. |
| 853 | 853 | */ |
| 854 | - do_action( 'give_after_cc_fields', $form_id ); |
|
| 854 | + do_action('give_after_cc_fields', $form_id); |
|
| 855 | 855 | |
| 856 | 856 | echo ob_get_clean(); |
| 857 | 857 | } |
| 858 | 858 | |
| 859 | -add_action( 'give_cc_form', 'give_get_cc_form' ); |
|
| 859 | +add_action('give_cc_form', 'give_get_cc_form'); |
|
| 860 | 860 | |
| 861 | 861 | /** |
| 862 | 862 | * Outputs the default credit card address fields. |
@@ -867,24 +867,24 @@ discard block |
||
| 867 | 867 | * |
| 868 | 868 | * @return void |
| 869 | 869 | */ |
| 870 | -function give_default_cc_address_fields( $form_id ) { |
|
| 870 | +function give_default_cc_address_fields($form_id) { |
|
| 871 | 871 | // Get user info. |
| 872 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
| 872 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
| 873 | 873 | |
| 874 | 874 | $logged_in = is_user_logged_in(); |
| 875 | 875 | |
| 876 | - if ( $logged_in ) { |
|
| 877 | - $user_address = get_user_meta( get_current_user_id(), '_give_user_address', true ); |
|
| 876 | + if ($logged_in) { |
|
| 877 | + $user_address = get_user_meta(get_current_user_id(), '_give_user_address', true); |
|
| 878 | 878 | } |
| 879 | - $line1 = $logged_in && ! empty( $user_address['line1'] ) ? $user_address['line1'] : ''; |
|
| 880 | - $line2 = $logged_in && ! empty( $user_address['line2'] ) ? $user_address['line2'] : ''; |
|
| 881 | - $city = $logged_in && ! empty( $user_address['city'] ) ? $user_address['city'] : ''; |
|
| 882 | - $zip = $logged_in && ! empty( $user_address['zip'] ) ? $user_address['zip'] : ''; |
|
| 879 | + $line1 = $logged_in && ! empty($user_address['line1']) ? $user_address['line1'] : ''; |
|
| 880 | + $line2 = $logged_in && ! empty($user_address['line2']) ? $user_address['line2'] : ''; |
|
| 881 | + $city = $logged_in && ! empty($user_address['city']) ? $user_address['city'] : ''; |
|
| 882 | + $zip = $logged_in && ! empty($user_address['zip']) ? $user_address['zip'] : ''; |
|
| 883 | 883 | |
| 884 | 884 | ob_start(); |
| 885 | 885 | ?> |
| 886 | 886 | <fieldset id="give_cc_address" class="cc-address"> |
| 887 | - <legend><?php echo apply_filters( 'give_billing_details_fieldset_heading', esc_html__( 'Billing Details', 'give' ) ); ?></legend> |
|
| 887 | + <legend><?php echo apply_filters('give_billing_details_fieldset_heading', esc_html__('Billing Details', 'give')); ?></legend> |
|
| 888 | 888 | <?php |
| 889 | 889 | /** |
| 890 | 890 | * Fires while rendering credit card billing form, before address fields. |
@@ -893,79 +893,79 @@ discard block |
||
| 893 | 893 | * |
| 894 | 894 | * @param int $form_id The form ID. |
| 895 | 895 | */ |
| 896 | - do_action( 'give_cc_billing_top' ); |
|
| 896 | + do_action('give_cc_billing_top'); |
|
| 897 | 897 | ?> |
| 898 | 898 | <p id="give-card-address-wrap" class="form-row form-row-two-thirds"> |
| 899 | 899 | <label for="card_address" class="give-label"> |
| 900 | - <?php esc_html_e( 'Address 1', 'give' ); ?> |
|
| 900 | + <?php esc_html_e('Address 1', 'give'); ?> |
|
| 901 | 901 | <?php |
| 902 | - if ( give_field_is_required( 'card_address', $form_id ) ) : ?> |
|
| 902 | + if (give_field_is_required('card_address', $form_id)) : ?> |
|
| 903 | 903 | <span class="give-required-indicator">*</span> |
| 904 | 904 | <?php endif; ?> |
| 905 | 905 | <span class="give-tooltip give-icon give-icon-question" |
| 906 | - data-tooltip="<?php esc_attr_e( 'The primary billing address for your credit card.', 'give' ); ?>"></span> |
|
| 906 | + data-tooltip="<?php esc_attr_e('The primary billing address for your credit card.', 'give'); ?>"></span> |
|
| 907 | 907 | </label> |
| 908 | 908 | |
| 909 | 909 | <input |
| 910 | 910 | type="text" |
| 911 | 911 | id="card_address" |
| 912 | 912 | name="card_address" |
| 913 | - class="card-address give-input<?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required' : '' ); ?>" |
|
| 914 | - placeholder="<?php esc_attr_e( 'Address line 1', 'give' ); ?>" |
|
| 915 | - value="<?php echo isset( $give_user_info['card_address'] ) ? $give_user_info['card_address'] : ''; ?>" |
|
| 916 | - <?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 913 | + class="card-address give-input<?php echo(give_field_is_required('card_address', $form_id) ? ' required' : ''); ?>" |
|
| 914 | + placeholder="<?php esc_attr_e('Address line 1', 'give'); ?>" |
|
| 915 | + value="<?php echo isset($give_user_info['card_address']) ? $give_user_info['card_address'] : ''; ?>" |
|
| 916 | + <?php echo(give_field_is_required('card_address', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 917 | 917 | /> |
| 918 | 918 | </p> |
| 919 | 919 | |
| 920 | 920 | <p id="give-card-address-2-wrap" class="form-row form-row-one-third"> |
| 921 | 921 | <label for="card_address_2" class="give-label"> |
| 922 | - <?php esc_html_e( 'Address 2', 'give' ); ?> |
|
| 923 | - <?php if ( give_field_is_required( 'card_address_2', $form_id ) ) : ?> |
|
| 922 | + <?php esc_html_e('Address 2', 'give'); ?> |
|
| 923 | + <?php if (give_field_is_required('card_address_2', $form_id)) : ?> |
|
| 924 | 924 | <span class="give-required-indicator">*</span> |
| 925 | 925 | <?php endif; ?> |
| 926 | 926 | <span class="give-tooltip give-icon give-icon-question" |
| 927 | - data-tooltip="<?php esc_attr_e( '(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give' ); ?>"></span> |
|
| 927 | + data-tooltip="<?php esc_attr_e('(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give'); ?>"></span> |
|
| 928 | 928 | </label> |
| 929 | 929 | |
| 930 | 930 | <input |
| 931 | 931 | type="text" |
| 932 | 932 | id="card_address_2" |
| 933 | 933 | name="card_address_2" |
| 934 | - class="card-address-2 give-input<?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required' : '' ); ?>" |
|
| 935 | - placeholder="<?php esc_attr_e( 'Address line 2', 'give' ); ?>" |
|
| 936 | - value="<?php echo isset( $give_user_info['card_address_2'] ) ? $give_user_info['card_address_2'] : ''; ?>" |
|
| 937 | - <?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 934 | + class="card-address-2 give-input<?php echo(give_field_is_required('card_address_2', $form_id) ? ' required' : ''); ?>" |
|
| 935 | + placeholder="<?php esc_attr_e('Address line 2', 'give'); ?>" |
|
| 936 | + value="<?php echo isset($give_user_info['card_address_2']) ? $give_user_info['card_address_2'] : ''; ?>" |
|
| 937 | + <?php echo(give_field_is_required('card_address_2', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 938 | 938 | /> |
| 939 | 939 | </p> |
| 940 | 940 | |
| 941 | 941 | <p id="give-card-city-wrap" class="form-row form-row-two-thirds"> |
| 942 | 942 | <label for="card_city" class="give-label"> |
| 943 | - <?php esc_html_e( 'City', 'give' ); ?> |
|
| 944 | - <?php if ( give_field_is_required( 'card_city', $form_id ) ) : ?> |
|
| 943 | + <?php esc_html_e('City', 'give'); ?> |
|
| 944 | + <?php if (give_field_is_required('card_city', $form_id)) : ?> |
|
| 945 | 945 | <span class="give-required-indicator">*</span> |
| 946 | 946 | <?php endif; ?> |
| 947 | 947 | <span class="give-tooltip give-icon give-icon-question" |
| 948 | - data-tooltip="<?php esc_attr_e( 'The city for your billing address.', 'give' ); ?>"></span> |
|
| 948 | + data-tooltip="<?php esc_attr_e('The city for your billing address.', 'give'); ?>"></span> |
|
| 949 | 949 | </label> |
| 950 | 950 | <input |
| 951 | 951 | type="text" |
| 952 | 952 | id="card_city" |
| 953 | 953 | name="card_city" |
| 954 | - class="card-city give-input<?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required' : '' ); ?>" |
|
| 955 | - placeholder="<?php esc_attr_e( 'City', 'give' ); ?>" |
|
| 956 | - value="<?php echo isset( $give_user_info['card_city'] ) ? $give_user_info['card_city'] : ''; ?>" |
|
| 957 | - <?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 954 | + class="card-city give-input<?php echo(give_field_is_required('card_city', $form_id) ? ' required' : ''); ?>" |
|
| 955 | + placeholder="<?php esc_attr_e('City', 'give'); ?>" |
|
| 956 | + value="<?php echo isset($give_user_info['card_city']) ? $give_user_info['card_city'] : ''; ?>" |
|
| 957 | + <?php echo(give_field_is_required('card_city', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 958 | 958 | /> |
| 959 | 959 | </p> |
| 960 | 960 | |
| 961 | 961 | <p id="give-card-zip-wrap" class="form-row form-row-one-third"> |
| 962 | 962 | <label for="card_zip" class="give-label"> |
| 963 | - <?php esc_html_e( 'Zip / Postal Code', 'give' ); ?> |
|
| 964 | - <?php if ( give_field_is_required( 'card_zip', $form_id ) ) : ?> |
|
| 963 | + <?php esc_html_e('Zip / Postal Code', 'give'); ?> |
|
| 964 | + <?php if (give_field_is_required('card_zip', $form_id)) : ?> |
|
| 965 | 965 | <span class="give-required-indicator">*</span> |
| 966 | 966 | <?php endif; ?> |
| 967 | 967 | <span class="give-tooltip give-icon give-icon-question" |
| 968 | - data-tooltip="<?php esc_attr_e( 'The zip or postal code for your billing address.', 'give' ); ?>"></span> |
|
| 968 | + data-tooltip="<?php esc_attr_e('The zip or postal code for your billing address.', 'give'); ?>"></span> |
|
| 969 | 969 | </label> |
| 970 | 970 | |
| 971 | 971 | <input |
@@ -973,40 +973,40 @@ discard block |
||
| 973 | 973 | size="4" |
| 974 | 974 | id="card_zip" |
| 975 | 975 | name="card_zip" |
| 976 | - class="card-zip give-input<?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required' : '' ); ?>" |
|
| 977 | - placeholder="<?php esc_attr_e( 'Zip / Postal Code', 'give' ); ?>" |
|
| 978 | - value="<?php echo isset( $give_user_info['card_zip'] ) ? $give_user_info['card_zip'] : ''; ?>" |
|
| 979 | - <?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 976 | + class="card-zip give-input<?php echo(give_field_is_required('card_zip', $form_id) ? ' required' : ''); ?>" |
|
| 977 | + placeholder="<?php esc_attr_e('Zip / Postal Code', 'give'); ?>" |
|
| 978 | + value="<?php echo isset($give_user_info['card_zip']) ? $give_user_info['card_zip'] : ''; ?>" |
|
| 979 | + <?php echo(give_field_is_required('card_zip', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 980 | 980 | /> |
| 981 | 981 | </p> |
| 982 | 982 | |
| 983 | 983 | <p id="give-card-country-wrap" class="form-row form-row-first"> |
| 984 | 984 | <label for="billing_country" class="give-label"> |
| 985 | - <?php esc_html_e( 'Country', 'give' ); ?> |
|
| 986 | - <?php if ( give_field_is_required( 'billing_country', $form_id ) ) : ?> |
|
| 985 | + <?php esc_html_e('Country', 'give'); ?> |
|
| 986 | + <?php if (give_field_is_required('billing_country', $form_id)) : ?> |
|
| 987 | 987 | <span class="give-required-indicator">*</span> |
| 988 | 988 | <?php endif; ?> |
| 989 | 989 | <span class="give-tooltip give-icon give-icon-question" |
| 990 | - data-tooltip="<?php esc_attr_e( 'The country for your billing address.', 'give' ); ?>"></span> |
|
| 990 | + data-tooltip="<?php esc_attr_e('The country for your billing address.', 'give'); ?>"></span> |
|
| 991 | 991 | </label> |
| 992 | 992 | |
| 993 | 993 | <select |
| 994 | 994 | name="billing_country" |
| 995 | 995 | id="billing_country" |
| 996 | - class="billing-country billing_country give-select<?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required' : '' ); ?>" |
|
| 997 | - <?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 996 | + class="billing-country billing_country give-select<?php echo(give_field_is_required('billing_country', $form_id) ? ' required' : ''); ?>" |
|
| 997 | + <?php echo(give_field_is_required('billing_country', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 998 | 998 | > |
| 999 | 999 | <?php |
| 1000 | 1000 | |
| 1001 | 1001 | $selected_country = give_get_country(); |
| 1002 | 1002 | |
| 1003 | - if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
| 1003 | + if ( ! empty($give_user_info['billing_country']) && '*' !== $give_user_info['billing_country']) { |
|
| 1004 | 1004 | $selected_country = $give_user_info['billing_country']; |
| 1005 | 1005 | } |
| 1006 | 1006 | |
| 1007 | 1007 | $countries = give_get_country_list(); |
| 1008 | - foreach ( $countries as $country_code => $country ) { |
|
| 1009 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
| 1008 | + foreach ($countries as $country_code => $country) { |
|
| 1009 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
| 1010 | 1010 | } |
| 1011 | 1011 | ?> |
| 1012 | 1012 | </select> |
@@ -1014,39 +1014,39 @@ discard block |
||
| 1014 | 1014 | |
| 1015 | 1015 | <p id="give-card-state-wrap" class="form-row form-row-last"> |
| 1016 | 1016 | <label for="card_state" class="give-label"> |
| 1017 | - <?php esc_html_e( 'State / Province', 'give' ); ?> |
|
| 1018 | - <?php if ( give_field_is_required( 'card_state', $form_id ) ) : ?> |
|
| 1017 | + <?php esc_html_e('State / Province', 'give'); ?> |
|
| 1018 | + <?php if (give_field_is_required('card_state', $form_id)) : ?> |
|
| 1019 | 1019 | <span class="give-required-indicator">*</span> |
| 1020 | 1020 | <?php endif; ?> |
| 1021 | 1021 | <span class="give-tooltip give-icon give-icon-question" |
| 1022 | - data-tooltip="<?php esc_attr_e( 'The state or province for your billing address.', 'give' ); ?>"></span> |
|
| 1022 | + data-tooltip="<?php esc_attr_e('The state or province for your billing address.', 'give'); ?>"></span> |
|
| 1023 | 1023 | </label> |
| 1024 | 1024 | |
| 1025 | 1025 | <?php |
| 1026 | 1026 | $selected_state = give_get_state(); |
| 1027 | - $states = give_get_states( $selected_country ); |
|
| 1027 | + $states = give_get_states($selected_country); |
|
| 1028 | 1028 | |
| 1029 | - if ( ! empty( $give_user_info['card_state'] ) ) { |
|
| 1029 | + if ( ! empty($give_user_info['card_state'])) { |
|
| 1030 | 1030 | $selected_state = $give_user_info['card_state']; |
| 1031 | 1031 | } |
| 1032 | 1032 | |
| 1033 | - if ( ! empty( $states ) ) : ?> |
|
| 1033 | + if ( ! empty($states)) : ?> |
|
| 1034 | 1034 | <select |
| 1035 | 1035 | name="card_state" |
| 1036 | 1036 | id="card_state" |
| 1037 | - class="card_state give-select<?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required' : '' ); ?>" |
|
| 1038 | - <?php if ( give_field_is_required( 'card_state', $form_id ) ? ' required aria-required="true" ' : '' ) { |
|
| 1037 | + class="card_state give-select<?php echo(give_field_is_required('card_state', $form_id) ? ' required' : ''); ?>" |
|
| 1038 | + <?php if (give_field_is_required('card_state', $form_id) ? ' required aria-required="true" ' : '') { |
|
| 1039 | 1039 | ; |
| 1040 | 1040 | } ?>> |
| 1041 | 1041 | <?php |
| 1042 | - foreach ( $states as $state_code => $state ) { |
|
| 1043 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
| 1042 | + foreach ($states as $state_code => $state) { |
|
| 1043 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
| 1044 | 1044 | } |
| 1045 | 1045 | ?> |
| 1046 | 1046 | </select> |
| 1047 | 1047 | <?php else : ?> |
| 1048 | 1048 | <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" |
| 1049 | - placeholder="<?php esc_attr_e( 'State / Province', 'give' ); ?>"/> |
|
| 1049 | + placeholder="<?php esc_attr_e('State / Province', 'give'); ?>"/> |
|
| 1050 | 1050 | <?php endif; ?> |
| 1051 | 1051 | </p> |
| 1052 | 1052 | <?php |
@@ -1057,14 +1057,14 @@ discard block |
||
| 1057 | 1057 | * |
| 1058 | 1058 | * @param int $form_id The form ID. |
| 1059 | 1059 | */ |
| 1060 | - do_action( 'give_cc_billing_bottom' ); |
|
| 1060 | + do_action('give_cc_billing_bottom'); |
|
| 1061 | 1061 | ?> |
| 1062 | 1062 | </fieldset> |
| 1063 | 1063 | <?php |
| 1064 | 1064 | echo ob_get_clean(); |
| 1065 | 1065 | } |
| 1066 | 1066 | |
| 1067 | -add_action( 'give_after_cc_fields', 'give_default_cc_address_fields' ); |
|
| 1067 | +add_action('give_after_cc_fields', 'give_default_cc_address_fields'); |
|
| 1068 | 1068 | |
| 1069 | 1069 | |
| 1070 | 1070 | /** |
@@ -1076,27 +1076,27 @@ discard block |
||
| 1076 | 1076 | * |
| 1077 | 1077 | * @return string |
| 1078 | 1078 | */ |
| 1079 | -function give_get_register_fields( $form_id ) { |
|
| 1079 | +function give_get_register_fields($form_id) { |
|
| 1080 | 1080 | |
| 1081 | 1081 | global $user_ID; |
| 1082 | 1082 | |
| 1083 | - if ( is_user_logged_in() ) { |
|
| 1084 | - $user_data = get_userdata( $user_ID ); |
|
| 1083 | + if (is_user_logged_in()) { |
|
| 1084 | + $user_data = get_userdata($user_ID); |
|
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
| 1087 | + $show_register_form = give_show_login_register_option($form_id); |
|
| 1088 | 1088 | |
| 1089 | 1089 | ob_start(); ?> |
| 1090 | 1090 | <fieldset id="give-register-fields-<?php echo $form_id; ?>"> |
| 1091 | 1091 | |
| 1092 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
| 1092 | + <?php if ($show_register_form == 'both') { ?> |
|
| 1093 | 1093 | <div class="give-login-account-wrap"> |
| 1094 | - <p class="give-login-message"><?php esc_html_e( 'Already have an account?', 'give' ); ?> |
|
| 1095 | - <a href="<?php echo esc_url( add_query_arg( 'login', 1 ) ); ?>" class="give-checkout-login" |
|
| 1096 | - data-action="give_checkout_login"><?php esc_html_e( 'Login', 'give' ); ?></a> |
|
| 1094 | + <p class="give-login-message"><?php esc_html_e('Already have an account?', 'give'); ?> |
|
| 1095 | + <a href="<?php echo esc_url(add_query_arg('login', 1)); ?>" class="give-checkout-login" |
|
| 1096 | + data-action="give_checkout_login"><?php esc_html_e('Login', 'give'); ?></a> |
|
| 1097 | 1097 | </p> |
| 1098 | 1098 | <p class="give-loading-text"> |
| 1099 | - <span class="give-loading-animation"></span> <?php esc_html_e( 'Loading...', 'give' ); ?></p> |
|
| 1099 | + <span class="give-loading-animation"></span> <?php esc_html_e('Loading...', 'give'); ?></p> |
|
| 1100 | 1100 | </div> |
| 1101 | 1101 | <?php } ?> |
| 1102 | 1102 | |
@@ -1108,15 +1108,15 @@ discard block |
||
| 1108 | 1108 | * |
| 1109 | 1109 | * @param int $form_id The form ID. |
| 1110 | 1110 | */ |
| 1111 | - do_action( 'give_register_fields_before', $form_id ); |
|
| 1111 | + do_action('give_register_fields_before', $form_id); |
|
| 1112 | 1112 | ?> |
| 1113 | 1113 | |
| 1114 | 1114 | <fieldset id="give-register-account-fields-<?php echo $form_id; ?>"> |
| 1115 | 1115 | <legend> |
| 1116 | 1116 | <?php |
| 1117 | - echo apply_filters( 'give_create_account_fieldset_heading', esc_html__( 'Create an account', 'give' ) ); |
|
| 1118 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
| 1119 | - echo ' <span class="sub-text">' . esc_html__( '(optional)', 'give' ) . '</span>'; |
|
| 1117 | + echo apply_filters('give_create_account_fieldset_heading', esc_html__('Create an account', 'give')); |
|
| 1118 | + if ( ! give_logged_in_only($form_id)) { |
|
| 1119 | + echo ' <span class="sub-text">'.esc_html__('(optional)', 'give').'</span>'; |
|
| 1120 | 1120 | } |
| 1121 | 1121 | ?> |
| 1122 | 1122 | </legend> |
@@ -1128,52 +1128,52 @@ discard block |
||
| 1128 | 1128 | * |
| 1129 | 1129 | * @param int $form_id The form ID. |
| 1130 | 1130 | */ |
| 1131 | - do_action( 'give_register_account_fields_before', $form_id ); |
|
| 1131 | + do_action('give_register_account_fields_before', $form_id); |
|
| 1132 | 1132 | ?> |
| 1133 | 1133 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-one-third form-row-first"> |
| 1134 | 1134 | <label for="give-user-login-<?php echo $form_id; ?>"> |
| 1135 | - <?php esc_html_e( 'Username', 'give' ); ?> |
|
| 1136 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1135 | + <?php esc_html_e('Username', 'give'); ?> |
|
| 1136 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1137 | 1137 | <span class="give-required-indicator">*</span> |
| 1138 | 1138 | <?php } ?> |
| 1139 | 1139 | <span class="give-tooltip give-icon give-icon-question" |
| 1140 | - data-tooltip="<?php esc_attr_e( 'The username you will use to log into your account.', 'give' ); ?>"></span> |
|
| 1140 | + data-tooltip="<?php esc_attr_e('The username you will use to log into your account.', 'give'); ?>"></span> |
|
| 1141 | 1141 | </label> |
| 1142 | 1142 | |
| 1143 | 1143 | <input name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" class="give-input" |
| 1144 | 1144 | type="text" |
| 1145 | - placeholder="<?php esc_attr_e( 'Username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1145 | + placeholder="<?php esc_attr_e('Username', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1146 | 1146 | </div> |
| 1147 | 1147 | |
| 1148 | 1148 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" class="form-row form-row-one-third"> |
| 1149 | 1149 | <label for="give-user-pass-<?php echo $form_id; ?>"> |
| 1150 | - <?php esc_html_e( 'Password', 'give' ); ?> |
|
| 1151 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1150 | + <?php esc_html_e('Password', 'give'); ?> |
|
| 1151 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1152 | 1152 | <span class="give-required-indicator">*</span> |
| 1153 | 1153 | <?php } ?> |
| 1154 | 1154 | <span class="give-tooltip give-icon give-icon-question" |
| 1155 | - data-tooltip="<?php esc_attr_e( 'The password used to access your account.', 'give' ); ?>"></span> |
|
| 1155 | + data-tooltip="<?php esc_attr_e('The password used to access your account.', 'give'); ?>"></span> |
|
| 1156 | 1156 | </label> |
| 1157 | 1157 | |
| 1158 | 1158 | <input name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" class="give-input" |
| 1159 | - placeholder="<?php esc_attr_e( 'Password', 'give' ); ?>" |
|
| 1160 | - type="password"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1159 | + placeholder="<?php esc_attr_e('Password', 'give'); ?>" |
|
| 1160 | + type="password"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1161 | 1161 | </div> |
| 1162 | 1162 | |
| 1163 | 1163 | <div id="give-user-pass-confirm-wrap-<?php echo $form_id; ?>" |
| 1164 | 1164 | class="give-register-password form-row form-row-one-third"> |
| 1165 | 1165 | <label for="give-user-pass-confirm-<?php echo $form_id; ?>"> |
| 1166 | - <?php esc_html_e( 'Confirm PW', 'give' ); ?> |
|
| 1167 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1166 | + <?php esc_html_e('Confirm PW', 'give'); ?> |
|
| 1167 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1168 | 1168 | <span class="give-required-indicator">*</span> |
| 1169 | 1169 | <?php } ?> |
| 1170 | 1170 | <span class="give-tooltip give-icon give-icon-question" |
| 1171 | - data-tooltip="<?php esc_attr_e( 'Please retype your password to confirm.', 'give' ); ?>"></span> |
|
| 1171 | + data-tooltip="<?php esc_attr_e('Please retype your password to confirm.', 'give'); ?>"></span> |
|
| 1172 | 1172 | </label> |
| 1173 | 1173 | |
| 1174 | 1174 | <input name="give_user_pass_confirm" id="give-user-pass-confirm-<?php echo $form_id; ?>" |
| 1175 | - class="give-input" placeholder="<?php esc_attr_e( 'Confirm password', 'give' ); ?>" |
|
| 1176 | - type="password"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1175 | + class="give-input" placeholder="<?php esc_attr_e('Confirm password', 'give'); ?>" |
|
| 1176 | + type="password"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1177 | 1177 | </div> |
| 1178 | 1178 | <?php |
| 1179 | 1179 | /** |
@@ -1183,7 +1183,7 @@ discard block |
||
| 1183 | 1183 | * |
| 1184 | 1184 | * @param int $form_id The form ID. |
| 1185 | 1185 | */ |
| 1186 | - do_action( 'give_register_account_fields_after', $form_id ); |
|
| 1186 | + do_action('give_register_account_fields_after', $form_id); |
|
| 1187 | 1187 | ?> |
| 1188 | 1188 | </fieldset> |
| 1189 | 1189 | |
@@ -1195,7 +1195,7 @@ discard block |
||
| 1195 | 1195 | * |
| 1196 | 1196 | * @param int $form_id The form ID. |
| 1197 | 1197 | */ |
| 1198 | - do_action( 'give_register_fields_after', $form_id ); |
|
| 1198 | + do_action('give_register_fields_after', $form_id); |
|
| 1199 | 1199 | ?> |
| 1200 | 1200 | |
| 1201 | 1201 | <input type="hidden" name="give-purchase-var" value="needs-to-register"/> |
@@ -1206,7 +1206,7 @@ discard block |
||
| 1206 | 1206 | * |
| 1207 | 1207 | * @since 1.7 |
| 1208 | 1208 | */ |
| 1209 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
| 1209 | + do_action('give_donation_form_user_info', $form_id); |
|
| 1210 | 1210 | ?> |
| 1211 | 1211 | |
| 1212 | 1212 | </fieldset> |
@@ -1214,7 +1214,7 @@ discard block |
||
| 1214 | 1214 | echo ob_get_clean(); |
| 1215 | 1215 | } |
| 1216 | 1216 | |
| 1217 | -add_action( 'give_donation_form_register_fields', 'give_get_register_fields' ); |
|
| 1217 | +add_action('give_donation_form_register_fields', 'give_get_register_fields'); |
|
| 1218 | 1218 | |
| 1219 | 1219 | /** |
| 1220 | 1220 | * Gets the login fields for the login form on the checkout. This function hooks |
@@ -1227,32 +1227,32 @@ discard block |
||
| 1227 | 1227 | * |
| 1228 | 1228 | * @return string |
| 1229 | 1229 | */ |
| 1230 | -function give_get_login_fields( $form_id ) { |
|
| 1230 | +function give_get_login_fields($form_id) { |
|
| 1231 | 1231 | |
| 1232 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : $form_id; |
|
| 1233 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
| 1232 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : $form_id; |
|
| 1233 | + $show_register_form = give_show_login_register_option($form_id); |
|
| 1234 | 1234 | |
| 1235 | 1235 | ob_start(); |
| 1236 | 1236 | ?> |
| 1237 | 1237 | <fieldset id="give-login-fields-<?php echo $form_id; ?>"> |
| 1238 | - <legend><?php echo apply_filters( 'give_account_login_fieldset_heading', esc_html__( 'Login to Your Account', 'give' ) ); |
|
| 1239 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
| 1240 | - echo ' <span class="sub-text">' . esc_html__( '(optional)', 'give' ) . '</span>'; |
|
| 1238 | + <legend><?php echo apply_filters('give_account_login_fieldset_heading', esc_html__('Login to Your Account', 'give')); |
|
| 1239 | + if ( ! give_logged_in_only($form_id)) { |
|
| 1240 | + echo ' <span class="sub-text">'.esc_html__('(optional)', 'give').'</span>'; |
|
| 1241 | 1241 | } ?> |
| 1242 | 1242 | </legend> |
| 1243 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
| 1243 | + <?php if ($show_register_form == 'both') { ?> |
|
| 1244 | 1244 | <p class="give-new-account-link"> |
| 1245 | - <?php esc_html_e( 'Need to create an account?', 'give' ); ?> |
|
| 1246 | - <a href="<?php echo remove_query_arg( 'login' ); ?>" class="give-checkout-register-cancel" |
|
| 1245 | + <?php esc_html_e('Need to create an account?', 'give'); ?> |
|
| 1246 | + <a href="<?php echo remove_query_arg('login'); ?>" class="give-checkout-register-cancel" |
|
| 1247 | 1247 | data-action="give_checkout_register"> |
| 1248 | - <?php esc_html_e( 'Register', 'give' ); |
|
| 1249 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
| 1250 | - echo ' ' . esc_html__( 'or checkout as a guest »', 'give' ); |
|
| 1248 | + <?php esc_html_e('Register', 'give'); |
|
| 1249 | + if ( ! give_logged_in_only($form_id)) { |
|
| 1250 | + echo ' '.esc_html__('or checkout as a guest »', 'give'); |
|
| 1251 | 1251 | } ?> |
| 1252 | 1252 | </a> |
| 1253 | 1253 | </p> |
| 1254 | 1254 | <p class="give-loading-text"> |
| 1255 | - <span class="give-loading-animation"></span> <?php esc_html_e( 'Loading...', 'give' ); ?> </p> |
|
| 1255 | + <span class="give-loading-animation"></span> <?php esc_html_e('Loading...', 'give'); ?> </p> |
|
| 1256 | 1256 | <?php } ?> |
| 1257 | 1257 | <?php |
| 1258 | 1258 | /** |
@@ -1262,48 +1262,48 @@ discard block |
||
| 1262 | 1262 | * |
| 1263 | 1263 | * @param int $form_id The form ID. |
| 1264 | 1264 | */ |
| 1265 | - do_action( 'give_checkout_login_fields_before', $form_id ); |
|
| 1265 | + do_action('give_checkout_login_fields_before', $form_id); |
|
| 1266 | 1266 | ?> |
| 1267 | 1267 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-first"> |
| 1268 | 1268 | <label class="give-label" for="give-user-login-<?php echo $form_id; ?>"> |
| 1269 | - <?php esc_html_e( 'Username', 'give' ); ?> |
|
| 1270 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1269 | + <?php esc_html_e('Username', 'give'); ?> |
|
| 1270 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1271 | 1271 | <span class="give-required-indicator">*</span> |
| 1272 | 1272 | <?php } ?> |
| 1273 | 1273 | </label> |
| 1274 | 1274 | |
| 1275 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" type="text" |
|
| 1275 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" type="text" |
|
| 1276 | 1276 | name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" |
| 1277 | - placeholder="<?php esc_attr_e( 'Your username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1277 | + placeholder="<?php esc_attr_e('Your username', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1278 | 1278 | </div> |
| 1279 | 1279 | |
| 1280 | 1280 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" class="give_login_password form-row form-row-last"> |
| 1281 | 1281 | <label class="give-label" for="give-user-pass-<?php echo $form_id; ?>"> |
| 1282 | - <?php esc_html_e( 'Password', 'give' ); ?> |
|
| 1283 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1282 | + <?php esc_html_e('Password', 'give'); ?> |
|
| 1283 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1284 | 1284 | <span class="give-required-indicator">*</span> |
| 1285 | 1285 | <?php } ?> |
| 1286 | 1286 | </label> |
| 1287 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" |
|
| 1287 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" |
|
| 1288 | 1288 | type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" |
| 1289 | - placeholder="<?php esc_attr_e( 'Your password', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1289 | + placeholder="<?php esc_attr_e('Your password', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1290 | 1290 | <input type="hidden" name="give-purchase-var" value="needs-to-login"/> |
| 1291 | 1291 | </div> |
| 1292 | 1292 | |
| 1293 | 1293 | <div id="give-forgot-password-wrap-<?php echo $form_id; ?>" class="give_login_forgot_password"> |
| 1294 | 1294 | <span class="give-forgot-password "> |
| 1295 | 1295 | <a href="<?php echo wp_lostpassword_url() ?>" |
| 1296 | - target="_blank"><?php esc_html_e( 'Reset Password', 'give' ) ?></a> |
|
| 1296 | + target="_blank"><?php esc_html_e('Reset Password', 'give') ?></a> |
|
| 1297 | 1297 | </span> |
| 1298 | 1298 | </div> |
| 1299 | 1299 | |
| 1300 | 1300 | <div id="give-user-login-submit-<?php echo $form_id; ?>" class="give-clearfix"> |
| 1301 | 1301 | <input type="submit" class="give-submit give-btn button" name="give_login_submit" |
| 1302 | - value="<?php esc_attr_e( 'Login', 'give' ); ?>"/> |
|
| 1303 | - <?php if ( $show_register_form !== 'login' ) { ?> |
|
| 1302 | + value="<?php esc_attr_e('Login', 'give'); ?>"/> |
|
| 1303 | + <?php if ($show_register_form !== 'login') { ?> |
|
| 1304 | 1304 | <input type="button" data-action="give_cancel_login" |
| 1305 | 1305 | class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel" |
| 1306 | - value="<?php esc_attr_e( 'Cancel', 'give' ); ?>"/> |
|
| 1306 | + value="<?php esc_attr_e('Cancel', 'give'); ?>"/> |
|
| 1307 | 1307 | <?php } ?> |
| 1308 | 1308 | <span class="give-loading-animation"></span> |
| 1309 | 1309 | </div> |
@@ -1315,14 +1315,14 @@ discard block |
||
| 1315 | 1315 | * |
| 1316 | 1316 | * @param int $form_id The form ID. |
| 1317 | 1317 | */ |
| 1318 | - do_action( 'give_checkout_login_fields_after', $form_id ); |
|
| 1318 | + do_action('give_checkout_login_fields_after', $form_id); |
|
| 1319 | 1319 | ?> |
| 1320 | 1320 | </fieldset><!--end #give-login-fields--> |
| 1321 | 1321 | <?php |
| 1322 | 1322 | echo ob_get_clean(); |
| 1323 | 1323 | } |
| 1324 | 1324 | |
| 1325 | -add_action( 'give_donation_form_login_fields', 'give_get_login_fields', 10, 1 ); |
|
| 1325 | +add_action('give_donation_form_login_fields', 'give_get_login_fields', 10, 1); |
|
| 1326 | 1326 | |
| 1327 | 1327 | /** |
| 1328 | 1328 | * Payment Mode Select. |
@@ -1338,7 +1338,7 @@ discard block |
||
| 1338 | 1338 | * |
| 1339 | 1339 | * @return void |
| 1340 | 1340 | */ |
| 1341 | -function give_payment_mode_select( $form_id ) { |
|
| 1341 | +function give_payment_mode_select($form_id) { |
|
| 1342 | 1342 | |
| 1343 | 1343 | $gateways = give_get_enabled_payment_gateways(); |
| 1344 | 1344 | |
@@ -1349,10 +1349,10 @@ discard block |
||
| 1349 | 1349 | * |
| 1350 | 1350 | * @param int $form_id The form ID. |
| 1351 | 1351 | */ |
| 1352 | - do_action( 'give_payment_mode_top', $form_id ); |
|
| 1352 | + do_action('give_payment_mode_top', $form_id); |
|
| 1353 | 1353 | ?> |
| 1354 | 1354 | |
| 1355 | - <fieldset id="give-payment-mode-select" <?php if ( count( $gateways ) <= 1 ) { |
|
| 1355 | + <fieldset id="give-payment-mode-select" <?php if (count($gateways) <= 1) { |
|
| 1356 | 1356 | echo 'style="display: none;"'; |
| 1357 | 1357 | } ?>> |
| 1358 | 1358 | <?php |
@@ -1363,14 +1363,14 @@ discard block |
||
| 1363 | 1363 | * |
| 1364 | 1364 | * @param int $form_id The form ID. |
| 1365 | 1365 | */ |
| 1366 | - do_action( 'give_payment_mode_before_gateways_wrap' ); |
|
| 1366 | + do_action('give_payment_mode_before_gateways_wrap'); |
|
| 1367 | 1367 | ?> |
| 1368 | 1368 | <legend |
| 1369 | - class="give-payment-mode-label"><?php echo apply_filters( 'give_checkout_payment_method_text', esc_html__( 'Select Payment Method', 'give' ) ); ?></legend> |
|
| 1369 | + class="give-payment-mode-label"><?php echo apply_filters('give_checkout_payment_method_text', esc_html__('Select Payment Method', 'give')); ?></legend> |
|
| 1370 | 1370 | |
| 1371 | 1371 | <div id="give-payment-mode-wrap"> |
| 1372 | 1372 | <span class="give-loading-text"><span |
| 1373 | - class="give-loading-animation"></span> <?php esc_html_e( 'Loading...', 'give' ); ?></span> |
|
| 1373 | + class="give-loading-animation"></span> <?php esc_html_e('Loading...', 'give'); ?></span> |
|
| 1374 | 1374 | |
| 1375 | 1375 | <?php |
| 1376 | 1376 | /** |
@@ -1378,26 +1378,26 @@ discard block |
||
| 1378 | 1378 | * |
| 1379 | 1379 | * @since 1.7 |
| 1380 | 1380 | */ |
| 1381 | - do_action( 'give_payment_mode_before_gateways' ) |
|
| 1381 | + do_action('give_payment_mode_before_gateways') |
|
| 1382 | 1382 | ?> |
| 1383 | 1383 | <ul id="give-gateway-radio-list"> |
| 1384 | 1384 | <?php |
| 1385 | 1385 | /** |
| 1386 | 1386 | * Loop through the active payment gateways. |
| 1387 | 1387 | */ |
| 1388 | - $selected_gateway = give_get_chosen_gateway( $form_id ); |
|
| 1388 | + $selected_gateway = give_get_chosen_gateway($form_id); |
|
| 1389 | 1389 | |
| 1390 | - foreach ( $gateways as $gateway_id => $gateway ) : |
|
| 1390 | + foreach ($gateways as $gateway_id => $gateway) : |
|
| 1391 | 1391 | //Determine the default gateway. |
| 1392 | - $checked = checked( $gateway_id, $selected_gateway, false ); |
|
| 1392 | + $checked = checked($gateway_id, $selected_gateway, false); |
|
| 1393 | 1393 | $checked_class = $checked ? ' class="give-gateway-option-selected"' : ''; ?> |
| 1394 | 1394 | <li<?php echo $checked_class?>> |
| 1395 | 1395 | <input type="radio" name="payment-mode" class="give-gateway" |
| 1396 | - id="give-gateway-<?php echo esc_attr( $gateway_id ) . '-' . $form_id; ?>" |
|
| 1397 | - value="<?php echo esc_attr( $gateway_id ); ?>"<?php echo $checked; ?>> |
|
| 1398 | - <label for="give-gateway-<?php echo esc_attr( $gateway_id ) . '-' . $form_id; ?>" |
|
| 1396 | + id="give-gateway-<?php echo esc_attr($gateway_id).'-'.$form_id; ?>" |
|
| 1397 | + value="<?php echo esc_attr($gateway_id); ?>"<?php echo $checked; ?>> |
|
| 1398 | + <label for="give-gateway-<?php echo esc_attr($gateway_id).'-'.$form_id; ?>" |
|
| 1399 | 1399 | class="give-gateway-option" |
| 1400 | - id="give-gateway-option-<?php echo esc_attr( $gateway_id ); ?>"> <?php echo esc_html( $gateway['checkout_label'] ); ?></label> |
|
| 1400 | + id="give-gateway-option-<?php echo esc_attr($gateway_id); ?>"> <?php echo esc_html($gateway['checkout_label']); ?></label> |
|
| 1401 | 1401 | </li> |
| 1402 | 1402 | <?php |
| 1403 | 1403 | endforeach; |
@@ -1409,7 +1409,7 @@ discard block |
||
| 1409 | 1409 | * |
| 1410 | 1410 | * @since 1.7 |
| 1411 | 1411 | */ |
| 1412 | - do_action( 'give_payment_mode_after_gateways' ); |
|
| 1412 | + do_action('give_payment_mode_after_gateways'); |
|
| 1413 | 1413 | ?> |
| 1414 | 1414 | </div> |
| 1415 | 1415 | <?php |
@@ -1420,7 +1420,7 @@ discard block |
||
| 1420 | 1420 | * |
| 1421 | 1421 | * @param int $form_id The form ID. |
| 1422 | 1422 | */ |
| 1423 | - do_action( 'give_payment_mode_after_gateways_wrap' ); |
|
| 1423 | + do_action('give_payment_mode_after_gateways_wrap'); |
|
| 1424 | 1424 | ?> |
| 1425 | 1425 | </fieldset> |
| 1426 | 1426 | |
@@ -1432,7 +1432,7 @@ discard block |
||
| 1432 | 1432 | * |
| 1433 | 1433 | * @param int $form_id The form ID. |
| 1434 | 1434 | */ |
| 1435 | - do_action( 'give_payment_mode_bottom', $form_id ); |
|
| 1435 | + do_action('give_payment_mode_bottom', $form_id); |
|
| 1436 | 1436 | ?> |
| 1437 | 1437 | |
| 1438 | 1438 | <div id="give_purchase_form_wrap"> |
@@ -1443,7 +1443,7 @@ discard block |
||
| 1443 | 1443 | * |
| 1444 | 1444 | * @since 1.7 |
| 1445 | 1445 | */ |
| 1446 | - do_action( 'give_donation_form', $form_id ); |
|
| 1446 | + do_action('give_donation_form', $form_id); |
|
| 1447 | 1447 | ?> |
| 1448 | 1448 | |
| 1449 | 1449 | </div> |
@@ -1454,10 +1454,10 @@ discard block |
||
| 1454 | 1454 | * |
| 1455 | 1455 | * @since 1.7 |
| 1456 | 1456 | */ |
| 1457 | - do_action( 'give_donation_form_wrap_bottom', $form_id ); |
|
| 1457 | + do_action('give_donation_form_wrap_bottom', $form_id); |
|
| 1458 | 1458 | } |
| 1459 | 1459 | |
| 1460 | -add_action( 'give_payment_mode_select', 'give_payment_mode_select' ); |
|
| 1460 | +add_action('give_payment_mode_select', 'give_payment_mode_select'); |
|
| 1461 | 1461 | |
| 1462 | 1462 | /** |
| 1463 | 1463 | * Renders the Checkout Agree to Terms, this displays a checkbox for users to |
@@ -1470,25 +1470,25 @@ discard block |
||
| 1470 | 1470 | * |
| 1471 | 1471 | * @return void|bool |
| 1472 | 1472 | */ |
| 1473 | -function give_terms_agreement( $form_id ) { |
|
| 1474 | - $form_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
| 1473 | +function give_terms_agreement($form_id) { |
|
| 1474 | + $form_option = get_post_meta($form_id, '_give_terms_option', true); |
|
| 1475 | 1475 | |
| 1476 | 1476 | // Bailout if per form and global term and conditions is not setup. |
| 1477 | - if ( 'yes' !== $form_option ) { |
|
| 1477 | + if ('yes' !== $form_option) { |
|
| 1478 | 1478 | return false; |
| 1479 | 1479 | } |
| 1480 | 1480 | |
| 1481 | - $label = ( $label = get_post_meta( $form_id, '_give_agree_label', true ) ) ? stripslashes( $label ) : give_get_option( 'agree_to_terms_label', esc_html__( 'Agree to Terms?', 'give' ) ); |
|
| 1482 | - $terms = ( $terms = get_post_meta( $form_id, '_give_agree_text', true ) ) ? $terms : give_get_option( 'agreement_text', '' ); |
|
| 1481 | + $label = ($label = get_post_meta($form_id, '_give_agree_label', true)) ? stripslashes($label) : give_get_option('agree_to_terms_label', esc_html__('Agree to Terms?', 'give')); |
|
| 1482 | + $terms = ($terms = get_post_meta($form_id, '_give_agree_text', true)) ? $terms : give_get_option('agreement_text', ''); |
|
| 1483 | 1483 | |
| 1484 | 1484 | // Set term and conditions label and text on basis of per form and global setting. |
| 1485 | 1485 | // $label = ( $label = get_post_meta( $form_id, '_give_agree_label', true ) ) ? stripslashes( $label ) : give_get_option( 'agree_to_terms_label', esc_html__( 'Agree to Terms?', 'give' ) ); |
| 1486 | 1486 | // $terms = ( $terms = get_post_meta( $form_id, '_give_agree_text', true ) ) ? $terms : give_get_option( 'agreement_text', '' ); |
| 1487 | 1487 | |
| 1488 | 1488 | // Bailout: Check if term and conditions text is empty or not. |
| 1489 | - if ( empty( $terms ) ) { |
|
| 1490 | - if ( is_user_logged_in() && current_user_can( 'manage_options' ) ) { |
|
| 1491 | - echo sprintf( __( 'Please enter term and conditions in <a href="%s">this form\'s settings</a>.', 'give' ), admin_url( 'post.php?post=' . $form_id . '&action=edit' ) ); |
|
| 1489 | + if (empty($terms)) { |
|
| 1490 | + if (is_user_logged_in() && current_user_can('manage_options')) { |
|
| 1491 | + echo sprintf(__('Please enter term and conditions in <a href="%s">this form\'s settings</a>.', 'give'), admin_url('post.php?post='.$form_id.'&action=edit')); |
|
| 1492 | 1492 | } |
| 1493 | 1493 | |
| 1494 | 1494 | return false; |
@@ -1496,7 +1496,7 @@ discard block |
||
| 1496 | 1496 | |
| 1497 | 1497 | ?> |
| 1498 | 1498 | <fieldset id="give_terms_agreement"> |
| 1499 | - <legend><?php echo apply_filters( 'give_terms_agreement_text', esc_html__( 'Terms', 'give' ) ); ?></legend> |
|
| 1499 | + <legend><?php echo apply_filters('give_terms_agreement_text', esc_html__('Terms', 'give')); ?></legend> |
|
| 1500 | 1500 | <div id="give_terms" class="give_terms-<?php echo $form_id; ?>" style="display:none;"> |
| 1501 | 1501 | <?php |
| 1502 | 1502 | /** |
@@ -1504,22 +1504,22 @@ discard block |
||
| 1504 | 1504 | * |
| 1505 | 1505 | * @since 1.0 |
| 1506 | 1506 | */ |
| 1507 | - do_action( 'give_before_terms' ); |
|
| 1507 | + do_action('give_before_terms'); |
|
| 1508 | 1508 | |
| 1509 | - echo wpautop( stripslashes( $terms ) ); |
|
| 1509 | + echo wpautop(stripslashes($terms)); |
|
| 1510 | 1510 | /** |
| 1511 | 1511 | * Fires while rendering terms of agreement, after the fields. |
| 1512 | 1512 | * |
| 1513 | 1513 | * @since 1.0 |
| 1514 | 1514 | */ |
| 1515 | - do_action( 'give_after_terms' ); |
|
| 1515 | + do_action('give_after_terms'); |
|
| 1516 | 1516 | ?> |
| 1517 | 1517 | </div> |
| 1518 | 1518 | <div id="give_show_terms"> |
| 1519 | 1519 | <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
| 1520 | - aria-controls="give_terms"><?php esc_html_e( 'Show Terms', 'give' ); ?></a> |
|
| 1520 | + aria-controls="give_terms"><?php esc_html_e('Show Terms', 'give'); ?></a> |
|
| 1521 | 1521 | <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
| 1522 | - aria-controls="give_terms" style="display:none;"><?php esc_html_e( 'Hide Terms', 'give' ); ?></a> |
|
| 1522 | + aria-controls="give_terms" style="display:none;"><?php esc_html_e('Hide Terms', 'give'); ?></a> |
|
| 1523 | 1523 | </div> |
| 1524 | 1524 | |
| 1525 | 1525 | <input name="give_agree_to_terms" class="required" type="checkbox" id="give_agree_to_terms-<?php echo $form_id; ?>" value="1" required aria-required="true" /> |
@@ -1529,7 +1529,7 @@ discard block |
||
| 1529 | 1529 | <?php |
| 1530 | 1530 | } |
| 1531 | 1531 | |
| 1532 | -add_action( 'give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1 ); |
|
| 1532 | +add_action('give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1); |
|
| 1533 | 1533 | |
| 1534 | 1534 | /** |
| 1535 | 1535 | * Checkout Final Total. |
@@ -1542,29 +1542,29 @@ discard block |
||
| 1542 | 1542 | * |
| 1543 | 1543 | * @return void |
| 1544 | 1544 | */ |
| 1545 | -function give_checkout_final_total( $form_id ) { |
|
| 1545 | +function give_checkout_final_total($form_id) { |
|
| 1546 | 1546 | |
| 1547 | - if ( isset( $_POST['give_total'] ) ) { |
|
| 1548 | - $total = apply_filters( 'give_donation_total', $_POST['give_total'] ); |
|
| 1547 | + if (isset($_POST['give_total'])) { |
|
| 1548 | + $total = apply_filters('give_donation_total', $_POST['give_total']); |
|
| 1549 | 1549 | } else { |
| 1550 | 1550 | //default total. |
| 1551 | - $total = give_get_default_form_amount( $form_id ); |
|
| 1551 | + $total = give_get_default_form_amount($form_id); |
|
| 1552 | 1552 | } |
| 1553 | 1553 | //Only proceed if give_total available. |
| 1554 | - if ( empty( $total ) ) { |
|
| 1554 | + if (empty($total)) { |
|
| 1555 | 1555 | return; |
| 1556 | 1556 | } |
| 1557 | 1557 | ?> |
| 1558 | 1558 | <p id="give-final-total-wrap" class="form-wrap "> |
| 1559 | 1559 | <span |
| 1560 | - class="give-donation-total-label"><?php echo apply_filters( 'give_donation_total_label', esc_html__( 'Donation Total:', 'give' ) ); ?></span> |
|
| 1560 | + class="give-donation-total-label"><?php echo apply_filters('give_donation_total_label', esc_html__('Donation Total:', 'give')); ?></span> |
|
| 1561 | 1561 | <span class="give-final-total-amount" |
| 1562 | - data-total="<?php echo give_format_amount( $total ); ?>"><?php echo give_currency_filter( give_format_amount( $total ) ); ?></span> |
|
| 1562 | + data-total="<?php echo give_format_amount($total); ?>"><?php echo give_currency_filter(give_format_amount($total)); ?></span> |
|
| 1563 | 1563 | </p> |
| 1564 | 1564 | <?php |
| 1565 | 1565 | } |
| 1566 | 1566 | |
| 1567 | -add_action( 'give_donation_form_before_submit', 'give_checkout_final_total', 999 ); |
|
| 1567 | +add_action('give_donation_form_before_submit', 'give_checkout_final_total', 999); |
|
| 1568 | 1568 | |
| 1569 | 1569 | /** |
| 1570 | 1570 | * Renders the Checkout Submit section. |
@@ -1575,7 +1575,7 @@ discard block |
||
| 1575 | 1575 | * |
| 1576 | 1576 | * @return void |
| 1577 | 1577 | */ |
| 1578 | -function give_checkout_submit( $form_id ) { |
|
| 1578 | +function give_checkout_submit($form_id) { |
|
| 1579 | 1579 | ?> |
| 1580 | 1580 | <fieldset id="give_purchase_submit"> |
| 1581 | 1581 | <?php |
@@ -1584,24 +1584,24 @@ discard block |
||
| 1584 | 1584 | * |
| 1585 | 1585 | * @since 1.7 |
| 1586 | 1586 | */ |
| 1587 | - do_action( 'give_donation_form_before_submit', $form_id ); |
|
| 1587 | + do_action('give_donation_form_before_submit', $form_id); |
|
| 1588 | 1588 | |
| 1589 | - give_checkout_hidden_fields( $form_id ); |
|
| 1589 | + give_checkout_hidden_fields($form_id); |
|
| 1590 | 1590 | |
| 1591 | - echo give_checkout_button_purchase( $form_id ); |
|
| 1591 | + echo give_checkout_button_purchase($form_id); |
|
| 1592 | 1592 | |
| 1593 | 1593 | /** |
| 1594 | 1594 | * Fire after donation form submit. |
| 1595 | 1595 | * |
| 1596 | 1596 | * @since 1.7 |
| 1597 | 1597 | */ |
| 1598 | - do_action( 'give_donation_form_after_submit', $form_id ); |
|
| 1598 | + do_action('give_donation_form_after_submit', $form_id); |
|
| 1599 | 1599 | ?> |
| 1600 | 1600 | </fieldset> |
| 1601 | 1601 | <?php |
| 1602 | 1602 | } |
| 1603 | 1603 | |
| 1604 | -add_action( 'give_donation_form_after_cc_form', 'give_checkout_submit', 9999 ); |
|
| 1604 | +add_action('give_donation_form_after_cc_form', 'give_checkout_submit', 9999); |
|
| 1605 | 1605 | |
| 1606 | 1606 | /** |
| 1607 | 1607 | * Give Checkout Button. |
@@ -1614,10 +1614,10 @@ discard block |
||
| 1614 | 1614 | * |
| 1615 | 1615 | * @return string |
| 1616 | 1616 | */ |
| 1617 | -function give_checkout_button_purchase( $form_id ) { |
|
| 1617 | +function give_checkout_button_purchase($form_id) { |
|
| 1618 | 1618 | |
| 1619 | - $display_label_field = get_post_meta( $form_id, '_give_checkout_label', true ); |
|
| 1620 | - $display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
| 1619 | + $display_label_field = get_post_meta($form_id, '_give_checkout_label', true); |
|
| 1620 | + $display_label = ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
| 1621 | 1621 | ob_start(); ?> |
| 1622 | 1622 | <div class="give-submit-button-wrap give-clearfix"> |
| 1623 | 1623 | <input type="submit" class="give-submit give-btn" id="give-purchase-button" name="give-purchase" |
@@ -1625,7 +1625,7 @@ discard block |
||
| 1625 | 1625 | <span class="give-loading-animation"></span> |
| 1626 | 1626 | </div> |
| 1627 | 1627 | <?php |
| 1628 | - return apply_filters( 'give_checkout_button_purchase', ob_get_clean(), $form_id ); |
|
| 1628 | + return apply_filters('give_checkout_button_purchase', ob_get_clean(), $form_id); |
|
| 1629 | 1629 | } |
| 1630 | 1630 | |
| 1631 | 1631 | /** |
@@ -1639,18 +1639,18 @@ discard block |
||
| 1639 | 1639 | * |
| 1640 | 1640 | * @return void |
| 1641 | 1641 | */ |
| 1642 | -function give_agree_to_terms_js( $form_id ) { |
|
| 1642 | +function give_agree_to_terms_js($form_id) { |
|
| 1643 | 1643 | |
| 1644 | - $form_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
| 1644 | + $form_option = get_post_meta($form_id, '_give_terms_option', true); |
|
| 1645 | 1645 | |
| 1646 | - if ( $form_option === 'yes' ) { |
|
| 1646 | + if ($form_option === 'yes') { |
|
| 1647 | 1647 | ?> |
| 1648 | 1648 | <script type="text/javascript"> |
| 1649 | 1649 | jQuery(document).ready(function ($) { |
| 1650 | - $('body').on('click', '.give_terms_links-<?php echo $form_id;?>', function (e) { |
|
| 1650 | + $('body').on('click', '.give_terms_links-<?php echo $form_id; ?>', function (e) { |
|
| 1651 | 1651 | e.preventDefault(); |
| 1652 | - $('.give_terms-<?php echo $form_id;?>').slideToggle(); |
|
| 1653 | - $('.give_terms_links-<?php echo $form_id;?>').toggle(); |
|
| 1652 | + $('.give_terms-<?php echo $form_id; ?>').slideToggle(); |
|
| 1653 | + $('.give_terms_links-<?php echo $form_id; ?>').toggle(); |
|
| 1654 | 1654 | return false; |
| 1655 | 1655 | }); |
| 1656 | 1656 | }); |
@@ -1659,7 +1659,7 @@ discard block |
||
| 1659 | 1659 | } |
| 1660 | 1660 | } |
| 1661 | 1661 | |
| 1662 | -add_action( 'give_checkout_form_top', 'give_agree_to_terms_js', 10, 2 ); |
|
| 1662 | +add_action('give_checkout_form_top', 'give_agree_to_terms_js', 10, 2); |
|
| 1663 | 1663 | |
| 1664 | 1664 | /** |
| 1665 | 1665 | * Show Give Goals. |
@@ -1673,17 +1673,17 @@ discard block |
||
| 1673 | 1673 | * |
| 1674 | 1674 | * @return mixed |
| 1675 | 1675 | */ |
| 1676 | -function give_show_goal_progress( $form_id, $args ) { |
|
| 1676 | +function give_show_goal_progress($form_id, $args) { |
|
| 1677 | 1677 | |
| 1678 | 1678 | ob_start(); |
| 1679 | - give_get_template( 'shortcode-goal', array( 'form_id' => $form_id, 'args' => $args ) ); |
|
| 1679 | + give_get_template('shortcode-goal', array('form_id' => $form_id, 'args' => $args)); |
|
| 1680 | 1680 | |
| 1681 | - echo apply_filters( 'give_goal_output', ob_get_clean() ); |
|
| 1681 | + echo apply_filters('give_goal_output', ob_get_clean()); |
|
| 1682 | 1682 | |
| 1683 | 1683 | return true; |
| 1684 | 1684 | } |
| 1685 | 1685 | |
| 1686 | -add_action( 'give_pre_form', 'give_show_goal_progress', 10, 2 ); |
|
| 1686 | +add_action('give_pre_form', 'give_show_goal_progress', 10, 2); |
|
| 1687 | 1687 | |
| 1688 | 1688 | /** |
| 1689 | 1689 | * Adds Actions to Render Form Content. |
@@ -1695,19 +1695,19 @@ discard block |
||
| 1695 | 1695 | * |
| 1696 | 1696 | * @return void |
| 1697 | 1697 | */ |
| 1698 | -function give_form_content( $form_id, $args ) { |
|
| 1698 | +function give_form_content($form_id, $args) { |
|
| 1699 | 1699 | |
| 1700 | - $show_content = ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) |
|
| 1700 | + $show_content = (isset($args['show_content']) && ! empty($args['show_content'])) |
|
| 1701 | 1701 | ? $args['show_content'] |
| 1702 | - : get_post_meta( $form_id, '_give_content_option', true ); |
|
| 1702 | + : get_post_meta($form_id, '_give_content_option', true); |
|
| 1703 | 1703 | |
| 1704 | - if ( $show_content !== 'none' ) { |
|
| 1704 | + if ($show_content !== 'none') { |
|
| 1705 | 1705 | //add action according to value. |
| 1706 | - add_action( $show_content, 'give_form_display_content', 10, 2 ); |
|
| 1706 | + add_action($show_content, 'give_form_display_content', 10, 2); |
|
| 1707 | 1707 | } |
| 1708 | 1708 | } |
| 1709 | 1709 | |
| 1710 | -add_action( 'give_pre_form_output', 'give_form_content', 10, 2 ); |
|
| 1710 | +add_action('give_pre_form_output', 'give_form_content', 10, 2); |
|
| 1711 | 1711 | |
| 1712 | 1712 | /** |
| 1713 | 1713 | * Renders Post Form Content. |
@@ -1721,24 +1721,24 @@ discard block |
||
| 1721 | 1721 | * |
| 1722 | 1722 | * @return void |
| 1723 | 1723 | */ |
| 1724 | -function give_form_display_content( $form_id, $args ) { |
|
| 1724 | +function give_form_display_content($form_id, $args) { |
|
| 1725 | 1725 | |
| 1726 | - $content = wpautop( get_post_meta( $form_id, '_give_form_content', true ) ); |
|
| 1727 | - $show_content = ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) |
|
| 1726 | + $content = wpautop(get_post_meta($form_id, '_give_form_content', true)); |
|
| 1727 | + $show_content = (isset($args['show_content']) && ! empty($args['show_content'])) |
|
| 1728 | 1728 | ? $args['show_content'] |
| 1729 | - : get_post_meta( $form_id, '_give_content_option', true ); |
|
| 1729 | + : get_post_meta($form_id, '_give_content_option', true); |
|
| 1730 | 1730 | |
| 1731 | - if ( give_get_option( 'disable_the_content_filter' ) !== 'on' ) { |
|
| 1732 | - $content = apply_filters( 'the_content', $content ); |
|
| 1731 | + if (give_get_option('disable_the_content_filter') !== 'on') { |
|
| 1732 | + $content = apply_filters('the_content', $content); |
|
| 1733 | 1733 | } |
| 1734 | 1734 | |
| 1735 | - $output = '<div id="give-form-content-' . $form_id . '" class="give-form-content-wrap" >' . $content . '</div>'; |
|
| 1735 | + $output = '<div id="give-form-content-'.$form_id.'" class="give-form-content-wrap" >'.$content.'</div>'; |
|
| 1736 | 1736 | |
| 1737 | - echo apply_filters( 'give_form_content_output', $output ); |
|
| 1737 | + echo apply_filters('give_form_content_output', $output); |
|
| 1738 | 1738 | |
| 1739 | 1739 | //remove action to prevent content output on addition forms on page. |
| 1740 | 1740 | //@see: https://github.com/WordImpress/Give/issues/634. |
| 1741 | - remove_action( $show_content, 'give_form_display_content' ); |
|
| 1741 | + remove_action($show_content, 'give_form_display_content'); |
|
| 1742 | 1742 | } |
| 1743 | 1743 | |
| 1744 | 1744 | /** |
@@ -1750,7 +1750,7 @@ discard block |
||
| 1750 | 1750 | * |
| 1751 | 1751 | * @return void |
| 1752 | 1752 | */ |
| 1753 | -function give_checkout_hidden_fields( $form_id ) { |
|
| 1753 | +function give_checkout_hidden_fields($form_id) { |
|
| 1754 | 1754 | |
| 1755 | 1755 | /** |
| 1756 | 1756 | * Fires while rendering hidden checkout fields, before the fields. |
@@ -1759,13 +1759,13 @@ discard block |
||
| 1759 | 1759 | * |
| 1760 | 1760 | * @param int $form_id The form ID. |
| 1761 | 1761 | */ |
| 1762 | - do_action( 'give_hidden_fields_before', $form_id ); |
|
| 1762 | + do_action('give_hidden_fields_before', $form_id); |
|
| 1763 | 1763 | |
| 1764 | - if ( is_user_logged_in() ) { ?> |
|
| 1764 | + if (is_user_logged_in()) { ?> |
|
| 1765 | 1765 | <input type="hidden" name="give-user-id" value="<?php echo get_current_user_id(); ?>"/> |
| 1766 | 1766 | <?php } ?> |
| 1767 | 1767 | <input type="hidden" name="give_action" value="purchase"/> |
| 1768 | - <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway( $form_id ); ?>"/> |
|
| 1768 | + <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway($form_id); ?>"/> |
|
| 1769 | 1769 | <?php |
| 1770 | 1770 | /** |
| 1771 | 1771 | * Fires while rendering hidden checkout fields, after the fields. |
@@ -1774,7 +1774,7 @@ discard block |
||
| 1774 | 1774 | * |
| 1775 | 1775 | * @param int $form_id The form ID. |
| 1776 | 1776 | */ |
| 1777 | - do_action( 'give_hidden_fields_after', $form_id ); |
|
| 1777 | + do_action('give_hidden_fields_after', $form_id); |
|
| 1778 | 1778 | |
| 1779 | 1779 | } |
| 1780 | 1780 | |
@@ -1789,20 +1789,20 @@ discard block |
||
| 1789 | 1789 | * |
| 1790 | 1790 | * @return string $content Filtered content. |
| 1791 | 1791 | */ |
| 1792 | -function give_filter_success_page_content( $content ) { |
|
| 1792 | +function give_filter_success_page_content($content) { |
|
| 1793 | 1793 | |
| 1794 | 1794 | $give_options = give_get_settings(); |
| 1795 | 1795 | |
| 1796 | - if ( isset( $give_options['success_page'] ) && isset( $_GET['payment-confirmation'] ) && is_page( $give_options['success_page'] ) ) { |
|
| 1797 | - if ( has_filter( 'give_donation_confirm_' . $_GET['payment-confirmation'] ) ) { |
|
| 1798 | - $content = apply_filters( 'give_donation_confirm_' . $_GET['payment-confirmation'], $content ); |
|
| 1796 | + if (isset($give_options['success_page']) && isset($_GET['payment-confirmation']) && is_page($give_options['success_page'])) { |
|
| 1797 | + if (has_filter('give_donation_confirm_'.$_GET['payment-confirmation'])) { |
|
| 1798 | + $content = apply_filters('give_donation_confirm_'.$_GET['payment-confirmation'], $content); |
|
| 1799 | 1799 | } |
| 1800 | 1800 | } |
| 1801 | 1801 | |
| 1802 | 1802 | return $content; |
| 1803 | 1803 | } |
| 1804 | 1804 | |
| 1805 | -add_filter( 'the_content', 'give_filter_success_page_content' ); |
|
| 1805 | +add_filter('the_content', 'give_filter_success_page_content'); |
|
| 1806 | 1806 | |
| 1807 | 1807 | /** |
| 1808 | 1808 | * Test Mode Frontend Warning. |
@@ -1813,12 +1813,12 @@ discard block |
||
| 1813 | 1813 | */ |
| 1814 | 1814 | function give_test_mode_frontend_warning() { |
| 1815 | 1815 | |
| 1816 | - if ( give_is_test_mode() ) { |
|
| 1817 | - echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>' . esc_html__( 'Notice:', 'give' ) . '</strong> ' . esc_html__( 'Test mode is enabled. While in test mode no live donations are processed.', 'give' ) . '</p></div>'; |
|
| 1816 | + if (give_is_test_mode()) { |
|
| 1817 | + echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>'.esc_html__('Notice:', 'give').'</strong> '.esc_html__('Test mode is enabled. While in test mode no live donations are processed.', 'give').'</p></div>'; |
|
| 1818 | 1818 | } |
| 1819 | 1819 | } |
| 1820 | 1820 | |
| 1821 | -add_action( 'give_pre_form', 'give_test_mode_frontend_warning', 10 ); |
|
| 1821 | +add_action('give_pre_form', 'give_test_mode_frontend_warning', 10); |
|
| 1822 | 1822 | |
| 1823 | 1823 | /** |
| 1824 | 1824 | * Members-only Form. |
@@ -1832,21 +1832,21 @@ discard block |
||
| 1832 | 1832 | * |
| 1833 | 1833 | * @return string |
| 1834 | 1834 | */ |
| 1835 | -function give_members_only_form( $final_output, $args ) { |
|
| 1835 | +function give_members_only_form($final_output, $args) { |
|
| 1836 | 1836 | |
| 1837 | - $form_id = isset( $args['form_id'] ) ? $args['form_id'] : 0; |
|
| 1837 | + $form_id = isset($args['form_id']) ? $args['form_id'] : 0; |
|
| 1838 | 1838 | |
| 1839 | 1839 | //Sanity Check: Must have form_id & not be logged in. |
| 1840 | - if ( empty( $form_id ) || is_user_logged_in() ) { |
|
| 1840 | + if (empty($form_id) || is_user_logged_in()) { |
|
| 1841 | 1841 | return $final_output; |
| 1842 | 1842 | } |
| 1843 | 1843 | |
| 1844 | 1844 | //Logged in only and Register / Login set to none. |
| 1845 | - if ( give_logged_in_only( $form_id ) && give_show_login_register_option( $form_id ) == 'none' ) { |
|
| 1845 | + if (give_logged_in_only($form_id) && give_show_login_register_option($form_id) == 'none') { |
|
| 1846 | 1846 | |
| 1847 | - $final_output = give_output_error( esc_html__( 'Please log in in order to complete your donation.', 'give' ), false ); |
|
| 1847 | + $final_output = give_output_error(esc_html__('Please log in in order to complete your donation.', 'give'), false); |
|
| 1848 | 1848 | |
| 1849 | - return apply_filters( 'give_members_only_output', $final_output, $form_id ); |
|
| 1849 | + return apply_filters('give_members_only_output', $final_output, $form_id); |
|
| 1850 | 1850 | |
| 1851 | 1851 | } |
| 1852 | 1852 | |
@@ -1854,4 +1854,4 @@ discard block |
||
| 1854 | 1854 | |
| 1855 | 1855 | } |
| 1856 | 1856 | |
| 1857 | -add_filter( 'give_donate_form', 'give_members_only_form', 10, 2 ); |
|
| 1857 | +add_filter('give_donate_form', 'give_members_only_form', 10, 2); |
|
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -62,50 +62,50 @@ discard block |
||
| 62 | 62 | * |
| 63 | 63 | * @return bool If the gravatar exists or not |
| 64 | 64 | */ |
| 65 | - public function validate_gravatar( $id_or_email ) { |
|
| 65 | + public function validate_gravatar($id_or_email) { |
|
| 66 | 66 | //id or email code borrowed from wp-includes/pluggable.php |
| 67 | 67 | $email = ''; |
| 68 | - if ( is_numeric( $id_or_email ) ) { |
|
| 68 | + if (is_numeric($id_or_email)) { |
|
| 69 | 69 | $id = (int) $id_or_email; |
| 70 | - $user = get_userdata( $id ); |
|
| 71 | - if ( $user ) { |
|
| 70 | + $user = get_userdata($id); |
|
| 71 | + if ($user) { |
|
| 72 | 72 | $email = $user->user_email; |
| 73 | 73 | } |
| 74 | - } elseif ( is_object( $id_or_email ) ) { |
|
| 74 | + } elseif (is_object($id_or_email)) { |
|
| 75 | 75 | // No avatar for pingbacks or trackbacks |
| 76 | - $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); |
|
| 77 | - if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) { |
|
| 76 | + $allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment')); |
|
| 77 | + if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) { |
|
| 78 | 78 | return false; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if ( ! empty( $id_or_email->user_id ) ) { |
|
| 81 | + if ( ! empty($id_or_email->user_id)) { |
|
| 82 | 82 | $id = (int) $id_or_email->user_id; |
| 83 | - $user = get_userdata( $id ); |
|
| 84 | - if ( $user ) { |
|
| 83 | + $user = get_userdata($id); |
|
| 84 | + if ($user) { |
|
| 85 | 85 | $email = $user->user_email; |
| 86 | 86 | } |
| 87 | - } elseif ( ! empty( $id_or_email->comment_author_email ) ) { |
|
| 87 | + } elseif ( ! empty($id_or_email->comment_author_email)) { |
|
| 88 | 88 | $email = $id_or_email->comment_author_email; |
| 89 | 89 | } |
| 90 | 90 | } else { |
| 91 | 91 | $email = $id_or_email; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - $hashkey = md5( strtolower( trim( $email ) ) ); |
|
| 95 | - $uri = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404'; |
|
| 94 | + $hashkey = md5(strtolower(trim($email))); |
|
| 95 | + $uri = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404'; |
|
| 96 | 96 | |
| 97 | - $data = wp_cache_get( $hashkey ); |
|
| 98 | - if ( false === $data ) { |
|
| 99 | - $response = wp_remote_head( $uri ); |
|
| 100 | - if ( is_wp_error( $response ) ) { |
|
| 97 | + $data = wp_cache_get($hashkey); |
|
| 98 | + if (false === $data) { |
|
| 99 | + $response = wp_remote_head($uri); |
|
| 100 | + if (is_wp_error($response)) { |
|
| 101 | 101 | $data = 'not200'; |
| 102 | 102 | } else { |
| 103 | 103 | $data = $response['response']['code']; |
| 104 | 104 | } |
| 105 | - wp_cache_set( $hashkey, $data, $group = '', $expire = 60 * 5 ); |
|
| 105 | + wp_cache_set($hashkey, $data, $group = '', $expire = 60 * 5); |
|
| 106 | 106 | |
| 107 | 107 | } |
| 108 | - if ( $data == '200' ) { |
|
| 108 | + if ($data == '200') { |
|
| 109 | 109 | return true; |
| 110 | 110 | } else { |
| 111 | 111 | return false; |
@@ -122,19 +122,19 @@ discard block |
||
| 122 | 122 | * |
| 123 | 123 | * @return array IDs if logs, false otherwise |
| 124 | 124 | */ |
| 125 | - public function get_log_ids( $form_id = '' ) { |
|
| 125 | + public function get_log_ids($form_id = '') { |
|
| 126 | 126 | |
| 127 | 127 | // get Give_Logging class |
| 128 | 128 | global $give_logs; |
| 129 | 129 | |
| 130 | 130 | // get log for this form |
| 131 | - $logs = $give_logs->get_logs( $form_id ); |
|
| 131 | + $logs = $give_logs->get_logs($form_id); |
|
| 132 | 132 | |
| 133 | - if ( $logs ) { |
|
| 133 | + if ($logs) { |
|
| 134 | 134 | $log_ids = array(); |
| 135 | 135 | |
| 136 | 136 | // make an array with all the donor IDs |
| 137 | - foreach ( $logs as $log ) { |
|
| 137 | + foreach ($logs as $log) { |
|
| 138 | 138 | $log_ids[] = $log->ID; |
| 139 | 139 | } |
| 140 | 140 | |
@@ -155,51 +155,51 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @return mixed |
| 157 | 157 | */ |
| 158 | - public function get_payment_ids( $form_id = '' ) { |
|
| 158 | + public function get_payment_ids($form_id = '') { |
|
| 159 | 159 | |
| 160 | 160 | $give_options = give_get_settings(); |
| 161 | 161 | |
| 162 | - $log_ids = $this->get_log_ids( $form_id ); |
|
| 162 | + $log_ids = $this->get_log_ids($form_id); |
|
| 163 | 163 | |
| 164 | - if ( $log_ids ) { |
|
| 164 | + if ($log_ids) { |
|
| 165 | 165 | |
| 166 | 166 | $payment_ids = array(); |
| 167 | 167 | |
| 168 | - foreach ( $log_ids as $id ) { |
|
| 168 | + foreach ($log_ids as $id) { |
|
| 169 | 169 | // get the payment ID for each corresponding log ID |
| 170 | - $payment_ids[] = get_post_meta( $id, '_give_log_payment_id', true ); |
|
| 170 | + $payment_ids[] = get_post_meta($id, '_give_log_payment_id', true); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // remove donors who have donated more than once so we can have unique avatars |
| 174 | 174 | $unique_emails = array(); |
| 175 | 175 | |
| 176 | - foreach ( $payment_ids as $key => $id ) { |
|
| 176 | + foreach ($payment_ids as $key => $id) { |
|
| 177 | 177 | |
| 178 | - $email = get_post_meta( $id, '_give_payment_user_email', true ); |
|
| 178 | + $email = get_post_meta($id, '_give_payment_user_email', true); |
|
| 179 | 179 | |
| 180 | - if ( isset ( $give_options['give_donors_gravatars_has_gravatar_account'] ) ) { |
|
| 181 | - if ( ! $this->validate_gravatar( $email ) ) { |
|
| 180 | + if (isset ($give_options['give_donors_gravatars_has_gravatar_account'])) { |
|
| 181 | + if ( ! $this->validate_gravatar($email)) { |
|
| 182 | 182 | continue; |
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - $unique_emails[ $id ] = get_post_meta( $id, '_give_payment_user_email', true ); |
|
| 186 | + $unique_emails[$id] = get_post_meta($id, '_give_payment_user_email', true); |
|
| 187 | 187 | |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | $unique_ids = array(); |
| 191 | 191 | |
| 192 | 192 | // strip duplicate emails |
| 193 | - $unique_emails = array_unique( $unique_emails ); |
|
| 193 | + $unique_emails = array_unique($unique_emails); |
|
| 194 | 194 | |
| 195 | 195 | // convert the unique IDs back into simple array |
| 196 | - foreach ( $unique_emails as $id => $email ) { |
|
| 196 | + foreach ($unique_emails as $id => $email) { |
|
| 197 | 197 | $unique_ids[] = $id; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | // randomize the payment IDs if enabled |
| 201 | - if ( isset( $give_options['give_donors_gravatars_random_gravatars'] ) ) { |
|
| 202 | - shuffle( $unique_ids ); |
|
| 201 | + if (isset($give_options['give_donors_gravatars_random_gravatars'])) { |
|
| 202 | + shuffle($unique_ids); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | // return our unique IDs |
@@ -220,22 +220,22 @@ discard block |
||
| 220 | 220 | * |
| 221 | 221 | * @return string |
| 222 | 222 | */ |
| 223 | - public function gravatars( $form_id = false, $title = '' ) { |
|
| 223 | + public function gravatars($form_id = false, $title = '') { |
|
| 224 | 224 | |
| 225 | 225 | // unique $payment_ids |
| 226 | - $payment_ids = $this->get_payment_ids( $form_id ); |
|
| 226 | + $payment_ids = $this->get_payment_ids($form_id); |
|
| 227 | 227 | |
| 228 | 228 | $give_options = give_get_settings(); |
| 229 | 229 | |
| 230 | 230 | // return if no ID |
| 231 | - if ( ! $form_id ) { |
|
| 231 | + if ( ! $form_id) { |
|
| 232 | 232 | return; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | // minimum amount of donations before showing gravatars |
| 236 | 236 | // if the number of items in array is not greater or equal to the number specified, then exit |
| 237 | - if ( isset( $give_options['give_donors_gravatars_min_purchases_required'] ) && '' != $give_options['give_donors_gravatars_min_purchases_required'] ) { |
|
| 238 | - if ( ! ( count( $payment_ids ) >= $give_options['give_donors_gravatars_min_purchases_required'] ) ) { |
|
| 237 | + if (isset($give_options['give_donors_gravatars_min_purchases_required']) && '' != $give_options['give_donors_gravatars_min_purchases_required']) { |
|
| 238 | + if ( ! (count($payment_ids) >= $give_options['give_donors_gravatars_min_purchases_required'])) { |
|
| 239 | 239 | return; |
| 240 | 240 | } |
| 241 | 241 | } |
@@ -246,51 +246,51 @@ discard block |
||
| 246 | 246 | echo '<div id="give-purchase-gravatars">'; |
| 247 | 247 | |
| 248 | 248 | |
| 249 | - if ( isset ( $title ) ) { |
|
| 249 | + if (isset ($title)) { |
|
| 250 | 250 | |
| 251 | - if ( $title ) { |
|
| 252 | - echo apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $title ) . '</h3>' ); |
|
| 253 | - } elseif ( isset( $give_options['give_donors_gravatars_heading'] ) ) { |
|
| 254 | - echo apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $give_options['give_donors_gravatars_heading'] ) . '</h2>' ); |
|
| 251 | + if ($title) { |
|
| 252 | + echo apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($title).'</h3>'); |
|
| 253 | + } elseif (isset($give_options['give_donors_gravatars_heading'])) { |
|
| 254 | + echo apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($give_options['give_donors_gravatars_heading']).'</h2>'); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | } |
| 258 | 258 | echo '<ul class="give-purchase-gravatars-list">'; |
| 259 | 259 | $i = 0; |
| 260 | 260 | |
| 261 | - if ( $payment_ids ) { |
|
| 262 | - foreach ( $payment_ids as $id ) { |
|
| 261 | + if ($payment_ids) { |
|
| 262 | + foreach ($payment_ids as $id) { |
|
| 263 | 263 | |
| 264 | 264 | // Give saves a blank option even when the control is turned off, hence the extra check |
| 265 | - if ( isset( $give_options['give_donors_gravatars_maximum_number'] ) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number'] ) { |
|
| 265 | + if (isset($give_options['give_donors_gravatars_maximum_number']) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number']) { |
|
| 266 | 266 | continue; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | // get the payment meta |
| 270 | - $payment_meta = get_post_meta( $id, '_give_payment_meta', true ); |
|
| 270 | + $payment_meta = get_post_meta($id, '_give_payment_meta', true); |
|
| 271 | 271 | |
| 272 | 272 | // unserialize the payment meta |
| 273 | - $user_info = maybe_unserialize( $payment_meta['user_info'] ); |
|
| 273 | + $user_info = maybe_unserialize($payment_meta['user_info']); |
|
| 274 | 274 | |
| 275 | 275 | // get donor's first name |
| 276 | 276 | $name = $user_info['first_name']; |
| 277 | 277 | |
| 278 | 278 | // get donor's email |
| 279 | - $email = get_post_meta( $id, '_give_payment_user_email', true ); |
|
| 279 | + $email = get_post_meta($id, '_give_payment_user_email', true); |
|
| 280 | 280 | |
| 281 | 281 | // set gravatar size and provide filter |
| 282 | - $size = isset( $give_options['give_donors_gravatars_gravatar_size'] ) ? apply_filters( 'give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size'] ) : ''; |
|
| 282 | + $size = isset($give_options['give_donors_gravatars_gravatar_size']) ? apply_filters('give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size']) : ''; |
|
| 283 | 283 | |
| 284 | 284 | // default image |
| 285 | - $default_image = apply_filters( 'give_donors_gravatars_gravatar_default_image', false ); |
|
| 285 | + $default_image = apply_filters('give_donors_gravatars_gravatar_default_image', false); |
|
| 286 | 286 | |
| 287 | 287 | // assemble output |
| 288 | 288 | $output .= '<li>'; |
| 289 | 289 | |
| 290 | - $output .= get_avatar( $email, $size, $default_image, $name ); |
|
| 290 | + $output .= get_avatar($email, $size, $default_image, $name); |
|
| 291 | 291 | $output .= '</li>'; |
| 292 | 292 | |
| 293 | - $i ++; |
|
| 293 | + $i++; |
|
| 294 | 294 | |
| 295 | 295 | } // end foreach |
| 296 | 296 | } |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | echo '</ul>'; |
| 300 | 300 | echo '</div>'; |
| 301 | 301 | |
| 302 | - return apply_filters( 'give_donors_gravatars', ob_get_clean() ); |
|
| 302 | + return apply_filters('give_donors_gravatars', ob_get_clean()); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | * @return void |
| 312 | 312 | */ |
| 313 | 313 | public function register_widget() { |
| 314 | - register_widget( 'Give_Donors_Gravatars_Widget' ); |
|
| 314 | + register_widget('Give_Donors_Gravatars_Widget'); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | /** |
@@ -327,19 +327,19 @@ discard block |
||
| 327 | 327 | * |
| 328 | 328 | * @todo Set the ID to get_the_ID() if ID parameter is not passed through. Otherwise it will incorrectly get other gravatars |
| 329 | 329 | */ |
| 330 | - public function shortcode( $atts, $content = null ) { |
|
| 330 | + public function shortcode($atts, $content = null) { |
|
| 331 | 331 | |
| 332 | - $atts = shortcode_atts( array( |
|
| 332 | + $atts = shortcode_atts(array( |
|
| 333 | 333 | 'id' => '', |
| 334 | 334 | 'title' => '' |
| 335 | - ), $atts, 'give_donors_gravatars' ); |
|
| 335 | + ), $atts, 'give_donors_gravatars'); |
|
| 336 | 336 | |
| 337 | 337 | // if no ID is passed on single give_forms pages, get the correct ID |
| 338 | - if ( is_singular( 'give_forms' ) ) { |
|
| 338 | + if (is_singular('give_forms')) { |
|
| 339 | 339 | $id = get_the_ID(); |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - $content = $this->gravatars( $atts['id'], $atts['title'] ); |
|
| 342 | + $content = $this->gravatars($atts['id'], $atts['title']); |
|
| 343 | 343 | |
| 344 | 344 | return $content; |
| 345 | 345 | |
@@ -355,56 +355,56 @@ discard block |
||
| 355 | 355 | * |
| 356 | 356 | * @return array Gravatar settings. |
| 357 | 357 | */ |
| 358 | - public function settings( $settings ) { |
|
| 358 | + public function settings($settings) { |
|
| 359 | 359 | |
| 360 | 360 | $give_gravatar_settings = array( |
| 361 | 361 | array( |
| 362 | - 'name' => esc_html__( 'Donator Gravatars', 'give' ), |
|
| 362 | + 'name' => esc_html__('Donator Gravatars', 'give'), |
|
| 363 | 363 | 'desc' => '<hr>', |
| 364 | 364 | 'id' => 'give_title', |
| 365 | 365 | 'type' => 'give_title' |
| 366 | 366 | ), |
| 367 | 367 | array( |
| 368 | - 'name' => esc_html__( 'Heading', 'give' ), |
|
| 369 | - 'desc' => esc_html__( 'The heading to display above the Gravatars.', 'give' ), |
|
| 368 | + 'name' => esc_html__('Heading', 'give'), |
|
| 369 | + 'desc' => esc_html__('The heading to display above the Gravatars.', 'give'), |
|
| 370 | 370 | 'type' => 'text', |
| 371 | 371 | 'id' => 'give_donors_gravatars_heading' |
| 372 | 372 | ), |
| 373 | 373 | array( |
| 374 | - 'name' => esc_html__( 'Gravatar Size', 'give' ), |
|
| 375 | - 'desc' => esc_html__( 'The size of each Gravatar in pixels (512px maximum).', 'give' ), |
|
| 374 | + 'name' => esc_html__('Gravatar Size', 'give'), |
|
| 375 | + 'desc' => esc_html__('The size of each Gravatar in pixels (512px maximum).', 'give'), |
|
| 376 | 376 | 'type' => 'text_small', |
| 377 | 377 | 'id' => 'give_donors_gravatars_gravatar_size', |
| 378 | 378 | 'default' => '64' |
| 379 | 379 | ), |
| 380 | 380 | array( |
| 381 | - 'name' => esc_html__( 'Minimum Unique Donations Required', 'give' ), |
|
| 382 | - 'desc' => esc_html__( 'The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give' ), |
|
| 381 | + 'name' => esc_html__('Minimum Unique Donations Required', 'give'), |
|
| 382 | + 'desc' => esc_html__('The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give'), |
|
| 383 | 383 | 'type' => 'text_small', |
| 384 | 384 | 'id' => 'give_donors_gravatars_min_purchases_required', |
| 385 | 385 | ), |
| 386 | 386 | array( |
| 387 | - 'name' => esc_html__( 'Maximum Gravatars To Show', 'give' ), |
|
| 388 | - 'desc' => esc_html__( 'The maximum number of gravatars to show. Leave blank for no limit.', 'give' ), |
|
| 387 | + 'name' => esc_html__('Maximum Gravatars To Show', 'give'), |
|
| 388 | + 'desc' => esc_html__('The maximum number of gravatars to show. Leave blank for no limit.', 'give'), |
|
| 389 | 389 | 'type' => 'text', |
| 390 | 390 | 'id' => 'give_donors_gravatars_maximum_number', |
| 391 | 391 | 'default' => '20', |
| 392 | 392 | ), |
| 393 | 393 | array( |
| 394 | - 'name' => esc_html__( 'Gravatar Visibility', 'give' ), |
|
| 395 | - 'desc' => esc_html__( 'Show only donors with a Gravatar account.', 'give' ), |
|
| 394 | + 'name' => esc_html__('Gravatar Visibility', 'give'), |
|
| 395 | + 'desc' => esc_html__('Show only donors with a Gravatar account.', 'give'), |
|
| 396 | 396 | 'id' => 'give_donors_gravatars_has_gravatar_account', |
| 397 | 397 | 'type' => 'checkbox', |
| 398 | 398 | ), |
| 399 | 399 | array( |
| 400 | - 'name' => esc_html__( 'Randomize Gravatars', 'give' ), |
|
| 401 | - 'desc' => esc_html__( 'Randomize the Gravatars.', 'give' ), |
|
| 400 | + 'name' => esc_html__('Randomize Gravatars', 'give'), |
|
| 401 | + 'desc' => esc_html__('Randomize the Gravatars.', 'give'), |
|
| 402 | 402 | 'id' => 'give_donors_gravatars_random_gravatars', |
| 403 | 403 | 'type' => 'checkbox', |
| 404 | 404 | ), |
| 405 | 405 | ); |
| 406 | 406 | |
| 407 | - return array_merge( $settings, $give_gravatar_settings ); |
|
| 407 | + return array_merge($settings, $give_gravatar_settings); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | } |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | // widget settings |
| 431 | 431 | $widget_ops = array( |
| 432 | 432 | 'classname' => 'give-donors-gravatars', |
| 433 | - 'description' => esc_html__( 'Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give' ), |
|
| 433 | + 'description' => esc_html__('Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give'), |
|
| 434 | 434 | ); |
| 435 | 435 | |
| 436 | 436 | // widget control settings |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | // create the widget |
| 444 | 444 | parent::__construct( |
| 445 | 445 | 'give_donors_gravatars_widget', |
| 446 | - esc_html__( 'Give Donors Gravatars', 'give' ), |
|
| 446 | + esc_html__('Give Donors Gravatars', 'give'), |
|
| 447 | 447 | $widget_ops, |
| 448 | 448 | $control_ops |
| 449 | 449 | ); |
@@ -463,29 +463,29 @@ discard block |
||
| 463 | 463 | * |
| 464 | 464 | * @return void |
| 465 | 465 | */ |
| 466 | - public function widget( $args, $instance ) { |
|
| 466 | + public function widget($args, $instance) { |
|
| 467 | 467 | |
| 468 | 468 | //@TODO: Don't extract it!!! |
| 469 | - extract( $args ); |
|
| 469 | + extract($args); |
|
| 470 | 470 | |
| 471 | - if ( ! is_singular( 'give_forms' ) ) { |
|
| 471 | + if ( ! is_singular('give_forms')) { |
|
| 472 | 472 | return; |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | // Variables from widget settings |
| 476 | - $title = apply_filters( 'widget_title', $instance['title'] ); |
|
| 476 | + $title = apply_filters('widget_title', $instance['title']); |
|
| 477 | 477 | |
| 478 | 478 | // Used by themes. Opens the widget |
| 479 | 479 | echo $before_widget; |
| 480 | 480 | |
| 481 | 481 | // Display the widget title |
| 482 | - if ( $title ) { |
|
| 483 | - echo $before_title . $title . $after_title; |
|
| 482 | + if ($title) { |
|
| 483 | + echo $before_title.$title.$after_title; |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | $gravatars = new Give_Donors_Gravatars(); |
| 487 | 487 | |
| 488 | - echo $gravatars->gravatars( get_the_ID(), null ); // remove title |
|
| 488 | + echo $gravatars->gravatars(get_the_ID(), null); // remove title |
|
| 489 | 489 | |
| 490 | 490 | // Used by themes. Closes the widget |
| 491 | 491 | echo $after_widget; |
@@ -505,11 +505,11 @@ discard block |
||
| 505 | 505 | * |
| 506 | 506 | * @return array Updated settings to save. |
| 507 | 507 | */ |
| 508 | - public function update( $new_instance, $old_instance ) { |
|
| 508 | + public function update($new_instance, $old_instance) { |
|
| 509 | 509 | |
| 510 | 510 | $instance = $old_instance; |
| 511 | 511 | |
| 512 | - $instance['title'] = strip_tags( $new_instance['title'] ); |
|
| 512 | + $instance['title'] = strip_tags($new_instance['title']); |
|
| 513 | 513 | |
| 514 | 514 | return $instance; |
| 515 | 515 | |
@@ -527,19 +527,19 @@ discard block |
||
| 527 | 527 | * |
| 528 | 528 | * @return void |
| 529 | 529 | */ |
| 530 | - public function form( $instance ) { |
|
| 530 | + public function form($instance) { |
|
| 531 | 531 | |
| 532 | 532 | // Set up some default widget settings. |
| 533 | 533 | $defaults = array( |
| 534 | 534 | 'title' => '', |
| 535 | 535 | ); |
| 536 | 536 | |
| 537 | - $instance = wp_parse_args( (array) $instance, $defaults ); ?> |
|
| 537 | + $instance = wp_parse_args((array) $instance, $defaults); ?> |
|
| 538 | 538 | |
| 539 | 539 | <!-- Title --> |
| 540 | 540 | <p> |
| 541 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ) ?></label> |
|
| 542 | - <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
| 541 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give') ?></label> |
|
| 542 | + <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
| 543 | 543 | </p> |
| 544 | 544 | |
| 545 | 545 | <?php |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | // Exit if accessed directly |
| 19 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 19 | +if ( ! defined('ABSPATH')) { |
|
| 20 | 20 | exit; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -29,32 +29,32 @@ discard block |
||
| 29 | 29 | * @return void |
| 30 | 30 | */ |
| 31 | 31 | function give_reports_page() { |
| 32 | - $current_page = admin_url( 'edit.php?post_type=give_forms&page=give-reports' ); |
|
| 33 | - $active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'reports'; |
|
| 32 | + $current_page = admin_url('edit.php?post_type=give_forms&page=give-reports'); |
|
| 33 | + $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'reports'; |
|
| 34 | 34 | ?> |
| 35 | 35 | <div class="wrap"> |
| 36 | 36 | |
| 37 | 37 | <h1 class="screen-reader-text"><?php echo get_admin_page_title(); ?></h1> |
| 38 | 38 | |
| 39 | 39 | <h2 class="nav-tab-wrapper"> |
| 40 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
| 40 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
| 41 | 41 | 'tab' => 'reports', |
| 42 | 42 | 'settings-updated' => false |
| 43 | - ), $current_page ) ); ?>" class="nav-tab <?php echo $active_tab == 'reports' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Reports', 'give' ); ?></a> |
|
| 44 | - <?php if ( current_user_can( 'export_give_reports' ) ) { ?> |
|
| 45 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
| 43 | + ), $current_page)); ?>" class="nav-tab <?php echo $active_tab == 'reports' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Reports', 'give'); ?></a> |
|
| 44 | + <?php if (current_user_can('export_give_reports')) { ?> |
|
| 45 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
| 46 | 46 | 'tab' => 'export', |
| 47 | 47 | 'settings-updated' => false |
| 48 | - ), $current_page ) ); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Export', 'give' ); ?></a> |
|
| 48 | + ), $current_page)); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Export', 'give'); ?></a> |
|
| 49 | 49 | <?php } ?> |
| 50 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
| 50 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
| 51 | 51 | 'tab' => 'logs', |
| 52 | 52 | 'settings-updated' => false |
| 53 | - ), $current_page ) ); ?>" class="nav-tab <?php echo $active_tab == 'logs' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Logs', 'give' ); ?></a> |
|
| 54 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
| 53 | + ), $current_page)); ?>" class="nav-tab <?php echo $active_tab == 'logs' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Logs', 'give'); ?></a> |
|
| 54 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
| 55 | 55 | 'tab' => 'tools', |
| 56 | 56 | 'settings-updated' => false |
| 57 | - ), $current_page ) ); ?>" class="nav-tab <?php echo $active_tab == 'tools' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Tools', 'give' ); ?></a> |
|
| 57 | + ), $current_page)); ?>" class="nav-tab <?php echo $active_tab == 'tools' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Tools', 'give'); ?></a> |
|
| 58 | 58 | <?php |
| 59 | 59 | /** |
| 60 | 60 | * Fires in the report tabs. |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @since 1.0 |
| 65 | 65 | */ |
| 66 | - do_action( 'give_reports_tabs' ); |
|
| 66 | + do_action('give_reports_tabs'); |
|
| 67 | 67 | ?> |
| 68 | 68 | </h2> |
| 69 | 69 | |
@@ -73,21 +73,21 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @since 1.0 |
| 75 | 75 | */ |
| 76 | - do_action( 'give_reports_page_top' ); |
|
| 76 | + do_action('give_reports_page_top'); |
|
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * Fires the report page active tab. |
| 80 | 80 | * |
| 81 | 81 | * @since 1.0 |
| 82 | 82 | */ |
| 83 | - do_action( "give_reports_tab_{$active_tab}" ); |
|
| 83 | + do_action("give_reports_tab_{$active_tab}"); |
|
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | 86 | * Fires after the report page. |
| 87 | 87 | * |
| 88 | 88 | * @since 1.0 |
| 89 | 89 | */ |
| 90 | - do_action( 'give_reports_page_bottom' ); |
|
| 90 | + do_action('give_reports_page_bottom'); |
|
| 91 | 91 | ?> |
| 92 | 92 | </div><!-- .wrap --> |
| 93 | 93 | <?php |
@@ -101,13 +101,13 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | function give_reports_default_views() { |
| 103 | 103 | $views = array( |
| 104 | - 'earnings' => esc_html__( 'Income', 'give' ), |
|
| 105 | - 'forms' => esc_html__( 'Forms', 'give' ), |
|
| 106 | - 'donors' => esc_html__( 'Donors', 'give' ), |
|
| 107 | - 'gateways' => esc_html__( 'Payment Methods', 'give' ) |
|
| 104 | + 'earnings' => esc_html__('Income', 'give'), |
|
| 105 | + 'forms' => esc_html__('Forms', 'give'), |
|
| 106 | + 'donors' => esc_html__('Donors', 'give'), |
|
| 107 | + 'gateways' => esc_html__('Payment Methods', 'give') |
|
| 108 | 108 | ); |
| 109 | 109 | |
| 110 | - $views = apply_filters( 'give_report_views', $views ); |
|
| 110 | + $views = apply_filters('give_report_views', $views); |
|
| 111 | 111 | |
| 112 | 112 | return $views; |
| 113 | 113 | } |
@@ -123,15 +123,15 @@ discard block |
||
| 123 | 123 | * @return string $view Report View |
| 124 | 124 | * |
| 125 | 125 | */ |
| 126 | -function give_get_reporting_view( $default = 'earnings' ) { |
|
| 126 | +function give_get_reporting_view($default = 'earnings') { |
|
| 127 | 127 | |
| 128 | - if ( ! isset( $_GET['view'] ) || ! in_array( $_GET['view'], array_keys( give_reports_default_views() ) ) ) { |
|
| 128 | + if ( ! isset($_GET['view']) || ! in_array($_GET['view'], array_keys(give_reports_default_views()))) { |
|
| 129 | 129 | $view = $default; |
| 130 | 130 | } else { |
| 131 | 131 | $view = $_GET['view']; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - return apply_filters( 'give_get_reporting_view', $view ); |
|
| 134 | + return apply_filters('give_get_reporting_view', $view); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | $current_view = 'earnings'; |
| 145 | 145 | $views = give_reports_default_views(); |
| 146 | 146 | |
| 147 | - if ( isset( $_GET['view'] ) && array_key_exists( $_GET['view'], $views ) ) { |
|
| 147 | + if (isset($_GET['view']) && array_key_exists($_GET['view'], $views)) { |
|
| 148 | 148 | $current_view = $_GET['view']; |
| 149 | 149 | } |
| 150 | 150 | |
@@ -153,10 +153,10 @@ discard block |
||
| 153 | 153 | * |
| 154 | 154 | * @since 1.0 |
| 155 | 155 | */ |
| 156 | - do_action( "give_reports_view_{$current_view}" ); |
|
| 156 | + do_action("give_reports_view_{$current_view}"); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | -add_action( 'give_reports_tab_reports', 'give_reports_tab_reports' ); |
|
| 159 | +add_action('give_reports_tab_reports', 'give_reports_tab_reports'); |
|
| 160 | 160 | |
| 161 | 161 | /** |
| 162 | 162 | * Renders the Reports Page Views Drop Downs |
@@ -166,19 +166,19 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | function give_report_views() { |
| 168 | 168 | $views = give_reports_default_views(); |
| 169 | - $current_view = isset( $_GET['view'] ) ? $_GET['view'] : 'earnings'; |
|
| 169 | + $current_view = isset($_GET['view']) ? $_GET['view'] : 'earnings'; |
|
| 170 | 170 | /** |
| 171 | 171 | * Fires before the report page actions form. |
| 172 | 172 | * |
| 173 | 173 | * @since 1.0 |
| 174 | 174 | */ |
| 175 | - do_action( 'give_report_view_actions_before' ); |
|
| 175 | + do_action('give_report_view_actions_before'); |
|
| 176 | 176 | ?> |
| 177 | 177 | <form id="give-reports-filter" method="get"> |
| 178 | 178 | <select id="give-reports-view" name="view"> |
| 179 | - <option value="-1"><?php esc_html_e( 'Report Type', 'give' ); ?></option> |
|
| 180 | - <?php foreach ( $views as $view_id => $label ) : ?> |
|
| 181 | - <option value="<?php echo esc_attr( $view_id ); ?>" <?php selected( $view_id, $current_view ); ?>><?php echo $label; ?></option> |
|
| 179 | + <option value="-1"><?php esc_html_e('Report Type', 'give'); ?></option> |
|
| 180 | + <?php foreach ($views as $view_id => $label) : ?> |
|
| 181 | + <option value="<?php echo esc_attr($view_id); ?>" <?php selected($view_id, $current_view); ?>><?php echo $label; ?></option> |
|
| 182 | 182 | <?php endforeach; ?> |
| 183 | 183 | </select> |
| 184 | 184 | |
@@ -190,12 +190,12 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @since 1.0 |
| 192 | 192 | */ |
| 193 | - do_action( 'give_report_view_actions' ); |
|
| 193 | + do_action('give_report_view_actions'); |
|
| 194 | 194 | ?> |
| 195 | 195 | |
| 196 | 196 | <input type="hidden" name="post_type" value="give_forms"/> |
| 197 | 197 | <input type="hidden" name="page" value="give-reports"/> |
| 198 | - <?php submit_button( esc_html__( 'Show', 'give' ), 'secondary', 'submit', false ); ?> |
|
| 198 | + <?php submit_button(esc_html__('Show', 'give'), 'secondary', 'submit', false); ?> |
|
| 199 | 199 | </form> |
| 200 | 200 | <?php |
| 201 | 201 | /** |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * |
| 204 | 204 | * @since 1.0 |
| 205 | 205 | */ |
| 206 | - do_action( 'give_report_view_actions_after' ); |
|
| 206 | + do_action('give_report_view_actions_after'); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -216,18 +216,18 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | function give_reports_forms_table() { |
| 218 | 218 | |
| 219 | - if ( isset( $_GET['form-id'] ) ) { |
|
| 219 | + if (isset($_GET['form-id'])) { |
|
| 220 | 220 | return; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - include( dirname( __FILE__ ) . '/class-form-reports-table.php' ); |
|
| 223 | + include(dirname(__FILE__).'/class-form-reports-table.php'); |
|
| 224 | 224 | |
| 225 | 225 | $give_table = new Give_Form_Reports_Table(); |
| 226 | 226 | $give_table->prepare_items(); |
| 227 | 227 | $give_table->display(); |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | -add_action( 'give_reports_view_forms', 'give_reports_forms_table' ); |
|
| 230 | +add_action('give_reports_view_forms', 'give_reports_forms_table'); |
|
| 231 | 231 | |
| 232 | 232 | /** |
| 233 | 233 | * Renders the detailed report for a specific give form |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | * @return void |
| 237 | 237 | */ |
| 238 | 238 | function give_reports_form_details() { |
| 239 | - if ( ! isset( $_GET['form-id'] ) ) { |
|
| 239 | + if ( ! isset($_GET['form-id'])) { |
|
| 240 | 240 | return; |
| 241 | 241 | } |
| 242 | 242 | ?> |
@@ -244,14 +244,14 @@ discard block |
||
| 244 | 244 | <div class="actions bulkactions"> |
| 245 | 245 | <?php give_report_views(); ?> |
| 246 | 246 | |
| 247 | - <button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e( 'Go Back', 'give' ); ?></button> |
|
| 247 | + <button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e('Go Back', 'give'); ?></button> |
|
| 248 | 248 | </div> |
| 249 | 249 | </div> |
| 250 | 250 | <?php |
| 251 | - give_reports_graph_of_form( absint( $_GET['form-id'] ) ); |
|
| 251 | + give_reports_graph_of_form(absint($_GET['form-id'])); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | -add_action( 'give_reports_view_forms', 'give_reports_form_details' ); |
|
| 254 | +add_action('give_reports_view_forms', 'give_reports_form_details'); |
|
| 255 | 255 | |
| 256 | 256 | /** |
| 257 | 257 | * Renders the Reports Donors Table |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | * @return void |
| 263 | 263 | */ |
| 264 | 264 | function give_reports_donors_table() { |
| 265 | - include( dirname( __FILE__ ) . '/class-donor-reports-table.php' ); |
|
| 265 | + include(dirname(__FILE__).'/class-donor-reports-table.php'); |
|
| 266 | 266 | |
| 267 | 267 | $give_table = new Give_Donor_Reports_Table(); |
| 268 | 268 | $give_table->prepare_items(); |
@@ -274,11 +274,11 @@ discard block |
||
| 274 | 274 | * |
| 275 | 275 | * @since 1.0 |
| 276 | 276 | */ |
| 277 | - do_action( 'give_logs_donors_table_top' ); |
|
| 277 | + do_action('give_logs_donors_table_top'); |
|
| 278 | 278 | ?> |
| 279 | - <form id="give-donors-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-reports&view=donors' ); ?>"> |
|
| 279 | + <form id="give-donors-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-reports&view=donors'); ?>"> |
|
| 280 | 280 | <?php |
| 281 | - $give_table->search_box( esc_html__( 'Search', 'give' ), 'give-donors' ); |
|
| 281 | + $give_table->search_box(esc_html__('Search', 'give'), 'give-donors'); |
|
| 282 | 282 | $give_table->display(); |
| 283 | 283 | ?> |
| 284 | 284 | <input type="hidden" name="post_type" value="give_forms"/> |
@@ -291,13 +291,13 @@ discard block |
||
| 291 | 291 | * |
| 292 | 292 | * @since 1.0 |
| 293 | 293 | */ |
| 294 | - do_action( 'give_logs_donors_table_bottom' ); |
|
| 294 | + do_action('give_logs_donors_table_bottom'); |
|
| 295 | 295 | ?> |
| 296 | 296 | </div> |
| 297 | 297 | <?php |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | -add_action( 'give_reports_view_donors', 'give_reports_donors_table' ); |
|
| 300 | +add_action('give_reports_view_donors', 'give_reports_donors_table'); |
|
| 301 | 301 | |
| 302 | 302 | |
| 303 | 303 | /** |
@@ -309,14 +309,14 @@ discard block |
||
| 309 | 309 | * @return void |
| 310 | 310 | */ |
| 311 | 311 | function give_reports_gateways_table() { |
| 312 | - include( dirname( __FILE__ ) . '/class-gateways-reports-table.php' ); |
|
| 312 | + include(dirname(__FILE__).'/class-gateways-reports-table.php'); |
|
| 313 | 313 | |
| 314 | 314 | $give_table = new Give_Gateawy_Reports_Table(); |
| 315 | 315 | $give_table->prepare_items(); |
| 316 | 316 | $give_table->display(); |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | -add_action( 'give_reports_view_gateways', 'give_reports_gateways_table' ); |
|
| 319 | +add_action('give_reports_view_gateways', 'give_reports_gateways_table'); |
|
| 320 | 320 | |
| 321 | 321 | |
| 322 | 322 | /** |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | function give_reports_earnings() { |
| 329 | 329 | ?> |
| 330 | 330 | <div class="tablenav top reports-table-nav"> |
| 331 | - <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e( 'Income Over Time', 'give' ); ?></span></h3> |
|
| 331 | + <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e('Income Over Time', 'give'); ?></span></h3> |
|
| 332 | 332 | |
| 333 | 333 | <div class="alignright actions reports-views-wrap"><?php give_report_views(); ?></div> |
| 334 | 334 | </div> |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | give_reports_graph(); |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | -add_action( 'give_reports_view_earnings', 'give_reports_earnings' ); |
|
| 339 | +add_action('give_reports_view_earnings', 'give_reports_earnings'); |
|
| 340 | 340 | |
| 341 | 341 | |
| 342 | 342 | /** |
@@ -357,14 +357,14 @@ discard block |
||
| 357 | 357 | * |
| 358 | 358 | * @since 1.0 |
| 359 | 359 | */ |
| 360 | - do_action( 'give_reports_tab_export_content_top' ); |
|
| 360 | + do_action('give_reports_tab_export_content_top'); |
|
| 361 | 361 | ?> |
| 362 | 362 | |
| 363 | 363 | <table class="widefat export-options-table give-table"> |
| 364 | 364 | <thead> |
| 365 | 365 | <tr> |
| 366 | - <th scope="col"><?php esc_html_e( 'Export Type', 'give' ); ?></th> |
|
| 367 | - <th scope="col"><?php esc_html_e( 'Export Options', 'give' ); ?></th> |
|
| 366 | + <th scope="col"><?php esc_html_e('Export Type', 'give'); ?></th> |
|
| 367 | + <th scope="col"><?php esc_html_e('Export Options', 'give'); ?></th> |
|
| 368 | 368 | </tr> |
| 369 | 369 | </thead> |
| 370 | 370 | <tbody> |
@@ -376,41 +376,41 @@ discard block |
||
| 376 | 376 | * |
| 377 | 377 | * @since 1.0 |
| 378 | 378 | */ |
| 379 | - do_action( 'give_reports_tab_export_table_top' ); |
|
| 379 | + do_action('give_reports_tab_export_table_top'); |
|
| 380 | 380 | ?> |
| 381 | 381 | <tr class="give-export-pdf-sales-earnings"> |
| 382 | 382 | <td scope="row" class="row-title"> |
| 383 | - <h3><span><?php esc_html_e( 'Export PDF of Donations and Income', 'give' ); ?></span></h3> |
|
| 384 | - <p><?php esc_html_e( 'Download a PDF of Donations and Income reports for all forms for the current year.', 'give' ); ?></p> |
|
| 383 | + <h3><span><?php esc_html_e('Export PDF of Donations and Income', 'give'); ?></span></h3> |
|
| 384 | + <p><?php esc_html_e('Download a PDF of Donations and Income reports for all forms for the current year.', 'give'); ?></p> |
|
| 385 | 385 | </td> |
| 386 | 386 | <td> |
| 387 | - <a class="button" href="<?php echo wp_nonce_url( add_query_arg( array( 'give-action' => 'generate_pdf' ) ), 'give_generate_pdf' ); ?>"><?php esc_html_e( 'Generate PDF', 'give' ); ?></a> |
|
| 387 | + <a class="button" href="<?php echo wp_nonce_url(add_query_arg(array('give-action' => 'generate_pdf')), 'give_generate_pdf'); ?>"><?php esc_html_e('Generate PDF', 'give'); ?></a> |
|
| 388 | 388 | </td> |
| 389 | 389 | </tr> |
| 390 | 390 | <tr class="alternate give-export-sales-earnings"> |
| 391 | 391 | <td scope="row" class="row-title"> |
| 392 | - <h3><span><?php esc_html_e( 'Export Income and Donation Stats', 'give' ); ?></span></h3> |
|
| 393 | - <p><?php esc_html_e( 'Download a CSV of income and donations over time.', 'give' ); ?></p> |
|
| 392 | + <h3><span><?php esc_html_e('Export Income and Donation Stats', 'give'); ?></span></h3> |
|
| 393 | + <p><?php esc_html_e('Download a CSV of income and donations over time.', 'give'); ?></p> |
|
| 394 | 394 | </td> |
| 395 | 395 | <td> |
| 396 | 396 | <form method="post"> |
| 397 | 397 | <?php |
| 398 | 398 | printf( |
| 399 | 399 | /* translators: 1: start date dropdown 2: end date dropdown */ |
| 400 | - esc_html__( '%1$s to %2$s', 'give' ), |
|
| 401 | - Give()->html->year_dropdown( 'start_year' ) . ' ' . Give()->html->month_dropdown( 'start_month' ), |
|
| 402 | - Give()->html->year_dropdown( 'end_year' ) . ' ' . Give()->html->month_dropdown( 'end_month' ) |
|
| 400 | + esc_html__('%1$s to %2$s', 'give'), |
|
| 401 | + Give()->html->year_dropdown('start_year').' '.Give()->html->month_dropdown('start_month'), |
|
| 402 | + Give()->html->year_dropdown('end_year').' '.Give()->html->month_dropdown('end_month') |
|
| 403 | 403 | ); |
| 404 | 404 | ?> |
| 405 | 405 | <input type="hidden" name="give-action" value="earnings_export"/> |
| 406 | - <input type="submit" value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>" class="button-secondary"/> |
|
| 406 | + <input type="submit" value="<?php esc_attr_e('Generate CSV', 'give'); ?>" class="button-secondary"/> |
|
| 407 | 407 | </form> |
| 408 | 408 | </td> |
| 409 | 409 | </tr> |
| 410 | 410 | <tr class="give-export-payment-history"> |
| 411 | 411 | <td scope="row" class="row-title"> |
| 412 | - <h3><span><?php esc_html_e( 'Export Donation History', 'give' ); ?></span></h3> |
|
| 413 | - <p><?php esc_html_e( 'Download a CSV of all donations recorded.', 'give' ); ?></p> |
|
| 412 | + <h3><span><?php esc_html_e('Export Donation History', 'give'); ?></span></h3> |
|
| 413 | + <p><?php esc_html_e('Download a CSV of all donations recorded.', 'give'); ?></p> |
|
| 414 | 414 | </td> |
| 415 | 415 | <td> |
| 416 | 416 | <form id="give-export-payments" class="give-export-form" method="post"> |
@@ -418,29 +418,29 @@ discard block |
||
| 418 | 418 | $args = array( |
| 419 | 419 | 'id' => 'give-payment-export-start', |
| 420 | 420 | 'name' => 'start', |
| 421 | - 'placeholder' => esc_attr__( 'Start date', 'give' ) |
|
| 421 | + 'placeholder' => esc_attr__('Start date', 'give') |
|
| 422 | 422 | ); |
| 423 | - echo Give()->html->date_field( $args ); ?> |
|
| 423 | + echo Give()->html->date_field($args); ?> |
|
| 424 | 424 | <?php |
| 425 | 425 | $args = array( |
| 426 | 426 | 'id' => 'give-payment-export-end', |
| 427 | 427 | 'name' => 'end', |
| 428 | - 'placeholder' => esc_attr__( 'End date', 'give' ) |
|
| 428 | + 'placeholder' => esc_attr__('End date', 'give') |
|
| 429 | 429 | ); |
| 430 | - echo Give()->html->date_field( $args ); ?> |
|
| 430 | + echo Give()->html->date_field($args); ?> |
|
| 431 | 431 | <select name="status"> |
| 432 | - <option value="any"><?php esc_html_e( 'All Statuses', 'give' ); ?></option> |
|
| 432 | + <option value="any"><?php esc_html_e('All Statuses', 'give'); ?></option> |
|
| 433 | 433 | <?php |
| 434 | 434 | $statuses = give_get_payment_statuses(); |
| 435 | - foreach ( $statuses as $status => $label ) { |
|
| 436 | - echo '<option value="' . $status . '">' . $label . '</option>'; |
|
| 435 | + foreach ($statuses as $status => $label) { |
|
| 436 | + echo '<option value="'.$status.'">'.$label.'</option>'; |
|
| 437 | 437 | } |
| 438 | 438 | ?> |
| 439 | 439 | </select> |
| 440 | - <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?> |
|
| 440 | + <?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?> |
|
| 441 | 441 | <input type="hidden" name="give-export-class" value="Give_Batch_Payments_Export"/> |
| 442 | 442 | <span> |
| 443 | - <input type="submit" value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>" class="button-secondary"/> |
|
| 443 | + <input type="submit" value="<?php esc_attr_e('Generate CSV', 'give'); ?>" class="button-secondary"/> |
|
| 444 | 444 | <span class="spinner"></span> |
| 445 | 445 | </span> |
| 446 | 446 | </form> |
@@ -448,8 +448,8 @@ discard block |
||
| 448 | 448 | </tr> |
| 449 | 449 | <tr class="alternate give-export-donors"> |
| 450 | 450 | <td scope="row" class="row-title"> |
| 451 | - <h3><span><?php esc_html_e( 'Export Donors in CSV', 'give' ); ?></span></h3> |
|
| 452 | - <p><?php esc_html_e( 'Download an export of donors for all donation forms or only those who have given to a particular form.', 'give' ); ?></p> |
|
| 451 | + <h3><span><?php esc_html_e('Export Donors in CSV', 'give'); ?></span></h3> |
|
| 452 | + <p><?php esc_html_e('Download an export of donors for all donation forms or only those who have given to a particular form.', 'give'); ?></p> |
|
| 453 | 453 | </td> |
| 454 | 454 | <td> |
| 455 | 455 | <form method="post" id="give_donor_export" class="give-export-form"> |
@@ -460,44 +460,44 @@ discard block |
||
| 460 | 460 | 'id' => 'give_customer_export_form', |
| 461 | 461 | 'chosen' => true |
| 462 | 462 | ); |
| 463 | - echo Give()->html->forms_dropdown( $args ); ?> |
|
| 463 | + echo Give()->html->forms_dropdown($args); ?> |
|
| 464 | 464 | |
| 465 | - <input type="submit" value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>" class="button-secondary"/> |
|
| 465 | + <input type="submit" value="<?php esc_attr_e('Generate CSV', 'give'); ?>" class="button-secondary"/> |
|
| 466 | 466 | |
| 467 | 467 | <div id="export-donor-options-wrap" class="give-clearfix"> |
| 468 | - <p><?php esc_html_e( 'Export Columns:', 'give' ); ?></p> |
|
| 468 | + <p><?php esc_html_e('Export Columns:', 'give'); ?></p> |
|
| 469 | 469 | <ul id="give-export-option-ul"> |
| 470 | 470 | <li> |
| 471 | - <label for="give-export-fullname"><input type="checkbox" checked name="give_export_option[full_name]" id="give-export-fullname"><?php esc_html_e( 'Name', 'give' ); ?> |
|
| 471 | + <label for="give-export-fullname"><input type="checkbox" checked name="give_export_option[full_name]" id="give-export-fullname"><?php esc_html_e('Name', 'give'); ?> |
|
| 472 | 472 | </label> |
| 473 | 473 | </li> |
| 474 | 474 | <li> |
| 475 | - <label for="give-export-email"><input type="checkbox" checked name="give_export_option[email]" id="give-export-email"><?php esc_html_e( 'Email', 'give' ); ?> |
|
| 475 | + <label for="give-export-email"><input type="checkbox" checked name="give_export_option[email]" id="give-export-email"><?php esc_html_e('Email', 'give'); ?> |
|
| 476 | 476 | </label> |
| 477 | 477 | </li> |
| 478 | 478 | <li> |
| 479 | - <label for="give-export-address"><input type="checkbox" checked name="give_export_option[address]" id="give-export-address"><?php esc_html_e( 'Address', 'give' ); ?> |
|
| 479 | + <label for="give-export-address"><input type="checkbox" checked name="give_export_option[address]" id="give-export-address"><?php esc_html_e('Address', 'give'); ?> |
|
| 480 | 480 | </label> |
| 481 | 481 | </li> |
| 482 | 482 | <li> |
| 483 | - <label for="give-export-userid"><input type="checkbox" checked name="give_export_option[userid]" id="give-export-userid"><?php esc_html_e( 'User ID', 'give' ); ?> |
|
| 483 | + <label for="give-export-userid"><input type="checkbox" checked name="give_export_option[userid]" id="give-export-userid"><?php esc_html_e('User ID', 'give'); ?> |
|
| 484 | 484 | </label> |
| 485 | 485 | </li> |
| 486 | 486 | <li> |
| 487 | - <label for="give-export-first-donation-date"><input type="checkbox" checked name="give_export_option[date_first_donated]" id="give-export-first-donation-date"><?php esc_html_e( 'First Donation Date', 'give' ); ?> |
|
| 487 | + <label for="give-export-first-donation-date"><input type="checkbox" checked name="give_export_option[date_first_donated]" id="give-export-first-donation-date"><?php esc_html_e('First Donation Date', 'give'); ?> |
|
| 488 | 488 | </label> |
| 489 | 489 | </li> |
| 490 | 490 | <li> |
| 491 | - <label for="give-export-donation-number"><input type="checkbox" checked name="give_export_option[donations]" id="give-export-donation-number"><?php esc_html_e( 'Number of Donations', 'give' ); ?> |
|
| 491 | + <label for="give-export-donation-number"><input type="checkbox" checked name="give_export_option[donations]" id="give-export-donation-number"><?php esc_html_e('Number of Donations', 'give'); ?> |
|
| 492 | 492 | </label> |
| 493 | 493 | </li> |
| 494 | 494 | <li> |
| 495 | - <label for="give-export-donation-sum"><input type="checkbox" checked name="give_export_option[donation_sum]" id="give-export-donation-sum"><?php esc_html_e( 'Total Donated', 'give' ); ?> |
|
| 495 | + <label for="give-export-donation-sum"><input type="checkbox" checked name="give_export_option[donation_sum]" id="give-export-donation-sum"><?php esc_html_e('Total Donated', 'give'); ?> |
|
| 496 | 496 | </label> |
| 497 | 497 | </li> |
| 498 | 498 | </ul> |
| 499 | 499 | </div> |
| 500 | - <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?> |
|
| 500 | + <?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?> |
|
| 501 | 501 | <input type="hidden" name="give-export-class" value="Give_Batch_Customers_Export"/> |
| 502 | 502 | <input type="hidden" name="give-action" value="email_export"/> |
| 503 | 503 | </form> |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | * |
| 512 | 512 | * @since 1.0 |
| 513 | 513 | */ |
| 514 | - do_action( 'give_reports_tab_export_table_bottom' ); |
|
| 514 | + do_action('give_reports_tab_export_table_bottom'); |
|
| 515 | 515 | ?> |
| 516 | 516 | </tbody> |
| 517 | 517 | </table> |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | * |
| 523 | 523 | * @since 1.0 |
| 524 | 524 | */ |
| 525 | - do_action( 'give_reports_tab_export_content_bottom' ); |
|
| 525 | + do_action('give_reports_tab_export_content_bottom'); |
|
| 526 | 526 | ?> |
| 527 | 527 | |
| 528 | 528 | </div> |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | <?php |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | -add_action( 'give_reports_tab_export', 'give_reports_tab_export' ); |
|
| 536 | +add_action('give_reports_tab_export', 'give_reports_tab_export'); |
|
| 537 | 537 | |
| 538 | 538 | /** |
| 539 | 539 | * Renders the Reports page |
@@ -543,12 +543,12 @@ discard block |
||
| 543 | 543 | */ |
| 544 | 544 | function give_reports_tab_logs() { |
| 545 | 545 | |
| 546 | - require( GIVE_PLUGIN_DIR . 'includes/admin/reporting/logs.php' ); |
|
| 546 | + require(GIVE_PLUGIN_DIR.'includes/admin/reporting/logs.php'); |
|
| 547 | 547 | |
| 548 | 548 | $current_view = 'sales'; |
| 549 | 549 | $log_views = give_log_default_views(); |
| 550 | 550 | |
| 551 | - if ( isset( $_GET['view'] ) && array_key_exists( $_GET['view'], $log_views ) ) { |
|
| 551 | + if (isset($_GET['view']) && array_key_exists($_GET['view'], $log_views)) { |
|
| 552 | 552 | $current_view = $_GET['view']; |
| 553 | 553 | } |
| 554 | 554 | |
@@ -557,10 +557,10 @@ discard block |
||
| 557 | 557 | * |
| 558 | 558 | * @since 1.0 |
| 559 | 559 | */ |
| 560 | - do_action( "give_logs_view_{$current_view}" ); |
|
| 560 | + do_action("give_logs_view_{$current_view}"); |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | -add_action( 'give_reports_tab_logs', 'give_reports_tab_logs' ); |
|
| 563 | +add_action('give_reports_tab_logs', 'give_reports_tab_logs'); |
|
| 564 | 564 | |
| 565 | 565 | /** |
| 566 | 566 | * Retrieves estimated monthly earnings and sales |
@@ -570,9 +570,9 @@ discard block |
||
| 570 | 570 | */ |
| 571 | 571 | function give_estimated_monthly_stats() { |
| 572 | 572 | |
| 573 | - $estimated = get_transient( 'give_estimated_monthly_stats' ); |
|
| 573 | + $estimated = get_transient('give_estimated_monthly_stats'); |
|
| 574 | 574 | |
| 575 | - if ( false === $estimated ) { |
|
| 575 | + if (false === $estimated) { |
|
| 576 | 576 | |
| 577 | 577 | $estimated = array( |
| 578 | 578 | 'earnings' => 0, |
@@ -581,20 +581,20 @@ discard block |
||
| 581 | 581 | |
| 582 | 582 | $stats = new Give_Payment_Stats; |
| 583 | 583 | |
| 584 | - $to_date_earnings = $stats->get_earnings( 0, 'this_month' ); |
|
| 585 | - $to_date_sales = $stats->get_sales( 0, 'this_month' ); |
|
| 584 | + $to_date_earnings = $stats->get_earnings(0, 'this_month'); |
|
| 585 | + $to_date_sales = $stats->get_sales(0, 'this_month'); |
|
| 586 | 586 | |
| 587 | - $current_day = date( 'd', current_time( 'timestamp' ) ); |
|
| 588 | - $current_month = date( 'n', current_time( 'timestamp' ) ); |
|
| 589 | - $current_year = date( 'Y', current_time( 'timestamp' ) ); |
|
| 590 | - $days_in_month = cal_days_in_month( CAL_GREGORIAN, $current_month, $current_year ); |
|
| 587 | + $current_day = date('d', current_time('timestamp')); |
|
| 588 | + $current_month = date('n', current_time('timestamp')); |
|
| 589 | + $current_year = date('Y', current_time('timestamp')); |
|
| 590 | + $days_in_month = cal_days_in_month(CAL_GREGORIAN, $current_month, $current_year); |
|
| 591 | 591 | |
| 592 | - $estimated['earnings'] = ( $to_date_earnings / $current_day ) * $days_in_month; |
|
| 593 | - $estimated['sales'] = ( $to_date_sales / $current_day ) * $days_in_month; |
|
| 592 | + $estimated['earnings'] = ($to_date_earnings / $current_day) * $days_in_month; |
|
| 593 | + $estimated['sales'] = ($to_date_sales / $current_day) * $days_in_month; |
|
| 594 | 594 | |
| 595 | 595 | // Cache for one day |
| 596 | - set_transient( 'give_estimated_monthly_stats', $estimated, 86400 ); |
|
| 596 | + set_transient('give_estimated_monthly_stats', $estimated, 86400); |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | - return maybe_unserialize( $estimated ); |
|
| 599 | + return maybe_unserialize($estimated); |
|
| 600 | 600 | } |