@@ -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 | /** |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @return void |
| 65 | 65 | */ |
| 66 | - public function search_box( $text, $input_id ) { |
|
| 66 | + public function search_box($text, $input_id) { |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function get_columns() { |
| 78 | 78 | $columns = array( |
| 79 | - 'ID' => __( 'Log ID', 'give' ), |
|
| 80 | - 'date' => __( 'Date', 'give' ), |
|
| 81 | - 'details' => __( 'Process Details', 'give' ), |
|
| 79 | + 'ID' => __('Log ID', 'give'), |
|
| 80 | + 'date' => __('Date', 'give'), |
|
| 81 | + 'details' => __('Process Details', 'give'), |
|
| 82 | 82 | ); |
| 83 | 83 | |
| 84 | 84 | return $columns; |
@@ -95,17 +95,17 @@ discard block |
||
| 95 | 95 | * |
| 96 | 96 | * @return string Column Name |
| 97 | 97 | */ |
| 98 | - public function column_default( $item, $column_name ) { |
|
| 99 | - switch ( $column_name ) { |
|
| 98 | + public function column_default($item, $column_name) { |
|
| 99 | + switch ($column_name) { |
|
| 100 | 100 | case 'ID': |
| 101 | 101 | return sprintf( |
| 102 | 102 | '<span class="give-item-label give-item-label-gray">%1$s</span> %2$s', |
| 103 | - esc_attr( $item[ $column_name ] ), |
|
| 104 | - esc_attr( $item['title'] ) |
|
| 103 | + esc_attr($item[$column_name]), |
|
| 104 | + esc_attr($item['title']) |
|
| 105 | 105 | ); |
| 106 | 106 | |
| 107 | 107 | default: |
| 108 | - return esc_attr( $item[ $column_name ] ); |
|
| 108 | + return esc_attr($item[$column_name]); |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | |
@@ -119,24 +119,24 @@ discard block |
||
| 119 | 119 | * |
| 120 | 120 | * @return void |
| 121 | 121 | */ |
| 122 | - public function column_details( $item ) { |
|
| 123 | - echo Give()->tooltips->render_link( array( |
|
| 124 | - 'label' => __( 'View Update Log', 'give' ), |
|
| 122 | + public function column_details($item) { |
|
| 123 | + echo Give()->tooltips->render_link(array( |
|
| 124 | + 'label' => __('View Update Log', 'give'), |
|
| 125 | 125 | 'tag_content' => '<span class="dashicons dashicons-visibility"></span>', |
| 126 | 126 | 'link' => "#TB_inline?width=640&inlineId=log-details-{$item['ID']}", |
| 127 | 127 | 'attributes' => array( |
| 128 | 128 | 'class' => 'thickbox give-error-log-details-link button button-small', |
| 129 | 129 | ), |
| 130 | - ) ); |
|
| 130 | + )); |
|
| 131 | 131 | ?> |
| 132 | - <div id="log-details-<?php echo esc_attr( $item['ID'] ); ?>" style="display:none;"> |
|
| 132 | + <div id="log-details-<?php echo esc_attr($item['ID']); ?>" style="display:none;"> |
|
| 133 | 133 | <?php |
| 134 | 134 | |
| 135 | 135 | // Print Log Content, if not empty. |
| 136 | - if ( ! empty( $item['log_content'] ) ) { |
|
| 136 | + if ( ! empty($item['log_content'])) { |
|
| 137 | 137 | echo sprintf( |
| 138 | 138 | '<p><pre>%1$s</pre></div>', |
| 139 | - esc_html( $item['log_content'] ) |
|
| 139 | + esc_html($item['log_content']) |
|
| 140 | 140 | ); |
| 141 | 141 | } |
| 142 | 142 | ?> |
@@ -157,19 +157,19 @@ discard block |
||
| 157 | 157 | * |
| 158 | 158 | * @param string $which |
| 159 | 159 | */ |
| 160 | - protected function display_tablenav( $which ) { |
|
| 161 | - if ( 'top' === $which ) { |
|
| 162 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
| 160 | + protected function display_tablenav($which) { |
|
| 161 | + if ('top' === $which) { |
|
| 162 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
| 163 | 163 | } |
| 164 | 164 | ?> |
| 165 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
| 165 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
| 166 | 166 | |
| 167 | 167 | <div class="alignleft actions bulkactions"> |
| 168 | - <?php $this->bulk_actions( $which ); ?> |
|
| 168 | + <?php $this->bulk_actions($which); ?> |
|
| 169 | 169 | </div> |
| 170 | 170 | <?php |
| 171 | - $this->extra_tablenav( $which ); |
|
| 172 | - $this->pagination( $which ); |
|
| 171 | + $this->extra_tablenav($which); |
|
| 172 | + $this->pagination($which); |
|
| 173 | 173 | ?> |
| 174 | 174 | |
| 175 | 175 | <br class="clear"/> |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | * @return int Current page number |
| 187 | 187 | */ |
| 188 | 188 | public function get_paged() { |
| 189 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
| 189 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * |
| 200 | 200 | * @return void |
| 201 | 201 | */ |
| 202 | - function bulk_actions( $which = '' ) { |
|
| 202 | + function bulk_actions($which = '') { |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -219,10 +219,10 @@ discard block |
||
| 219 | 219 | 'posts_per_page' => $this->per_page, |
| 220 | 220 | ); |
| 221 | 221 | |
| 222 | - $logs = Give()->logs->get_connected_logs( $log_query ); |
|
| 222 | + $logs = Give()->logs->get_connected_logs($log_query); |
|
| 223 | 223 | |
| 224 | - if ( $logs ) { |
|
| 225 | - foreach ( $logs as $log ) { |
|
| 224 | + if ($logs) { |
|
| 225 | + foreach ($logs as $log) { |
|
| 226 | 226 | |
| 227 | 227 | $logs_data[] = array( |
| 228 | 228 | 'ID' => $log->ID, |
@@ -254,14 +254,14 @@ discard block |
||
| 254 | 254 | $columns = $this->get_columns(); |
| 255 | 255 | $hidden = array(); // No hidden columns |
| 256 | 256 | $sortable = $this->get_sortable_columns(); |
| 257 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
| 257 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
| 258 | 258 | $this->items = $this->get_logs(); |
| 259 | - $total_items = Give()->logs->get_log_count( 0, 'update' ); |
|
| 259 | + $total_items = Give()->logs->get_log_count(0, 'update'); |
|
| 260 | 260 | |
| 261 | - $this->set_pagination_args( array( |
|
| 261 | + $this->set_pagination_args(array( |
|
| 262 | 262 | 'total_items' => $total_items, |
| 263 | 263 | 'per_page' => $this->per_page, |
| 264 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
| 265 | - ) ); |
|
| 264 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
| 265 | + )); |
|
| 266 | 266 | } |
| 267 | 267 | } |
@@ -3,11 +3,11 @@ discard block |
||
| 3 | 3 | * Admin View: Exports |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 6 | +if ( ! defined('ABSPATH')) { |
|
| 7 | 7 | exit; |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | -if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 10 | +if ( ! current_user_can('manage_give_settings')) { |
|
| 11 | 11 | return; |
| 12 | 12 | } |
| 13 | 13 | |
@@ -16,29 +16,29 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @since 1.5 |
| 18 | 18 | */ |
| 19 | -do_action( 'give_tools_recount_stats_before' ); |
|
| 19 | +do_action('give_tools_recount_stats_before'); |
|
| 20 | 20 | ?> |
| 21 | 21 | <div id="poststuff"> |
| 22 | 22 | <div class="postbox"> |
| 23 | 23 | |
| 24 | - <h2 class="hndle ui-sortable-handle"><span><?php esc_html_e( 'Recount Stats', 'give' ); ?></span></h2> |
|
| 24 | + <h2 class="hndle ui-sortable-handle"><span><?php esc_html_e('Recount Stats', 'give'); ?></span></h2> |
|
| 25 | 25 | |
| 26 | 26 | <div class="inside recount-stats-controls"> |
| 27 | - <p><?php esc_html_e( 'Use these tools to recount stats, delete test transactions, or reset stats.', 'give' ); ?></p> |
|
| 27 | + <p><?php esc_html_e('Use these tools to recount stats, delete test transactions, or reset stats.', 'give'); ?></p> |
|
| 28 | 28 | <form method="post" id="give-tools-recount-form" class="give-export-form"> |
| 29 | 29 | |
| 30 | - <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?> |
|
| 30 | + <?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?> |
|
| 31 | 31 | |
| 32 | 32 | <select name="give-export-class" id="recount-stats-type"> |
| 33 | - <option value="0" selected="selected" disabled="disabled"><?php esc_html_e( 'Please select an option', 'give' ); ?></option> |
|
| 34 | - <option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e( 'Recalculate Total Donation Income Amount', 'give' ); ?></option> |
|
| 35 | - <option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_e( 'Recalculate Income Amount and Donation Counts for a Form', 'give' ); ?></option> |
|
| 36 | - <option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php esc_html_e( 'Recalculate Income Amount and Donation Counts for All Forms', 'give' ); ?></option> |
|
| 37 | - <option data-type="recount-donor-stats" value="Give_Tools_Recount_Donor_Stats"><?php esc_html_e( 'Recalculate Donor Statistics', 'give' ); ?></option> |
|
| 38 | - <option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e( 'Delete Test Payments', 'give' ); ?></option> |
|
| 39 | - <option data-type="delete-test-donors" value="Give_Tools_Delete_Donors"><?php esc_html_e( 'Delete Test Donors and Payments', 'give' ); ?></option> |
|
| 40 | - <option data-type="delete-import-donors" value="Give_Tools_Import_Donors"><?php esc_html_e( 'Delete Imported Donors and Payments', 'give' ); ?></option> |
|
| 41 | - <option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_e( 'Delete All Data', 'give' ); ?></option> |
|
| 33 | + <option value="0" selected="selected" disabled="disabled"><?php esc_html_e('Please select an option', 'give'); ?></option> |
|
| 34 | + <option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e('Recalculate Total Donation Income Amount', 'give'); ?></option> |
|
| 35 | + <option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_e('Recalculate Income Amount and Donation Counts for a Form', 'give'); ?></option> |
|
| 36 | + <option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php esc_html_e('Recalculate Income Amount and Donation Counts for All Forms', 'give'); ?></option> |
|
| 37 | + <option data-type="recount-donor-stats" value="Give_Tools_Recount_Donor_Stats"><?php esc_html_e('Recalculate Donor Statistics', 'give'); ?></option> |
|
| 38 | + <option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e('Delete Test Payments', 'give'); ?></option> |
|
| 39 | + <option data-type="delete-test-donors" value="Give_Tools_Delete_Donors"><?php esc_html_e('Delete Test Donors and Payments', 'give'); ?></option> |
|
| 40 | + <option data-type="delete-import-donors" value="Give_Tools_Import_Donors"><?php esc_html_e('Delete Imported Donors and Payments', 'give'); ?></option> |
|
| 41 | + <option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_e('Delete All Data', 'give'); ?></option> |
|
| 42 | 42 | <?php |
| 43 | 43 | /** |
| 44 | 44 | * Fires in the recount stats selectbox. |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * |
| 48 | 48 | * @since 1.5 |
| 49 | 49 | */ |
| 50 | - do_action( 'give_recount_tool_options' ); |
|
| 50 | + do_action('give_recount_tool_options'); |
|
| 51 | 51 | ?> |
| 52 | 52 | </select> |
| 53 | 53 | |
@@ -57,30 +57,30 @@ discard block |
||
| 57 | 57 | 'class' => 'tools-form-dropdown-recount-form-select', |
| 58 | 58 | 'name' => 'form_id', |
| 59 | 59 | 'chosen' => true, |
| 60 | - 'placeholder' => __( 'Select Form', 'give' ), |
|
| 60 | + 'placeholder' => __('Select Form', 'give'), |
|
| 61 | 61 | ); |
| 62 | - echo Give()->html->forms_dropdown( $args ); |
|
| 62 | + echo Give()->html->forms_dropdown($args); |
|
| 63 | 63 | ?> |
| 64 | 64 | </span> |
| 65 | 65 | |
| 66 | 66 | <span class="tools-form-dropdown tools-form-dropdown-delete-import-donors" style="display: none"> |
| 67 | 67 | <label for="delete-import-donors"> |
| 68 | 68 | <?php |
| 69 | - echo Give()->html->checkbox( array( 'name' => 'delete-import-donors' ) ); |
|
| 70 | - esc_html_e( 'Delete imported WordPress users', 'give' ); |
|
| 69 | + echo Give()->html->checkbox(array('name' => 'delete-import-donors')); |
|
| 70 | + esc_html_e('Delete imported WordPress users', 'give'); |
|
| 71 | 71 | ?> |
| 72 | 72 | </label> |
| 73 | 73 | </span> |
| 74 | 74 | |
| 75 | - <input type="submit" id="recount-stats-submit" value="<?php esc_attr_e( 'Submit', 'give' ); ?>" class="button-secondary"/> |
|
| 75 | + <input type="submit" id="recount-stats-submit" value="<?php esc_attr_e('Submit', 'give'); ?>" class="button-secondary"/> |
|
| 76 | 76 | |
| 77 | 77 | <br/> |
| 78 | 78 | |
| 79 | 79 | <span class="give-recount-stats-descriptions"> |
| 80 | - <span id="recount-stats"><?php esc_html_e( 'Recalculates the overall donation income amount.', 'give' ); ?></span> |
|
| 81 | - <span id="recount-form"><?php esc_html_e( 'Recalculates the donation and income stats for a specific form.', 'give' ); ?></span> |
|
| 82 | - <span id="recount-all"><?php esc_html_e( 'Recalculates the earnings and sales stats for all forms.', 'give' ); ?></span> |
|
| 83 | - <span id="recount-customer-stats"><?php esc_html_e( 'Recalculates the lifetime value and donation counts for all donors.', 'give' ); ?></span> |
|
| 80 | + <span id="recount-stats"><?php esc_html_e('Recalculates the overall donation income amount.', 'give'); ?></span> |
|
| 81 | + <span id="recount-form"><?php esc_html_e('Recalculates the donation and income stats for a specific form.', 'give'); ?></span> |
|
| 82 | + <span id="recount-all"><?php esc_html_e('Recalculates the earnings and sales stats for all forms.', 'give'); ?></span> |
|
| 83 | + <span id="recount-customer-stats"><?php esc_html_e('Recalculates the lifetime value and donation counts for all donors.', 'give'); ?></span> |
|
| 84 | 84 | <?php |
| 85 | 85 | /** |
| 86 | 86 | * Fires in the recount stats description area. |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @since 1.5 |
| 91 | 91 | */ |
| 92 | - do_action( 'give_recount_tool_descriptions' ); |
|
| 92 | + do_action('give_recount_tool_descriptions'); |
|
| 93 | 93 | ?> |
| 94 | - <span id="delete-test-transactions"><strong><?php esc_html_e( 'Deletes', 'give' ); ?></strong> <?php esc_html_e( 'all TEST donations, donors, and related log entries.', 'give' ); ?></span> |
|
| 95 | - <span id="reset-stats"><strong><?php esc_html_e( 'Deletes', 'give' ); ?></strong> <?php esc_html_e( 'ALL donations, donors, and related log entries regardless of test or live mode.', 'give' ); ?></span> |
|
| 94 | + <span id="delete-test-transactions"><strong><?php esc_html_e('Deletes', 'give'); ?></strong> <?php esc_html_e('all TEST donations, donors, and related log entries.', 'give'); ?></span> |
|
| 95 | + <span id="reset-stats"><strong><?php esc_html_e('Deletes', 'give'); ?></strong> <?php esc_html_e('ALL donations, donors, and related log entries regardless of test or live mode.', 'give'); ?></span> |
|
| 96 | 96 | </span> |
| 97 | 97 | |
| 98 | 98 | <span class="spinner"></span> |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @since 1.5 |
| 108 | 108 | */ |
| 109 | - do_action( 'give_tools_recount_forms' ); |
|
| 109 | + do_action('give_tools_recount_forms'); |
|
| 110 | 110 | ?> |
| 111 | 111 | </div><!-- .inside --> |
| 112 | 112 | </div><!-- .postbox --> |
@@ -117,4 +117,4 @@ discard block |
||
| 117 | 117 | * |
| 118 | 118 | * @since 1.5 |
| 119 | 119 | */ |
| 120 | -do_action( 'give_tools_recount_stats_after' ); |
|
| 120 | +do_action('give_tools_recount_stats_after'); |
|
@@ -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 | |
@@ -25,16 +25,16 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | function give_get_actions() { |
| 27 | 27 | |
| 28 | - $get_data = give_clean( $_GET ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 28 | + $get_data = give_clean($_GET); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 29 | 29 | |
| 30 | - $_get_action = ! empty( $get_data['give_action'] ) ? $get_data['give_action'] : null; |
|
| 30 | + $_get_action = ! empty($get_data['give_action']) ? $get_data['give_action'] : null; |
|
| 31 | 31 | |
| 32 | 32 | // Add backward compatibility to give-action param ( $_GET ). |
| 33 | - if ( empty( $_get_action ) ) { |
|
| 34 | - $_get_action = ! empty( $get_data['give-action'] ) ? $get_data['give-action'] : null; |
|
| 33 | + if (empty($_get_action)) { |
|
| 34 | + $_get_action = ! empty($get_data['give-action']) ? $get_data['give-action'] : null; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - if ( isset( $_get_action ) ) { |
|
| 37 | + if (isset($_get_action)) { |
|
| 38 | 38 | /** |
| 39 | 39 | * Fires in WordPress init or admin init, when give_action is present in $_GET. |
| 40 | 40 | * |
@@ -42,12 +42,12 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @param array $_GET Array of HTTP GET variables. |
| 44 | 44 | */ |
| 45 | - do_action( "give_{$_get_action}", $get_data ); |
|
| 45 | + do_action("give_{$_get_action}", $get_data); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | -add_action( 'init', 'give_get_actions' ); |
|
| 50 | +add_action('init', 'give_get_actions'); |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * Hooks Give actions, when present in the $_POST super global. Every give_action |
@@ -60,16 +60,16 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | function give_post_actions() { |
| 62 | 62 | |
| 63 | - $post_data = give_clean( $_POST ); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 63 | + $post_data = give_clean($_POST); // WPCS: input var ok, sanitization ok, CSRF ok. |
|
| 64 | 64 | |
| 65 | - $_post_action = ! empty( $post_data['give_action'] ) ? $post_data['give_action'] : null; |
|
| 65 | + $_post_action = ! empty($post_data['give_action']) ? $post_data['give_action'] : null; |
|
| 66 | 66 | |
| 67 | 67 | // Add backward compatibility to give-action param ( $_POST ). |
| 68 | - if ( empty( $_post_action ) ) { |
|
| 69 | - $_post_action = ! empty( $post_data['give-action'] ) ? $post_data['give-action'] : null; |
|
| 68 | + if (empty($_post_action)) { |
|
| 69 | + $_post_action = ! empty($post_data['give-action']) ? $post_data['give-action'] : null; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - if ( isset( $_post_action ) ) { |
|
| 72 | + if (isset($_post_action)) { |
|
| 73 | 73 | /** |
| 74 | 74 | * Fires in WordPress init or admin init, when give_action is present in $_POST. |
| 75 | 75 | * |
@@ -77,12 +77,12 @@ discard block |
||
| 77 | 77 | * |
| 78 | 78 | * @param array $_POST Array of HTTP POST variables. |
| 79 | 79 | */ |
| 80 | - do_action( "give_{$_post_action}", $post_data ); |
|
| 80 | + do_action("give_{$_post_action}", $post_data); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | -add_action( 'init', 'give_post_actions' ); |
|
| 85 | +add_action('init', 'give_post_actions'); |
|
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | 88 | * Connect WordPress user with Donor. |
@@ -94,17 +94,17 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @return void |
| 96 | 96 | */ |
| 97 | -function give_connect_donor_to_wpuser( $user_id, $user_data ) { |
|
| 97 | +function give_connect_donor_to_wpuser($user_id, $user_data) { |
|
| 98 | 98 | /* @var Give_Donor $donor */ |
| 99 | - $donor = new Give_Donor( $user_data['user_email'] ); |
|
| 99 | + $donor = new Give_Donor($user_data['user_email']); |
|
| 100 | 100 | |
| 101 | 101 | // Validate donor id and check if do nor is already connect to wp user or not. |
| 102 | - if ( $donor->id && ! $donor->user_id ) { |
|
| 102 | + if ($donor->id && ! $donor->user_id) { |
|
| 103 | 103 | |
| 104 | 104 | // Update donor user_id. |
| 105 | - if ( $donor->update( array( 'user_id' => $user_id ) ) ) { |
|
| 106 | - $donor_note = sprintf( esc_html__( 'WordPress user #%d is connected to #%d', 'give' ), $user_id, $donor->id ); |
|
| 107 | - $donor->add_note( $donor_note ); |
|
| 105 | + if ($donor->update(array('user_id' => $user_id))) { |
|
| 106 | + $donor_note = sprintf(esc_html__('WordPress user #%d is connected to #%d', 'give'), $user_id, $donor->id); |
|
| 107 | + $donor->add_note($donor_note); |
|
| 108 | 108 | |
| 109 | 109 | // Update user_id meta in payments. |
| 110 | 110 | // if( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) { |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | -add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 ); |
|
| 120 | +add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2); |
|
| 121 | 121 | |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -127,19 +127,19 @@ discard block |
||
| 127 | 127 | * |
| 128 | 128 | * @param $data |
| 129 | 129 | */ |
| 130 | -function give_donor_batch_export_complete( $data ) { |
|
| 130 | +function give_donor_batch_export_complete($data) { |
|
| 131 | 131 | // Remove donor ids cache. |
| 132 | 132 | if ( |
| 133 | - isset( $data['class'] ) |
|
| 133 | + isset($data['class']) |
|
| 134 | 134 | && 'Give_Batch_Donors_Export' === $data['class'] |
| 135 | - && ! empty( $data['forms'] ) |
|
| 136 | - && isset( $data['give_export_option']['query_id'] ) |
|
| 135 | + && ! empty($data['forms']) |
|
| 136 | + && isset($data['give_export_option']['query_id']) |
|
| 137 | 137 | ) { |
| 138 | - Give_Cache::delete( Give_Cache::get_key( $data['give_export_option']['query_id'] ) ); |
|
| 138 | + Give_Cache::delete(Give_Cache::get_key($data['give_export_option']['query_id'])); |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | -add_action( 'give_file_export_complete', 'give_donor_batch_export_complete' ); |
|
| 142 | +add_action('give_file_export_complete', 'give_donor_batch_export_complete'); |
|
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | 145 | * Print css for wordpress setting pages. |
@@ -150,12 +150,12 @@ discard block |
||
| 150 | 150 | /* @var WP_Screen $screen */ |
| 151 | 151 | $screen = get_current_screen(); |
| 152 | 152 | |
| 153 | - if ( ! ( $screen instanceof WP_Screen ) ) { |
|
| 153 | + if ( ! ($screen instanceof WP_Screen)) { |
|
| 154 | 154 | return false; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - switch ( true ) { |
|
| 158 | - case ( 'plugins' === $screen->base || 'plugins-network' === $screen->base ): |
|
| 157 | + switch (true) { |
|
| 158 | + case ('plugins' === $screen->base || 'plugins-network' === $screen->base): |
|
| 159 | 159 | ?> |
| 160 | 160 | <style> |
| 161 | 161 | tr.active.update + tr.give-addon-notice-tr td { |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | } |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | -add_action( 'admin_head', 'give_admin_quick_css' ); |
|
| 195 | +add_action('admin_head', 'give_admin_quick_css'); |
|
| 196 | 196 | |
| 197 | 197 | |
| 198 | 198 | /** |
@@ -204,31 +204,31 @@ discard block |
||
| 204 | 204 | * |
| 205 | 205 | * @return void |
| 206 | 206 | */ |
| 207 | -function give_set_donation_levels_max_min_amount( $form_id ) { |
|
| 207 | +function give_set_donation_levels_max_min_amount($form_id) { |
|
| 208 | 208 | if ( |
| 209 | - ( 'set' === $_POST['_give_price_option'] ) || |
|
| 210 | - ( in_array( '_give_donation_levels', $_POST ) && count( $_POST['_give_donation_levels'] ) <= 0 ) || |
|
| 211 | - ! ( $donation_levels_amounts = wp_list_pluck( $_POST['_give_donation_levels'], '_give_amount' ) ) |
|
| 209 | + ('set' === $_POST['_give_price_option']) || |
|
| 210 | + (in_array('_give_donation_levels', $_POST) && count($_POST['_give_donation_levels']) <= 0) || |
|
| 211 | + ! ($donation_levels_amounts = wp_list_pluck($_POST['_give_donation_levels'], '_give_amount')) |
|
| 212 | 212 | ) { |
| 213 | 213 | // Delete old meta. |
| 214 | - give_delete_meta( $form_id, '_give_levels_minimum_amount' ); |
|
| 215 | - give_delete_meta( $form_id, '_give_levels_maximum_amount' ); |
|
| 214 | + give_delete_meta($form_id, '_give_levels_minimum_amount'); |
|
| 215 | + give_delete_meta($form_id, '_give_levels_maximum_amount'); |
|
| 216 | 216 | |
| 217 | 217 | return; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | // Sanitize donation level amounts. |
| 221 | - $donation_levels_amounts = array_map( 'give_maybe_sanitize_amount', $donation_levels_amounts ); |
|
| 221 | + $donation_levels_amounts = array_map('give_maybe_sanitize_amount', $donation_levels_amounts); |
|
| 222 | 222 | |
| 223 | - $min_amount = min( $donation_levels_amounts ); |
|
| 224 | - $max_amount = max( $donation_levels_amounts ); |
|
| 223 | + $min_amount = min($donation_levels_amounts); |
|
| 224 | + $max_amount = max($donation_levels_amounts); |
|
| 225 | 225 | |
| 226 | 226 | // Set Minimum and Maximum amount for Multi Level Donation Forms. |
| 227 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db( $min_amount ) : 0 ); |
|
| 228 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db( $max_amount ) : 0 ); |
|
| 227 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db($min_amount) : 0); |
|
| 228 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db($max_amount) : 0); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | -add_action( 'give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30 ); |
|
| 231 | +add_action('give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30); |
|
| 232 | 232 | |
| 233 | 233 | |
| 234 | 234 | /** |
@@ -238,23 +238,23 @@ discard block |
||
| 238 | 238 | * |
| 239 | 239 | * @param int $payment_id |
| 240 | 240 | */ |
| 241 | -function _give_save_donor_billing_address( $payment_id ) { |
|
| 242 | - $donor_id = absint( give_get_payment_donor_id( $payment_id )); |
|
| 241 | +function _give_save_donor_billing_address($payment_id) { |
|
| 242 | + $donor_id = absint(give_get_payment_donor_id($payment_id)); |
|
| 243 | 243 | |
| 244 | 244 | // Bailout |
| 245 | - if ( ! $donor_id ) { |
|
| 245 | + if ( ! $donor_id) { |
|
| 246 | 246 | return; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | |
| 250 | 250 | /* @var Give_Donor $donor */ |
| 251 | - $donor = new Give_Donor( $donor_id ); |
|
| 251 | + $donor = new Give_Donor($donor_id); |
|
| 252 | 252 | |
| 253 | 253 | // Save address. |
| 254 | - $donor->add_address( 'billing[]', give_get_donation_address( $payment_id ) ); |
|
| 254 | + $donor->add_address('billing[]', give_get_donation_address($payment_id)); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | -add_action( 'give_complete_donation', '_give_save_donor_billing_address', 9999 ); |
|
| 257 | +add_action('give_complete_donation', '_give_save_donor_billing_address', 9999); |
|
| 258 | 258 | |
| 259 | 259 | |
| 260 | 260 | /** |
@@ -264,26 +264,26 @@ discard block |
||
| 264 | 264 | * |
| 265 | 265 | * @param array $args |
| 266 | 266 | */ |
| 267 | -function give_update_log_form_id( $args ) { |
|
| 268 | - $new_form_id = absint( $args[0] ); |
|
| 269 | - $payment_id = absint( $args[1] ); |
|
| 270 | - $logs = Give()->logs->get_logs( $payment_id ); |
|
| 267 | +function give_update_log_form_id($args) { |
|
| 268 | + $new_form_id = absint($args[0]); |
|
| 269 | + $payment_id = absint($args[1]); |
|
| 270 | + $logs = Give()->logs->get_logs($payment_id); |
|
| 271 | 271 | |
| 272 | 272 | // Bailout. |
| 273 | - if ( empty( $logs ) ) { |
|
| 273 | + if (empty($logs)) { |
|
| 274 | 274 | return; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /* @var object $log */ |
| 278 | - foreach ( $logs as $log ) { |
|
| 279 | - Give()->logs->logmeta_db->update_meta( $log->ID, '_give_log_form_id', $new_form_id ); |
|
| 278 | + foreach ($logs as $log) { |
|
| 279 | + Give()->logs->logmeta_db->update_meta($log->ID, '_give_log_form_id', $new_form_id); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | // Delete cache. |
| 283 | 283 | Give()->logs->delete_cache(); |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | -add_action( 'give_update_log_form_id', 'give_update_log_form_id' ); |
|
| 286 | +add_action('give_update_log_form_id', 'give_update_log_form_id'); |
|
| 287 | 287 | |
| 288 | 288 | /** |
| 289 | 289 | * Verify addon dependency before addon update |
@@ -295,25 +295,25 @@ discard block |
||
| 295 | 295 | * |
| 296 | 296 | * @return WP_Error |
| 297 | 297 | */ |
| 298 | -function __give_verify_addon_dependency_before_update( $error, $hook_extra ) { |
|
| 298 | +function __give_verify_addon_dependency_before_update($error, $hook_extra) { |
|
| 299 | 299 | // Bailout. |
| 300 | 300 | if ( |
| 301 | - is_wp_error( $error ) |
|
| 302 | - || ! array_key_exists( 'plugin', $hook_extra ) |
|
| 301 | + is_wp_error($error) |
|
| 302 | + || ! array_key_exists('plugin', $hook_extra) |
|
| 303 | 303 | ) { |
| 304 | 304 | return $error; |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - $plugin_base = strtolower( $hook_extra['plugin'] ); |
|
| 308 | - $licensed_addon = array_map( 'strtolower', Give_License::get_licensed_addons() ); |
|
| 307 | + $plugin_base = strtolower($hook_extra['plugin']); |
|
| 308 | + $licensed_addon = array_map('strtolower', Give_License::get_licensed_addons()); |
|
| 309 | 309 | |
| 310 | 310 | // Skip if not a Give addon. |
| 311 | - if ( ! in_array( $plugin_base, $licensed_addon ) ) { |
|
| 311 | + if ( ! in_array($plugin_base, $licensed_addon)) { |
|
| 312 | 312 | return $error; |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - $plugin_base = strtolower( $plugin_base ); |
|
| 316 | - $plugin_slug = str_replace( '.php', '', basename( $plugin_base ) ); |
|
| 315 | + $plugin_base = strtolower($plugin_base); |
|
| 316 | + $plugin_slug = str_replace('.php', '', basename($plugin_base)); |
|
| 317 | 317 | |
| 318 | 318 | /** |
| 319 | 319 | * Filter the addon readme.txt url |
@@ -326,15 +326,15 @@ discard block |
||
| 326 | 326 | $plugin_slug |
| 327 | 327 | ); |
| 328 | 328 | |
| 329 | - $parser = new Give_Readme_Parser( $url ); |
|
| 329 | + $parser = new Give_Readme_Parser($url); |
|
| 330 | 330 | $give_min_version = $parser->requires_at_least(); |
| 331 | 331 | |
| 332 | 332 | |
| 333 | - if ( version_compare( GIVE_VERSION, $give_min_version, '<' ) ) { |
|
| 333 | + if (version_compare(GIVE_VERSION, $give_min_version, '<')) { |
|
| 334 | 334 | return new WP_Error( |
| 335 | 335 | 'Give_Addon_Update_Error', |
| 336 | 336 | sprintf( |
| 337 | - __( 'Give version %s is required to update this add-on.', 'give' ), |
|
| 337 | + __('Give version %s is required to update this add-on.', 'give'), |
|
| 338 | 338 | $give_min_version |
| 339 | 339 | ) |
| 340 | 340 | ); |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | return $error; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | -add_filter( 'upgrader_pre_install', '__give_verify_addon_dependency_before_update', 10, 2 ); |
|
| 346 | +add_filter('upgrader_pre_install', '__give_verify_addon_dependency_before_update', 10, 2); |
|
| 347 | 347 | |
| 348 | 348 | /** |
| 349 | 349 | * Function to add suppress_filters param if WPML add-on is activated. |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | * |
| 355 | 355 | * @return array WP query argument for Total Goal. |
| 356 | 356 | */ |
| 357 | -function __give_wpml_total_goal_shortcode_agrs( $args ) { |
|
| 357 | +function __give_wpml_total_goal_shortcode_agrs($args) { |
|
| 358 | 358 | $args['suppress_filters'] = true; |
| 359 | 359 | |
| 360 | 360 | return $args; |
@@ -389,19 +389,19 @@ discard block |
||
| 389 | 389 | * @since 2.1.4 |
| 390 | 390 | */ |
| 391 | 391 | function give_add_support_for_wpml() { |
| 392 | - if ( ! function_exists( 'is_plugin_active' ) ) { |
|
| 393 | - include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
| 392 | + if ( ! function_exists('is_plugin_active')) { |
|
| 393 | + include_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | |
| 397 | - if ( is_plugin_active( 'sitepress-multilingual-cms/sitepress.php' ) ) { |
|
| 397 | + if (is_plugin_active('sitepress-multilingual-cms/sitepress.php')) { |
|
| 398 | 398 | |
| 399 | - add_filter( 'give_totals_goal_shortcode_query_args', '__give_wpml_total_goal_shortcode_agrs' ); |
|
| 399 | + add_filter('give_totals_goal_shortcode_query_args', '__give_wpml_total_goal_shortcode_agrs'); |
|
| 400 | 400 | |
| 401 | 401 | // @see https://wpml.org/forums/topic/problem-with-query-filter-in-get_posts-function/#post-271309 |
| 402 | - add_action( 'give_totals_goal_shortcode_before_render', '__give_remove_wpml_parse_query_filter', 99 ); |
|
| 403 | - add_action( 'give_totals_goal_shortcode_after_render', '__give_add_wpml_parse_query_filter', 99 ); |
|
| 402 | + add_action('give_totals_goal_shortcode_before_render', '__give_remove_wpml_parse_query_filter', 99); |
|
| 403 | + add_action('give_totals_goal_shortcode_after_render', '__give_add_wpml_parse_query_filter', 99); |
|
| 404 | 404 | } |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | -add_action( 'give_init', 'give_add_support_for_wpml', 1000 ); |
|
| 407 | +add_action('give_init', 'give_add_support_for_wpml', 1000); |
|
@@ -118,7 +118,7 @@ |
||
| 118 | 118 | * @uses api_request() |
| 119 | 119 | * |
| 120 | 120 | * @param array $_transient_data Update array build by WordPress. |
| 121 | - * @return array Modified update array with custom plugin data. |
|
| 121 | + * @return stdClass Modified update array with custom plugin data. |
|
| 122 | 122 | */ |
| 123 | 123 | public function check_update( $_transient_data ) { |
| 124 | 124 | |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Exit if accessed directly |
| 4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 4 | +if ( ! defined('ABSPATH')) { |
|
| 5 | 5 | exit; |
| 6 | 6 | } |
| 7 | 7 | |
@@ -33,21 +33,21 @@ discard block |
||
| 33 | 33 | * @param string $_plugin_file Path to the plugin file. |
| 34 | 34 | * @param array $_api_data Optional data to send with API calls. |
| 35 | 35 | */ |
| 36 | - public function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
| 36 | + public function __construct($_api_url, $_plugin_file, $_api_data = null) { |
|
| 37 | 37 | |
| 38 | 38 | global $edd_plugin_data, $edd_plugin_url_available; |
| 39 | 39 | |
| 40 | - $this->api_url = trailingslashit( $_api_url ); |
|
| 40 | + $this->api_url = trailingslashit($_api_url); |
|
| 41 | 41 | |
| 42 | 42 | $this->api_data = $_api_data; |
| 43 | - $this->name = plugin_basename( $_plugin_file ); |
|
| 44 | - $this->slug = basename( $_plugin_file, '.php' ); |
|
| 43 | + $this->name = plugin_basename($_plugin_file); |
|
| 44 | + $this->slug = basename($_plugin_file, '.php'); |
|
| 45 | 45 | $this->version = $_api_data['version']; |
| 46 | - $this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false; |
|
| 47 | - $this->beta = ! empty( $this->api_data['beta'] ) ? true : false; |
|
| 48 | - $this->cache_key = 'edd_sl_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) ); |
|
| 46 | + $this->wp_override = isset($_api_data['wp_override']) ? (bool) $_api_data['wp_override'] : false; |
|
| 47 | + $this->beta = ! empty($this->api_data['beta']) ? true : false; |
|
| 48 | + $this->cache_key = 'edd_sl_'.md5(serialize($this->slug.$this->api_data['license'].$this->beta)); |
|
| 49 | 49 | |
| 50 | - $edd_plugin_data[ $this->slug ] = $this->api_data; |
|
| 50 | + $edd_plugin_data[$this->slug] = $this->api_data; |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * Fires after the $edd_plugin_data is setup. |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * |
| 57 | 57 | * @param array $edd_plugin_data Array of EDD SL plugin data. |
| 58 | 58 | */ |
| 59 | - do_action( 'post_edd_sl_plugin_updater_setup', $edd_plugin_data ); |
|
| 59 | + do_action('post_edd_sl_plugin_updater_setup', $edd_plugin_data); |
|
| 60 | 60 | |
| 61 | 61 | // Set up hooks. |
| 62 | 62 | $this->init(); |
@@ -72,11 +72,11 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function init() { |
| 74 | 74 | |
| 75 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
| 76 | - add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
| 77 | - remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 ); |
|
| 78 | - add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 ); |
|
| 79 | - add_action( 'admin_init', array( $this, 'show_changelog' ) ); |
|
| 75 | + add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update')); |
|
| 76 | + add_filter('plugins_api', array($this, 'plugins_api_filter'), 10, 3); |
|
| 77 | + remove_action('after_plugin_row_'.$this->name, 'wp_plugin_update_row', 10); |
|
| 78 | + add_action('after_plugin_row_'.$this->name, array($this, 'show_update_notification'), 10, 2); |
|
| 79 | + add_action('admin_init', array($this, 'show_changelog')); |
|
| 80 | 80 | |
| 81 | 81 | } |
| 82 | 82 | |
@@ -93,25 +93,25 @@ discard block |
||
| 93 | 93 | * @param array $_transient_data Update array build by WordPress. |
| 94 | 94 | * @return array Modified update array with custom plugin data. |
| 95 | 95 | */ |
| 96 | - public function check_update( $_transient_data ) { |
|
| 96 | + public function check_update($_transient_data) { |
|
| 97 | 97 | |
| 98 | 98 | global $pagenow; |
| 99 | 99 | |
| 100 | - if ( ! is_object( $_transient_data ) ) { |
|
| 100 | + if ( ! is_object($_transient_data)) { |
|
| 101 | 101 | $_transient_data = new stdClass(); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - if ( 'plugins.php' == $pagenow && is_multisite() ) { |
|
| 104 | + if ('plugins.php' == $pagenow && is_multisite()) { |
|
| 105 | 105 | return $_transient_data; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) { |
|
| 108 | + if ( ! empty($_transient_data->response) && ! empty($_transient_data->response[$this->name]) && false === $this->wp_override) { |
|
| 109 | 109 | return $_transient_data; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | $version_info = $this->get_cached_version_info(); |
| 113 | 113 | |
| 114 | - if ( false === $version_info ) { |
|
| 114 | + if (false === $version_info) { |
|
| 115 | 115 | $version_info = $this->api_request( |
| 116 | 116 | 'plugin_latest_version', array( |
| 117 | 117 | 'slug' => $this->slug, |
@@ -119,20 +119,20 @@ discard block |
||
| 119 | 119 | ) |
| 120 | 120 | ); |
| 121 | 121 | |
| 122 | - $this->set_version_info_cache( $version_info ); |
|
| 122 | + $this->set_version_info_cache($version_info); |
|
| 123 | 123 | |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
| 126 | + if (false !== $version_info && is_object($version_info) && isset($version_info->new_version)) { |
|
| 127 | 127 | |
| 128 | - if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
| 128 | + if (version_compare($this->version, $version_info->new_version, '<')) { |
|
| 129 | 129 | |
| 130 | - $_transient_data->response[ $this->name ] = $version_info; |
|
| 130 | + $_transient_data->response[$this->name] = $version_info; |
|
| 131 | 131 | |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | $_transient_data->last_checked = time(); |
| 135 | - $_transient_data->checked[ $this->name ] = $this->version; |
|
| 135 | + $_transient_data->checked[$this->name] = $this->version; |
|
| 136 | 136 | |
| 137 | 137 | } |
| 138 | 138 | |
@@ -145,36 +145,36 @@ discard block |
||
| 145 | 145 | * @param string $file |
| 146 | 146 | * @param array $plugin |
| 147 | 147 | */ |
| 148 | - public function show_update_notification( $file, $plugin ) { |
|
| 148 | + public function show_update_notification($file, $plugin) { |
|
| 149 | 149 | |
| 150 | - if ( is_network_admin() ) { |
|
| 150 | + if (is_network_admin()) { |
|
| 151 | 151 | return; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - if ( ! current_user_can( 'update_plugins' ) ) { |
|
| 154 | + if ( ! current_user_can('update_plugins')) { |
|
| 155 | 155 | return; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - if ( ! is_multisite() ) { |
|
| 158 | + if ( ! is_multisite()) { |
|
| 159 | 159 | return; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if ( $this->name != $file ) { |
|
| 162 | + if ($this->name != $file) { |
|
| 163 | 163 | return; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | // Remove our filter on the site transient |
| 167 | - remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 ); |
|
| 167 | + remove_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'), 10); |
|
| 168 | 168 | |
| 169 | - $update_cache = get_site_transient( 'update_plugins' ); |
|
| 169 | + $update_cache = get_site_transient('update_plugins'); |
|
| 170 | 170 | |
| 171 | - $update_cache = is_object( $update_cache ) ? $update_cache : new stdClass(); |
|
| 171 | + $update_cache = is_object($update_cache) ? $update_cache : new stdClass(); |
|
| 172 | 172 | |
| 173 | - if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) { |
|
| 173 | + if (empty($update_cache->response) || empty($update_cache->response[$this->name])) { |
|
| 174 | 174 | |
| 175 | 175 | $version_info = $this->get_cached_version_info(); |
| 176 | 176 | |
| 177 | - if ( false === $version_info ) { |
|
| 177 | + if (false === $version_info) { |
|
| 178 | 178 | $version_info = $this->api_request( |
| 179 | 179 | 'plugin_latest_version', array( |
| 180 | 180 | 'slug' => $this->slug, |
@@ -182,65 +182,65 @@ discard block |
||
| 182 | 182 | ) |
| 183 | 183 | ); |
| 184 | 184 | |
| 185 | - $this->set_version_info_cache( $version_info ); |
|
| 185 | + $this->set_version_info_cache($version_info); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - if ( ! is_object( $version_info ) ) { |
|
| 188 | + if ( ! is_object($version_info)) { |
|
| 189 | 189 | return; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
| 192 | + if (version_compare($this->version, $version_info->new_version, '<')) { |
|
| 193 | 193 | |
| 194 | - $update_cache->response[ $this->name ] = $version_info; |
|
| 194 | + $update_cache->response[$this->name] = $version_info; |
|
| 195 | 195 | |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | $update_cache->last_checked = time(); |
| 199 | - $update_cache->checked[ $this->name ] = $this->version; |
|
| 199 | + $update_cache->checked[$this->name] = $this->version; |
|
| 200 | 200 | |
| 201 | - set_site_transient( 'update_plugins', $update_cache ); |
|
| 201 | + set_site_transient('update_plugins', $update_cache); |
|
| 202 | 202 | |
| 203 | 203 | } else { |
| 204 | 204 | |
| 205 | - $version_info = $update_cache->response[ $this->name ]; |
|
| 205 | + $version_info = $update_cache->response[$this->name]; |
|
| 206 | 206 | |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | // Restore our filter |
| 210 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
| 210 | + add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update')); |
|
| 211 | 211 | |
| 212 | - if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
| 212 | + if ( ! empty($update_cache->response[$this->name]) && version_compare($this->version, $version_info->new_version, '<')) { |
|
| 213 | 213 | |
| 214 | 214 | // build a plugin list row, with update notification |
| 215 | - $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
| 215 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 216 | 216 | // <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"> |
| 217 | - echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">'; |
|
| 217 | + echo '<tr class="plugin-update-tr" id="'.$this->slug.'-update" data-slug="'.$this->slug.'" data-plugin="'.$this->slug.'/'.$file.'">'; |
|
| 218 | 218 | echo '<td colspan="3" class="plugin-update colspanchange">'; |
| 219 | 219 | echo '<div class="update-message notice inline notice-warning notice-alt">'; |
| 220 | 220 | |
| 221 | - $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' ); |
|
| 221 | + $changelog_link = self_admin_url('index.php?edd_sl_action=view_plugin_changelog&plugin='.$this->name.'&slug='.$this->slug.'&TB_iframe=true&width=772&height=911'); |
|
| 222 | 222 | |
| 223 | - if ( empty( $version_info->download_link ) ) { |
|
| 223 | + if (empty($version_info->download_link)) { |
|
| 224 | 224 | printf( |
| 225 | - __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'give' ), |
|
| 226 | - esc_html( $version_info->name ), |
|
| 227 | - '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">', |
|
| 228 | - esc_html( $version_info->new_version ), |
|
| 225 | + __('There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'give'), |
|
| 226 | + esc_html($version_info->name), |
|
| 227 | + '<a target="_blank" class="thickbox" href="'.esc_url($changelog_link).'">', |
|
| 228 | + esc_html($version_info->new_version), |
|
| 229 | 229 | '</a>' |
| 230 | 230 | ); |
| 231 | 231 | } else { |
| 232 | 232 | printf( |
| 233 | - __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'give' ), |
|
| 234 | - esc_html( $version_info->name ), |
|
| 235 | - '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">', |
|
| 236 | - esc_html( $version_info->new_version ), |
|
| 233 | + __('There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'give'), |
|
| 234 | + esc_html($version_info->name), |
|
| 235 | + '<a target="_blank" class="thickbox" href="'.esc_url($changelog_link).'">', |
|
| 236 | + esc_html($version_info->new_version), |
|
| 237 | 237 | '</a>', |
| 238 | - '<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) . '">', |
|
| 238 | + '<a href="'.esc_url(wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$this->name, 'upgrade-plugin_'.$this->name)).'">', |
|
| 239 | 239 | '</a>' |
| 240 | 240 | ); |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - do_action( "in_plugin_update_message-{$file}", $plugin, $version_info ); |
|
| 243 | + do_action("in_plugin_update_message-{$file}", $plugin, $version_info); |
|
| 244 | 244 | |
| 245 | 245 | echo '</div></td></tr>'; |
| 246 | 246 | } |
@@ -256,15 +256,15 @@ discard block |
||
| 256 | 256 | * @param object $_args |
| 257 | 257 | * @return object $_data |
| 258 | 258 | */ |
| 259 | - public function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
| 259 | + public function plugins_api_filter($_data, $_action = '', $_args = null) { |
|
| 260 | 260 | |
| 261 | - if ( $_action != 'plugin_information' ) { |
|
| 261 | + if ($_action != 'plugin_information') { |
|
| 262 | 262 | |
| 263 | 263 | return $_data; |
| 264 | 264 | |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
| 267 | + if ( ! isset($_args->slug) || ($_args->slug != $this->slug)) { |
|
| 268 | 268 | |
| 269 | 269 | return $_data; |
| 270 | 270 | |
@@ -279,20 +279,20 @@ discard block |
||
| 279 | 279 | ), |
| 280 | 280 | ); |
| 281 | 281 | |
| 282 | - $cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) ); |
|
| 282 | + $cache_key = 'edd_api_request_'.md5(serialize($this->slug.$this->api_data['license'].$this->beta)); |
|
| 283 | 283 | |
| 284 | 284 | // Get the transient where we store the api request for this plugin for 24 hours |
| 285 | - $edd_api_request_transient = $this->get_cached_version_info( $cache_key ); |
|
| 285 | + $edd_api_request_transient = $this->get_cached_version_info($cache_key); |
|
| 286 | 286 | |
| 287 | 287 | // If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now. |
| 288 | - if ( empty( $edd_api_request_transient ) ) { |
|
| 288 | + if (empty($edd_api_request_transient)) { |
|
| 289 | 289 | |
| 290 | - $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
| 290 | + $api_response = $this->api_request('plugin_information', $to_send); |
|
| 291 | 291 | |
| 292 | 292 | // Expires in 3 hours |
| 293 | - $this->set_version_info_cache( $api_response, $cache_key ); |
|
| 293 | + $this->set_version_info_cache($api_response, $cache_key); |
|
| 294 | 294 | |
| 295 | - if ( false !== $api_response ) { |
|
| 295 | + if (false !== $api_response) { |
|
| 296 | 296 | $_data = $api_response; |
| 297 | 297 | } |
| 298 | 298 | } else { |
@@ -300,20 +300,20 @@ discard block |
||
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | // Convert sections into an associative array, since we're getting an object, but Core expects an array. |
| 303 | - if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) { |
|
| 303 | + if (isset($_data->sections) && ! is_array($_data->sections)) { |
|
| 304 | 304 | $new_sections = array(); |
| 305 | - foreach ( $_data->sections as $key => $value ) { |
|
| 306 | - $new_sections[ $key ] = $value; |
|
| 305 | + foreach ($_data->sections as $key => $value) { |
|
| 306 | + $new_sections[$key] = $value; |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | $_data->sections = $new_sections; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | // Convert banners into an associative array, since we're getting an object, but Core expects an array. |
| 313 | - if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) { |
|
| 313 | + if (isset($_data->banners) && ! is_array($_data->banners)) { |
|
| 314 | 314 | $new_banners = array(); |
| 315 | - foreach ( $_data->banners as $key => $value ) { |
|
| 316 | - $new_banners[ $key ] = $value; |
|
| 315 | + foreach ($_data->banners as $key => $value) { |
|
| 316 | + $new_banners[$key] = $value; |
|
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | $_data->banners = $new_banners; |
@@ -329,10 +329,10 @@ discard block |
||
| 329 | 329 | * @param string $url |
| 330 | 330 | * @return object $array |
| 331 | 331 | */ |
| 332 | - public function http_request_args( $args, $url ) { |
|
| 332 | + public function http_request_args($args, $url) { |
|
| 333 | 333 | |
| 334 | 334 | $verify_ssl = $this->verify_ssl(); |
| 335 | - if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
| 335 | + if (strpos($url, 'https://') !== false && strpos($url, 'edd_action=package_download')) { |
|
| 336 | 336 | $args['sslverify'] = $verify_ssl; |
| 337 | 337 | } |
| 338 | 338 | return $args; |
@@ -350,30 +350,30 @@ discard block |
||
| 350 | 350 | * @param array $_data Parameters for the API action. |
| 351 | 351 | * @return false|object |
| 352 | 352 | */ |
| 353 | - private function api_request( $_action, $_data ) { |
|
| 353 | + private function api_request($_action, $_data) { |
|
| 354 | 354 | |
| 355 | 355 | global $wp_version; |
| 356 | 356 | |
| 357 | - $data = array_merge( $this->api_data, $_data ); |
|
| 357 | + $data = array_merge($this->api_data, $_data); |
|
| 358 | 358 | |
| 359 | - if ( $data['slug'] != $this->slug ) { |
|
| 359 | + if ($data['slug'] != $this->slug) { |
|
| 360 | 360 | return; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | - if ( $this->api_url == trailingslashit( home_url() ) ) { |
|
| 363 | + if ($this->api_url == trailingslashit(home_url())) { |
|
| 364 | 364 | return false; // Don't allow a plugin to ping itself |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | $api_params = array( |
| 368 | 368 | 'edd_action' => 'get_version', |
| 369 | - 'license' => ! empty( $data['license'] ) ? $data['license'] : '', |
|
| 370 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
| 371 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
| 372 | - 'version' => isset( $data['version'] ) ? $data['version'] : false, |
|
| 369 | + 'license' => ! empty($data['license']) ? $data['license'] : '', |
|
| 370 | + 'item_name' => isset($data['item_name']) ? $data['item_name'] : false, |
|
| 371 | + 'item_id' => isset($data['item_id']) ? $data['item_id'] : false, |
|
| 372 | + 'version' => isset($data['version']) ? $data['version'] : false, |
|
| 373 | 373 | 'slug' => $data['slug'], |
| 374 | 374 | 'author' => $data['author'], |
| 375 | 375 | 'url' => home_url(), |
| 376 | - 'beta' => ! empty( $data['beta'] ), |
|
| 376 | + 'beta' => ! empty($data['beta']), |
|
| 377 | 377 | ); |
| 378 | 378 | |
| 379 | 379 | $verify_ssl = $this->verify_ssl(); |
@@ -385,22 +385,22 @@ discard block |
||
| 385 | 385 | ) |
| 386 | 386 | ); |
| 387 | 387 | |
| 388 | - if ( ! is_wp_error( $request ) ) { |
|
| 389 | - $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
| 388 | + if ( ! is_wp_error($request)) { |
|
| 389 | + $request = json_decode(wp_remote_retrieve_body($request)); |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - if ( $request && isset( $request->sections ) ) { |
|
| 393 | - $request->sections = maybe_unserialize( $request->sections ); |
|
| 392 | + if ($request && isset($request->sections)) { |
|
| 393 | + $request->sections = maybe_unserialize($request->sections); |
|
| 394 | 394 | } else { |
| 395 | 395 | $request = false; |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | - if ( $request && isset( $request->banners ) ) { |
|
| 399 | - $request->banners = maybe_unserialize( $request->banners ); |
|
| 398 | + if ($request && isset($request->banners)) { |
|
| 399 | + $request->banners = maybe_unserialize($request->banners); |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | - if ( ! empty( $request->sections ) ) { |
|
| 403 | - foreach ( $request->sections as $key => $section ) { |
|
| 402 | + if ( ! empty($request->sections)) { |
|
| 403 | + foreach ($request->sections as $key => $section) { |
|
| 404 | 404 | $request->$key = (array) $section; |
| 405 | 405 | } |
| 406 | 406 | } |
@@ -412,37 +412,37 @@ discard block |
||
| 412 | 412 | |
| 413 | 413 | global $edd_plugin_data; |
| 414 | 414 | |
| 415 | - if ( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
|
| 415 | + if (empty($_REQUEST['edd_sl_action']) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action']) { |
|
| 416 | 416 | return; |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - if ( empty( $_REQUEST['plugin'] ) ) { |
|
| 419 | + if (empty($_REQUEST['plugin'])) { |
|
| 420 | 420 | return; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - if ( empty( $_REQUEST['slug'] ) ) { |
|
| 423 | + if (empty($_REQUEST['slug'])) { |
|
| 424 | 424 | return; |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - if ( ! current_user_can( 'update_plugins' ) ) { |
|
| 428 | - wp_die( __( 'You do not have permission to install plugin updates', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 427 | + if ( ! current_user_can('update_plugins')) { |
|
| 428 | + wp_die(__('You do not have permission to install plugin updates', 'give'), __('Error', 'give'), array('response' => 403)); |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | - $data = $edd_plugin_data[ $_REQUEST['slug'] ]; |
|
| 432 | - $beta = ! empty( $data['beta'] ) ? true : false; |
|
| 433 | - $cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' ); |
|
| 434 | - $version_info = $this->get_cached_version_info( $cache_key ); |
|
| 431 | + $data = $edd_plugin_data[$_REQUEST['slug']]; |
|
| 432 | + $beta = ! empty($data['beta']) ? true : false; |
|
| 433 | + $cache_key = md5('edd_plugin_'.sanitize_key($_REQUEST['plugin']).'_'.$beta.'_version_info'); |
|
| 434 | + $version_info = $this->get_cached_version_info($cache_key); |
|
| 435 | 435 | |
| 436 | - if ( false === $version_info ) { |
|
| 436 | + if (false === $version_info) { |
|
| 437 | 437 | |
| 438 | 438 | $api_params = array( |
| 439 | 439 | 'edd_action' => 'get_version', |
| 440 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
| 441 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
| 440 | + 'item_name' => isset($data['item_name']) ? $data['item_name'] : false, |
|
| 441 | + 'item_id' => isset($data['item_id']) ? $data['item_id'] : false, |
|
| 442 | 442 | 'slug' => $_REQUEST['slug'], |
| 443 | 443 | 'author' => $data['author'], |
| 444 | 444 | 'url' => home_url(), |
| 445 | - 'beta' => ! empty( $data['beta'] ), |
|
| 445 | + 'beta' => ! empty($data['beta']), |
|
| 446 | 446 | ); |
| 447 | 447 | |
| 448 | 448 | $verify_ssl = $this->verify_ssl(); |
@@ -454,61 +454,61 @@ discard block |
||
| 454 | 454 | ) |
| 455 | 455 | ); |
| 456 | 456 | |
| 457 | - if ( ! is_wp_error( $request ) ) { |
|
| 458 | - $version_info = json_decode( wp_remote_retrieve_body( $request ) ); |
|
| 457 | + if ( ! is_wp_error($request)) { |
|
| 458 | + $version_info = json_decode(wp_remote_retrieve_body($request)); |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - if ( ! empty( $version_info ) && isset( $version_info->sections ) ) { |
|
| 462 | - $version_info->sections = maybe_unserialize( $version_info->sections ); |
|
| 461 | + if ( ! empty($version_info) && isset($version_info->sections)) { |
|
| 462 | + $version_info->sections = maybe_unserialize($version_info->sections); |
|
| 463 | 463 | } else { |
| 464 | 464 | $version_info = false; |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | - if ( ! empty( $version_info ) ) { |
|
| 468 | - foreach ( $version_info->sections as $key => $section ) { |
|
| 467 | + if ( ! empty($version_info)) { |
|
| 468 | + foreach ($version_info->sections as $key => $section) { |
|
| 469 | 469 | $version_info->$key = (array) $section; |
| 470 | 470 | } |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - $this->set_version_info_cache( $version_info, $cache_key ); |
|
| 473 | + $this->set_version_info_cache($version_info, $cache_key); |
|
| 474 | 474 | |
| 475 | 475 | } |
| 476 | 476 | |
| 477 | - if ( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) { |
|
| 478 | - echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>'; |
|
| 477 | + if ( ! empty($version_info) && isset($version_info->sections['changelog'])) { |
|
| 478 | + echo '<div style="background:#fff;padding:10px;">'.$version_info->sections['changelog'].'</div>'; |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | exit; |
| 482 | 482 | } |
| 483 | 483 | |
| 484 | - public function get_cached_version_info( $cache_key = '' ) { |
|
| 484 | + public function get_cached_version_info($cache_key = '') { |
|
| 485 | 485 | |
| 486 | - if ( empty( $cache_key ) ) { |
|
| 486 | + if (empty($cache_key)) { |
|
| 487 | 487 | $cache_key = $this->cache_key; |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - $cache = get_option( $cache_key ); |
|
| 490 | + $cache = get_option($cache_key); |
|
| 491 | 491 | |
| 492 | - if ( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) { |
|
| 492 | + if (empty($cache['timeout']) || time() > $cache['timeout']) { |
|
| 493 | 493 | return false; // Cache is expired |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | - return json_decode( $cache['value'] ); |
|
| 496 | + return json_decode($cache['value']); |
|
| 497 | 497 | |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | - public function set_version_info_cache( $value = '', $cache_key = '' ) { |
|
| 500 | + public function set_version_info_cache($value = '', $cache_key = '') { |
|
| 501 | 501 | |
| 502 | - if ( empty( $cache_key ) ) { |
|
| 502 | + if (empty($cache_key)) { |
|
| 503 | 503 | $cache_key = $this->cache_key; |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | $data = array( |
| 507 | - 'timeout' => strtotime( '+3 hours', time() ), |
|
| 508 | - 'value' => json_encode( $value ), |
|
| 507 | + 'timeout' => strtotime('+3 hours', time()), |
|
| 508 | + 'value' => json_encode($value), |
|
| 509 | 509 | ); |
| 510 | 510 | |
| 511 | - update_option( $cache_key, $data, 'no' ); |
|
| 511 | + update_option($cache_key, $data, 'no'); |
|
| 512 | 512 | |
| 513 | 513 | } |
| 514 | 514 | |
@@ -519,7 +519,7 @@ discard block |
||
| 519 | 519 | * @return bool |
| 520 | 520 | */ |
| 521 | 521 | private function verify_ssl() { |
| 522 | - return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this ); |
|
| 522 | + return (bool) apply_filters('edd_sl_api_request_verify_ssl', true, $this); |
|
| 523 | 523 | } |
| 524 | 524 | |
| 525 | 525 | } |
@@ -4,13 +4,13 @@ discard block |
||
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | // Exit if accessed directly. |
| 7 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 7 | +if ( ! defined('ABSPATH')) { |
|
| 8 | 8 | exit; |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | /** @var $donor Give_Donor */ |
| 12 | 12 | $donor = $args[0]; |
| 13 | -$donor = new Give_Donor( $donor->id ); |
|
| 13 | +$donor = new Give_Donor($donor->id); |
|
| 14 | 14 | |
| 15 | 15 | $give_settings = $args[1]; // Give settings. |
| 16 | 16 | $atts = $args[2]; // Shortcode attributes. |
@@ -21,17 +21,17 @@ discard block |
||
| 21 | 21 | <div class="give-donor__header"> |
| 22 | 22 | <?php |
| 23 | 23 | // Maybe display the Avatar. |
| 24 | - if ( true === $atts['show_avatar'] ) { |
|
| 25 | - echo give_get_donor_avatar( $donor ); |
|
| 24 | + if (true === $atts['show_avatar']) { |
|
| 25 | + echo give_get_donor_avatar($donor); |
|
| 26 | 26 | } |
| 27 | 27 | ?> |
| 28 | 28 | |
| 29 | 29 | <div class="give-donor__details"> |
| 30 | - <?php if ( true === $atts['show_name'] ) : ?> |
|
| 31 | - <h3 class="give-donor__name"><?php esc_html_e( $donor->name ); ?></h3> |
|
| 30 | + <?php if (true === $atts['show_name']) : ?> |
|
| 31 | + <h3 class="give-donor__name"><?php esc_html_e($donor->name); ?></h3> |
|
| 32 | 32 | <?php endif; ?> |
| 33 | 33 | |
| 34 | - <?php if ( true === $atts['show_total'] ) : ?> |
|
| 34 | + <?php if (true === $atts['show_total']) : ?> |
|
| 35 | 35 | <span class="give-donor__total"> |
| 36 | 36 | <?php |
| 37 | 37 | $donated_amount = Give_Donor_Stats::donated( |
@@ -41,17 +41,17 @@ discard block |
||
| 41 | 41 | ) |
| 42 | 42 | ); |
| 43 | 43 | |
| 44 | - echo give_currency_filter( give_format_amount( $donated_amount, array( 'sanitize' => false ) ) ); |
|
| 44 | + echo give_currency_filter(give_format_amount($donated_amount, array('sanitize' => false))); |
|
| 45 | 45 | ?> |
| 46 | 46 | </span> |
| 47 | 47 | <?php endif; ?> |
| 48 | 48 | |
| 49 | - <?php if ( true === $atts['show_time'] ) : ?> |
|
| 49 | + <?php if (true === $atts['show_time']) : ?> |
|
| 50 | 50 | <span class="give-donor__timestamp"> |
| 51 | 51 | <?php |
| 52 | 52 | // If not filtered by form ID then display the "Donor Since" text. |
| 53 | 53 | // If filtered by form ID then display the last donation date. |
| 54 | - echo $donor->get_last_donation_date( true ); |
|
| 54 | + echo $donor->get_last_donation_date(true); |
|
| 55 | 55 | ?> |
| 56 | 56 | </span> |
| 57 | 57 | <?php endif; ?> |
@@ -59,18 +59,18 @@ discard block |
||
| 59 | 59 | </div> |
| 60 | 60 | |
| 61 | 61 | <?php |
| 62 | - $comment = give_get_donor_latest_comment( $donor->id, $atts['form_id'] ); |
|
| 62 | + $comment = give_get_donor_latest_comment($donor->id, $atts['form_id']); |
|
| 63 | 63 | |
| 64 | - if ( true === $atts['show_comments'] && absint( $atts['comment_length'] ) && $comment instanceof WP_Comment ) : |
|
| 64 | + if (true === $atts['show_comments'] && absint($atts['comment_length']) && $comment instanceof WP_Comment) : |
|
| 65 | 65 | ?> |
| 66 | 66 | <div class="give-donor__content"> |
| 67 | 67 | <?php |
| 68 | - $comment_content = apply_filters( 'the_content', $comment->comment_content ); |
|
| 68 | + $comment_content = apply_filters('the_content', $comment->comment_content); |
|
| 69 | 69 | |
| 70 | - if ( $atts['comment_length'] < strlen( $comment->comment_content ) ) { |
|
| 70 | + if ($atts['comment_length'] < strlen($comment->comment_content)) { |
|
| 71 | 71 | echo sprintf( |
| 72 | 72 | '<p class="give-donor__comment_excerpt">%s…<span> <a class="give-donor__read-more">%s</a></span></p>', |
| 73 | - substr( $comment_content, 0, $atts['comment_length'] ), |
|
| 73 | + substr($comment_content, 0, $atts['comment_length']), |
|
| 74 | 74 | $atts['readmore_text'] |
| 75 | 75 | ); |
| 76 | 76 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly. |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if ( ! defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * Constructor. |
| 48 | 48 | */ |
| 49 | - public function __construct( $_step = 1 ) { |
|
| 50 | - parent::__construct( $_step ); |
|
| 49 | + public function __construct($_step = 1) { |
|
| 50 | + parent::__construct($_step); |
|
| 51 | 51 | |
| 52 | 52 | $this->is_writable = true; |
| 53 | 53 | } |
@@ -61,32 +61,32 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function get_data() { |
| 63 | 63 | |
| 64 | - if ( $this->step == 1 ) { |
|
| 65 | - $this->delete_data( 'give_temp_recount_earnings' ); |
|
| 64 | + if ($this->step == 1) { |
|
| 65 | + $this->delete_data('give_temp_recount_earnings'); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - $total = get_option( 'give_temp_recount_earnings', false ); |
|
| 68 | + $total = get_option('give_temp_recount_earnings', false); |
|
| 69 | 69 | |
| 70 | - if ( false === $total ) { |
|
| 70 | + if (false === $total) { |
|
| 71 | 71 | $total = (float) 0; |
| 72 | - $this->store_data( 'give_temp_recount_earnings', $total ); |
|
| 72 | + $this->store_data('give_temp_recount_earnings', $total); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
| 75 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
| 76 | 76 | |
| 77 | - $args = apply_filters( 'give_recount_earnings_args', array( |
|
| 77 | + $args = apply_filters('give_recount_earnings_args', array( |
|
| 78 | 78 | 'number' => $this->per_step, |
| 79 | 79 | 'page' => $this->step, |
| 80 | 80 | 'status' => $accepted_statuses, |
| 81 | - ) ); |
|
| 81 | + )); |
|
| 82 | 82 | |
| 83 | - $payments = give_get_payments( $args ); |
|
| 83 | + $payments = give_get_payments($args); |
|
| 84 | 84 | |
| 85 | - if ( ! empty( $payments ) ) { |
|
| 85 | + if ( ! empty($payments)) { |
|
| 86 | 86 | |
| 87 | - foreach ( $payments as $payment ) { |
|
| 87 | + foreach ($payments as $payment) { |
|
| 88 | 88 | // Get the payment amount. |
| 89 | - $payment_amount = give_get_meta( $payment->ID, '_give_payment_total', true ); |
|
| 89 | + $payment_amount = give_get_meta($payment->ID, '_give_payment_total', true); |
|
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | 92 | * Filter the payment amount. |
@@ -95,28 +95,28 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | $donation_amount = apply_filters( |
| 97 | 97 | 'give_donation_amount', |
| 98 | - give_format_amount( $payment_amount, array( 'donation_id' => $payment->ID ) ), |
|
| 98 | + give_format_amount($payment_amount, array('donation_id' => $payment->ID)), |
|
| 99 | 99 | $payment->total, |
| 100 | 100 | $payment->ID, |
| 101 | - array( 'type' => 'stats', 'currency' => false, 'amount' => false ) |
|
| 101 | + array('type' => 'stats', 'currency' => false, 'amount' => false) |
|
| 102 | 102 | ); |
| 103 | 103 | |
| 104 | - $total += (float) give_maybe_sanitize_amount( $donation_amount ); |
|
| 104 | + $total += (float) give_maybe_sanitize_amount($donation_amount); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if ( $total < 0 ) { |
|
| 107 | + if ($total < 0) { |
|
| 108 | 108 | $totals = 0; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - $total = round( $total, give_get_price_decimals() ); |
|
| 111 | + $total = round($total, give_get_price_decimals()); |
|
| 112 | 112 | |
| 113 | - $this->store_data( 'give_temp_recount_earnings', $total ); |
|
| 113 | + $this->store_data('give_temp_recount_earnings', $total); |
|
| 114 | 114 | |
| 115 | 115 | return true; |
| 116 | 116 | |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - update_option( 'give_earnings_total', $total, false ); |
|
| 119 | + update_option('give_earnings_total', $total, false); |
|
| 120 | 120 | |
| 121 | 121 | return false; |
| 122 | 122 | |
@@ -130,25 +130,25 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public function get_percentage_complete() { |
| 132 | 132 | |
| 133 | - $total = $this->get_stored_data( 'give_recount_earnings_total' ); |
|
| 133 | + $total = $this->get_stored_data('give_recount_earnings_total'); |
|
| 134 | 134 | |
| 135 | - if ( false === $total ) { |
|
| 136 | - $args = apply_filters( 'give_recount_earnings_total_args', array() ); |
|
| 135 | + if (false === $total) { |
|
| 136 | + $args = apply_filters('give_recount_earnings_total_args', array()); |
|
| 137 | 137 | |
| 138 | - $counts = give_count_payments( $args ); |
|
| 139 | - $total = absint( $counts->publish ); |
|
| 140 | - $total = apply_filters( 'give_recount_store_earnings_total', $total ); |
|
| 138 | + $counts = give_count_payments($args); |
|
| 139 | + $total = absint($counts->publish); |
|
| 140 | + $total = apply_filters('give_recount_store_earnings_total', $total); |
|
| 141 | 141 | |
| 142 | - $this->store_data( 'give_recount_earnings_total', $total ); |
|
| 142 | + $this->store_data('give_recount_earnings_total', $total); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | $percentage = 100; |
| 146 | 146 | |
| 147 | - if ( $total > 0 ) { |
|
| 148 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
| 147 | + if ($total > 0) { |
|
| 148 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - if ( $percentage > 100 ) { |
|
| 151 | + if ($percentage > 100) { |
|
| 152 | 152 | $percentage = 100; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * |
| 163 | 163 | * @param array $request The Form Data passed into the batch processing |
| 164 | 164 | */ |
| 165 | - public function set_properties( $request ) { |
|
| 165 | + public function set_properties($request) { |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -173,21 +173,21 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | public function process_step() { |
| 175 | 175 | |
| 176 | - if ( ! $this->can_export() ) { |
|
| 177 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 176 | + if ( ! $this->can_export()) { |
|
| 177 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | $had_data = $this->get_data(); |
| 181 | 181 | |
| 182 | - if ( $had_data ) { |
|
| 182 | + if ($had_data) { |
|
| 183 | 183 | $this->done = false; |
| 184 | 184 | |
| 185 | 185 | return true; |
| 186 | 186 | } else { |
| 187 | - $this->delete_data( 'give_recount_earnings_total' ); |
|
| 188 | - $this->delete_data( 'give_temp_recount_earnings' ); |
|
| 187 | + $this->delete_data('give_recount_earnings_total'); |
|
| 188 | + $this->delete_data('give_temp_recount_earnings'); |
|
| 189 | 189 | $this->done = true; |
| 190 | - $this->message = esc_html__( 'Income stats have been successfully recounted.', 'give' ); |
|
| 190 | + $this->message = esc_html__('Income stats have been successfully recounted.', 'give'); |
|
| 191 | 191 | |
| 192 | 192 | return false; |
| 193 | 193 | } |
@@ -224,17 +224,17 @@ discard block |
||
| 224 | 224 | * |
| 225 | 225 | * @return mixed Returns the data from the database |
| 226 | 226 | */ |
| 227 | - private function get_stored_data( $key ) { |
|
| 227 | + private function get_stored_data($key) { |
|
| 228 | 228 | global $wpdb; |
| 229 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
| 229 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
| 230 | 230 | |
| 231 | - if ( empty( $value ) ) { |
|
| 231 | + if (empty($value)) { |
|
| 232 | 232 | return false; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - $maybe_json = json_decode( $value ); |
|
| 236 | - if ( ! is_null( $maybe_json ) ) { |
|
| 237 | - $value = json_decode( $value, true ); |
|
| 235 | + $maybe_json = json_decode($value); |
|
| 236 | + if ( ! is_null($maybe_json)) { |
|
| 237 | + $value = json_decode($value, true); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | return $value; |
@@ -250,10 +250,10 @@ discard block |
||
| 250 | 250 | * |
| 251 | 251 | * @return void |
| 252 | 252 | */ |
| 253 | - private function store_data( $key, $value ) { |
|
| 253 | + private function store_data($key, $value) { |
|
| 254 | 254 | global $wpdb; |
| 255 | 255 | |
| 256 | - $value = is_array( $value ) ? wp_json_encode( $value ) : esc_attr( $value ); |
|
| 256 | + $value = is_array($value) ? wp_json_encode($value) : esc_attr($value); |
|
| 257 | 257 | |
| 258 | 258 | $data = array( |
| 259 | 259 | 'option_name' => $key, |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | '%s', |
| 268 | 268 | ); |
| 269 | 269 | |
| 270 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
| 270 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | /** |
@@ -279,9 +279,9 @@ discard block |
||
| 279 | 279 | * |
| 280 | 280 | * @return void |
| 281 | 281 | */ |
| 282 | - private function delete_data( $key ) { |
|
| 282 | + private function delete_data($key) { |
|
| 283 | 283 | global $wpdb; |
| 284 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
| 284 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | 15 | // Exit if accessed directly. |
| 16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 16 | +if ( ! defined('ABSPATH')) { |
|
| 17 | 17 | exit; |
| 18 | 18 | } |
| 19 | 19 | |
@@ -25,70 +25,70 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | function give_do_automatic_upgrades() { |
| 27 | 27 | $did_upgrade = false; |
| 28 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
| 28 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
| 29 | 29 | |
| 30 | - if ( ! $give_version ) { |
|
| 30 | + if ( ! $give_version) { |
|
| 31 | 31 | // 1.0 is the first version to use this option so we must add it. |
| 32 | 32 | $give_version = '1.0'; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - switch ( true ) { |
|
| 35 | + switch (true) { |
|
| 36 | 36 | |
| 37 | - case version_compare( $give_version, '1.6', '<' ): |
|
| 37 | + case version_compare($give_version, '1.6', '<'): |
|
| 38 | 38 | give_v16_upgrades(); |
| 39 | 39 | $did_upgrade = true; |
| 40 | 40 | |
| 41 | - case version_compare( $give_version, '1.7', '<' ): |
|
| 41 | + case version_compare($give_version, '1.7', '<'): |
|
| 42 | 42 | give_v17_upgrades(); |
| 43 | 43 | $did_upgrade = true; |
| 44 | 44 | |
| 45 | - case version_compare( $give_version, '1.8', '<' ): |
|
| 45 | + case version_compare($give_version, '1.8', '<'): |
|
| 46 | 46 | give_v18_upgrades(); |
| 47 | 47 | $did_upgrade = true; |
| 48 | 48 | |
| 49 | - case version_compare( $give_version, '1.8.7', '<' ): |
|
| 49 | + case version_compare($give_version, '1.8.7', '<'): |
|
| 50 | 50 | give_v187_upgrades(); |
| 51 | 51 | $did_upgrade = true; |
| 52 | 52 | |
| 53 | - case version_compare( $give_version, '1.8.8', '<' ): |
|
| 53 | + case version_compare($give_version, '1.8.8', '<'): |
|
| 54 | 54 | give_v188_upgrades(); |
| 55 | 55 | $did_upgrade = true; |
| 56 | 56 | |
| 57 | - case version_compare( $give_version, '1.8.9', '<' ): |
|
| 57 | + case version_compare($give_version, '1.8.9', '<'): |
|
| 58 | 58 | give_v189_upgrades(); |
| 59 | 59 | $did_upgrade = true; |
| 60 | 60 | |
| 61 | - case version_compare( $give_version, '1.8.12', '<' ): |
|
| 61 | + case version_compare($give_version, '1.8.12', '<'): |
|
| 62 | 62 | give_v1812_upgrades(); |
| 63 | 63 | $did_upgrade = true; |
| 64 | 64 | |
| 65 | - case version_compare( $give_version, '1.8.13', '<' ): |
|
| 65 | + case version_compare($give_version, '1.8.13', '<'): |
|
| 66 | 66 | give_v1813_upgrades(); |
| 67 | 67 | $did_upgrade = true; |
| 68 | 68 | |
| 69 | - case version_compare( $give_version, '1.8.17', '<' ): |
|
| 69 | + case version_compare($give_version, '1.8.17', '<'): |
|
| 70 | 70 | give_v1817_upgrades(); |
| 71 | 71 | $did_upgrade = true; |
| 72 | 72 | |
| 73 | - case version_compare( $give_version, '1.8.18', '<' ): |
|
| 73 | + case version_compare($give_version, '1.8.18', '<'): |
|
| 74 | 74 | give_v1818_upgrades(); |
| 75 | 75 | $did_upgrade = true; |
| 76 | 76 | |
| 77 | - case version_compare( $give_version, '2.0', '<' ): |
|
| 77 | + case version_compare($give_version, '2.0', '<'): |
|
| 78 | 78 | give_v20_upgrades(); |
| 79 | 79 | $did_upgrade = true; |
| 80 | 80 | |
| 81 | - case version_compare( $give_version, '2.0.1', '<' ): |
|
| 81 | + case version_compare($give_version, '2.0.1', '<'): |
|
| 82 | 82 | // Do nothing on fresh install. |
| 83 | - if ( ! doing_action( 'give_upgrades' ) ) { |
|
| 83 | + if ( ! doing_action('give_upgrades')) { |
|
| 84 | 84 | give_v201_create_tables(); |
| 85 | - Give_Updates::get_instance()->__health_background_update( Give_Updates::get_instance() ); |
|
| 85 | + Give_Updates::get_instance()->__health_background_update(Give_Updates::get_instance()); |
|
| 86 | 86 | Give_Updates::$background_updater->dispatch(); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | $did_upgrade = true; |
| 90 | 90 | |
| 91 | - case version_compare( $give_version, '2.0.2', '<' ): |
|
| 91 | + case version_compare($give_version, '2.0.2', '<'): |
|
| 92 | 92 | // Remove 2.0.1 update to rerun on 2.0.2 |
| 93 | 93 | $completed_upgrades = give_get_completed_upgrades(); |
| 94 | 94 | $v201_updates = array( |
@@ -98,43 +98,43 @@ discard block |
||
| 98 | 98 | 'v201_logs_upgrades', |
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | - foreach ( $v201_updates as $v201_update ) { |
|
| 102 | - if ( in_array( $v201_update, $completed_upgrades ) ) { |
|
| 103 | - unset( $completed_upgrades[ array_search( $v201_update, $completed_upgrades ) ] ); |
|
| 101 | + foreach ($v201_updates as $v201_update) { |
|
| 102 | + if (in_array($v201_update, $completed_upgrades)) { |
|
| 103 | + unset($completed_upgrades[array_search($v201_update, $completed_upgrades)]); |
|
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - update_option( 'give_completed_upgrades', $completed_upgrades, false ); |
|
| 107 | + update_option('give_completed_upgrades', $completed_upgrades, false); |
|
| 108 | 108 | |
| 109 | 109 | // Do nothing on fresh install. |
| 110 | - if ( ! doing_action( 'give_upgrades' ) ) { |
|
| 110 | + if ( ! doing_action('give_upgrades')) { |
|
| 111 | 111 | give_v201_create_tables(); |
| 112 | - Give_Updates::get_instance()->__health_background_update( Give_Updates::get_instance() ); |
|
| 112 | + Give_Updates::get_instance()->__health_background_update(Give_Updates::get_instance()); |
|
| 113 | 113 | Give_Updates::$background_updater->dispatch(); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | $did_upgrade = true; |
| 117 | 117 | |
| 118 | - case version_compare( $give_version, '2.0.3', '<' ): |
|
| 118 | + case version_compare($give_version, '2.0.3', '<'): |
|
| 119 | 119 | give_v203_upgrades(); |
| 120 | 120 | $did_upgrade = true; |
| 121 | 121 | |
| 122 | - case version_compare( $give_version, '2.2.0', '<' ): |
|
| 122 | + case version_compare($give_version, '2.2.0', '<'): |
|
| 123 | 123 | give_v220_upgrades(); |
| 124 | 124 | $did_upgrade = true; |
| 125 | 125 | |
| 126 | - case version_compare( $give_version, '2.2.1', '<' ): |
|
| 126 | + case version_compare($give_version, '2.2.1', '<'): |
|
| 127 | 127 | give_v221_upgrades(); |
| 128 | 128 | $did_upgrade = true; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if ( $did_upgrade ) { |
|
| 132 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ), false ); |
|
| 131 | + if ($did_upgrade) { |
|
| 132 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION), false); |
|
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
| 137 | -add_action( 'give_upgrades', 'give_do_automatic_upgrades' ); |
|
| 136 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
| 137 | +add_action('give_upgrades', 'give_do_automatic_upgrades'); |
|
| 138 | 138 | |
| 139 | 139 | /** |
| 140 | 140 | * Display Upgrade Notices. |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @return void |
| 150 | 150 | */ |
| 151 | -function give_show_upgrade_notices( $give_updates ) { |
|
| 151 | +function give_show_upgrade_notices($give_updates) { |
|
| 152 | 152 | // v1.3.2 Upgrades |
| 153 | 153 | $give_updates->register( |
| 154 | 154 | array( |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | 'id' => 'v20_move_metadata_into_new_table', |
| 302 | 302 | 'version' => '2.0.0', |
| 303 | 303 | 'callback' => 'give_v20_move_metadata_into_new_table_callback', |
| 304 | - 'depend' => array( 'v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata' ), |
|
| 304 | + 'depend' => array('v20_upgrades_payment_metadata', 'v20_upgrades_form_metadata'), |
|
| 305 | 305 | ) |
| 306 | 306 | ); |
| 307 | 307 | |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | 'id' => 'v201_move_metadata_into_new_table', |
| 347 | 347 | 'version' => '2.0.1', |
| 348 | 348 | 'callback' => 'give_v201_move_metadata_into_new_table_callback', |
| 349 | - 'depend' => array( 'v201_upgrades_payment_metadata', 'v201_add_missing_donors' ), |
|
| 349 | + 'depend' => array('v201_upgrades_payment_metadata', 'v201_add_missing_donors'), |
|
| 350 | 350 | ) |
| 351 | 351 | ); |
| 352 | 352 | |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | 'id' => 'v213_delete_donation_meta', |
| 375 | 375 | 'version' => '2.1.3', |
| 376 | 376 | 'callback' => 'give_v213_delete_donation_meta_callback', |
| 377 | - 'depends' => array( 'v201_move_metadata_into_new_table' ), |
|
| 377 | + 'depends' => array('v201_move_metadata_into_new_table'), |
|
| 378 | 378 | ) |
| 379 | 379 | ); |
| 380 | 380 | |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | ); |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | -add_action( 'give_register_updates', 'give_show_upgrade_notices' ); |
|
| 400 | +add_action('give_register_updates', 'give_show_upgrade_notices'); |
|
| 401 | 401 | |
| 402 | 402 | /** |
| 403 | 403 | * Triggers all upgrade functions |
@@ -409,31 +409,31 @@ discard block |
||
| 409 | 409 | */ |
| 410 | 410 | function give_trigger_upgrades() { |
| 411 | 411 | |
| 412 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 412 | + if ( ! current_user_can('manage_give_settings')) { |
|
| 413 | 413 | wp_die( |
| 414 | - esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
| 414 | + esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
| 415 | 415 | 'response' => 403, |
| 416 | 416 | ) |
| 417 | 417 | ); |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | - $give_version = get_option( 'give_version' ); |
|
| 420 | + $give_version = get_option('give_version'); |
|
| 421 | 421 | |
| 422 | - if ( ! $give_version ) { |
|
| 422 | + if ( ! $give_version) { |
|
| 423 | 423 | // 1.0 is the first version to use this option so we must add it. |
| 424 | 424 | $give_version = '1.0'; |
| 425 | - add_option( 'give_version', $give_version, '', false ); |
|
| 425 | + add_option('give_version', $give_version, '', false); |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - update_option( 'give_version', GIVE_VERSION, false ); |
|
| 429 | - delete_option( 'give_doing_upgrade' ); |
|
| 428 | + update_option('give_version', GIVE_VERSION, false); |
|
| 429 | + delete_option('give_doing_upgrade'); |
|
| 430 | 430 | |
| 431 | - if ( DOING_AJAX ) { |
|
| 432 | - die( 'complete' ); |
|
| 431 | + if (DOING_AJAX) { |
|
| 432 | + die('complete'); |
|
| 433 | 433 | } // End if(). |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
| 436 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
| 437 | 437 | |
| 438 | 438 | |
| 439 | 439 | /** |
@@ -451,10 +451,10 @@ discard block |
||
| 451 | 451 | |
| 452 | 452 | // UPDATE DB METAKEYS. |
| 453 | 453 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
| 454 | - $query = $wpdb->query( $sql ); |
|
| 454 | + $query = $wpdb->query($sql); |
|
| 455 | 455 | |
| 456 | 456 | $give_updates->percentage = 100; |
| 457 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
| 457 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | |
@@ -478,24 +478,24 @@ discard block |
||
| 478 | 478 | $where .= "AND ( p.post_status = 'abandoned' )"; |
| 479 | 479 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
| 480 | 480 | |
| 481 | - $sql = $select . $join . $where; |
|
| 482 | - $found_payments = $wpdb->get_col( $sql ); |
|
| 481 | + $sql = $select.$join.$where; |
|
| 482 | + $found_payments = $wpdb->get_col($sql); |
|
| 483 | 483 | |
| 484 | - foreach ( $found_payments as $payment ) { |
|
| 484 | + foreach ($found_payments as $payment) { |
|
| 485 | 485 | |
| 486 | 486 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
| 487 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
| 487 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
| 488 | 488 | |
| 489 | 489 | // 1450124863 = 12/10/2015 20:42:25. |
| 490 | - if ( $modified_time >= 1450124863 ) { |
|
| 490 | + if ($modified_time >= 1450124863) { |
|
| 491 | 491 | |
| 492 | - give_update_payment_status( $payment, 'pending' ); |
|
| 492 | + give_update_payment_status($payment, 'pending'); |
|
| 493 | 493 | |
| 494 | 494 | } |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | $give_updates->percentage = 100; |
| 498 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
| 498 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
| 499 | 499 | } |
| 500 | 500 | |
| 501 | 501 | |
@@ -508,17 +508,17 @@ discard block |
||
| 508 | 508 | */ |
| 509 | 509 | function give_v152_cleanup_users() { |
| 510 | 510 | |
| 511 | - $give_version = get_option( 'give_version' ); |
|
| 511 | + $give_version = get_option('give_version'); |
|
| 512 | 512 | |
| 513 | - if ( ! $give_version ) { |
|
| 513 | + if ( ! $give_version) { |
|
| 514 | 514 | // 1.0 is the first version to use this option so we must add it. |
| 515 | 515 | $give_version = '1.0'; |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
| 518 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
| 519 | 519 | |
| 520 | 520 | // v1.5.2 Upgrades |
| 521 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
| 521 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
| 522 | 522 | |
| 523 | 523 | // Delete all caps with "ss". |
| 524 | 524 | // Also delete all unused "campaign" roles. |
@@ -565,9 +565,9 @@ discard block |
||
| 565 | 565 | ); |
| 566 | 566 | |
| 567 | 567 | global $wp_roles; |
| 568 | - foreach ( $delete_caps as $cap ) { |
|
| 569 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
| 570 | - $wp_roles->remove_cap( $role, $cap ); |
|
| 568 | + foreach ($delete_caps as $cap) { |
|
| 569 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
| 570 | + $wp_roles->remove_cap($role, $cap); |
|
| 571 | 571 | } |
| 572 | 572 | } |
| 573 | 573 | |
@@ -577,15 +577,15 @@ discard block |
||
| 577 | 577 | $roles->add_caps(); |
| 578 | 578 | |
| 579 | 579 | // The Update Ran. |
| 580 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ), false ); |
|
| 581 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
| 582 | - delete_option( 'give_doing_upgrade' ); |
|
| 580 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION), false); |
|
| 581 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
| 582 | + delete_option('give_doing_upgrade'); |
|
| 583 | 583 | |
| 584 | 584 | }// End if(). |
| 585 | 585 | |
| 586 | 586 | } |
| 587 | 587 | |
| 588 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
| 588 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
| 589 | 589 | |
| 590 | 590 | /** |
| 591 | 591 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -628,53 +628,53 @@ discard block |
||
| 628 | 628 | |
| 629 | 629 | // Get addons license key. |
| 630 | 630 | $addons = array(); |
| 631 | - foreach ( $give_options as $key => $value ) { |
|
| 632 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
| 633 | - $addons[ $key ] = $value; |
|
| 631 | + foreach ($give_options as $key => $value) { |
|
| 632 | + if (false !== strpos($key, '_license_key')) { |
|
| 633 | + $addons[$key] = $value; |
|
| 634 | 634 | } |
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | // Bailout: We do not have any addon license data to upgrade. |
| 638 | - if ( empty( $addons ) ) { |
|
| 638 | + if (empty($addons)) { |
|
| 639 | 639 | return false; |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | - foreach ( $addons as $key => $addon_license ) { |
|
| 642 | + foreach ($addons as $key => $addon_license) { |
|
| 643 | 643 | |
| 644 | 644 | // Get addon shortname. |
| 645 | - $shortname = str_replace( '_license_key', '', $key ); |
|
| 645 | + $shortname = str_replace('_license_key', '', $key); |
|
| 646 | 646 | |
| 647 | 647 | // Addon license option name. |
| 648 | - $addon_license_option_name = $shortname . '_license_active'; |
|
| 648 | + $addon_license_option_name = $shortname.'_license_active'; |
|
| 649 | 649 | |
| 650 | 650 | // bailout if license is empty. |
| 651 | - if ( empty( $addon_license ) ) { |
|
| 652 | - delete_option( $addon_license_option_name ); |
|
| 651 | + if (empty($addon_license)) { |
|
| 652 | + delete_option($addon_license_option_name); |
|
| 653 | 653 | continue; |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | 656 | // Get addon name. |
| 657 | 657 | $addon_name = array(); |
| 658 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
| 659 | - foreach ( $addon_name_parts as $name_part ) { |
|
| 658 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
| 659 | + foreach ($addon_name_parts as $name_part) { |
|
| 660 | 660 | |
| 661 | 661 | // Fix addon name |
| 662 | - switch ( $name_part ) { |
|
| 662 | + switch ($name_part) { |
|
| 663 | 663 | case 'authorizenet': |
| 664 | 664 | $name_part = 'authorize.net'; |
| 665 | 665 | break; |
| 666 | 666 | } |
| 667 | 667 | |
| 668 | - $addon_name[] = ucfirst( $name_part ); |
|
| 668 | + $addon_name[] = ucfirst($name_part); |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | - $addon_name = implode( ' ', $addon_name ); |
|
| 671 | + $addon_name = implode(' ', $addon_name); |
|
| 672 | 672 | |
| 673 | 673 | // Data to send to the API. |
| 674 | 674 | $api_params = array( |
| 675 | 675 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
| 676 | 676 | 'license' => $addon_license, |
| 677 | - 'item_name' => urlencode( $addon_name ), |
|
| 677 | + 'item_name' => urlencode($addon_name), |
|
| 678 | 678 | 'url' => home_url(), |
| 679 | 679 | ); |
| 680 | 680 | |
@@ -689,17 +689,17 @@ discard block |
||
| 689 | 689 | ); |
| 690 | 690 | |
| 691 | 691 | // Make sure there are no errors. |
| 692 | - if ( is_wp_error( $response ) ) { |
|
| 693 | - delete_option( $addon_license_option_name ); |
|
| 692 | + if (is_wp_error($response)) { |
|
| 693 | + delete_option($addon_license_option_name); |
|
| 694 | 694 | continue; |
| 695 | 695 | } |
| 696 | 696 | |
| 697 | 697 | // Tell WordPress to look for updates. |
| 698 | - set_site_transient( 'update_plugins', null ); |
|
| 698 | + set_site_transient('update_plugins', null); |
|
| 699 | 699 | |
| 700 | 700 | // Decode license data. |
| 701 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 702 | - update_option( $addon_license_option_name, $license_data, false ); |
|
| 701 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
| 702 | + update_option($addon_license_option_name, $license_data, false); |
|
| 703 | 703 | }// End foreach(). |
| 704 | 704 | } |
| 705 | 705 | |
@@ -729,9 +729,9 @@ discard block |
||
| 729 | 729 | ); |
| 730 | 730 | |
| 731 | 731 | global $wp_roles; |
| 732 | - foreach ( $delete_caps as $cap ) { |
|
| 733 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
| 734 | - $wp_roles->remove_cap( $role, $cap ); |
|
| 732 | + foreach ($delete_caps as $cap) { |
|
| 733 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
| 734 | + $wp_roles->remove_cap($role, $cap); |
|
| 735 | 735 | } |
| 736 | 736 | } |
| 737 | 737 | |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | function give_v18_upgrades_core_setting() { |
| 766 | 766 | // Core settings which changes from checkbox to radio. |
| 767 | 767 | $core_setting_names = array_merge( |
| 768 | - array_keys( give_v18_renamed_core_settings() ), |
|
| 768 | + array_keys(give_v18_renamed_core_settings()), |
|
| 769 | 769 | array( |
| 770 | 770 | 'uninstall_on_delete', |
| 771 | 771 | 'scripts_footer', |
@@ -777,48 +777,48 @@ discard block |
||
| 777 | 777 | ); |
| 778 | 778 | |
| 779 | 779 | // Bailout: If not any setting define. |
| 780 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
| 780 | + if ($give_settings = get_option('give_settings')) { |
|
| 781 | 781 | |
| 782 | 782 | $setting_changed = false; |
| 783 | 783 | |
| 784 | 784 | // Loop: check each setting field. |
| 785 | - foreach ( $core_setting_names as $setting_name ) { |
|
| 785 | + foreach ($core_setting_names as $setting_name) { |
|
| 786 | 786 | // New setting name. |
| 787 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
| 787 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
| 788 | 788 | |
| 789 | 789 | // Continue: If setting already set. |
| 790 | 790 | if ( |
| 791 | - array_key_exists( $new_setting_name, $give_settings ) |
|
| 792 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
| 791 | + array_key_exists($new_setting_name, $give_settings) |
|
| 792 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
| 793 | 793 | ) { |
| 794 | 794 | continue; |
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | // Set checkbox value to radio value. |
| 798 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
| 798 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
| 799 | 799 | |
| 800 | 800 | // @see https://github.com/WordImpress/Give/issues/1063. |
| 801 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
| 801 | + if (false !== strpos($setting_name, 'disable_')) { |
|
| 802 | 802 | |
| 803 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
| 804 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
| 803 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
| 804 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
| 805 | 805 | |
| 806 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
| 806 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
| 807 | 807 | } |
| 808 | 808 | |
| 809 | 809 | // Tell bot to update core setting to db. |
| 810 | - if ( ! $setting_changed ) { |
|
| 810 | + if ( ! $setting_changed) { |
|
| 811 | 811 | $setting_changed = true; |
| 812 | 812 | } |
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | // Update setting only if they changed. |
| 816 | - if ( $setting_changed ) { |
|
| 817 | - update_option( 'give_settings', $give_settings, false ); |
|
| 816 | + if ($setting_changed) { |
|
| 817 | + update_option('give_settings', $give_settings, false); |
|
| 818 | 818 | } |
| 819 | 819 | }// End if(). |
| 820 | 820 | |
| 821 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
| 821 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
| 822 | 822 | } |
| 823 | 823 | |
| 824 | 824 | /** |
@@ -842,41 +842,41 @@ discard block |
||
| 842 | 842 | ) |
| 843 | 843 | ); |
| 844 | 844 | |
| 845 | - if ( $forms->have_posts() ) { |
|
| 846 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 20 ) ); |
|
| 845 | + if ($forms->have_posts()) { |
|
| 846 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 20)); |
|
| 847 | 847 | |
| 848 | - while ( $forms->have_posts() ) { |
|
| 848 | + while ($forms->have_posts()) { |
|
| 849 | 849 | $forms->the_post(); |
| 850 | 850 | |
| 851 | 851 | // Form content. |
| 852 | 852 | // Note in version 1.8 display content setting split into display content and content placement setting. |
| 853 | 853 | // You can delete _give_content_option in future. |
| 854 | - $show_content = give_get_meta( get_the_ID(), '_give_content_option', true ); |
|
| 855 | - if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
| 856 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
| 857 | - give_update_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
| 854 | + $show_content = give_get_meta(get_the_ID(), '_give_content_option', true); |
|
| 855 | + if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) { |
|
| 856 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
| 857 | + give_update_meta(get_the_ID(), '_give_display_content', $field_value); |
|
| 858 | 858 | |
| 859 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
| 860 | - give_update_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
| 859 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
| 860 | + give_update_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
| 861 | 861 | } |
| 862 | 862 | |
| 863 | 863 | // "Disable" Guest Donation. Checkbox. |
| 864 | 864 | // See: https://github.com/WordImpress/Give/issues/1470. |
| 865 | - $guest_donation = give_get_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
| 866 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
| 867 | - give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
| 865 | + $guest_donation = give_get_meta(get_the_ID(), '_give_logged_in_only', true); |
|
| 866 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
| 867 | + give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
| 868 | 868 | |
| 869 | 869 | // Offline Donations. |
| 870 | 870 | // See: https://github.com/WordImpress/Give/issues/1579. |
| 871 | - $offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
| 872 | - if ( 'no' === $offline_donation ) { |
|
| 871 | + $offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
| 872 | + if ('no' === $offline_donation) { |
|
| 873 | 873 | $offline_donation_newval = 'global'; |
| 874 | - } elseif ( 'yes' === $offline_donation ) { |
|
| 874 | + } elseif ('yes' === $offline_donation) { |
|
| 875 | 875 | $offline_donation_newval = 'enabled'; |
| 876 | 876 | } else { |
| 877 | 877 | $offline_donation_newval = 'disabled'; |
| 878 | 878 | } |
| 879 | - give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval ); |
|
| 879 | + give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval); |
|
| 880 | 880 | |
| 881 | 881 | // Convert yes/no setting field to enabled/disabled. |
| 882 | 882 | $form_radio_settings = array( |
@@ -896,15 +896,15 @@ discard block |
||
| 896 | 896 | '_give_offline_donation_enable_billing_fields_single', |
| 897 | 897 | ); |
| 898 | 898 | |
| 899 | - foreach ( $form_radio_settings as $meta_key ) { |
|
| 899 | + foreach ($form_radio_settings as $meta_key) { |
|
| 900 | 900 | // Get value. |
| 901 | - $field_value = give_get_meta( get_the_ID(), $meta_key, true ); |
|
| 901 | + $field_value = give_get_meta(get_the_ID(), $meta_key, true); |
|
| 902 | 902 | |
| 903 | 903 | // Convert meta value only if it is in yes/no/none. |
| 904 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
| 904 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
| 905 | 905 | |
| 906 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
| 907 | - give_update_meta( get_the_ID(), $meta_key, $field_value ); |
|
| 906 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
| 907 | + give_update_meta(get_the_ID(), $meta_key, $field_value); |
|
| 908 | 908 | } |
| 909 | 909 | } |
| 910 | 910 | }// End while(). |
@@ -913,7 +913,7 @@ discard block |
||
| 913 | 913 | |
| 914 | 914 | } else { |
| 915 | 915 | // No more forms found, finish up. |
| 916 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
| 916 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
| 917 | 917 | } |
| 918 | 918 | } |
| 919 | 919 | |
@@ -980,7 +980,7 @@ discard block |
||
| 980 | 980 | '%_transient_give_stats_%', |
| 981 | 981 | 'give_cache%', |
| 982 | 982 | '%_transient_give_add_ons_feed%', |
| 983 | - '%_transient__give_ajax_works' . |
|
| 983 | + '%_transient__give_ajax_works'. |
|
| 984 | 984 | '%_transient_give_total_api_keys%', |
| 985 | 985 | '%_transient_give_i18n_give_promo_hide%', |
| 986 | 986 | '%_transient_give_contributors%', |
@@ -1007,24 +1007,24 @@ discard block |
||
| 1007 | 1007 | ARRAY_A |
| 1008 | 1008 | ); |
| 1009 | 1009 | |
| 1010 | - if ( ! empty( $user_apikey_options ) ) { |
|
| 1011 | - foreach ( $user_apikey_options as $user ) { |
|
| 1012 | - $cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] ); |
|
| 1013 | - $cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] ); |
|
| 1014 | - $cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] ); |
|
| 1010 | + if ( ! empty($user_apikey_options)) { |
|
| 1011 | + foreach ($user_apikey_options as $user) { |
|
| 1012 | + $cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']); |
|
| 1013 | + $cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']); |
|
| 1014 | + $cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']); |
|
| 1015 | 1015 | } |
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | - if ( ! empty( $cached_options ) ) { |
|
| 1019 | - foreach ( $cached_options as $option ) { |
|
| 1020 | - switch ( true ) { |
|
| 1021 | - case ( false !== strpos( $option, 'transient' ) ): |
|
| 1022 | - $option = str_replace( '_transient_', '', $option ); |
|
| 1023 | - delete_transient( $option ); |
|
| 1018 | + if ( ! empty($cached_options)) { |
|
| 1019 | + foreach ($cached_options as $option) { |
|
| 1020 | + switch (true) { |
|
| 1021 | + case (false !== strpos($option, 'transient')): |
|
| 1022 | + $option = str_replace('_transient_', '', $option); |
|
| 1023 | + delete_transient($option); |
|
| 1024 | 1024 | break; |
| 1025 | 1025 | |
| 1026 | 1026 | default: |
| 1027 | - delete_option( $option ); |
|
| 1027 | + delete_option($option); |
|
| 1028 | 1028 | } |
| 1029 | 1029 | } |
| 1030 | 1030 | } |
@@ -1042,7 +1042,7 @@ discard block |
||
| 1042 | 1042 | global $wp_roles; |
| 1043 | 1043 | |
| 1044 | 1044 | // Get the role object. |
| 1045 | - $give_worker = get_role( 'give_worker' ); |
|
| 1045 | + $give_worker = get_role('give_worker'); |
|
| 1046 | 1046 | |
| 1047 | 1047 | // A list of capabilities to add for give workers. |
| 1048 | 1048 | $caps_to_add = array( |
@@ -1050,9 +1050,9 @@ discard block |
||
| 1050 | 1050 | 'edit_pages', |
| 1051 | 1051 | ); |
| 1052 | 1052 | |
| 1053 | - foreach ( $caps_to_add as $cap ) { |
|
| 1053 | + foreach ($caps_to_add as $cap) { |
|
| 1054 | 1054 | // Add the capability. |
| 1055 | - $give_worker->add_cap( $cap ); |
|
| 1055 | + $give_worker->add_cap($cap); |
|
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | 1058 | } |
@@ -1079,10 +1079,10 @@ discard block |
||
| 1079 | 1079 | ) |
| 1080 | 1080 | ); |
| 1081 | 1081 | |
| 1082 | - if ( $donation_forms->have_posts() ) { |
|
| 1083 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
| 1082 | + if ($donation_forms->have_posts()) { |
|
| 1083 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
| 1084 | 1084 | |
| 1085 | - while ( $donation_forms->have_posts() ) { |
|
| 1085 | + while ($donation_forms->have_posts()) { |
|
| 1086 | 1086 | $donation_forms->the_post(); |
| 1087 | 1087 | $form_id = get_the_ID(); |
| 1088 | 1088 | |
@@ -1090,41 +1090,41 @@ discard block |
||
| 1090 | 1090 | update_post_meta( |
| 1091 | 1091 | $form_id, |
| 1092 | 1092 | '_give_set_price', |
| 1093 | - give_sanitize_amount( get_post_meta( $form_id, '_give_set_price', true ) ) |
|
| 1093 | + give_sanitize_amount(get_post_meta($form_id, '_give_set_price', true)) |
|
| 1094 | 1094 | ); |
| 1095 | 1095 | |
| 1096 | 1096 | // Remove formatting from _give_custom_amount_minimum. |
| 1097 | 1097 | update_post_meta( |
| 1098 | 1098 | $form_id, |
| 1099 | 1099 | '_give_custom_amount_minimum', |
| 1100 | - give_sanitize_amount( get_post_meta( $form_id, '_give_custom_amount_minimum', true ) ) |
|
| 1100 | + give_sanitize_amount(get_post_meta($form_id, '_give_custom_amount_minimum', true)) |
|
| 1101 | 1101 | ); |
| 1102 | 1102 | |
| 1103 | 1103 | // Bailout. |
| 1104 | - if ( 'set' === get_post_meta( $form_id, '_give_price_option', true ) ) { |
|
| 1104 | + if ('set' === get_post_meta($form_id, '_give_price_option', true)) { |
|
| 1105 | 1105 | continue; |
| 1106 | 1106 | } |
| 1107 | 1107 | |
| 1108 | - $donation_levels = get_post_meta( $form_id, '_give_donation_levels', true ); |
|
| 1108 | + $donation_levels = get_post_meta($form_id, '_give_donation_levels', true); |
|
| 1109 | 1109 | |
| 1110 | - if ( ! empty( $donation_levels ) ) { |
|
| 1110 | + if ( ! empty($donation_levels)) { |
|
| 1111 | 1111 | |
| 1112 | - foreach ( $donation_levels as $index => $donation_level ) { |
|
| 1113 | - if ( isset( $donation_level['_give_amount'] ) ) { |
|
| 1114 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount( $donation_level['_give_amount'] ); |
|
| 1112 | + foreach ($donation_levels as $index => $donation_level) { |
|
| 1113 | + if (isset($donation_level['_give_amount'])) { |
|
| 1114 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount($donation_level['_give_amount']); |
|
| 1115 | 1115 | } |
| 1116 | 1116 | } |
| 1117 | 1117 | |
| 1118 | - update_post_meta( $form_id, '_give_donation_levels', $donation_levels ); |
|
| 1118 | + update_post_meta($form_id, '_give_donation_levels', $donation_levels); |
|
| 1119 | 1119 | |
| 1120 | - $donation_levels_amounts = wp_list_pluck( $donation_levels, '_give_amount' ); |
|
| 1120 | + $donation_levels_amounts = wp_list_pluck($donation_levels, '_give_amount'); |
|
| 1121 | 1121 | |
| 1122 | - $min_amount = min( $donation_levels_amounts ); |
|
| 1123 | - $max_amount = max( $donation_levels_amounts ); |
|
| 1122 | + $min_amount = min($donation_levels_amounts); |
|
| 1123 | + $max_amount = max($donation_levels_amounts); |
|
| 1124 | 1124 | |
| 1125 | 1125 | // Set Minimum and Maximum amount for Multi Level Donation Forms |
| 1126 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount( $min_amount ) : 0 ); |
|
| 1127 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount( $max_amount ) : 0 ); |
|
| 1126 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount($min_amount) : 0); |
|
| 1127 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount($max_amount) : 0); |
|
| 1128 | 1128 | } |
| 1129 | 1129 | } |
| 1130 | 1130 | |
@@ -1132,7 +1132,7 @@ discard block |
||
| 1132 | 1132 | wp_reset_postdata(); |
| 1133 | 1133 | } else { |
| 1134 | 1134 | // The Update Ran. |
| 1135 | - give_set_upgrade_complete( 'v189_upgrades_levels_post_meta' ); |
|
| 1135 | + give_set_upgrade_complete('v189_upgrades_levels_post_meta'); |
|
| 1136 | 1136 | } |
| 1137 | 1137 | |
| 1138 | 1138 | } |
@@ -1182,7 +1182,7 @@ discard block |
||
| 1182 | 1182 | */ |
| 1183 | 1183 | function give_v20_upgrades() { |
| 1184 | 1184 | // Update cache setting. |
| 1185 | - give_update_option( 'cache', 'enabled' ); |
|
| 1185 | + give_update_option('cache', 'enabled'); |
|
| 1186 | 1186 | |
| 1187 | 1187 | // Upgrade email settings. |
| 1188 | 1188 | give_v20_upgrades_email_setting(); |
@@ -1201,7 +1201,7 @@ discard block |
||
| 1201 | 1201 | $all_setting = give_get_settings(); |
| 1202 | 1202 | |
| 1203 | 1203 | // Bailout on fresh install. |
| 1204 | - if ( empty( $all_setting ) ) { |
|
| 1204 | + if (empty($all_setting)) { |
|
| 1205 | 1205 | return; |
| 1206 | 1206 | } |
| 1207 | 1207 | |
@@ -1220,19 +1220,19 @@ discard block |
||
| 1220 | 1220 | 'admin_notices' => 'new-donation_notification', |
| 1221 | 1221 | ); |
| 1222 | 1222 | |
| 1223 | - foreach ( $settings as $old_setting => $new_setting ) { |
|
| 1223 | + foreach ($settings as $old_setting => $new_setting) { |
|
| 1224 | 1224 | // Do not update already modified |
| 1225 | - if ( ! is_array( $new_setting ) ) { |
|
| 1226 | - if ( array_key_exists( $new_setting, $all_setting ) || ! array_key_exists( $old_setting, $all_setting ) ) { |
|
| 1225 | + if ( ! is_array($new_setting)) { |
|
| 1226 | + if (array_key_exists($new_setting, $all_setting) || ! array_key_exists($old_setting, $all_setting)) { |
|
| 1227 | 1227 | continue; |
| 1228 | 1228 | } |
| 1229 | 1229 | } |
| 1230 | 1230 | |
| 1231 | - switch ( $old_setting ) { |
|
| 1231 | + switch ($old_setting) { |
|
| 1232 | 1232 | case 'admin_notices': |
| 1233 | - $notification_status = give_get_option( $old_setting, 'enabled' ); |
|
| 1233 | + $notification_status = give_get_option($old_setting, 'enabled'); |
|
| 1234 | 1234 | |
| 1235 | - give_update_option( $new_setting, $notification_status ); |
|
| 1235 | + give_update_option($new_setting, $notification_status); |
|
| 1236 | 1236 | |
| 1237 | 1237 | // @todo: Delete this option later ( version > 2.0 ), We need this for per form email addon. |
| 1238 | 1238 | // give_delete_option( $old_setting ); |
@@ -1242,19 +1242,19 @@ discard block |
||
| 1242 | 1242 | case 'admin_notice_emails': |
| 1243 | 1243 | $recipients = give_get_admin_notice_emails(); |
| 1244 | 1244 | |
| 1245 | - foreach ( $new_setting as $setting ) { |
|
| 1245 | + foreach ($new_setting as $setting) { |
|
| 1246 | 1246 | // bailout if setting already exist. |
| 1247 | - if ( array_key_exists( $setting, $all_setting ) ) { |
|
| 1247 | + if (array_key_exists($setting, $all_setting)) { |
|
| 1248 | 1248 | continue; |
| 1249 | 1249 | } |
| 1250 | 1250 | |
| 1251 | - give_update_option( $setting, $recipients ); |
|
| 1251 | + give_update_option($setting, $recipients); |
|
| 1252 | 1252 | } |
| 1253 | 1253 | break; |
| 1254 | 1254 | |
| 1255 | 1255 | default: |
| 1256 | - give_update_option( $new_setting, give_get_option( $old_setting ) ); |
|
| 1257 | - give_delete_option( $old_setting ); |
|
| 1256 | + give_update_option($new_setting, give_get_option($old_setting)); |
|
| 1257 | + give_delete_option($old_setting); |
|
| 1258 | 1258 | } |
| 1259 | 1259 | } |
| 1260 | 1260 | } |
@@ -1271,22 +1271,22 @@ discard block |
||
| 1271 | 1271 | $give_settings = give_get_settings(); |
| 1272 | 1272 | $give_setting_updated = false; |
| 1273 | 1273 | |
| 1274 | - if ( $give_settings['thousands_separator'] === $give_settings['decimal_separator'] ) { |
|
| 1274 | + if ($give_settings['thousands_separator'] === $give_settings['decimal_separator']) { |
|
| 1275 | 1275 | $give_settings['number_decimals'] = 0; |
| 1276 | 1276 | $give_settings['decimal_separator'] = ''; |
| 1277 | 1277 | $give_setting_updated = true; |
| 1278 | 1278 | |
| 1279 | - } elseif ( empty( $give_settings['decimal_separator'] ) ) { |
|
| 1279 | + } elseif (empty($give_settings['decimal_separator'])) { |
|
| 1280 | 1280 | $give_settings['number_decimals'] = 0; |
| 1281 | 1281 | $give_setting_updated = true; |
| 1282 | 1282 | |
| 1283 | - } elseif ( 6 < absint( $give_settings['number_decimals'] ) ) { |
|
| 1283 | + } elseif (6 < absint($give_settings['number_decimals'])) { |
|
| 1284 | 1284 | $give_settings['number_decimals'] = 5; |
| 1285 | 1285 | $give_setting_updated = true; |
| 1286 | 1286 | } |
| 1287 | 1287 | |
| 1288 | - if ( $give_setting_updated ) { |
|
| 1289 | - update_option( 'give_settings', $give_settings, false ); |
|
| 1288 | + if ($give_setting_updated) { |
|
| 1289 | + update_option('give_settings', $give_settings, false); |
|
| 1290 | 1290 | } |
| 1291 | 1291 | } |
| 1292 | 1292 | |
@@ -1310,73 +1310,73 @@ discard block |
||
| 1310 | 1310 | 'paged' => $give_updates->step, |
| 1311 | 1311 | 'status' => 'any', |
| 1312 | 1312 | 'order' => 'ASC', |
| 1313 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
| 1313 | + 'post_type' => array('give_forms', 'give_payment'), |
|
| 1314 | 1314 | 'posts_per_page' => 20, |
| 1315 | 1315 | ) |
| 1316 | 1316 | ); |
| 1317 | - if ( $donation_forms->have_posts() ) { |
|
| 1318 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
| 1317 | + if ($donation_forms->have_posts()) { |
|
| 1318 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
| 1319 | 1319 | |
| 1320 | - while ( $donation_forms->have_posts() ) { |
|
| 1320 | + while ($donation_forms->have_posts()) { |
|
| 1321 | 1321 | $donation_forms->the_post(); |
| 1322 | 1322 | global $post; |
| 1323 | 1323 | |
| 1324 | - $meta = get_post_meta( $post->ID ); |
|
| 1324 | + $meta = get_post_meta($post->ID); |
|
| 1325 | 1325 | |
| 1326 | - switch ( $post->post_type ) { |
|
| 1326 | + switch ($post->post_type) { |
|
| 1327 | 1327 | case 'give_forms': |
| 1328 | 1328 | // _give_set_price. |
| 1329 | - if ( ! empty( $meta['_give_set_price'][0] ) ) { |
|
| 1330 | - update_post_meta( $post->ID, '_give_set_price', give_sanitize_amount_for_db( $meta['_give_set_price'][0] ) ); |
|
| 1329 | + if ( ! empty($meta['_give_set_price'][0])) { |
|
| 1330 | + update_post_meta($post->ID, '_give_set_price', give_sanitize_amount_for_db($meta['_give_set_price'][0])); |
|
| 1331 | 1331 | } |
| 1332 | 1332 | |
| 1333 | 1333 | // _give_custom_amount_minimum. |
| 1334 | - if ( ! empty( $meta['_give_custom_amount_minimum'][0] ) ) { |
|
| 1335 | - update_post_meta( $post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db( $meta['_give_custom_amount_minimum'][0] ) ); |
|
| 1334 | + if ( ! empty($meta['_give_custom_amount_minimum'][0])) { |
|
| 1335 | + update_post_meta($post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db($meta['_give_custom_amount_minimum'][0])); |
|
| 1336 | 1336 | } |
| 1337 | 1337 | |
| 1338 | 1338 | // _give_levels_minimum_amount. |
| 1339 | - if ( ! empty( $meta['_give_levels_minimum_amount'][0] ) ) { |
|
| 1340 | - update_post_meta( $post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db( $meta['_give_levels_minimum_amount'][0] ) ); |
|
| 1339 | + if ( ! empty($meta['_give_levels_minimum_amount'][0])) { |
|
| 1340 | + update_post_meta($post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db($meta['_give_levels_minimum_amount'][0])); |
|
| 1341 | 1341 | } |
| 1342 | 1342 | |
| 1343 | 1343 | // _give_levels_maximum_amount. |
| 1344 | - if ( ! empty( $meta['_give_levels_maximum_amount'][0] ) ) { |
|
| 1345 | - update_post_meta( $post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db( $meta['_give_levels_maximum_amount'][0] ) ); |
|
| 1344 | + if ( ! empty($meta['_give_levels_maximum_amount'][0])) { |
|
| 1345 | + update_post_meta($post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db($meta['_give_levels_maximum_amount'][0])); |
|
| 1346 | 1346 | } |
| 1347 | 1347 | |
| 1348 | 1348 | // _give_set_goal. |
| 1349 | - if ( ! empty( $meta['_give_set_goal'][0] ) ) { |
|
| 1350 | - update_post_meta( $post->ID, '_give_set_goal', give_sanitize_amount_for_db( $meta['_give_set_goal'][0] ) ); |
|
| 1349 | + if ( ! empty($meta['_give_set_goal'][0])) { |
|
| 1350 | + update_post_meta($post->ID, '_give_set_goal', give_sanitize_amount_for_db($meta['_give_set_goal'][0])); |
|
| 1351 | 1351 | } |
| 1352 | 1352 | |
| 1353 | 1353 | // _give_form_earnings. |
| 1354 | - if ( ! empty( $meta['_give_form_earnings'][0] ) ) { |
|
| 1355 | - update_post_meta( $post->ID, '_give_form_earnings', give_sanitize_amount_for_db( $meta['_give_form_earnings'][0] ) ); |
|
| 1354 | + if ( ! empty($meta['_give_form_earnings'][0])) { |
|
| 1355 | + update_post_meta($post->ID, '_give_form_earnings', give_sanitize_amount_for_db($meta['_give_form_earnings'][0])); |
|
| 1356 | 1356 | } |
| 1357 | 1357 | |
| 1358 | 1358 | // _give_custom_amount_minimum. |
| 1359 | - if ( ! empty( $meta['_give_donation_levels'][0] ) ) { |
|
| 1360 | - $donation_levels = unserialize( $meta['_give_donation_levels'][0] ); |
|
| 1359 | + if ( ! empty($meta['_give_donation_levels'][0])) { |
|
| 1360 | + $donation_levels = unserialize($meta['_give_donation_levels'][0]); |
|
| 1361 | 1361 | |
| 1362 | - foreach ( $donation_levels as $index => $level ) { |
|
| 1363 | - if ( empty( $level['_give_amount'] ) ) { |
|
| 1362 | + foreach ($donation_levels as $index => $level) { |
|
| 1363 | + if (empty($level['_give_amount'])) { |
|
| 1364 | 1364 | continue; |
| 1365 | 1365 | } |
| 1366 | 1366 | |
| 1367 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount_for_db( $level['_give_amount'] ); |
|
| 1367 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount_for_db($level['_give_amount']); |
|
| 1368 | 1368 | } |
| 1369 | 1369 | |
| 1370 | 1370 | $meta['_give_donation_levels'] = $donation_levels; |
| 1371 | - update_post_meta( $post->ID, '_give_donation_levels', $meta['_give_donation_levels'] ); |
|
| 1371 | + update_post_meta($post->ID, '_give_donation_levels', $meta['_give_donation_levels']); |
|
| 1372 | 1372 | } |
| 1373 | 1373 | |
| 1374 | 1374 | break; |
| 1375 | 1375 | |
| 1376 | 1376 | case 'give_payment': |
| 1377 | 1377 | // _give_payment_total. |
| 1378 | - if ( ! empty( $meta['_give_payment_total'][0] ) ) { |
|
| 1379 | - update_post_meta( $post->ID, '_give_payment_total', give_sanitize_amount_for_db( $meta['_give_payment_total'][0] ) ); |
|
| 1378 | + if ( ! empty($meta['_give_payment_total'][0])) { |
|
| 1379 | + update_post_meta($post->ID, '_give_payment_total', give_sanitize_amount_for_db($meta['_give_payment_total'][0])); |
|
| 1380 | 1380 | } |
| 1381 | 1381 | |
| 1382 | 1382 | break; |
@@ -1387,7 +1387,7 @@ discard block |
||
| 1387 | 1387 | wp_reset_postdata(); |
| 1388 | 1388 | } else { |
| 1389 | 1389 | // The Update Ran. |
| 1390 | - give_set_upgrade_complete( 'v1812_update_amount_values' ); |
|
| 1390 | + give_set_upgrade_complete('v1812_update_amount_values'); |
|
| 1391 | 1391 | } |
| 1392 | 1392 | } |
| 1393 | 1393 | |
@@ -1409,20 +1409,20 @@ discard block |
||
| 1409 | 1409 | $donors = Give()->donors->get_donors( |
| 1410 | 1410 | array( |
| 1411 | 1411 | 'number' => 20, |
| 1412 | - 'offset' => $give_updates->get_offset( 20 ), |
|
| 1412 | + 'offset' => $give_updates->get_offset(20), |
|
| 1413 | 1413 | ) |
| 1414 | 1414 | ); |
| 1415 | 1415 | |
| 1416 | - if ( ! empty( $donors ) ) { |
|
| 1417 | - $give_updates->set_percentage( Give()->donors->count(), $give_updates->get_offset( 20 ) ); |
|
| 1416 | + if ( ! empty($donors)) { |
|
| 1417 | + $give_updates->set_percentage(Give()->donors->count(), $give_updates->get_offset(20)); |
|
| 1418 | 1418 | |
| 1419 | 1419 | /* @var Object $donor */ |
| 1420 | - foreach ( $donors as $donor ) { |
|
| 1421 | - Give()->donors->update( $donor->id, array( 'purchase_value' => give_sanitize_amount_for_db( $donor->purchase_value ) ) ); |
|
| 1420 | + foreach ($donors as $donor) { |
|
| 1421 | + Give()->donors->update($donor->id, array('purchase_value' => give_sanitize_amount_for_db($donor->purchase_value))); |
|
| 1422 | 1422 | } |
| 1423 | 1423 | } else { |
| 1424 | 1424 | // The Update Ran. |
| 1425 | - give_set_upgrade_complete( 'v1812_update_donor_purchase_values' ); |
|
| 1425 | + give_set_upgrade_complete('v1812_update_donor_purchase_values'); |
|
| 1426 | 1426 | } |
| 1427 | 1427 | } |
| 1428 | 1428 | |
@@ -1439,23 +1439,23 @@ discard block |
||
| 1439 | 1439 | $donors = Give()->donors->get_donors( |
| 1440 | 1440 | array( |
| 1441 | 1441 | 'number' => 20, |
| 1442 | - 'offset' => $give_updates->get_offset( 20 ), |
|
| 1442 | + 'offset' => $give_updates->get_offset(20), |
|
| 1443 | 1443 | ) |
| 1444 | 1444 | ); |
| 1445 | 1445 | |
| 1446 | - if ( ! empty( $donors ) ) { |
|
| 1447 | - $give_updates->set_percentage( Give()->donors->count(), $give_updates->get_offset( 20 ) ); |
|
| 1446 | + if ( ! empty($donors)) { |
|
| 1447 | + $give_updates->set_percentage(Give()->donors->count(), $give_updates->get_offset(20)); |
|
| 1448 | 1448 | |
| 1449 | 1449 | /* @var Object $donor */ |
| 1450 | - foreach ( $donors as $donor ) { |
|
| 1450 | + foreach ($donors as $donor) { |
|
| 1451 | 1451 | $user_id = $donor->user_id; |
| 1452 | 1452 | |
| 1453 | 1453 | // Proceed, if donor is attached with user. |
| 1454 | - if ( $user_id ) { |
|
| 1455 | - $user = get_userdata( $user_id ); |
|
| 1454 | + if ($user_id) { |
|
| 1455 | + $user = get_userdata($user_id); |
|
| 1456 | 1456 | |
| 1457 | 1457 | // Update user role, if user has subscriber role. |
| 1458 | - if ( is_array( $user->roles ) && in_array( 'subscriber', $user->roles ) ) { |
|
| 1458 | + if (is_array($user->roles) && in_array('subscriber', $user->roles)) { |
|
| 1459 | 1459 | wp_update_user( |
| 1460 | 1460 | array( |
| 1461 | 1461 | 'ID' => $user_id, |
@@ -1467,7 +1467,7 @@ discard block |
||
| 1467 | 1467 | } |
| 1468 | 1468 | } else { |
| 1469 | 1469 | // The Update Ran. |
| 1470 | - give_set_upgrade_complete( 'v1813_update_donor_user_roles' ); |
|
| 1470 | + give_set_upgrade_complete('v1813_update_donor_user_roles'); |
|
| 1471 | 1471 | } |
| 1472 | 1472 | } |
| 1473 | 1473 | |
@@ -1479,7 +1479,7 @@ discard block |
||
| 1479 | 1479 | */ |
| 1480 | 1480 | function give_v1813_upgrades() { |
| 1481 | 1481 | // Update admin setting. |
| 1482 | - give_update_option( 'donor_default_user_role', 'give_donor' ); |
|
| 1482 | + give_update_option('donor_default_user_role', 'give_donor'); |
|
| 1483 | 1483 | |
| 1484 | 1484 | // Update Give roles. |
| 1485 | 1485 | $roles = new Give_Roles(); |
@@ -1502,27 +1502,27 @@ discard block |
||
| 1502 | 1502 | 'paged' => $give_updates->step, |
| 1503 | 1503 | 'status' => 'any', |
| 1504 | 1504 | 'order' => 'ASC', |
| 1505 | - 'post_type' => array( 'give_payment' ), |
|
| 1505 | + 'post_type' => array('give_payment'), |
|
| 1506 | 1506 | 'posts_per_page' => 100, |
| 1507 | 1507 | ) |
| 1508 | 1508 | ); |
| 1509 | 1509 | |
| 1510 | - if ( $payments->have_posts() ) { |
|
| 1511 | - $give_updates->set_percentage( $payments->found_posts, ( $give_updates->step * 100 ) ); |
|
| 1510 | + if ($payments->have_posts()) { |
|
| 1511 | + $give_updates->set_percentage($payments->found_posts, ($give_updates->step * 100)); |
|
| 1512 | 1512 | |
| 1513 | - while ( $payments->have_posts() ) { |
|
| 1513 | + while ($payments->have_posts()) { |
|
| 1514 | 1514 | $payments->the_post(); |
| 1515 | 1515 | |
| 1516 | - $payment_meta = give_get_payment_meta( get_the_ID() ); |
|
| 1516 | + $payment_meta = give_get_payment_meta(get_the_ID()); |
|
| 1517 | 1517 | |
| 1518 | - if ( 'RIAL' === $payment_meta['currency'] ) { |
|
| 1518 | + if ('RIAL' === $payment_meta['currency']) { |
|
| 1519 | 1519 | $payment_meta['currency'] = 'IRR'; |
| 1520 | - give_update_meta( get_the_ID(), '_give_payment_meta', $payment_meta ); |
|
| 1520 | + give_update_meta(get_the_ID(), '_give_payment_meta', $payment_meta); |
|
| 1521 | 1521 | } |
| 1522 | 1522 | } |
| 1523 | 1523 | } else { |
| 1524 | 1524 | // The Update Ran. |
| 1525 | - give_set_upgrade_complete( 'v1817_update_donation_iranian_currency_code' ); |
|
| 1525 | + give_set_upgrade_complete('v1817_update_donation_iranian_currency_code'); |
|
| 1526 | 1526 | } |
| 1527 | 1527 | } |
| 1528 | 1528 | |
@@ -1535,9 +1535,9 @@ discard block |
||
| 1535 | 1535 | function give_v1817_upgrades() { |
| 1536 | 1536 | $give_settings = give_get_settings(); |
| 1537 | 1537 | |
| 1538 | - if ( 'RIAL' === $give_settings['currency'] ) { |
|
| 1538 | + if ('RIAL' === $give_settings['currency']) { |
|
| 1539 | 1539 | $give_settings['currency'] = 'IRR'; |
| 1540 | - update_option( 'give_settings', $give_settings, false ); |
|
| 1540 | + update_option('give_settings', $give_settings, false); |
|
| 1541 | 1541 | } |
| 1542 | 1542 | } |
| 1543 | 1543 | |
@@ -1550,7 +1550,7 @@ discard block |
||
| 1550 | 1550 | |
| 1551 | 1551 | global $wp_roles; |
| 1552 | 1552 | |
| 1553 | - if ( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
| 1553 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
| 1554 | 1554 | return; |
| 1555 | 1555 | } |
| 1556 | 1556 | |
@@ -1574,15 +1574,15 @@ discard block |
||
| 1574 | 1574 | ), |
| 1575 | 1575 | ); |
| 1576 | 1576 | |
| 1577 | - foreach ( $add_caps as $role => $caps ) { |
|
| 1578 | - foreach ( $caps as $cap ) { |
|
| 1579 | - $wp_roles->add_cap( $role, $cap ); |
|
| 1577 | + foreach ($add_caps as $role => $caps) { |
|
| 1578 | + foreach ($caps as $cap) { |
|
| 1579 | + $wp_roles->add_cap($role, $cap); |
|
| 1580 | 1580 | } |
| 1581 | 1581 | } |
| 1582 | 1582 | |
| 1583 | - foreach ( $remove_caps as $role => $caps ) { |
|
| 1584 | - foreach ( $caps as $cap ) { |
|
| 1585 | - $wp_roles->remove_cap( $role, $cap ); |
|
| 1583 | + foreach ($remove_caps as $role => $caps) { |
|
| 1584 | + foreach ($caps as $cap) { |
|
| 1585 | + $wp_roles->remove_cap($role, $cap); |
|
| 1586 | 1586 | } |
| 1587 | 1587 | } |
| 1588 | 1588 | |
@@ -1606,7 +1606,7 @@ discard block |
||
| 1606 | 1606 | $roles->add_roles(); |
| 1607 | 1607 | $roles->add_caps(); |
| 1608 | 1608 | |
| 1609 | - give_set_upgrade_complete( 'v1817_cleanup_user_roles' ); |
|
| 1609 | + give_set_upgrade_complete('v1817_cleanup_user_roles'); |
|
| 1610 | 1610 | } |
| 1611 | 1611 | |
| 1612 | 1612 | /** |
@@ -1617,7 +1617,7 @@ discard block |
||
| 1617 | 1617 | function give_v1818_upgrades() { |
| 1618 | 1618 | |
| 1619 | 1619 | // Remove email_access_installed from give_settings. |
| 1620 | - give_delete_option( 'email_access_installed' ); |
|
| 1620 | + give_delete_option('email_access_installed'); |
|
| 1621 | 1621 | } |
| 1622 | 1622 | |
| 1623 | 1623 | /** |
@@ -1635,19 +1635,19 @@ discard block |
||
| 1635 | 1635 | 'paged' => $give_updates->step, |
| 1636 | 1636 | 'status' => 'any', |
| 1637 | 1637 | 'order' => 'ASC', |
| 1638 | - 'post_type' => array( 'give_payment' ), |
|
| 1638 | + 'post_type' => array('give_payment'), |
|
| 1639 | 1639 | 'posts_per_page' => 100, |
| 1640 | 1640 | ) |
| 1641 | 1641 | ); |
| 1642 | 1642 | |
| 1643 | - if ( $donations->have_posts() ) { |
|
| 1644 | - $give_updates->set_percentage( $donations->found_posts, $give_updates->step * 100 ); |
|
| 1643 | + if ($donations->have_posts()) { |
|
| 1644 | + $give_updates->set_percentage($donations->found_posts, $give_updates->step * 100); |
|
| 1645 | 1645 | |
| 1646 | - while ( $donations->have_posts() ) { |
|
| 1646 | + while ($donations->have_posts()) { |
|
| 1647 | 1647 | $donations->the_post(); |
| 1648 | 1648 | |
| 1649 | - $form = new Give_Donate_Form( give_get_meta( get_the_ID(), '_give_payment_form_id', true ) ); |
|
| 1650 | - $donation_meta = give_get_payment_meta( get_the_ID() ); |
|
| 1649 | + $form = new Give_Donate_Form(give_get_meta(get_the_ID(), '_give_payment_form_id', true)); |
|
| 1650 | + $donation_meta = give_get_payment_meta(get_the_ID()); |
|
| 1651 | 1651 | |
| 1652 | 1652 | // Update Donation meta with price_id set as custom, only if it is: |
| 1653 | 1653 | // 1. Donation Type = Set Donation. |
@@ -1656,19 +1656,19 @@ discard block |
||
| 1656 | 1656 | if ( |
| 1657 | 1657 | $form->ID && |
| 1658 | 1658 | $form->is_set_type_donation_form() && |
| 1659 | - ( 'custom' !== $donation_meta['price_id'] ) && |
|
| 1660 | - $form->is_custom_price( give_get_meta( get_the_ID(), '_give_payment_total', true ) ) |
|
| 1659 | + ('custom' !== $donation_meta['price_id']) && |
|
| 1660 | + $form->is_custom_price(give_get_meta(get_the_ID(), '_give_payment_total', true)) |
|
| 1661 | 1661 | ) { |
| 1662 | 1662 | $donation_meta['price_id'] = 'custom'; |
| 1663 | - give_update_meta( get_the_ID(), '_give_payment_meta', $donation_meta ); |
|
| 1664 | - give_update_meta( get_the_ID(), '_give_payment_price_id', 'custom' ); |
|
| 1663 | + give_update_meta(get_the_ID(), '_give_payment_meta', $donation_meta); |
|
| 1664 | + give_update_meta(get_the_ID(), '_give_payment_price_id', 'custom'); |
|
| 1665 | 1665 | } |
| 1666 | 1666 | } |
| 1667 | 1667 | |
| 1668 | 1668 | wp_reset_postdata(); |
| 1669 | 1669 | } else { |
| 1670 | 1670 | // Update Ran Successfully. |
| 1671 | - give_set_upgrade_complete( 'v1818_assign_custom_amount_set_donation' ); |
|
| 1671 | + give_set_upgrade_complete('v1818_assign_custom_amount_set_donation'); |
|
| 1672 | 1672 | } |
| 1673 | 1673 | } |
| 1674 | 1674 | |
@@ -1686,7 +1686,7 @@ discard block |
||
| 1686 | 1686 | |
| 1687 | 1687 | global $wp_roles; |
| 1688 | 1688 | |
| 1689 | - if ( ! ( $wp_roles instanceof WP_Roles ) ) { |
|
| 1689 | + if ( ! ($wp_roles instanceof WP_Roles)) { |
|
| 1690 | 1690 | return; |
| 1691 | 1691 | } |
| 1692 | 1692 | |
@@ -1704,9 +1704,9 @@ discard block |
||
| 1704 | 1704 | ), |
| 1705 | 1705 | ); |
| 1706 | 1706 | |
| 1707 | - foreach ( $remove_caps as $role => $caps ) { |
|
| 1708 | - foreach ( $caps as $cap ) { |
|
| 1709 | - $wp_roles->remove_cap( $role, $cap ); |
|
| 1707 | + foreach ($remove_caps as $role => $caps) { |
|
| 1708 | + foreach ($caps as $cap) { |
|
| 1709 | + $wp_roles->remove_cap($role, $cap); |
|
| 1710 | 1710 | } |
| 1711 | 1711 | } |
| 1712 | 1712 | |
@@ -1717,7 +1717,7 @@ discard block |
||
| 1717 | 1717 | $roles->add_roles(); |
| 1718 | 1718 | $roles->add_caps(); |
| 1719 | 1719 | |
| 1720 | - give_set_upgrade_complete( 'v1818_give_worker_role_cleanup' ); |
|
| 1720 | + give_set_upgrade_complete('v1818_give_worker_role_cleanup'); |
|
| 1721 | 1721 | } |
| 1722 | 1722 | |
| 1723 | 1723 | /** |
@@ -1741,15 +1741,15 @@ discard block |
||
| 1741 | 1741 | ) |
| 1742 | 1742 | ); |
| 1743 | 1743 | |
| 1744 | - if ( $forms->have_posts() ) { |
|
| 1745 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) ); |
|
| 1744 | + if ($forms->have_posts()) { |
|
| 1745 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100)); |
|
| 1746 | 1746 | |
| 1747 | - while ( $forms->have_posts() ) { |
|
| 1747 | + while ($forms->have_posts()) { |
|
| 1748 | 1748 | $forms->the_post(); |
| 1749 | 1749 | global $post; |
| 1750 | 1750 | |
| 1751 | 1751 | // Update offline instruction email notification status. |
| 1752 | - $offline_instruction_notification_status = get_post_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
| 1752 | + $offline_instruction_notification_status = get_post_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
| 1753 | 1753 | $offline_instruction_notification_status = give_is_setting_enabled( |
| 1754 | 1754 | $offline_instruction_notification_status, array( |
| 1755 | 1755 | 'enabled', |
@@ -1758,7 +1758,7 @@ discard block |
||
| 1758 | 1758 | ) |
| 1759 | 1759 | ? $offline_instruction_notification_status |
| 1760 | 1760 | : 'global'; |
| 1761 | - update_post_meta( get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status ); |
|
| 1761 | + update_post_meta(get_the_ID(), '_give_offline-donation-instruction_notification', $offline_instruction_notification_status); |
|
| 1762 | 1762 | |
| 1763 | 1763 | // Update offline instruction email message. |
| 1764 | 1764 | update_post_meta( |
@@ -1789,7 +1789,7 @@ discard block |
||
| 1789 | 1789 | wp_reset_postdata(); |
| 1790 | 1790 | } else { |
| 1791 | 1791 | // No more forms found, finish up. |
| 1792 | - give_set_upgrade_complete( 'v20_upgrades_form_metadata' ); |
|
| 1792 | + give_set_upgrade_complete('v20_upgrades_form_metadata'); |
|
| 1793 | 1793 | } |
| 1794 | 1794 | } |
| 1795 | 1795 | |
@@ -1816,19 +1816,19 @@ discard block |
||
| 1816 | 1816 | ) |
| 1817 | 1817 | ); |
| 1818 | 1818 | |
| 1819 | - if ( $forms->have_posts() ) { |
|
| 1820 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 100 ) ); |
|
| 1819 | + if ($forms->have_posts()) { |
|
| 1820 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 100)); |
|
| 1821 | 1821 | |
| 1822 | - while ( $forms->have_posts() ) { |
|
| 1822 | + while ($forms->have_posts()) { |
|
| 1823 | 1823 | $forms->the_post(); |
| 1824 | 1824 | global $post; |
| 1825 | 1825 | |
| 1826 | 1826 | // Split _give_payment_meta meta. |
| 1827 | 1827 | // @todo Remove _give_payment_meta after releases 2.0 |
| 1828 | - $payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true ); |
|
| 1828 | + $payment_meta = give_get_meta($post->ID, '_give_payment_meta', true); |
|
| 1829 | 1829 | |
| 1830 | - if ( ! empty( $payment_meta ) ) { |
|
| 1831 | - _give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta ); |
|
| 1830 | + if ( ! empty($payment_meta)) { |
|
| 1831 | + _give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta); |
|
| 1832 | 1832 | } |
| 1833 | 1833 | |
| 1834 | 1834 | $deprecated_meta_keys = array( |
@@ -1837,9 +1837,9 @@ discard block |
||
| 1837 | 1837 | '_give_payment_user_ip' => '_give_payment_donor_ip', |
| 1838 | 1838 | ); |
| 1839 | 1839 | |
| 1840 | - foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) { |
|
| 1840 | + foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) { |
|
| 1841 | 1841 | // Do not add new meta key if already exist. |
| 1842 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key ) ) ) { |
|
| 1842 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key))) { |
|
| 1843 | 1843 | continue; |
| 1844 | 1844 | } |
| 1845 | 1845 | |
@@ -1848,25 +1848,25 @@ discard block |
||
| 1848 | 1848 | array( |
| 1849 | 1849 | 'post_id' => $post->ID, |
| 1850 | 1850 | 'meta_key' => $new_meta_key, |
| 1851 | - 'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ), |
|
| 1851 | + 'meta_value' => give_get_meta($post->ID, $old_meta_key, true), |
|
| 1852 | 1852 | ) |
| 1853 | 1853 | ); |
| 1854 | 1854 | } |
| 1855 | 1855 | |
| 1856 | 1856 | // Bailout |
| 1857 | - if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) { |
|
| 1857 | + if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) { |
|
| 1858 | 1858 | /* @var Give_Donor $donor */ |
| 1859 | - $donor = new Give_Donor( $donor_id ); |
|
| 1859 | + $donor = new Give_Donor($donor_id); |
|
| 1860 | 1860 | |
| 1861 | - $address['line1'] = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' ); |
|
| 1862 | - $address['line2'] = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' ); |
|
| 1863 | - $address['city'] = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' ); |
|
| 1864 | - $address['state'] = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' ); |
|
| 1865 | - $address['zip'] = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' ); |
|
| 1866 | - $address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' ); |
|
| 1861 | + $address['line1'] = give_get_meta($post->ID, '_give_donor_billing_address1', true, ''); |
|
| 1862 | + $address['line2'] = give_get_meta($post->ID, '_give_donor_billing_address2', true, ''); |
|
| 1863 | + $address['city'] = give_get_meta($post->ID, '_give_donor_billing_city', true, ''); |
|
| 1864 | + $address['state'] = give_get_meta($post->ID, '_give_donor_billing_state', true, ''); |
|
| 1865 | + $address['zip'] = give_get_meta($post->ID, '_give_donor_billing_zip', true, ''); |
|
| 1866 | + $address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, ''); |
|
| 1867 | 1867 | |
| 1868 | 1868 | // Save address. |
| 1869 | - $donor->add_address( 'billing[]', $address ); |
|
| 1869 | + $donor->add_address('billing[]', $address); |
|
| 1870 | 1870 | } |
| 1871 | 1871 | }// End while(). |
| 1872 | 1872 | |
@@ -1875,7 +1875,7 @@ discard block |
||
| 1875 | 1875 | // @todo Delete user id meta after releases 2.0 |
| 1876 | 1876 | // $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) ); |
| 1877 | 1877 | // No more forms found, finish up. |
| 1878 | - give_set_upgrade_complete( 'v20_upgrades_payment_metadata' ); |
|
| 1878 | + give_set_upgrade_complete('v20_upgrades_payment_metadata'); |
|
| 1879 | 1879 | } |
| 1880 | 1880 | } |
| 1881 | 1881 | |
@@ -1901,20 +1901,20 @@ discard block |
||
| 1901 | 1901 | ) |
| 1902 | 1902 | ); |
| 1903 | 1903 | |
| 1904 | - if ( $forms->have_posts() ) { |
|
| 1905 | - $give_updates->set_percentage( $forms->found_posts, $give_updates->step * 100 ); |
|
| 1904 | + if ($forms->have_posts()) { |
|
| 1905 | + $give_updates->set_percentage($forms->found_posts, $give_updates->step * 100); |
|
| 1906 | 1906 | |
| 1907 | - while ( $forms->have_posts() ) { |
|
| 1907 | + while ($forms->have_posts()) { |
|
| 1908 | 1908 | $forms->the_post(); |
| 1909 | 1909 | global $post; |
| 1910 | 1910 | |
| 1911 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) { |
|
| 1911 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) { |
|
| 1912 | 1912 | continue; |
| 1913 | 1913 | } |
| 1914 | 1914 | |
| 1915 | - $term = get_the_terms( $post->ID, 'give_log_type' ); |
|
| 1916 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
| 1917 | - $term_name = ! empty( $term ) ? $term->slug : ''; |
|
| 1915 | + $term = get_the_terms($post->ID, 'give_log_type'); |
|
| 1916 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
| 1917 | + $term_name = ! empty($term) ? $term->slug : ''; |
|
| 1918 | 1918 | |
| 1919 | 1919 | $log_data = array( |
| 1920 | 1920 | 'ID' => $post->ID, |
@@ -1927,29 +1927,29 @@ discard block |
||
| 1927 | 1927 | ); |
| 1928 | 1928 | $log_meta = array(); |
| 1929 | 1929 | |
| 1930 | - if ( $old_log_meta = get_post_meta( $post->ID ) ) { |
|
| 1931 | - foreach ( $old_log_meta as $meta_key => $meta_value ) { |
|
| 1932 | - switch ( $meta_key ) { |
|
| 1930 | + if ($old_log_meta = get_post_meta($post->ID)) { |
|
| 1931 | + foreach ($old_log_meta as $meta_key => $meta_value) { |
|
| 1932 | + switch ($meta_key) { |
|
| 1933 | 1933 | case '_give_log_payment_id': |
| 1934 | - $log_data['log_parent'] = current( $meta_value ); |
|
| 1934 | + $log_data['log_parent'] = current($meta_value); |
|
| 1935 | 1935 | $log_meta['_give_log_form_id'] = $post->post_parent; |
| 1936 | 1936 | break; |
| 1937 | 1937 | |
| 1938 | 1938 | default: |
| 1939 | - $log_meta[ $meta_key ] = current( $meta_value ); |
|
| 1939 | + $log_meta[$meta_key] = current($meta_value); |
|
| 1940 | 1940 | } |
| 1941 | 1941 | } |
| 1942 | 1942 | } |
| 1943 | 1943 | |
| 1944 | - if ( 'api_request' === $term_name ) { |
|
| 1944 | + if ('api_request' === $term_name) { |
|
| 1945 | 1945 | $log_meta['_give_log_api_query'] = $post->post_excerpt; |
| 1946 | 1946 | } |
| 1947 | 1947 | |
| 1948 | - $wpdb->insert( "{$wpdb->prefix}give_logs", $log_data ); |
|
| 1948 | + $wpdb->insert("{$wpdb->prefix}give_logs", $log_data); |
|
| 1949 | 1949 | |
| 1950 | - if ( ! empty( $log_meta ) ) { |
|
| 1951 | - foreach ( $log_meta as $meta_key => $meta_value ) { |
|
| 1952 | - Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value ); |
|
| 1950 | + if ( ! empty($log_meta)) { |
|
| 1951 | + foreach ($log_meta as $meta_key => $meta_value) { |
|
| 1952 | + Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value); |
|
| 1953 | 1953 | } |
| 1954 | 1954 | } |
| 1955 | 1955 | |
@@ -1994,7 +1994,7 @@ discard block |
||
| 1994 | 1994 | Give()->logs->delete_cache(); |
| 1995 | 1995 | |
| 1996 | 1996 | // No more forms found, finish up. |
| 1997 | - give_set_upgrade_complete( 'v20_logs_upgrades' ); |
|
| 1997 | + give_set_upgrade_complete('v20_logs_upgrades'); |
|
| 1998 | 1998 | } |
| 1999 | 1999 | } |
| 2000 | 2000 | |
@@ -2015,15 +2015,15 @@ discard block |
||
| 2015 | 2015 | 'paged' => $give_updates->step, |
| 2016 | 2016 | 'status' => 'any', |
| 2017 | 2017 | 'order' => 'ASC', |
| 2018 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
| 2018 | + 'post_type' => array('give_forms', 'give_payment'), |
|
| 2019 | 2019 | 'posts_per_page' => 100, |
| 2020 | 2020 | ) |
| 2021 | 2021 | ); |
| 2022 | 2022 | |
| 2023 | - if ( $payments->have_posts() ) { |
|
| 2024 | - $give_updates->set_percentage( $payments->found_posts, $give_updates->step * 100 ); |
|
| 2023 | + if ($payments->have_posts()) { |
|
| 2024 | + $give_updates->set_percentage($payments->found_posts, $give_updates->step * 100); |
|
| 2025 | 2025 | |
| 2026 | - while ( $payments->have_posts() ) { |
|
| 2026 | + while ($payments->have_posts()) { |
|
| 2027 | 2027 | $payments->the_post(); |
| 2028 | 2028 | global $post; |
| 2029 | 2029 | |
@@ -2035,19 +2035,19 @@ discard block |
||
| 2035 | 2035 | ARRAY_A |
| 2036 | 2036 | ); |
| 2037 | 2037 | |
| 2038 | - if ( ! empty( $meta_data ) ) { |
|
| 2039 | - foreach ( $meta_data as $index => $data ) { |
|
| 2038 | + if ( ! empty($meta_data)) { |
|
| 2039 | + foreach ($meta_data as $index => $data) { |
|
| 2040 | 2040 | // Check for duplicate meta values. |
| 2041 | - if ( $result = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . ( 'give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta ) . ' WHERE meta_id=%d', $data['meta_id'] ), ARRAY_A ) ) { |
|
| 2041 | + if ($result = $wpdb->get_results($wpdb->prepare('SELECT * FROM '.('give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta).' WHERE meta_id=%d', $data['meta_id']), ARRAY_A)) { |
|
| 2042 | 2042 | continue; |
| 2043 | 2043 | } |
| 2044 | 2044 | |
| 2045 | - switch ( $post->post_type ) { |
|
| 2045 | + switch ($post->post_type) { |
|
| 2046 | 2046 | case 'give_forms': |
| 2047 | 2047 | $data['form_id'] = $data['post_id']; |
| 2048 | - unset( $data['post_id'] ); |
|
| 2048 | + unset($data['post_id']); |
|
| 2049 | 2049 | |
| 2050 | - Give()->form_meta->insert( $data ); |
|
| 2050 | + Give()->form_meta->insert($data); |
|
| 2051 | 2051 | // @todo: delete form meta from post meta table after releases 2.0. |
| 2052 | 2052 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
| 2053 | 2053 | |
@@ -2055,9 +2055,9 @@ discard block |
||
| 2055 | 2055 | |
| 2056 | 2056 | case 'give_payment': |
| 2057 | 2057 | $data['payment_id'] = $data['post_id']; |
| 2058 | - unset( $data['post_id'] ); |
|
| 2058 | + unset($data['post_id']); |
|
| 2059 | 2059 | |
| 2060 | - Give()->payment_meta->insert( $data ); |
|
| 2060 | + Give()->payment_meta->insert($data); |
|
| 2061 | 2061 | |
| 2062 | 2062 | // @todo: delete donation meta from post meta table after releases 2.0. |
| 2063 | 2063 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
@@ -2071,7 +2071,7 @@ discard block |
||
| 2071 | 2071 | wp_reset_postdata(); |
| 2072 | 2072 | } else { |
| 2073 | 2073 | // No more forms found, finish up. |
| 2074 | - give_set_upgrade_complete( 'v20_move_metadata_into_new_table' ); |
|
| 2074 | + give_set_upgrade_complete('v20_move_metadata_into_new_table'); |
|
| 2075 | 2075 | } |
| 2076 | 2076 | |
| 2077 | 2077 | } |
@@ -2094,38 +2094,38 @@ discard block |
||
| 2094 | 2094 | ) |
| 2095 | 2095 | ); |
| 2096 | 2096 | |
| 2097 | - if ( $donors ) { |
|
| 2098 | - $give_updates->set_percentage( count( $donors ), $give_updates->step * 100 ); |
|
| 2097 | + if ($donors) { |
|
| 2098 | + $give_updates->set_percentage(count($donors), $give_updates->step * 100); |
|
| 2099 | 2099 | // Loop through Donors |
| 2100 | - foreach ( $donors as $donor ) { |
|
| 2100 | + foreach ($donors as $donor) { |
|
| 2101 | 2101 | |
| 2102 | - $donor_name = explode( ' ', $donor->name, 2 ); |
|
| 2103 | - $donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' ); |
|
| 2104 | - $donor_last_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' ); |
|
| 2102 | + $donor_name = explode(' ', $donor->name, 2); |
|
| 2103 | + $donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name'); |
|
| 2104 | + $donor_last_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name'); |
|
| 2105 | 2105 | |
| 2106 | 2106 | // If first name meta of donor is not created, then create it. |
| 2107 | - if ( ! $donor_first_name && isset( $donor_name[0] ) ) { |
|
| 2108 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] ); |
|
| 2107 | + if ( ! $donor_first_name && isset($donor_name[0])) { |
|
| 2108 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]); |
|
| 2109 | 2109 | } |
| 2110 | 2110 | |
| 2111 | 2111 | // If last name meta of donor is not created, then create it. |
| 2112 | - if ( ! $donor_last_name && isset( $donor_name[1] ) ) { |
|
| 2113 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] ); |
|
| 2112 | + if ( ! $donor_last_name && isset($donor_name[1])) { |
|
| 2113 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]); |
|
| 2114 | 2114 | } |
| 2115 | 2115 | |
| 2116 | 2116 | // If Donor is connected with WP User then update user meta. |
| 2117 | - if ( $donor->user_id ) { |
|
| 2118 | - if ( isset( $donor_name[0] ) ) { |
|
| 2119 | - update_user_meta( $donor->user_id, 'first_name', $donor_name[0] ); |
|
| 2117 | + if ($donor->user_id) { |
|
| 2118 | + if (isset($donor_name[0])) { |
|
| 2119 | + update_user_meta($donor->user_id, 'first_name', $donor_name[0]); |
|
| 2120 | 2120 | } |
| 2121 | - if ( isset( $donor_name[1] ) ) { |
|
| 2122 | - update_user_meta( $donor->user_id, 'last_name', $donor_name[1] ); |
|
| 2121 | + if (isset($donor_name[1])) { |
|
| 2122 | + update_user_meta($donor->user_id, 'last_name', $donor_name[1]); |
|
| 2123 | 2123 | } |
| 2124 | 2124 | } |
| 2125 | 2125 | } |
| 2126 | 2126 | } else { |
| 2127 | 2127 | // The Update Ran. |
| 2128 | - give_set_upgrade_complete( 'v20_upgrades_donor_name' ); |
|
| 2128 | + give_set_upgrade_complete('v20_upgrades_donor_name'); |
|
| 2129 | 2129 | } |
| 2130 | 2130 | |
| 2131 | 2131 | } |
@@ -2154,15 +2154,15 @@ discard block |
||
| 2154 | 2154 | |
| 2155 | 2155 | $users = $user_query->get_results(); |
| 2156 | 2156 | |
| 2157 | - if ( $users ) { |
|
| 2158 | - $give_updates->set_percentage( $user_query->get_total(), $give_updates->step * 100 ); |
|
| 2157 | + if ($users) { |
|
| 2158 | + $give_updates->set_percentage($user_query->get_total(), $give_updates->step * 100); |
|
| 2159 | 2159 | |
| 2160 | 2160 | // Loop through Donors |
| 2161 | - foreach ( $users as $user ) { |
|
| 2161 | + foreach ($users as $user) { |
|
| 2162 | 2162 | /* @var Give_Donor $donor */ |
| 2163 | - $donor = new Give_Donor( $user->ID, true ); |
|
| 2163 | + $donor = new Give_Donor($user->ID, true); |
|
| 2164 | 2164 | |
| 2165 | - if ( ! $donor->id ) { |
|
| 2165 | + if ( ! $donor->id) { |
|
| 2166 | 2166 | continue; |
| 2167 | 2167 | } |
| 2168 | 2168 | |
@@ -2178,10 +2178,10 @@ discard block |
||
| 2178 | 2178 | ) |
| 2179 | 2179 | ); |
| 2180 | 2180 | |
| 2181 | - if ( ! empty( $address ) ) { |
|
| 2182 | - $address = maybe_unserialize( $address ); |
|
| 2183 | - $donor->add_address( 'personal', $address ); |
|
| 2184 | - $donor->add_address( 'billing[]', $address ); |
|
| 2181 | + if ( ! empty($address)) { |
|
| 2182 | + $address = maybe_unserialize($address); |
|
| 2183 | + $donor->add_address('personal', $address); |
|
| 2184 | + $donor->add_address('billing[]', $address); |
|
| 2185 | 2185 | |
| 2186 | 2186 | // @todo: delete _give_user_address from user meta after releases 2.0. |
| 2187 | 2187 | /*delete_user_meta( $user->ID, '_give_user_address' );*/ |
@@ -2189,7 +2189,7 @@ discard block |
||
| 2189 | 2189 | } |
| 2190 | 2190 | } else { |
| 2191 | 2191 | // The Update Ran. |
| 2192 | - give_set_upgrade_complete( 'v20_upgrades_user_address' ); |
|
| 2192 | + give_set_upgrade_complete('v20_upgrades_user_address'); |
|
| 2193 | 2193 | } |
| 2194 | 2194 | |
| 2195 | 2195 | } |
@@ -2213,15 +2213,15 @@ discard block |
||
| 2213 | 2213 | ); |
| 2214 | 2214 | |
| 2215 | 2215 | // Alter customer table |
| 2216 | - foreach ( $tables as $old_table => $new_table ) { |
|
| 2216 | + foreach ($tables as $old_table => $new_table) { |
|
| 2217 | 2217 | if ( |
| 2218 | - $wpdb->query( $wpdb->prepare( 'SHOW TABLES LIKE %s', $old_table ) ) && |
|
| 2219 | - ! $wpdb->query( $wpdb->prepare( 'SHOW TABLES LIKE %s', $new_table ) ) |
|
| 2218 | + $wpdb->query($wpdb->prepare('SHOW TABLES LIKE %s', $old_table)) && |
|
| 2219 | + ! $wpdb->query($wpdb->prepare('SHOW TABLES LIKE %s', $new_table)) |
|
| 2220 | 2220 | ) { |
| 2221 | - $wpdb->query( "ALTER TABLE {$old_table} RENAME TO {$new_table}" ); |
|
| 2221 | + $wpdb->query("ALTER TABLE {$old_table} RENAME TO {$new_table}"); |
|
| 2222 | 2222 | |
| 2223 | - if ( "{$wpdb->prefix}give_donormeta" === $new_table ) { |
|
| 2224 | - $wpdb->query( "ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)" ); |
|
| 2223 | + if ("{$wpdb->prefix}give_donormeta" === $new_table) { |
|
| 2224 | + $wpdb->query("ALTER TABLE {$new_table} CHANGE COLUMN customer_id donor_id bigint(20)"); |
|
| 2225 | 2225 | } |
| 2226 | 2226 | } |
| 2227 | 2227 | } |
@@ -2229,7 +2229,7 @@ discard block |
||
| 2229 | 2229 | $give_updates->percentage = 100; |
| 2230 | 2230 | |
| 2231 | 2231 | // No more forms found, finish up. |
| 2232 | - give_set_upgrade_complete( 'v20_rename_donor_tables' ); |
|
| 2232 | + give_set_upgrade_complete('v20_rename_donor_tables'); |
|
| 2233 | 2233 | |
| 2234 | 2234 | // Re initiate donor classes. |
| 2235 | 2235 | Give()->donors = new Give_DB_Donors(); |
@@ -2247,19 +2247,19 @@ discard block |
||
| 2247 | 2247 | function give_v201_create_tables() { |
| 2248 | 2248 | global $wpdb; |
| 2249 | 2249 | |
| 2250 | - if ( ! $wpdb->query( $wpdb->prepare( 'SHOW TABLES LIKE %s', "{$wpdb->prefix}give_paymentmeta" ) ) ) { |
|
| 2250 | + if ( ! $wpdb->query($wpdb->prepare('SHOW TABLES LIKE %s', "{$wpdb->prefix}give_paymentmeta"))) { |
|
| 2251 | 2251 | Give()->payment_meta->create_table(); |
| 2252 | 2252 | } |
| 2253 | 2253 | |
| 2254 | - if ( ! $wpdb->query( $wpdb->prepare( 'SHOW TABLES LIKE %s', "{$wpdb->prefix}give_formmeta" ) ) ) { |
|
| 2254 | + if ( ! $wpdb->query($wpdb->prepare('SHOW TABLES LIKE %s', "{$wpdb->prefix}give_formmeta"))) { |
|
| 2255 | 2255 | Give()->form_meta->create_table(); |
| 2256 | 2256 | } |
| 2257 | 2257 | |
| 2258 | - if ( ! $wpdb->query( $wpdb->prepare( 'SHOW TABLES LIKE %s', "{$wpdb->prefix}give_logs" ) ) ) { |
|
| 2258 | + if ( ! $wpdb->query($wpdb->prepare('SHOW TABLES LIKE %s', "{$wpdb->prefix}give_logs"))) { |
|
| 2259 | 2259 | Give()->logs->log_db->create_table(); |
| 2260 | 2260 | } |
| 2261 | 2261 | |
| 2262 | - if ( ! $wpdb->query( $wpdb->prepare( 'SHOW TABLES LIKE %s', "{$wpdb->prefix}give_logmeta" ) ) ) { |
|
| 2262 | + if ( ! $wpdb->query($wpdb->prepare('SHOW TABLES LIKE %s', "{$wpdb->prefix}give_logmeta"))) { |
|
| 2263 | 2263 | Give()->logs->logmeta_db->create_table(); |
| 2264 | 2264 | } |
| 2265 | 2265 | } |
@@ -2284,30 +2284,30 @@ discard block |
||
| 2284 | 2284 | $wpdb->posts.post_date >= '2018-01-08 00:00:00' |
| 2285 | 2285 | ) |
| 2286 | 2286 | AND $wpdb->posts.post_type = 'give_payment' |
| 2287 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
| 2287 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
| 2288 | 2288 | ORDER BY $wpdb->posts.post_date ASC |
| 2289 | 2289 | LIMIT 100 |
| 2290 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
| 2290 | + OFFSET ".$give_updates->get_offset(100) |
|
| 2291 | 2291 | ); |
| 2292 | 2292 | |
| 2293 | - if ( ! empty( $payments ) ) { |
|
| 2294 | - $give_updates->set_percentage( give_get_total_post_type_count( 'give_payment' ), ( $give_updates->step * 100 ) ); |
|
| 2293 | + if ( ! empty($payments)) { |
|
| 2294 | + $give_updates->set_percentage(give_get_total_post_type_count('give_payment'), ($give_updates->step * 100)); |
|
| 2295 | 2295 | |
| 2296 | - foreach ( $payments as $payment_id ) { |
|
| 2297 | - $post = get_post( $payment_id ); |
|
| 2298 | - setup_postdata( $post ); |
|
| 2296 | + foreach ($payments as $payment_id) { |
|
| 2297 | + $post = get_post($payment_id); |
|
| 2298 | + setup_postdata($post); |
|
| 2299 | 2299 | |
| 2300 | 2300 | // Do not add new meta keys if already refactored. |
| 2301 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, '_give_payment_donor_id' ) ) ) { |
|
| 2301 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, '_give_payment_donor_id'))) { |
|
| 2302 | 2302 | continue; |
| 2303 | 2303 | } |
| 2304 | 2304 | |
| 2305 | 2305 | // Split _give_payment_meta meta. |
| 2306 | 2306 | // @todo Remove _give_payment_meta after releases 2.0 |
| 2307 | - $payment_meta = give_get_meta( $post->ID, '_give_payment_meta', true ); |
|
| 2307 | + $payment_meta = give_get_meta($post->ID, '_give_payment_meta', true); |
|
| 2308 | 2308 | |
| 2309 | - if ( ! empty( $payment_meta ) ) { |
|
| 2310 | - _give_20_bc_split_and_save_give_payment_meta( $post->ID, $payment_meta ); |
|
| 2309 | + if ( ! empty($payment_meta)) { |
|
| 2310 | + _give_20_bc_split_and_save_give_payment_meta($post->ID, $payment_meta); |
|
| 2311 | 2311 | } |
| 2312 | 2312 | |
| 2313 | 2313 | $deprecated_meta_keys = array( |
@@ -2316,9 +2316,9 @@ discard block |
||
| 2316 | 2316 | '_give_payment_user_ip' => '_give_payment_donor_ip', |
| 2317 | 2317 | ); |
| 2318 | 2318 | |
| 2319 | - foreach ( $deprecated_meta_keys as $old_meta_key => $new_meta_key ) { |
|
| 2319 | + foreach ($deprecated_meta_keys as $old_meta_key => $new_meta_key) { |
|
| 2320 | 2320 | // Do not add new meta key if already exist. |
| 2321 | - if ( $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key ) ) ) { |
|
| 2321 | + if ($wpdb->get_var($wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id=%d AND meta_key=%s", $post->ID, $new_meta_key))) { |
|
| 2322 | 2322 | continue; |
| 2323 | 2323 | } |
| 2324 | 2324 | |
@@ -2327,25 +2327,25 @@ discard block |
||
| 2327 | 2327 | array( |
| 2328 | 2328 | 'post_id' => $post->ID, |
| 2329 | 2329 | 'meta_key' => $new_meta_key, |
| 2330 | - 'meta_value' => give_get_meta( $post->ID, $old_meta_key, true ), |
|
| 2330 | + 'meta_value' => give_get_meta($post->ID, $old_meta_key, true), |
|
| 2331 | 2331 | ) |
| 2332 | 2332 | ); |
| 2333 | 2333 | } |
| 2334 | 2334 | |
| 2335 | 2335 | // Bailout |
| 2336 | - if ( $donor_id = give_get_meta( $post->ID, '_give_payment_donor_id', true ) ) { |
|
| 2336 | + if ($donor_id = give_get_meta($post->ID, '_give_payment_donor_id', true)) { |
|
| 2337 | 2337 | /* @var Give_Donor $donor */ |
| 2338 | - $donor = new Give_Donor( $donor_id ); |
|
| 2338 | + $donor = new Give_Donor($donor_id); |
|
| 2339 | 2339 | |
| 2340 | - $address['line1'] = give_get_meta( $post->ID, '_give_donor_billing_address1', true, '' ); |
|
| 2341 | - $address['line2'] = give_get_meta( $post->ID, '_give_donor_billing_address2', true, '' ); |
|
| 2342 | - $address['city'] = give_get_meta( $post->ID, '_give_donor_billing_city', true, '' ); |
|
| 2343 | - $address['state'] = give_get_meta( $post->ID, '_give_donor_billing_state', true, '' ); |
|
| 2344 | - $address['zip'] = give_get_meta( $post->ID, '_give_donor_billing_zip', true, '' ); |
|
| 2345 | - $address['country'] = give_get_meta( $post->ID, '_give_donor_billing_country', true, '' ); |
|
| 2340 | + $address['line1'] = give_get_meta($post->ID, '_give_donor_billing_address1', true, ''); |
|
| 2341 | + $address['line2'] = give_get_meta($post->ID, '_give_donor_billing_address2', true, ''); |
|
| 2342 | + $address['city'] = give_get_meta($post->ID, '_give_donor_billing_city', true, ''); |
|
| 2343 | + $address['state'] = give_get_meta($post->ID, '_give_donor_billing_state', true, ''); |
|
| 2344 | + $address['zip'] = give_get_meta($post->ID, '_give_donor_billing_zip', true, ''); |
|
| 2345 | + $address['country'] = give_get_meta($post->ID, '_give_donor_billing_country', true, ''); |
|
| 2346 | 2346 | |
| 2347 | 2347 | // Save address. |
| 2348 | - $donor->add_address( 'billing[]', $address ); |
|
| 2348 | + $donor->add_address('billing[]', $address); |
|
| 2349 | 2349 | } |
| 2350 | 2350 | }// End while(). |
| 2351 | 2351 | |
@@ -2354,7 +2354,7 @@ discard block |
||
| 2354 | 2354 | // @todo Delete user id meta after releases 2.0 |
| 2355 | 2355 | // $wpdb->get_var( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key=%s", '_give_payment_user_id' ) ); |
| 2356 | 2356 | // No more forms found, finish up. |
| 2357 | - give_set_upgrade_complete( 'v201_upgrades_payment_metadata' ); |
|
| 2357 | + give_set_upgrade_complete('v201_upgrades_payment_metadata'); |
|
| 2358 | 2358 | } |
| 2359 | 2359 | } |
| 2360 | 2360 | |
@@ -2374,13 +2374,13 @@ discard block |
||
| 2374 | 2374 | SELECT ID FROM $wpdb->posts |
| 2375 | 2375 | WHERE 1=1 |
| 2376 | 2376 | AND ( $wpdb->posts.post_type = 'give_payment' OR $wpdb->posts.post_type = 'give_forms' ) |
| 2377 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
| 2377 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
| 2378 | 2378 | ORDER BY $wpdb->posts.post_date ASC |
| 2379 | 2379 | LIMIT 100 |
| 2380 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
| 2380 | + OFFSET ".$give_updates->get_offset(100) |
|
| 2381 | 2381 | ); |
| 2382 | 2382 | |
| 2383 | - if ( ! empty( $payments ) ) { |
|
| 2383 | + if ( ! empty($payments)) { |
|
| 2384 | 2384 | $give_updates->set_percentage( |
| 2385 | 2385 | give_get_total_post_type_count( |
| 2386 | 2386 | array( |
@@ -2390,9 +2390,9 @@ discard block |
||
| 2390 | 2390 | ), $give_updates->step * 100 |
| 2391 | 2391 | ); |
| 2392 | 2392 | |
| 2393 | - foreach ( $payments as $payment_id ) { |
|
| 2394 | - $post = get_post( $payment_id ); |
|
| 2395 | - setup_postdata( $post ); |
|
| 2393 | + foreach ($payments as $payment_id) { |
|
| 2394 | + $post = get_post($payment_id); |
|
| 2395 | + setup_postdata($post); |
|
| 2396 | 2396 | |
| 2397 | 2397 | $meta_data = $wpdb->get_results( |
| 2398 | 2398 | $wpdb->prepare( |
@@ -2402,19 +2402,19 @@ discard block |
||
| 2402 | 2402 | ARRAY_A |
| 2403 | 2403 | ); |
| 2404 | 2404 | |
| 2405 | - if ( ! empty( $meta_data ) ) { |
|
| 2406 | - foreach ( $meta_data as $index => $data ) { |
|
| 2405 | + if ( ! empty($meta_data)) { |
|
| 2406 | + foreach ($meta_data as $index => $data) { |
|
| 2407 | 2407 | // Check for duplicate meta values. |
| 2408 | - if ( $result = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . ( 'give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta ) . ' WHERE meta_id=%d', $data['meta_id'] ), ARRAY_A ) ) { |
|
| 2408 | + if ($result = $wpdb->get_results($wpdb->prepare('SELECT * FROM '.('give_forms' === $post->post_type ? $wpdb->formmeta : $wpdb->paymentmeta).' WHERE meta_id=%d', $data['meta_id']), ARRAY_A)) { |
|
| 2409 | 2409 | continue; |
| 2410 | 2410 | } |
| 2411 | 2411 | |
| 2412 | - switch ( $post->post_type ) { |
|
| 2412 | + switch ($post->post_type) { |
|
| 2413 | 2413 | case 'give_forms': |
| 2414 | 2414 | $data['form_id'] = $data['post_id']; |
| 2415 | - unset( $data['post_id'] ); |
|
| 2415 | + unset($data['post_id']); |
|
| 2416 | 2416 | |
| 2417 | - Give()->form_meta->insert( $data ); |
|
| 2417 | + Give()->form_meta->insert($data); |
|
| 2418 | 2418 | // @todo: delete form meta from post meta table after releases 2.0. |
| 2419 | 2419 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
| 2420 | 2420 | |
@@ -2422,9 +2422,9 @@ discard block |
||
| 2422 | 2422 | |
| 2423 | 2423 | case 'give_payment': |
| 2424 | 2424 | $data['payment_id'] = $data['post_id']; |
| 2425 | - unset( $data['post_id'] ); |
|
| 2425 | + unset($data['post_id']); |
|
| 2426 | 2426 | |
| 2427 | - Give()->payment_meta->insert( $data ); |
|
| 2427 | + Give()->payment_meta->insert($data); |
|
| 2428 | 2428 | |
| 2429 | 2429 | // @todo: delete donation meta from post meta table after releases 2.0. |
| 2430 | 2430 | /*delete_post_meta( get_the_ID(), $data['meta_key'] );*/ |
@@ -2438,7 +2438,7 @@ discard block |
||
| 2438 | 2438 | wp_reset_postdata(); |
| 2439 | 2439 | } else { |
| 2440 | 2440 | // No more forms found, finish up. |
| 2441 | - give_set_upgrade_complete( 'v201_move_metadata_into_new_table' ); |
|
| 2441 | + give_set_upgrade_complete('v201_move_metadata_into_new_table'); |
|
| 2442 | 2442 | } |
| 2443 | 2443 | |
| 2444 | 2444 | } |
@@ -2459,26 +2459,26 @@ discard block |
||
| 2459 | 2459 | SELECT ID FROM $wpdb->posts |
| 2460 | 2460 | WHERE 1=1 |
| 2461 | 2461 | AND $wpdb->posts.post_type = 'give_log' |
| 2462 | - AND {$wpdb->posts}.post_status IN ('" . implode( "','", array_keys( give_get_payment_statuses() ) ) . "') |
|
| 2462 | + AND {$wpdb->posts}.post_status IN ('".implode("','", array_keys(give_get_payment_statuses()))."') |
|
| 2463 | 2463 | ORDER BY $wpdb->posts.post_date ASC |
| 2464 | 2464 | LIMIT 100 |
| 2465 | - OFFSET " . $give_updates->get_offset( 100 ) |
|
| 2465 | + OFFSET ".$give_updates->get_offset(100) |
|
| 2466 | 2466 | ); |
| 2467 | 2467 | |
| 2468 | - if ( ! empty( $logs ) ) { |
|
| 2469 | - $give_updates->set_percentage( give_get_total_post_type_count( 'give_log' ), $give_updates->step * 100 ); |
|
| 2468 | + if ( ! empty($logs)) { |
|
| 2469 | + $give_updates->set_percentage(give_get_total_post_type_count('give_log'), $give_updates->step * 100); |
|
| 2470 | 2470 | |
| 2471 | - foreach ( $logs as $log_id ) { |
|
| 2472 | - $post = get_post( $log_id ); |
|
| 2473 | - setup_postdata( $post ); |
|
| 2471 | + foreach ($logs as $log_id) { |
|
| 2472 | + $post = get_post($log_id); |
|
| 2473 | + setup_postdata($post); |
|
| 2474 | 2474 | |
| 2475 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID ) ) ) { |
|
| 2475 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_logs WHERE ID=%d", $post->ID))) { |
|
| 2476 | 2476 | continue; |
| 2477 | 2477 | } |
| 2478 | 2478 | |
| 2479 | - $term = get_the_terms( $post->ID, 'give_log_type' ); |
|
| 2480 | - $term = ! is_wp_error( $term ) && ! empty( $term ) ? $term[0] : array(); |
|
| 2481 | - $term_name = ! empty( $term ) ? $term->slug : ''; |
|
| 2479 | + $term = get_the_terms($post->ID, 'give_log_type'); |
|
| 2480 | + $term = ! is_wp_error($term) && ! empty($term) ? $term[0] : array(); |
|
| 2481 | + $term_name = ! empty($term) ? $term->slug : ''; |
|
| 2482 | 2482 | |
| 2483 | 2483 | $log_data = array( |
| 2484 | 2484 | 'ID' => $post->ID, |
@@ -2491,29 +2491,29 @@ discard block |
||
| 2491 | 2491 | ); |
| 2492 | 2492 | $log_meta = array(); |
| 2493 | 2493 | |
| 2494 | - if ( $old_log_meta = get_post_meta( $post->ID ) ) { |
|
| 2495 | - foreach ( $old_log_meta as $meta_key => $meta_value ) { |
|
| 2496 | - switch ( $meta_key ) { |
|
| 2494 | + if ($old_log_meta = get_post_meta($post->ID)) { |
|
| 2495 | + foreach ($old_log_meta as $meta_key => $meta_value) { |
|
| 2496 | + switch ($meta_key) { |
|
| 2497 | 2497 | case '_give_log_payment_id': |
| 2498 | - $log_data['log_parent'] = current( $meta_value ); |
|
| 2498 | + $log_data['log_parent'] = current($meta_value); |
|
| 2499 | 2499 | $log_meta['_give_log_form_id'] = $post->post_parent; |
| 2500 | 2500 | break; |
| 2501 | 2501 | |
| 2502 | 2502 | default: |
| 2503 | - $log_meta[ $meta_key ] = current( $meta_value ); |
|
| 2503 | + $log_meta[$meta_key] = current($meta_value); |
|
| 2504 | 2504 | } |
| 2505 | 2505 | } |
| 2506 | 2506 | } |
| 2507 | 2507 | |
| 2508 | - if ( 'api_request' === $term_name ) { |
|
| 2508 | + if ('api_request' === $term_name) { |
|
| 2509 | 2509 | $log_meta['_give_log_api_query'] = $post->post_excerpt; |
| 2510 | 2510 | } |
| 2511 | 2511 | |
| 2512 | - $wpdb->insert( "{$wpdb->prefix}give_logs", $log_data ); |
|
| 2512 | + $wpdb->insert("{$wpdb->prefix}give_logs", $log_data); |
|
| 2513 | 2513 | |
| 2514 | - if ( ! empty( $log_meta ) ) { |
|
| 2515 | - foreach ( $log_meta as $meta_key => $meta_value ) { |
|
| 2516 | - Give()->logs->logmeta_db->update_meta( $post->ID, $meta_key, $meta_value ); |
|
| 2514 | + if ( ! empty($log_meta)) { |
|
| 2515 | + foreach ($log_meta as $meta_key => $meta_value) { |
|
| 2516 | + Give()->logs->logmeta_db->update_meta($post->ID, $meta_key, $meta_value); |
|
| 2517 | 2517 | } |
| 2518 | 2518 | } |
| 2519 | 2519 | |
@@ -2526,7 +2526,7 @@ discard block |
||
| 2526 | 2526 | Give()->logs->delete_cache(); |
| 2527 | 2527 | |
| 2528 | 2528 | // No more forms found, finish up. |
| 2529 | - give_set_upgrade_complete( 'v201_logs_upgrades' ); |
|
| 2529 | + give_set_upgrade_complete('v201_logs_upgrades'); |
|
| 2530 | 2530 | } |
| 2531 | 2531 | } |
| 2532 | 2532 | |
@@ -2541,51 +2541,51 @@ discard block |
||
| 2541 | 2541 | global $wpdb; |
| 2542 | 2542 | give_v201_create_tables(); |
| 2543 | 2543 | |
| 2544 | - if ( $wpdb->query( $wpdb->prepare( 'SHOW TABLES LIKE %s', "{$wpdb->prefix}give_customers" ) ) ) { |
|
| 2545 | - $customers = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_customers" ), 'id' ); |
|
| 2546 | - $donors = wp_list_pluck( $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}give_donors" ), 'id' ); |
|
| 2544 | + if ($wpdb->query($wpdb->prepare('SHOW TABLES LIKE %s', "{$wpdb->prefix}give_customers"))) { |
|
| 2545 | + $customers = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_customers"), 'id'); |
|
| 2546 | + $donors = wp_list_pluck($wpdb->get_results("SELECT id FROM {$wpdb->prefix}give_donors"), 'id'); |
|
| 2547 | 2547 | $donor_data = array(); |
| 2548 | 2548 | |
| 2549 | - if ( $missing_donors = array_diff( $customers, $donors ) ) { |
|
| 2550 | - foreach ( $missing_donors as $donor_id ) { |
|
| 2549 | + if ($missing_donors = array_diff($customers, $donors)) { |
|
| 2550 | + foreach ($missing_donors as $donor_id) { |
|
| 2551 | 2551 | $donor_data[] = array( |
| 2552 | - 'info' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id ) ), |
|
| 2553 | - 'meta' => $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id ) ), |
|
| 2552 | + 'info' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customers WHERE id=%d", $donor_id)), |
|
| 2553 | + 'meta' => $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_customermeta WHERE customer_id=%d", $donor_id)), |
|
| 2554 | 2554 | |
| 2555 | 2555 | ); |
| 2556 | 2556 | } |
| 2557 | 2557 | } |
| 2558 | 2558 | |
| 2559 | - if ( ! empty( $donor_data ) ) { |
|
| 2559 | + if ( ! empty($donor_data)) { |
|
| 2560 | 2560 | $donor_table_name = Give()->donors->table_name; |
| 2561 | 2561 | $donor_meta_table_name = Give()->donor_meta->table_name; |
| 2562 | 2562 | |
| 2563 | 2563 | Give()->donors->table_name = "{$wpdb->prefix}give_donors"; |
| 2564 | 2564 | Give()->donor_meta->table_name = "{$wpdb->prefix}give_donormeta"; |
| 2565 | 2565 | |
| 2566 | - foreach ( $donor_data as $donor ) { |
|
| 2566 | + foreach ($donor_data as $donor) { |
|
| 2567 | 2567 | $donor['info'][0] = (array) $donor['info'][0]; |
| 2568 | 2568 | |
| 2569 | 2569 | // Prevent duplicate meta id issue. |
| 2570 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id'] ) ) ) { |
|
| 2570 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donors WHERE id=%d", $donor['info'][0]['id']))) { |
|
| 2571 | 2571 | continue; |
| 2572 | 2572 | } |
| 2573 | 2573 | |
| 2574 | - $donor_id = Give()->donors->add( $donor['info'][0] ); |
|
| 2574 | + $donor_id = Give()->donors->add($donor['info'][0]); |
|
| 2575 | 2575 | |
| 2576 | - if ( ! empty( $donor['meta'] ) ) { |
|
| 2577 | - foreach ( $donor['meta'] as $donor_meta ) { |
|
| 2576 | + if ( ! empty($donor['meta'])) { |
|
| 2577 | + foreach ($donor['meta'] as $donor_meta) { |
|
| 2578 | 2578 | $donor_meta = (array) $donor_meta; |
| 2579 | 2579 | |
| 2580 | 2580 | // Prevent duplicate meta id issue. |
| 2581 | - if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id'] ) ) ) { |
|
| 2582 | - unset( $donor_meta['meta_id'] ); |
|
| 2581 | + if ($wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}give_donormeta WHERE meta_id=%d", $donor_meta['meta_id']))) { |
|
| 2582 | + unset($donor_meta['meta_id']); |
|
| 2583 | 2583 | } |
| 2584 | 2584 | |
| 2585 | 2585 | $donor_meta['donor_id'] = $donor_meta['customer_id']; |
| 2586 | - unset( $donor_meta['customer_id'] ); |
|
| 2586 | + unset($donor_meta['customer_id']); |
|
| 2587 | 2587 | |
| 2588 | - Give()->donor_meta->insert( $donor_meta ); |
|
| 2588 | + Give()->donor_meta->insert($donor_meta); |
|
| 2589 | 2589 | } |
| 2590 | 2590 | } |
| 2591 | 2591 | |
@@ -2604,35 +2604,35 @@ discard block |
||
| 2604 | 2604 | ) |
| 2605 | 2605 | ); |
| 2606 | 2606 | |
| 2607 | - $donor = new Give_Donor( $donor_id ); |
|
| 2607 | + $donor = new Give_Donor($donor_id); |
|
| 2608 | 2608 | |
| 2609 | - if ( ! empty( $address ) ) { |
|
| 2610 | - $address = maybe_unserialize( $address ); |
|
| 2611 | - $donor->add_address( 'personal', $address ); |
|
| 2612 | - $donor->add_address( 'billing[]', $address ); |
|
| 2609 | + if ( ! empty($address)) { |
|
| 2610 | + $address = maybe_unserialize($address); |
|
| 2611 | + $donor->add_address('personal', $address); |
|
| 2612 | + $donor->add_address('billing[]', $address); |
|
| 2613 | 2613 | } |
| 2614 | 2614 | |
| 2615 | - $donor_name = explode( ' ', $donor->name, 2 ); |
|
| 2616 | - $donor_first_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_first_name' ); |
|
| 2617 | - $donor_last_name = Give()->donor_meta->get_meta( $donor->id, '_give_donor_last_name' ); |
|
| 2615 | + $donor_name = explode(' ', $donor->name, 2); |
|
| 2616 | + $donor_first_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_first_name'); |
|
| 2617 | + $donor_last_name = Give()->donor_meta->get_meta($donor->id, '_give_donor_last_name'); |
|
| 2618 | 2618 | |
| 2619 | 2619 | // If first name meta of donor is not created, then create it. |
| 2620 | - if ( ! $donor_first_name && isset( $donor_name[0] ) ) { |
|
| 2621 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_first_name', $donor_name[0] ); |
|
| 2620 | + if ( ! $donor_first_name && isset($donor_name[0])) { |
|
| 2621 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_first_name', $donor_name[0]); |
|
| 2622 | 2622 | } |
| 2623 | 2623 | |
| 2624 | 2624 | // If last name meta of donor is not created, then create it. |
| 2625 | - if ( ! $donor_last_name && isset( $donor_name[1] ) ) { |
|
| 2626 | - Give()->donor_meta->add_meta( $donor->id, '_give_donor_last_name', $donor_name[1] ); |
|
| 2625 | + if ( ! $donor_last_name && isset($donor_name[1])) { |
|
| 2626 | + Give()->donor_meta->add_meta($donor->id, '_give_donor_last_name', $donor_name[1]); |
|
| 2627 | 2627 | } |
| 2628 | 2628 | |
| 2629 | 2629 | // If Donor is connected with WP User then update user meta. |
| 2630 | - if ( $donor->user_id ) { |
|
| 2631 | - if ( isset( $donor_name[0] ) ) { |
|
| 2632 | - update_user_meta( $donor->user_id, 'first_name', $donor_name[0] ); |
|
| 2630 | + if ($donor->user_id) { |
|
| 2631 | + if (isset($donor_name[0])) { |
|
| 2632 | + update_user_meta($donor->user_id, 'first_name', $donor_name[0]); |
|
| 2633 | 2633 | } |
| 2634 | - if ( isset( $donor_name[1] ) ) { |
|
| 2635 | - update_user_meta( $donor->user_id, 'last_name', $donor_name[1] ); |
|
| 2634 | + if (isset($donor_name[1])) { |
|
| 2635 | + update_user_meta($donor->user_id, 'last_name', $donor_name[1]); |
|
| 2636 | 2636 | } |
| 2637 | 2637 | } |
| 2638 | 2638 | } |
@@ -2643,7 +2643,7 @@ discard block |
||
| 2643 | 2643 | } |
| 2644 | 2644 | |
| 2645 | 2645 | Give_Updates::get_instance()->percentage = 100; |
| 2646 | - give_set_upgrade_complete( 'v201_add_missing_donors' ); |
|
| 2646 | + give_set_upgrade_complete('v201_add_missing_donors'); |
|
| 2647 | 2647 | } |
| 2648 | 2648 | |
| 2649 | 2649 | |
@@ -2656,14 +2656,14 @@ discard block |
||
| 2656 | 2656 | global $wpdb; |
| 2657 | 2657 | |
| 2658 | 2658 | // Do not auto load option. |
| 2659 | - $wpdb->update( $wpdb->options, array( 'autoload' => 'no' ), array( 'option_name' => 'give_completed_upgrades' ) ); |
|
| 2659 | + $wpdb->update($wpdb->options, array('autoload' => 'no'), array('option_name' => 'give_completed_upgrades')); |
|
| 2660 | 2660 | |
| 2661 | 2661 | // Remove from cache. |
| 2662 | 2662 | $all_options = wp_load_alloptions(); |
| 2663 | 2663 | |
| 2664 | - if ( isset( $all_options['give_completed_upgrades'] ) ) { |
|
| 2665 | - unset( $all_options['give_completed_upgrades'] ); |
|
| 2666 | - wp_cache_set( 'alloptions', $all_options, 'options' ); |
|
| 2664 | + if (isset($all_options['give_completed_upgrades'])) { |
|
| 2665 | + unset($all_options['give_completed_upgrades']); |
|
| 2666 | + wp_cache_set('alloptions', $all_options, 'options'); |
|
| 2667 | 2667 | } |
| 2668 | 2668 | |
| 2669 | 2669 | } |
@@ -2727,11 +2727,11 @@ discard block |
||
| 2727 | 2727 | " |
| 2728 | 2728 | ); |
| 2729 | 2729 | |
| 2730 | - if ( ! empty( $option_like ) ) { |
|
| 2731 | - $options = array_merge( $options, $option_like ); |
|
| 2730 | + if ( ! empty($option_like)) { |
|
| 2731 | + $options = array_merge($options, $option_like); |
|
| 2732 | 2732 | } |
| 2733 | 2733 | |
| 2734 | - $options_str = '\'' . implode( "','", $options ) . '\''; |
|
| 2734 | + $options_str = '\''.implode("','", $options).'\''; |
|
| 2735 | 2735 | |
| 2736 | 2736 | $wpdb->query( |
| 2737 | 2737 | " |
@@ -2755,7 +2755,7 @@ discard block |
||
| 2755 | 2755 | * |
| 2756 | 2756 | * Change column length |
| 2757 | 2757 | */ |
| 2758 | - $wpdb->query( "ALTER TABLE $wpdb->donors MODIFY email varchar(255) NOT NULL" ); |
|
| 2758 | + $wpdb->query("ALTER TABLE $wpdb->donors MODIFY email varchar(255) NOT NULL"); |
|
| 2759 | 2759 | } |
| 2760 | 2760 | |
| 2761 | 2761 | /** |
@@ -2778,16 +2778,16 @@ discard block |
||
| 2778 | 2778 | ) |
| 2779 | 2779 | ); |
| 2780 | 2780 | |
| 2781 | - if ( $donation_forms->have_posts() ) { |
|
| 2782 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
| 2781 | + if ($donation_forms->have_posts()) { |
|
| 2782 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
| 2783 | 2783 | |
| 2784 | - while ( $donation_forms->have_posts() ) { |
|
| 2784 | + while ($donation_forms->have_posts()) { |
|
| 2785 | 2785 | $donation_forms->the_post(); |
| 2786 | 2786 | $form_id = get_the_ID(); |
| 2787 | 2787 | |
| 2788 | - $form_closed_status = give_get_meta( $form_id, '_give_form_status', true ); |
|
| 2789 | - if ( empty( $form_closed_status ) ) { |
|
| 2790 | - give_set_form_closed_status( $form_id ); |
|
| 2788 | + $form_closed_status = give_get_meta($form_id, '_give_form_status', true); |
|
| 2789 | + if (empty($form_closed_status)) { |
|
| 2790 | + give_set_form_closed_status($form_id); |
|
| 2791 | 2791 | } |
| 2792 | 2792 | } |
| 2793 | 2793 | |
@@ -2797,7 +2797,7 @@ discard block |
||
| 2797 | 2797 | } else { |
| 2798 | 2798 | |
| 2799 | 2799 | // The Update Ran. |
| 2800 | - give_set_upgrade_complete( 'v210_verify_form_status_upgrades' ); |
|
| 2800 | + give_set_upgrade_complete('v210_verify_form_status_upgrades'); |
|
| 2801 | 2801 | } |
| 2802 | 2802 | } |
| 2803 | 2803 | |
@@ -2816,22 +2816,22 @@ discard block |
||
| 2816 | 2816 | SELECT DISTINCT payment_id |
| 2817 | 2817 | FROM {$donation_meta_table} |
| 2818 | 2818 | LIMIT 20 |
| 2819 | - OFFSET {$give_updates->get_offset( 20 )} |
|
| 2819 | + OFFSET {$give_updates->get_offset(20)} |
|
| 2820 | 2820 | " |
| 2821 | 2821 | ); |
| 2822 | 2822 | |
| 2823 | - if ( ! empty( $donations ) ) { |
|
| 2824 | - foreach ( $donations as $donation ) { |
|
| 2825 | - $donation_obj = get_post( $donation ); |
|
| 2823 | + if ( ! empty($donations)) { |
|
| 2824 | + foreach ($donations as $donation) { |
|
| 2825 | + $donation_obj = get_post($donation); |
|
| 2826 | 2826 | |
| 2827 | - if ( ! $donation_obj instanceof WP_Post ) { |
|
| 2828 | - Give()->payment_meta->delete_all_meta( $donation ); |
|
| 2827 | + if ( ! $donation_obj instanceof WP_Post) { |
|
| 2828 | + Give()->payment_meta->delete_all_meta($donation); |
|
| 2829 | 2829 | } |
| 2830 | 2830 | } |
| 2831 | 2831 | } else { |
| 2832 | 2832 | |
| 2833 | 2833 | // The Update Ran. |
| 2834 | - give_set_upgrade_complete( 'v213_delete_donation_meta' ); |
|
| 2834 | + give_set_upgrade_complete('v213_delete_donation_meta'); |
|
| 2835 | 2835 | } |
| 2836 | 2836 | } |
| 2837 | 2837 | |
@@ -2847,16 +2847,16 @@ discard block |
||
| 2847 | 2847 | |
| 2848 | 2848 | // Check upgrade before running. |
| 2849 | 2849 | if ( |
| 2850 | - give_has_upgrade_completed( 'v220_rename_donation_meta_type' ) |
|
| 2851 | - || ! $wpdb->query( $wpdb->prepare( 'SHOW TABLES LIKE %s', "{$wpdb->prefix}give_paymentmeta" ) ) |
|
| 2850 | + give_has_upgrade_completed('v220_rename_donation_meta_type') |
|
| 2851 | + || ! $wpdb->query($wpdb->prepare('SHOW TABLES LIKE %s', "{$wpdb->prefix}give_paymentmeta")) |
|
| 2852 | 2852 | ) { |
| 2853 | 2853 | return; |
| 2854 | 2854 | } |
| 2855 | 2855 | |
| 2856 | - $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_paymentmeta CHANGE COLUMN payment_id donation_id bigint(20)" ); |
|
| 2857 | - $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_paymentmeta RENAME TO {$wpdb->prefix}give_donationmeta" ); |
|
| 2856 | + $wpdb->query("ALTER TABLE {$wpdb->prefix}give_paymentmeta CHANGE COLUMN payment_id donation_id bigint(20)"); |
|
| 2857 | + $wpdb->query("ALTER TABLE {$wpdb->prefix}give_paymentmeta RENAME TO {$wpdb->prefix}give_donationmeta"); |
|
| 2858 | 2858 | |
| 2859 | - give_set_upgrade_complete( 'v220_rename_donation_meta_type' ); |
|
| 2859 | + give_set_upgrade_complete('v220_rename_donation_meta_type'); |
|
| 2860 | 2860 | } |
| 2861 | 2861 | |
| 2862 | 2862 | /** |
@@ -2866,10 +2866,10 @@ discard block |
||
| 2866 | 2866 | */ |
| 2867 | 2867 | function give_v215_update_donor_user_roles_callback() { |
| 2868 | 2868 | |
| 2869 | - $role = get_role( 'give_manager' ); |
|
| 2870 | - $role->add_cap( 'view_give_payments' ); |
|
| 2869 | + $role = get_role('give_manager'); |
|
| 2870 | + $role->add_cap('view_give_payments'); |
|
| 2871 | 2871 | |
| 2872 | - give_set_upgrade_complete( 'v215_update_donor_user_roles' ); |
|
| 2872 | + give_set_upgrade_complete('v215_update_donor_user_roles'); |
|
| 2873 | 2873 | } |
| 2874 | 2874 | |
| 2875 | 2875 | |
@@ -2884,7 +2884,7 @@ discard block |
||
| 2884 | 2884 | function give_v220_delete_wp_session_data() { |
| 2885 | 2885 | global $wpdb; |
| 2886 | 2886 | |
| 2887 | - $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE '_wp_session_%'" ); |
|
| 2887 | + $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_wp_session_%'"); |
|
| 2888 | 2888 | } |
| 2889 | 2889 | |
| 2890 | 2890 | |
@@ -2911,19 +2911,19 @@ discard block |
||
| 2911 | 2911 | ) |
| 2912 | 2912 | ); |
| 2913 | 2913 | |
| 2914 | - if ( $donors ) { |
|
| 2915 | - $give_updates->set_percentage( $donor_count, $give_updates->step * 100 ); |
|
| 2914 | + if ($donors) { |
|
| 2915 | + $give_updates->set_percentage($donor_count, $give_updates->step * 100); |
|
| 2916 | 2916 | // Loop through Donors |
| 2917 | - foreach ( $donors as $donor ) { |
|
| 2918 | - $anonymous_metadata = Give()->donor_meta->get_meta( $donor->id, '_give_anonymous_donor', true ); |
|
| 2917 | + foreach ($donors as $donor) { |
|
| 2918 | + $anonymous_metadata = Give()->donor_meta->get_meta($donor->id, '_give_anonymous_donor', true); |
|
| 2919 | 2919 | |
| 2920 | 2920 | // If first name meta of donor is not created, then create it. |
| 2921 | - if ( ! in_array( $anonymous_metadata, array( '0', '1' ) ) ) { |
|
| 2922 | - Give()->donor_meta->add_meta( $donor->id, '_give_anonymous_donor', '0' ); |
|
| 2921 | + if ( ! in_array($anonymous_metadata, array('0', '1'))) { |
|
| 2922 | + Give()->donor_meta->add_meta($donor->id, '_give_anonymous_donor', '0'); |
|
| 2923 | 2923 | } |
| 2924 | 2924 | } |
| 2925 | 2925 | } else { |
| 2926 | 2926 | // The Update Ran. |
| 2927 | - give_set_upgrade_complete( 'v224_update_donor_meta' ); |
|
| 2927 | + give_set_upgrade_complete('v224_update_donor_meta'); |
|
| 2928 | 2928 | } |
| 2929 | 2929 | } |
@@ -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 | |
@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | * @access public |
| 73 | 73 | */ |
| 74 | 74 | public function __construct() { |
| 75 | - if( is_multisite() ) { |
|
| 76 | - add_action( 'switch_blog', array( $this, 'handle_switch_blog' ), 10, 2 ); |
|
| 75 | + if (is_multisite()) { |
|
| 76 | + add_action('switch_blog', array($this, 'handle_switch_blog'), 10, 2); |
|
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
@@ -111,16 +111,16 @@ discard block |
||
| 111 | 111 | * |
| 112 | 112 | * @return object |
| 113 | 113 | */ |
| 114 | - public function get( $row_id ) { |
|
| 114 | + public function get($row_id) { |
|
| 115 | 115 | /* @var WPDB $wpdb */ |
| 116 | 116 | global $wpdb; |
| 117 | 117 | |
| 118 | 118 | // Bailout. |
| 119 | - if ( empty( $row_id ) ) { |
|
| 119 | + if (empty($row_id)) { |
|
| 120 | 120 | return null; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
| 123 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -134,18 +134,18 @@ discard block |
||
| 134 | 134 | * |
| 135 | 135 | * @return object |
| 136 | 136 | */ |
| 137 | - public function get_by( $column, $row_id ) { |
|
| 137 | + public function get_by($column, $row_id) { |
|
| 138 | 138 | /* @var WPDB $wpdb */ |
| 139 | 139 | global $wpdb; |
| 140 | 140 | |
| 141 | 141 | // Bailout. |
| 142 | - if ( empty( $column ) || empty( $row_id ) ) { |
|
| 142 | + if (empty($column) || empty($row_id)) { |
|
| 143 | 143 | return null; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - $column = esc_sql( $column ); |
|
| 146 | + $column = esc_sql($column); |
|
| 147 | 147 | |
| 148 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
| 148 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id)); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -159,12 +159,12 @@ discard block |
||
| 159 | 159 | * |
| 160 | 160 | * @return array |
| 161 | 161 | */ |
| 162 | - public function get_results_by( $column_args ) { |
|
| 162 | + public function get_results_by($column_args) { |
|
| 163 | 163 | /* @var WPDB $wpdb */ |
| 164 | 164 | global $wpdb; |
| 165 | 165 | |
| 166 | 166 | // Bailout. |
| 167 | - if ( empty( $column_args ) ) { |
|
| 167 | + if (empty($column_args)) { |
|
| 168 | 168 | return null; |
| 169 | 169 | } |
| 170 | 170 | |
@@ -179,12 +179,12 @@ discard block |
||
| 179 | 179 | unset($column_args['relation']); |
| 180 | 180 | |
| 181 | 181 | $where = array(); |
| 182 | - foreach ( $column_args as $column_name => $column_value ) { |
|
| 183 | - $where[] = esc_sql( $column_name ) . "='$column_value'"; |
|
| 182 | + foreach ($column_args as $column_name => $column_value) { |
|
| 183 | + $where[] = esc_sql($column_name)."='$column_value'"; |
|
| 184 | 184 | } |
| 185 | - $where = implode( " {$relation} ", $where ); |
|
| 185 | + $where = implode(" {$relation} ", $where); |
|
| 186 | 186 | |
| 187 | - return $wpdb->get_results( "SELECT * FROM {$this->table_name} WHERE {$where};" ); |
|
| 187 | + return $wpdb->get_results("SELECT * FROM {$this->table_name} WHERE {$where};"); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
@@ -198,18 +198,18 @@ discard block |
||
| 198 | 198 | * |
| 199 | 199 | * @return string Column value. |
| 200 | 200 | */ |
| 201 | - public function get_column( $column, $row_id ) { |
|
| 201 | + public function get_column($column, $row_id) { |
|
| 202 | 202 | /* @var WPDB $wpdb */ |
| 203 | 203 | global $wpdb; |
| 204 | 204 | |
| 205 | 205 | // Bailout. |
| 206 | - if ( empty( $column ) || empty( $row_id ) ) { |
|
| 206 | + if (empty($column) || empty($row_id)) { |
|
| 207 | 207 | return null; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - $column = esc_sql( $column ); |
|
| 210 | + $column = esc_sql($column); |
|
| 211 | 211 | |
| 212 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
| 212 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -224,19 +224,19 @@ discard block |
||
| 224 | 224 | * |
| 225 | 225 | * @return string |
| 226 | 226 | */ |
| 227 | - public function get_column_by( $column, $column_where, $column_value ) { |
|
| 227 | + public function get_column_by($column, $column_where, $column_value) { |
|
| 228 | 228 | /* @var WPDB $wpdb */ |
| 229 | 229 | global $wpdb; |
| 230 | 230 | |
| 231 | 231 | // Bailout. |
| 232 | - if ( empty( $column ) || empty( $column_where ) || empty( $column_value ) ) { |
|
| 232 | + if (empty($column) || empty($column_where) || empty($column_value)) { |
|
| 233 | 233 | return null; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - $column_where = esc_sql( $column_where ); |
|
| 237 | - $column = esc_sql( $column ); |
|
| 236 | + $column_where = esc_sql($column_where); |
|
| 237 | + $column = esc_sql($column); |
|
| 238 | 238 | |
| 239 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
| 239 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value)); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -250,12 +250,12 @@ discard block |
||
| 250 | 250 | * |
| 251 | 251 | * @return int |
| 252 | 252 | */ |
| 253 | - public function insert( $data, $type = '' ) { |
|
| 253 | + public function insert($data, $type = '') { |
|
| 254 | 254 | /* @var WPDB $wpdb */ |
| 255 | 255 | global $wpdb; |
| 256 | 256 | |
| 257 | 257 | // Set default values. |
| 258 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
| 258 | + $data = wp_parse_args($data, $this->get_column_defaults()); |
|
| 259 | 259 | |
| 260 | 260 | /** |
| 261 | 261 | * Fires before inserting data to the database. |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | * |
| 265 | 265 | * @param array $data |
| 266 | 266 | */ |
| 267 | - do_action( "give_pre_insert_{$type}", $data ); |
|
| 267 | + do_action("give_pre_insert_{$type}", $data); |
|
| 268 | 268 | |
| 269 | 269 | // Initialise column format array |
| 270 | 270 | $column_formats = $this->get_columns(); |
@@ -273,13 +273,13 @@ discard block |
||
| 273 | 273 | // $data = array_change_key_case( $data ); |
| 274 | 274 | |
| 275 | 275 | // White list columns |
| 276 | - $data = array_intersect_key( $data, $column_formats ); |
|
| 276 | + $data = array_intersect_key($data, $column_formats); |
|
| 277 | 277 | |
| 278 | 278 | // Reorder $column_formats to match the order of columns given in $data |
| 279 | - $data_keys = array_keys( $data ); |
|
| 280 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
| 279 | + $data_keys = array_keys($data); |
|
| 280 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
| 281 | 281 | |
| 282 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
| 282 | + $wpdb->insert($this->table_name, $data, $column_formats); |
|
| 283 | 283 | |
| 284 | 284 | /** |
| 285 | 285 | * Fires after inserting data to the database. |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | * @param int $insert_id |
| 290 | 290 | * @param array $data |
| 291 | 291 | */ |
| 292 | - do_action( "give_post_insert_{$type}", $wpdb->insert_id, $data ); |
|
| 292 | + do_action("give_post_insert_{$type}", $wpdb->insert_id, $data); |
|
| 293 | 293 | |
| 294 | 294 | return $wpdb->insert_id; |
| 295 | 295 | } |
@@ -306,18 +306,18 @@ discard block |
||
| 306 | 306 | * |
| 307 | 307 | * @return bool |
| 308 | 308 | */ |
| 309 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
| 309 | + public function update($row_id, $data = array(), $where = '') { |
|
| 310 | 310 | /* @var WPDB $wpdb */ |
| 311 | 311 | global $wpdb; |
| 312 | 312 | |
| 313 | 313 | // Row ID must be positive integer |
| 314 | - $row_id = absint( $row_id ); |
|
| 314 | + $row_id = absint($row_id); |
|
| 315 | 315 | |
| 316 | - if ( empty( $row_id ) ) { |
|
| 316 | + if (empty($row_id)) { |
|
| 317 | 317 | return false; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | - if ( empty( $where ) ) { |
|
| 320 | + if (empty($where)) { |
|
| 321 | 321 | $where = $this->primary_key; |
| 322 | 322 | } |
| 323 | 323 | |
@@ -325,16 +325,16 @@ discard block |
||
| 325 | 325 | $column_formats = $this->get_columns(); |
| 326 | 326 | |
| 327 | 327 | // Force fields to lower case |
| 328 | - $data = array_change_key_case( $data ); |
|
| 328 | + $data = array_change_key_case($data); |
|
| 329 | 329 | |
| 330 | 330 | // White list columns |
| 331 | - $data = array_intersect_key( $data, $column_formats ); |
|
| 331 | + $data = array_intersect_key($data, $column_formats); |
|
| 332 | 332 | |
| 333 | 333 | // Reorder $column_formats to match the order of columns given in $data |
| 334 | - $data_keys = array_keys( $data ); |
|
| 335 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
| 334 | + $data_keys = array_keys($data); |
|
| 335 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
| 336 | 336 | |
| 337 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
| 337 | + if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) { |
|
| 338 | 338 | return false; |
| 339 | 339 | } |
| 340 | 340 | |
@@ -351,18 +351,18 @@ discard block |
||
| 351 | 351 | * |
| 352 | 352 | * @return bool |
| 353 | 353 | */ |
| 354 | - public function delete( $row_id = 0 ) { |
|
| 354 | + public function delete($row_id = 0) { |
|
| 355 | 355 | /* @var WPDB $wpdb */ |
| 356 | 356 | global $wpdb; |
| 357 | 357 | |
| 358 | 358 | // Row ID must be positive integer |
| 359 | - $row_id = absint( $row_id ); |
|
| 359 | + $row_id = absint($row_id); |
|
| 360 | 360 | |
| 361 | - if ( empty( $row_id ) ) { |
|
| 361 | + if (empty($row_id)) { |
|
| 362 | 362 | return false; |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
| 365 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) { |
|
| 366 | 366 | return false; |
| 367 | 367 | } |
| 368 | 368 | |
@@ -379,13 +379,13 @@ discard block |
||
| 379 | 379 | * |
| 380 | 380 | * @return bool If the table name exists. |
| 381 | 381 | */ |
| 382 | - public function table_exists( $table ) { |
|
| 382 | + public function table_exists($table) { |
|
| 383 | 383 | /* @var WPDB $wpdb */ |
| 384 | 384 | global $wpdb; |
| 385 | 385 | |
| 386 | - $table = sanitize_text_field( $table ); |
|
| 386 | + $table = sanitize_text_field($table); |
|
| 387 | 387 | |
| 388 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
| 388 | + return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table; |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | /** |
@@ -399,16 +399,16 @@ discard block |
||
| 399 | 399 | * |
| 400 | 400 | * @return bool |
| 401 | 401 | */ |
| 402 | - public function does_column_exist( $column_name ) { |
|
| 402 | + public function does_column_exist($column_name) { |
|
| 403 | 403 | |
| 404 | 404 | global $wpdb; |
| 405 | 405 | |
| 406 | - $column = $wpdb->get_results( $wpdb->prepare( |
|
| 406 | + $column = $wpdb->get_results($wpdb->prepare( |
|
| 407 | 407 | "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = %s AND TABLE_NAME = %s AND COLUMN_NAME = %s ", |
| 408 | 408 | DB_NAME, $this->table_name, $column_name |
| 409 | - ) ); |
|
| 409 | + )); |
|
| 410 | 410 | |
| 411 | - if ( ! empty( $column ) ) { |
|
| 411 | + if ( ! empty($column)) { |
|
| 412 | 412 | return true; |
| 413 | 413 | } |
| 414 | 414 | |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | * @return bool Returns if the customers table was installed and upgrade routine run. |
| 425 | 425 | */ |
| 426 | 426 | public function installed() { |
| 427 | - return $this->table_exists( $this->table_name ); |
|
| 427 | + return $this->table_exists($this->table_name); |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | /** |
@@ -434,8 +434,8 @@ discard block |
||
| 434 | 434 | * @access public |
| 435 | 435 | */ |
| 436 | 436 | public function register_table() { |
| 437 | - $current_version = get_option( $this->table_name . '_db_version' ); |
|
| 438 | - if ( ! $current_version || version_compare( $current_version, $this->version, '<' ) ) { |
|
| 437 | + $current_version = get_option($this->table_name.'_db_version'); |
|
| 438 | + if ( ! $current_version || version_compare($current_version, $this->version, '<')) { |
|
| 439 | 439 | $this->create_table(); |
| 440 | 440 | } |
| 441 | 441 | } |
@@ -460,23 +460,23 @@ discard block |
||
| 460 | 460 | * |
| 461 | 461 | * @return int|bool The normalized log ID or false if it's found to not be valid. |
| 462 | 462 | */ |
| 463 | - public function sanitize_id( $id ) { |
|
| 464 | - if ( ! is_numeric( $id ) ) { |
|
| 463 | + public function sanitize_id($id) { |
|
| 464 | + if ( ! is_numeric($id)) { |
|
| 465 | 465 | return false; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | $id = (int) $id; |
| 469 | 469 | |
| 470 | 470 | // We were given a non positive number. |
| 471 | - if ( absint( $id ) !== $id ) { |
|
| 471 | + if (absint($id) !== $id) { |
|
| 472 | 472 | return false; |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | - if ( empty( $id ) ) { |
|
| 475 | + if (empty($id)) { |
|
| 476 | 476 | return false; |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | - return absint( $id ); |
|
| 479 | + return absint($id); |
|
| 480 | 480 | |
| 481 | 481 | } |
| 482 | 482 | |
@@ -490,23 +490,23 @@ discard block |
||
| 490 | 490 | * @param $new_blog_id |
| 491 | 491 | * @param $prev_blog_id |
| 492 | 492 | */ |
| 493 | - public function handle_switch_blog( $new_blog_id, $prev_blog_id ) { |
|
| 493 | + public function handle_switch_blog($new_blog_id, $prev_blog_id) { |
|
| 494 | 494 | global $wpdb; |
| 495 | 495 | |
| 496 | 496 | // Bailout. |
| 497 | - if ( $new_blog_id === $prev_blog_id ) { |
|
| 497 | + if ($new_blog_id === $prev_blog_id) { |
|
| 498 | 498 | return; |
| 499 | 499 | } |
| 500 | 500 | |
| 501 | 501 | |
| 502 | 502 | $this->table_name = str_replace( |
| 503 | - 1 != $prev_blog_id ? $wpdb->get_blog_prefix( $prev_blog_id ) : $wpdb->base_prefix, |
|
| 504 | - 1 != $new_blog_id ? $wpdb->get_blog_prefix( $new_blog_id ) : $wpdb->base_prefix, |
|
| 503 | + 1 != $prev_blog_id ? $wpdb->get_blog_prefix($prev_blog_id) : $wpdb->base_prefix, |
|
| 504 | + 1 != $new_blog_id ? $wpdb->get_blog_prefix($new_blog_id) : $wpdb->base_prefix, |
|
| 505 | 505 | $this->table_name |
| 506 | 506 | ); |
| 507 | 507 | |
| 508 | - if ( $this instanceof Give_DB_Meta ) { |
|
| 509 | - $wpdb->{$this->get_meta_type() . 'meta'} = $this->table_name; |
|
| 508 | + if ($this instanceof Give_DB_Meta) { |
|
| 509 | + $wpdb->{$this->get_meta_type().'meta'} = $this->table_name; |
|
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @param $args array The array of arguments that can be passed in and used for setting up this payment query. |
| 88 | 88 | */ |
| 89 | - public function __construct( $args = array() ) { |
|
| 89 | + public function __construct($args = array()) { |
|
| 90 | 90 | $defaults = array( |
| 91 | 91 | 'number' => 20, |
| 92 | 92 | 'offset' => 0, |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | // 'form' => array(), |
| 117 | 117 | ); |
| 118 | 118 | |
| 119 | - $this->args = wp_parse_args( $args, $defaults ); |
|
| 119 | + $this->args = wp_parse_args($args, $defaults); |
|
| 120 | 120 | $this->table_name = Give()->donors->table_name; |
| 121 | 121 | $this->meta_table_name = Give()->donor_meta->table_name; |
| 122 | 122 | $this->meta_type = Give()->donor_meta->meta_type; |
@@ -158,21 +158,21 @@ discard block |
||
| 158 | 158 | * |
| 159 | 159 | * @param Give_Donors_Query $this Donors query object. |
| 160 | 160 | */ |
| 161 | - do_action( 'give_pre_get_donors', $this ); |
|
| 161 | + do_action('give_pre_get_donors', $this); |
|
| 162 | 162 | |
| 163 | - $cache_key = Give_Cache::get_key( 'give_donor', $this->get_sql(), false ); |
|
| 163 | + $cache_key = Give_Cache::get_key('give_donor', $this->get_sql(), false); |
|
| 164 | 164 | |
| 165 | 165 | // Get donors from cache. |
| 166 | - $this->donors = Give_Cache::get_db_query( $cache_key ); |
|
| 166 | + $this->donors = Give_Cache::get_db_query($cache_key); |
|
| 167 | 167 | |
| 168 | - if ( is_null( $this->donors ) ) { |
|
| 169 | - if ( empty( $this->args['count'] ) ) { |
|
| 170 | - $this->donors = $wpdb->get_results( $this->get_sql() ); |
|
| 168 | + if (is_null($this->donors)) { |
|
| 169 | + if (empty($this->args['count'])) { |
|
| 170 | + $this->donors = $wpdb->get_results($this->get_sql()); |
|
| 171 | 171 | } else { |
| 172 | - $this->donors = $wpdb->get_var( $this->get_sql() ); |
|
| 172 | + $this->donors = $wpdb->get_var($this->get_sql()); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - Give_Cache::set_db_query( $cache_key, $this->donors ); |
|
| 175 | + Give_Cache::set_db_query($cache_key, $this->donors); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * |
| 184 | 184 | * @param Give_Donors_Query $this Donors query object. |
| 185 | 185 | */ |
| 186 | - do_action( 'give_post_get_donors', $this ); |
|
| 186 | + do_action('give_post_get_donors', $this); |
|
| 187 | 187 | |
| 188 | 188 | return $this->donors; |
| 189 | 189 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | public function get_sql() { |
| 201 | 201 | global $wpdb; |
| 202 | 202 | |
| 203 | - if ( $this->args['number'] < 1 ) { |
|
| 203 | + if ($this->args['number'] < 1) { |
|
| 204 | 204 | $this->args['number'] = 99999999999; |
| 205 | 205 | } |
| 206 | 206 | |
@@ -208,32 +208,32 @@ discard block |
||
| 208 | 208 | |
| 209 | 209 | |
| 210 | 210 | // Set offset. |
| 211 | - if ( empty( $this->args['offset'] ) && ( 0 < $this->args['paged'] ) ) { |
|
| 212 | - $this->args['offset'] = $this->args['number'] * ( $this->args['paged'] - 1 ); |
|
| 211 | + if (empty($this->args['offset']) && (0 < $this->args['paged'])) { |
|
| 212 | + $this->args['offset'] = $this->args['number'] * ($this->args['paged'] - 1); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | // Set fields. |
| 216 | 216 | $fields = "{$this->table_name}.*"; |
| 217 | - if ( ! empty( $this->args['fields'] ) && 'all' !== $this->args['fields'] ) { |
|
| 218 | - if ( is_string( $this->args['fields'] ) ) { |
|
| 217 | + if ( ! empty($this->args['fields']) && 'all' !== $this->args['fields']) { |
|
| 218 | + if (is_string($this->args['fields'])) { |
|
| 219 | 219 | $fields = "{$this->table_name}.{$this->args['fields']}"; |
| 220 | - } elseif ( is_array( $this->args['fields'] ) ) { |
|
| 221 | - $fields = "{$this->table_name}." . implode( " , {$this->table_name}.", $this->args['fields'] ); |
|
| 220 | + } elseif (is_array($this->args['fields'])) { |
|
| 221 | + $fields = "{$this->table_name}.".implode(" , {$this->table_name}.", $this->args['fields']); |
|
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | // Set count. |
| 226 | - if ( ! empty( $this->args['count'] ) ) { |
|
| 226 | + if ( ! empty($this->args['count'])) { |
|
| 227 | 227 | $fields = "COUNT({$this->table_name}.id)"; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | $orderby = $this->get_order_query(); |
| 231 | 231 | |
| 232 | - $sql = $wpdb->prepare( "SELECT {$fields} FROM {$this->table_name} LIMIT %d,%d;", absint( $this->args['offset'] ), absint( $this->args['number'] ) ); |
|
| 232 | + $sql = $wpdb->prepare("SELECT {$fields} FROM {$this->table_name} LIMIT %d,%d;", absint($this->args['offset']), absint($this->args['number'])); |
|
| 233 | 233 | |
| 234 | 234 | // $where, $orderby and order already prepared query they can generate notice if you re prepare them in above. |
| 235 | 235 | // WordPress consider LIKE condition as placeholder if start with s,f, or d. |
| 236 | - $sql = str_replace( 'LIMIT', "{$where} {$orderby} LIMIT", $sql ); |
|
| 236 | + $sql = str_replace('LIMIT', "{$where} {$orderby} LIMIT", $sql); |
|
| 237 | 237 | |
| 238 | 238 | return $sql; |
| 239 | 239 | } |
@@ -250,11 +250,11 @@ discard block |
||
| 250 | 250 | private function get_where_query() { |
| 251 | 251 | |
| 252 | 252 | // Get sql query for meta. |
| 253 | - if ( ! empty( $this->args['meta_query'] ) ) { |
|
| 254 | - $meta_query_object = new WP_Meta_Query( $this->args['meta_query'] ); |
|
| 255 | - $meta_query = $meta_query_object->get_sql( $this->meta_type, $this->table_name, 'id' ); |
|
| 253 | + if ( ! empty($this->args['meta_query'])) { |
|
| 254 | + $meta_query_object = new WP_Meta_Query($this->args['meta_query']); |
|
| 255 | + $meta_query = $meta_query_object->get_sql($this->meta_type, $this->table_name, 'id'); |
|
| 256 | 256 | |
| 257 | - $where[] = implode( '', $meta_query ); |
|
| 257 | + $where[] = implode('', $meta_query); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | $where[] = 'WHERE 1=1'; |
@@ -267,9 +267,9 @@ discard block |
||
| 267 | 267 | $where[] = $this->get_where_donation_count(); |
| 268 | 268 | $where[] = $this->get_where_give_forms(); |
| 269 | 269 | |
| 270 | - $where = array_filter( $where ); |
|
| 270 | + $where = array_filter($where); |
|
| 271 | 271 | |
| 272 | - return trim( implode( ' ', array_map( 'trim', $where ) ) ); |
|
| 272 | + return trim(implode(' ', array_map('trim', $where))); |
|
| 273 | 273 | |
| 274 | 274 | } |
| 275 | 275 | |
@@ -287,17 +287,17 @@ discard block |
||
| 287 | 287 | |
| 288 | 288 | $where = ''; |
| 289 | 289 | |
| 290 | - if ( ! empty( $this->args['email'] ) ) { |
|
| 290 | + if ( ! empty($this->args['email'])) { |
|
| 291 | 291 | |
| 292 | - if ( is_array( $this->args['email'] ) ) { |
|
| 292 | + if (is_array($this->args['email'])) { |
|
| 293 | 293 | |
| 294 | - $emails_count = count( $this->args['email'] ); |
|
| 295 | - $emails_placeholder = array_fill( 0, $emails_count, '%s' ); |
|
| 296 | - $emails = implode( ', ', $emails_placeholder ); |
|
| 294 | + $emails_count = count($this->args['email']); |
|
| 295 | + $emails_placeholder = array_fill(0, $emails_count, '%s'); |
|
| 296 | + $emails = implode(', ', $emails_placeholder); |
|
| 297 | 297 | |
| 298 | - $where .= $wpdb->prepare( "AND {$this->table_name}.email IN( $emails )", $this->args['email'] ); |
|
| 298 | + $where .= $wpdb->prepare("AND {$this->table_name}.email IN( $emails )", $this->args['email']); |
|
| 299 | 299 | } else { |
| 300 | - $where .= $wpdb->prepare( "AND {$this->table_name}.email = %s", $this->args['email'] ); |
|
| 300 | + $where .= $wpdb->prepare("AND {$this->table_name}.email = %s", $this->args['email']); |
|
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | 303 | |
@@ -317,11 +317,11 @@ discard block |
||
| 317 | 317 | $where = ''; |
| 318 | 318 | |
| 319 | 319 | // Specific donors. |
| 320 | - if ( ! empty( $this->args['donor'] ) ) { |
|
| 321 | - if ( ! is_array( $this->args['donor'] ) ) { |
|
| 322 | - $this->args['donor'] = explode( ',', $this->args['donor'] ); |
|
| 320 | + if ( ! empty($this->args['donor'])) { |
|
| 321 | + if ( ! is_array($this->args['donor'])) { |
|
| 322 | + $this->args['donor'] = explode(',', $this->args['donor']); |
|
| 323 | 323 | } |
| 324 | - $donor_ids = implode( ',', array_map( 'intval', $this->args['donor'] ) ); |
|
| 324 | + $donor_ids = implode(',', array_map('intval', $this->args['donor'])); |
|
| 325 | 325 | |
| 326 | 326 | $where .= "AND {$this->table_name}.id IN( {$donor_ids} )"; |
| 327 | 327 | } |
@@ -342,10 +342,10 @@ discard block |
||
| 342 | 342 | $where = ''; |
| 343 | 343 | |
| 344 | 344 | // Donors created for a specific date or in a date range |
| 345 | - if ( ! empty( $this->args['date_query'] ) ) { |
|
| 346 | - $date_query_object = new WP_Date_Query( is_array( $this->args['date_query'] ) ? $this->args['date_query'] : wp_parse_args( $this->args['date_query'] ), "{$this->table_name}.date_created" ); |
|
| 345 | + if ( ! empty($this->args['date_query'])) { |
|
| 346 | + $date_query_object = new WP_Date_Query(is_array($this->args['date_query']) ? $this->args['date_query'] : wp_parse_args($this->args['date_query']), "{$this->table_name}.date_created"); |
|
| 347 | 347 | |
| 348 | - $where .= str_replace( array( |
|
| 348 | + $where .= str_replace(array( |
|
| 349 | 349 | "\n", |
| 350 | 350 | '( (', |
| 351 | 351 | '))', |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | '', |
| 354 | 354 | '( (', |
| 355 | 355 | ') )', |
| 356 | - ), $date_query_object->get_sql() ); |
|
| 356 | + ), $date_query_object->get_sql()); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | return $where; |
@@ -372,11 +372,11 @@ discard block |
||
| 372 | 372 | $where = ''; |
| 373 | 373 | |
| 374 | 374 | // Donors created for a specific date or in a date range |
| 375 | - if ( ! empty( $this->args['s'] ) && false !== strpos( $this->args['s'], ':' ) ) { |
|
| 376 | - $search_parts = explode( ':', $this->args['s'] ); |
|
| 375 | + if ( ! empty($this->args['s']) && false !== strpos($this->args['s'], ':')) { |
|
| 376 | + $search_parts = explode(':', $this->args['s']); |
|
| 377 | 377 | |
| 378 | - if ( ! empty( $search_parts[0] ) ) { |
|
| 379 | - switch ( $search_parts[0] ) { |
|
| 378 | + if ( ! empty($search_parts[0])) { |
|
| 379 | + switch ($search_parts[0]) { |
|
| 380 | 380 | case 'name': |
| 381 | 381 | $where = "AND {$this->table_name}.name LIKE '%{$search_parts[1]}%'"; |
| 382 | 382 | break; |
@@ -404,11 +404,11 @@ discard block |
||
| 404 | 404 | $where = ''; |
| 405 | 405 | |
| 406 | 406 | // Donors create for specific wp user. |
| 407 | - if ( ! empty( $this->args['user'] ) ) { |
|
| 408 | - if ( ! is_array( $this->args['user'] ) ) { |
|
| 409 | - $this->args['user'] = explode( ',', $this->args['user'] ); |
|
| 407 | + if ( ! empty($this->args['user'])) { |
|
| 408 | + if ( ! is_array($this->args['user'])) { |
|
| 409 | + $this->args['user'] = explode(',', $this->args['user']); |
|
| 410 | 410 | } |
| 411 | - $user_ids = implode( ',', array_map( 'intval', $this->args['user'] ) ); |
|
| 411 | + $user_ids = implode(',', array_map('intval', $this->args['user'])); |
|
| 412 | 412 | |
| 413 | 413 | $where .= "AND {$this->table_name}.user_id IN( {$user_ids} )"; |
| 414 | 414 | } |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | $query = array(); |
| 431 | 431 | $ordersby = $this->args['orderby']; |
| 432 | 432 | |
| 433 | - if( ! is_array( $ordersby ) ) { |
|
| 433 | + if ( ! is_array($ordersby)) { |
|
| 434 | 434 | $ordersby = array( |
| 435 | 435 | $this->args['orderby'] => $this->args['order'] |
| 436 | 436 | ); |
@@ -438,23 +438,23 @@ discard block |
||
| 438 | 438 | |
| 439 | 439 | // Remove non existing column. |
| 440 | 440 | // Filter orderby values. |
| 441 | - foreach ( $ordersby as $orderby => $order ) { |
|
| 442 | - if( ! array_key_exists( $orderby, $table_columns ) ) { |
|
| 443 | - unset( $ordersby[$orderby] ); |
|
| 441 | + foreach ($ordersby as $orderby => $order) { |
|
| 442 | + if ( ! array_key_exists($orderby, $table_columns)) { |
|
| 443 | + unset($ordersby[$orderby]); |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | - $ordersby[ esc_sql( $orderby ) ] = esc_sql( $order ); |
|
| 446 | + $ordersby[esc_sql($orderby)] = esc_sql($order); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | - if( empty( $ordersby ) ) { |
|
| 449 | + if (empty($ordersby)) { |
|
| 450 | 450 | $ordersby = array( |
| 451 | 451 | 'id' => $this->args['order'] |
| 452 | 452 | ); |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | // Create query. |
| 456 | - foreach ( $ordersby as $orderby => $order ) { |
|
| 457 | - switch ( $table_columns[ $orderby ] ) { |
|
| 456 | + foreach ($ordersby as $orderby => $order) { |
|
| 457 | + switch ($table_columns[$orderby]) { |
|
| 458 | 458 | case '%d': |
| 459 | 459 | case '%f': |
| 460 | 460 | $query[] = "{$this->table_name}.{$orderby}+0 {$order}"; |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - return ! empty( $query ) ? 'ORDER BY ' . implode( ', ', $query ) : ''; |
|
| 468 | + return ! empty($query) ? 'ORDER BY '.implode(', ', $query) : ''; |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | /** |
@@ -481,10 +481,10 @@ discard block |
||
| 481 | 481 | private function get_where_donation_count() { |
| 482 | 482 | $where = ''; |
| 483 | 483 | |
| 484 | - if ( ! empty( $this->args['donation_count'] ) ) { |
|
| 484 | + if ( ! empty($this->args['donation_count'])) { |
|
| 485 | 485 | $compare = '>'; |
| 486 | 486 | $amount = $this->args['donation_count']; |
| 487 | - if ( is_array( $this->args['donation_count'] ) ) { |
|
| 487 | + if (is_array($this->args['donation_count'])) { |
|
| 488 | 488 | $compare = $this->args['donation_count'] ['compare']; |
| 489 | 489 | $amount = $this->args['donation_count']['amount']; |
| 490 | 490 | } |
@@ -508,10 +508,10 @@ discard block |
||
| 508 | 508 | private function get_where_donation_amount() { |
| 509 | 509 | $where = ''; |
| 510 | 510 | |
| 511 | - if ( ! empty( $this->args['donation_amount'] ) ) { |
|
| 511 | + if ( ! empty($this->args['donation_amount'])) { |
|
| 512 | 512 | $compare = '>'; |
| 513 | 513 | $amount = $this->args['donation_amount']; |
| 514 | - if ( is_array( $this->args['donation_amount'] ) ) { |
|
| 514 | + if (is_array($this->args['donation_amount'])) { |
|
| 515 | 515 | $compare = $this->args['donation_amount'] ['compare']; |
| 516 | 516 | $amount = $this->args['donation_amount']['amount']; |
| 517 | 517 | } |
@@ -537,13 +537,13 @@ discard block |
||
| 537 | 537 | global $wpdb; |
| 538 | 538 | $where = ''; |
| 539 | 539 | |
| 540 | - if ( ! empty( $this->args['give_forms'] ) ) { |
|
| 541 | - if ( ! is_array( $this->args['give_forms'] ) ) { |
|
| 542 | - $this->args['give_forms'] = explode( ',', $this->args['give_forms'] ); |
|
| 540 | + if ( ! empty($this->args['give_forms'])) { |
|
| 541 | + if ( ! is_array($this->args['give_forms'])) { |
|
| 542 | + $this->args['give_forms'] = explode(',', $this->args['give_forms']); |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | - $form_ids = implode( ',', array_map( 'intval', $this->args['give_forms'] ) ); |
|
| 546 | - $donation_id_col = Give()->payment_meta->get_meta_type() . '_id'; |
|
| 545 | + $form_ids = implode(',', array_map('intval', $this->args['give_forms'])); |
|
| 546 | + $donation_id_col = Give()->payment_meta->get_meta_type().'_id'; |
|
| 547 | 547 | |
| 548 | 548 | $query = $wpdb->prepare( |
| 549 | 549 | " |
@@ -562,12 +562,12 @@ discard block |
||
| 562 | 562 | $form_ids |
| 563 | 563 | ); |
| 564 | 564 | |
| 565 | - $donor_ids = $wpdb->get_results( $query, ARRAY_A ); |
|
| 565 | + $donor_ids = $wpdb->get_results($query, ARRAY_A); |
|
| 566 | 566 | |
| 567 | - if ( ! empty( $donor_ids ) ) { |
|
| 568 | - $donor_ids = wp_list_pluck( $donor_ids, 'donor_id' ); |
|
| 569 | - $donor_ids = implode( ',', array_map( 'intval', $donor_ids ) ); |
|
| 570 | - $where .= "AND {$this->table_name}.id IN ({$donor_ids})"; |
|
| 567 | + if ( ! empty($donor_ids)) { |
|
| 568 | + $donor_ids = wp_list_pluck($donor_ids, 'donor_id'); |
|
| 569 | + $donor_ids = implode(',', array_map('intval', $donor_ids)); |
|
| 570 | + $where .= "AND {$this->table_name}.id IN ({$donor_ids})"; |
|
| 571 | 571 | } else { |
| 572 | 572 | $where .= "AND {$this->table_name}.id IN ('0')"; |
| 573 | 573 | } |