@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | 17 | // Load WP_List_Table if not loaded |
18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
18 | +if ( ! class_exists('WP_List_Table')) { |
|
19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | global $status, $page; |
46 | 46 | |
47 | 47 | // Set parent defaults |
48 | - parent::__construct( array( |
|
49 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
48 | + parent::__construct(array( |
|
49 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
51 | 51 | 'ajax' => false // Does this table support ajax? |
52 | - ) ); |
|
52 | + )); |
|
53 | 53 | |
54 | 54 | } |
55 | 55 | |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return string Column Name |
66 | 66 | */ |
67 | - public function column_default( $item, $column_name ) { |
|
68 | - switch ( $column_name ) { |
|
67 | + public function column_default($item, $column_name) { |
|
68 | + switch ($column_name) { |
|
69 | 69 | default: |
70 | - return $item[ $column_name ]; |
|
70 | + return $item[$column_name]; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function get_columns() { |
82 | 82 | $columns = array( |
83 | - 'label' => esc_attr__( 'Gateway', 'give' ), |
|
84 | - 'complete_sales' => esc_attr__( 'Complete Transactions', 'give' ), |
|
85 | - 'pending_sales' => esc_attr__( 'Pending / Failed Transactions', 'give' ), |
|
86 | - 'total_sales' => esc_attr__( 'Total Transactions', 'give' ), |
|
87 | - 'total_donations' => esc_attr__( 'Total Donated', 'give' ) |
|
83 | + 'label' => esc_attr__('Gateway', 'give'), |
|
84 | + 'complete_sales' => esc_attr__('Complete Transactions', 'give'), |
|
85 | + 'pending_sales' => esc_attr__('Pending / Failed Transactions', 'give'), |
|
86 | + 'total_sales' => esc_attr__('Total Transactions', 'give'), |
|
87 | + 'total_donations' => esc_attr__('Total Donated', 'give') |
|
88 | 88 | ); |
89 | 89 | |
90 | 90 | return $columns; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @return int Current page number |
100 | 100 | */ |
101 | 101 | public function get_paged() { |
102 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
102 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @since 1.0 |
111 | 111 | * @return void |
112 | 112 | */ |
113 | - public function bulk_actions( $which = '' ) { |
|
113 | + public function bulk_actions($which = '') { |
|
114 | 114 | |
115 | 115 | } |
116 | 116 | |
@@ -122,27 +122,27 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @param string $which |
124 | 124 | */ |
125 | - protected function display_tablenav( $which ) { |
|
125 | + protected function display_tablenav($which) { |
|
126 | 126 | |
127 | - if ( 'top' === $which ) { |
|
128 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
127 | + if ('top' === $which) { |
|
128 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
129 | 129 | } |
130 | 130 | ?> |
131 | - <div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr( $which ); ?>"> |
|
131 | + <div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr($which); ?>"> |
|
132 | 132 | |
133 | - <?php if ( 'top' === $which ) { ?> |
|
133 | + <?php if ('top' === $which) { ?> |
|
134 | 134 | <h3 class="alignleft reports-earnings-title"> |
135 | - <span><?php esc_html_e( 'Donation Methods Report', 'give' ); ?></span> |
|
135 | + <span><?php esc_html_e('Donation Methods Report', 'give'); ?></span> |
|
136 | 136 | </h3> |
137 | 137 | <?php } ?> |
138 | 138 | |
139 | 139 | <div class="alignright tablenav-right"> |
140 | 140 | <div class="actions bulkactions"> |
141 | - <?php $this->bulk_actions( $which ); ?> |
|
141 | + <?php $this->bulk_actions($which); ?> |
|
142 | 142 | </div> |
143 | 143 | <?php |
144 | - $this->extra_tablenav( $which ); |
|
145 | - $this->pagination( $which ); |
|
144 | + $this->extra_tablenav($which); |
|
145 | + $this->pagination($which); |
|
146 | 146 | ?> |
147 | 147 | </div> |
148 | 148 | |
@@ -167,18 +167,18 @@ discard block |
||
167 | 167 | $gateways = give_get_payment_gateways(); |
168 | 168 | $stats = new Give_Payment_Stats(); |
169 | 169 | |
170 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
170 | + foreach ($gateways as $gateway_id => $gateway) { |
|
171 | 171 | |
172 | - $complete_count = give_count_sales_by_gateway( $gateway_id, 'publish' ); |
|
173 | - $pending_count = give_count_sales_by_gateway( $gateway_id, array( 'pending', 'failed' ) ); |
|
172 | + $complete_count = give_count_sales_by_gateway($gateway_id, 'publish'); |
|
173 | + $pending_count = give_count_sales_by_gateway($gateway_id, array('pending', 'failed')); |
|
174 | 174 | |
175 | 175 | $reports_data[] = array( |
176 | 176 | 'ID' => $gateway_id, |
177 | 177 | 'label' => $gateway['admin_label'], |
178 | - 'complete_sales' => give_format_amount( $complete_count, false ), |
|
179 | - 'pending_sales' => give_format_amount( $pending_count, false ), |
|
180 | - 'total_sales' => give_format_amount( $complete_count + $pending_count, false ), |
|
181 | - 'total_donations' => give_currency_filter( give_format_amount( $stats->get_earnings( 0, 0, 0, $gateway_id ) ) ) |
|
178 | + 'complete_sales' => give_format_amount($complete_count, false), |
|
179 | + 'pending_sales' => give_format_amount($pending_count, false), |
|
180 | + 'total_sales' => give_format_amount($complete_count + $pending_count, false), |
|
181 | + 'total_donations' => give_currency_filter(give_format_amount($stats->get_earnings(0, 0, 0, $gateway_id))) |
|
182 | 182 | ); |
183 | 183 | } |
184 | 184 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $columns = $this->get_columns(); |
201 | 201 | $hidden = array(); // No hidden columns |
202 | 202 | $sortable = $this->get_sortable_columns(); |
203 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
203 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
204 | 204 | $this->items = $this->reports_data(); |
205 | 205 | |
206 | 206 | } |
@@ -1181,23 +1181,23 @@ discard block |
||
1181 | 1181 | function give_license_key_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) { |
1182 | 1182 | /* @var CMB2_Types $field_type_object */ |
1183 | 1183 | |
1184 | - $id = $field_type_object->field->args['id']; |
|
1184 | + $id = $field_type_object->field->args['id']; |
|
1185 | 1185 | $field_description = $field_type_object->field->args['desc']; |
1186 | 1186 | $license = $field_type_object->field->args['options']['license']; |
1187 | - $license_key = $escaped_value; |
|
1188 | - $is_license_key = apply_filters( 'give_is_license_key', ( is_object( $license ) && ! empty( $license ) ) ); |
|
1189 | - $is_valid_license = apply_filters( 'give_is_valid_license', ( $is_license_key && property_exists( $license, 'license' ) && 'valid' === $license->license ) ); |
|
1190 | - $shortname = $field_type_object->field->args['options']['shortname']; |
|
1187 | + $license_key = $escaped_value; |
|
1188 | + $is_license_key = apply_filters( 'give_is_license_key', ( is_object( $license ) && ! empty( $license ) ) ); |
|
1189 | + $is_valid_license = apply_filters( 'give_is_valid_license', ( $is_license_key && property_exists( $license, 'license' ) && 'valid' === $license->license ) ); |
|
1190 | + $shortname = $field_type_object->field->args['options']['shortname']; |
|
1191 | 1191 | $field_classes = 'regular-text give-license-field'; |
1192 | 1192 | $type = empty( $escaped_value ) || ! $is_valid_license ? 'text' : 'password'; |
1193 | - $custom_html = ''; |
|
1194 | - $messages = array(); |
|
1195 | - $class = ''; |
|
1196 | - $account_page_link = $field_type_object->field->args['options']['account_url']; |
|
1197 | - $checkout_page_link = $field_type_object->field->args['options']['checkout_url']; |
|
1198 | - $addon_name = $field_type_object->field->args['options']['item_name']; |
|
1199 | - $license_status = null; |
|
1200 | - $is_in_subscription = null; |
|
1193 | + $custom_html = ''; |
|
1194 | + $messages = array(); |
|
1195 | + $class = ''; |
|
1196 | + $account_page_link = $field_type_object->field->args['options']['account_url']; |
|
1197 | + $checkout_page_link = $field_type_object->field->args['options']['checkout_url']; |
|
1198 | + $addon_name = $field_type_object->field->args['options']['item_name']; |
|
1199 | + $license_status = null; |
|
1200 | + $is_in_subscription = null; |
|
1201 | 1201 | |
1202 | 1202 | // By default query on edd api url will return license object which contain status and message property, this can break below functionality. |
1203 | 1203 | // To combat that check if status is set to error or not, if yes then set $is_license_key to false. |
@@ -1259,17 +1259,17 @@ discard block |
||
1259 | 1259 | |
1260 | 1260 | } elseif ( empty( $license->success ) && property_exists( $license, 'error' ) ) { |
1261 | 1261 | |
1262 | - // activate_license 'invalid' on anything other than valid, so if there was an error capture it |
|
1263 | - switch( $license->error ) { |
|
1264 | - case 'expired' : |
|
1265 | - $class = $license->error; |
|
1266 | - $messages[] = sprintf( |
|
1267 | - __( 'Your license key expired on %s. Please <a href="%s" target="_blank" title="Renew your license key">renew your license key</a>.', 'give' ), |
|
1268 | - date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), |
|
1269 | - $checkout_page_link . '?edd_license_key=' . $license_key . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired' |
|
1270 | - ); |
|
1271 | - $license_status = 'license-' . $class; |
|
1272 | - break; |
|
1262 | + // activate_license 'invalid' on anything other than valid, so if there was an error capture it |
|
1263 | + switch( $license->error ) { |
|
1264 | + case 'expired' : |
|
1265 | + $class = $license->error; |
|
1266 | + $messages[] = sprintf( |
|
1267 | + __( 'Your license key expired on %s. Please <a href="%s" target="_blank" title="Renew your license key">renew your license key</a>.', 'give' ), |
|
1268 | + date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), |
|
1269 | + $checkout_page_link . '?edd_license_key=' . $license_key . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired' |
|
1270 | + ); |
|
1271 | + $license_status = 'license-' . $class; |
|
1272 | + break; |
|
1273 | 1273 | |
1274 | 1274 | case 'missing' : |
1275 | 1275 | $class = $license->error; |
@@ -1300,11 +1300,11 @@ discard block |
||
1300 | 1300 | $license_status = 'license-' . $class; |
1301 | 1301 | break; |
1302 | 1302 | |
1303 | - case 'item_name_mismatch' : |
|
1304 | - $class = $license->error; |
|
1305 | - $messages[] = sprintf( __( 'This license %s does not belong to %s.', 'give' ), $license_key, $addon_name ); |
|
1306 | - $license_status = 'license-' . $class; |
|
1307 | - break; |
|
1303 | + case 'item_name_mismatch' : |
|
1304 | + $class = $license->error; |
|
1305 | + $messages[] = sprintf( __( 'This license %s does not belong to %s.', 'give' ), $license_key, $addon_name ); |
|
1306 | + $license_status = 'license-' . $class; |
|
1307 | + break; |
|
1308 | 1308 | |
1309 | 1309 | case 'no_activations_left': |
1310 | 1310 | $class = $license->error; |
@@ -1359,7 +1359,7 @@ discard block |
||
1359 | 1359 | |
1360 | 1360 | // If license is active so show deactivate button. |
1361 | 1361 | if ( $is_valid_license ) { |
1362 | - // Get input field html. |
|
1362 | + // Get input field html. |
|
1363 | 1363 | $input_field_html = "<input type=\"{$type}\" name=\"{$id}\" class=\"{$field_classes}\" value=\"{$license_key}\" readonly=\"readonly\">"; |
1364 | 1364 | |
1365 | 1365 | $custom_html = '<input type="submit" class="button button-small give-license-deactivate" name="' . $id . '_deactivate" value="' . esc_attr__( 'Deactivate License', 'give' ) . '"/>'; |
@@ -1375,11 +1375,11 @@ discard block |
||
1375 | 1375 | $messages[] = apply_filters( "{$shortname}_default_addon_notice", esc_html__( 'To receive updates, please enter your valid license key.', 'give' ) ); |
1376 | 1376 | } |
1377 | 1377 | |
1378 | - foreach( $messages as $message ) { |
|
1379 | - $custom_html .= '<div class="give-license-status-notice give-' . $license_status . '">'; |
|
1380 | - $custom_html .= '<p>' . $message . '</p>'; |
|
1381 | - $custom_html .= '</div>'; |
|
1382 | - } |
|
1378 | + foreach( $messages as $message ) { |
|
1379 | + $custom_html .= '<div class="give-license-status-notice give-' . $license_status . '">'; |
|
1380 | + $custom_html .= '<p>' . $message . '</p>'; |
|
1381 | + $custom_html .= '</div>'; |
|
1382 | + } |
|
1383 | 1383 | |
1384 | 1384 | |
1385 | 1385 | // Field html. |
@@ -1388,8 +1388,8 @@ discard block |
||
1388 | 1388 | // Nonce. |
1389 | 1389 | wp_nonce_field( $id . '-nonce', $id . '-nonce' ); |
1390 | 1390 | |
1391 | - // Print field html. |
|
1392 | - echo "<div class=\"give-license-key\"><label for=\"{$id}\">{$addon_name }</label></div><div class=\"give-license-block\">{$custom_html}</div>"; |
|
1391 | + // Print field html. |
|
1392 | + echo "<div class=\"give-license-key\"><label for=\"{$id}\">{$addon_name }</label></div><div class=\"give-license-block\">{$custom_html}</div>"; |
|
1393 | 1393 | } |
1394 | 1394 | |
1395 | 1395 |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @param $url |
77 | 77 | * |
78 | - * @return mixed |
|
78 | + * @return string |
|
79 | 79 | */ |
80 | 80 | public function give_update_cmb_meta_box_url( $url ) { |
81 | 81 | //Path to Give's CMB |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | * @since 1.0 |
857 | 857 | * |
858 | 858 | * @param string $key The Key to update |
859 | - * @param string|bool|int $value The value to set the key to |
|
859 | + * @param integer $value The value to set the key to |
|
860 | 860 | * |
861 | 861 | * @return boolean True if updated, false if not. |
862 | 862 | */ |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | * @since 1.3.5 |
960 | 960 | * |
961 | 961 | * @param $array |
962 | - * @param $position |int|string Expects an array key or 'id' of the settings field to appear after |
|
962 | + * @param string $position |int|string Expects an array key or 'id' of the settings field to appear after |
|
963 | 963 | * @param $insert |array a valid array of options to insert |
964 | 964 | * |
965 | 965 | * @return array |
@@ -997,7 +997,7 @@ discard block |
||
997 | 997 | * |
998 | 998 | * @since 1.0 |
999 | 999 | * @param array $field_arr |
1000 | - * @param array $saved_values |
|
1000 | + * @param string|boolean $saved_values |
|
1001 | 1001 | * @return void |
1002 | 1002 | */ |
1003 | 1003 | function give_enabled_gateways_callback( $field_arr, $saved_values = array() ) { |
@@ -1030,7 +1030,7 @@ discard block |
||
1030 | 1030 | * |
1031 | 1031 | * @since 1.0 |
1032 | 1032 | * @param array $field_arr |
1033 | - * @param array $saved_value |
|
1033 | + * @param string|boolean $saved_value |
|
1034 | 1034 | * @return void |
1035 | 1035 | */ |
1036 | 1036 | function give_default_gateway_callback( $field_arr, $saved_value ) { |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | public function __construct() { |
47 | 47 | |
48 | 48 | //Custom CMB2 Settings Fields |
49 | - add_action( 'cmb2_render_give_title', 'give_title_callback', 10, 5 ); |
|
50 | - add_action( 'cmb2_render_give_description', 'give_description_callback', 10, 5 ); |
|
51 | - add_action( 'cmb2_render_enabled_gateways', 'give_enabled_gateways_callback', 10, 5 ); |
|
52 | - add_action( 'cmb2_render_default_gateway', 'give_default_gateway_callback', 10, 5 ); |
|
53 | - add_action( 'cmb2_render_email_preview_buttons', 'give_email_preview_buttons_callback', 10, 5 ); |
|
54 | - add_action( 'cmb2_render_system_info', 'give_system_info_callback', 10, 5 ); |
|
55 | - add_action( 'cmb2_render_api', 'give_api_callback', 10, 5 ); |
|
56 | - add_action( 'cmb2_render_license_key', 'give_license_key_callback', 10, 5 ); |
|
49 | + add_action('cmb2_render_give_title', 'give_title_callback', 10, 5); |
|
50 | + add_action('cmb2_render_give_description', 'give_description_callback', 10, 5); |
|
51 | + add_action('cmb2_render_enabled_gateways', 'give_enabled_gateways_callback', 10, 5); |
|
52 | + add_action('cmb2_render_default_gateway', 'give_default_gateway_callback', 10, 5); |
|
53 | + add_action('cmb2_render_email_preview_buttons', 'give_email_preview_buttons_callback', 10, 5); |
|
54 | + add_action('cmb2_render_system_info', 'give_system_info_callback', 10, 5); |
|
55 | + add_action('cmb2_render_api', 'give_api_callback', 10, 5); |
|
56 | + add_action('cmb2_render_license_key', 'give_license_key_callback', 10, 5); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @since 1.0 |
64 | 64 | */ |
65 | 65 | public function init() { |
66 | - register_setting( $this->key, $this->key ); |
|
66 | + register_setting($this->key, $this->key); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @return mixed |
79 | 79 | */ |
80 | - public function give_update_cmb_meta_box_url( $url ) { |
|
80 | + public function give_update_cmb_meta_box_url($url) { |
|
81 | 81 | //Path to Give's CMB |
82 | - return GIVE_PLUGIN_URL . '/includes/libraries/cmb2'; |
|
82 | + return GIVE_PLUGIN_URL.'/includes/libraries/cmb2'; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
@@ -91,27 +91,27 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function give_get_settings_tabs() { |
93 | 93 | |
94 | - $settings = $this->give_settings( null ); |
|
94 | + $settings = $this->give_settings(null); |
|
95 | 95 | |
96 | 96 | $tabs = array(); |
97 | - $tabs['general'] = esc_html__( 'General', 'give' ); |
|
98 | - $tabs['gateways'] = esc_html__( 'Payment Gateways', 'give' ); |
|
99 | - $tabs['display'] = esc_html__( 'Display Options', 'give' ); |
|
100 | - $tabs['emails'] = esc_html__( 'Emails', 'give' ); |
|
97 | + $tabs['general'] = esc_html__('General', 'give'); |
|
98 | + $tabs['gateways'] = esc_html__('Payment Gateways', 'give'); |
|
99 | + $tabs['display'] = esc_html__('Display Options', 'give'); |
|
100 | + $tabs['emails'] = esc_html__('Emails', 'give'); |
|
101 | 101 | |
102 | - if ( ! empty( $settings['addons']['fields'] ) ) { |
|
103 | - $tabs['addons'] = esc_html__( 'Add-ons', 'give' ); |
|
102 | + if ( ! empty($settings['addons']['fields'])) { |
|
103 | + $tabs['addons'] = esc_html__('Add-ons', 'give'); |
|
104 | 104 | } |
105 | 105 | |
106 | - if ( ! empty( $settings['licenses']['fields'] ) ) { |
|
107 | - $tabs['licenses'] = esc_html__( 'Licenses', 'give' ); |
|
106 | + if ( ! empty($settings['licenses']['fields'])) { |
|
107 | + $tabs['licenses'] = esc_html__('Licenses', 'give'); |
|
108 | 108 | } |
109 | 109 | |
110 | - $tabs['advanced'] = esc_html__( 'Advanced', 'give' ); |
|
111 | - $tabs['api'] = esc_html__( 'API', 'give' ); |
|
112 | - $tabs['system_info'] = esc_html__( 'System Info', 'give' ); |
|
110 | + $tabs['advanced'] = esc_html__('Advanced', 'give'); |
|
111 | + $tabs['api'] = esc_html__('API', 'give'); |
|
112 | + $tabs['system_info'] = esc_html__('System Info', 'give'); |
|
113 | 113 | |
114 | - return apply_filters( 'give_settings_tabs', $tabs ); |
|
114 | + return apply_filters('give_settings_tabs', $tabs); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function admin_page_display() { |
123 | 123 | |
124 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $this->give_get_settings_tabs() ) ? $_GET['tab'] : 'general'; |
|
124 | + $active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $this->give_get_settings_tabs()) ? $_GET['tab'] : 'general'; |
|
125 | 125 | |
126 | 126 | ?> |
127 | 127 | |
@@ -131,22 +131,22 @@ discard block |
||
131 | 131 | |
132 | 132 | <h2 class="nav-tab-wrapper"> |
133 | 133 | <?php |
134 | - foreach ( $this->give_get_settings_tabs() as $tab_id => $tab_name ) { |
|
134 | + foreach ($this->give_get_settings_tabs() as $tab_id => $tab_name) { |
|
135 | 135 | |
136 | - $tab_url = esc_url( add_query_arg( array( |
|
136 | + $tab_url = esc_url(add_query_arg(array( |
|
137 | 137 | 'settings-updated' => false, |
138 | 138 | 'tab' => $tab_id |
139 | - ) ) ); |
|
139 | + ))); |
|
140 | 140 | |
141 | 141 | $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
142 | 142 | |
143 | - echo '<a href="' . esc_url( $tab_url ) . '" class="nav-tab' . $active . '" id="tab-' . $tab_id . '">' . esc_html( $tab_name ) . '</a>'; |
|
143 | + echo '<a href="'.esc_url($tab_url).'" class="nav-tab'.$active.'" id="tab-'.$tab_id.'">'.esc_html($tab_name).'</a>'; |
|
144 | 144 | |
145 | 145 | } |
146 | 146 | ?> |
147 | 147 | </h2> |
148 | 148 | |
149 | - <?php cmb2_metabox_form( $this->give_settings( $active_tab ), $this->key ); ?> |
|
149 | + <?php cmb2_metabox_form($this->give_settings($active_tab), $this->key); ?> |
|
150 | 150 | |
151 | 151 | </div><!-- .wrap --> |
152 | 152 | |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @return string |
170 | 170 | */ |
171 | - function give_modify_cmb2_form_output( $form_format, $object_id, $cmb ) { |
|
171 | + function give_modify_cmb2_form_output($form_format, $object_id, $cmb) { |
|
172 | 172 | |
173 | 173 | //only modify the give settings form |
174 | - if ( 'give_settings' == $object_id ) { |
|
174 | + if ('give_settings' == $object_id) { |
|
175 | 175 | |
176 | - return '<form class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data"><input type="hidden" name="give_settings_saved" value="true"><input type="hidden" name="object_id" value="%2$s">%3$s<div class="give-submit-wrap"><input type="submit" name="submit-cmb" value="' . esc_attr__( 'Save Settings', 'give' ) . '" class="button-primary"></div></form>'; |
|
176 | + return '<form class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data"><input type="hidden" name="give_settings_saved" value="true"><input type="hidden" name="object_id" value="%2$s">%3$s<div class="give-submit-wrap"><input type="submit" name="submit-cmb" value="'.esc_attr__('Save Settings', 'give').'" class="button-primary"></div></form>'; |
|
177 | 177 | |
178 | 178 | } |
179 | 179 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * |
191 | 191 | * @return array |
192 | 192 | */ |
193 | - public function give_settings( $active_tab ) { |
|
193 | + public function give_settings($active_tab) { |
|
194 | 194 | |
195 | 195 | $give_settings = array( |
196 | 196 | /** |
@@ -198,99 +198,99 @@ discard block |
||
198 | 198 | */ |
199 | 199 | 'general' => array( |
200 | 200 | 'id' => 'general_settings', |
201 | - 'give_title' => esc_html__( 'General Settings', 'give' ), |
|
202 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
203 | - 'fields' => apply_filters( 'give_settings_general', array( |
|
201 | + 'give_title' => esc_html__('General Settings', 'give'), |
|
202 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
203 | + 'fields' => apply_filters('give_settings_general', array( |
|
204 | 204 | array( |
205 | - 'name' => esc_html__( 'General Settings', 'give' ), |
|
205 | + 'name' => esc_html__('General Settings', 'give'), |
|
206 | 206 | 'desc' => '', |
207 | 207 | 'type' => 'give_title', |
208 | 208 | 'id' => 'give_title_general_settings_1' |
209 | 209 | ), |
210 | 210 | array( |
211 | - 'name' => esc_html__( 'Success Page', 'give' ), |
|
211 | + 'name' => esc_html__('Success Page', 'give'), |
|
212 | 212 | /* translators: %s: [give_receipt] */ |
213 | - 'desc' => sprintf( __( 'The page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give' ), '<code>[give_receipt]</code>' ), |
|
213 | + 'desc' => sprintf(__('The page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give'), '<code>[give_receipt]</code>'), |
|
214 | 214 | 'id' => 'success_page', |
215 | 215 | 'type' => 'select', |
216 | - 'options' => give_cmb2_get_post_options( array( |
|
216 | + 'options' => give_cmb2_get_post_options(array( |
|
217 | 217 | 'post_type' => 'page', |
218 | - 'numberposts' => - 1 |
|
219 | - ) ), |
|
218 | + 'numberposts' => -1 |
|
219 | + )), |
|
220 | 220 | ), |
221 | 221 | array( |
222 | - 'name' => esc_html__( 'Failed Donation Page', 'give' ), |
|
223 | - 'desc' => esc_html__( 'The page donors are sent to if their donation is cancelled or fails.', 'give' ), |
|
222 | + 'name' => esc_html__('Failed Donation Page', 'give'), |
|
223 | + 'desc' => esc_html__('The page donors are sent to if their donation is cancelled or fails.', 'give'), |
|
224 | 224 | 'id' => 'failure_page', |
225 | 225 | 'type' => 'select', |
226 | - 'options' => give_cmb2_get_post_options( array( |
|
226 | + 'options' => give_cmb2_get_post_options(array( |
|
227 | 227 | 'post_type' => 'page', |
228 | - 'numberposts' => - 1 |
|
229 | - ) ), |
|
228 | + 'numberposts' => -1 |
|
229 | + )), |
|
230 | 230 | ), |
231 | 231 | array( |
232 | - 'name' => esc_html__( 'Donation History Page', 'give' ), |
|
232 | + 'name' => esc_html__('Donation History Page', 'give'), |
|
233 | 233 | /* translators: %s: [donation_history] */ |
234 | - 'desc' => sprintf( __( 'The page showing a complete donation history for the current user. The %s shortcode should be on this page.', 'give' ), '<code>[donation_history]</code>' ), |
|
234 | + 'desc' => sprintf(__('The page showing a complete donation history for the current user. The %s shortcode should be on this page.', 'give'), '<code>[donation_history]</code>'), |
|
235 | 235 | 'id' => 'history_page', |
236 | 236 | 'type' => 'select', |
237 | - 'options' => give_cmb2_get_post_options( array( |
|
237 | + 'options' => give_cmb2_get_post_options(array( |
|
238 | 238 | 'post_type' => 'page', |
239 | - 'numberposts' => - 1 |
|
240 | - ) ), |
|
239 | + 'numberposts' => -1 |
|
240 | + )), |
|
241 | 241 | ), |
242 | 242 | array( |
243 | - 'name' => esc_html__( 'Base Country', 'give' ), |
|
244 | - 'desc' => esc_html__( 'The country your site operates from.', 'give' ), |
|
243 | + 'name' => esc_html__('Base Country', 'give'), |
|
244 | + 'desc' => esc_html__('The country your site operates from.', 'give'), |
|
245 | 245 | 'id' => 'base_country', |
246 | 246 | 'type' => 'select', |
247 | 247 | 'options' => give_get_country_list(), |
248 | 248 | ), |
249 | 249 | array( |
250 | - 'name' => esc_html__( 'Currency Settings', 'give' ), |
|
250 | + 'name' => esc_html__('Currency Settings', 'give'), |
|
251 | 251 | 'desc' => '', |
252 | 252 | 'type' => 'give_title', |
253 | 253 | 'id' => 'give_title_general_settings_2' |
254 | 254 | ), |
255 | 255 | array( |
256 | - 'name' => esc_html__( 'Currency', 'give' ), |
|
257 | - 'desc' => esc_html__( 'The donation currency. Note that some payment gateways have currency restrictions.', 'give' ), |
|
256 | + 'name' => esc_html__('Currency', 'give'), |
|
257 | + 'desc' => esc_html__('The donation currency. Note that some payment gateways have currency restrictions.', 'give'), |
|
258 | 258 | 'id' => 'currency', |
259 | 259 | 'type' => 'select', |
260 | 260 | 'options' => give_get_currencies(), |
261 | 261 | 'default' => 'USD', |
262 | 262 | ), |
263 | 263 | array( |
264 | - 'name' => esc_html__( 'Currency Position', 'give' ), |
|
265 | - 'desc' => esc_html__( 'The position of the currency symbol.', 'give' ), |
|
264 | + 'name' => esc_html__('Currency Position', 'give'), |
|
265 | + 'desc' => esc_html__('The position of the currency symbol.', 'give'), |
|
266 | 266 | 'id' => 'currency_position', |
267 | 267 | 'type' => 'select', |
268 | 268 | 'options' => array( |
269 | 269 | /* translators: %s: currency symbol */ |
270 | - 'before' => sprintf( esc_html__( 'Before - %s10', 'give' ), give_currency_symbol( give_get_currency() ) ), |
|
270 | + 'before' => sprintf(esc_html__('Before - %s10', 'give'), give_currency_symbol(give_get_currency())), |
|
271 | 271 | /* translators: %s: currency symbol */ |
272 | - 'after' => sprintf( esc_html__( 'After - 10%s', 'give' ), give_currency_symbol( give_get_currency() ) ) |
|
272 | + 'after' => sprintf(esc_html__('After - 10%s', 'give'), give_currency_symbol(give_get_currency())) |
|
273 | 273 | ), |
274 | 274 | 'default' => 'before', |
275 | 275 | ), |
276 | 276 | array( |
277 | - 'name' => esc_html__( 'Thousands Separator', 'give' ), |
|
278 | - 'desc' => esc_html__( 'The symbol (usually , or .) to separate thousands.', 'give' ), |
|
277 | + 'name' => esc_html__('Thousands Separator', 'give'), |
|
278 | + 'desc' => esc_html__('The symbol (usually , or .) to separate thousands.', 'give'), |
|
279 | 279 | 'id' => 'thousands_separator', |
280 | 280 | 'type' => 'text_small', |
281 | 281 | 'sanitization_cb' => 'give_sanitize_thousand_separator', |
282 | 282 | 'default' => ',', |
283 | 283 | ), |
284 | 284 | array( |
285 | - 'name' => esc_html__( 'Decimal Separator', 'give' ), |
|
286 | - 'desc' => esc_html__( 'The symbol (usually , or .) to separate decimal points.', 'give' ), |
|
285 | + 'name' => esc_html__('Decimal Separator', 'give'), |
|
286 | + 'desc' => esc_html__('The symbol (usually , or .) to separate decimal points.', 'give'), |
|
287 | 287 | 'id' => 'decimal_separator', |
288 | 288 | 'type' => 'text_small', |
289 | 289 | 'default' => '.', |
290 | 290 | ), |
291 | 291 | array( |
292 | - 'name' => esc_html__( 'Number of Decimals', 'give' ), |
|
293 | - 'desc' => esc_html__( 'The number of decimal points displayed in amounts.', 'give' ), |
|
292 | + 'name' => esc_html__('Number of Decimals', 'give'), |
|
293 | + 'desc' => esc_html__('The number of decimal points displayed in amounts.', 'give'), |
|
294 | 294 | 'id' => 'number_decimals', |
295 | 295 | 'type' => 'text_small', |
296 | 296 | 'default' => 2, |
@@ -304,83 +304,83 @@ discard block |
||
304 | 304 | */ |
305 | 305 | 'gateways' => array( |
306 | 306 | 'id' => 'payment_gateways', |
307 | - 'give_title' => esc_html__( 'Payment Gateways', 'give' ), |
|
308 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
309 | - 'fields' => apply_filters( 'give_settings_gateways', array( |
|
307 | + 'give_title' => esc_html__('Payment Gateways', 'give'), |
|
308 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
309 | + 'fields' => apply_filters('give_settings_gateways', array( |
|
310 | 310 | array( |
311 | - 'name' => esc_html__( 'Gateways Settings', 'give' ), |
|
311 | + 'name' => esc_html__('Gateways Settings', 'give'), |
|
312 | 312 | 'desc' => '', |
313 | 313 | 'id' => 'give_title_gateway_settings_1', |
314 | 314 | 'type' => 'give_title' |
315 | 315 | ), |
316 | 316 | array( |
317 | - 'name' => esc_html__( 'Test Mode', 'give' ), |
|
318 | - 'desc' => esc_html__( 'While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give' ), |
|
317 | + 'name' => esc_html__('Test Mode', 'give'), |
|
318 | + 'desc' => esc_html__('While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give'), |
|
319 | 319 | 'id' => 'test_mode', |
320 | 320 | 'type' => 'checkbox' |
321 | 321 | ), |
322 | 322 | array( |
323 | - 'name' => esc_html__( 'Enabled Gateways', 'give' ), |
|
324 | - 'desc' => esc_html__( 'Enable your payment gateway. Can be ordered by dragging.', 'give' ), |
|
323 | + 'name' => esc_html__('Enabled Gateways', 'give'), |
|
324 | + 'desc' => esc_html__('Enable your payment gateway. Can be ordered by dragging.', 'give'), |
|
325 | 325 | 'id' => 'gateways', |
326 | 326 | 'type' => 'enabled_gateways' |
327 | 327 | ), |
328 | 328 | array( |
329 | - 'name' => esc_html__( 'Default Gateway', 'give' ), |
|
330 | - 'desc' => esc_html__( 'The gateway that will be selected by default.', 'give' ), |
|
329 | + 'name' => esc_html__('Default Gateway', 'give'), |
|
330 | + 'desc' => esc_html__('The gateway that will be selected by default.', 'give'), |
|
331 | 331 | 'id' => 'default_gateway', |
332 | 332 | 'type' => 'default_gateway' |
333 | 333 | ), |
334 | 334 | array( |
335 | - 'name' => esc_html__( 'PayPal Standard', 'give' ), |
|
335 | + 'name' => esc_html__('PayPal Standard', 'give'), |
|
336 | 336 | 'desc' => '', |
337 | 337 | 'type' => 'give_title', |
338 | 338 | 'id' => 'give_title_gateway_settings_2', |
339 | 339 | ), |
340 | 340 | array( |
341 | - 'name' => esc_html__( 'PayPal Email', 'give' ), |
|
342 | - 'desc' => esc_html__( 'Enter your PayPal account\'s email.', 'give' ), |
|
341 | + 'name' => esc_html__('PayPal Email', 'give'), |
|
342 | + 'desc' => esc_html__('Enter your PayPal account\'s email.', 'give'), |
|
343 | 343 | 'id' => 'paypal_email', |
344 | 344 | 'type' => 'text_email', |
345 | 345 | ), |
346 | 346 | array( |
347 | - 'name' => esc_html__( 'PayPal Page Style', 'give' ), |
|
348 | - 'desc' => esc_html__( 'Enter the name of the page style to use, or leave blank to use the default.', 'give' ), |
|
347 | + 'name' => esc_html__('PayPal Page Style', 'give'), |
|
348 | + 'desc' => esc_html__('Enter the name of the page style to use, or leave blank to use the default.', 'give'), |
|
349 | 349 | 'id' => 'paypal_page_style', |
350 | 350 | 'type' => 'text', |
351 | 351 | ), |
352 | 352 | array( |
353 | - 'name' => esc_html__( 'PayPal Transaction Type', 'give' ), |
|
354 | - 'desc' => esc_html__( 'Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give' ), |
|
353 | + 'name' => esc_html__('PayPal Transaction Type', 'give'), |
|
354 | + 'desc' => esc_html__('Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give'), |
|
355 | 355 | 'id' => 'paypal_button_type', |
356 | 356 | 'type' => 'radio_inline', |
357 | 357 | 'options' => array( |
358 | - 'donation' => esc_html__( 'Donation', 'give' ), |
|
359 | - 'standard' => esc_html__( 'Standard Transaction', 'give' ) |
|
358 | + 'donation' => esc_html__('Donation', 'give'), |
|
359 | + 'standard' => esc_html__('Standard Transaction', 'give') |
|
360 | 360 | ), |
361 | 361 | 'default' => 'donation', |
362 | 362 | ), |
363 | 363 | array( |
364 | - 'name' => esc_html__( 'Disable PayPal IPN Verification', 'give' ), |
|
365 | - 'desc' => esc_html__( 'If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give' ), |
|
364 | + 'name' => esc_html__('Disable PayPal IPN Verification', 'give'), |
|
365 | + 'desc' => esc_html__('If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give'), |
|
366 | 366 | 'id' => 'disable_paypal_verification', |
367 | 367 | 'type' => 'checkbox' |
368 | 368 | ), |
369 | 369 | array( |
370 | - 'name' => esc_html__( 'Offline Donations', 'give' ), |
|
370 | + 'name' => esc_html__('Offline Donations', 'give'), |
|
371 | 371 | 'desc' => '', |
372 | 372 | 'type' => 'give_title', |
373 | 373 | 'id' => 'give_title_gateway_settings_3', |
374 | 374 | ), |
375 | 375 | array( |
376 | - 'name' => esc_html__( 'Collect Billing Details', 'give' ), |
|
377 | - 'desc' => esc_html__( 'Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give' ), |
|
376 | + 'name' => esc_html__('Collect Billing Details', 'give'), |
|
377 | + 'desc' => esc_html__('Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give'), |
|
378 | 378 | 'id' => 'give_offline_donation_enable_billing_fields', |
379 | 379 | 'type' => 'checkbox' |
380 | 380 | ), |
381 | 381 | array( |
382 | - 'name' => esc_html__( 'Offline Donation Instructions', 'give' ), |
|
383 | - 'desc' => esc_html__( 'The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give' ), |
|
382 | + 'name' => esc_html__('Offline Donation Instructions', 'give'), |
|
383 | + 'desc' => esc_html__('The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give'), |
|
384 | 384 | 'id' => 'global_offline_donation_content', |
385 | 385 | 'default' => give_get_default_offline_donation_content(), |
386 | 386 | 'type' => 'wysiwyg', |
@@ -389,15 +389,15 @@ discard block |
||
389 | 389 | ) |
390 | 390 | ), |
391 | 391 | array( |
392 | - 'name' => esc_html__( 'Offline Donation Email Instructions Subject', 'give' ), |
|
393 | - 'desc' => esc_html__( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
392 | + 'name' => esc_html__('Offline Donation Email Instructions Subject', 'give'), |
|
393 | + 'desc' => esc_html__('Enter the subject line for the donation receipt email.', 'give'), |
|
394 | 394 | 'id' => 'offline_donation_subject', |
395 | - 'default' => esc_attr__( '{donation} - Offline Donation Instructions', 'give' ), |
|
395 | + 'default' => esc_attr__('{donation} - Offline Donation Instructions', 'give'), |
|
396 | 396 | 'type' => 'text' |
397 | 397 | ), |
398 | 398 | array( |
399 | - 'name' => esc_html__( 'Offline Donation Email Instructions', 'give' ), |
|
400 | - 'desc' => esc_html__( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
399 | + 'name' => esc_html__('Offline Donation Email Instructions', 'give'), |
|
400 | + 'desc' => esc_html__('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
401 | 401 | 'id' => 'global_offline_donation_email', |
402 | 402 | 'default' => give_get_default_offline_donation_email_content(), |
403 | 403 | 'type' => 'wysiwyg', |
@@ -411,100 +411,100 @@ discard block |
||
411 | 411 | /** Display Settings */ |
412 | 412 | 'display' => array( |
413 | 413 | 'id' => 'display_settings', |
414 | - 'give_title' => esc_html__( 'Display Settings', 'give' ), |
|
415 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
416 | - 'fields' => apply_filters( 'give_settings_display', array( |
|
414 | + 'give_title' => esc_html__('Display Settings', 'give'), |
|
415 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
416 | + 'fields' => apply_filters('give_settings_display', array( |
|
417 | 417 | array( |
418 | - 'name' => esc_html__( 'Display Settings', 'give' ), |
|
418 | + 'name' => esc_html__('Display Settings', 'give'), |
|
419 | 419 | 'desc' => '', |
420 | 420 | 'id' => 'give_title_display_settings_1', |
421 | 421 | 'type' => 'give_title' |
422 | 422 | ), |
423 | 423 | array( |
424 | - 'name' => esc_html__( 'Disable CSS', 'give' ), |
|
425 | - 'desc' => esc_html__( 'Enable this option if you would like to disable all of Give\'s included CSS stylesheets.', 'give' ), |
|
424 | + 'name' => esc_html__('Disable CSS', 'give'), |
|
425 | + 'desc' => esc_html__('Enable this option if you would like to disable all of Give\'s included CSS stylesheets.', 'give'), |
|
426 | 426 | 'id' => 'disable_css', |
427 | 427 | 'type' => 'checkbox' |
428 | 428 | ), |
429 | 429 | array( |
430 | - 'name' => esc_html__( 'Enable Floating Labels', 'give' ), |
|
430 | + 'name' => esc_html__('Enable Floating Labels', 'give'), |
|
431 | 431 | /* translators: %s: http://docs.givewp.com/form-floating-labels */ |
432 | - 'desc' => sprintf( wp_kses( __( 'Enable <a href="%s" target="_blank">floating labels</a> in Give\'s donation forms. Note that if the "Disable CSS" option is enabled, you will need to style the floating labels yourself.', 'give' ), array( 'a' => array( 'href' => array(), 'target' => array() ) ) ), esc_url( 'http://docs.givewp.com/form-floating-labels' ) ), |
|
432 | + 'desc' => sprintf(wp_kses(__('Enable <a href="%s" target="_blank">floating labels</a> in Give\'s donation forms. Note that if the "Disable CSS" option is enabled, you will need to style the floating labels yourself.', 'give'), array('a' => array('href' => array(), 'target' => array()))), esc_url('http://docs.givewp.com/form-floating-labels')), |
|
433 | 433 | 'id' => 'floatlabels', |
434 | 434 | 'type' => 'checkbox' |
435 | 435 | ), |
436 | 436 | array( |
437 | - 'name' => esc_html__( 'Disable Welcome Screen', 'give' ), |
|
437 | + 'name' => esc_html__('Disable Welcome Screen', 'give'), |
|
438 | 438 | /* translators: %s: about page URL */ |
439 | - 'desc' => sprintf( wp_kses( __( 'Enable this option if you would like to disable the <a href="%s" target="_blank">Give Welcome screen</a> every time Give is activated and/or updated.', 'give' ), array( |
|
439 | + 'desc' => sprintf(wp_kses(__('Enable this option if you would like to disable the <a href="%s" target="_blank">Give Welcome screen</a> every time Give is activated and/or updated.', 'give'), array( |
|
440 | 440 | 'a' => array( |
441 | 441 | 'href' => array(), |
442 | 442 | 'target' => array() |
443 | 443 | ) |
444 | - ) ), esc_url( admin_url( 'index.php?page=give-about' ) ) ), |
|
444 | + )), esc_url(admin_url('index.php?page=give-about'))), |
|
445 | 445 | 'id' => 'disable_welcome', |
446 | 446 | 'type' => 'checkbox' |
447 | 447 | ), |
448 | 448 | array( |
449 | - 'name' => esc_html__( 'Post Types', 'give' ), |
|
449 | + 'name' => esc_html__('Post Types', 'give'), |
|
450 | 450 | 'desc' => '', |
451 | 451 | 'id' => 'give_title_display_settings_2', |
452 | 452 | 'type' => 'give_title' |
453 | 453 | ), |
454 | 454 | array( |
455 | - 'name' => esc_html__( 'Disable Form Single Views', 'give' ), |
|
456 | - 'desc' => esc_html__( 'By default, all forms have single views enabled which create a specific URL on your website for that form. This option disables the singular and archive views from being publicly viewable. Note: you will need to embed forms using a shortcode or widget if enabled.', 'give' ), |
|
455 | + 'name' => esc_html__('Disable Form Single Views', 'give'), |
|
456 | + 'desc' => esc_html__('By default, all forms have single views enabled which create a specific URL on your website for that form. This option disables the singular and archive views from being publicly viewable. Note: you will need to embed forms using a shortcode or widget if enabled.', 'give'), |
|
457 | 457 | 'id' => 'disable_forms_singular', |
458 | 458 | 'type' => 'checkbox' |
459 | 459 | ), |
460 | 460 | array( |
461 | - 'name' => esc_html__( 'Disable Form Archives', 'give' ), |
|
462 | - 'desc' => esc_html__( 'Archives pages list all the forms you have created. This option will disable only the form\'s archive page(s). The single form\'s view will remain in place. Note: you will need to refresh your permalinks after this option has been enabled.', 'give' ), |
|
461 | + 'name' => esc_html__('Disable Form Archives', 'give'), |
|
462 | + 'desc' => esc_html__('Archives pages list all the forms you have created. This option will disable only the form\'s archive page(s). The single form\'s view will remain in place. Note: you will need to refresh your permalinks after this option has been enabled.', 'give'), |
|
463 | 463 | 'id' => 'disable_forms_archives', |
464 | 464 | 'type' => 'checkbox' |
465 | 465 | ), |
466 | 466 | array( |
467 | - 'name' => esc_html__( 'Disable Form Excerpts', 'give' ), |
|
468 | - 'desc' => esc_html__( 'The excerpt is an optional summary or description of a donation form; in short, a summary as to why the user should give.', 'give' ), |
|
467 | + 'name' => esc_html__('Disable Form Excerpts', 'give'), |
|
468 | + 'desc' => esc_html__('The excerpt is an optional summary or description of a donation form; in short, a summary as to why the user should give.', 'give'), |
|
469 | 469 | 'id' => 'disable_forms_excerpt', |
470 | 470 | 'type' => 'checkbox' |
471 | 471 | ), |
472 | 472 | |
473 | 473 | array( |
474 | - 'name' => esc_html__( 'Featured Image Size', 'give' ), |
|
475 | - 'desc' => esc_html__( 'The Featured Image is an image that is chosen as the representative image for a donation form. Some themes may have custom featured image sizes. Please select the size you would like to display for your single donation form\'s featured image.', 'give' ), |
|
474 | + 'name' => esc_html__('Featured Image Size', 'give'), |
|
475 | + 'desc' => esc_html__('The Featured Image is an image that is chosen as the representative image for a donation form. Some themes may have custom featured image sizes. Please select the size you would like to display for your single donation form\'s featured image.', 'give'), |
|
476 | 476 | 'id' => 'featured_image_size', |
477 | 477 | 'type' => 'select', |
478 | 478 | 'default' => 'large', |
479 | 479 | 'options' => give_get_featured_image_sizes() |
480 | 480 | ), |
481 | 481 | array( |
482 | - 'name' => esc_html__( 'Disable Form Featured Image', 'give' ), |
|
483 | - 'desc' => esc_html__( 'If you do not wish to use the featured image functionality you can disable it using this option and it will not be displayed for single donation forms.', 'give' ), |
|
482 | + 'name' => esc_html__('Disable Form Featured Image', 'give'), |
|
483 | + 'desc' => esc_html__('If you do not wish to use the featured image functionality you can disable it using this option and it will not be displayed for single donation forms.', 'give'), |
|
484 | 484 | 'id' => 'disable_form_featured_img', |
485 | 485 | 'type' => 'checkbox' |
486 | 486 | ), |
487 | 487 | array( |
488 | - 'name' => esc_html__( 'Disable Single Form Sidebar', 'give' ), |
|
489 | - 'desc' => esc_html__( 'The sidebar allows you to add additional widget to the Give single form view. If you don\'t plan on using the sidebar you may disable it with this option.', 'give' ), |
|
488 | + 'name' => esc_html__('Disable Single Form Sidebar', 'give'), |
|
489 | + 'desc' => esc_html__('The sidebar allows you to add additional widget to the Give single form view. If you don\'t plan on using the sidebar you may disable it with this option.', 'give'), |
|
490 | 490 | 'id' => 'disable_form_sidebar', |
491 | 491 | 'type' => 'checkbox' |
492 | 492 | ), |
493 | 493 | array( |
494 | - 'name' => esc_html__( 'Taxonomies', 'give' ), |
|
494 | + 'name' => esc_html__('Taxonomies', 'give'), |
|
495 | 495 | 'desc' => '', |
496 | 496 | 'id' => 'give_title_display_settings_3', |
497 | 497 | 'type' => 'give_title' |
498 | 498 | ), |
499 | 499 | array( |
500 | - 'name' => esc_html__( 'Enable Form Categories', 'give' ), |
|
501 | - 'desc' => esc_html__( 'Enables the "Category" taxonomy for all Give forms.', 'give' ), |
|
500 | + 'name' => esc_html__('Enable Form Categories', 'give'), |
|
501 | + 'desc' => esc_html__('Enables the "Category" taxonomy for all Give forms.', 'give'), |
|
502 | 502 | 'id' => 'categories', |
503 | 503 | 'type' => 'checkbox' |
504 | 504 | ), |
505 | 505 | array( |
506 | - 'name' => esc_html__( 'Enable Form Tags', 'give' ), |
|
507 | - 'desc' => esc_html__( 'Enables the "Tag" taxonomy for all Give forms.', 'give' ), |
|
506 | + 'name' => esc_html__('Enable Form Tags', 'give'), |
|
507 | + 'desc' => esc_html__('Enables the "Tag" taxonomy for all Give forms.', 'give'), |
|
508 | 508 | 'id' => 'tags', |
509 | 509 | 'type' => 'checkbox' |
510 | 510 | ), |
@@ -538,101 +538,101 @@ discard block |
||
538 | 538 | */ |
539 | 539 | 'emails' => array( |
540 | 540 | 'id' => 'email_settings', |
541 | - 'give_title' => esc_html__( 'Email Settings', 'give' ), |
|
542 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
543 | - 'fields' => apply_filters( 'give_settings_emails', array( |
|
541 | + 'give_title' => esc_html__('Email Settings', 'give'), |
|
542 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
543 | + 'fields' => apply_filters('give_settings_emails', array( |
|
544 | 544 | array( |
545 | - 'name' => esc_html__( 'Email Settings', 'give' ), |
|
545 | + 'name' => esc_html__('Email Settings', 'give'), |
|
546 | 546 | 'desc' => '', |
547 | 547 | 'id' => 'give_title_email_settings_1', |
548 | 548 | 'type' => 'give_title' |
549 | 549 | ), |
550 | 550 | array( |
551 | 551 | 'id' => 'email_template', |
552 | - 'name' => esc_html__( 'Email Template', 'give' ), |
|
553 | - 'desc' => esc_html__( 'Choose a template. Click "Save Changes" then "Preview Donation Receipt" to see the new template.', 'give' ), |
|
552 | + 'name' => esc_html__('Email Template', 'give'), |
|
553 | + 'desc' => esc_html__('Choose a template. Click "Save Changes" then "Preview Donation Receipt" to see the new template.', 'give'), |
|
554 | 554 | 'type' => 'select', |
555 | 555 | 'options' => give_get_email_templates() |
556 | 556 | ), |
557 | 557 | array( |
558 | 558 | 'id' => 'email_logo', |
559 | - 'name' => esc_html__( 'Logo', 'give' ), |
|
560 | - 'desc' => esc_html__( 'Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give' ), |
|
559 | + 'name' => esc_html__('Logo', 'give'), |
|
560 | + 'desc' => esc_html__('Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give'), |
|
561 | 561 | 'type' => 'file' |
562 | 562 | ), |
563 | 563 | array( |
564 | 564 | 'id' => 'from_name', |
565 | - 'name' => esc_html__( 'From Name', 'give' ), |
|
566 | - 'desc' => esc_html__( 'The name that appears in the "From" field in donation receipt emails.', 'give' ), |
|
567 | - 'default' => get_bloginfo( 'name' ), |
|
565 | + 'name' => esc_html__('From Name', 'give'), |
|
566 | + 'desc' => esc_html__('The name that appears in the "From" field in donation receipt emails.', 'give'), |
|
567 | + 'default' => get_bloginfo('name'), |
|
568 | 568 | 'type' => 'text' |
569 | 569 | ), |
570 | 570 | array( |
571 | 571 | 'id' => 'from_email', |
572 | - 'name' => esc_html__( 'From Email', 'give' ), |
|
573 | - 'desc' => esc_html__( 'Email to send donation receipts from. This will act as the "from" and "reply-to" address.', 'give' ), |
|
574 | - 'default' => get_bloginfo( 'admin_email' ), |
|
572 | + 'name' => esc_html__('From Email', 'give'), |
|
573 | + 'desc' => esc_html__('Email to send donation receipts from. This will act as the "from" and "reply-to" address.', 'give'), |
|
574 | + 'default' => get_bloginfo('admin_email'), |
|
575 | 575 | 'type' => 'text' |
576 | 576 | ), |
577 | 577 | array( |
578 | - 'name' => esc_html__( 'Donation Receipt', 'give' ), |
|
578 | + 'name' => esc_html__('Donation Receipt', 'give'), |
|
579 | 579 | 'desc' => '', |
580 | 580 | 'id' => 'give_title_email_settings_2', |
581 | 581 | 'type' => 'give_title' |
582 | 582 | ), |
583 | 583 | array( |
584 | 584 | 'id' => 'donation_subject', |
585 | - 'name' => esc_html__( 'Donation Email Subject', 'give' ), |
|
586 | - 'desc' => esc_html__( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
587 | - 'default' => esc_attr__( 'Donation Receipt', 'give' ), |
|
585 | + 'name' => esc_html__('Donation Email Subject', 'give'), |
|
586 | + 'desc' => esc_html__('Enter the subject line for the donation receipt email.', 'give'), |
|
587 | + 'default' => esc_attr__('Donation Receipt', 'give'), |
|
588 | 588 | 'type' => 'text' |
589 | 589 | ), |
590 | 590 | array( |
591 | 591 | 'id' => 'donation_receipt', |
592 | - 'name' => esc_html__( 'Donation Receipt', 'give' ), |
|
592 | + 'name' => esc_html__('Donation Receipt', 'give'), |
|
593 | 593 | 'desc' => sprintf( |
594 | 594 | /* translators: %s: emails tags list */ |
595 | - esc_html__( 'Enter the email that is sent to users after completing a successful donation. HTML is accepted. Available template tags: %s', 'give' ), |
|
596 | - '<br/>' . give_get_emails_tags_list() |
|
595 | + esc_html__('Enter the email that is sent to users after completing a successful donation. HTML is accepted. Available template tags: %s', 'give'), |
|
596 | + '<br/>'.give_get_emails_tags_list() |
|
597 | 597 | ), |
598 | 598 | 'type' => 'wysiwyg', |
599 | 599 | 'default' => give_get_default_donation_receipt_email() |
600 | 600 | ), |
601 | 601 | array( |
602 | - 'name' => esc_html__( 'New Donation Notification', 'give' ), |
|
602 | + 'name' => esc_html__('New Donation Notification', 'give'), |
|
603 | 603 | 'desc' => '', |
604 | 604 | 'id' => 'give_title_email_settings_3', |
605 | 605 | 'type' => 'give_title' |
606 | 606 | ), |
607 | 607 | array( |
608 | 608 | 'id' => 'donation_notification_subject', |
609 | - 'name' => esc_html__( 'Donation Notification Subject', 'give' ), |
|
610 | - 'desc' => esc_html__( 'Enter the subject line for the donation notification email.', 'give' ), |
|
609 | + 'name' => esc_html__('Donation Notification Subject', 'give'), |
|
610 | + 'desc' => esc_html__('Enter the subject line for the donation notification email.', 'give'), |
|
611 | 611 | 'type' => 'text', |
612 | - 'default' => esc_attr__( 'New Donation - #{payment_id}', 'give' ) |
|
612 | + 'default' => esc_attr__('New Donation - #{payment_id}', 'give') |
|
613 | 613 | ), |
614 | 614 | array( |
615 | 615 | 'id' => 'donation_notification', |
616 | - 'name' => esc_html__( 'Donation Notification', 'give' ), |
|
616 | + 'name' => esc_html__('Donation Notification', 'give'), |
|
617 | 617 | 'desc' => sprintf( |
618 | 618 | /* translators: %s: emails tags list */ |
619 | - esc_html__( 'Enter the email that is sent to donation notification emails after completion of a donation. HTML is accepted. Available template tags: %s', 'give' ), |
|
620 | - '<br/>' . give_get_emails_tags_list() |
|
619 | + esc_html__('Enter the email that is sent to donation notification emails after completion of a donation. HTML is accepted. Available template tags: %s', 'give'), |
|
620 | + '<br/>'.give_get_emails_tags_list() |
|
621 | 621 | ), |
622 | 622 | 'type' => 'wysiwyg', |
623 | 623 | 'default' => give_get_default_donation_notification_email() |
624 | 624 | ), |
625 | 625 | array( |
626 | 626 | 'id' => 'admin_notice_emails', |
627 | - 'name' => esc_html__( 'Donation Notification Emails', 'give' ), |
|
628 | - 'desc' => __( 'Enter the email address(es) that should receive a notification anytime a donation is made, please only enter <span class="give-underline">one email address per line</span> and <strong>not separated by commas</strong>.', 'give' ), |
|
627 | + 'name' => esc_html__('Donation Notification Emails', 'give'), |
|
628 | + 'desc' => __('Enter the email address(es) that should receive a notification anytime a donation is made, please only enter <span class="give-underline">one email address per line</span> and <strong>not separated by commas</strong>.', 'give'), |
|
629 | 629 | 'type' => 'textarea', |
630 | - 'default' => get_bloginfo( 'admin_email' ) |
|
630 | + 'default' => get_bloginfo('admin_email') |
|
631 | 631 | ), |
632 | 632 | array( |
633 | 633 | 'id' => 'disable_admin_notices', |
634 | - 'name' => esc_html__( 'Disable Admin Notifications', 'give' ), |
|
635 | - 'desc' => esc_html__( 'Check this box if you do not want to receive emails when new donations are made.', 'give' ), |
|
634 | + 'name' => esc_html__('Disable Admin Notifications', 'give'), |
|
635 | + 'desc' => esc_html__('Check this box if you do not want to receive emails when new donations are made.', 'give'), |
|
636 | 636 | 'type' => 'checkbox' |
637 | 637 | ) |
638 | 638 | ) |
@@ -641,99 +641,99 @@ discard block |
||
641 | 641 | /** Extension Settings */ |
642 | 642 | 'addons' => array( |
643 | 643 | 'id' => 'addons', |
644 | - 'give_title' => esc_html__( 'Give Add-ons Settings', 'give' ), |
|
645 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
646 | - 'fields' => apply_filters( 'give_settings_addons', array() |
|
644 | + 'give_title' => esc_html__('Give Add-ons Settings', 'give'), |
|
645 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
646 | + 'fields' => apply_filters('give_settings_addons', array() |
|
647 | 647 | ) |
648 | 648 | ), |
649 | 649 | /** Licenses Settings */ |
650 | 650 | 'licenses' => array( |
651 | 651 | 'id' => 'licenses', |
652 | - 'give_title' => esc_html__( 'Give Licenses', 'give' ), |
|
653 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
654 | - 'fields' => apply_filters( 'give_settings_licenses', array() |
|
652 | + 'give_title' => esc_html__('Give Licenses', 'give'), |
|
653 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
654 | + 'fields' => apply_filters('give_settings_licenses', array() |
|
655 | 655 | ) |
656 | 656 | ), |
657 | 657 | /** Advanced Options */ |
658 | 658 | 'advanced' => array( |
659 | 659 | 'id' => 'advanced_options', |
660 | - 'give_title' => esc_html__( 'Advanced Options', 'give' ), |
|
661 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
662 | - 'fields' => apply_filters( 'give_settings_advanced', array( |
|
660 | + 'give_title' => esc_html__('Advanced Options', 'give'), |
|
661 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
662 | + 'fields' => apply_filters('give_settings_advanced', array( |
|
663 | 663 | array( |
664 | - 'name' => esc_html__( 'Access Control', 'give' ), |
|
664 | + 'name' => esc_html__('Access Control', 'give'), |
|
665 | 665 | 'desc' => '', |
666 | 666 | 'id' => 'give_title_session_control_1', |
667 | 667 | 'type' => 'give_title' |
668 | 668 | ), |
669 | 669 | array( |
670 | 670 | 'id' => 'session_lifetime', |
671 | - 'name' => esc_html__( 'Session Lifetime', 'give' ), |
|
672 | - 'desc' => esc_html__( 'The length of time a user\'s session is kept alive. Give starts a new session per user upon donation. Sessions allow donors to view their donation receipts without being logged in.', 'give' ), |
|
671 | + 'name' => esc_html__('Session Lifetime', 'give'), |
|
672 | + 'desc' => esc_html__('The length of time a user\'s session is kept alive. Give starts a new session per user upon donation. Sessions allow donors to view their donation receipts without being logged in.', 'give'), |
|
673 | 673 | 'type' => 'select', |
674 | 674 | 'options' => array( |
675 | - '86400' => esc_html__( '24 Hours', 'give' ), |
|
676 | - '172800' => esc_html__( '48 Hours', 'give' ), |
|
677 | - '259200' => esc_html__( '72 Hours', 'give' ), |
|
678 | - '604800' => esc_html__( '1 Week', 'give' ), |
|
675 | + '86400' => esc_html__('24 Hours', 'give'), |
|
676 | + '172800' => esc_html__('48 Hours', 'give'), |
|
677 | + '259200' => esc_html__('72 Hours', 'give'), |
|
678 | + '604800' => esc_html__('1 Week', 'give'), |
|
679 | 679 | ) |
680 | 680 | ), |
681 | 681 | array( |
682 | - 'name' => esc_html__( 'Email Access', 'give' ), |
|
683 | - 'desc' => esc_html__( 'Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give' ), |
|
682 | + 'name' => esc_html__('Email Access', 'give'), |
|
683 | + 'desc' => esc_html__('Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give'), |
|
684 | 684 | 'id' => 'email_access', |
685 | 685 | 'type' => 'checkbox', |
686 | 686 | ), |
687 | 687 | array( |
688 | 688 | 'id' => 'recaptcha_key', |
689 | - 'name' => esc_html__( 'reCAPTCHA Site Key', 'give' ), |
|
689 | + 'name' => esc_html__('reCAPTCHA Site Key', 'give'), |
|
690 | 690 | /* translators: %s: https://www.google.com/recaptcha/ */ |
691 | - 'desc' => sprintf( __( 'If you would like to prevent spam on the email access form navigate to <a href="%s" target="_blank">the reCAPTCHA website</a> and sign up for an API key. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give' ), esc_url( 'https://www.google.com/recaptcha/' ) ), |
|
691 | + 'desc' => sprintf(__('If you would like to prevent spam on the email access form navigate to <a href="%s" target="_blank">the reCAPTCHA website</a> and sign up for an API key. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give'), esc_url('https://www.google.com/recaptcha/')), |
|
692 | 692 | 'default' => '', |
693 | 693 | 'type' => 'text' |
694 | 694 | ), |
695 | 695 | array( |
696 | 696 | 'id' => 'recaptcha_secret', |
697 | - 'name' => esc_html__( 'reCAPTCHA Secret Key', 'give' ), |
|
698 | - 'desc' => esc_html__( 'Please paste the reCAPTCHA secret key here from your manage reCAPTCHA API Keys panel.', 'give' ), |
|
697 | + 'name' => esc_html__('reCAPTCHA Secret Key', 'give'), |
|
698 | + 'desc' => esc_html__('Please paste the reCAPTCHA secret key here from your manage reCAPTCHA API Keys panel.', 'give'), |
|
699 | 699 | 'default' => '', |
700 | 700 | 'type' => 'text' |
701 | 701 | ), |
702 | 702 | array( |
703 | - 'name' => esc_html__( 'Data Control', 'give' ), |
|
703 | + 'name' => esc_html__('Data Control', 'give'), |
|
704 | 704 | 'desc' => '', |
705 | 705 | 'id' => 'give_title_data_control_2', |
706 | 706 | 'type' => 'give_title' |
707 | 707 | ), |
708 | 708 | array( |
709 | - 'name' => esc_html__( 'Remove All Data on Uninstall?', 'give' ), |
|
710 | - 'desc' => esc_html__( 'When the plugin is deleted, completely remove all Give data.', 'give' ), |
|
709 | + 'name' => esc_html__('Remove All Data on Uninstall?', 'give'), |
|
710 | + 'desc' => esc_html__('When the plugin is deleted, completely remove all Give data.', 'give'), |
|
711 | 711 | 'id' => 'uninstall_on_delete', |
712 | 712 | 'type' => 'checkbox' |
713 | 713 | ), |
714 | 714 | array( |
715 | - 'name' => esc_html__( 'Filter Control', 'give' ), |
|
715 | + 'name' => esc_html__('Filter Control', 'give'), |
|
716 | 716 | 'desc' => '', |
717 | 717 | 'id' => 'give_title_filter_control', |
718 | 718 | 'type' => 'give_title' |
719 | 719 | ), |
720 | 720 | array( |
721 | 721 | /* translators: %s: the_content */ |
722 | - 'name' => sprintf( __( 'Disable %s filter', 'give' ), '<code>the_content</code>' ), |
|
722 | + 'name' => sprintf(__('Disable %s filter', 'give'), '<code>the_content</code>'), |
|
723 | 723 | /* translators: 1: https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content 2: the_content */ |
724 | - 'desc' => sprintf( __( 'If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give' ), esc_url( 'https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content' ), '<code>the_content</code>' ), |
|
724 | + 'desc' => sprintf(__('If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give'), esc_url('https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content'), '<code>the_content</code>'), |
|
725 | 725 | 'id' => 'disable_the_content_filter', |
726 | 726 | 'type' => 'checkbox' |
727 | 727 | ), |
728 | 728 | array( |
729 | - 'name' => esc_html__( 'Script Loading', 'give' ), |
|
729 | + 'name' => esc_html__('Script Loading', 'give'), |
|
730 | 730 | 'desc' => '', |
731 | 731 | 'id' => 'give_title_script_control', |
732 | 732 | 'type' => 'give_title' |
733 | 733 | ), |
734 | 734 | array( |
735 | - 'name' => esc_html__( 'Load Scripts in Footer?', 'give' ), |
|
736 | - 'desc' => esc_html__( 'Check this box if you would like Give to load all frontend JavaScript files in the footer.', 'give' ), |
|
735 | + 'name' => esc_html__('Load Scripts in Footer?', 'give'), |
|
736 | + 'desc' => esc_html__('Check this box if you would like Give to load all frontend JavaScript files in the footer.', 'give'), |
|
737 | 737 | 'id' => 'scripts_footer', |
738 | 738 | 'type' => 'checkbox' |
739 | 739 | ) |
@@ -743,13 +743,13 @@ discard block |
||
743 | 743 | /** API Settings */ |
744 | 744 | 'api' => array( |
745 | 745 | 'id' => 'api', |
746 | - 'give_title' => esc_html__( 'API', 'give' ), |
|
747 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
746 | + 'give_title' => esc_html__('API', 'give'), |
|
747 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
748 | 748 | 'show_names' => false, // Hide field names on the left |
749 | - 'fields' => apply_filters( 'give_settings_system', array( |
|
749 | + 'fields' => apply_filters('give_settings_system', array( |
|
750 | 750 | array( |
751 | 751 | 'id' => 'api', |
752 | - 'name' => esc_html__( 'API', 'give' ), |
|
752 | + 'name' => esc_html__('API', 'give'), |
|
753 | 753 | 'type' => 'api' |
754 | 754 | ) |
755 | 755 | ) |
@@ -758,13 +758,13 @@ discard block |
||
758 | 758 | /** Licenses Settings */ |
759 | 759 | 'system_info' => array( |
760 | 760 | 'id' => 'system_info', |
761 | - 'give_title' => esc_html__( 'System Info', 'give' ), |
|
762 | - 'show_on' => array( 'key' => 'options-page', 'value' => array( $this->key, ), ), |
|
763 | - 'fields' => apply_filters( 'give_settings_system', array( |
|
761 | + 'give_title' => esc_html__('System Info', 'give'), |
|
762 | + 'show_on' => array('key' => 'options-page', 'value' => array($this->key,),), |
|
763 | + 'fields' => apply_filters('give_settings_system', array( |
|
764 | 764 | array( |
765 | 765 | 'id' => 'system-info-textarea', |
766 | - 'name' => esc_html__( 'System Info', 'give' ), |
|
767 | - 'desc' => esc_html__( 'Please copy and paste this information in your ticket when contacting support.', 'give' ), |
|
766 | + 'name' => esc_html__('System Info', 'give'), |
|
767 | + 'desc' => esc_html__('Please copy and paste this information in your ticket when contacting support.', 'give'), |
|
768 | 768 | 'type' => 'system_info' |
769 | 769 | ) |
770 | 770 | ) |
@@ -772,16 +772,16 @@ discard block |
||
772 | 772 | ), |
773 | 773 | ); |
774 | 774 | |
775 | - $give_settings = apply_filters( 'give_registered_settings', $give_settings ); |
|
775 | + $give_settings = apply_filters('give_registered_settings', $give_settings); |
|
776 | 776 | |
777 | 777 | //Return all settings array if no active tab |
778 | - if ( empty( $active_tab ) || ! isset( $give_settings[ $active_tab ] ) ) { |
|
778 | + if (empty($active_tab) || ! isset($give_settings[$active_tab])) { |
|
779 | 779 | return $give_settings; |
780 | 780 | } |
781 | 781 | |
782 | 782 | |
783 | 783 | // Add other tabs and settings fields as needed |
784 | - return $give_settings[ $active_tab ]; |
|
784 | + return $give_settings[$active_tab]; |
|
785 | 785 | |
786 | 786 | } |
787 | 787 | |
@@ -790,11 +790,11 @@ discard block |
||
790 | 790 | */ |
791 | 791 | public function settings_notices() { |
792 | 792 | |
793 | - if ( ! isset( $_POST['give_settings_saved'] ) ) { |
|
793 | + if ( ! isset($_POST['give_settings_saved'])) { |
|
794 | 794 | return; |
795 | 795 | } |
796 | 796 | |
797 | - add_settings_error( 'give-notices', 'global-settings-updated', esc_html__( 'Settings updated.', 'give' ), 'updated' ); |
|
797 | + add_settings_error('give-notices', 'global-settings-updated', esc_html__('Settings updated.', 'give'), 'updated'); |
|
798 | 798 | |
799 | 799 | } |
800 | 800 | |
@@ -809,17 +809,17 @@ discard block |
||
809 | 809 | * @return mixed Field value or exception is thrown. |
810 | 810 | * @throws Exception Throws an exception if the field is invalid. |
811 | 811 | */ |
812 | - public function __get( $field ) { |
|
812 | + public function __get($field) { |
|
813 | 813 | |
814 | 814 | // Allowed fields to retrieve |
815 | - if ( in_array( $field, array( 'key', 'fields', 'give_title', 'options_page' ), true ) ) { |
|
815 | + if (in_array($field, array('key', 'fields', 'give_title', 'options_page'), true)) { |
|
816 | 816 | return $this->{$field}; |
817 | 817 | } |
818 | - if ( 'option_metabox' === $field ) { |
|
818 | + if ('option_metabox' === $field) { |
|
819 | 819 | return $this->option_metabox(); |
820 | 820 | } |
821 | 821 | |
822 | - throw new Exception( sprintf( esc_html__( 'Invalid property: %s', 'give' ), $field ) ); |
|
822 | + throw new Exception(sprintf(esc_html__('Invalid property: %s', 'give'), $field)); |
|
823 | 823 | } |
824 | 824 | |
825 | 825 | |
@@ -837,12 +837,12 @@ discard block |
||
837 | 837 | * |
838 | 838 | * @return mixed Option value |
839 | 839 | */ |
840 | -function give_get_option( $key = '', $default = false ) { |
|
840 | +function give_get_option($key = '', $default = false) { |
|
841 | 841 | $give_options = give_get_settings(); |
842 | - $value = ! empty( $give_options[ $key ] ) ? $give_options[ $key ] : $default; |
|
843 | - $value = apply_filters( 'give_get_option', $value, $key, $default ); |
|
842 | + $value = ! empty($give_options[$key]) ? $give_options[$key] : $default; |
|
843 | + $value = apply_filters('give_get_option', $value, $key, $default); |
|
844 | 844 | |
845 | - return apply_filters( "give_get_option_{$key}", $value, $key, $default ); |
|
845 | + return apply_filters("give_get_option_{$key}", $value, $key, $default); |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | |
@@ -860,33 +860,33 @@ discard block |
||
860 | 860 | * |
861 | 861 | * @return boolean True if updated, false if not. |
862 | 862 | */ |
863 | -function give_update_option( $key = '', $value = false ) { |
|
863 | +function give_update_option($key = '', $value = false) { |
|
864 | 864 | |
865 | 865 | // If no key, exit |
866 | - if ( empty( $key ) ) { |
|
866 | + if (empty($key)) { |
|
867 | 867 | return false; |
868 | 868 | } |
869 | 869 | |
870 | - if ( empty( $value ) ) { |
|
871 | - $remove_option = give_delete_option( $key ); |
|
870 | + if (empty($value)) { |
|
871 | + $remove_option = give_delete_option($key); |
|
872 | 872 | |
873 | 873 | return $remove_option; |
874 | 874 | } |
875 | 875 | |
876 | 876 | // First let's grab the current settings |
877 | - $options = get_option( 'give_settings' ); |
|
877 | + $options = get_option('give_settings'); |
|
878 | 878 | |
879 | 879 | // Let's let devs alter that value coming in |
880 | - $value = apply_filters( 'give_update_option', $value, $key ); |
|
880 | + $value = apply_filters('give_update_option', $value, $key); |
|
881 | 881 | |
882 | 882 | // Next let's try to update the value |
883 | - $options[ $key ] = $value; |
|
884 | - $did_update = update_option( 'give_settings', $options ); |
|
883 | + $options[$key] = $value; |
|
884 | + $did_update = update_option('give_settings', $options); |
|
885 | 885 | |
886 | 886 | // If it updated, let's update the global variable |
887 | - if ( $did_update ) { |
|
887 | + if ($did_update) { |
|
888 | 888 | global $give_options; |
889 | - $give_options[ $key ] = $value; |
|
889 | + $give_options[$key] = $value; |
|
890 | 890 | } |
891 | 891 | |
892 | 892 | return $did_update; |
@@ -905,27 +905,27 @@ discard block |
||
905 | 905 | * |
906 | 906 | * @return boolean True if updated, false if not. |
907 | 907 | */ |
908 | -function give_delete_option( $key = '' ) { |
|
908 | +function give_delete_option($key = '') { |
|
909 | 909 | |
910 | 910 | // If no key, exit |
911 | - if ( empty( $key ) ) { |
|
911 | + if (empty($key)) { |
|
912 | 912 | return false; |
913 | 913 | } |
914 | 914 | |
915 | 915 | // First let's grab the current settings |
916 | - $options = get_option( 'give_settings' ); |
|
916 | + $options = get_option('give_settings'); |
|
917 | 917 | |
918 | 918 | // Next let's try to update the value |
919 | - if ( isset( $options[ $key ] ) ) { |
|
919 | + if (isset($options[$key])) { |
|
920 | 920 | |
921 | - unset( $options[ $key ] ); |
|
921 | + unset($options[$key]); |
|
922 | 922 | |
923 | 923 | } |
924 | 924 | |
925 | - $did_update = update_option( 'give_settings', $options ); |
|
925 | + $did_update = update_option('give_settings', $options); |
|
926 | 926 | |
927 | 927 | // If it updated, let's update the global variable |
928 | - if ( $did_update ) { |
|
928 | + if ($did_update) { |
|
929 | 929 | global $give_options; |
930 | 930 | $give_options = $options; |
931 | 931 | } |
@@ -944,9 +944,9 @@ discard block |
||
944 | 944 | */ |
945 | 945 | function give_get_settings() { |
946 | 946 | |
947 | - $settings = get_option( 'give_settings' ); |
|
947 | + $settings = get_option('give_settings'); |
|
948 | 948 | |
949 | - return (array) apply_filters( 'give_get_settings', $settings ); |
|
949 | + return (array) apply_filters('give_get_settings', $settings); |
|
950 | 950 | |
951 | 951 | } |
952 | 952 | |
@@ -964,25 +964,25 @@ discard block |
||
964 | 964 | * |
965 | 965 | * @return array |
966 | 966 | */ |
967 | -function give_settings_array_insert( $array, $position, $insert ) { |
|
968 | - if ( is_int( $position ) ) { |
|
969 | - array_splice( $array, $position, 0, $insert ); |
|
967 | +function give_settings_array_insert($array, $position, $insert) { |
|
968 | + if (is_int($position)) { |
|
969 | + array_splice($array, $position, 0, $insert); |
|
970 | 970 | } else { |
971 | 971 | |
972 | - foreach ( $array as $index => $subarray ) { |
|
973 | - if ( isset( $subarray['id'] ) && $subarray['id'] == $position ) { |
|
972 | + foreach ($array as $index => $subarray) { |
|
973 | + if (isset($subarray['id']) && $subarray['id'] == $position) { |
|
974 | 974 | $pos = $index; |
975 | 975 | } |
976 | 976 | } |
977 | 977 | |
978 | - if ( ! isset( $pos ) ) { |
|
978 | + if ( ! isset($pos)) { |
|
979 | 979 | return $array; |
980 | 980 | } |
981 | 981 | |
982 | 982 | $array = array_merge( |
983 | - array_slice( $array, 0, $pos ), |
|
983 | + array_slice($array, 0, $pos), |
|
984 | 984 | $insert, |
985 | - array_slice( $array, $pos ) |
|
985 | + array_slice($array, $pos) |
|
986 | 986 | ); |
987 | 987 | } |
988 | 988 | |
@@ -1000,23 +1000,23 @@ discard block |
||
1000 | 1000 | * @param array $saved_values |
1001 | 1001 | * @return void |
1002 | 1002 | */ |
1003 | -function give_enabled_gateways_callback( $field_arr, $saved_values = array() ) { |
|
1003 | +function give_enabled_gateways_callback($field_arr, $saved_values = array()) { |
|
1004 | 1004 | |
1005 | 1005 | $id = $field_arr['id']; |
1006 | - $gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() ); |
|
1006 | + $gateways = give_get_ordered_payment_gateways(give_get_payment_gateways()); |
|
1007 | 1007 | |
1008 | 1008 | echo '<ul class="give-checklist-fields give-payment-gatways-list">'; |
1009 | 1009 | |
1010 | - foreach ( $gateways as $key => $option ) : |
|
1010 | + foreach ($gateways as $key => $option) : |
|
1011 | 1011 | |
1012 | - if ( is_array( $saved_values ) && array_key_exists( $key, $saved_values ) ) { |
|
1012 | + if (is_array($saved_values) && array_key_exists($key, $saved_values)) { |
|
1013 | 1013 | $enabled = '1'; |
1014 | 1014 | } else { |
1015 | 1015 | $enabled = null; |
1016 | 1016 | } |
1017 | 1017 | |
1018 | - echo '<li><span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span><input name="' . $id . '[' . $key . ']" id="' . $id . '[' . $key . ']" type="checkbox" value="1" ' . checked( '1', $enabled, false ) . '/> '; |
|
1019 | - echo '<label for="' . $id . '[' . $key . ']">' . $option['admin_label'] . '</label></li>'; |
|
1018 | + echo '<li><span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span><input name="'.$id.'['.$key.']" id="'.$id.'['.$key.']" type="checkbox" value="1" '.checked('1', $enabled, false).'/> '; |
|
1019 | + echo '<label for="'.$id.'['.$key.']">'.$option['admin_label'].'</label></li>'; |
|
1020 | 1020 | |
1021 | 1021 | endforeach; |
1022 | 1022 | |
@@ -1033,16 +1033,16 @@ discard block |
||
1033 | 1033 | * @param array $saved_value |
1034 | 1034 | * @return void |
1035 | 1035 | */ |
1036 | -function give_default_gateway_callback( $field_arr, $saved_value ) { |
|
1036 | +function give_default_gateway_callback($field_arr, $saved_value) { |
|
1037 | 1037 | $id = $field_arr['id']; |
1038 | 1038 | $gateways = give_get_enabled_payment_gateways(); |
1039 | - $saved_value = give_get_default_gateway( null ); |
|
1039 | + $saved_value = give_get_default_gateway(null); |
|
1040 | 1040 | |
1041 | - echo '<select class="give-select" name="' . $id . '" id="' . $id . '">'; |
|
1041 | + echo '<select class="give-select" name="'.$id.'" id="'.$id.'">'; |
|
1042 | 1042 | |
1043 | - foreach ( $gateways as $key => $option ) : |
|
1044 | - $selected = isset( $saved_value ) ? selected( $key, $saved_value, false ) : ''; |
|
1045 | - echo '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
1043 | + foreach ($gateways as $key => $option) : |
|
1044 | + $selected = isset($saved_value) ? selected($key, $saved_value, false) : ''; |
|
1045 | + echo '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option['admin_label']).'</option>'; |
|
1046 | 1046 | endforeach; |
1047 | 1047 | |
1048 | 1048 | echo '</select>'; |
@@ -1060,13 +1060,13 @@ discard block |
||
1060 | 1060 | * |
1061 | 1061 | * @return void |
1062 | 1062 | */ |
1063 | -function give_title_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
1063 | +function give_title_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
1064 | 1064 | |
1065 | 1065 | $id = $field_type_object->field->args['id']; |
1066 | 1066 | $title = $field_type_object->field->args['name']; |
1067 | 1067 | $field_description = $field_type_object->field->args['desc']; |
1068 | 1068 | |
1069 | - echo '<hr>' . $field_description; |
|
1069 | + echo '<hr>'.$field_description; |
|
1070 | 1070 | |
1071 | 1071 | } |
1072 | 1072 | |
@@ -1081,7 +1081,7 @@ discard block |
||
1081 | 1081 | * |
1082 | 1082 | * @return void |
1083 | 1083 | */ |
1084 | -function give_description_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
1084 | +function give_description_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
1085 | 1085 | |
1086 | 1086 | $id = $field_type_object->field->args['id']; |
1087 | 1087 | $title = $field_type_object->field->args['name']; |
@@ -1101,25 +1101,25 @@ discard block |
||
1101 | 1101 | * @see: https://github.com/WebDevStudios/CMB2/wiki/Adding-your-own-field-types |
1102 | 1102 | * @return array An array of options that matches the CMB2 options array |
1103 | 1103 | */ |
1104 | -function give_cmb2_get_post_options( $query_args, $force = false ) { |
|
1104 | +function give_cmb2_get_post_options($query_args, $force = false) { |
|
1105 | 1105 | |
1106 | - $post_options = array( '' => '' ); // Blank option |
|
1106 | + $post_options = array('' => ''); // Blank option |
|
1107 | 1107 | |
1108 | - if ( ( ! isset( $_GET['page'] ) || 'give-settings' != $_GET['page'] ) && ! $force ) { |
|
1108 | + if (( ! isset($_GET['page']) || 'give-settings' != $_GET['page']) && ! $force) { |
|
1109 | 1109 | return $post_options; |
1110 | 1110 | } |
1111 | 1111 | |
1112 | - $args = wp_parse_args( $query_args, array( |
|
1112 | + $args = wp_parse_args($query_args, array( |
|
1113 | 1113 | 'post_type' => 'page', |
1114 | 1114 | 'numberposts' => 10, |
1115 | - ) ); |
|
1115 | + )); |
|
1116 | 1116 | |
1117 | - $posts = get_posts( $args ); |
|
1117 | + $posts = get_posts($args); |
|
1118 | 1118 | |
1119 | - if ( $posts ) { |
|
1120 | - foreach ( $posts as $post ) { |
|
1119 | + if ($posts) { |
|
1120 | + foreach ($posts as $post) { |
|
1121 | 1121 | |
1122 | - $post_options[ $post->ID ] = $post->post_title; |
|
1122 | + $post_options[$post->ID] = $post->post_title; |
|
1123 | 1123 | |
1124 | 1124 | } |
1125 | 1125 | } |
@@ -1143,21 +1143,21 @@ discard block |
||
1143 | 1143 | $get_sizes = get_intermediate_image_sizes(); |
1144 | 1144 | |
1145 | 1145 | // check whether intermediate image sizes exist first |
1146 | - if ( empty( $get_sizes ) ) { |
|
1147 | - $get_sizes = array( 'thumbnail', 'medium', 'medium_large', 'large' ); |
|
1146 | + if (empty($get_sizes)) { |
|
1147 | + $get_sizes = array('thumbnail', 'medium', 'medium_large', 'large'); |
|
1148 | 1148 | } |
1149 | 1149 | |
1150 | - foreach ( $get_sizes as $_size ) { |
|
1150 | + foreach ($get_sizes as $_size) { |
|
1151 | 1151 | |
1152 | - if ( in_array( $_size, array( 'thumbnail', 'medium', 'medium_large', 'large' ) ) ) { |
|
1153 | - $sizes[ $_size ] = $_size . ' - ' . get_option( "{$_size}_size_w" ) . 'x' . get_option( "{$_size}_size_h" ); |
|
1154 | - } elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) { |
|
1155 | - $sizes[ $_size ] = $_size . ' - ' . $_wp_additional_image_sizes[ $_size ]['width'] . 'x' . $_wp_additional_image_sizes[ $_size ]['height']; |
|
1152 | + if (in_array($_size, array('thumbnail', 'medium', 'medium_large', 'large'))) { |
|
1153 | + $sizes[$_size] = $_size.' - '.get_option("{$_size}_size_w").'x'.get_option("{$_size}_size_h"); |
|
1154 | + } elseif (isset($_wp_additional_image_sizes[$_size])) { |
|
1155 | + $sizes[$_size] = $_size.' - '.$_wp_additional_image_sizes[$_size]['width'].'x'.$_wp_additional_image_sizes[$_size]['height']; |
|
1156 | 1156 | } |
1157 | 1157 | |
1158 | 1158 | } |
1159 | 1159 | |
1160 | - return apply_filters( 'give_get_featured_image_sizes', $sizes ); |
|
1160 | + return apply_filters('give_get_featured_image_sizes', $sizes); |
|
1161 | 1161 | } |
1162 | 1162 | |
1163 | 1163 | |
@@ -1172,18 +1172,18 @@ discard block |
||
1172 | 1172 | * |
1173 | 1173 | * @return void |
1174 | 1174 | */ |
1175 | -function give_license_key_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
1175 | +function give_license_key_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
1176 | 1176 | /* @var CMB2_Types $field_type_object */ |
1177 | 1177 | |
1178 | 1178 | $id = $field_type_object->field->args['id']; |
1179 | 1179 | $field_description = $field_type_object->field->args['desc']; |
1180 | 1180 | $license = $field_type_object->field->args['options']['license']; |
1181 | 1181 | $license_key = $escaped_value; |
1182 | - $is_license_key = apply_filters( 'give_is_license_key', ( is_object( $license ) && ! empty( $license ) ) ); |
|
1183 | - $is_valid_license = apply_filters( 'give_is_valid_license', ( $is_license_key && property_exists( $license, 'license' ) && 'valid' === $license->license ) ); |
|
1182 | + $is_license_key = apply_filters('give_is_license_key', (is_object($license) && ! empty($license))); |
|
1183 | + $is_valid_license = apply_filters('give_is_valid_license', ($is_license_key && property_exists($license, 'license') && 'valid' === $license->license)); |
|
1184 | 1184 | $shortname = $field_type_object->field->args['options']['shortname']; |
1185 | 1185 | $field_classes = 'regular-text give-license-field'; |
1186 | - $type = empty( $escaped_value ) || ! $is_valid_license ? 'text' : 'password'; |
|
1186 | + $type = empty($escaped_value) || ! $is_valid_license ? 'text' : 'password'; |
|
1187 | 1187 | $custom_html = ''; |
1188 | 1188 | $messages = array(); |
1189 | 1189 | $class = ''; |
@@ -1195,17 +1195,17 @@ discard block |
||
1195 | 1195 | |
1196 | 1196 | // By default query on edd api url will return license object which contain status and message property, this can break below functionality. |
1197 | 1197 | // To combat that check if status is set to error or not, if yes then set $is_license_key to false. |
1198 | - if ( $is_license_key && property_exists( $license, 'status' ) && 'error' === $license->status ) { |
|
1198 | + if ($is_license_key && property_exists($license, 'status') && 'error' === $license->status) { |
|
1199 | 1199 | $is_license_key = false; |
1200 | 1200 | } |
1201 | 1201 | |
1202 | 1202 | |
1203 | 1203 | // Check if current license is part of subscription or not. |
1204 | - $subscriptions = get_option( 'give_subscriptions' ); |
|
1204 | + $subscriptions = get_option('give_subscriptions'); |
|
1205 | 1205 | |
1206 | - if ( $is_license_key && $subscriptions ) { |
|
1207 | - foreach ( $subscriptions as $subscription ) { |
|
1208 | - if ( in_array( $license_key, $subscription['licenses'] ) ) { |
|
1206 | + if ($is_license_key && $subscriptions) { |
|
1207 | + foreach ($subscriptions as $subscription) { |
|
1208 | + if (in_array($license_key, $subscription['licenses'])) { |
|
1209 | 1209 | $is_in_subscription = $subscription['id']; |
1210 | 1210 | break; |
1211 | 1211 | } |
@@ -1213,121 +1213,121 @@ discard block |
||
1213 | 1213 | } |
1214 | 1214 | |
1215 | 1215 | |
1216 | - if ( $is_license_key ) { |
|
1217 | - if ( $is_in_subscription ) { |
|
1218 | - $subscription_expires = strtotime( $subscriptions[ $is_in_subscription ]['expires'] ); |
|
1219 | - $subscription_status = esc_html__( 'renew', 'give' ); |
|
1216 | + if ($is_license_key) { |
|
1217 | + if ($is_in_subscription) { |
|
1218 | + $subscription_expires = strtotime($subscriptions[$is_in_subscription]['expires']); |
|
1219 | + $subscription_status = esc_html__('renew', 'give'); |
|
1220 | 1220 | |
1221 | - if ( ( 'active' !== $subscriptions[ $is_in_subscription ]['status'] ) ) { |
|
1222 | - $subscription_status = esc_html__( 'expire', 'give' ); |
|
1221 | + if (('active' !== $subscriptions[$is_in_subscription]['status'])) { |
|
1222 | + $subscription_status = esc_html__('expire', 'give'); |
|
1223 | 1223 | } |
1224 | 1224 | |
1225 | - if ( $subscription_expires < current_time( 'timestamp', 1 ) ) { |
|
1226 | - $messages[] = sprintf( |
|
1227 | - __( 'Your subscription (<a href="%s" target="_blank">#%d</a>) expired. Please <a href="%s" target="_blank" title="Renew your license key">renew your license key</a>', 'give' ), |
|
1228 | - urldecode( $subscriptions[ $is_in_subscription ]['invoice_url'] ), |
|
1229 | - $subscriptions[ $is_in_subscription ]['payment_id'], |
|
1230 | - $checkout_page_link . '?edd_license_key=' . $subscriptions[ $is_in_subscription ]['license_key'] . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired' |
|
1225 | + if ($subscription_expires < current_time('timestamp', 1)) { |
|
1226 | + $messages[] = sprintf( |
|
1227 | + __('Your subscription (<a href="%s" target="_blank">#%d</a>) expired. Please <a href="%s" target="_blank" title="Renew your license key">renew your license key</a>', 'give'), |
|
1228 | + urldecode($subscriptions[$is_in_subscription]['invoice_url']), |
|
1229 | + $subscriptions[$is_in_subscription]['payment_id'], |
|
1230 | + $checkout_page_link.'?edd_license_key='.$subscriptions[$is_in_subscription]['license_key'].'&utm_campaign=admin&utm_source=licenses&utm_medium=expired' |
|
1231 | 1231 | ); |
1232 | 1232 | $license_status = 'license-expired'; |
1233 | - } elseif ( strtotime( '- 7 days', $subscription_expires ) < current_time( 'timestamp', 1 ) ) { |
|
1233 | + } elseif (strtotime('- 7 days', $subscription_expires) < current_time('timestamp', 1)) { |
|
1234 | 1234 | $messages[] = sprintf( |
1235 | - __( 'Your subscription (<a href="%s" target="_blank">#%d</a>) will %s in %s.', 'give' ), |
|
1236 | - urldecode( $subscriptions[ $is_in_subscription ]['invoice_url'] ), |
|
1237 | - $subscriptions[ $is_in_subscription ]['payment_id'], |
|
1235 | + __('Your subscription (<a href="%s" target="_blank">#%d</a>) will %s in %s.', 'give'), |
|
1236 | + urldecode($subscriptions[$is_in_subscription]['invoice_url']), |
|
1237 | + $subscriptions[$is_in_subscription]['payment_id'], |
|
1238 | 1238 | $subscription_status, |
1239 | - human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscriptions[ $is_in_subscription ]['expires'] ) ) |
|
1239 | + human_time_diff(current_time('timestamp', 1), strtotime($subscriptions[$is_in_subscription]['expires'])) |
|
1240 | 1240 | ); |
1241 | 1241 | $license_status = 'license-expires-soon'; |
1242 | 1242 | } else { |
1243 | 1243 | $messages[] = sprintf( |
1244 | - __( 'Your subscription (<a href="%s" target="_blank">#%d</a>) will %s on %s.', 'give' ), |
|
1245 | - urldecode( $subscriptions[ $is_in_subscription ]['invoice_url'] ), |
|
1246 | - $subscriptions[ $is_in_subscription ]['payment_id'], |
|
1244 | + __('Your subscription (<a href="%s" target="_blank">#%d</a>) will %s on %s.', 'give'), |
|
1245 | + urldecode($subscriptions[$is_in_subscription]['invoice_url']), |
|
1246 | + $subscriptions[$is_in_subscription]['payment_id'], |
|
1247 | 1247 | $subscription_status, |
1248 | - date_i18n( get_option( 'date_format' ), strtotime( $subscriptions[ $is_in_subscription ]['expires'], current_time( 'timestamp' ) ) ) |
|
1248 | + date_i18n(get_option('date_format'), strtotime($subscriptions[$is_in_subscription]['expires'], current_time('timestamp'))) |
|
1249 | 1249 | ); |
1250 | 1250 | $license_status = 'license-expiration-date'; |
1251 | 1251 | } |
1252 | 1252 | |
1253 | 1253 | |
1254 | - } elseif ( empty( $license->success ) && property_exists( $license, 'error' ) ) { |
|
1254 | + } elseif (empty($license->success) && property_exists($license, 'error')) { |
|
1255 | 1255 | |
1256 | 1256 | // activate_license 'invalid' on anything other than valid, so if there was an error capture it |
1257 | - switch( $license->error ) { |
|
1257 | + switch ($license->error) { |
|
1258 | 1258 | case 'expired' : |
1259 | 1259 | $class = $license->error; |
1260 | 1260 | $messages[] = sprintf( |
1261 | - __( 'Your license key expired on %s. Please <a href="%s" target="_blank" title="Renew your license key">renew your license key</a>.', 'give' ), |
|
1262 | - date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), |
|
1263 | - $checkout_page_link . '?edd_license_key=' . $license_key . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired' |
|
1261 | + __('Your license key expired on %s. Please <a href="%s" target="_blank" title="Renew your license key">renew your license key</a>.', 'give'), |
|
1262 | + date_i18n(get_option('date_format'), strtotime($license->expires, current_time('timestamp'))), |
|
1263 | + $checkout_page_link.'?edd_license_key='.$license_key.'&utm_campaign=admin&utm_source=licenses&utm_medium=expired' |
|
1264 | 1264 | ); |
1265 | - $license_status = 'license-' . $class; |
|
1265 | + $license_status = 'license-'.$class; |
|
1266 | 1266 | break; |
1267 | 1267 | |
1268 | 1268 | case 'missing' : |
1269 | 1269 | $class = $license->error; |
1270 | 1270 | $messages[] = sprintf( |
1271 | - __( 'Invalid license. Please <a href="%s" target="_blank" title="Visit account page">visit your account page</a> and verify it.', 'give' ), |
|
1272 | - $account_page_link . '?utm_campaign=admin&utm_source=licenses&utm_medium=missing' |
|
1271 | + __('Invalid license. Please <a href="%s" target="_blank" title="Visit account page">visit your account page</a> and verify it.', 'give'), |
|
1272 | + $account_page_link.'?utm_campaign=admin&utm_source=licenses&utm_medium=missing' |
|
1273 | 1273 | ); |
1274 | - $license_status = 'license-' . $class; |
|
1274 | + $license_status = 'license-'.$class; |
|
1275 | 1275 | break; |
1276 | 1276 | |
1277 | 1277 | case 'invalid' : |
1278 | 1278 | $class = $license->error; |
1279 | 1279 | $messages[] = sprintf( |
1280 | - __( 'Your %s is not active for this URL. Please <a href="%s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'give' ), |
|
1280 | + __('Your %s is not active for this URL. Please <a href="%s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'give'), |
|
1281 | 1281 | $addon_name, |
1282 | - $account_page_link . '?utm_campaign=admin&utm_source=licenses&utm_medium=invalid' |
|
1282 | + $account_page_link.'?utm_campaign=admin&utm_source=licenses&utm_medium=invalid' |
|
1283 | 1283 | ); |
1284 | - $license_status = 'license-' . $class; |
|
1284 | + $license_status = 'license-'.$class; |
|
1285 | 1285 | break; |
1286 | 1286 | |
1287 | 1287 | case 'site_inactive' : |
1288 | 1288 | $class = $license->error; |
1289 | 1289 | $messages[] = sprintf( |
1290 | - __( 'Your %s is not active for this URL. Please <a href="%s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'give' ), |
|
1290 | + __('Your %s is not active for this URL. Please <a href="%s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'give'), |
|
1291 | 1291 | $addon_name, |
1292 | - $account_page_link . '?utm_campaign=admin&utm_source=licenses&utm_medium=invalid' |
|
1292 | + $account_page_link.'?utm_campaign=admin&utm_source=licenses&utm_medium=invalid' |
|
1293 | 1293 | ); |
1294 | - $license_status = 'license-' . $class; |
|
1294 | + $license_status = 'license-'.$class; |
|
1295 | 1295 | break; |
1296 | 1296 | |
1297 | 1297 | case 'item_name_mismatch' : |
1298 | 1298 | $class = $license->error; |
1299 | - $messages[] = sprintf( __( 'This license %s does not belong to %s.', 'give' ), $license_key, $addon_name ); |
|
1300 | - $license_status = 'license-' . $class; |
|
1299 | + $messages[] = sprintf(__('This license %s does not belong to %s.', 'give'), $license_key, $addon_name); |
|
1300 | + $license_status = 'license-'.$class; |
|
1301 | 1301 | break; |
1302 | 1302 | |
1303 | 1303 | case 'no_activations_left': |
1304 | 1304 | $class = $license->error; |
1305 | - $messages[] = sprintf( __( 'Your license key has reached it\'s activation limit. <a href="%s">View possible upgrades</a> now.', 'give' ), $account_page_link ); |
|
1306 | - $license_status = 'license-' . $class; |
|
1305 | + $messages[] = sprintf(__('Your license key has reached it\'s activation limit. <a href="%s">View possible upgrades</a> now.', 'give'), $account_page_link); |
|
1306 | + $license_status = 'license-'.$class; |
|
1307 | 1307 | break; |
1308 | 1308 | } |
1309 | 1309 | } else { |
1310 | - switch ( $license->license ) { |
|
1310 | + switch ($license->license) { |
|
1311 | 1311 | case 'valid' : |
1312 | 1312 | default: |
1313 | 1313 | $class = 'valid'; |
1314 | - $now = current_time( 'timestamp' ); |
|
1315 | - $expiration = strtotime( $license->expires, current_time( 'timestamp' ) ); |
|
1314 | + $now = current_time('timestamp'); |
|
1315 | + $expiration = strtotime($license->expires, current_time('timestamp')); |
|
1316 | 1316 | |
1317 | - if ( 'lifetime' === $license->expires ) { |
|
1318 | - $messages[] = esc_html__( 'License key never expires.', 'give' ); |
|
1317 | + if ('lifetime' === $license->expires) { |
|
1318 | + $messages[] = esc_html__('License key never expires.', 'give'); |
|
1319 | 1319 | $license_status = 'license-lifetime-notice'; |
1320 | - } elseif ( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) { |
|
1320 | + } elseif ($expiration > $now && $expiration - $now < (DAY_IN_SECONDS * 30)) { |
|
1321 | 1321 | $messages[] = sprintf( |
1322 | - __( 'Your license key expires soon! It expires on %s. <a href="%s" target="_blank" title="Renew license">Renew your license key</a>.', 'give' ), |
|
1323 | - date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), |
|
1324 | - $checkout_page_link . '?edd_license_key=' . $value . '&utm_campaign=admin&utm_source=licenses&utm_medium=renew' |
|
1322 | + __('Your license key expires soon! It expires on %s. <a href="%s" target="_blank" title="Renew license">Renew your license key</a>.', 'give'), |
|
1323 | + date_i18n(get_option('date_format'), strtotime($license->expires, current_time('timestamp'))), |
|
1324 | + $checkout_page_link.'?edd_license_key='.$value.'&utm_campaign=admin&utm_source=licenses&utm_medium=renew' |
|
1325 | 1325 | ); |
1326 | 1326 | $license_status = 'license-expires-soon'; |
1327 | 1327 | } else { |
1328 | 1328 | $messages[] = sprintf( |
1329 | - __( 'Your license key expires on %s.', 'give' ), |
|
1330 | - date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ) |
|
1329 | + __('Your license key expires on %s.', 'give'), |
|
1330 | + date_i18n(get_option('date_format'), strtotime($license->expires, current_time('timestamp'))) |
|
1331 | 1331 | ); |
1332 | 1332 | $license_status = 'license-expiration-date'; |
1333 | 1333 | } |
@@ -1335,8 +1335,8 @@ discard block |
||
1335 | 1335 | } |
1336 | 1336 | } |
1337 | 1337 | } else { |
1338 | - $messages[] = sprintf( |
|
1339 | - __( 'To receive updates, please enter your valid %s license key.', 'give' ), |
|
1338 | + $messages[] = sprintf( |
|
1339 | + __('To receive updates, please enter your valid %s license key.', 'give'), |
|
1340 | 1340 | $addon_name |
1341 | 1341 | ); |
1342 | 1342 | $license_status = 'inactive'; |
@@ -1344,7 +1344,7 @@ discard block |
||
1344 | 1344 | |
1345 | 1345 | |
1346 | 1346 | // Add class for input field if license is active. |
1347 | - if ( $is_valid_license ) { |
|
1347 | + if ($is_valid_license) { |
|
1348 | 1348 | $field_classes .= ' give-license-active'; |
1349 | 1349 | } |
1350 | 1350 | |
@@ -1352,35 +1352,35 @@ discard block |
||
1352 | 1352 | $input_field_html = "<input type=\"{$type}\" name=\"{$id}\" class=\"{$field_classes}\" value=\"{$license_key}\">"; |
1353 | 1353 | |
1354 | 1354 | // If license is active so show deactivate button. |
1355 | - if ( $is_valid_license ) { |
|
1355 | + if ($is_valid_license) { |
|
1356 | 1356 | // Get input field html. |
1357 | 1357 | $input_field_html = "<input type=\"{$type}\" name=\"{$id}\" class=\"{$field_classes}\" value=\"{$license_key}\" readonly=\"readonly\">"; |
1358 | 1358 | |
1359 | - $custom_html = '<input type="submit" class="button button-small give-license-deactivate" name="' . $id . '_deactivate" value="' . esc_attr__( 'Deactivate License', 'give' ) . '"/>'; |
|
1359 | + $custom_html = '<input type="submit" class="button button-small give-license-deactivate" name="'.$id.'_deactivate" value="'.esc_attr__('Deactivate License', 'give').'"/>'; |
|
1360 | 1360 | |
1361 | 1361 | |
1362 | 1362 | } |
1363 | 1363 | |
1364 | 1364 | // Field description. |
1365 | - $custom_html .= '<label for="give_settings[' . $id . ']"> ' . $field_description . '</label>'; |
|
1365 | + $custom_html .= '<label for="give_settings['.$id.']"> '.$field_description.'</label>'; |
|
1366 | 1366 | |
1367 | 1367 | // If no messages found then inform user that to get updated in future register yourself. |
1368 | - if ( empty( $messages ) ) { |
|
1369 | - $messages[] = apply_filters( "{$shortname}_default_addon_notice", esc_html__( 'To receive updates, please enter your valid license key.', 'give' ) ); |
|
1368 | + if (empty($messages)) { |
|
1369 | + $messages[] = apply_filters("{$shortname}_default_addon_notice", esc_html__('To receive updates, please enter your valid license key.', 'give')); |
|
1370 | 1370 | } |
1371 | 1371 | |
1372 | - foreach( $messages as $message ) { |
|
1373 | - $custom_html .= '<div class="give-license-status-notice give-' . $license_status . '">'; |
|
1374 | - $custom_html .= '<p>' . $message . '</p>'; |
|
1372 | + foreach ($messages as $message) { |
|
1373 | + $custom_html .= '<div class="give-license-status-notice give-'.$license_status.'">'; |
|
1374 | + $custom_html .= '<p>'.$message.'</p>'; |
|
1375 | 1375 | $custom_html .= '</div>'; |
1376 | 1376 | } |
1377 | 1377 | |
1378 | 1378 | |
1379 | 1379 | // Field html. |
1380 | - $custom_html = apply_filters( 'give_license_key_field_html', $input_field_html . $custom_html, $field_type_object ); |
|
1380 | + $custom_html = apply_filters('give_license_key_field_html', $input_field_html.$custom_html, $field_type_object); |
|
1381 | 1381 | |
1382 | 1382 | // Nonce. |
1383 | - wp_nonce_field( $id . '-nonce', $id . '-nonce' ); |
|
1383 | + wp_nonce_field($id.'-nonce', $id.'-nonce'); |
|
1384 | 1384 | |
1385 | 1385 | // Print field html. |
1386 | 1386 | echo "<div class=\"give-license-key\"><label for=\"{$id}\">{$addon_name }</label></div><div class=\"give-license-block\">{$custom_html}</div>"; |
@@ -1395,7 +1395,7 @@ discard block |
||
1395 | 1395 | */ |
1396 | 1396 | function give_api_callback() { |
1397 | 1397 | |
1398 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
1398 | + if ( ! current_user_can('manage_give_settings')) { |
|
1399 | 1399 | return; |
1400 | 1400 | } |
1401 | 1401 | |
@@ -1404,9 +1404,9 @@ discard block |
||
1404 | 1404 | * |
1405 | 1405 | * @since 1.0 |
1406 | 1406 | */ |
1407 | - do_action( 'give_tools_api_keys_before' ); |
|
1407 | + do_action('give_tools_api_keys_before'); |
|
1408 | 1408 | |
1409 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php'; |
|
1409 | + require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php'; |
|
1410 | 1410 | |
1411 | 1411 | $api_keys_table = new Give_API_Keys_Table(); |
1412 | 1412 | $api_keys_table->prepare_items(); |
@@ -1415,9 +1415,9 @@ discard block |
||
1415 | 1415 | <span class="cmb2-metabox-description api-description"> |
1416 | 1416 | <?php echo sprintf( |
1417 | 1417 | /* translators: 1: http://docs.givewp.com/api 2: http://docs.givewp.com/addon-zapier */ |
1418 | - __( 'You can create API keys for individual users within their profile edit screen. API keys allow users to use the <a href="%1$s" target="_blank">Give REST API</a> to retrieve donation data in JSON or XML for external applications or devices, such as <a href="%2$s" target="_blank">Zapier</a>.', 'give' ), |
|
1419 | - esc_url( 'http://docs.givewp.com/api' ), |
|
1420 | - esc_url( 'http://docs.givewp.com/addon-zapier' ) |
|
1418 | + __('You can create API keys for individual users within their profile edit screen. API keys allow users to use the <a href="%1$s" target="_blank">Give REST API</a> to retrieve donation data in JSON or XML for external applications or devices, such as <a href="%2$s" target="_blank">Zapier</a>.', 'give'), |
|
1419 | + esc_url('http://docs.givewp.com/api'), |
|
1420 | + esc_url('http://docs.givewp.com/addon-zapier') |
|
1421 | 1421 | ); ?> |
1422 | 1422 | </span> |
1423 | 1423 | <?php |
@@ -1427,10 +1427,10 @@ discard block |
||
1427 | 1427 | * |
1428 | 1428 | * @since 1.0 |
1429 | 1429 | */ |
1430 | - do_action( 'give_tools_api_keys_after' ); |
|
1430 | + do_action('give_tools_api_keys_after'); |
|
1431 | 1431 | } |
1432 | 1432 | |
1433 | -add_action( 'give_settings_tab_api_keys', 'give_api_callback' ); |
|
1433 | +add_action('give_settings_tab_api_keys', 'give_api_callback'); |
|
1434 | 1434 | |
1435 | 1435 | /** |
1436 | 1436 | * Hook Callback |
@@ -1443,7 +1443,7 @@ discard block |
||
1443 | 1443 | * |
1444 | 1444 | * @return void |
1445 | 1445 | */ |
1446 | -function give_hook_callback( $args ) { |
|
1446 | +function give_hook_callback($args) { |
|
1447 | 1447 | |
1448 | 1448 | $id = $args['id']; |
1449 | 1449 | |
@@ -1452,7 +1452,7 @@ discard block |
||
1452 | 1452 | * |
1453 | 1453 | * @since 1.0 |
1454 | 1454 | */ |
1455 | - do_action( "give_{$id}" ); |
|
1455 | + do_action("give_{$id}"); |
|
1456 | 1456 | |
1457 | 1457 | } |
1458 | 1458 | |
@@ -1465,19 +1465,19 @@ discard block |
||
1465 | 1465 | * @param string $compare_with |
1466 | 1466 | * @return bool |
1467 | 1467 | */ |
1468 | -function give_is_setting_enabled( $value, $compare_with = null ) { |
|
1469 | - if( ! is_null( $compare_with ) ) { |
|
1468 | +function give_is_setting_enabled($value, $compare_with = null) { |
|
1469 | + if ( ! is_null($compare_with)) { |
|
1470 | 1470 | |
1471 | - if( is_array( $compare_with ) ) { |
|
1471 | + if (is_array($compare_with)) { |
|
1472 | 1472 | // Output. |
1473 | - return in_array( $value, $compare_with ); |
|
1473 | + return in_array($value, $compare_with); |
|
1474 | 1474 | } |
1475 | 1475 | |
1476 | 1476 | // Output. |
1477 | - return ( $value === $compare_with ); |
|
1477 | + return ($value === $compare_with); |
|
1478 | 1478 | } |
1479 | 1479 | |
1480 | 1480 | // Backward compatibility: From version 1.8 most of setting is modified to enabled/disabled |
1481 | 1481 | // Output. |
1482 | - return ( in_array( $value, array( 'enabled', 'on', 'yes' ) ) ? true : false ); |
|
1482 | + return (in_array($value, array('enabled', 'on', 'yes')) ? true : false); |
|
1483 | 1483 | } |
1484 | 1484 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @since 1.0 |
21 | 21 | * @return void |
22 | 22 | */ |
23 | -add_action( 'give_manual_cc_form', '__return_false' ); |
|
23 | +add_action('give_manual_cc_form', '__return_false'); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Processes the donation data and uses the Manual Payment gateway to record |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return void |
34 | 34 | */ |
35 | -function give_manual_payment( $purchase_data ) { |
|
35 | +function give_manual_payment($purchase_data) { |
|
36 | 36 | |
37 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
38 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
37 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
38 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | //Create payment_data array |
42 | 42 | $payment_data = array( |
43 | 43 | 'price' => $purchase_data['price'], |
44 | 44 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
45 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
45 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
46 | 46 | 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
47 | 47 | 'date' => $purchase_data['date'], |
48 | 48 | 'user_email' => $purchase_data['user_email'], |
@@ -52,24 +52,24 @@ discard block |
||
52 | 52 | 'status' => 'pending' |
53 | 53 | ); |
54 | 54 | // Record the pending payment |
55 | - $payment = give_insert_payment( $payment_data ); |
|
55 | + $payment = give_insert_payment($payment_data); |
|
56 | 56 | |
57 | - if ( $payment ) { |
|
58 | - give_update_payment_status( $payment, 'publish' ); |
|
57 | + if ($payment) { |
|
58 | + give_update_payment_status($payment, 'publish'); |
|
59 | 59 | give_send_to_success_page(); |
60 | 60 | } else { |
61 | 61 | give_record_gateway_error( |
62 | - esc_html__( 'Payment Error', 'give' ), |
|
62 | + esc_html__('Payment Error', 'give'), |
|
63 | 63 | sprintf( |
64 | 64 | /* translators: %s: payment data */ |
65 | - esc_html__( 'The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give' ), |
|
66 | - json_encode( $payment_data ) |
|
65 | + esc_html__('The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give'), |
|
66 | + json_encode($payment_data) |
|
67 | 67 | ), |
68 | 68 | $payment |
69 | 69 | ); |
70 | 70 | // If errors are present, send the user back to the donation page so they can be corrected |
71 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
71 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | -add_action( 'give_gateway_manual', 'give_manual_payment' ); |
|
75 | +add_action('give_gateway_manual', 'give_manual_payment'); |
@@ -9,7 +9,7 @@ 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 | |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function __construct() { |
25 | 25 | |
26 | - $this->shortcode['title'] = esc_html__( 'Donation Form Goal', 'give' ); |
|
27 | - $this->shortcode['label'] = esc_html__( 'Donation Form Goal', 'give' ); |
|
26 | + $this->shortcode['title'] = esc_html__('Donation Form Goal', 'give'); |
|
27 | + $this->shortcode['label'] = esc_html__('Donation Form Goal', 'give'); |
|
28 | 28 | |
29 | - parent::__construct( 'give_goal' ); |
|
29 | + parent::__construct('give_goal'); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | |
39 | 39 | $create_form_link = sprintf( |
40 | 40 | /* translators: %s: create new form URL */ |
41 | - __( '<a href="%s">Create</a> a new Donation Form.', 'give' ), |
|
42 | - admin_url( 'post-new.php?post_type=give_forms' ) |
|
41 | + __('<a href="%s">Create</a> a new Donation Form.', 'give'), |
|
42 | + admin_url('post-new.php?post_type=give_forms') |
|
43 | 43 | ); |
44 | 44 | |
45 | 45 | return array( |
@@ -49,35 +49,35 @@ discard block |
||
49 | 49 | 'post_type' => 'give_forms', |
50 | 50 | ), |
51 | 51 | 'name' => 'id', |
52 | - 'tooltip' => esc_attr__( 'Select a Donation Form', 'give' ), |
|
53 | - 'placeholder' => '- ' . esc_attr__( 'Select a Donation Form', 'give' ) . ' -', |
|
52 | + 'tooltip' => esc_attr__('Select a Donation Form', 'give'), |
|
53 | + 'placeholder' => '- '.esc_attr__('Select a Donation Form', 'give').' -', |
|
54 | 54 | 'required' => array( |
55 | - 'alert' => esc_html__( 'You must first select a Form!', 'give' ), |
|
56 | - 'error' => sprintf( '<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__( 'No forms found.', 'give' ), $create_form_link ), |
|
55 | + 'alert' => esc_html__('You must first select a Form!', 'give'), |
|
56 | + 'error' => sprintf('<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__('No forms found.', 'give'), $create_form_link), |
|
57 | 57 | ), |
58 | 58 | ), |
59 | 59 | array( |
60 | 60 | 'type' => 'container', |
61 | - 'html' => sprintf( '<p class="strong margin-top">%s</p>', esc_html__( 'Optional settings', 'give' ) ), |
|
61 | + 'html' => sprintf('<p class="strong margin-top">%s</p>', esc_html__('Optional settings', 'give')), |
|
62 | 62 | ), |
63 | 63 | array( |
64 | 64 | 'type' => 'listbox', |
65 | 65 | 'name' => 'show_text', |
66 | - 'label' => esc_attr__( 'Show Text:', 'give' ), |
|
67 | - 'tooltip' => esc_attr__( 'This text displays the amount of income raised compared to the goal.', 'give' ), |
|
66 | + 'label' => esc_attr__('Show Text:', 'give'), |
|
67 | + 'tooltip' => esc_attr__('This text displays the amount of income raised compared to the goal.', 'give'), |
|
68 | 68 | 'options' => array( |
69 | - 'true' => esc_html__( 'Show', 'give' ), |
|
70 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
69 | + 'true' => esc_html__('Show', 'give'), |
|
70 | + 'false' => esc_html__('Hide', 'give'), |
|
71 | 71 | ), |
72 | 72 | ), |
73 | 73 | array( |
74 | 74 | 'type' => 'listbox', |
75 | 75 | 'name' => 'show_bar', |
76 | - 'label' => esc_attr__( 'Show Progress Bar:', 'give' ), |
|
77 | - 'tooltip' => esc_attr__( 'Do you want to display the goal\'s progress bar?', 'give' ), |
|
76 | + 'label' => esc_attr__('Show Progress Bar:', 'give'), |
|
77 | + 'tooltip' => esc_attr__('Do you want to display the goal\'s progress bar?', 'give'), |
|
78 | 78 | 'options' => array( |
79 | - 'true' => esc_html__( 'Show', 'give' ), |
|
80 | - 'false' => esc_html__( 'Hide', 'give' ), |
|
79 | + 'true' => esc_html__('Show', 'give'), |
|
80 | + 'false' => esc_html__('Hide', 'give'), |
|
81 | 81 | ), |
82 | 82 | ), |
83 | 83 | ); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param $end_date string|bool The end date for which we'd like to filter our sale stats. If false, we'll use the default end date of `this_month` |
37 | 37 | * @param $status string|array The sale status(es) to count. Only valid when retrieving global stats |
38 | 38 | * |
39 | - * @return float|int Total amount of donations based on the passed arguments. |
|
39 | + * @return string Total amount of donations based on the passed arguments. |
|
40 | 40 | */ |
41 | 41 | public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) { |
42 | 42 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @param $end_date string|bool The end date for which we'd like to filter the donations stats. If false, method will use the default end date of `this_month`. |
100 | 100 | * @param $gateway_id string|bool The gateway to get earnings for such as 'paypal' or 'stripe'. |
101 | 101 | * |
102 | - * @return float|int Total amount of donations based on the passed arguments. |
|
102 | + * @return string Total amount of donations based on the passed arguments. |
|
103 | 103 | */ |
104 | 104 | public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
105 | 105 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @param $end_date string|bool The end date for which we'd like to filter our sale stats. If false, we'll use the default end date of `this_month` |
220 | 220 | * @param $gateway_id string|bool The gateway to get earnings for such as 'paypal' or 'stripe' |
221 | 221 | * |
222 | - * @return float|int Total amount of donations based on the passed arguments. |
|
222 | + * @return string Total amount of donations based on the passed arguments. |
|
223 | 223 | */ |
224 | 224 | public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
225 | 225 |
@@ -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 | |
@@ -38,35 +38,35 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return float|int Total amount of donations based on the passed arguments. |
40 | 40 | */ |
41 | - public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) { |
|
41 | + public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish') { |
|
42 | 42 | |
43 | - $this->setup_dates( $start_date, $end_date ); |
|
43 | + $this->setup_dates($start_date, $end_date); |
|
44 | 44 | |
45 | 45 | // Make sure start date is valid |
46 | - if ( is_wp_error( $this->start_date ) ) { |
|
46 | + if (is_wp_error($this->start_date)) { |
|
47 | 47 | return $this->start_date; |
48 | 48 | } |
49 | 49 | |
50 | 50 | // Make sure end date is valid |
51 | - if ( is_wp_error( $this->end_date ) ) { |
|
51 | + if (is_wp_error($this->end_date)) { |
|
52 | 52 | return $this->end_date; |
53 | 53 | } |
54 | 54 | |
55 | - if ( empty( $form_id ) ) { |
|
55 | + if (empty($form_id)) { |
|
56 | 56 | |
57 | 57 | // Global sale stats |
58 | - add_filter( 'give_count_payments_where', array( $this, 'count_where' ) ); |
|
58 | + add_filter('give_count_payments_where', array($this, 'count_where')); |
|
59 | 59 | |
60 | - if ( is_array( $status ) ) { |
|
60 | + if (is_array($status)) { |
|
61 | 61 | $count = 0; |
62 | - foreach ( $status as $payment_status ) { |
|
62 | + foreach ($status as $payment_status) { |
|
63 | 63 | $count += give_count_payments()->$payment_status; |
64 | 64 | } |
65 | 65 | } else { |
66 | 66 | $count = give_count_payments()->$status; |
67 | 67 | } |
68 | 68 | |
69 | - remove_filter( 'give_count_payments_where', array( $this, 'count_where' ) ); |
|
69 | + remove_filter('give_count_payments_where', array($this, 'count_where')); |
|
70 | 70 | |
71 | 71 | } else { |
72 | 72 | |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | // Product specific stats |
76 | 76 | global $give_logs; |
77 | 77 | |
78 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
78 | + add_filter('posts_where', array($this, 'payments_where')); |
|
79 | 79 | |
80 | - $count = $give_logs->get_log_count( $form_id, 'sale' ); |
|
80 | + $count = $give_logs->get_log_count($form_id, 'sale'); |
|
81 | 81 | |
82 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
82 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
83 | 83 | |
84 | 84 | } |
85 | 85 | |
@@ -101,31 +101,31 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return float|int Total amount of donations based on the passed arguments. |
103 | 103 | */ |
104 | - public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
|
104 | + public function get_earnings($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) { |
|
105 | 105 | |
106 | 106 | global $wpdb; |
107 | 107 | |
108 | - $this->setup_dates( $start_date, $end_date ); |
|
108 | + $this->setup_dates($start_date, $end_date); |
|
109 | 109 | |
110 | 110 | // Make sure start date is valid |
111 | - if ( is_wp_error( $this->start_date ) ) { |
|
111 | + if (is_wp_error($this->start_date)) { |
|
112 | 112 | return $this->start_date; |
113 | 113 | } |
114 | 114 | |
115 | 115 | // Make sure end date is valid |
116 | - if ( is_wp_error( $this->end_date ) ) { |
|
116 | + if (is_wp_error($this->end_date)) { |
|
117 | 117 | return $this->end_date; |
118 | 118 | } |
119 | 119 | |
120 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
120 | + add_filter('posts_where', array($this, 'payments_where')); |
|
121 | 121 | |
122 | - if ( empty( $form_id ) ) { |
|
122 | + if (empty($form_id)) { |
|
123 | 123 | |
124 | 124 | // Global earning stats |
125 | 125 | $args = array( |
126 | 126 | 'post_type' => 'give_payment', |
127 | 127 | 'nopaging' => true, |
128 | - 'post_status' => array( 'publish' ), |
|
128 | + 'post_status' => array('publish'), |
|
129 | 129 | 'fields' => 'ids', |
130 | 130 | 'update_post_term_cache' => false, |
131 | 131 | 'suppress_filters' => false, |
@@ -137,24 +137,24 @@ discard block |
||
137 | 137 | ); |
138 | 138 | |
139 | 139 | //Filter by Gateway ID meta_key |
140 | - if ( $gateway_id !== false ) { |
|
140 | + if ($gateway_id !== false) { |
|
141 | 141 | $args['meta_key'] = '_give_payment_gateway'; |
142 | 142 | $args['meta_value'] = $gateway_id; |
143 | 143 | } |
144 | 144 | |
145 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
146 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
147 | - $earnings = get_transient( $key ); |
|
145 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
146 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
147 | + $earnings = get_transient($key); |
|
148 | 148 | |
149 | - if ( false === $earnings ) { |
|
150 | - $sales = get_posts( $args ); |
|
149 | + if (false === $earnings) { |
|
150 | + $sales = get_posts($args); |
|
151 | 151 | $earnings = 0; |
152 | - if ( $sales ) { |
|
153 | - $sales = implode( ',', array_map('intval', $sales ) ); |
|
154 | - $earnings += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})" ); |
|
152 | + if ($sales) { |
|
153 | + $sales = implode(',', array_map('intval', $sales)); |
|
154 | + $earnings += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})"); |
|
155 | 155 | } |
156 | 156 | // Cache the results for one hour |
157 | - set_transient( $key, $earnings, HOUR_IN_SECONDS ); |
|
157 | + set_transient($key, $earnings, HOUR_IN_SECONDS); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | } else { |
@@ -174,37 +174,37 @@ discard block |
||
174 | 174 | 'give_transient_type' => 'give_earnings', |
175 | 175 | // This is not a valid query arg, but is used for cache keying |
176 | 176 | ); |
177 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
178 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
177 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
178 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
179 | 179 | //Set transient for faster stats |
180 | - $earnings = get_transient( $key ); |
|
180 | + $earnings = get_transient($key); |
|
181 | 181 | |
182 | - if ( false === $earnings ) { |
|
182 | + if (false === $earnings) { |
|
183 | 183 | |
184 | 184 | $this->timestamp = false; |
185 | - $log_ids = $give_logs->get_connected_logs( $args, 'sale' ); |
|
185 | + $log_ids = $give_logs->get_connected_logs($args, 'sale'); |
|
186 | 186 | $earnings = 0; |
187 | 187 | |
188 | - if ( $log_ids ) { |
|
189 | - $log_ids = implode( ',', array_map('intval', $log_ids ) ); |
|
190 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);" ); |
|
188 | + if ($log_ids) { |
|
189 | + $log_ids = implode(',', array_map('intval', $log_ids)); |
|
190 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);"); |
|
191 | 191 | |
192 | - foreach ( $payment_ids as $payment_id ) { |
|
193 | - $earnings += give_get_payment_amount( $payment_id ); |
|
192 | + foreach ($payment_ids as $payment_id) { |
|
193 | + $earnings += give_get_payment_amount($payment_id); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | } |
197 | 197 | |
198 | 198 | // Cache the results for one hour |
199 | - set_transient( $key, $earnings, 60 * 60 ); |
|
199 | + set_transient($key, $earnings, 60 * 60); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | 203 | //remove our filter |
204 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
204 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
205 | 205 | |
206 | 206 | //return earnings |
207 | - return round( $earnings, give_currency_decimal_filter() ); |
|
207 | + return round($earnings, give_currency_decimal_filter()); |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | |
@@ -221,29 +221,29 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return float|int Total amount of donations based on the passed arguments. |
223 | 223 | */ |
224 | - public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
|
224 | + public function get_earnings_cache_key($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) { |
|
225 | 225 | |
226 | - $this->setup_dates( $start_date, $end_date ); |
|
226 | + $this->setup_dates($start_date, $end_date); |
|
227 | 227 | |
228 | 228 | // Make sure start date is valid |
229 | - if ( is_wp_error( $this->start_date ) ) { |
|
229 | + if (is_wp_error($this->start_date)) { |
|
230 | 230 | return $this->start_date; |
231 | 231 | } |
232 | 232 | |
233 | 233 | // Make sure end date is valid |
234 | - if ( is_wp_error( $this->end_date ) ) { |
|
234 | + if (is_wp_error($this->end_date)) { |
|
235 | 235 | return $this->end_date; |
236 | 236 | } |
237 | 237 | |
238 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
238 | + add_filter('posts_where', array($this, 'payments_where')); |
|
239 | 239 | |
240 | - if ( empty( $form_id ) ) { |
|
240 | + if (empty($form_id)) { |
|
241 | 241 | |
242 | 242 | // Global earning stats |
243 | 243 | $args = array( |
244 | 244 | 'post_type' => 'give_payment', |
245 | 245 | 'nopaging' => true, |
246 | - 'post_status' => array( 'publish' ), |
|
246 | + 'post_status' => array('publish'), |
|
247 | 247 | 'fields' => 'ids', |
248 | 248 | 'update_post_term_cache' => false, |
249 | 249 | 'suppress_filters' => false, |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | ); |
256 | 256 | |
257 | 257 | //Filter by Gateway ID meta_key |
258 | - if ( $gateway_id !== false ) { |
|
258 | + if ($gateway_id !== false) { |
|
259 | 259 | $args['meta_key'] = '_give_payment_gateway'; |
260 | 260 | $args['meta_value'] = $gateway_id; |
261 | 261 | } |
262 | 262 | |
263 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
264 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
263 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
264 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
265 | 265 | |
266 | 266 | } else { |
267 | 267 | |
@@ -280,12 +280,12 @@ discard block |
||
280 | 280 | 'give_transient_type' => 'give_earnings', |
281 | 281 | // This is not a valid query arg, but is used for cache keying |
282 | 282 | ); |
283 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
284 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
283 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
284 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | //remove our filter |
288 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
288 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
289 | 289 | |
290 | 290 | //return earnings |
291 | 291 | return $key; |
@@ -302,16 +302,16 @@ discard block |
||
302 | 302 | * |
303 | 303 | * @return array Best selling forms |
304 | 304 | */ |
305 | - public function get_best_selling( $number = 10 ) { |
|
305 | + public function get_best_selling($number = 10) { |
|
306 | 306 | |
307 | 307 | global $wpdb; |
308 | 308 | |
309 | - $give_forms = $wpdb->get_results( $wpdb->prepare( |
|
309 | + $give_forms = $wpdb->get_results($wpdb->prepare( |
|
310 | 310 | "SELECT post_id as form_id, max(meta_value) as sales |
311 | 311 | FROM $wpdb->postmeta WHERE meta_key='_give_form_sales' AND meta_value > 0 |
312 | 312 | GROUP BY meta_value+0 |
313 | 313 | DESC LIMIT %d;", $number |
314 | - ) ); |
|
314 | + )); |
|
315 | 315 | |
316 | 316 | return $give_forms; |
317 | 317 | } |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | * and redirect back to the donor interface for feedback |
528 | 528 | * |
529 | 529 | * @since 1.7 |
530 | - * @return bool|null |
|
530 | + * @return false|null |
|
531 | 531 | */ |
532 | 532 | function give_remove_donor_email() { |
533 | 533 | if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | * and redirect back to the donor interface for feedback |
569 | 569 | * |
570 | 570 | * @since 1.7 |
571 | - * @return bool|null |
|
571 | + * @return false|null |
|
572 | 572 | */ |
573 | 573 | function give_set_donor_primary_email() { |
574 | 574 | 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,70 +53,70 @@ 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 | |
72 | 72 | // Record this for later |
73 | 73 | $previous_user_id = $customer->user_id; |
74 | 74 | |
75 | - if ( give_get_errors() ) { |
|
75 | + if (give_get_errors()) { |
|
76 | 76 | return; |
77 | 77 | } |
78 | 78 | |
79 | 79 | // Setup the customer address, if present |
80 | 80 | $address = array(); |
81 | - if ( intval( $customer_info['user_id'] ) > 0 ) { |
|
81 | + if (intval($customer_info['user_id']) > 0) { |
|
82 | 82 | |
83 | - $current_address = get_user_meta( $customer_info['user_id'], '_give_user_address', true ); |
|
83 | + $current_address = get_user_meta($customer_info['user_id'], '_give_user_address', true); |
|
84 | 84 | |
85 | - if ( false === $current_address ) { |
|
86 | - $address['line1'] = isset( $customer_info['line1'] ) ? $customer_info['line1'] : ''; |
|
87 | - $address['line2'] = isset( $customer_info['line2'] ) ? $customer_info['line2'] : ''; |
|
88 | - $address['city'] = isset( $customer_info['city'] ) ? $customer_info['city'] : ''; |
|
89 | - $address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : ''; |
|
90 | - $address['zip'] = isset( $customer_info['zip'] ) ? $customer_info['zip'] : ''; |
|
91 | - $address['state'] = isset( $customer_info['state'] ) ? $customer_info['state'] : ''; |
|
85 | + if (false === $current_address) { |
|
86 | + $address['line1'] = isset($customer_info['line1']) ? $customer_info['line1'] : ''; |
|
87 | + $address['line2'] = isset($customer_info['line2']) ? $customer_info['line2'] : ''; |
|
88 | + $address['city'] = isset($customer_info['city']) ? $customer_info['city'] : ''; |
|
89 | + $address['country'] = isset($customer_info['country']) ? $customer_info['country'] : ''; |
|
90 | + $address['zip'] = isset($customer_info['zip']) ? $customer_info['zip'] : ''; |
|
91 | + $address['state'] = isset($customer_info['state']) ? $customer_info['state'] : ''; |
|
92 | 92 | } else { |
93 | - $current_address = wp_parse_args( $current_address, array( |
|
93 | + $current_address = wp_parse_args($current_address, array( |
|
94 | 94 | 'line1', |
95 | 95 | 'line2', |
96 | 96 | 'city', |
97 | 97 | 'zip', |
98 | 98 | 'state', |
99 | 99 | 'country', |
100 | - ) ); |
|
101 | - $address['line1'] = isset( $customer_info['line1'] ) ? $customer_info['line1'] : $current_address['line1']; |
|
102 | - $address['line2'] = isset( $customer_info['line2'] ) ? $customer_info['line2'] : $current_address['line2']; |
|
103 | - $address['city'] = isset( $customer_info['city'] ) ? $customer_info['city'] : $current_address['city']; |
|
104 | - $address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : $current_address['country']; |
|
105 | - $address['zip'] = isset( $customer_info['zip'] ) ? $customer_info['zip'] : $current_address['zip']; |
|
106 | - $address['state'] = isset( $customer_info['state'] ) ? $customer_info['state'] : $current_address['state']; |
|
100 | + )); |
|
101 | + $address['line1'] = isset($customer_info['line1']) ? $customer_info['line1'] : $current_address['line1']; |
|
102 | + $address['line2'] = isset($customer_info['line2']) ? $customer_info['line2'] : $current_address['line2']; |
|
103 | + $address['city'] = isset($customer_info['city']) ? $customer_info['city'] : $current_address['city']; |
|
104 | + $address['country'] = isset($customer_info['country']) ? $customer_info['country'] : $current_address['country']; |
|
105 | + $address['zip'] = isset($customer_info['zip']) ? $customer_info['zip'] : $current_address['zip']; |
|
106 | + $address['state'] = isset($customer_info['state']) ? $customer_info['state'] : $current_address['state']; |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | 110 | // Sanitize the inputs |
111 | 111 | $customer_data = array(); |
112 | - $customer_data['name'] = strip_tags( stripslashes( $customer_info['name'] ) ); |
|
112 | + $customer_data['name'] = strip_tags(stripslashes($customer_info['name'])); |
|
113 | 113 | $customer_data['user_id'] = $customer_info['user_id']; |
114 | 114 | |
115 | - $customer_data = apply_filters( 'give_edit_customer_info', $customer_data, $customer_id ); |
|
116 | - $address = apply_filters( 'give_edit_customer_address', $address, $customer_id ); |
|
115 | + $customer_data = apply_filters('give_edit_customer_info', $customer_data, $customer_id); |
|
116 | + $address = apply_filters('give_edit_customer_address', $address, $customer_id); |
|
117 | 117 | |
118 | - $customer_data = array_map( 'sanitize_text_field', $customer_data ); |
|
119 | - $address = array_map( 'sanitize_text_field', $address ); |
|
118 | + $customer_data = array_map('sanitize_text_field', $customer_data); |
|
119 | + $address = array_map('sanitize_text_field', $address); |
|
120 | 120 | |
121 | 121 | /** |
122 | 122 | * Fires before editing customer. |
@@ -127,27 +127,27 @@ discard block |
||
127 | 127 | * @param array $customer_data The customer data. |
128 | 128 | * @param array $address The customer address. |
129 | 129 | */ |
130 | - do_action( 'give_pre_edit_customer', $customer_id, $customer_data, $address ); |
|
130 | + do_action('give_pre_edit_customer', $customer_id, $customer_data, $address); |
|
131 | 131 | |
132 | 132 | $output = array(); |
133 | 133 | |
134 | - if ( $customer->update( $customer_data ) ) { |
|
134 | + if ($customer->update($customer_data)) { |
|
135 | 135 | |
136 | - if ( ! empty( $customer->user_id ) && $customer->user_id > 0 ) { |
|
137 | - update_user_meta( $customer->user_id, '_give_user_address', $address ); |
|
136 | + if ( ! empty($customer->user_id) && $customer->user_id > 0) { |
|
137 | + update_user_meta($customer->user_id, '_give_user_address', $address); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | // Update some donation meta if we need to |
141 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
141 | + $payments_array = explode(',', $customer->payment_ids); |
|
142 | 142 | |
143 | - if ( $customer->user_id != $previous_user_id ) { |
|
144 | - foreach ( $payments_array as $payment_id ) { |
|
145 | - give_update_payment_meta( $payment_id, '_give_payment_user_id', $customer->user_id ); |
|
143 | + if ($customer->user_id != $previous_user_id) { |
|
144 | + foreach ($payments_array as $payment_id) { |
|
145 | + give_update_payment_meta($payment_id, '_give_payment_user_id', $customer->user_id); |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | 149 | $output['success'] = true; |
150 | - $customer_data = array_merge( $customer_data, $address ); |
|
150 | + $customer_data = array_merge($customer_data, $address); |
|
151 | 151 | $output['customer_info'] = $customer_data; |
152 | 152 | |
153 | 153 | } else { |
@@ -164,11 +164,11 @@ discard block |
||
164 | 164 | * @param int $customer_id The ID of the customer. |
165 | 165 | * @param array $customer_data The customer data. |
166 | 166 | */ |
167 | - do_action( 'give_post_edit_customer', $customer_id, $customer_data ); |
|
167 | + do_action('give_post_edit_customer', $customer_id, $customer_data); |
|
168 | 168 | |
169 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
170 | - header( 'Content-Type: application/json' ); |
|
171 | - echo json_encode( $output ); |
|
169 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
170 | + header('Content-Type: application/json'); |
|
171 | + echo json_encode($output); |
|
172 | 172 | wp_die(); |
173 | 173 | } |
174 | 174 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | } |
178 | 178 | |
179 | -add_action( 'give_edit-customer', 'give_edit_customer', 10, 1 ); |
|
179 | +add_action('give_edit-customer', 'give_edit_customer', 10, 1); |
|
180 | 180 | |
181 | 181 | /** |
182 | 182 | * Save a customer note being added |
@@ -187,36 +187,36 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return int The Note ID that was saved, or 0 if nothing was saved |
189 | 189 | */ |
190 | -function give_customer_save_note( $args ) { |
|
190 | +function give_customer_save_note($args) { |
|
191 | 191 | |
192 | - $customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' ); |
|
192 | + $customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports'); |
|
193 | 193 | |
194 | - if ( ! is_admin() || ! current_user_can( $customer_view_role ) ) { |
|
195 | - wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
194 | + if ( ! is_admin() || ! current_user_can($customer_view_role)) { |
|
195 | + wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
196 | 196 | } |
197 | 197 | |
198 | - if ( empty( $args ) ) { |
|
198 | + if (empty($args)) { |
|
199 | 199 | return; |
200 | 200 | } |
201 | 201 | |
202 | - $customer_note = trim( sanitize_text_field( $args['customer_note'] ) ); |
|
202 | + $customer_note = trim(sanitize_text_field($args['customer_note'])); |
|
203 | 203 | $customer_id = (int) $args['customer_id']; |
204 | 204 | $nonce = $args['add_customer_note_nonce']; |
205 | 205 | |
206 | - if ( ! wp_verify_nonce( $nonce, 'add-customer-note' ) ) { |
|
207 | - wp_die( esc_html__( 'Cheatin’ uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
206 | + if ( ! wp_verify_nonce($nonce, 'add-customer-note')) { |
|
207 | + wp_die(esc_html__('Cheatin’ uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
208 | 208 | } |
209 | 209 | |
210 | - if ( empty( $customer_note ) ) { |
|
211 | - give_set_error( 'empty-customer-note', esc_html__( 'A note is required.', 'give' ) ); |
|
210 | + if (empty($customer_note)) { |
|
211 | + give_set_error('empty-customer-note', esc_html__('A note is required.', 'give')); |
|
212 | 212 | } |
213 | 213 | |
214 | - if ( give_get_errors() ) { |
|
214 | + if (give_get_errors()) { |
|
215 | 215 | return; |
216 | 216 | } |
217 | 217 | |
218 | - $customer = new Give_Customer( $customer_id ); |
|
219 | - $new_note = $customer->add_note( $customer_note ); |
|
218 | + $customer = new Give_Customer($customer_id); |
|
219 | + $new_note = $customer->add_note($customer_note); |
|
220 | 220 | |
221 | 221 | /** |
222 | 222 | * Fires before inserting customer note. |
@@ -226,22 +226,22 @@ discard block |
||
226 | 226 | * @param int $customer_id The ID of the customer. |
227 | 227 | * @param string $new_note Note content. |
228 | 228 | */ |
229 | - do_action( 'give_pre_insert_customer_note', $customer_id, $new_note ); |
|
229 | + do_action('give_pre_insert_customer_note', $customer_id, $new_note); |
|
230 | 230 | |
231 | - if ( ! empty( $new_note ) && ! empty( $customer->id ) ) { |
|
231 | + if ( ! empty($new_note) && ! empty($customer->id)) { |
|
232 | 232 | |
233 | 233 | ob_start(); |
234 | 234 | ?> |
235 | 235 | <div class="customer-note-wrapper dashboard-comment-wrap comment-item"> |
236 | 236 | <span class="note-content-wrap"> |
237 | - <?php echo stripslashes( $new_note ); ?> |
|
237 | + <?php echo stripslashes($new_note); ?> |
|
238 | 238 | </span> |
239 | 239 | </div> |
240 | 240 | <?php |
241 | 241 | $output = ob_get_contents(); |
242 | 242 | ob_end_clean(); |
243 | 243 | |
244 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
244 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
245 | 245 | echo $output; |
246 | 246 | exit; |
247 | 247 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | |
255 | 255 | } |
256 | 256 | |
257 | -add_action( 'give_add-customer-note', 'give_customer_save_note', 10, 1 ); |
|
257 | +add_action('give_add-customer-note', 'give_customer_save_note', 10, 1); |
|
258 | 258 | |
259 | 259 | /** |
260 | 260 | * Delete a customer |
@@ -265,37 +265,37 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @return int Whether it was a successful deletion |
267 | 267 | */ |
268 | -function give_customer_delete( $args ) { |
|
268 | +function give_customer_delete($args) { |
|
269 | 269 | |
270 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
270 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
271 | 271 | |
272 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
273 | - wp_die( esc_html__( 'You do not have permission to delete donors.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
272 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
273 | + wp_die(esc_html__('You do not have permission to delete donors.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
274 | 274 | } |
275 | 275 | |
276 | - if ( empty( $args ) ) { |
|
276 | + if (empty($args)) { |
|
277 | 277 | return; |
278 | 278 | } |
279 | 279 | |
280 | 280 | $customer_id = (int) $args['customer_id']; |
281 | - $confirm = ! empty( $args['give-customer-delete-confirm'] ) ? true : false; |
|
282 | - $remove_data = ! empty( $args['give-customer-delete-records'] ) ? true : false; |
|
281 | + $confirm = ! empty($args['give-customer-delete-confirm']) ? true : false; |
|
282 | + $remove_data = ! empty($args['give-customer-delete-records']) ? true : false; |
|
283 | 283 | $nonce = $args['_wpnonce']; |
284 | 284 | |
285 | - if ( ! wp_verify_nonce( $nonce, 'delete-customer' ) ) { |
|
286 | - wp_die( esc_html__( 'Cheatin’ uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
285 | + if ( ! wp_verify_nonce($nonce, 'delete-customer')) { |
|
286 | + wp_die(esc_html__('Cheatin’ uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
287 | 287 | } |
288 | 288 | |
289 | - if ( ! $confirm ) { |
|
290 | - give_set_error( 'customer-delete-no-confirm', esc_html__( 'Please confirm you want to delete this donor.', 'give' ) ); |
|
289 | + if ( ! $confirm) { |
|
290 | + give_set_error('customer-delete-no-confirm', esc_html__('Please confirm you want to delete this donor.', 'give')); |
|
291 | 291 | } |
292 | 292 | |
293 | - if ( give_get_errors() ) { |
|
294 | - wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id ) ); |
|
293 | + if (give_get_errors()) { |
|
294 | + wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer_id)); |
|
295 | 295 | exit; |
296 | 296 | } |
297 | 297 | |
298 | - $customer = new Give_Customer( $customer_id ); |
|
298 | + $customer = new Give_Customer($customer_id); |
|
299 | 299 | |
300 | 300 | /** |
301 | 301 | * Fires before deleting customer. |
@@ -306,50 +306,50 @@ discard block |
||
306 | 306 | * @param bool $confirm Delete confirmation. |
307 | 307 | * @param bool $remove_data Records delete confirmation. |
308 | 308 | */ |
309 | - do_action( 'give_pre_delete_customer', $customer_id, $confirm, $remove_data ); |
|
309 | + do_action('give_pre_delete_customer', $customer_id, $confirm, $remove_data); |
|
310 | 310 | |
311 | - if ( $customer->id > 0 ) { |
|
311 | + if ($customer->id > 0) { |
|
312 | 312 | |
313 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
314 | - $success = Give()->customers->delete( $customer->id ); |
|
313 | + $payments_array = explode(',', $customer->payment_ids); |
|
314 | + $success = Give()->customers->delete($customer->id); |
|
315 | 315 | |
316 | - if ( $success ) { |
|
316 | + if ($success) { |
|
317 | 317 | |
318 | - if ( $remove_data ) { |
|
318 | + if ($remove_data) { |
|
319 | 319 | |
320 | 320 | // Remove all donations, logs, etc |
321 | - foreach ( $payments_array as $payment_id ) { |
|
322 | - give_delete_purchase( $payment_id ); |
|
321 | + foreach ($payments_array as $payment_id) { |
|
322 | + give_delete_purchase($payment_id); |
|
323 | 323 | } |
324 | 324 | } else { |
325 | 325 | |
326 | 326 | // Just set the donations to customer_id of 0 |
327 | - foreach ( $payments_array as $payment_id ) { |
|
328 | - give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 ); |
|
327 | + foreach ($payments_array as $payment_id) { |
|
328 | + give_update_payment_meta($payment_id, '_give_payment_customer_id', 0); |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | |
332 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted' ); |
|
332 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted'); |
|
333 | 333 | |
334 | 334 | } else { |
335 | 335 | |
336 | - give_set_error( 'give-donor-delete-failed', esc_html__( 'Error deleting donor.', 'give' ) ); |
|
337 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer_id ); |
|
336 | + give_set_error('give-donor-delete-failed', esc_html__('Error deleting donor.', 'give')); |
|
337 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$customer_id); |
|
338 | 338 | |
339 | 339 | } |
340 | 340 | } else { |
341 | 341 | |
342 | - give_set_error( 'give-customer-delete-invalid-id', esc_html__( 'Invalid Donor ID.', 'give' ) ); |
|
343 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); |
|
342 | + give_set_error('give-customer-delete-invalid-id', esc_html__('Invalid Donor ID.', 'give')); |
|
343 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors'); |
|
344 | 344 | |
345 | 345 | } |
346 | 346 | |
347 | - wp_redirect( $redirect ); |
|
347 | + wp_redirect($redirect); |
|
348 | 348 | exit; |
349 | 349 | |
350 | 350 | } |
351 | 351 | |
352 | -add_action( 'give_delete-customer', 'give_customer_delete', 10, 1 ); |
|
352 | +add_action('give_delete-customer', 'give_customer_delete', 10, 1); |
|
353 | 353 | |
354 | 354 | /** |
355 | 355 | * Disconnect a user ID from a donor |
@@ -360,27 +360,27 @@ discard block |
||
360 | 360 | * |
361 | 361 | * @return bool If the disconnect was successful |
362 | 362 | */ |
363 | -function give_disconnect_customer_user_id( $args ) { |
|
363 | +function give_disconnect_customer_user_id($args) { |
|
364 | 364 | |
365 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
365 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
366 | 366 | |
367 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
368 | - wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
367 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
368 | + wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
369 | 369 | } |
370 | 370 | |
371 | - if ( empty( $args ) ) { |
|
371 | + if (empty($args)) { |
|
372 | 372 | return; |
373 | 373 | } |
374 | 374 | |
375 | 375 | $customer_id = (int) $args['customer_id']; |
376 | 376 | $nonce = $args['_wpnonce']; |
377 | 377 | |
378 | - if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) { |
|
379 | - wp_die( esc_html__( 'Cheatin’ uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
378 | + if ( ! wp_verify_nonce($nonce, 'edit-customer')) { |
|
379 | + wp_die(esc_html__('Cheatin’ uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
380 | 380 | } |
381 | 381 | |
382 | - $customer = new Give_Customer( $customer_id ); |
|
383 | - if ( empty( $customer->id ) ) { |
|
382 | + $customer = new Give_Customer($customer_id); |
|
383 | + if (empty($customer->id)) { |
|
384 | 384 | return false; |
385 | 385 | } |
386 | 386 | |
@@ -394,16 +394,16 @@ discard block |
||
394 | 394 | * @param int $customer_id The ID of the customer. |
395 | 395 | * @param int $user_id The ID of the user. |
396 | 396 | */ |
397 | - do_action( 'give_pre_customer_disconnect_user_id', $customer_id, $user_id ); |
|
397 | + do_action('give_pre_customer_disconnect_user_id', $customer_id, $user_id); |
|
398 | 398 | |
399 | 399 | $output = array(); |
400 | - $customer_args = array( 'user_id' => 0 ); |
|
400 | + $customer_args = array('user_id' => 0); |
|
401 | 401 | |
402 | - if ( $customer->update( $customer_args ) ) { |
|
402 | + if ($customer->update($customer_args)) { |
|
403 | 403 | global $wpdb; |
404 | 404 | |
405 | - if ( ! empty( $customer->payment_ids ) ) { |
|
406 | - $wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )" ); |
|
405 | + if ( ! empty($customer->payment_ids)) { |
|
406 | + $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )"); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | $output['success'] = true; |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | } else { |
412 | 412 | |
413 | 413 | $output['success'] = false; |
414 | - give_set_error( 'give-disconnect-user-fail', esc_html__( 'Failed to disconnect user from donor.', 'give' ) ); |
|
414 | + give_set_error('give-disconnect-user-fail', esc_html__('Failed to disconnect user from donor.', 'give')); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | /** |
@@ -421,11 +421,11 @@ discard block |
||
421 | 421 | * |
422 | 422 | * @param int $customer_id The ID of the customer. |
423 | 423 | */ |
424 | - do_action( 'give_post_customer_disconnect_user_id', $customer_id ); |
|
424 | + do_action('give_post_customer_disconnect_user_id', $customer_id); |
|
425 | 425 | |
426 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
427 | - header( 'Content-Type: application/json' ); |
|
428 | - echo json_encode( $output ); |
|
426 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
427 | + header('Content-Type: application/json'); |
|
428 | + echo json_encode($output); |
|
429 | 429 | wp_die(); |
430 | 430 | } |
431 | 431 | |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | |
434 | 434 | } |
435 | 435 | |
436 | -add_action( 'give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1 ); |
|
436 | +add_action('give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1); |
|
437 | 437 | |
438 | 438 | /** |
439 | 439 | * Add an email address to the donor from within the admin and log a donor note |
@@ -444,82 +444,82 @@ discard block |
||
444 | 444 | * |
445 | 445 | * @return mixed If DOING_AJAX echos out JSON, otherwise returns array of success (bool) and message (string) |
446 | 446 | */ |
447 | -function give_add_donor_email( $args ) { |
|
448 | - $customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' ); |
|
447 | +function give_add_donor_email($args) { |
|
448 | + $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); |
|
449 | 449 | |
450 | - if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) { |
|
451 | - wp_die( esc_html__( 'You do not have permission to edit this donor.', 'edit' ) ); |
|
450 | + if ( ! is_admin() || ! current_user_can($customer_edit_role)) { |
|
451 | + wp_die(esc_html__('You do not have permission to edit this donor.', 'edit')); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | $output = array(); |
455 | - if ( empty( $args ) || empty( $args['email'] ) || empty( $args['customer_id'] ) ) { |
|
455 | + if (empty($args) || empty($args['email']) || empty($args['customer_id'])) { |
|
456 | 456 | $output['success'] = false; |
457 | - if ( empty( $args['email'] ) ) { |
|
458 | - $output['message'] = esc_html__( 'Email address is required.', 'give' ); |
|
459 | - } elseif ( empty( $args['customer_id'] ) ) { |
|
460 | - $output['message'] = esc_html__( 'Customer ID is required.', 'give' ); |
|
457 | + if (empty($args['email'])) { |
|
458 | + $output['message'] = esc_html__('Email address is required.', 'give'); |
|
459 | + } elseif (empty($args['customer_id'])) { |
|
460 | + $output['message'] = esc_html__('Customer ID is required.', 'give'); |
|
461 | 461 | } else { |
462 | - $output['message'] = esc_html__( 'An error has occurred. Please try again.', 'give' ); |
|
462 | + $output['message'] = esc_html__('An error has occurred. Please try again.', 'give'); |
|
463 | 463 | } |
464 | - } elseif ( ! wp_verify_nonce( $args['_wpnonce'], 'give_add_donor_email' ) ) { |
|
464 | + } elseif ( ! wp_verify_nonce($args['_wpnonce'], 'give_add_donor_email')) { |
|
465 | 465 | $output = array( |
466 | 466 | 'success' => false, |
467 | - 'message' => esc_html__( 'Nonce verification failed.', 'give' ), |
|
467 | + 'message' => esc_html__('Nonce verification failed.', 'give'), |
|
468 | 468 | ); |
469 | - } elseif ( ! is_email( $args['email'] ) ) { |
|
469 | + } elseif ( ! is_email($args['email'])) { |
|
470 | 470 | $output = array( |
471 | 471 | 'success' => false, |
472 | - 'message' => esc_html__( 'Invalid email.', 'give' ), |
|
472 | + 'message' => esc_html__('Invalid email.', 'give'), |
|
473 | 473 | ); |
474 | 474 | } else { |
475 | - $email = sanitize_email( $args['email'] ); |
|
475 | + $email = sanitize_email($args['email']); |
|
476 | 476 | $customer_id = (int) $args['customer_id']; |
477 | 477 | $primary = 'true' === $args['primary'] ? true : false; |
478 | - $customer = new Give_Customer( $customer_id ); |
|
479 | - if ( false === $customer->add_email( $email, $primary ) ) { |
|
480 | - if ( in_array( $email, $customer->emails ) ) { |
|
478 | + $customer = new Give_Customer($customer_id); |
|
479 | + if (false === $customer->add_email($email, $primary)) { |
|
480 | + if (in_array($email, $customer->emails)) { |
|
481 | 481 | $output = array( |
482 | 482 | 'success' => false, |
483 | - 'message' => esc_html__( 'Email already associated with this donor.', 'give' ), |
|
483 | + 'message' => esc_html__('Email already associated with this donor.', 'give'), |
|
484 | 484 | ); |
485 | 485 | } else { |
486 | 486 | $output = array( |
487 | 487 | 'success' => false, |
488 | - 'message' => esc_html__( 'Email address is already associated with another donor.', 'give' ), |
|
488 | + 'message' => esc_html__('Email address is already associated with another donor.', 'give'), |
|
489 | 489 | ); |
490 | 490 | } |
491 | 491 | } else { |
492 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id . '&give-message=email-added' ); |
|
492 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer_id.'&give-message=email-added'); |
|
493 | 493 | $output = array( |
494 | 494 | 'success' => true, |
495 | - 'message' => esc_html__( 'Email successfully added to donor.', 'give' ), |
|
495 | + 'message' => esc_html__('Email successfully added to donor.', 'give'), |
|
496 | 496 | 'redirect' => $redirect, |
497 | 497 | ); |
498 | 498 | |
499 | 499 | $user = wp_get_current_user(); |
500 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' ); |
|
501 | - $customer_note = sprintf( __( 'Email address %1$s added by %2$s', 'give' ), $email, $user_login ); |
|
502 | - $customer->add_note( $customer_note ); |
|
500 | + $user_login = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give'); |
|
501 | + $customer_note = sprintf(__('Email address %1$s added by %2$s', 'give'), $email, $user_login); |
|
502 | + $customer->add_note($customer_note); |
|
503 | 503 | |
504 | - if ( $primary ) { |
|
505 | - $customer_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $email, $user_login ); |
|
506 | - $customer->add_note( $customer_note ); |
|
504 | + if ($primary) { |
|
505 | + $customer_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $email, $user_login); |
|
506 | + $customer->add_note($customer_note); |
|
507 | 507 | } |
508 | 508 | } |
509 | 509 | } |
510 | 510 | |
511 | - do_action( 'give_post_add_customer_email', $customer_id, $args ); |
|
511 | + do_action('give_post_add_customer_email', $customer_id, $args); |
|
512 | 512 | |
513 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
514 | - header( 'Content-Type: application/json' ); |
|
515 | - echo json_encode( $output ); |
|
513 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
514 | + header('Content-Type: application/json'); |
|
515 | + echo json_encode($output); |
|
516 | 516 | wp_die(); |
517 | 517 | } |
518 | 518 | |
519 | 519 | return $output; |
520 | 520 | } |
521 | 521 | |
522 | -add_action( 'give_add_donor_email', 'give_add_donor_email', 10, 1 ); |
|
522 | +add_action('give_add_donor_email', 'give_add_donor_email', 10, 1); |
|
523 | 523 | |
524 | 524 | |
525 | 525 | /** |
@@ -530,37 +530,37 @@ discard block |
||
530 | 530 | * @return bool|null |
531 | 531 | */ |
532 | 532 | function give_remove_donor_email() { |
533 | - if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
533 | + if (empty($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
534 | 534 | return false; |
535 | 535 | } |
536 | - if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) { |
|
536 | + if (empty($_GET['email']) || ! is_email($_GET['email'])) { |
|
537 | 537 | return false; |
538 | 538 | } |
539 | - if ( empty( $_GET['_wpnonce'] ) ) { |
|
539 | + if (empty($_GET['_wpnonce'])) { |
|
540 | 540 | return false; |
541 | 541 | } |
542 | 542 | |
543 | 543 | $nonce = $_GET['_wpnonce']; |
544 | - if ( ! wp_verify_nonce( $nonce, 'give-remove-donor-email' ) ) { |
|
545 | - wp_die( esc_html__( 'Nonce verification failed', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
544 | + if ( ! wp_verify_nonce($nonce, 'give-remove-donor-email')) { |
|
545 | + wp_die(esc_html__('Nonce verification failed', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
546 | 546 | } |
547 | 547 | |
548 | - $customer = new Give_Customer( $_GET['id'] ); |
|
549 | - if ( $customer->remove_email( $_GET['email'] ) ) { |
|
550 | - $url = add_query_arg( 'give-message', 'email-removed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ) ); |
|
548 | + $customer = new Give_Customer($_GET['id']); |
|
549 | + if ($customer->remove_email($_GET['email'])) { |
|
550 | + $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 | 551 | $user = wp_get_current_user(); |
552 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' ); |
|
553 | - $customer_note = sprintf( __( 'Email address %1$s removed by %2$s', 'give' ), $_GET['email'], $user_login ); |
|
554 | - $customer->add_note( $customer_note ); |
|
552 | + $user_login = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give'); |
|
553 | + $customer_note = sprintf(__('Email address %1$s removed by %2$s', 'give'), $_GET['email'], $user_login); |
|
554 | + $customer->add_note($customer_note); |
|
555 | 555 | } else { |
556 | - $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 ) ); |
|
556 | + $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)); |
|
557 | 557 | } |
558 | 558 | |
559 | - wp_safe_redirect( $url ); |
|
559 | + wp_safe_redirect($url); |
|
560 | 560 | exit; |
561 | 561 | } |
562 | 562 | |
563 | -add_action( 'give_remove_donor_email', 'give_remove_donor_email', 10 ); |
|
563 | +add_action('give_remove_donor_email', 'give_remove_donor_email', 10); |
|
564 | 564 | |
565 | 565 | |
566 | 566 | /** |
@@ -571,39 +571,39 @@ discard block |
||
571 | 571 | * @return bool|null |
572 | 572 | */ |
573 | 573 | function give_set_donor_primary_email() { |
574 | - if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
574 | + if (empty($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
575 | 575 | return false; |
576 | 576 | } |
577 | 577 | |
578 | - if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) { |
|
578 | + if (empty($_GET['email']) || ! is_email($_GET['email'])) { |
|
579 | 579 | return false; |
580 | 580 | } |
581 | 581 | |
582 | - if ( empty( $_GET['_wpnonce'] ) ) { |
|
582 | + if (empty($_GET['_wpnonce'])) { |
|
583 | 583 | return false; |
584 | 584 | } |
585 | 585 | |
586 | 586 | $nonce = $_GET['_wpnonce']; |
587 | 587 | |
588 | - if ( ! wp_verify_nonce( $nonce, 'give-set-donor-primary-email' ) ) { |
|
589 | - wp_die( esc_html__( 'Nonce verification failed', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
588 | + if ( ! wp_verify_nonce($nonce, 'give-set-donor-primary-email')) { |
|
589 | + wp_die(esc_html__('Nonce verification failed', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
590 | 590 | } |
591 | 591 | |
592 | - $donor = new Give_Customer( $_GET['id'] ); |
|
592 | + $donor = new Give_Customer($_GET['id']); |
|
593 | 593 | |
594 | - if ( $donor->set_primary_email( $_GET['email'] ) ) { |
|
595 | - $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 ) ); |
|
594 | + if ($donor->set_primary_email($_GET['email'])) { |
|
595 | + $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 | 596 | $user = wp_get_current_user(); |
597 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' ); |
|
598 | - $donor_note = sprintf( __( 'Email address %1$s set as primary by %1$s', 'give' ), $_GET['email'], $user_login ); |
|
597 | + $user_login = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give'); |
|
598 | + $donor_note = sprintf(__('Email address %1$s set as primary by %1$s', 'give'), $_GET['email'], $user_login); |
|
599 | 599 | |
600 | - $donor->add_note( $donor_note ); |
|
600 | + $donor->add_note($donor_note); |
|
601 | 601 | } else { |
602 | - $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 ) ); |
|
602 | + $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)); |
|
603 | 603 | } |
604 | 604 | |
605 | - wp_safe_redirect( $url ); |
|
605 | + wp_safe_redirect($url); |
|
606 | 606 | exit; |
607 | 607 | } |
608 | 608 | |
609 | -add_action( 'give_set_donor_primary_email', 'give_set_donor_primary_email', 10 ); |
|
609 | +add_action('give_set_donor_primary_email', 'give_set_donor_primary_email', 10); |
@@ -157,7 +157,7 @@ |
||
157 | 157 | * |
158 | 158 | * @access public |
159 | 159 | * @since 1.0 |
160 | - * @return string|bool String if search is present, false otherwise |
|
160 | + * @return string|false String if search is present, false otherwise |
|
161 | 161 | */ |
162 | 162 | public function get_search() { |
163 | 163 | return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | 17 | // Load WP_List_Table if not loaded |
18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
18 | +if ( ! class_exists('WP_List_Table')) { |
|
19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | global $status, $page; |
46 | 46 | |
47 | 47 | // Set parent defaults |
48 | - parent::__construct( array( |
|
49 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
51 | - 'ajax' => false,// Does this table support ajax? |
|
52 | - ) ); |
|
48 | + parent::__construct(array( |
|
49 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
51 | + 'ajax' => false, // Does this table support ajax? |
|
52 | + )); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -63,20 +63,20 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return void |
65 | 65 | */ |
66 | - public function search_box( $text, $input_id ) { |
|
67 | - $input_id = $input_id . '-search-input'; |
|
66 | + public function search_box($text, $input_id) { |
|
67 | + $input_id = $input_id.'-search-input'; |
|
68 | 68 | |
69 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
70 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
69 | + if ( ! empty($_REQUEST['orderby'])) { |
|
70 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
71 | 71 | } |
72 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
73 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
72 | + if ( ! empty($_REQUEST['order'])) { |
|
73 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
74 | 74 | } |
75 | 75 | ?> |
76 | 76 | <p class="search-box" role="search"> |
77 | 77 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
78 | 78 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/> |
79 | - <?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?> |
|
79 | + <?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?> |
|
80 | 80 | </p> |
81 | 81 | <?php |
82 | 82 | } |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function get_columns() { |
92 | 92 | $columns = array( |
93 | - 'ID' => esc_html__( 'Log ID', 'give' ), |
|
94 | - 'details' => esc_html__( 'Request Details', 'give' ), |
|
95 | - 'ip' => esc_html__( 'Request IP', 'give' ), |
|
96 | - 'date' => esc_html__( 'Date', 'give' ), |
|
93 | + 'ID' => esc_html__('Log ID', 'give'), |
|
94 | + 'details' => esc_html__('Request Details', 'give'), |
|
95 | + 'ip' => esc_html__('Request IP', 'give'), |
|
96 | + 'date' => esc_html__('Date', 'give'), |
|
97 | 97 | ); |
98 | 98 | |
99 | 99 | return $columns; |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return string Column Name |
112 | 112 | */ |
113 | - public function column_default( $item, $column_name ) { |
|
114 | - switch ( $column_name ) { |
|
113 | + public function column_default($item, $column_name) { |
|
114 | + switch ($column_name) { |
|
115 | 115 | default: |
116 | - return $item[ $column_name ]; |
|
116 | + return $item[$column_name]; |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -127,26 +127,26 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @return void |
129 | 129 | */ |
130 | - public function column_details( $item ) { |
|
130 | + public function column_details($item) { |
|
131 | 131 | ?> |
132 | - <a href="#TB_inline?width=640&inlineId=log-details-<?php echo $item['ID']; ?>" class="thickbox"><?php esc_html_e( 'View Request', 'give' ); ?></a> |
|
132 | + <a href="#TB_inline?width=640&inlineId=log-details-<?php echo $item['ID']; ?>" class="thickbox"><?php esc_html_e('View Request', 'give'); ?></a> |
|
133 | 133 | <div id="log-details-<?php echo $item['ID']; ?>" style="display:none;"> |
134 | 134 | <?php |
135 | 135 | |
136 | - $request = get_post_field( 'post_excerpt', $item['ID'] ); |
|
137 | - $error = get_post_field( 'post_content', $item['ID'] ); |
|
138 | - echo '<p><strong>' . esc_html__( 'API Request:', 'give' ) . '</strong></p>'; |
|
139 | - echo '<div>' . $request . '</div>'; |
|
140 | - if ( ! empty( $error ) ) { |
|
141 | - echo '<p><strong>' . esc_html__( 'Error', 'give' ) . '</strong></p>'; |
|
142 | - echo '<div>' . esc_html( $error ) . '</div>'; |
|
136 | + $request = get_post_field('post_excerpt', $item['ID']); |
|
137 | + $error = get_post_field('post_content', $item['ID']); |
|
138 | + echo '<p><strong>'.esc_html__('API Request:', 'give').'</strong></p>'; |
|
139 | + echo '<div>'.$request.'</div>'; |
|
140 | + if ( ! empty($error)) { |
|
141 | + echo '<p><strong>'.esc_html__('Error', 'give').'</strong></p>'; |
|
142 | + echo '<div>'.esc_html($error).'</div>'; |
|
143 | 143 | } |
144 | - echo '<p><strong>' . esc_html__( 'API User:', 'give' ) . '</strong></p>'; |
|
145 | - echo '<div>' . get_post_meta( $item['ID'], '_give_log_user', true ) . '</div>'; |
|
146 | - echo '<p><strong>' . esc_html__( 'API Key:', 'give' ) . '</strong></p>'; |
|
147 | - echo '<div>' . get_post_meta( $item['ID'], '_give_log_key', true ) . '</div>'; |
|
148 | - echo '<p><strong>' . esc_html__( 'Request Date:', 'give' ) . '</strong></p>'; |
|
149 | - echo '<div>' . get_post_field( 'post_date', $item['ID'] ) . '</div>'; |
|
144 | + echo '<p><strong>'.esc_html__('API User:', 'give').'</strong></p>'; |
|
145 | + echo '<div>'.get_post_meta($item['ID'], '_give_log_user', true).'</div>'; |
|
146 | + echo '<p><strong>'.esc_html__('API Key:', 'give').'</strong></p>'; |
|
147 | + echo '<div>'.get_post_meta($item['ID'], '_give_log_key', true).'</div>'; |
|
148 | + echo '<p><strong>'.esc_html__('Request Date:', 'give').'</strong></p>'; |
|
149 | + echo '<div>'.get_post_field('post_date', $item['ID']).'</div>'; |
|
150 | 150 | ?> |
151 | 151 | </div> |
152 | 152 | <?php |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @return string|bool String if search is present, false otherwise |
161 | 161 | */ |
162 | 162 | public function get_search() { |
163 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
163 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
@@ -176,19 +176,19 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @param string $which |
178 | 178 | */ |
179 | - protected function display_tablenav( $which ) { |
|
180 | - if ( 'top' === $which ) { |
|
181 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
179 | + protected function display_tablenav($which) { |
|
180 | + if ('top' === $which) { |
|
181 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
182 | 182 | } |
183 | 183 | ?> |
184 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
184 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
185 | 185 | |
186 | 186 | <div class="alignleft actions bulkactions"> |
187 | - <?php $this->bulk_actions( $which ); ?> |
|
187 | + <?php $this->bulk_actions($which); ?> |
|
188 | 188 | </div> |
189 | 189 | <?php |
190 | - $this->extra_tablenav( $which ); |
|
191 | - $this->pagination( $which ); |
|
190 | + $this->extra_tablenav($which); |
|
191 | + $this->pagination($which); |
|
192 | 192 | ?> |
193 | 193 | |
194 | 194 | <br class="clear"/> |
@@ -210,31 +210,31 @@ discard block |
||
210 | 210 | |
211 | 211 | $search = $this->get_search(); |
212 | 212 | |
213 | - if ( $search ) { |
|
214 | - if ( filter_var( $search, FILTER_VALIDATE_IP ) ) { |
|
213 | + if ($search) { |
|
214 | + if (filter_var($search, FILTER_VALIDATE_IP)) { |
|
215 | 215 | // This is an IP address search |
216 | 216 | $key = '_give_log_request_ip'; |
217 | - } elseif ( is_email( $search ) ) { |
|
217 | + } elseif (is_email($search)) { |
|
218 | 218 | // This is an email search |
219 | - $userdata = get_user_by( 'email', $search ); |
|
219 | + $userdata = get_user_by('email', $search); |
|
220 | 220 | |
221 | - if ( $userdata ) { |
|
221 | + if ($userdata) { |
|
222 | 222 | $search = $userdata->ID; |
223 | 223 | } |
224 | 224 | |
225 | 225 | $key = '_give_log_user'; |
226 | - } elseif ( strlen( $search ) == 32 ) { |
|
226 | + } elseif (strlen($search) == 32) { |
|
227 | 227 | // Look for an API key |
228 | 228 | $key = '_give_log_key'; |
229 | - } elseif ( stristr( $search, 'token:' ) ) { |
|
229 | + } elseif (stristr($search, 'token:')) { |
|
230 | 230 | // Look for an API token |
231 | - $search = str_ireplace( 'token:', '', $search ); |
|
231 | + $search = str_ireplace('token:', '', $search); |
|
232 | 232 | $key = '_give_log_token'; |
233 | 233 | } else { |
234 | 234 | // This is (probably) a user ID search |
235 | - $userdata = get_userdata( $search ); |
|
235 | + $userdata = get_userdata($search); |
|
236 | 236 | |
237 | - if ( $userdata ) { |
|
237 | + if ($userdata) { |
|
238 | 238 | $search = $userdata->ID; |
239 | 239 | } |
240 | 240 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @return int Current page number |
261 | 261 | */ |
262 | 262 | public function get_paged() { |
263 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
263 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @since 1.0 |
271 | 271 | * @return void |
272 | 272 | */ |
273 | - function bulk_actions( $which = '' ) { |
|
273 | + function bulk_actions($which = '') { |
|
274 | 274 | give_log_views(); |
275 | 275 | } |
276 | 276 | |
@@ -293,14 +293,14 @@ discard block |
||
293 | 293 | 'meta_query' => $this->get_meta_query(), |
294 | 294 | ); |
295 | 295 | |
296 | - $logs = $give_logs->get_connected_logs( $log_query ); |
|
296 | + $logs = $give_logs->get_connected_logs($log_query); |
|
297 | 297 | |
298 | - if ( $logs ) { |
|
299 | - foreach ( $logs as $log ) { |
|
298 | + if ($logs) { |
|
299 | + foreach ($logs as $log) { |
|
300 | 300 | |
301 | 301 | $logs_data[] = array( |
302 | 302 | 'ID' => $log->ID, |
303 | - 'ip' => get_post_meta( $log->ID, '_give_log_request_ip', true ), |
|
303 | + 'ip' => get_post_meta($log->ID, '_give_log_request_ip', true), |
|
304 | 304 | 'date' => $log->post_date, |
305 | 305 | ); |
306 | 306 | } |
@@ -328,14 +328,14 @@ discard block |
||
328 | 328 | $columns = $this->get_columns(); |
329 | 329 | $hidden = array(); // No hidden columns |
330 | 330 | $sortable = $this->get_sortable_columns(); |
331 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
331 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
332 | 332 | $this->items = $this->get_logs(); |
333 | - $total_items = $give_logs->get_log_count( 0, 'api_requests' ); |
|
333 | + $total_items = $give_logs->get_log_count(0, 'api_requests'); |
|
334 | 334 | |
335 | - $this->set_pagination_args( array( |
|
335 | + $this->set_pagination_args(array( |
|
336 | 336 | 'total_items' => $total_items, |
337 | 337 | 'per_page' => $this->per_page, |
338 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
338 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
339 | 339 | ) |
340 | 340 | ); |
341 | 341 | } |
@@ -157,7 +157,7 @@ |
||
157 | 157 | * |
158 | 158 | * @access public |
159 | 159 | * @since 1.0 |
160 | - * @return string|bool string If search is present, false otherwise |
|
160 | + * @return string|false string If search is present, false otherwise |
|
161 | 161 | */ |
162 | 162 | public function get_search() { |
163 | 163 | return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
@@ -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,13 +44,13 @@ discard block |
||
44 | 44 | global $status, $page; |
45 | 45 | |
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 |
|
50 | - 'ajax' => false,// Does this table support ajax? |
|
51 | - ) ); |
|
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 | + 'ajax' => false, // Does this table support ajax? |
|
51 | + )); |
|
52 | 52 | |
53 | - add_action( 'give_log_view_actions', array( $this, 'give_forms_filter' ) ); |
|
53 | + add_action('give_log_view_actions', array($this, 'give_forms_filter')); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -64,39 +64,39 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return string Column Name |
66 | 66 | */ |
67 | - public function column_default( $item, $column_name ) { |
|
67 | + public function column_default($item, $column_name) { |
|
68 | 68 | |
69 | - $payment = give_get_payment_by( 'id', $item['payment_id'] ); |
|
69 | + $payment = give_get_payment_by('id', $item['payment_id']); |
|
70 | 70 | |
71 | - switch ( $column_name ) { |
|
71 | + switch ($column_name) { |
|
72 | 72 | case 'form' : |
73 | - $form_title = get_the_title( $item[ $column_name ] ); |
|
74 | - $form_title = empty( $form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $item[ $column_name ] ) : $form_title; |
|
75 | - return '<a href="' . esc_url( add_query_arg( 'form', $item[ $column_name ] ) ) . '" >' . $form_title . '</a>'; |
|
73 | + $form_title = get_the_title($item[$column_name]); |
|
74 | + $form_title = empty($form_title) ? sprintf(__('Untitled (#%s)', 'give'), $item[$column_name]) : $form_title; |
|
75 | + return '<a href="'.esc_url(add_query_arg('form', $item[$column_name])).'" >'.$form_title.'</a>'; |
|
76 | 76 | |
77 | 77 | case 'user_id' : |
78 | - return '<a href="' . |
|
79 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . ( ! empty( $item['user_id'] ) ? urlencode( $item['user_id'] ) : give_get_payment_user_email( $item['payment_id'] ) ) ) . |
|
80 | - '">' . $item['user_name'] . '</a>'; |
|
78 | + return '<a href="'. |
|
79 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.( ! empty($item['user_id']) ? urlencode($item['user_id']) : give_get_payment_user_email($item['payment_id']))). |
|
80 | + '">'.$item['user_name'].'</a>'; |
|
81 | 81 | |
82 | 82 | case 'amount' : |
83 | - return give_currency_filter( give_format_amount( $item['amount'] ) ); |
|
83 | + return give_currency_filter(give_format_amount($item['amount'])); |
|
84 | 84 | |
85 | 85 | case 'status' : |
86 | 86 | |
87 | - $value = '<div class="give-donation-status status-' . sanitize_title( give_get_payment_status( $payment, true ) ) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status( $payment, true ) . '</div>'; |
|
87 | + $value = '<div class="give-donation-status status-'.sanitize_title(give_get_payment_status($payment, true)).'"><span class="give-donation-status-icon"></span> '.give_get_payment_status($payment, true).'</div>'; |
|
88 | 88 | |
89 | - if ( $payment->mode == 'test' ) { |
|
90 | - $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This donation was made in test mode.', 'give' ) . '">' . esc_html__( 'Test', 'give' ) . '</span>'; |
|
89 | + if ($payment->mode == 'test') { |
|
90 | + $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This donation was made in test mode.', 'give').'">'.esc_html__('Test', 'give').'</span>'; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | return $value; |
94 | 94 | |
95 | 95 | case 'payment_id' : |
96 | - return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $item['payment_id'] ) . '">' . give_get_payment_number( $item['payment_id'] ) . '</a>'; |
|
96 | + return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$item['payment_id']).'">'.give_get_payment_number($item['payment_id']).'</a>'; |
|
97 | 97 | |
98 | 98 | default: |
99 | - return $item[ $column_name ]; |
|
99 | + return $item[$column_name]; |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
@@ -109,13 +109,13 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function get_columns() { |
111 | 111 | $columns = array( |
112 | - 'ID' => esc_html__( 'Log ID', 'give' ), |
|
113 | - 'user_id' => esc_html__( 'Donor', 'give' ), |
|
114 | - 'form' => esc_html__( 'Form', 'give' ), |
|
115 | - 'amount' => esc_html__( 'Donation Amount', 'give' ), |
|
116 | - 'status' => esc_html__( 'Status', 'give' ), |
|
117 | - 'payment_id' => esc_html__( 'Transaction ID', 'give' ), |
|
118 | - 'date' => esc_html__( 'Date', 'give' ), |
|
112 | + 'ID' => esc_html__('Log ID', 'give'), |
|
113 | + 'user_id' => esc_html__('Donor', 'give'), |
|
114 | + 'form' => esc_html__('Form', 'give'), |
|
115 | + 'amount' => esc_html__('Donation Amount', 'give'), |
|
116 | + 'status' => esc_html__('Status', 'give'), |
|
117 | + 'payment_id' => esc_html__('Transaction ID', 'give'), |
|
118 | + 'date' => esc_html__('Date', 'give'), |
|
119 | 119 | ); |
120 | 120 | |
121 | 121 | return $columns; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @return int Current page number |
130 | 130 | */ |
131 | 131 | public function get_paged() { |
132 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
132 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @return mixed int If User ID, string If Email/Login |
141 | 141 | */ |
142 | 142 | public function get_filtered_user() { |
143 | - return isset( $_GET['user'] ) ? absint( $_GET['user'] ) : false; |
|
143 | + return isset($_GET['user']) ? absint($_GET['user']) : false; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @return int Download ID |
152 | 152 | */ |
153 | 153 | public function get_filtered_give_form() { |
154 | - return ! empty( $_GET['form'] ) ? absint( $_GET['form'] ) : false; |
|
154 | + return ! empty($_GET['form']) ? absint($_GET['form']) : false; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @return string|bool string If search is present, false otherwise |
163 | 163 | */ |
164 | 164 | public function get_search() { |
165 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
165 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | |
@@ -178,20 +178,20 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @param string $which |
180 | 180 | */ |
181 | - protected function display_tablenav( $which ) { |
|
181 | + protected function display_tablenav($which) { |
|
182 | 182 | |
183 | - if ( 'top' === $which ) { |
|
184 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
183 | + if ('top' === $which) { |
|
184 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
185 | 185 | } |
186 | 186 | ?> |
187 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
187 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
188 | 188 | |
189 | 189 | <div class="alignleft actions bulkactions"> |
190 | - <?php $this->bulk_actions( $which ); ?> |
|
190 | + <?php $this->bulk_actions($which); ?> |
|
191 | 191 | </div> |
192 | 192 | <?php |
193 | - $this->extra_tablenav( $which ); |
|
194 | - $this->pagination( $which ); |
|
193 | + $this->extra_tablenav($which); |
|
194 | + $this->pagination($which); |
|
195 | 195 | ?> |
196 | 196 | |
197 | 197 | <br class="clear"/> |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | |
215 | 215 | $meta_query = array(); |
216 | 216 | |
217 | - if ( $user ) { |
|
217 | + if ($user) { |
|
218 | 218 | // Show only logs from a specific user |
219 | 219 | $meta_query[] = array( |
220 | 220 | 'key' => '_give_log_user_id', |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | } |
224 | 224 | |
225 | 225 | $search = $this->get_search(); |
226 | - if ( $search ) { |
|
227 | - if ( is_email( $search ) ) { |
|
226 | + if ($search) { |
|
227 | + if (is_email($search)) { |
|
228 | 228 | // This is an email search. We use this to ensure it works for guest users and logged-in users |
229 | 229 | $key = '_give_log_user_info'; |
230 | 230 | $compare = 'LIKE'; |
@@ -233,32 +233,32 @@ discard block |
||
233 | 233 | $key = '_give_log_user_id'; |
234 | 234 | $compare = 'LIKE'; |
235 | 235 | |
236 | - if ( ! is_numeric( $search ) ) { |
|
236 | + if ( ! is_numeric($search)) { |
|
237 | 237 | // Searching for user by username |
238 | - $user = get_user_by( 'login', $search ); |
|
238 | + $user = get_user_by('login', $search); |
|
239 | 239 | |
240 | - if ( $user ) { |
|
240 | + if ($user) { |
|
241 | 241 | // Found one, set meta value to user's ID |
242 | 242 | $search = $user->ID; |
243 | 243 | } else { |
244 | 244 | // No user found so let's do a real search query |
245 | - $users = new WP_User_Query( array( |
|
245 | + $users = new WP_User_Query(array( |
|
246 | 246 | 'search' => $search, |
247 | - 'search_columns' => array( 'user_url', 'user_nicename' ), |
|
247 | + 'search_columns' => array('user_url', 'user_nicename'), |
|
248 | 248 | 'number' => 1, |
249 | 249 | 'fields' => 'ids', |
250 | - ) ); |
|
250 | + )); |
|
251 | 251 | |
252 | 252 | $found_user = $users->get_results(); |
253 | 253 | |
254 | - if ( $found_user ) { |
|
254 | + if ($found_user) { |
|
255 | 255 | $search = $found_user[0]; |
256 | 256 | } |
257 | 257 | } |
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
261 | - if ( ! $this->file_search ) { |
|
261 | + if ( ! $this->file_search) { |
|
262 | 262 | // Meta query only works for non file name searche |
263 | 263 | $meta_query[] = array( |
264 | 264 | 'key' => $key, |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | * @since 1.0 |
280 | 280 | * @return void |
281 | 281 | */ |
282 | - function bulk_actions( $which = '' ) { |
|
282 | + function bulk_actions($which = '') { |
|
283 | 283 | give_log_views(); |
284 | 284 | } |
285 | 285 | |
@@ -291,24 +291,24 @@ discard block |
||
291 | 291 | * @return void |
292 | 292 | */ |
293 | 293 | public function give_forms_filter() { |
294 | - $give_forms = get_posts( array( |
|
294 | + $give_forms = get_posts(array( |
|
295 | 295 | 'post_type' => 'give_forms', |
296 | 296 | 'post_status' => 'any', |
297 | - 'posts_per_page' => - 1, |
|
297 | + 'posts_per_page' => -1, |
|
298 | 298 | 'orderby' => 'title', |
299 | 299 | 'order' => 'ASC', |
300 | 300 | 'fields' => 'ids', |
301 | 301 | 'update_post_meta_cache' => false, |
302 | 302 | 'update_post_term_cache' => false, |
303 | - ) ); |
|
303 | + )); |
|
304 | 304 | |
305 | - if ( $give_forms ) { |
|
305 | + if ($give_forms) { |
|
306 | 306 | echo '<select name="form" id="give-log-form-filter">'; |
307 | - echo '<option value="0">' . esc_html__( 'All', 'give' ) . '</option>'; |
|
308 | - foreach ( $give_forms as $form ) { |
|
309 | - $form_title = get_the_title( $form ); |
|
310 | - $form_title = empty( $form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $form ) : $form_title; |
|
311 | - echo '<option value="' . $form . '"' . selected( $form, $this->get_filtered_give_form() ) . '>' . esc_html( $form_title ) . '</option>'; |
|
307 | + echo '<option value="0">'.esc_html__('All', 'give').'</option>'; |
|
308 | + foreach ($give_forms as $form) { |
|
309 | + $form_title = get_the_title($form); |
|
310 | + $form_title = empty($form_title) ? sprintf(__('Untitled (#%s)', 'give'), $form) : $form_title; |
|
311 | + echo '<option value="'.$form.'"'.selected($form, $this->get_filtered_give_form()).'>'.esc_html($form_title).'</option>'; |
|
312 | 312 | } |
313 | 313 | echo '</select>'; |
314 | 314 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | |
329 | 329 | $logs_data = array(); |
330 | 330 | $paged = $this->get_paged(); |
331 | - $give_form = empty( $_GET['s'] ) ? $this->get_filtered_give_form() : null; |
|
331 | + $give_form = empty($_GET['s']) ? $this->get_filtered_give_form() : null; |
|
332 | 332 | $user = $this->get_filtered_user(); |
333 | 333 | |
334 | 334 | $log_query = array( |
@@ -338,39 +338,39 @@ discard block |
||
338 | 338 | 'meta_query' => $this->get_meta_query(), |
339 | 339 | ); |
340 | 340 | |
341 | - $cache_key = give_get_cache_key( 'get_logs', $log_query ); |
|
341 | + $cache_key = give_get_cache_key('get_logs', $log_query); |
|
342 | 342 | |
343 | 343 | // Return result from cache if exist. |
344 | - if ( ! ( $logs_data = get_option( $cache_key ) ) ) { |
|
344 | + if ( ! ($logs_data = get_option($cache_key))) { |
|
345 | 345 | |
346 | - $logs = $give_logs->get_connected_logs( $log_query ); |
|
346 | + $logs = $give_logs->get_connected_logs($log_query); |
|
347 | 347 | |
348 | - if ( $logs ) { |
|
349 | - foreach ( $logs as $log ) { |
|
350 | - $payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true ); |
|
348 | + if ($logs) { |
|
349 | + foreach ($logs as $log) { |
|
350 | + $payment_id = get_post_meta($log->ID, '_give_log_payment_id', true); |
|
351 | 351 | |
352 | 352 | // Make sure this payment hasn't been deleted |
353 | - if ( get_post( $payment_id ) ) : |
|
354 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
355 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
356 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
353 | + if (get_post($payment_id)) : |
|
354 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
355 | + $payment_meta = give_get_payment_meta($payment_id); |
|
356 | + $payment_amount = give_get_payment_amount($payment_id); |
|
357 | 357 | |
358 | 358 | $logs_data[] = array( |
359 | - 'ID' => '<span class="give-item-label give-item-label-gray">' . $log->ID . '</span>', |
|
359 | + 'ID' => '<span class="give-item-label give-item-label-gray">'.$log->ID.'</span>', |
|
360 | 360 | 'payment_id' => $payment_id, |
361 | 361 | 'form' => $log->post_parent, |
362 | 362 | 'amount' => $payment_amount, |
363 | 363 | 'user_id' => $user_info['id'], |
364 | - 'user_name' => $user_info['first_name'] . ' ' . $user_info['last_name'], |
|
365 | - 'date' => get_post_field( 'post_date', $payment_id ), |
|
364 | + 'user_name' => $user_info['first_name'].' '.$user_info['last_name'], |
|
365 | + 'date' => get_post_field('post_date', $payment_id), |
|
366 | 366 | ); |
367 | 367 | |
368 | 368 | endif; |
369 | 369 | } |
370 | 370 | |
371 | 371 | // Cache results. |
372 | - if ( ! empty( $logs_data ) ) { |
|
373 | - add_option( $cache_key, $logs_data, '', 'no' ); |
|
372 | + if ( ! empty($logs_data)) { |
|
373 | + add_option($cache_key, $logs_data, '', 'no'); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | } |
@@ -398,15 +398,15 @@ discard block |
||
398 | 398 | $columns = $this->get_columns(); |
399 | 399 | $hidden = array(); |
400 | 400 | $sortable = $this->get_sortable_columns(); |
401 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
401 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
402 | 402 | $current_page = $this->get_pagenum(); |
403 | 403 | $this->items = $this->get_logs(); |
404 | - $total_items = $give_logs->get_log_count( $this->get_filtered_give_form(), 'sale', $this->get_meta_query() ); |
|
404 | + $total_items = $give_logs->get_log_count($this->get_filtered_give_form(), 'sale', $this->get_meta_query()); |
|
405 | 405 | |
406 | - $this->set_pagination_args( array( |
|
406 | + $this->set_pagination_args(array( |
|
407 | 407 | 'total_items' => $total_items, |
408 | 408 | 'per_page' => $this->per_page, |
409 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
409 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
410 | 410 | ) |
411 | 411 | ); |
412 | 412 | } |
@@ -664,7 +664,7 @@ |
||
664 | 664 | * |
665 | 665 | * @param array $args Arguments to override defaults |
666 | 666 | * |
667 | - * @return array $dates |
|
667 | + * @return integer|null $dates |
|
668 | 668 | */ |
669 | 669 | public function get_dates( $args = array() ) { |
670 | 670 | $dates = array(); |
@@ -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 | |
@@ -140,27 +140,27 @@ discard block |
||
140 | 140 | 'v1' => 'GIVE_API_V1', |
141 | 141 | ); |
142 | 142 | |
143 | - foreach ( $this->get_versions() as $version => $class ) { |
|
144 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php'; |
|
143 | + foreach ($this->get_versions() as $version => $class) { |
|
144 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php'; |
|
145 | 145 | } |
146 | 146 | |
147 | - add_action( 'init', array( $this, 'add_endpoint' ) ); |
|
148 | - add_action( 'wp', array( $this, 'process_query' ), - 1 ); |
|
149 | - add_filter( 'query_vars', array( $this, 'query_vars' ) ); |
|
150 | - add_action( 'show_user_profile', array( $this, 'user_key_field' ) ); |
|
151 | - add_action( 'edit_user_profile', array( $this, 'user_key_field' ) ); |
|
152 | - add_action( 'personal_options_update', array( $this, 'update_key' ) ); |
|
153 | - add_action( 'edit_user_profile_update', array( $this, 'update_key' ) ); |
|
154 | - add_action( 'give_process_api_key', array( $this, 'process_api_key' ) ); |
|
147 | + add_action('init', array($this, 'add_endpoint')); |
|
148 | + add_action('wp', array($this, 'process_query'), - 1); |
|
149 | + add_filter('query_vars', array($this, 'query_vars')); |
|
150 | + add_action('show_user_profile', array($this, 'user_key_field')); |
|
151 | + add_action('edit_user_profile', array($this, 'user_key_field')); |
|
152 | + add_action('personal_options_update', array($this, 'update_key')); |
|
153 | + add_action('edit_user_profile_update', array($this, 'update_key')); |
|
154 | + add_action('give_process_api_key', array($this, 'process_api_key')); |
|
155 | 155 | |
156 | 156 | // Setup a backwards compatibility check for user API Keys |
157 | - add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 ); |
|
157 | + add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4); |
|
158 | 158 | |
159 | 159 | // Determine if JSON_PRETTY_PRINT is available |
160 | - $this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null; |
|
160 | + $this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null; |
|
161 | 161 | |
162 | 162 | // Allow API request logging to be turned off |
163 | - $this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests ); |
|
163 | + $this->log_requests = apply_filters('give_api_log_requests', $this->log_requests); |
|
164 | 164 | |
165 | 165 | // Setup Give_Payment_Stats instance |
166 | 166 | $this->stats = new Give_Payment_Stats; |
@@ -176,8 +176,8 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @since 1.1 |
178 | 178 | */ |
179 | - public function add_endpoint( $rewrite_rules ) { |
|
180 | - add_rewrite_endpoint( 'give-api', EP_ALL ); |
|
179 | + public function add_endpoint($rewrite_rules) { |
|
180 | + add_rewrite_endpoint('give-api', EP_ALL); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * |
191 | 191 | * @return string[] $vars New query vars |
192 | 192 | */ |
193 | - public function query_vars( $vars ) { |
|
193 | + public function query_vars($vars) { |
|
194 | 194 | |
195 | 195 | $vars[] = 'token'; |
196 | 196 | $vars[] = 'key'; |
@@ -241,11 +241,11 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function get_default_version() { |
243 | 243 | |
244 | - $version = get_option( 'give_default_api_version' ); |
|
244 | + $version = get_option('give_default_api_version'); |
|
245 | 245 | |
246 | - if ( defined( 'GIVE_API_VERSION' ) ) { |
|
246 | + if (defined('GIVE_API_VERSION')) { |
|
247 | 247 | $version = GIVE_API_VERSION; |
248 | - } elseif ( ! $version ) { |
|
248 | + } elseif ( ! $version) { |
|
249 | 249 | $version = 'v1'; |
250 | 250 | } |
251 | 251 | |
@@ -266,14 +266,14 @@ discard block |
||
266 | 266 | |
267 | 267 | $version = $wp_query->query_vars['give-api']; |
268 | 268 | |
269 | - if ( strpos( $version, '/' ) ) { |
|
269 | + if (strpos($version, '/')) { |
|
270 | 270 | |
271 | - $version = explode( '/', $version ); |
|
272 | - $version = strtolower( $version[0] ); |
|
271 | + $version = explode('/', $version); |
|
272 | + $version = strtolower($version[0]); |
|
273 | 273 | |
274 | - $wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] ); |
|
274 | + $wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']); |
|
275 | 275 | |
276 | - if ( array_key_exists( $version, $this->versions ) ) { |
|
276 | + if (array_key_exists($version, $this->versions)) { |
|
277 | 277 | |
278 | 278 | $this->queried_version = $version; |
279 | 279 | |
@@ -309,32 +309,32 @@ discard block |
||
309 | 309 | $this->override = false; |
310 | 310 | |
311 | 311 | // Make sure we have both user and api key |
312 | - if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] != 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) { |
|
312 | + if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] != 'forms' || ! empty($wp_query->query_vars['token']))) { |
|
313 | 313 | |
314 | - if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) { |
|
314 | + if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) { |
|
315 | 315 | $this->missing_auth(); |
316 | 316 | } |
317 | 317 | |
318 | 318 | // Retrieve the user by public API key and ensure they exist |
319 | - if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) { |
|
319 | + if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) { |
|
320 | 320 | |
321 | 321 | $this->invalid_key(); |
322 | 322 | |
323 | 323 | } else { |
324 | 324 | |
325 | - $token = urldecode( $wp_query->query_vars['token'] ); |
|
326 | - $secret = $this->get_user_secret_key( $user ); |
|
327 | - $public = urldecode( $wp_query->query_vars['key'] ); |
|
325 | + $token = urldecode($wp_query->query_vars['token']); |
|
326 | + $secret = $this->get_user_secret_key($user); |
|
327 | + $public = urldecode($wp_query->query_vars['key']); |
|
328 | 328 | |
329 | - if ( hash_equals( md5( $secret . $public ), $token ) ) { |
|
329 | + if (hash_equals(md5($secret.$public), $token)) { |
|
330 | 330 | $this->is_valid_request = true; |
331 | 331 | } else { |
332 | 332 | $this->invalid_auth(); |
333 | 333 | } |
334 | 334 | } |
335 | - } elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] == 'forms' ) { |
|
335 | + } elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] == 'forms') { |
|
336 | 336 | $this->is_valid_request = true; |
337 | - $wp_query->set( 'key', 'public' ); |
|
337 | + $wp_query->set('key', 'public'); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | |
@@ -350,25 +350,25 @@ discard block |
||
350 | 350 | * |
351 | 351 | * @return bool if user ID is found, false otherwise |
352 | 352 | */ |
353 | - public function get_user( $key = '' ) { |
|
353 | + public function get_user($key = '') { |
|
354 | 354 | global $wpdb, $wp_query; |
355 | 355 | |
356 | - if ( empty( $key ) ) { |
|
357 | - $key = urldecode( $wp_query->query_vars['key'] ); |
|
356 | + if (empty($key)) { |
|
357 | + $key = urldecode($wp_query->query_vars['key']); |
|
358 | 358 | } |
359 | 359 | |
360 | - if ( empty( $key ) ) { |
|
360 | + if (empty($key)) { |
|
361 | 361 | return false; |
362 | 362 | } |
363 | 363 | |
364 | - $user = get_transient( md5( 'give_api_user_' . $key ) ); |
|
364 | + $user = get_transient(md5('give_api_user_'.$key)); |
|
365 | 365 | |
366 | - if ( false === $user ) { |
|
367 | - $user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) ); |
|
368 | - set_transient( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS ); |
|
366 | + if (false === $user) { |
|
367 | + $user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key)); |
|
368 | + set_transient(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS); |
|
369 | 369 | } |
370 | 370 | |
371 | - if ( $user != null ) { |
|
371 | + if ($user != null) { |
|
372 | 372 | $this->user_id = $user; |
373 | 373 | |
374 | 374 | return $user; |
@@ -377,37 +377,37 @@ discard block |
||
377 | 377 | return false; |
378 | 378 | } |
379 | 379 | |
380 | - public function get_user_public_key( $user_id = 0 ) { |
|
380 | + public function get_user_public_key($user_id = 0) { |
|
381 | 381 | global $wpdb; |
382 | 382 | |
383 | - if ( empty( $user_id ) ) { |
|
383 | + if (empty($user_id)) { |
|
384 | 384 | return ''; |
385 | 385 | } |
386 | 386 | |
387 | - $cache_key = md5( 'give_api_user_public_key' . $user_id ); |
|
388 | - $user_public_key = get_transient( $cache_key ); |
|
387 | + $cache_key = md5('give_api_user_public_key'.$user_id); |
|
388 | + $user_public_key = get_transient($cache_key); |
|
389 | 389 | |
390 | - if ( empty( $user_public_key ) ) { |
|
391 | - $user_public_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id ) ); |
|
392 | - set_transient( $cache_key, $user_public_key, HOUR_IN_SECONDS ); |
|
390 | + if (empty($user_public_key)) { |
|
391 | + $user_public_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id)); |
|
392 | + set_transient($cache_key, $user_public_key, HOUR_IN_SECONDS); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | return $user_public_key; |
396 | 396 | } |
397 | 397 | |
398 | - public function get_user_secret_key( $user_id = 0 ) { |
|
398 | + public function get_user_secret_key($user_id = 0) { |
|
399 | 399 | global $wpdb; |
400 | 400 | |
401 | - if ( empty( $user_id ) ) { |
|
401 | + if (empty($user_id)) { |
|
402 | 402 | return ''; |
403 | 403 | } |
404 | 404 | |
405 | - $cache_key = md5( 'give_api_user_secret_key' . $user_id ); |
|
406 | - $user_secret_key = get_transient( $cache_key ); |
|
405 | + $cache_key = md5('give_api_user_secret_key'.$user_id); |
|
406 | + $user_secret_key = get_transient($cache_key); |
|
407 | 407 | |
408 | - if ( empty( $user_secret_key ) ) { |
|
409 | - $user_secret_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id ) ); |
|
410 | - set_transient( $cache_key, $user_secret_key, HOUR_IN_SECONDS ); |
|
408 | + if (empty($user_secret_key)) { |
|
409 | + $user_secret_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id)); |
|
410 | + set_transient($cache_key, $user_secret_key, HOUR_IN_SECONDS); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | return $user_secret_key; |
@@ -423,10 +423,10 @@ discard block |
||
423 | 423 | */ |
424 | 424 | private function missing_auth() { |
425 | 425 | $error = array(); |
426 | - $error['error'] = esc_html__( 'You must specify both a token and API key.', 'give' ); |
|
426 | + $error['error'] = esc_html__('You must specify both a token and API key.', 'give'); |
|
427 | 427 | |
428 | 428 | $this->data = $error; |
429 | - $this->output( 401 ); |
|
429 | + $this->output(401); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | /** |
@@ -440,10 +440,10 @@ discard block |
||
440 | 440 | */ |
441 | 441 | private function invalid_auth() { |
442 | 442 | $error = array(); |
443 | - $error['error'] = esc_html__( 'Your request could not be authenticated.', 'give' ); |
|
443 | + $error['error'] = esc_html__('Your request could not be authenticated.', 'give'); |
|
444 | 444 | |
445 | 445 | $this->data = $error; |
446 | - $this->output( 403 ); |
|
446 | + $this->output(403); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
@@ -457,10 +457,10 @@ discard block |
||
457 | 457 | */ |
458 | 458 | private function invalid_key() { |
459 | 459 | $error = array(); |
460 | - $error['error'] = esc_html__( 'Invalid API key.', 'give' ); |
|
460 | + $error['error'] = esc_html__('Invalid API key.', 'give'); |
|
461 | 461 | |
462 | 462 | $this->data = $error; |
463 | - $this->output( 403 ); |
|
463 | + $this->output(403); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
@@ -473,10 +473,10 @@ discard block |
||
473 | 473 | */ |
474 | 474 | private function invalid_version() { |
475 | 475 | $error = array(); |
476 | - $error['error'] = esc_html__( 'Invalid API version.', 'give' ); |
|
476 | + $error['error'] = esc_html__('Invalid API version.', 'give'); |
|
477 | 477 | |
478 | 478 | $this->data = $error; |
479 | - $this->output( 404 ); |
|
479 | + $this->output(404); |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | /** |
@@ -492,10 +492,10 @@ discard block |
||
492 | 492 | global $wp_query; |
493 | 493 | |
494 | 494 | // Start logging how long the request takes for logging |
495 | - $before = microtime( true ); |
|
495 | + $before = microtime(true); |
|
496 | 496 | |
497 | 497 | // Check for give-api var. Get out if not present |
498 | - if ( empty( $wp_query->query_vars['give-api'] ) ) { |
|
498 | + if (empty($wp_query->query_vars['give-api'])) { |
|
499 | 499 | return; |
500 | 500 | } |
501 | 501 | |
@@ -509,45 +509,45 @@ discard block |
||
509 | 509 | $this->validate_request(); |
510 | 510 | |
511 | 511 | // Only proceed if no errors have been noted |
512 | - if ( ! $this->is_valid_request ) { |
|
512 | + if ( ! $this->is_valid_request) { |
|
513 | 513 | return; |
514 | 514 | } |
515 | 515 | |
516 | - if ( ! defined( 'GIVE_DOING_API' ) ) { |
|
517 | - define( 'GIVE_DOING_API', true ); |
|
516 | + if ( ! defined('GIVE_DOING_API')) { |
|
517 | + define('GIVE_DOING_API', true); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | $data = array(); |
521 | 521 | $this->routes = new $this->versions[$this->get_queried_version()]; |
522 | 522 | $this->routes->validate_request(); |
523 | 523 | |
524 | - switch ( $this->endpoint ) : |
|
524 | + switch ($this->endpoint) : |
|
525 | 525 | |
526 | 526 | case 'stats' : |
527 | 527 | |
528 | - $data = $this->routes->get_stats( array( |
|
529 | - 'type' => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null, |
|
530 | - 'form' => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null, |
|
531 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
532 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
533 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, |
|
534 | - ) ); |
|
528 | + $data = $this->routes->get_stats(array( |
|
529 | + 'type' => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null, |
|
530 | + 'form' => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null, |
|
531 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
532 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
533 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, |
|
534 | + )); |
|
535 | 535 | |
536 | 536 | break; |
537 | 537 | |
538 | 538 | case 'forms' : |
539 | 539 | |
540 | - $form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null; |
|
540 | + $form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null; |
|
541 | 541 | |
542 | - $data = $this->routes->get_forms( $form ); |
|
542 | + $data = $this->routes->get_forms($form); |
|
543 | 543 | |
544 | 544 | break; |
545 | 545 | |
546 | 546 | case 'donors' : |
547 | 547 | |
548 | - $customer = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null; |
|
548 | + $customer = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null; |
|
549 | 549 | |
550 | - $data = $this->routes->get_customers( $customer ); |
|
550 | + $data = $this->routes->get_customers($customer); |
|
551 | 551 | |
552 | 552 | break; |
553 | 553 | |
@@ -560,14 +560,14 @@ discard block |
||
560 | 560 | endswitch; |
561 | 561 | |
562 | 562 | // Allow extensions to setup their own return data |
563 | - $this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this ); |
|
563 | + $this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this); |
|
564 | 564 | |
565 | - $after = microtime( true ); |
|
566 | - $request_time = ( $after - $before ); |
|
565 | + $after = microtime(true); |
|
566 | + $request_time = ($after - $before); |
|
567 | 567 | $this->data['request_speed'] = $request_time; |
568 | 568 | |
569 | 569 | // Log this API request, if enabled. We log it here because we have access to errors. |
570 | - $this->log_request( $this->data ); |
|
570 | + $this->log_request($this->data); |
|
571 | 571 | |
572 | 572 | // Send out data to the output function |
573 | 573 | $this->output(); |
@@ -597,25 +597,25 @@ discard block |
||
597 | 597 | global $wp_query; |
598 | 598 | |
599 | 599 | // Whitelist our query options |
600 | - $accepted = apply_filters( 'give_api_valid_query_modes', array( |
|
600 | + $accepted = apply_filters('give_api_valid_query_modes', array( |
|
601 | 601 | 'stats', |
602 | 602 | 'forms', |
603 | 603 | 'donors', |
604 | 604 | 'donations', |
605 | - ) ); |
|
605 | + )); |
|
606 | 606 | |
607 | - $query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null; |
|
608 | - $query = str_replace( $this->queried_version . '/', '', $query ); |
|
607 | + $query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null; |
|
608 | + $query = str_replace($this->queried_version.'/', '', $query); |
|
609 | 609 | |
610 | 610 | $error = array(); |
611 | 611 | |
612 | 612 | // Make sure our query is valid |
613 | - if ( ! in_array( $query, $accepted ) ) { |
|
614 | - $error['error'] = esc_html__( 'Invalid query.', 'give' ); |
|
613 | + if ( ! in_array($query, $accepted)) { |
|
614 | + $error['error'] = esc_html__('Invalid query.', 'give'); |
|
615 | 615 | |
616 | 616 | $this->data = $error; |
617 | 617 | // 400 is Bad Request |
618 | - $this->output( 400 ); |
|
618 | + $this->output(400); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | $this->endpoint = $query; |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | public function get_paged() { |
633 | 633 | global $wp_query; |
634 | 634 | |
635 | - return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1; |
|
635 | + return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1; |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | |
@@ -647,13 +647,13 @@ discard block |
||
647 | 647 | public function per_page() { |
648 | 648 | global $wp_query; |
649 | 649 | |
650 | - $per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10; |
|
650 | + $per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10; |
|
651 | 651 | |
652 | - if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) { |
|
652 | + if ($per_page < 0 && $this->get_query_mode() == 'donors') { |
|
653 | 653 | $per_page = 99999999; |
654 | 654 | } // Customers query doesn't support -1 |
655 | 655 | |
656 | - return apply_filters( 'give_api_results_per_page', $per_page ); |
|
656 | + return apply_filters('give_api_results_per_page', $per_page); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | /** |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | * |
667 | 667 | * @return array $dates |
668 | 668 | */ |
669 | - public function get_dates( $args = array() ) { |
|
669 | + public function get_dates($args = array()) { |
|
670 | 670 | $dates = array(); |
671 | 671 | |
672 | 672 | $defaults = array( |
@@ -677,60 +677,60 @@ discard block |
||
677 | 677 | 'enddate' => null, |
678 | 678 | ); |
679 | 679 | |
680 | - $args = wp_parse_args( $args, $defaults ); |
|
680 | + $args = wp_parse_args($args, $defaults); |
|
681 | 681 | |
682 | - $current_time = current_time( 'timestamp' ); |
|
682 | + $current_time = current_time('timestamp'); |
|
683 | 683 | |
684 | - if ( 'range' === $args['date'] ) { |
|
685 | - $startdate = strtotime( $args['startdate'] ); |
|
686 | - $enddate = strtotime( $args['enddate'] ); |
|
687 | - $dates['day_start'] = date( 'd', $startdate ); |
|
688 | - $dates['day_end'] = date( 'd', $enddate ); |
|
689 | - $dates['m_start'] = date( 'n', $startdate ); |
|
690 | - $dates['m_end'] = date( 'n', $enddate ); |
|
691 | - $dates['year'] = date( 'Y', $startdate ); |
|
692 | - $dates['year_end'] = date( 'Y', $enddate ); |
|
684 | + if ('range' === $args['date']) { |
|
685 | + $startdate = strtotime($args['startdate']); |
|
686 | + $enddate = strtotime($args['enddate']); |
|
687 | + $dates['day_start'] = date('d', $startdate); |
|
688 | + $dates['day_end'] = date('d', $enddate); |
|
689 | + $dates['m_start'] = date('n', $startdate); |
|
690 | + $dates['m_end'] = date('n', $enddate); |
|
691 | + $dates['year'] = date('Y', $startdate); |
|
692 | + $dates['year_end'] = date('Y', $enddate); |
|
693 | 693 | } else { |
694 | 694 | // Modify dates based on predefined ranges |
695 | - switch ( $args['date'] ) : |
|
695 | + switch ($args['date']) : |
|
696 | 696 | |
697 | 697 | case 'this_month' : |
698 | 698 | $dates['day'] = null; |
699 | - $dates['m_start'] = date( 'n', $current_time ); |
|
700 | - $dates['m_end'] = date( 'n', $current_time ); |
|
701 | - $dates['year'] = date( 'Y', $current_time ); |
|
699 | + $dates['m_start'] = date('n', $current_time); |
|
700 | + $dates['m_end'] = date('n', $current_time); |
|
701 | + $dates['year'] = date('Y', $current_time); |
|
702 | 702 | break; |
703 | 703 | |
704 | 704 | case 'last_month' : |
705 | 705 | $dates['day'] = null; |
706 | - $dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1; |
|
706 | + $dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1; |
|
707 | 707 | $dates['m_end'] = $dates['m_start']; |
708 | - $dates['year'] = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time ); |
|
708 | + $dates['year'] = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time); |
|
709 | 709 | break; |
710 | 710 | |
711 | 711 | case 'today' : |
712 | - $dates['day'] = date( 'd', $current_time ); |
|
713 | - $dates['m_start'] = date( 'n', $current_time ); |
|
714 | - $dates['m_end'] = date( 'n', $current_time ); |
|
715 | - $dates['year'] = date( 'Y', $current_time ); |
|
712 | + $dates['day'] = date('d', $current_time); |
|
713 | + $dates['m_start'] = date('n', $current_time); |
|
714 | + $dates['m_end'] = date('n', $current_time); |
|
715 | + $dates['year'] = date('Y', $current_time); |
|
716 | 716 | break; |
717 | 717 | |
718 | 718 | case 'yesterday' : |
719 | 719 | |
720 | - $year = date( 'Y', $current_time ); |
|
721 | - $month = date( 'n', $current_time ); |
|
722 | - $day = date( 'd', $current_time ); |
|
720 | + $year = date('Y', $current_time); |
|
721 | + $month = date('n', $current_time); |
|
722 | + $day = date('d', $current_time); |
|
723 | 723 | |
724 | - if ( $month == 1 && $day == 1 ) { |
|
724 | + if ($month == 1 && $day == 1) { |
|
725 | 725 | |
726 | 726 | $year -= 1; |
727 | 727 | $month = 12; |
728 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
728 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
729 | 729 | |
730 | - } elseif ( $month > 1 && $day == 1 ) { |
|
730 | + } elseif ($month > 1 && $day == 1) { |
|
731 | 731 | |
732 | 732 | $month -= 1; |
733 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
733 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
734 | 734 | |
735 | 735 | } else { |
736 | 736 | |
@@ -746,65 +746,65 @@ discard block |
||
746 | 746 | break; |
747 | 747 | |
748 | 748 | case 'this_quarter' : |
749 | - $month_now = date( 'n', $current_time ); |
|
749 | + $month_now = date('n', $current_time); |
|
750 | 750 | |
751 | 751 | $dates['day'] = null; |
752 | 752 | |
753 | - if ( $month_now <= 3 ) { |
|
753 | + if ($month_now <= 3) { |
|
754 | 754 | |
755 | 755 | $dates['m_start'] = 1; |
756 | 756 | $dates['m_end'] = 3; |
757 | - $dates['year'] = date( 'Y', $current_time ); |
|
757 | + $dates['year'] = date('Y', $current_time); |
|
758 | 758 | |
759 | - } elseif ( $month_now <= 6 ) { |
|
759 | + } elseif ($month_now <= 6) { |
|
760 | 760 | |
761 | 761 | $dates['m_start'] = 4; |
762 | 762 | $dates['m_end'] = 6; |
763 | - $dates['year'] = date( 'Y', $current_time ); |
|
763 | + $dates['year'] = date('Y', $current_time); |
|
764 | 764 | |
765 | - } elseif ( $month_now <= 9 ) { |
|
765 | + } elseif ($month_now <= 9) { |
|
766 | 766 | |
767 | 767 | $dates['m_start'] = 7; |
768 | 768 | $dates['m_end'] = 9; |
769 | - $dates['year'] = date( 'Y', $current_time ); |
|
769 | + $dates['year'] = date('Y', $current_time); |
|
770 | 770 | |
771 | 771 | } else { |
772 | 772 | |
773 | 773 | $dates['m_start'] = 10; |
774 | 774 | $dates['m_end'] = 12; |
775 | - $dates['year'] = date( 'Y', $current_time ); |
|
775 | + $dates['year'] = date('Y', $current_time); |
|
776 | 776 | |
777 | 777 | } |
778 | 778 | break; |
779 | 779 | |
780 | 780 | case 'last_quarter' : |
781 | - $month_now = date( 'n', $current_time ); |
|
781 | + $month_now = date('n', $current_time); |
|
782 | 782 | |
783 | 783 | $dates['day'] = null; |
784 | 784 | |
785 | - if ( $month_now <= 3 ) { |
|
785 | + if ($month_now <= 3) { |
|
786 | 786 | |
787 | 787 | $dates['m_start'] = 10; |
788 | 788 | $dates['m_end'] = 12; |
789 | - $dates['year'] = date( 'Y', $current_time ) - 1; // Previous year |
|
789 | + $dates['year'] = date('Y', $current_time) - 1; // Previous year |
|
790 | 790 | |
791 | - } elseif ( $month_now <= 6 ) { |
|
791 | + } elseif ($month_now <= 6) { |
|
792 | 792 | |
793 | 793 | $dates['m_start'] = 1; |
794 | 794 | $dates['m_end'] = 3; |
795 | - $dates['year'] = date( 'Y', $current_time ); |
|
795 | + $dates['year'] = date('Y', $current_time); |
|
796 | 796 | |
797 | - } elseif ( $month_now <= 9 ) { |
|
797 | + } elseif ($month_now <= 9) { |
|
798 | 798 | |
799 | 799 | $dates['m_start'] = 4; |
800 | 800 | $dates['m_end'] = 6; |
801 | - $dates['year'] = date( 'Y', $current_time ); |
|
801 | + $dates['year'] = date('Y', $current_time); |
|
802 | 802 | |
803 | 803 | } else { |
804 | 804 | |
805 | 805 | $dates['m_start'] = 7; |
806 | 806 | $dates['m_end'] = 9; |
807 | - $dates['year'] = date( 'Y', $current_time ); |
|
807 | + $dates['year'] = date('Y', $current_time); |
|
808 | 808 | |
809 | 809 | } |
810 | 810 | break; |
@@ -813,14 +813,14 @@ discard block |
||
813 | 813 | $dates['day'] = null; |
814 | 814 | $dates['m_start'] = null; |
815 | 815 | $dates['m_end'] = null; |
816 | - $dates['year'] = date( 'Y', $current_time ); |
|
816 | + $dates['year'] = date('Y', $current_time); |
|
817 | 817 | break; |
818 | 818 | |
819 | 819 | case 'last_year' : |
820 | 820 | $dates['day'] = null; |
821 | 821 | $dates['m_start'] = null; |
822 | 822 | $dates['m_end'] = null; |
823 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
823 | + $dates['year'] = date('Y', $current_time) - 1; |
|
824 | 824 | break; |
825 | 825 | |
826 | 826 | endswitch; |
@@ -833,7 +833,7 @@ discard block |
||
833 | 833 | * |
834 | 834 | * @param array $dates The dates used for retrieving earnings/donations |
835 | 835 | */ |
836 | - return apply_filters( 'give_api_stat_dates', $dates ); |
|
836 | + return apply_filters('give_api_stat_dates', $dates); |
|
837 | 837 | } |
838 | 838 | |
839 | 839 | /** |
@@ -848,11 +848,11 @@ discard block |
||
848 | 848 | * |
849 | 849 | * @return array $customers Multidimensional array of the customers |
850 | 850 | */ |
851 | - public function get_customers( $customer = null ) { |
|
851 | + public function get_customers($customer = null) { |
|
852 | 852 | |
853 | 853 | $customers = array(); |
854 | 854 | $error = array(); |
855 | - if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) { |
|
855 | + if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) { |
|
856 | 856 | return $customers; |
857 | 857 | } |
858 | 858 | |
@@ -860,63 +860,63 @@ discard block |
||
860 | 860 | |
861 | 861 | $paged = $this->get_paged(); |
862 | 862 | $per_page = $this->per_page(); |
863 | - $offset = $per_page * ( $paged - 1 ); |
|
863 | + $offset = $per_page * ($paged - 1); |
|
864 | 864 | |
865 | - if ( is_numeric( $customer ) ) { |
|
865 | + if (is_numeric($customer)) { |
|
866 | 866 | $field = 'id'; |
867 | 867 | } else { |
868 | 868 | $field = 'email'; |
869 | 869 | } |
870 | 870 | |
871 | - $customer_query = Give()->customers->get_customers( array( |
|
871 | + $customer_query = Give()->customers->get_customers(array( |
|
872 | 872 | 'number' => $per_page, |
873 | 873 | 'offset' => $offset, |
874 | 874 | $field => $customer, |
875 | - ) ); |
|
875 | + )); |
|
876 | 876 | $customer_count = 0; |
877 | 877 | |
878 | - if ( $customer_query ) { |
|
878 | + if ($customer_query) { |
|
879 | 879 | |
880 | - foreach ( $customer_query as $customer_obj ) { |
|
880 | + foreach ($customer_query as $customer_obj) { |
|
881 | 881 | |
882 | - $names = explode( ' ', $customer_obj->name ); |
|
883 | - $first_name = ! empty( $names[0] ) ? $names[0] : ''; |
|
882 | + $names = explode(' ', $customer_obj->name); |
|
883 | + $first_name = ! empty($names[0]) ? $names[0] : ''; |
|
884 | 884 | $last_name = ''; |
885 | - if ( ! empty( $names[1] ) ) { |
|
886 | - unset( $names[0] ); |
|
887 | - $last_name = implode( ' ', $names ); |
|
885 | + if ( ! empty($names[1])) { |
|
886 | + unset($names[0]); |
|
887 | + $last_name = implode(' ', $names); |
|
888 | 888 | } |
889 | 889 | |
890 | - $customers['donors'][ $customer_count ]['info']['user_id'] = ''; |
|
891 | - $customers['donors'][ $customer_count ]['info']['username'] = ''; |
|
892 | - $customers['donors'][ $customer_count ]['info']['display_name'] = ''; |
|
893 | - $customers['donors'][ $customer_count ]['info']['customer_id'] = $customer_obj->id; |
|
894 | - $customers['donors'][ $customer_count ]['info']['first_name'] = $first_name; |
|
895 | - $customers['donors'][ $customer_count ]['info']['last_name'] = $last_name; |
|
896 | - $customers['donors'][ $customer_count ]['info']['email'] = $customer_obj->email; |
|
890 | + $customers['donors'][$customer_count]['info']['user_id'] = ''; |
|
891 | + $customers['donors'][$customer_count]['info']['username'] = ''; |
|
892 | + $customers['donors'][$customer_count]['info']['display_name'] = ''; |
|
893 | + $customers['donors'][$customer_count]['info']['customer_id'] = $customer_obj->id; |
|
894 | + $customers['donors'][$customer_count]['info']['first_name'] = $first_name; |
|
895 | + $customers['donors'][$customer_count]['info']['last_name'] = $last_name; |
|
896 | + $customers['donors'][$customer_count]['info']['email'] = $customer_obj->email; |
|
897 | 897 | |
898 | - if ( ! empty( $customer_obj->user_id ) ) { |
|
898 | + if ( ! empty($customer_obj->user_id)) { |
|
899 | 899 | |
900 | - $user_data = get_userdata( $customer_obj->user_id ); |
|
900 | + $user_data = get_userdata($customer_obj->user_id); |
|
901 | 901 | |
902 | 902 | // Customer with registered account. |
903 | - $customers['donors'][ $customer_count ]['info']['user_id'] = $customer_obj->user_id; |
|
904 | - $customers['donors'][ $customer_count ]['info']['username'] = $user_data->user_login; |
|
905 | - $customers['donors'][ $customer_count ]['info']['display_name'] = $user_data->display_name; |
|
903 | + $customers['donors'][$customer_count]['info']['user_id'] = $customer_obj->user_id; |
|
904 | + $customers['donors'][$customer_count]['info']['username'] = $user_data->user_login; |
|
905 | + $customers['donors'][$customer_count]['info']['display_name'] = $user_data->display_name; |
|
906 | 906 | |
907 | 907 | } |
908 | 908 | |
909 | - $customers['donors'][ $customer_count ]['stats']['total_donations'] = $customer_obj->purchase_count; |
|
910 | - $customers['donors'][ $customer_count ]['stats']['total_spent'] = $customer_obj->purchase_value; |
|
909 | + $customers['donors'][$customer_count]['stats']['total_donations'] = $customer_obj->purchase_count; |
|
910 | + $customers['donors'][$customer_count]['stats']['total_spent'] = $customer_obj->purchase_value; |
|
911 | 911 | |
912 | - $customer_count ++; |
|
912 | + $customer_count++; |
|
913 | 913 | |
914 | 914 | } |
915 | - } elseif ( $customer ) { |
|
915 | + } elseif ($customer) { |
|
916 | 916 | |
917 | 917 | $error['error'] = sprintf( |
918 | 918 | /* translators: %s: customer */ |
919 | - esc_html__( 'Donor %s not found.', 'give' ), |
|
919 | + esc_html__('Donor %s not found.', 'give'), |
|
920 | 920 | $customer |
921 | 921 | ); |
922 | 922 | |
@@ -924,7 +924,7 @@ discard block |
||
924 | 924 | |
925 | 925 | } else { |
926 | 926 | |
927 | - $error['error'] = esc_html__( 'No donors found.', 'give' ); |
|
927 | + $error['error'] = esc_html__('No donors found.', 'give'); |
|
928 | 928 | |
929 | 929 | return $error; |
930 | 930 | |
@@ -943,38 +943,38 @@ discard block |
||
943 | 943 | * |
944 | 944 | * @return array $customers Multidimensional array of the forms |
945 | 945 | */ |
946 | - public function get_forms( $form = null ) { |
|
946 | + public function get_forms($form = null) { |
|
947 | 947 | |
948 | 948 | $forms = array(); |
949 | 949 | $error = array(); |
950 | 950 | |
951 | - if ( $form == null ) { |
|
951 | + if ($form == null) { |
|
952 | 952 | $forms['forms'] = array(); |
953 | 953 | |
954 | - $form_list = get_posts( array( |
|
954 | + $form_list = get_posts(array( |
|
955 | 955 | 'post_type' => 'give_forms', |
956 | 956 | 'posts_per_page' => $this->per_page(), |
957 | 957 | 'suppress_filters' => true, |
958 | 958 | 'paged' => $this->get_paged(), |
959 | - ) ); |
|
959 | + )); |
|
960 | 960 | |
961 | - if ( $form_list ) { |
|
961 | + if ($form_list) { |
|
962 | 962 | $i = 0; |
963 | - foreach ( $form_list as $form_info ) { |
|
964 | - $forms['forms'][ $i ] = $this->get_form_data( $form_info ); |
|
965 | - $i ++; |
|
963 | + foreach ($form_list as $form_info) { |
|
964 | + $forms['forms'][$i] = $this->get_form_data($form_info); |
|
965 | + $i++; |
|
966 | 966 | } |
967 | 967 | } |
968 | 968 | } else { |
969 | - if ( get_post_type( $form ) == 'give_forms' ) { |
|
970 | - $form_info = get_post( $form ); |
|
969 | + if (get_post_type($form) == 'give_forms') { |
|
970 | + $form_info = get_post($form); |
|
971 | 971 | |
972 | - $forms['forms'][0] = $this->get_form_data( $form_info ); |
|
972 | + $forms['forms'][0] = $this->get_form_data($form_info); |
|
973 | 973 | |
974 | 974 | } else { |
975 | 975 | $error['error'] = sprintf( |
976 | 976 | /* translators: %s: form */ |
977 | - esc_html__( 'Form %s not found.', 'give' ), |
|
977 | + esc_html__('Form %s not found.', 'give'), |
|
978 | 978 | $form |
979 | 979 | ); |
980 | 980 | |
@@ -994,7 +994,7 @@ discard block |
||
994 | 994 | * |
995 | 995 | * @return array Array of post data to return back in the API |
996 | 996 | */ |
997 | - private function get_form_data( $form_info ) { |
|
997 | + private function get_form_data($form_info) { |
|
998 | 998 | |
999 | 999 | $form = array(); |
1000 | 1000 | |
@@ -1004,50 +1004,50 @@ discard block |
||
1004 | 1004 | $form['info']['create_date'] = $form_info->post_date; |
1005 | 1005 | $form['info']['modified_date'] = $form_info->post_modified; |
1006 | 1006 | $form['info']['status'] = $form_info->post_status; |
1007 | - $form['info']['link'] = html_entity_decode( $form_info->guid ); |
|
1008 | - $form['info']['content'] = get_post_meta( $form_info->ID, '_give_form_content', true ); |
|
1009 | - $form['info']['thumbnail'] = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) ); |
|
1007 | + $form['info']['link'] = html_entity_decode($form_info->guid); |
|
1008 | + $form['info']['content'] = get_post_meta($form_info->ID, '_give_form_content', true); |
|
1009 | + $form['info']['thumbnail'] = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID)); |
|
1010 | 1010 | |
1011 | - if ( give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) { |
|
1012 | - $form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' ); |
|
1013 | - $form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' ); |
|
1011 | + if (give_is_setting_enabled(give_get_option('categories', 'disabled'))) { |
|
1012 | + $form['info']['category'] = get_the_terms($form_info, 'give_forms_category'); |
|
1013 | + $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag'); |
|
1014 | 1014 | } |
1015 | - if ( give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) { |
|
1016 | - $form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' ); |
|
1015 | + if (give_is_setting_enabled(give_get_option('tags', 'disabled'))) { |
|
1016 | + $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag'); |
|
1017 | 1017 | } |
1018 | 1018 | |
1019 | - if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) { |
|
1020 | - $form['stats']['total']['donations'] = give_get_form_sales_stats( $form_info->ID ); |
|
1021 | - $form['stats']['total']['earnings'] = give_get_form_earnings_stats( $form_info->ID ); |
|
1022 | - $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID ); |
|
1023 | - $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings( $form_info->ID ); |
|
1019 | + if (user_can($this->user_id, 'view_give_reports') || $this->override) { |
|
1020 | + $form['stats']['total']['donations'] = give_get_form_sales_stats($form_info->ID); |
|
1021 | + $form['stats']['total']['earnings'] = give_get_form_earnings_stats($form_info->ID); |
|
1022 | + $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID); |
|
1023 | + $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings($form_info->ID); |
|
1024 | 1024 | } |
1025 | 1025 | |
1026 | 1026 | $counter = 0; |
1027 | - if ( give_has_variable_prices( $form_info->ID ) ) { |
|
1028 | - foreach ( give_get_variable_prices( $form_info->ID ) as $price ) { |
|
1029 | - $counter ++; |
|
1027 | + if (give_has_variable_prices($form_info->ID)) { |
|
1028 | + foreach (give_get_variable_prices($form_info->ID) as $price) { |
|
1029 | + $counter++; |
|
1030 | 1030 | // muli-level item |
1031 | - $level = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter; |
|
1032 | - $form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount']; |
|
1031 | + $level = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter; |
|
1032 | + $form['pricing'][sanitize_key($level)] = $price['_give_amount']; |
|
1033 | 1033 | |
1034 | 1034 | } |
1035 | 1035 | } else { |
1036 | - $form['pricing']['amount'] = give_get_form_price( $form_info->ID ); |
|
1036 | + $form['pricing']['amount'] = give_get_form_price($form_info->ID); |
|
1037 | 1037 | } |
1038 | 1038 | |
1039 | - if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) { |
|
1039 | + if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) { |
|
1040 | 1040 | |
1041 | 1041 | /** |
1042 | 1042 | * Fires when generating API sensitive data. |
1043 | 1043 | * |
1044 | 1044 | * @since 1.1 |
1045 | 1045 | */ |
1046 | - do_action( 'give_api_sensitive_data' ); |
|
1046 | + do_action('give_api_sensitive_data'); |
|
1047 | 1047 | |
1048 | 1048 | } |
1049 | 1049 | |
1050 | - return apply_filters( 'give_api_forms_form', $form ); |
|
1050 | + return apply_filters('give_api_forms_form', $form); |
|
1051 | 1051 | |
1052 | 1052 | } |
1053 | 1053 | |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | * |
1063 | 1063 | * @return array |
1064 | 1064 | */ |
1065 | - public function get_stats( $args = array() ) { |
|
1065 | + public function get_stats($args = array()) { |
|
1066 | 1066 | $defaults = array( |
1067 | 1067 | 'type' => null, |
1068 | 1068 | 'form' => null, |
@@ -1071,9 +1071,9 @@ discard block |
||
1071 | 1071 | 'enddate' => null, |
1072 | 1072 | ); |
1073 | 1073 | |
1074 | - $args = wp_parse_args( $args, $defaults ); |
|
1074 | + $args = wp_parse_args($args, $defaults); |
|
1075 | 1075 | |
1076 | - $dates = $this->get_dates( $args ); |
|
1076 | + $dates = $this->get_dates($args); |
|
1077 | 1077 | |
1078 | 1078 | $stats = array(); |
1079 | 1079 | $earnings = array( |
@@ -1084,40 +1084,40 @@ discard block |
||
1084 | 1084 | ); |
1085 | 1085 | $error = array(); |
1086 | 1086 | |
1087 | - if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) { |
|
1087 | + if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) { |
|
1088 | 1088 | return $stats; |
1089 | 1089 | } |
1090 | 1090 | |
1091 | - if ( $args['type'] == 'donations' ) { |
|
1091 | + if ($args['type'] == 'donations') { |
|
1092 | 1092 | |
1093 | - if ( $args['form'] == null ) { |
|
1094 | - if ( $args['date'] == null ) { |
|
1093 | + if ($args['form'] == null) { |
|
1094 | + if ($args['date'] == null) { |
|
1095 | 1095 | $sales = $this->get_default_sales_stats(); |
1096 | - } elseif ( $args['date'] === 'range' ) { |
|
1096 | + } elseif ($args['date'] === 'range') { |
|
1097 | 1097 | // Return sales for a date range |
1098 | 1098 | // Ensure the end date is later than the start date |
1099 | - if ( $args['enddate'] < $args['startdate'] ) { |
|
1100 | - $error['error'] = esc_html__( 'The end date must be later than the start date.', 'give' ); |
|
1099 | + if ($args['enddate'] < $args['startdate']) { |
|
1100 | + $error['error'] = esc_html__('The end date must be later than the start date.', 'give'); |
|
1101 | 1101 | } |
1102 | 1102 | |
1103 | 1103 | // Ensure both the start and end date are specified |
1104 | - if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) { |
|
1105 | - $error['error'] = esc_html__( 'Invalid or no date range specified.', 'give' ); |
|
1104 | + if (empty($args['startdate']) || empty($args['enddate'])) { |
|
1105 | + $error['error'] = esc_html__('Invalid or no date range specified.', 'give'); |
|
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | $total = 0; |
1109 | 1109 | |
1110 | 1110 | // Loop through the years |
1111 | 1111 | $y = $dates['year']; |
1112 | - while ( $y <= $dates['year_end'] ) : |
|
1112 | + while ($y <= $dates['year_end']) : |
|
1113 | 1113 | |
1114 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
1114 | + if ($dates['year'] == $dates['year_end']) { |
|
1115 | 1115 | $month_start = $dates['m_start']; |
1116 | 1116 | $month_end = $dates['m_end']; |
1117 | - } elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { |
|
1117 | + } elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) { |
|
1118 | 1118 | $month_start = $dates['m_start']; |
1119 | 1119 | $month_end = 12; |
1120 | - } elseif ( $y == $dates['year_end'] ) { |
|
1120 | + } elseif ($y == $dates['year_end']) { |
|
1121 | 1121 | $month_start = 1; |
1122 | 1122 | $month_end = $dates['m_end']; |
1123 | 1123 | } else { |
@@ -1126,112 +1126,112 @@ discard block |
||
1126 | 1126 | } |
1127 | 1127 | |
1128 | 1128 | $i = $month_start; |
1129 | - while ( $i <= $month_end ) : |
|
1129 | + while ($i <= $month_end) : |
|
1130 | 1130 | |
1131 | - if ( $i == $dates['m_start'] ) { |
|
1131 | + if ($i == $dates['m_start']) { |
|
1132 | 1132 | $d = $dates['day_start']; |
1133 | 1133 | } else { |
1134 | 1134 | $d = 1; |
1135 | 1135 | } |
1136 | 1136 | |
1137 | - if ( $i == $dates['m_end'] ) { |
|
1137 | + if ($i == $dates['m_end']) { |
|
1138 | 1138 | $num_of_days = $dates['day_end']; |
1139 | 1139 | } else { |
1140 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
1140 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
1141 | 1141 | } |
1142 | 1142 | |
1143 | - while ( $d <= $num_of_days ) : |
|
1144 | - $sale_count = give_get_sales_by_date( $d, $i, $y ); |
|
1145 | - $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); |
|
1146 | - if ( ! isset( $sales['sales'][ $date_key ] ) ) { |
|
1147 | - $sales['sales'][ $date_key ] = 0; |
|
1143 | + while ($d <= $num_of_days) : |
|
1144 | + $sale_count = give_get_sales_by_date($d, $i, $y); |
|
1145 | + $date_key = date('Ymd', strtotime($y.'/'.$i.'/'.$d)); |
|
1146 | + if ( ! isset($sales['sales'][$date_key])) { |
|
1147 | + $sales['sales'][$date_key] = 0; |
|
1148 | 1148 | } |
1149 | - $sales['sales'][ $date_key ] += $sale_count; |
|
1149 | + $sales['sales'][$date_key] += $sale_count; |
|
1150 | 1150 | $total += $sale_count; |
1151 | - $d ++; |
|
1151 | + $d++; |
|
1152 | 1152 | endwhile; |
1153 | - $i ++; |
|
1153 | + $i++; |
|
1154 | 1154 | endwhile; |
1155 | 1155 | |
1156 | - $y ++; |
|
1156 | + $y++; |
|
1157 | 1157 | endwhile; |
1158 | 1158 | |
1159 | 1159 | $sales['totals'] = $total; |
1160 | 1160 | } else { |
1161 | - if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) { |
|
1161 | + if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') { |
|
1162 | 1162 | $sales_count = 0; |
1163 | 1163 | |
1164 | 1164 | // Loop through the months |
1165 | 1165 | $month = $dates['m_start']; |
1166 | 1166 | |
1167 | - while ( $month <= $dates['m_end'] ) : |
|
1168 | - $sales_count += give_get_sales_by_date( null, $month, $dates['year'] ); |
|
1169 | - $month ++; |
|
1167 | + while ($month <= $dates['m_end']) : |
|
1168 | + $sales_count += give_get_sales_by_date(null, $month, $dates['year']); |
|
1169 | + $month++; |
|
1170 | 1170 | endwhile; |
1171 | 1171 | |
1172 | - $sales['donations'][ $args['date'] ] = $sales_count; |
|
1172 | + $sales['donations'][$args['date']] = $sales_count; |
|
1173 | 1173 | } else { |
1174 | - $sales['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] ); |
|
1174 | + $sales['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']); |
|
1175 | 1175 | } |
1176 | 1176 | } |
1177 | - } elseif ( $args['form'] == 'all' ) { |
|
1178 | - $forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) ); |
|
1177 | + } elseif ($args['form'] == 'all') { |
|
1178 | + $forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true)); |
|
1179 | 1179 | $i = 0; |
1180 | - foreach ( $forms as $form_info ) { |
|
1181 | - $sales['donations'][ $i ] = array( $form_info->post_name => give_get_form_sales_stats( $form_info->ID ) ); |
|
1182 | - $i ++; |
|
1180 | + foreach ($forms as $form_info) { |
|
1181 | + $sales['donations'][$i] = array($form_info->post_name => give_get_form_sales_stats($form_info->ID)); |
|
1182 | + $i++; |
|
1183 | 1183 | } |
1184 | 1184 | } else { |
1185 | - if ( get_post_type( $args['form'] ) == 'give_forms' ) { |
|
1186 | - $form_info = get_post( $args['form'] ); |
|
1187 | - $sales['donations'][0] = array( $form_info->post_name => give_get_form_sales_stats( $args['form'] ) ); |
|
1185 | + if (get_post_type($args['form']) == 'give_forms') { |
|
1186 | + $form_info = get_post($args['form']); |
|
1187 | + $sales['donations'][0] = array($form_info->post_name => give_get_form_sales_stats($args['form'])); |
|
1188 | 1188 | } else { |
1189 | 1189 | $error['error'] = sprintf( |
1190 | 1190 | /* translators: %s: form */ |
1191 | - esc_html__( 'Form %s not found.', 'give' ), |
|
1191 | + esc_html__('Form %s not found.', 'give'), |
|
1192 | 1192 | $args['form'] |
1193 | 1193 | ); |
1194 | 1194 | } |
1195 | 1195 | } |
1196 | 1196 | |
1197 | - if ( ! empty( $error ) ) { |
|
1197 | + if ( ! empty($error)) { |
|
1198 | 1198 | return $error; |
1199 | 1199 | } |
1200 | 1200 | |
1201 | 1201 | return $sales; |
1202 | 1202 | |
1203 | - } elseif ( $args['type'] == 'earnings' ) { |
|
1204 | - if ( $args['form'] == null ) { |
|
1205 | - if ( $args['date'] == null ) { |
|
1203 | + } elseif ($args['type'] == 'earnings') { |
|
1204 | + if ($args['form'] == null) { |
|
1205 | + if ($args['date'] == null) { |
|
1206 | 1206 | $earnings = $this->get_default_earnings_stats(); |
1207 | - } elseif ( $args['date'] === 'range' ) { |
|
1207 | + } elseif ($args['date'] === 'range') { |
|
1208 | 1208 | // Return sales for a date range |
1209 | 1209 | // Ensure the end date is later than the start date |
1210 | - if ( $args['enddate'] < $args['startdate'] ) { |
|
1211 | - $error['error'] = esc_html__( 'The end date must be later than the start date.', 'give' ); |
|
1210 | + if ($args['enddate'] < $args['startdate']) { |
|
1211 | + $error['error'] = esc_html__('The end date must be later than the start date.', 'give'); |
|
1212 | 1212 | } |
1213 | 1213 | |
1214 | 1214 | // Ensure both the start and end date are specified |
1215 | - if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) { |
|
1216 | - $error['error'] = esc_html__( 'Invalid or no date range specified.', 'give' ); |
|
1215 | + if (empty($args['startdate']) || empty($args['enddate'])) { |
|
1216 | + $error['error'] = esc_html__('Invalid or no date range specified.', 'give'); |
|
1217 | 1217 | } |
1218 | 1218 | |
1219 | 1219 | $total = (float) 0.00; |
1220 | 1220 | |
1221 | 1221 | // Loop through the years |
1222 | 1222 | $y = $dates['year']; |
1223 | - if ( ! isset( $earnings['earnings'] ) ) { |
|
1223 | + if ( ! isset($earnings['earnings'])) { |
|
1224 | 1224 | $earnings['earnings'] = array(); |
1225 | 1225 | } |
1226 | - while ( $y <= $dates['year_end'] ) : |
|
1226 | + while ($y <= $dates['year_end']) : |
|
1227 | 1227 | |
1228 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
1228 | + if ($dates['year'] == $dates['year_end']) { |
|
1229 | 1229 | $month_start = $dates['m_start']; |
1230 | 1230 | $month_end = $dates['m_end']; |
1231 | - } elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { |
|
1231 | + } elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) { |
|
1232 | 1232 | $month_start = $dates['m_start']; |
1233 | 1233 | $month_end = 12; |
1234 | - } elseif ( $y == $dates['year_end'] ) { |
|
1234 | + } elseif ($y == $dates['year_end']) { |
|
1235 | 1235 | $month_start = 1; |
1236 | 1236 | $month_end = $dates['m_end']; |
1237 | 1237 | } else { |
@@ -1240,92 +1240,92 @@ discard block |
||
1240 | 1240 | } |
1241 | 1241 | |
1242 | 1242 | $i = $month_start; |
1243 | - while ( $i <= $month_end ) : |
|
1243 | + while ($i <= $month_end) : |
|
1244 | 1244 | |
1245 | - if ( $i == $dates['m_start'] ) { |
|
1245 | + if ($i == $dates['m_start']) { |
|
1246 | 1246 | $d = $dates['day_start']; |
1247 | 1247 | } else { |
1248 | 1248 | $d = 1; |
1249 | 1249 | } |
1250 | 1250 | |
1251 | - if ( $i == $dates['m_end'] ) { |
|
1251 | + if ($i == $dates['m_end']) { |
|
1252 | 1252 | $num_of_days = $dates['day_end']; |
1253 | 1253 | } else { |
1254 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
1254 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
1255 | 1255 | } |
1256 | 1256 | |
1257 | - while ( $d <= $num_of_days ) : |
|
1258 | - $earnings_stat = give_get_earnings_by_date( $d, $i, $y ); |
|
1259 | - $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); |
|
1260 | - if ( ! isset( $earnings['earnings'][ $date_key ] ) ) { |
|
1261 | - $earnings['earnings'][ $date_key ] = 0; |
|
1257 | + while ($d <= $num_of_days) : |
|
1258 | + $earnings_stat = give_get_earnings_by_date($d, $i, $y); |
|
1259 | + $date_key = date('Ymd', strtotime($y.'/'.$i.'/'.$d)); |
|
1260 | + if ( ! isset($earnings['earnings'][$date_key])) { |
|
1261 | + $earnings['earnings'][$date_key] = 0; |
|
1262 | 1262 | } |
1263 | - $earnings['earnings'][ $date_key ] += $earnings_stat; |
|
1263 | + $earnings['earnings'][$date_key] += $earnings_stat; |
|
1264 | 1264 | $total += $earnings_stat; |
1265 | - $d ++; |
|
1265 | + $d++; |
|
1266 | 1266 | endwhile; |
1267 | 1267 | |
1268 | - $i ++; |
|
1268 | + $i++; |
|
1269 | 1269 | endwhile; |
1270 | 1270 | |
1271 | - $y ++; |
|
1271 | + $y++; |
|
1272 | 1272 | endwhile; |
1273 | 1273 | |
1274 | 1274 | $earnings['totals'] = $total; |
1275 | 1275 | } else { |
1276 | - if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) { |
|
1276 | + if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') { |
|
1277 | 1277 | $earnings_count = (float) 0.00; |
1278 | 1278 | |
1279 | 1279 | // Loop through the months |
1280 | 1280 | $month = $dates['m_start']; |
1281 | 1281 | |
1282 | - while ( $month <= $dates['m_end'] ) : |
|
1283 | - $earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] ); |
|
1284 | - $month ++; |
|
1282 | + while ($month <= $dates['m_end']) : |
|
1283 | + $earnings_count += give_get_earnings_by_date(null, $month, $dates['year']); |
|
1284 | + $month++; |
|
1285 | 1285 | endwhile; |
1286 | 1286 | |
1287 | - $earnings['earnings'][ $args['date'] ] = $earnings_count; |
|
1287 | + $earnings['earnings'][$args['date']] = $earnings_count; |
|
1288 | 1288 | } else { |
1289 | - $earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] ); |
|
1289 | + $earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']); |
|
1290 | 1290 | } |
1291 | 1291 | } |
1292 | - } elseif ( $args['form'] == 'all' ) { |
|
1293 | - $forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) ); |
|
1292 | + } elseif ($args['form'] == 'all') { |
|
1293 | + $forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true)); |
|
1294 | 1294 | |
1295 | 1295 | $i = 0; |
1296 | - foreach ( $forms as $form_info ) { |
|
1297 | - $earnings['earnings'][ $i ] = array( $form_info->post_name => give_get_form_earnings_stats( $form_info->ID ) ); |
|
1298 | - $i ++; |
|
1296 | + foreach ($forms as $form_info) { |
|
1297 | + $earnings['earnings'][$i] = array($form_info->post_name => give_get_form_earnings_stats($form_info->ID)); |
|
1298 | + $i++; |
|
1299 | 1299 | } |
1300 | 1300 | } else { |
1301 | - if ( get_post_type( $args['form'] ) == 'give_forms' ) { |
|
1302 | - $form_info = get_post( $args['form'] ); |
|
1303 | - $earnings['earnings'][0] = array( $form_info->post_name => give_get_form_earnings_stats( $args['form'] ) ); |
|
1301 | + if (get_post_type($args['form']) == 'give_forms') { |
|
1302 | + $form_info = get_post($args['form']); |
|
1303 | + $earnings['earnings'][0] = array($form_info->post_name => give_get_form_earnings_stats($args['form'])); |
|
1304 | 1304 | } else { |
1305 | 1305 | $error['error'] = sprintf( |
1306 | 1306 | /* translators: %s: form */ |
1307 | - esc_html__( 'Form %s not found.', 'give' ), |
|
1307 | + esc_html__('Form %s not found.', 'give'), |
|
1308 | 1308 | $args['form'] |
1309 | 1309 | ); |
1310 | 1310 | } |
1311 | 1311 | } |
1312 | 1312 | |
1313 | - if ( ! empty( $error ) ) { |
|
1313 | + if ( ! empty($error)) { |
|
1314 | 1314 | return $error; |
1315 | 1315 | } |
1316 | 1316 | |
1317 | 1317 | return $earnings; |
1318 | - } elseif ( $args['type'] == 'donors' ) { |
|
1318 | + } elseif ($args['type'] == 'donors') { |
|
1319 | 1319 | $customers = new Give_DB_Customers(); |
1320 | 1320 | $stats['donations']['total_donors'] = $customers->count(); |
1321 | 1321 | |
1322 | 1322 | return $stats; |
1323 | 1323 | |
1324 | - } elseif ( empty( $args['type'] ) ) { |
|
1325 | - $stats = array_merge( $stats, $this->get_default_sales_stats() ); |
|
1326 | - $stats = array_merge( $stats, $this->get_default_earnings_stats() ); |
|
1324 | + } elseif (empty($args['type'])) { |
|
1325 | + $stats = array_merge($stats, $this->get_default_sales_stats()); |
|
1326 | + $stats = array_merge($stats, $this->get_default_earnings_stats()); |
|
1327 | 1327 | |
1328 | - return array( 'stats' => $stats ); |
|
1328 | + return array('stats' => $stats); |
|
1329 | 1329 | } |
1330 | 1330 | } |
1331 | 1331 | |
@@ -1341,18 +1341,18 @@ discard block |
||
1341 | 1341 | |
1342 | 1342 | $sales = array(); |
1343 | 1343 | |
1344 | - if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) { |
|
1344 | + if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) { |
|
1345 | 1345 | return $sales; |
1346 | 1346 | } |
1347 | 1347 | |
1348 | - if ( isset( $wp_query->query_vars['id'] ) ) { |
|
1348 | + if (isset($wp_query->query_vars['id'])) { |
|
1349 | 1349 | $query = array(); |
1350 | - $query[] = new Give_Payment( $wp_query->query_vars['id'] ); |
|
1351 | - } elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) { |
|
1350 | + $query[] = new Give_Payment($wp_query->query_vars['id']); |
|
1351 | + } elseif (isset($wp_query->query_vars['purchasekey'])) { |
|
1352 | 1352 | $query = array(); |
1353 | - $query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] ); |
|
1354 | - } elseif ( isset( $wp_query->query_vars['email'] ) ) { |
|
1355 | - $args = array( |
|
1353 | + $query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']); |
|
1354 | + } elseif (isset($wp_query->query_vars['email'])) { |
|
1355 | + $args = array( |
|
1356 | 1356 | 'fields' => 'ids', |
1357 | 1357 | 'meta_key' => '_give_payment_user_email', |
1358 | 1358 | 'meta_value' => $wp_query->query_vars['email'], |
@@ -1360,7 +1360,7 @@ discard block |
||
1360 | 1360 | 'page' => $this->get_paged(), |
1361 | 1361 | 'status' => 'publish', |
1362 | 1362 | ); |
1363 | - $query = give_get_payments( $args ); |
|
1363 | + $query = give_get_payments($args); |
|
1364 | 1364 | } else { |
1365 | 1365 | $args = array( |
1366 | 1366 | 'fields' => 'ids', |
@@ -1368,14 +1368,14 @@ discard block |
||
1368 | 1368 | 'page' => $this->get_paged(), |
1369 | 1369 | 'status' => 'publish', |
1370 | 1370 | ); |
1371 | - $query = give_get_payments( $args ); |
|
1371 | + $query = give_get_payments($args); |
|
1372 | 1372 | } |
1373 | - if ( $query ) { |
|
1373 | + if ($query) { |
|
1374 | 1374 | $i = 0; |
1375 | - foreach ( $query as $payment ) { |
|
1375 | + foreach ($query as $payment) { |
|
1376 | 1376 | |
1377 | - if ( is_numeric( $payment ) ) { |
|
1378 | - $payment = new Give_Payment( $payment ); |
|
1377 | + if (is_numeric($payment)) { |
|
1378 | + $payment = new Give_Payment($payment); |
|
1379 | 1379 | $payment_meta = $payment->get_meta(); |
1380 | 1380 | $user_info = $payment->user_info; |
1381 | 1381 | } else { |
@@ -1385,40 +1385,40 @@ discard block |
||
1385 | 1385 | $payment_meta = $payment->get_meta(); |
1386 | 1386 | $user_info = $payment->user_info; |
1387 | 1387 | |
1388 | - $first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : ''; |
|
1389 | - $last_name = isset( $user_info['last_name'] ) ? $user_info['last_name'] : ''; |
|
1390 | - |
|
1391 | - $sales['donations'][ $i ]['ID'] = $payment->number; |
|
1392 | - $sales['donations'][ $i ]['transaction_id'] = $payment->transaction_id; |
|
1393 | - $sales['donations'][ $i ]['key'] = $payment->key; |
|
1394 | - $sales['donations'][ $i ]['total'] = $payment->total; |
|
1395 | - $sales['donations'][ $i ]['gateway'] = $payment->gateway; |
|
1396 | - $sales['donations'][ $i ]['name'] = $first_name . ' ' . $last_name; |
|
1397 | - $sales['donations'][ $i ]['fname'] = $first_name; |
|
1398 | - $sales['donations'][ $i ]['lname'] = $last_name; |
|
1399 | - $sales['donations'][ $i ]['email'] = $payment->email; |
|
1400 | - $sales['donations'][ $i ]['date'] = $payment->date; |
|
1401 | - |
|
1402 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta; |
|
1403 | - $price = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false; |
|
1404 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
1405 | - |
|
1406 | - $sales['donations'][ $i ]['form']['id'] = $form_id; |
|
1407 | - $sales['donations'][ $i ]['form']['name'] = get_the_title( $payment_meta['form_id'] ); |
|
1408 | - $sales['donations'][ $i ]['form']['price'] = $price; |
|
1409 | - |
|
1410 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1411 | - if ( isset( $payment_meta['price_id'] ) ) { |
|
1412 | - $price_name = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID ); |
|
1413 | - $sales['donations'][ $i ]['form']['price_name'] = $price_name; |
|
1414 | - $sales['donations'][ $i ]['form']['price_id'] = $price_id; |
|
1415 | - $sales['donations'][ $i ]['form']['price'] = give_get_price_option_amount( $form_id, $price_id ); |
|
1388 | + $first_name = isset($user_info['first_name']) ? $user_info['first_name'] : ''; |
|
1389 | + $last_name = isset($user_info['last_name']) ? $user_info['last_name'] : ''; |
|
1390 | + |
|
1391 | + $sales['donations'][$i]['ID'] = $payment->number; |
|
1392 | + $sales['donations'][$i]['transaction_id'] = $payment->transaction_id; |
|
1393 | + $sales['donations'][$i]['key'] = $payment->key; |
|
1394 | + $sales['donations'][$i]['total'] = $payment->total; |
|
1395 | + $sales['donations'][$i]['gateway'] = $payment->gateway; |
|
1396 | + $sales['donations'][$i]['name'] = $first_name.' '.$last_name; |
|
1397 | + $sales['donations'][$i]['fname'] = $first_name; |
|
1398 | + $sales['donations'][$i]['lname'] = $last_name; |
|
1399 | + $sales['donations'][$i]['email'] = $payment->email; |
|
1400 | + $sales['donations'][$i]['date'] = $payment->date; |
|
1401 | + |
|
1402 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta; |
|
1403 | + $price = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false; |
|
1404 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
1405 | + |
|
1406 | + $sales['donations'][$i]['form']['id'] = $form_id; |
|
1407 | + $sales['donations'][$i]['form']['name'] = get_the_title($payment_meta['form_id']); |
|
1408 | + $sales['donations'][$i]['form']['price'] = $price; |
|
1409 | + |
|
1410 | + if (give_has_variable_prices($form_id)) { |
|
1411 | + if (isset($payment_meta['price_id'])) { |
|
1412 | + $price_name = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID); |
|
1413 | + $sales['donations'][$i]['form']['price_name'] = $price_name; |
|
1414 | + $sales['donations'][$i]['form']['price_id'] = $price_id; |
|
1415 | + $sales['donations'][$i]['form']['price'] = give_get_price_option_amount($form_id, $price_id); |
|
1416 | 1416 | |
1417 | 1417 | } |
1418 | 1418 | } |
1419 | 1419 | |
1420 | 1420 | // Add custom meta to API |
1421 | - foreach ( $payment_meta as $meta_key => $meta_value ) { |
|
1421 | + foreach ($payment_meta as $meta_key => $meta_value) { |
|
1422 | 1422 | |
1423 | 1423 | $exceptions = array( |
1424 | 1424 | 'form_title', |
@@ -1431,19 +1431,19 @@ discard block |
||
1431 | 1431 | ); |
1432 | 1432 | |
1433 | 1433 | // Don't clutter up results with dupes |
1434 | - if ( in_array( $meta_key, $exceptions ) ) { |
|
1434 | + if (in_array($meta_key, $exceptions)) { |
|
1435 | 1435 | continue; |
1436 | 1436 | } |
1437 | 1437 | |
1438 | - $sales['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value; |
|
1438 | + $sales['donations'][$i]['payment_meta'][$meta_key] = $meta_value; |
|
1439 | 1439 | |
1440 | 1440 | } |
1441 | 1441 | |
1442 | - $i ++; |
|
1442 | + $i++; |
|
1443 | 1443 | } |
1444 | 1444 | } |
1445 | 1445 | |
1446 | - return apply_filters( 'give_api_donations_endpoint', $sales ); |
|
1446 | + return apply_filters('give_api_donations_endpoint', $sales); |
|
1447 | 1447 | } |
1448 | 1448 | |
1449 | 1449 | /** |
@@ -1459,9 +1459,9 @@ discard block |
||
1459 | 1459 | public function get_output_format() { |
1460 | 1460 | global $wp_query; |
1461 | 1461 | |
1462 | - $format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json'; |
|
1462 | + $format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json'; |
|
1463 | 1463 | |
1464 | - return apply_filters( 'give_api_output_format', $format ); |
|
1464 | + return apply_filters('give_api_output_format', $format); |
|
1465 | 1465 | } |
1466 | 1466 | |
1467 | 1467 | |
@@ -1478,8 +1478,8 @@ discard block |
||
1478 | 1478 | * |
1479 | 1479 | * @return void |
1480 | 1480 | */ |
1481 | - private function log_request( $data = array() ) { |
|
1482 | - if ( ! $this->log_requests ) { |
|
1481 | + private function log_request($data = array()) { |
|
1482 | + if ( ! $this->log_requests) { |
|
1483 | 1483 | return; |
1484 | 1484 | } |
1485 | 1485 | |
@@ -1495,36 +1495,36 @@ discard block |
||
1495 | 1495 | |
1496 | 1496 | $query = array( |
1497 | 1497 | 'give-api' => $wp_query->query_vars['give-api'], |
1498 | - 'key' => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null, |
|
1499 | - 'token' => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null, |
|
1500 | - 'query' => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null, |
|
1501 | - 'type' => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null, |
|
1502 | - 'form' => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null, |
|
1503 | - 'customer' => isset( $wp_query->query_vars['customer'] ) ? $wp_query->query_vars['customer'] : null, |
|
1504 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
1505 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
1506 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, |
|
1507 | - 'id' => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null, |
|
1508 | - 'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null, |
|
1509 | - 'email' => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null, |
|
1498 | + 'key' => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null, |
|
1499 | + 'token' => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null, |
|
1500 | + 'query' => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null, |
|
1501 | + 'type' => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null, |
|
1502 | + 'form' => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null, |
|
1503 | + 'customer' => isset($wp_query->query_vars['customer']) ? $wp_query->query_vars['customer'] : null, |
|
1504 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
1505 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
1506 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, |
|
1507 | + 'id' => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null, |
|
1508 | + 'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null, |
|
1509 | + 'email' => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null, |
|
1510 | 1510 | ); |
1511 | 1511 | |
1512 | 1512 | $log_data = array( |
1513 | 1513 | 'log_type' => 'api_request', |
1514 | - 'post_excerpt' => http_build_query( $query ), |
|
1515 | - 'post_content' => ! empty( $data['error'] ) ? $data['error'] : '', |
|
1514 | + 'post_excerpt' => http_build_query($query), |
|
1515 | + 'post_content' => ! empty($data['error']) ? $data['error'] : '', |
|
1516 | 1516 | ); |
1517 | 1517 | |
1518 | 1518 | $log_meta = array( |
1519 | 1519 | 'request_ip' => give_get_ip(), |
1520 | 1520 | 'user' => $this->user_id, |
1521 | - 'key' => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null, |
|
1522 | - 'token' => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null, |
|
1521 | + 'key' => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null, |
|
1522 | + 'token' => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null, |
|
1523 | 1523 | 'time' => $data['request_speed'], |
1524 | 1524 | 'version' => $this->get_queried_version(), |
1525 | 1525 | ); |
1526 | 1526 | |
1527 | - $give_logs->insert_log( $log_data, $log_meta ); |
|
1527 | + $give_logs->insert_log($log_data, $log_meta); |
|
1528 | 1528 | } |
1529 | 1529 | |
1530 | 1530 | |
@@ -1548,7 +1548,7 @@ discard block |
||
1548 | 1548 | * |
1549 | 1549 | * @param int $status_code |
1550 | 1550 | */ |
1551 | - public function output( $status_code = 200 ) { |
|
1551 | + public function output($status_code = 200) { |
|
1552 | 1552 | /** |
1553 | 1553 | * @var WP_Query $wp_query |
1554 | 1554 | */ |
@@ -1556,7 +1556,7 @@ discard block |
||
1556 | 1556 | |
1557 | 1557 | $format = $this->get_output_format(); |
1558 | 1558 | |
1559 | - status_header( $status_code ); |
|
1559 | + status_header($status_code); |
|
1560 | 1560 | |
1561 | 1561 | /** |
1562 | 1562 | * Fires before outputing the API. |
@@ -1567,25 +1567,25 @@ discard block |
||
1567 | 1567 | * @param Give_API $this The Give_API object. |
1568 | 1568 | * @param string $format Output format, XML or JSON. Default is JSON. |
1569 | 1569 | */ |
1570 | - do_action( 'give_api_output_before', $this->data, $this, $format ); |
|
1570 | + do_action('give_api_output_before', $this->data, $this, $format); |
|
1571 | 1571 | |
1572 | - switch ( $format ) : |
|
1572 | + switch ($format) : |
|
1573 | 1573 | |
1574 | 1574 | case 'xml' : |
1575 | 1575 | |
1576 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php'; |
|
1577 | - $xml = Array2XML::createXML( 'give', $this->data ); |
|
1576 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php'; |
|
1577 | + $xml = Array2XML::createXML('give', $this->data); |
|
1578 | 1578 | echo $xml->saveXML(); |
1579 | 1579 | |
1580 | 1580 | break; |
1581 | 1581 | |
1582 | 1582 | case 'json' : |
1583 | 1583 | |
1584 | - header( 'Content-Type: application/json' ); |
|
1585 | - if ( ! empty( $this->pretty_print ) ) { |
|
1586 | - echo json_encode( $this->data, $this->pretty_print ); |
|
1584 | + header('Content-Type: application/json'); |
|
1585 | + if ( ! empty($this->pretty_print)) { |
|
1586 | + echo json_encode($this->data, $this->pretty_print); |
|
1587 | 1587 | } else { |
1588 | - echo json_encode( $this->data ); |
|
1588 | + echo json_encode($this->data); |
|
1589 | 1589 | } |
1590 | 1590 | |
1591 | 1591 | break; |
@@ -1600,7 +1600,7 @@ discard block |
||
1600 | 1600 | * @param array $data Response data to return. |
1601 | 1601 | * @param Give_API $this The Give_API object. |
1602 | 1602 | */ |
1603 | - do_action( "give_api_output_{$format}", $this->data, $this ); |
|
1603 | + do_action("give_api_output_{$format}", $this->data, $this); |
|
1604 | 1604 | |
1605 | 1605 | break; |
1606 | 1606 | |
@@ -1615,7 +1615,7 @@ discard block |
||
1615 | 1615 | * @param Give_API $this The Give_API object. |
1616 | 1616 | * @param string $format Output format, XML or JSON. Default is JSON. |
1617 | 1617 | */ |
1618 | - do_action( 'give_api_output_after', $this->data, $this, $format ); |
|
1618 | + do_action('give_api_output_after', $this->data, $this, $format); |
|
1619 | 1619 | |
1620 | 1620 | give_die(); |
1621 | 1621 | } |
@@ -1632,40 +1632,40 @@ discard block |
||
1632 | 1632 | * |
1633 | 1633 | * @return void |
1634 | 1634 | */ |
1635 | - function user_key_field( $user ) { |
|
1635 | + function user_key_field($user) { |
|
1636 | 1636 | |
1637 | - if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) { |
|
1638 | - $user = get_userdata( $user->ID ); |
|
1637 | + if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) { |
|
1638 | + $user = get_userdata($user->ID); |
|
1639 | 1639 | ?> |
1640 | 1640 | <table class="form-table"> |
1641 | 1641 | <tbody> |
1642 | 1642 | <tr> |
1643 | 1643 | <th> |
1644 | - <?php esc_html_e( 'Give API Keys', 'give' ); ?> |
|
1644 | + <?php esc_html_e('Give API Keys', 'give'); ?> |
|
1645 | 1645 | </th> |
1646 | 1646 | <td> |
1647 | 1647 | <?php |
1648 | - $public_key = $this->get_user_public_key( $user->ID ); |
|
1649 | - $secret_key = $this->get_user_secret_key( $user->ID ); |
|
1648 | + $public_key = $this->get_user_public_key($user->ID); |
|
1649 | + $secret_key = $this->get_user_secret_key($user->ID); |
|
1650 | 1650 | ?> |
1651 | - <?php if ( empty( $user->give_user_public_key ) ) { ?> |
|
1651 | + <?php if (empty($user->give_user_public_key)) { ?> |
|
1652 | 1652 | <input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/> |
1653 | - <span class="description"><?php esc_html_e( 'Generate API Key', 'give' ); ?></span> |
|
1653 | + <span class="description"><?php esc_html_e('Generate API Key', 'give'); ?></span> |
|
1654 | 1654 | <?php } else { ?> |
1655 | - <strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Public key:', 'give' ); ?> |
|
1655 | + <strong style="display:inline-block; width: 125px;"><?php esc_html_e('Public key:', 'give'); ?> |
|
1656 | 1656 | </strong> |
1657 | - <input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>"/> |
|
1657 | + <input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>"/> |
|
1658 | 1658 | <br/> |
1659 | - <strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Secret key:', 'give' ); ?> |
|
1659 | + <strong style="display:inline-block; width: 125px;"><?php esc_html_e('Secret key:', 'give'); ?> |
|
1660 | 1660 | </strong> |
1661 | - <input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>"/> |
|
1661 | + <input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>"/> |
|
1662 | 1662 | <br/> |
1663 | - <strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Token:', 'give' ); ?> |
|
1663 | + <strong style="display:inline-block; width: 125px;"><?php esc_html_e('Token:', 'give'); ?> |
|
1664 | 1664 | </strong> |
1665 | - <input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>"/> |
|
1665 | + <input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>"/> |
|
1666 | 1666 | <br/> |
1667 | 1667 | <input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/> |
1668 | - <span class="description"><label for="give_set_api_key"><?php esc_html_e( 'Revoke API Keys', 'give' ); ?></label></span> |
|
1668 | + <span class="description"><label for="give_set_api_key"><?php esc_html_e('Revoke API Keys', 'give'); ?></label></span> |
|
1669 | 1669 | <?php } ?> |
1670 | 1670 | </td> |
1671 | 1671 | </tr> |
@@ -1684,69 +1684,69 @@ discard block |
||
1684 | 1684 | * |
1685 | 1685 | * @return void |
1686 | 1686 | */ |
1687 | - public function process_api_key( $args ) { |
|
1687 | + public function process_api_key($args) { |
|
1688 | 1688 | |
1689 | - if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) { |
|
1689 | + if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) { |
|
1690 | 1690 | |
1691 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
1691 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
1692 | 1692 | |
1693 | 1693 | } |
1694 | 1694 | |
1695 | - if ( empty( $args['user_id'] ) ) { |
|
1696 | - wp_die( esc_html__( 'User ID Required.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 401 ) ); |
|
1695 | + if (empty($args['user_id'])) { |
|
1696 | + wp_die(esc_html__('User ID Required.', 'give'), esc_html__('Error', 'give'), array('response' => 401)); |
|
1697 | 1697 | } |
1698 | 1698 | |
1699 | - if ( is_numeric( $args['user_id'] ) ) { |
|
1700 | - $user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id(); |
|
1699 | + if (is_numeric($args['user_id'])) { |
|
1700 | + $user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id(); |
|
1701 | 1701 | } else { |
1702 | - $userdata = get_user_by( 'login', $args['user_id'] ); |
|
1702 | + $userdata = get_user_by('login', $args['user_id']); |
|
1703 | 1703 | $user_id = $userdata->ID; |
1704 | 1704 | } |
1705 | - $process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false; |
|
1705 | + $process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false; |
|
1706 | 1706 | |
1707 | - if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) { |
|
1707 | + if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) { |
|
1708 | 1708 | wp_die( |
1709 | 1709 | sprintf( |
1710 | 1710 | /* translators: %s: process */ |
1711 | - esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ), |
|
1711 | + esc_html__('You do not have permission to %s API keys for this user.', 'give'), |
|
1712 | 1712 | $process |
1713 | 1713 | ), |
1714 | - esc_html__( 'Error', 'give' ), |
|
1715 | - array( 'response' => 403 ) |
|
1714 | + esc_html__('Error', 'give'), |
|
1715 | + array('response' => 403) |
|
1716 | 1716 | ); |
1717 | - } elseif ( ! current_user_can( 'manage_give_settings' ) ) { |
|
1717 | + } elseif ( ! current_user_can('manage_give_settings')) { |
|
1718 | 1718 | wp_die( |
1719 | 1719 | sprintf( |
1720 | 1720 | /* translators: %s: process */ |
1721 | - esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ), |
|
1721 | + esc_html__('You do not have permission to %s API keys for this user.', 'give'), |
|
1722 | 1722 | $process |
1723 | 1723 | ), |
1724 | - esc_html__( 'Error', 'give' ), |
|
1725 | - array( 'response' => 403 ) |
|
1724 | + esc_html__('Error', 'give'), |
|
1725 | + array('response' => 403) |
|
1726 | 1726 | ); |
1727 | 1727 | } |
1728 | 1728 | |
1729 | - switch ( $process ) { |
|
1729 | + switch ($process) { |
|
1730 | 1730 | case 'generate': |
1731 | - if ( $this->generate_api_key( $user_id ) ) { |
|
1732 | - delete_transient( 'give_total_api_keys' ); |
|
1733 | - wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1731 | + if ($this->generate_api_key($user_id)) { |
|
1732 | + delete_transient('give_total_api_keys'); |
|
1733 | + wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1734 | 1734 | exit(); |
1735 | 1735 | } else { |
1736 | - wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1736 | + wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1737 | 1737 | exit(); |
1738 | 1738 | } |
1739 | 1739 | break; |
1740 | 1740 | case 'regenerate': |
1741 | - $this->generate_api_key( $user_id, true ); |
|
1742 | - delete_transient( 'give_total_api_keys' ); |
|
1743 | - wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1741 | + $this->generate_api_key($user_id, true); |
|
1742 | + delete_transient('give_total_api_keys'); |
|
1743 | + wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1744 | 1744 | exit(); |
1745 | 1745 | break; |
1746 | 1746 | case 'revoke': |
1747 | - $this->revoke_api_key( $user_id ); |
|
1748 | - delete_transient( 'give_total_api_keys' ); |
|
1749 | - wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1747 | + $this->revoke_api_key($user_id); |
|
1748 | + delete_transient('give_total_api_keys'); |
|
1749 | + wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1750 | 1750 | exit(); |
1751 | 1751 | break; |
1752 | 1752 | default; |
@@ -1765,34 +1765,34 @@ discard block |
||
1765 | 1765 | * |
1766 | 1766 | * @return boolean True if (re)generated succesfully, false otherwise. |
1767 | 1767 | */ |
1768 | - public function generate_api_key( $user_id = 0, $regenerate = false ) { |
|
1768 | + public function generate_api_key($user_id = 0, $regenerate = false) { |
|
1769 | 1769 | |
1770 | - if ( empty( $user_id ) ) { |
|
1770 | + if (empty($user_id)) { |
|
1771 | 1771 | return false; |
1772 | 1772 | } |
1773 | 1773 | |
1774 | - $user = get_userdata( $user_id ); |
|
1774 | + $user = get_userdata($user_id); |
|
1775 | 1775 | |
1776 | - if ( ! $user ) { |
|
1776 | + if ( ! $user) { |
|
1777 | 1777 | return false; |
1778 | 1778 | } |
1779 | 1779 | |
1780 | - $public_key = $this->get_user_public_key( $user_id ); |
|
1781 | - $secret_key = $this->get_user_secret_key( $user_id ); |
|
1780 | + $public_key = $this->get_user_public_key($user_id); |
|
1781 | + $secret_key = $this->get_user_secret_key($user_id); |
|
1782 | 1782 | |
1783 | - if ( empty( $public_key ) || $regenerate == true ) { |
|
1784 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
1785 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
1783 | + if (empty($public_key) || $regenerate == true) { |
|
1784 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
1785 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
1786 | 1786 | } else { |
1787 | 1787 | return false; |
1788 | 1788 | } |
1789 | 1789 | |
1790 | - if ( $regenerate == true ) { |
|
1791 | - $this->revoke_api_key( $user->ID ); |
|
1790 | + if ($regenerate == true) { |
|
1791 | + $this->revoke_api_key($user->ID); |
|
1792 | 1792 | } |
1793 | 1793 | |
1794 | - update_user_meta( $user_id, $new_public_key, 'give_user_public_key' ); |
|
1795 | - update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' ); |
|
1794 | + update_user_meta($user_id, $new_public_key, 'give_user_public_key'); |
|
1795 | + update_user_meta($user_id, $new_secret_key, 'give_user_secret_key'); |
|
1796 | 1796 | |
1797 | 1797 | return true; |
1798 | 1798 | } |
@@ -1807,26 +1807,26 @@ discard block |
||
1807 | 1807 | * |
1808 | 1808 | * @return bool |
1809 | 1809 | */ |
1810 | - public function revoke_api_key( $user_id = 0 ) { |
|
1810 | + public function revoke_api_key($user_id = 0) { |
|
1811 | 1811 | |
1812 | - if ( empty( $user_id ) ) { |
|
1812 | + if (empty($user_id)) { |
|
1813 | 1813 | return false; |
1814 | 1814 | } |
1815 | 1815 | |
1816 | - $user = get_userdata( $user_id ); |
|
1816 | + $user = get_userdata($user_id); |
|
1817 | 1817 | |
1818 | - if ( ! $user ) { |
|
1818 | + if ( ! $user) { |
|
1819 | 1819 | return false; |
1820 | 1820 | } |
1821 | 1821 | |
1822 | - $public_key = $this->get_user_public_key( $user_id ); |
|
1823 | - $secret_key = $this->get_user_secret_key( $user_id ); |
|
1824 | - if ( ! empty( $public_key ) ) { |
|
1825 | - delete_transient( md5( 'give_api_user_' . $public_key ) ); |
|
1826 | - delete_transient( md5( 'give_api_user_public_key' . $user_id ) ); |
|
1827 | - delete_transient( md5( 'give_api_user_secret_key' . $user_id ) ); |
|
1828 | - delete_user_meta( $user_id, $public_key ); |
|
1829 | - delete_user_meta( $user_id, $secret_key ); |
|
1822 | + $public_key = $this->get_user_public_key($user_id); |
|
1823 | + $secret_key = $this->get_user_secret_key($user_id); |
|
1824 | + if ( ! empty($public_key)) { |
|
1825 | + delete_transient(md5('give_api_user_'.$public_key)); |
|
1826 | + delete_transient(md5('give_api_user_public_key'.$user_id)); |
|
1827 | + delete_transient(md5('give_api_user_secret_key'.$user_id)); |
|
1828 | + delete_user_meta($user_id, $public_key); |
|
1829 | + delete_user_meta($user_id, $secret_key); |
|
1830 | 1830 | } else { |
1831 | 1831 | return false; |
1832 | 1832 | } |
@@ -1851,22 +1851,22 @@ discard block |
||
1851 | 1851 | * |
1852 | 1852 | * @return void |
1853 | 1853 | */ |
1854 | - public function update_key( $user_id ) { |
|
1855 | - if ( current_user_can( 'edit_user', $user_id ) && isset( $_POST['give_set_api_key'] ) ) { |
|
1854 | + public function update_key($user_id) { |
|
1855 | + if (current_user_can('edit_user', $user_id) && isset($_POST['give_set_api_key'])) { |
|
1856 | 1856 | |
1857 | - $user = get_userdata( $user_id ); |
|
1857 | + $user = get_userdata($user_id); |
|
1858 | 1858 | |
1859 | - $public_key = $this->get_user_public_key( $user_id ); |
|
1860 | - $secret_key = $this->get_user_secret_key( $user_id ); |
|
1859 | + $public_key = $this->get_user_public_key($user_id); |
|
1860 | + $secret_key = $this->get_user_secret_key($user_id); |
|
1861 | 1861 | |
1862 | - if ( empty( $public_key ) ) { |
|
1863 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
1864 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
1862 | + if (empty($public_key)) { |
|
1863 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
1864 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
1865 | 1865 | |
1866 | - update_user_meta( $user_id, $new_public_key, 'give_user_public_key' ); |
|
1867 | - update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' ); |
|
1866 | + update_user_meta($user_id, $new_public_key, 'give_user_public_key'); |
|
1867 | + update_user_meta($user_id, $new_secret_key, 'give_user_secret_key'); |
|
1868 | 1868 | } else { |
1869 | - $this->revoke_api_key( $user_id ); |
|
1869 | + $this->revoke_api_key($user_id); |
|
1870 | 1870 | } |
1871 | 1871 | } |
1872 | 1872 | } |
@@ -1881,9 +1881,9 @@ discard block |
||
1881 | 1881 | * |
1882 | 1882 | * @return string |
1883 | 1883 | */ |
1884 | - private function generate_public_key( $user_email = '' ) { |
|
1885 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
1886 | - $public = hash( 'md5', $user_email . $auth_key . date( 'U' ) ); |
|
1884 | + private function generate_public_key($user_email = '') { |
|
1885 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
1886 | + $public = hash('md5', $user_email.$auth_key.date('U')); |
|
1887 | 1887 | |
1888 | 1888 | return $public; |
1889 | 1889 | } |
@@ -1898,9 +1898,9 @@ discard block |
||
1898 | 1898 | * |
1899 | 1899 | * @return string |
1900 | 1900 | */ |
1901 | - private function generate_private_key( $user_id = 0 ) { |
|
1902 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
1903 | - $secret = hash( 'md5', $user_id . $auth_key . date( 'U' ) ); |
|
1901 | + private function generate_private_key($user_id = 0) { |
|
1902 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
1903 | + $secret = hash('md5', $user_id.$auth_key.date('U')); |
|
1904 | 1904 | |
1905 | 1905 | return $secret; |
1906 | 1906 | } |
@@ -1915,8 +1915,8 @@ discard block |
||
1915 | 1915 | * |
1916 | 1916 | * @return string |
1917 | 1917 | */ |
1918 | - public function get_token( $user_id = 0 ) { |
|
1919 | - return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) ); |
|
1918 | + public function get_token($user_id = 0) { |
|
1919 | + return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id)); |
|
1920 | 1920 | } |
1921 | 1921 | |
1922 | 1922 | /** |
@@ -1930,9 +1930,9 @@ discard block |
||
1930 | 1930 | |
1931 | 1931 | // Default sales return |
1932 | 1932 | $sales = array(); |
1933 | - $sales['donations']['today'] = $this->stats->get_sales( 0, 'today' ); |
|
1934 | - $sales['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' ); |
|
1935 | - $sales['donations']['last_month'] = $this->stats->get_sales( 0, 'last_month' ); |
|
1933 | + $sales['donations']['today'] = $this->stats->get_sales(0, 'today'); |
|
1934 | + $sales['donations']['current_month'] = $this->stats->get_sales(0, 'this_month'); |
|
1935 | + $sales['donations']['last_month'] = $this->stats->get_sales(0, 'last_month'); |
|
1936 | 1936 | $sales['donations']['totals'] = give_get_total_sales(); |
1937 | 1937 | |
1938 | 1938 | return $sales; |
@@ -1949,9 +1949,9 @@ discard block |
||
1949 | 1949 | |
1950 | 1950 | // Default earnings return |
1951 | 1951 | $earnings = array(); |
1952 | - $earnings['earnings']['today'] = $this->stats->get_earnings( 0, 'today' ); |
|
1953 | - $earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' ); |
|
1954 | - $earnings['earnings']['last_month'] = $this->stats->get_earnings( 0, 'last_month' ); |
|
1952 | + $earnings['earnings']['today'] = $this->stats->get_earnings(0, 'today'); |
|
1953 | + $earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month'); |
|
1954 | + $earnings['earnings']['last_month'] = $this->stats->get_earnings(0, 'last_month'); |
|
1955 | 1955 | $earnings['earnings']['totals'] = give_get_total_earnings(); |
1956 | 1956 | |
1957 | 1957 | return $earnings; |
@@ -1971,25 +1971,25 @@ discard block |
||
1971 | 1971 | * |
1972 | 1972 | * @return string The API key/secret for the user supplied |
1973 | 1973 | */ |
1974 | - public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) { |
|
1974 | + public function api_key_backwards_compat($check, $object_id, $meta_key, $single) { |
|
1975 | 1975 | |
1976 | - if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) { |
|
1976 | + if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') { |
|
1977 | 1977 | return $check; |
1978 | 1978 | } |
1979 | 1979 | |
1980 | 1980 | $return = $check; |
1981 | 1981 | |
1982 | - switch ( $meta_key ) { |
|
1982 | + switch ($meta_key) { |
|
1983 | 1983 | case 'give_user_public_key': |
1984 | - $return = Give()->api->get_user_public_key( $object_id ); |
|
1984 | + $return = Give()->api->get_user_public_key($object_id); |
|
1985 | 1985 | break; |
1986 | 1986 | case 'give_user_secret_key': |
1987 | - $return = Give()->api->get_user_secret_key( $object_id ); |
|
1987 | + $return = Give()->api->get_user_secret_key($object_id); |
|
1988 | 1988 | break; |
1989 | 1989 | } |
1990 | 1990 | |
1991 | - if ( ! $single ) { |
|
1992 | - $return = array( $return ); |
|
1991 | + if ( ! $single) { |
|
1992 | + $return = array($return); |
|
1993 | 1993 | } |
1994 | 1994 | |
1995 | 1995 | return $return; |