@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | * @return void |
23 | 23 | */ |
24 | 24 | function give_process_actions() { |
25 | - if ( isset( $_POST['give-action'] ) ) { |
|
26 | - do_action( 'give_' . $_POST['give-action'], $_POST ); |
|
25 | + if (isset($_POST['give-action'])) { |
|
26 | + do_action('give_'.$_POST['give-action'], $_POST); |
|
27 | 27 | } |
28 | 28 | |
29 | - if ( isset( $_GET['give-action'] ) ) { |
|
30 | - do_action( 'give_' . $_GET['give-action'], $_GET ); |
|
29 | + if (isset($_GET['give-action'])) { |
|
30 | + do_action('give_'.$_GET['give-action'], $_GET); |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 | |
34 | -add_action( 'admin_init', 'give_process_actions' ); |
|
35 | 34 | \ No newline at end of file |
35 | +add_action('admin_init', 'give_process_actions'); |
|
36 | 36 | \ No newline at end of file |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -78,15 +78,15 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @since 1.0 |
80 | 80 | */ |
81 | - public function __construct( $_data ) { |
|
81 | + public function __construct($_data) { |
|
82 | 82 | |
83 | 83 | $this->data = $_data; |
84 | 84 | |
85 | 85 | // Generate unique ID |
86 | - $this->id = md5( rand() ); |
|
86 | + $this->id = md5(rand()); |
|
87 | 87 | |
88 | 88 | // Setup default options; |
89 | - $this->options = apply_filters( 'give_graph_args', array( |
|
89 | + $this->options = apply_filters('give_graph_args', array( |
|
90 | 90 | 'y_mode' => null, |
91 | 91 | 'x_mode' => null, |
92 | 92 | 'y_decimals' => 0, |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | 'bars' => true, |
104 | 104 | 'lines' => false, |
105 | 105 | 'points' => true |
106 | - ) ); |
|
106 | + )); |
|
107 | 107 | |
108 | 108 | } |
109 | 109 | |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @since 1.0 |
117 | 117 | */ |
118 | - public function set( $key, $value ) { |
|
119 | - $this->options[ $key ] = $value; |
|
118 | + public function set($key, $value) { |
|
119 | + $this->options[$key] = $value; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @since 1.0 |
128 | 128 | */ |
129 | - public function get( $key ) { |
|
130 | - return isset( $this->options[ $key ] ) ? $this->options[ $key ] : false; |
|
129 | + public function get($key) { |
|
130 | + return isset($this->options[$key]) ? $this->options[$key] : false; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @since 1.0 |
137 | 137 | */ |
138 | 138 | public function get_data() { |
139 | - return apply_filters( 'give_get_graph_data', $this->data, $this ); |
|
139 | + return apply_filters('give_get_graph_data', $this->data, $this); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -146,19 +146,19 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function load_scripts() { |
148 | 148 | // Use minified libraries if SCRIPT_DEBUG is turned off |
149 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
149 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
150 | 150 | |
151 | - wp_register_script( 'jquery-flot-orderbars', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.orderBars' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION ); |
|
152 | - wp_enqueue_script( 'jquery-flot-orderbars' ); |
|
151 | + wp_register_script('jquery-flot-orderbars', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.orderBars'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION); |
|
152 | + wp_enqueue_script('jquery-flot-orderbars'); |
|
153 | 153 | |
154 | - wp_register_script( 'jquery-flot-time', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.time' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION ); |
|
155 | - wp_enqueue_script( 'jquery-flot-time' ); |
|
154 | + wp_register_script('jquery-flot-time', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.time'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION); |
|
155 | + wp_enqueue_script('jquery-flot-time'); |
|
156 | 156 | |
157 | - wp_register_script( 'jquery-flot-resize', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.resize' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION ); |
|
158 | - wp_enqueue_script( 'jquery-flot-resize' ); |
|
157 | + wp_register_script('jquery-flot-resize', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.resize'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION); |
|
158 | + wp_enqueue_script('jquery-flot-resize'); |
|
159 | 159 | |
160 | - wp_register_script( 'jquery-flot', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot' . $suffix . '.js', false, GIVE_VERSION ); |
|
161 | - wp_enqueue_script( 'jquery-flot' ); |
|
160 | + wp_register_script('jquery-flot', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot'.$suffix.'.js', false, GIVE_VERSION); |
|
161 | + wp_enqueue_script('jquery-flot'); |
|
162 | 162 | |
163 | 163 | } |
164 | 164 | |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | [ |
186 | 186 | <?php |
187 | 187 | $order = 0; |
188 | - foreach( $this->get_data() as $label => $data ) : |
|
188 | + foreach ($this->get_data() as $label => $data) : |
|
189 | 189 | ?> |
190 | 190 | { |
191 | - label : "<?php echo esc_attr( $label ); ?>", |
|
192 | - id : "<?php echo sanitize_key( $label ); ?>", |
|
191 | + label : "<?php echo esc_attr($label); ?>", |
|
192 | + id : "<?php echo sanitize_key($label); ?>", |
|
193 | 193 | // data format is: [ point on x, value on y ] |
194 | - data : [<?php foreach( $data as $point ) { echo '[' . implode( ',', $point ) . '],'; } ?>], |
|
194 | + data : [<?php foreach ($data as $point) { echo '['.implode(',', $point).'],'; } ?>], |
|
195 | 195 | points: { |
196 | 196 | show: <?php echo $this->options['points'] ? 'true' : 'false'; ?>, |
197 | 197 | }, |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | fill : true, |
207 | 207 | fillColor: {colors: [{opacity: 0.4}, {opacity: 0.1}]} |
208 | 208 | }, |
209 | - <?php if( $this->options[ 'multiple_y_axes' ] ) : ?> |
|
209 | + <?php if ($this->options['multiple_y_axes']) : ?> |
|
210 | 210 | yaxis : <?php echo $yaxis_count; ?> |
211 | 211 | <?php endif; ?> |
212 | 212 | |
@@ -220,10 +220,10 @@ discard block |
||
220 | 220 | grid: { |
221 | 221 | show : true, |
222 | 222 | aboveData : false, |
223 | - color : "<?php echo $this->options[ 'color' ]; ?>", |
|
224 | - backgroundColor: "<?php echo $this->options[ 'bgcolor' ]; ?>", |
|
225 | - borderColor : "<?php echo $this->options[ 'bordercolor' ]; ?>", |
|
226 | - borderWidth : <?php echo absint( $this->options[ 'borderwidth' ] ); ?>, |
|
223 | + color : "<?php echo $this->options['color']; ?>", |
|
224 | + backgroundColor: "<?php echo $this->options['bgcolor']; ?>", |
|
225 | + borderColor : "<?php echo $this->options['bordercolor']; ?>", |
|
226 | + borderWidth : <?php echo absint($this->options['borderwidth']); ?>, |
|
227 | 227 | clickable : false, |
228 | 228 | hoverable : true |
229 | 229 | }, |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | mode : "<?php echo $this->options['x_mode']; ?>", |
235 | 235 | timeFormat : "<?php echo $this->options['x_mode'] == 'time' ? $this->options['time_format'] : ''; ?>", |
236 | 236 | tickSize : "<?php echo $this->options['x_mode'] == 'time' ? '' : 1; ?>", |
237 | - <?php if( $this->options['x_mode'] != 'time' ) : ?> |
|
237 | + <?php if ($this->options['x_mode'] != 'time') : ?> |
|
238 | 238 | tickDecimals: <?php echo $this->options['x_decimals']; ?> |
239 | 239 | <?php endif; ?> |
240 | 240 | }, |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | min : 0, |
244 | 244 | mode : "<?php echo $this->options['y_mode']; ?>", |
245 | 245 | timeFormat : "<?php echo $this->options['y_mode'] == 'time' ? $this->options['time_format'] : ''; ?>", |
246 | - <?php if( $this->options['y_mode'] != 'time' ) : ?> |
|
246 | + <?php if ($this->options['y_mode'] != 'time') : ?> |
|
247 | 247 | tickDecimals: <?php echo $this->options['y_decimals']; ?> |
248 | 248 | <?php endif; ?> |
249 | 249 | } |
@@ -303,9 +303,9 @@ discard block |
||
303 | 303 | * @since 1.0 |
304 | 304 | */ |
305 | 305 | public function display() { |
306 | - do_action( 'give_before_graph', $this ); |
|
306 | + do_action('give_before_graph', $this); |
|
307 | 307 | echo $this->build_graph(); |
308 | - do_action( 'give_after_graph', $this ); |
|
308 | + do_action('give_after_graph', $this); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
13 | +if ( ! defined('ABSPATH')) exit; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Give_API_V1 Class |
@@ -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 | |
@@ -26,16 +26,16 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return array $links |
28 | 28 | */ |
29 | -function give_plugin_action_links( $links, $file ) { |
|
30 | - $settings_link = '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-settings' ) . '">' . esc_html__( 'Settings', 'give' ) . '</a>'; |
|
31 | - if ( $file == 'give/give.php' ) { |
|
32 | - array_unshift( $links, $settings_link ); |
|
29 | +function give_plugin_action_links($links, $file) { |
|
30 | + $settings_link = '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-settings').'">'.esc_html__('Settings', 'give').'</a>'; |
|
31 | + if ($file == 'give/give.php') { |
|
32 | + array_unshift($links, $settings_link); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | return $links; |
36 | 36 | } |
37 | 37 | |
38 | -add_filter( 'plugin_action_links', 'give_plugin_action_links', 10, 2 ); |
|
38 | +add_filter('plugin_action_links', 'give_plugin_action_links', 10, 2); |
|
39 | 39 | |
40 | 40 | |
41 | 41 | /** |
@@ -48,33 +48,33 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return array $input |
50 | 50 | */ |
51 | -function give_plugin_row_meta( $input, $file ) { |
|
52 | - if ( $file != 'give/give.php' ) { |
|
51 | +function give_plugin_row_meta($input, $file) { |
|
52 | + if ($file != 'give/give.php') { |
|
53 | 53 | return $input; |
54 | 54 | } |
55 | 55 | |
56 | - $give_addons_link = esc_url( add_query_arg( array( |
|
56 | + $give_addons_link = esc_url(add_query_arg(array( |
|
57 | 57 | 'utm_source' => 'plugins-page', |
58 | 58 | 'utm_medium' => 'plugin-row', |
59 | 59 | 'utm_campaign' => 'admin', |
60 | - ), 'https://givewp.com/addons/' ) |
|
60 | + ), 'https://givewp.com/addons/') |
|
61 | 61 | ); |
62 | 62 | |
63 | - $give_docs_link = esc_url( add_query_arg( array( |
|
63 | + $give_docs_link = esc_url(add_query_arg(array( |
|
64 | 64 | 'utm_source' => 'plugins-page', |
65 | 65 | 'utm_medium' => 'plugin-row', |
66 | 66 | 'utm_campaign' => 'admin', |
67 | - ), 'https://givewp.com/documentation/' ) |
|
67 | + ), 'https://givewp.com/documentation/') |
|
68 | 68 | ); |
69 | 69 | |
70 | 70 | $links = array( |
71 | - '<a href="' . $give_docs_link . '" target="_blank">' . esc_html__( 'Documentation', 'give' ) . '</a>', |
|
72 | - '<a href="' . $give_addons_link . '" target="_blank">' . esc_html__( 'Add-ons', 'give' ) . '</a>', |
|
71 | + '<a href="'.$give_docs_link.'" target="_blank">'.esc_html__('Documentation', 'give').'</a>', |
|
72 | + '<a href="'.$give_addons_link.'" target="_blank">'.esc_html__('Add-ons', 'give').'</a>', |
|
73 | 73 | ); |
74 | 74 | |
75 | - $input = array_merge( $input, $links ); |
|
75 | + $input = array_merge($input, $links); |
|
76 | 76 | |
77 | 77 | return $input; |
78 | 78 | } |
79 | 79 | |
80 | -add_filter( 'plugin_row_meta', 'give_plugin_row_meta', 10, 2 ); |
|
80 | +add_filter('plugin_row_meta', 'give_plugin_row_meta', 10, 2); |
@@ -19,6 +19,6 @@ |
||
19 | 19 | * @return void |
20 | 20 | */ |
21 | 21 | function give_disable_mandrill_nl2br() { |
22 | - add_filter( 'mandrill_nl2br', '__return_false' ); |
|
22 | + add_filter('mandrill_nl2br', '__return_false'); |
|
23 | 23 | } |
24 | -add_action( 'give_email_send_before', 'give_disable_mandrill_nl2br'); |
|
24 | +add_action('give_email_send_before', 'give_disable_mandrill_nl2br'); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -70,53 +70,53 @@ discard block |
||
70 | 70 | public function __construct() { |
71 | 71 | |
72 | 72 | $this->use_php_sessions = $this->use_php_sessions(); |
73 | - $this->exp_option = give_get_option( 'session_lifetime' ); |
|
73 | + $this->exp_option = give_get_option('session_lifetime'); |
|
74 | 74 | |
75 | 75 | //PHP Sessions |
76 | - if ( $this->use_php_sessions ) { |
|
76 | + if ($this->use_php_sessions) { |
|
77 | 77 | |
78 | - if ( is_multisite() ) { |
|
78 | + if (is_multisite()) { |
|
79 | 79 | |
80 | - $this->prefix = '_' . get_current_blog_id(); |
|
80 | + $this->prefix = '_'.get_current_blog_id(); |
|
81 | 81 | |
82 | 82 | } |
83 | 83 | |
84 | - add_action( 'init', array( $this, 'maybe_start_session' ), - 2 ); |
|
84 | + add_action('init', array($this, 'maybe_start_session'), - 2); |
|
85 | 85 | |
86 | 86 | } else { |
87 | 87 | |
88 | - if ( ! $this->should_start_session() ) { |
|
88 | + if ( ! $this->should_start_session()) { |
|
89 | 89 | return; |
90 | 90 | } |
91 | 91 | |
92 | 92 | // Use WP_Session |
93 | - if ( ! defined( 'WP_SESSION_COOKIE' ) ) { |
|
94 | - define( 'WP_SESSION_COOKIE', 'give_wp_session' ); |
|
93 | + if ( ! defined('WP_SESSION_COOKIE')) { |
|
94 | + define('WP_SESSION_COOKIE', 'give_wp_session'); |
|
95 | 95 | } |
96 | 96 | |
97 | - if ( ! class_exists( 'Recursive_ArrayAccess' ) ) { |
|
98 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-recursive-arrayaccess.php'; |
|
97 | + if ( ! class_exists('Recursive_ArrayAccess')) { |
|
98 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-recursive-arrayaccess.php'; |
|
99 | 99 | } |
100 | 100 | |
101 | - if ( ! class_exists( 'WP_Session' ) ) { |
|
102 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session.php'; |
|
103 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/wp-session.php'; |
|
101 | + if ( ! class_exists('WP_Session')) { |
|
102 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session.php'; |
|
103 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/wp-session.php'; |
|
104 | 104 | } |
105 | 105 | |
106 | - add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 ); |
|
107 | - add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 ); |
|
106 | + add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999); |
|
107 | + add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999); |
|
108 | 108 | |
109 | 109 | } |
110 | 110 | |
111 | 111 | //Init Session |
112 | - if ( empty( $this->session ) && ! $this->use_php_sessions ) { |
|
113 | - add_action( 'plugins_loaded', array( $this, 'init' ), - 1 ); |
|
112 | + if (empty($this->session) && ! $this->use_php_sessions) { |
|
113 | + add_action('plugins_loaded', array($this, 'init'), - 1); |
|
114 | 114 | } else { |
115 | - add_action( 'init', array( $this, 'init' ), - 1 ); |
|
115 | + add_action('init', array($this, 'init'), - 1); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | //Set cookie on Donation Completion page |
119 | - add_action( 'give_pre_process_purchase', array( $this, 'set_session_cookies' ) ); |
|
119 | + add_action('give_pre_process_purchase', array($this, 'set_session_cookies')); |
|
120 | 120 | |
121 | 121 | } |
122 | 122 | |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function init() { |
131 | 131 | |
132 | - if ( $this->use_php_sessions ) { |
|
133 | - $this->session = isset( $_SESSION[ 'give' . $this->prefix ] ) && is_array( $_SESSION[ 'give' . $this->prefix ] ) ? $_SESSION[ 'give' . $this->prefix ] : array(); |
|
132 | + if ($this->use_php_sessions) { |
|
133 | + $this->session = isset($_SESSION['give'.$this->prefix]) && is_array($_SESSION['give'.$this->prefix]) ? $_SESSION['give'.$this->prefix] : array(); |
|
134 | 134 | } else { |
135 | 135 | $this->session = WP_Session::get_instance(); |
136 | 136 | } |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return string Session variable |
164 | 164 | */ |
165 | - public function get( $key ) { |
|
166 | - $key = sanitize_key( $key ); |
|
165 | + public function get($key) { |
|
166 | + $key = sanitize_key($key); |
|
167 | 167 | |
168 | - return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false; |
|
168 | + return isset($this->session[$key]) ? maybe_unserialize($this->session[$key]) : false; |
|
169 | 169 | |
170 | 170 | } |
171 | 171 | |
@@ -179,21 +179,21 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return mixed Session variable |
181 | 181 | */ |
182 | - public function set( $key, $value ) { |
|
182 | + public function set($key, $value) { |
|
183 | 183 | |
184 | - $key = sanitize_key( $key ); |
|
184 | + $key = sanitize_key($key); |
|
185 | 185 | |
186 | - if ( is_array( $value ) ) { |
|
187 | - $this->session[ $key ] = serialize( $value ); |
|
186 | + if (is_array($value)) { |
|
187 | + $this->session[$key] = serialize($value); |
|
188 | 188 | } else { |
189 | - $this->session[ $key ] = $value; |
|
189 | + $this->session[$key] = $value; |
|
190 | 190 | } |
191 | 191 | |
192 | - if ( $this->use_php_sessions ) { |
|
193 | - $_SESSION[ 'give' . $this->prefix ] = $this->session; |
|
192 | + if ($this->use_php_sessions) { |
|
193 | + $_SESSION['give'.$this->prefix] = $this->session; |
|
194 | 194 | } |
195 | 195 | |
196 | - return $this->session[ $key ]; |
|
196 | + return $this->session[$key]; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -206,10 +206,10 @@ discard block |
||
206 | 206 | * @since 1.4 |
207 | 207 | */ |
208 | 208 | public function set_session_cookies() { |
209 | - if( ! headers_sent() ) { |
|
210 | - $lifetime = current_time( 'timestamp' ) + $this->set_expiration_time(); |
|
211 | - @setcookie( session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
212 | - @setcookie( session_name() . '_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
209 | + if ( ! headers_sent()) { |
|
210 | + $lifetime = current_time('timestamp') + $this->set_expiration_time(); |
|
211 | + @setcookie(session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
212 | + @setcookie(session_name().'_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
213 | 213 | } |
214 | 214 | } |
215 | 215 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function set_expiration_variant_time() { |
227 | 227 | |
228 | - return ( ! empty( $this->exp_option ) ? ( intval( $this->exp_option ) - 3600 ) : 30 * 60 * 23 ); |
|
228 | + return ( ! empty($this->exp_option) ? (intval($this->exp_option) - 3600) : 30 * 60 * 23); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function set_expiration_time() { |
242 | 242 | |
243 | - return ( ! empty( $this->exp_option ) ? intval( $this->exp_option ) : 30 * 60 * 24 ); |
|
243 | + return ( ! empty($this->exp_option) ? intval($this->exp_option) : 30 * 60 * 24); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -258,21 +258,21 @@ discard block |
||
258 | 258 | $ret = false; |
259 | 259 | |
260 | 260 | // If the database variable is already set, no need to run autodetection |
261 | - $give_use_php_sessions = (bool) get_option( 'give_use_php_sessions' ); |
|
261 | + $give_use_php_sessions = (bool) get_option('give_use_php_sessions'); |
|
262 | 262 | |
263 | - if ( ! $give_use_php_sessions ) { |
|
263 | + if ( ! $give_use_php_sessions) { |
|
264 | 264 | |
265 | 265 | // Attempt to detect if the server supports PHP sessions |
266 | - if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) { |
|
266 | + if (function_exists('session_start') && ! ini_get('safe_mode')) { |
|
267 | 267 | |
268 | - $this->set( 'give_use_php_sessions', 1 ); |
|
268 | + $this->set('give_use_php_sessions', 1); |
|
269 | 269 | |
270 | - if ( $this->get( 'give_use_php_sessions' ) ) { |
|
270 | + if ($this->get('give_use_php_sessions')) { |
|
271 | 271 | |
272 | 272 | $ret = true; |
273 | 273 | |
274 | 274 | // Set the database option |
275 | - update_option( 'give_use_php_sessions', true ); |
|
275 | + update_option('give_use_php_sessions', true); |
|
276 | 276 | |
277 | 277 | } |
278 | 278 | |
@@ -284,13 +284,13 @@ discard block |
||
284 | 284 | } |
285 | 285 | |
286 | 286 | // Enable or disable PHP Sessions based on the GIVE_USE_PHP_SESSIONS constant |
287 | - if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ) { |
|
287 | + if (defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS) { |
|
288 | 288 | $ret = true; |
289 | - } else if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && ! GIVE_USE_PHP_SESSIONS ) { |
|
289 | + } else if (defined('GIVE_USE_PHP_SESSIONS') && ! GIVE_USE_PHP_SESSIONS) { |
|
290 | 290 | $ret = false; |
291 | 291 | } |
292 | 292 | |
293 | - return (bool) apply_filters( 'give_use_php_sessions', $ret ); |
|
293 | + return (bool) apply_filters('give_use_php_sessions', $ret); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -303,9 +303,9 @@ discard block |
||
303 | 303 | |
304 | 304 | $start_session = true; |
305 | 305 | |
306 | - if ( ! empty( $_SERVER['REQUEST_URI'] ) ) { |
|
306 | + if ( ! empty($_SERVER['REQUEST_URI'])) { |
|
307 | 307 | |
308 | - $blacklist = apply_filters( 'give_session_start_uri_blacklist', array( |
|
308 | + $blacklist = apply_filters('give_session_start_uri_blacklist', array( |
|
309 | 309 | 'feed', |
310 | 310 | 'feed', |
311 | 311 | 'feed/rss', |
@@ -313,21 +313,21 @@ discard block |
||
313 | 313 | 'feed/rdf', |
314 | 314 | 'feed/atom', |
315 | 315 | 'comments/feed/' |
316 | - ) ); |
|
317 | - $uri = ltrim( $_SERVER['REQUEST_URI'], '/' ); |
|
318 | - $uri = untrailingslashit( $uri ); |
|
319 | - if ( in_array( $uri, $blacklist ) ) { |
|
316 | + )); |
|
317 | + $uri = ltrim($_SERVER['REQUEST_URI'], '/'); |
|
318 | + $uri = untrailingslashit($uri); |
|
319 | + if (in_array($uri, $blacklist)) { |
|
320 | 320 | $start_session = false; |
321 | 321 | } |
322 | - if ( false !== strpos( $uri, 'feed=' ) ) { |
|
322 | + if (false !== strpos($uri, 'feed=')) { |
|
323 | 323 | $start_session = false; |
324 | 324 | } |
325 | - if ( is_admin() ) { |
|
325 | + if (is_admin()) { |
|
326 | 326 | $start_session = false; |
327 | 327 | } |
328 | 328 | } |
329 | 329 | |
330 | - return apply_filters( 'give_start_session', $start_session ); |
|
330 | + return apply_filters('give_start_session', $start_session); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -338,11 +338,11 @@ discard block |
||
338 | 338 | */ |
339 | 339 | public function maybe_start_session() { |
340 | 340 | |
341 | - if ( ! $this->should_start_session() ) { |
|
341 | + if ( ! $this->should_start_session()) { |
|
342 | 342 | return; |
343 | 343 | } |
344 | 344 | |
345 | - if ( ! session_id() && ! headers_sent() ) { |
|
345 | + if ( ! session_id() && ! headers_sent()) { |
|
346 | 346 | session_start(); |
347 | 347 | } |
348 | 348 | |
@@ -358,9 +358,9 @@ discard block |
||
358 | 358 | |
359 | 359 | $expiration = false; |
360 | 360 | |
361 | - if ( session_id() && isset( $_COOKIE[ session_name() . '_expiration' ] ) ) { |
|
361 | + if (session_id() && isset($_COOKIE[session_name().'_expiration'])) { |
|
362 | 362 | |
363 | - $expiration = date( 'D, d M Y h:i:s', intval( $_COOKIE[ session_name() . '_expiration' ] ) ); |
|
363 | + $expiration = date('D, d M Y h:i:s', intval($_COOKIE[session_name().'_expiration'])); |
|
364 | 364 | |
365 | 365 | } |
366 | 366 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return bool $ret True if guest checkout is enabled, false otherwise |
30 | 30 | */ |
31 | -function give_no_guest_checkout( $form_id ) { |
|
31 | +function give_no_guest_checkout($form_id) { |
|
32 | 32 | |
33 | 33 | $backtrace = debug_backtrace(); |
34 | 34 | |
35 | - _give_deprecated_function( __FUNCTION__, '1.4.1', null, $backtrace ); |
|
35 | + _give_deprecated_function(__FUNCTION__, '1.4.1', null, $backtrace); |
|
36 | 36 | |
37 | - $ret = get_post_meta( $form_id, '_give_logged_in_only', true ); |
|
37 | + $ret = get_post_meta($form_id, '_give_logged_in_only', true); |
|
38 | 38 | |
39 | - return (bool) apply_filters( 'give_no_guest_checkout', $ret ); |
|
39 | + return (bool) apply_filters('give_no_guest_checkout', $ret); |
|
40 | 40 | } |
41 | 41 | \ No newline at end of file |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | |
34 | 34 | global $wpdb; |
35 | 35 | |
36 | - $this->table_name = $wpdb->prefix . 'give_customers'; |
|
36 | + $this->table_name = $wpdb->prefix.'give_customers'; |
|
37 | 37 | $this->primary_key = 'id'; |
38 | 38 | $this->version = '1.0'; |
39 | 39 | |
40 | - add_action( 'profile_update', array( $this, 'update_customer_email_on_user_update' ), 10, 2 ); |
|
40 | + add_action('profile_update', array($this, 'update_customer_email_on_user_update'), 10, 2); |
|
41 | 41 | |
42 | 42 | } |
43 | 43 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | 'purchase_value' => 0.00, |
77 | 77 | 'purchase_count' => 0, |
78 | 78 | 'notes' => '', |
79 | - 'date_created' => date( 'Y-m-d H:i:s' ), |
|
79 | + 'date_created' => date('Y-m-d H:i:s'), |
|
80 | 80 | ); |
81 | 81 | } |
82 | 82 | |
@@ -86,40 +86,40 @@ discard block |
||
86 | 86 | * @access public |
87 | 87 | * @since 1.0 |
88 | 88 | */ |
89 | - public function add( $data = array() ) { |
|
89 | + public function add($data = array()) { |
|
90 | 90 | |
91 | 91 | $defaults = array( |
92 | 92 | 'payment_ids' => '' |
93 | 93 | ); |
94 | 94 | |
95 | - $args = wp_parse_args( $data, $defaults ); |
|
95 | + $args = wp_parse_args($data, $defaults); |
|
96 | 96 | |
97 | - if ( empty( $args['email'] ) ) { |
|
97 | + if (empty($args['email'])) { |
|
98 | 98 | return false; |
99 | 99 | } |
100 | 100 | |
101 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
102 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
101 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
102 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
103 | 103 | } |
104 | 104 | |
105 | - $customer = $this->get_customer_by( 'email', $args['email'] ); |
|
105 | + $customer = $this->get_customer_by('email', $args['email']); |
|
106 | 106 | |
107 | - if ( $customer ) { |
|
107 | + if ($customer) { |
|
108 | 108 | // update an existing customer |
109 | 109 | |
110 | 110 | // Update the payment IDs attached to the customer |
111 | - if ( ! empty( $args['payment_ids'] ) ) { |
|
111 | + if ( ! empty($args['payment_ids'])) { |
|
112 | 112 | |
113 | - if ( empty( $customer->payment_ids ) ) { |
|
113 | + if (empty($customer->payment_ids)) { |
|
114 | 114 | |
115 | 115 | $customer->payment_ids = $args['payment_ids']; |
116 | 116 | |
117 | 117 | } else { |
118 | 118 | |
119 | - $existing_ids = array_map( 'absint', explode( ',', $customer->payment_ids ) ); |
|
120 | - $payment_ids = array_map( 'absint', explode( ',', $args['payment_ids'] ) ); |
|
121 | - $payment_ids = array_merge( $payment_ids, $existing_ids ); |
|
122 | - $customer->payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
119 | + $existing_ids = array_map('absint', explode(',', $customer->payment_ids)); |
|
120 | + $payment_ids = array_map('absint', explode(',', $args['payment_ids'])); |
|
121 | + $payment_ids = array_merge($payment_ids, $existing_ids); |
|
122 | + $customer->payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
123 | 123 | |
124 | 124 | } |
125 | 125 | |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | |
128 | 128 | } |
129 | 129 | |
130 | - $this->update( $customer->id, $args ); |
|
130 | + $this->update($customer->id, $args); |
|
131 | 131 | |
132 | 132 | return $customer->id; |
133 | 133 | |
134 | 134 | } else { |
135 | 135 | |
136 | - return $this->insert( $args, 'customer' ); |
|
136 | + return $this->insert($args, 'customer'); |
|
137 | 137 | |
138 | 138 | } |
139 | 139 | |
@@ -152,20 +152,20 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return bool|false|int |
154 | 154 | */ |
155 | - public function delete( $_id_or_email = false ) { |
|
155 | + public function delete($_id_or_email = false) { |
|
156 | 156 | |
157 | - if ( empty( $_id_or_email ) ) { |
|
157 | + if (empty($_id_or_email)) { |
|
158 | 158 | return false; |
159 | 159 | } |
160 | 160 | |
161 | - $column = is_email( $_id_or_email ) ? 'email' : 'id'; |
|
162 | - $customer = $this->get_customer_by( $column, $_id_or_email ); |
|
161 | + $column = is_email($_id_or_email) ? 'email' : 'id'; |
|
162 | + $customer = $this->get_customer_by($column, $_id_or_email); |
|
163 | 163 | |
164 | - if ( $customer->id > 0 ) { |
|
164 | + if ($customer->id > 0) { |
|
165 | 165 | |
166 | 166 | global $wpdb; |
167 | 167 | |
168 | - return $wpdb->delete( $this->table_name, array( 'id' => $customer->id ), array( '%d' ) ); |
|
168 | + return $wpdb->delete($this->table_name, array('id' => $customer->id), array('%d')); |
|
169 | 169 | |
170 | 170 | } else { |
171 | 171 | return false; |
@@ -179,14 +179,14 @@ discard block |
||
179 | 179 | * @access public |
180 | 180 | * @since 1.0 |
181 | 181 | */ |
182 | - public function exists( $value = '', $field = 'email' ) { |
|
182 | + public function exists($value = '', $field = 'email') { |
|
183 | 183 | |
184 | 184 | $columns = $this->get_columns(); |
185 | - if ( ! array_key_exists( $field, $columns ) ) { |
|
185 | + if ( ! array_key_exists($field, $columns)) { |
|
186 | 186 | return false; |
187 | 187 | } |
188 | 188 | |
189 | - return (bool) $this->get_column_by( 'id', $field, $value ); |
|
189 | + return (bool) $this->get_column_by('id', $field, $value); |
|
190 | 190 | |
191 | 191 | } |
192 | 192 | |
@@ -196,16 +196,16 @@ discard block |
||
196 | 196 | * @access public |
197 | 197 | * @since 1.0 |
198 | 198 | */ |
199 | - public function attach_payment( $customer_id = 0, $payment_id = 0 ) { |
|
199 | + public function attach_payment($customer_id = 0, $payment_id = 0) { |
|
200 | 200 | |
201 | - $customer = new Give_Customer( $customer_id ); |
|
201 | + $customer = new Give_Customer($customer_id); |
|
202 | 202 | |
203 | - if ( empty( $customer->id ) ) { |
|
203 | + if (empty($customer->id)) { |
|
204 | 204 | return false; |
205 | 205 | } |
206 | 206 | |
207 | 207 | // Attach the payment, but don't increment stats, as this function previously did not |
208 | - return $customer->attach_payment( $payment_id, false ); |
|
208 | + return $customer->attach_payment($payment_id, false); |
|
209 | 209 | |
210 | 210 | } |
211 | 211 | |
@@ -215,16 +215,16 @@ discard block |
||
215 | 215 | * @access public |
216 | 216 | * @since 1.0 |
217 | 217 | */ |
218 | - public function remove_payment( $customer_id = 0, $payment_id = 0 ) { |
|
218 | + public function remove_payment($customer_id = 0, $payment_id = 0) { |
|
219 | 219 | |
220 | - $customer = new Give_Customer( $customer_id ); |
|
220 | + $customer = new Give_Customer($customer_id); |
|
221 | 221 | |
222 | - if ( ! $customer ) { |
|
222 | + if ( ! $customer) { |
|
223 | 223 | return false; |
224 | 224 | } |
225 | 225 | |
226 | 226 | // Remove the payment, but don't decrease stats, as this function previously did not |
227 | - return $customer->remove_payment( $payment_id, false ); |
|
227 | + return $customer->remove_payment($payment_id, false); |
|
228 | 228 | |
229 | 229 | } |
230 | 230 | |
@@ -236,18 +236,18 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @return bool |
238 | 238 | */ |
239 | - public function increment_stats( $customer_id = 0, $amount = 0.00 ) { |
|
239 | + public function increment_stats($customer_id = 0, $amount = 0.00) { |
|
240 | 240 | |
241 | - $customer = new Give_Customer( $customer_id ); |
|
241 | + $customer = new Give_Customer($customer_id); |
|
242 | 242 | |
243 | - if ( empty( $customer->id ) ) { |
|
243 | + if (empty($customer->id)) { |
|
244 | 244 | return false; |
245 | 245 | } |
246 | 246 | |
247 | 247 | $increased_count = $customer->increase_purchase_count(); |
248 | - $increased_value = $customer->increase_value( $amount ); |
|
248 | + $increased_value = $customer->increase_value($amount); |
|
249 | 249 | |
250 | - return ( $increased_count && $increased_value ) ? true : false; |
|
250 | + return ($increased_count && $increased_value) ? true : false; |
|
251 | 251 | |
252 | 252 | } |
253 | 253 | |
@@ -257,18 +257,18 @@ discard block |
||
257 | 257 | * @access public |
258 | 258 | * @since 1.0 |
259 | 259 | */ |
260 | - public function decrement_stats( $customer_id = 0, $amount = 0.00 ) { |
|
260 | + public function decrement_stats($customer_id = 0, $amount = 0.00) { |
|
261 | 261 | |
262 | - $customer = new Give_Customer( $customer_id ); |
|
262 | + $customer = new Give_Customer($customer_id); |
|
263 | 263 | |
264 | - if ( ! $customer ) { |
|
264 | + if ( ! $customer) { |
|
265 | 265 | return false; |
266 | 266 | } |
267 | 267 | |
268 | 268 | $decreased_count = $customer->decrease_purchase_count(); |
269 | - $decreased_value = $customer->decrease_value( $amount ); |
|
269 | + $decreased_value = $customer->decrease_value($amount); |
|
270 | 270 | |
271 | - return ( $decreased_count && $decreased_value ) ? true : false; |
|
271 | + return ($decreased_count && $decreased_value) ? true : false; |
|
272 | 272 | |
273 | 273 | } |
274 | 274 | |
@@ -284,37 +284,37 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @return bool |
286 | 286 | */ |
287 | - public function update_customer_email_on_user_update( $user_id = 0, $old_user_data ) { |
|
287 | + public function update_customer_email_on_user_update($user_id = 0, $old_user_data) { |
|
288 | 288 | |
289 | - $customer = new Give_Customer( $user_id, true ); |
|
289 | + $customer = new Give_Customer($user_id, true); |
|
290 | 290 | |
291 | - if( ! $customer ) { |
|
291 | + if ( ! $customer) { |
|
292 | 292 | return false; |
293 | 293 | } |
294 | 294 | |
295 | - $user = get_userdata( $user_id ); |
|
295 | + $user = get_userdata($user_id); |
|
296 | 296 | |
297 | - if( ! empty( $user ) && $user->user_email !== $customer->email ) { |
|
297 | + if ( ! empty($user) && $user->user_email !== $customer->email) { |
|
298 | 298 | |
299 | - if( ! $this->get_customer_by( 'email', $user->user_email ) ) { |
|
299 | + if ( ! $this->get_customer_by('email', $user->user_email)) { |
|
300 | 300 | |
301 | - $success = $this->update( $customer->id, array( 'email' => $user->user_email ) ); |
|
301 | + $success = $this->update($customer->id, array('email' => $user->user_email)); |
|
302 | 302 | |
303 | - if( $success ) { |
|
303 | + if ($success) { |
|
304 | 304 | // Update some payment meta if we need to |
305 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
305 | + $payments_array = explode(',', $customer->payment_ids); |
|
306 | 306 | |
307 | - if( ! empty( $payments_array ) ) { |
|
307 | + if ( ! empty($payments_array)) { |
|
308 | 308 | |
309 | - foreach ( $payments_array as $payment_id ) { |
|
309 | + foreach ($payments_array as $payment_id) { |
|
310 | 310 | |
311 | - give_update_payment_meta( $payment_id, 'email', $user->user_email ); |
|
311 | + give_update_payment_meta($payment_id, 'email', $user->user_email); |
|
312 | 312 | |
313 | 313 | } |
314 | 314 | |
315 | 315 | } |
316 | 316 | |
317 | - do_action( 'give_update_customer_email_on_user_update', $user, $customer ); |
|
317 | + do_action('give_update_customer_email_on_user_update', $user, $customer); |
|
318 | 318 | |
319 | 319 | } |
320 | 320 | |
@@ -335,45 +335,45 @@ discard block |
||
335 | 335 | * |
336 | 336 | * @return mixed Upon success, an object of the customer. Upon failure, NULL |
337 | 337 | */ |
338 | - public function get_customer_by( $field = 'id', $value = 0 ) { |
|
338 | + public function get_customer_by($field = 'id', $value = 0) { |
|
339 | 339 | global $wpdb; |
340 | 340 | |
341 | - if ( empty( $field ) || empty( $value ) ) { |
|
341 | + if (empty($field) || empty($value)) { |
|
342 | 342 | return null; |
343 | 343 | } |
344 | 344 | |
345 | - if ( 'id' == $field || 'user_id' == $field ) { |
|
345 | + if ('id' == $field || 'user_id' == $field) { |
|
346 | 346 | // Make sure the value is numeric to avoid casting objects, for example, |
347 | 347 | // to int 1. |
348 | - if ( ! is_numeric( $value ) ) { |
|
348 | + if ( ! is_numeric($value)) { |
|
349 | 349 | return false; |
350 | 350 | } |
351 | 351 | |
352 | - $value = intval( $value ); |
|
352 | + $value = intval($value); |
|
353 | 353 | |
354 | - if ( $value < 1 ) { |
|
354 | + if ($value < 1) { |
|
355 | 355 | return false; |
356 | 356 | } |
357 | 357 | |
358 | - } elseif ( 'email' === $field ) { |
|
358 | + } elseif ('email' === $field) { |
|
359 | 359 | |
360 | - if ( ! is_email( $value ) ) { |
|
360 | + if ( ! is_email($value)) { |
|
361 | 361 | return false; |
362 | 362 | } |
363 | 363 | |
364 | - $value = trim( $value ); |
|
364 | + $value = trim($value); |
|
365 | 365 | } |
366 | 366 | |
367 | - if ( ! $value ) { |
|
367 | + if ( ! $value) { |
|
368 | 368 | return false; |
369 | 369 | } |
370 | 370 | |
371 | - switch ( $field ) { |
|
371 | + switch ($field) { |
|
372 | 372 | case 'id': |
373 | 373 | $db_field = 'id'; |
374 | 374 | break; |
375 | 375 | case 'email': |
376 | - $value = sanitize_text_field( $value ); |
|
376 | + $value = sanitize_text_field($value); |
|
377 | 377 | $db_field = 'email'; |
378 | 378 | break; |
379 | 379 | case 'user_id': |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | return false; |
384 | 384 | } |
385 | 385 | |
386 | - if ( ! $customer = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value ) ) ) { |
|
386 | + if ( ! $customer = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value))) { |
|
387 | 387 | return false; |
388 | 388 | } |
389 | 389 | |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | * @access public |
397 | 397 | * @since 1.0 |
398 | 398 | */ |
399 | - public function get_customers( $args = array() ) { |
|
399 | + public function get_customers($args = array()) { |
|
400 | 400 | |
401 | 401 | global $wpdb; |
402 | 402 | |
@@ -408,21 +408,21 @@ discard block |
||
408 | 408 | 'order' => 'DESC' |
409 | 409 | ); |
410 | 410 | |
411 | - $args = wp_parse_args( $args, $defaults ); |
|
411 | + $args = wp_parse_args($args, $defaults); |
|
412 | 412 | |
413 | - if ( $args['number'] < 1 ) { |
|
413 | + if ($args['number'] < 1) { |
|
414 | 414 | $args['number'] = 999999999999; |
415 | 415 | } |
416 | 416 | |
417 | 417 | $where = ' WHERE 1=1 '; |
418 | 418 | |
419 | 419 | // specific customers |
420 | - if ( ! empty( $args['id'] ) ) { |
|
420 | + if ( ! empty($args['id'])) { |
|
421 | 421 | |
422 | - if ( is_array( $args['id'] ) ) { |
|
423 | - $ids = implode( ',', array_map( 'intval', $args['id'] ) ); |
|
422 | + if (is_array($args['id'])) { |
|
423 | + $ids = implode(',', array_map('intval', $args['id'])); |
|
424 | 424 | } else { |
425 | - $ids = intval( $args['id'] ); |
|
425 | + $ids = intval($args['id']); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | $where .= " AND `id` IN( {$ids} ) "; |
@@ -430,12 +430,12 @@ discard block |
||
430 | 430 | } |
431 | 431 | |
432 | 432 | // customers for specific user accounts |
433 | - if ( ! empty( $args['user_id'] ) ) { |
|
433 | + if ( ! empty($args['user_id'])) { |
|
434 | 434 | |
435 | - if ( is_array( $args['user_id'] ) ) { |
|
436 | - $user_ids = implode( ',', array_map( 'intval', $args['user_id'] ) ); |
|
435 | + if (is_array($args['user_id'])) { |
|
436 | + $user_ids = implode(',', array_map('intval', $args['user_id'])); |
|
437 | 437 | } else { |
438 | - $user_ids = intval( $args['user_id'] ); |
|
438 | + $user_ids = intval($args['user_id']); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | $where .= " AND `user_id` IN( {$user_ids} ) "; |
@@ -443,41 +443,41 @@ discard block |
||
443 | 443 | } |
444 | 444 | |
445 | 445 | //specific customers by email |
446 | - if( ! empty( $args['email'] ) ) { |
|
446 | + if ( ! empty($args['email'])) { |
|
447 | 447 | |
448 | - if( is_array( $args['email'] ) ) { |
|
448 | + if (is_array($args['email'])) { |
|
449 | 449 | |
450 | - $emails_count = count( $args['email'] ); |
|
451 | - $emails_placeholder = array_fill( 0, $emails_count, '%s' ); |
|
452 | - $emails = implode( ', ', $emails_placeholder ); |
|
450 | + $emails_count = count($args['email']); |
|
451 | + $emails_placeholder = array_fill(0, $emails_count, '%s'); |
|
452 | + $emails = implode(', ', $emails_placeholder); |
|
453 | 453 | |
454 | - $where .= $wpdb->prepare( " AND `email` IN( $emails ) ", $args['email'] ); |
|
454 | + $where .= $wpdb->prepare(" AND `email` IN( $emails ) ", $args['email']); |
|
455 | 455 | } else { |
456 | - $where .= $wpdb->prepare( " AND `email` = %s ", $args['email'] ); |
|
456 | + $where .= $wpdb->prepare(" AND `email` = %s ", $args['email']); |
|
457 | 457 | } |
458 | 458 | } |
459 | 459 | |
460 | 460 | // specific customers by name |
461 | - if( ! empty( $args['name'] ) ) { |
|
462 | - $where .= $wpdb->prepare( " AND `name` LIKE '%%%%" . '%s' . "%%%%' ", $args['name'] ); |
|
461 | + if ( ! empty($args['name'])) { |
|
462 | + $where .= $wpdb->prepare(" AND `name` LIKE '%%%%".'%s'."%%%%' ", $args['name']); |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | // Customers created for a specific date or in a date range |
466 | - if ( ! empty( $args['date'] ) ) { |
|
466 | + if ( ! empty($args['date'])) { |
|
467 | 467 | |
468 | - if ( is_array( $args['date'] ) ) { |
|
468 | + if (is_array($args['date'])) { |
|
469 | 469 | |
470 | - if ( ! empty( $args['date']['start'] ) ) { |
|
470 | + if ( ! empty($args['date']['start'])) { |
|
471 | 471 | |
472 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
472 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
473 | 473 | |
474 | 474 | $where .= " AND `date_created` >= '{$start}'"; |
475 | 475 | |
476 | 476 | } |
477 | 477 | |
478 | - if ( ! empty( $args['date']['end'] ) ) { |
|
478 | + if ( ! empty($args['date']['end'])) { |
|
479 | 479 | |
480 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
480 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
481 | 481 | |
482 | 482 | $where .= " AND `date_created` <= '{$end}'"; |
483 | 483 | |
@@ -485,31 +485,31 @@ discard block |
||
485 | 485 | |
486 | 486 | } else { |
487 | 487 | |
488 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
489 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
490 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
488 | + $year = date('Y', strtotime($args['date'])); |
|
489 | + $month = date('m', strtotime($args['date'])); |
|
490 | + $day = date('d', strtotime($args['date'])); |
|
491 | 491 | |
492 | 492 | $where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )"; |
493 | 493 | } |
494 | 494 | |
495 | 495 | } |
496 | 496 | |
497 | - $args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'id' : $args['orderby']; |
|
497 | + $args['orderby'] = ! array_key_exists($args['orderby'], $this->get_columns()) ? 'id' : $args['orderby']; |
|
498 | 498 | |
499 | - if ( 'purchase_value' == $args['orderby'] ) { |
|
499 | + if ('purchase_value' == $args['orderby']) { |
|
500 | 500 | $args['orderby'] = 'purchase_value+0'; |
501 | 501 | } |
502 | 502 | |
503 | - $cache_key = md5( 'give_customers_' . serialize( $args ) ); |
|
503 | + $cache_key = md5('give_customers_'.serialize($args)); |
|
504 | 504 | |
505 | - $customers = wp_cache_get( $cache_key, 'customers' ); |
|
505 | + $customers = wp_cache_get($cache_key, 'customers'); |
|
506 | 506 | |
507 | - $args['orderby'] = esc_sql( $args['orderby'] ); |
|
508 | - $args['order'] = esc_sql( $args['order'] ); |
|
507 | + $args['orderby'] = esc_sql($args['orderby']); |
|
508 | + $args['order'] = esc_sql($args['order']); |
|
509 | 509 | |
510 | - if ( $customers === false ) { |
|
511 | - $customers = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint( $args['offset'] ), absint( $args['number'] ) ) ); |
|
512 | - wp_cache_set( $cache_key, $customers, 'customers', 3600 ); |
|
510 | + if ($customers === false) { |
|
511 | + $customers = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint($args['offset']), absint($args['number']))); |
|
512 | + wp_cache_set($cache_key, $customers, 'customers', 3600); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | return $customers; |
@@ -523,26 +523,26 @@ discard block |
||
523 | 523 | * @access public |
524 | 524 | * @since 1.0 |
525 | 525 | */ |
526 | - public function count( $args = array() ) { |
|
526 | + public function count($args = array()) { |
|
527 | 527 | |
528 | 528 | global $wpdb; |
529 | 529 | |
530 | 530 | $where = ' WHERE 1=1 '; |
531 | 531 | |
532 | - if ( ! empty( $args['date'] ) ) { |
|
532 | + if ( ! empty($args['date'])) { |
|
533 | 533 | |
534 | - if ( is_array( $args['date'] ) ) { |
|
534 | + if (is_array($args['date'])) { |
|
535 | 535 | |
536 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
537 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
536 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
537 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
538 | 538 | |
539 | 539 | $where .= " AND `date_created` >= '{$start}' AND `date_created` <= '{$end}'"; |
540 | 540 | |
541 | 541 | } else { |
542 | 542 | |
543 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
544 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
545 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
543 | + $year = date('Y', strtotime($args['date'])); |
|
544 | + $month = date('m', strtotime($args['date'])); |
|
545 | + $day = date('d', strtotime($args['date'])); |
|
546 | 546 | |
547 | 547 | $where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )"; |
548 | 548 | } |
@@ -550,16 +550,16 @@ discard block |
||
550 | 550 | } |
551 | 551 | |
552 | 552 | |
553 | - $cache_key = md5( 'give_customers_count' . serialize( $args ) ); |
|
553 | + $cache_key = md5('give_customers_count'.serialize($args)); |
|
554 | 554 | |
555 | - $count = wp_cache_get( $cache_key, 'customers' ); |
|
555 | + $count = wp_cache_get($cache_key, 'customers'); |
|
556 | 556 | |
557 | - if ( $count === false ) { |
|
558 | - $count = $wpdb->get_var( "SELECT COUNT($this->primary_key) FROM " . $this->table_name . "{$where};" ); |
|
559 | - wp_cache_set( $cache_key, $count, 'customers', 3600 ); |
|
557 | + if ($count === false) { |
|
558 | + $count = $wpdb->get_var("SELECT COUNT($this->primary_key) FROM ".$this->table_name."{$where};"); |
|
559 | + wp_cache_set($cache_key, $count, 'customers', 3600); |
|
560 | 560 | } |
561 | 561 | |
562 | - return absint( $count ); |
|
562 | + return absint($count); |
|
563 | 563 | |
564 | 564 | } |
565 | 565 | |
@@ -571,9 +571,9 @@ discard block |
||
571 | 571 | */ |
572 | 572 | public function create_table() { |
573 | 573 | |
574 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
574 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
575 | 575 | |
576 | - $sql = "CREATE TABLE " . $this->table_name . " ( |
|
576 | + $sql = "CREATE TABLE ".$this->table_name." ( |
|
577 | 577 | id bigint(20) NOT NULL AUTO_INCREMENT, |
578 | 578 | user_id bigint(20) NOT NULL, |
579 | 579 | email varchar(50) NOT NULL, |
@@ -588,9 +588,9 @@ discard block |
||
588 | 588 | KEY user (user_id) |
589 | 589 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
590 | 590 | |
591 | - dbDelta( $sql ); |
|
591 | + dbDelta($sql); |
|
592 | 592 | |
593 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
593 | + update_option($this->table_name.'_db_version', $this->version); |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | /** |
@@ -600,6 +600,6 @@ discard block |
||
600 | 600 | * @return bool Returns if the customers table was installed and upgrade routine run |
601 | 601 | */ |
602 | 602 | public function installed() { |
603 | - return $this->table_exists( $this->table_name ); |
|
603 | + return $this->table_exists($this->table_name); |
|
604 | 604 | } |
605 | 605 | } |
@@ -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 | |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @param $args array The array of arguments that can be passed in and used for setting up this payment query. |
56 | 56 | */ |
57 | - public function __construct( $args = array() ) { |
|
57 | + public function __construct($args = array()) { |
|
58 | 58 | $defaults = array( |
59 | 59 | 'output' => 'payments', // Use 'posts' to get standard post objects |
60 | - 'post_type' => array( 'give_payment' ), |
|
60 | + 'post_type' => array('give_payment'), |
|
61 | 61 | 'start_date' => false, |
62 | 62 | 'end_date' => false, |
63 | 63 | 'number' => 20, |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | 'give_forms' => null |
78 | 78 | ); |
79 | 79 | |
80 | - $this->args = wp_parse_args( $args, $defaults ); |
|
80 | + $this->args = wp_parse_args($args, $defaults); |
|
81 | 81 | |
82 | 82 | $this->init(); |
83 | 83 | } |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | * @access public |
89 | 89 | * @since 1.0 |
90 | 90 | */ |
91 | - public function __set( $query_var, $value ) { |
|
92 | - if ( in_array( $query_var, array( 'meta_query', 'tax_query' ) ) ) { |
|
93 | - $this->args[ $query_var ][] = $value; |
|
91 | + public function __set($query_var, $value) { |
|
92 | + if (in_array($query_var, array('meta_query', 'tax_query'))) { |
|
93 | + $this->args[$query_var][] = $value; |
|
94 | 94 | } else { |
95 | - $this->args[ $query_var ] = $value; |
|
95 | + $this->args[$query_var] = $value; |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | * @access public |
103 | 103 | * @since 1.0 |
104 | 104 | */ |
105 | - public function __unset( $query_var ) { |
|
106 | - unset( $this->args[ $query_var ] ); |
|
105 | + public function __unset($query_var) { |
|
106 | + unset($this->args[$query_var]); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -115,19 +115,19 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public function init() { |
117 | 117 | |
118 | - add_action( 'give_pre_get_payments', array( $this, 'date_filter_pre' ) ); |
|
119 | - add_action( 'give_post_get_payments', array( $this, 'date_filter_post' ) ); |
|
120 | - |
|
121 | - add_action( 'give_pre_get_payments', array( $this, 'orderby' ) ); |
|
122 | - add_action( 'give_pre_get_payments', array( $this, 'status' ) ); |
|
123 | - add_action( 'give_pre_get_payments', array( $this, 'month' ) ); |
|
124 | - add_action( 'give_pre_get_payments', array( $this, 'per_page' ) ); |
|
125 | - add_action( 'give_pre_get_payments', array( $this, 'page' ) ); |
|
126 | - add_action( 'give_pre_get_payments', array( $this, 'user' ) ); |
|
127 | - add_action( 'give_pre_get_payments', array( $this, 'search' ) ); |
|
128 | - add_action( 'give_pre_get_payments', array( $this, 'mode' ) ); |
|
129 | - add_action( 'give_pre_get_payments', array( $this, 'children' ) ); |
|
130 | - add_action( 'give_pre_get_payments', array( $this, 'give_forms' ) ); |
|
118 | + add_action('give_pre_get_payments', array($this, 'date_filter_pre')); |
|
119 | + add_action('give_post_get_payments', array($this, 'date_filter_post')); |
|
120 | + |
|
121 | + add_action('give_pre_get_payments', array($this, 'orderby')); |
|
122 | + add_action('give_pre_get_payments', array($this, 'status')); |
|
123 | + add_action('give_pre_get_payments', array($this, 'month')); |
|
124 | + add_action('give_pre_get_payments', array($this, 'per_page')); |
|
125 | + add_action('give_pre_get_payments', array($this, 'page')); |
|
126 | + add_action('give_pre_get_payments', array($this, 'user')); |
|
127 | + add_action('give_pre_get_payments', array($this, 'search')); |
|
128 | + add_action('give_pre_get_payments', array($this, 'mode')); |
|
129 | + add_action('give_pre_get_payments', array($this, 'children')); |
|
130 | + add_action('give_pre_get_payments', array($this, 'give_forms')); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -143,33 +143,33 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function get_payments() { |
145 | 145 | |
146 | - do_action( 'give_pre_get_payments', $this ); |
|
146 | + do_action('give_pre_get_payments', $this); |
|
147 | 147 | |
148 | - $query = new WP_Query( $this->args ); |
|
148 | + $query = new WP_Query($this->args); |
|
149 | 149 | |
150 | 150 | $custom_output = array( |
151 | 151 | 'payments', |
152 | 152 | 'give_payments', |
153 | 153 | ); |
154 | 154 | |
155 | - if ( ! in_array( $this->args['output'], $custom_output ) ) { |
|
155 | + if ( ! in_array($this->args['output'], $custom_output)) { |
|
156 | 156 | return $query->posts; |
157 | 157 | } |
158 | 158 | |
159 | - if ( $query->have_posts() ) { |
|
160 | - while ( $query->have_posts() ) { |
|
159 | + if ($query->have_posts()) { |
|
160 | + while ($query->have_posts()) { |
|
161 | 161 | $query->the_post(); |
162 | 162 | |
163 | 163 | $payment_id = get_post()->ID; |
164 | - $payment = new Give_Payment( $payment_id ); |
|
164 | + $payment = new Give_Payment($payment_id); |
|
165 | 165 | |
166 | - $this->payments[] = apply_filters( 'give_payment', $payment, $payment_id, $this ); |
|
166 | + $this->payments[] = apply_filters('give_payment', $payment, $payment_id, $this); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | wp_reset_postdata(); |
170 | 170 | } |
171 | 171 | |
172 | - do_action( 'give_post_get_payments', $this ); |
|
172 | + do_action('give_post_get_payments', $this); |
|
173 | 173 | |
174 | 174 | return $this->payments; |
175 | 175 | } |
@@ -182,13 +182,13 @@ discard block |
||
182 | 182 | * @return void |
183 | 183 | */ |
184 | 184 | public function date_filter_pre() { |
185 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
185 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
186 | 186 | return; |
187 | 187 | } |
188 | 188 | |
189 | - $this->setup_dates( $this->args['start_date'], $this->args['end_date'] ); |
|
189 | + $this->setup_dates($this->args['start_date'], $this->args['end_date']); |
|
190 | 190 | |
191 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
191 | + add_filter('posts_where', array($this, 'payments_where')); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -200,11 +200,11 @@ discard block |
||
200 | 200 | * @return void |
201 | 201 | */ |
202 | 202 | public function date_filter_post() { |
203 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
203 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
204 | 204 | return; |
205 | 205 | } |
206 | 206 | |
207 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
207 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | * @return void |
216 | 216 | */ |
217 | 217 | public function status() { |
218 | - if ( ! isset ( $this->args['status'] ) ) { |
|
218 | + if ( ! isset ($this->args['status'])) { |
|
219 | 219 | return; |
220 | 220 | } |
221 | 221 | |
222 | - $this->__set( 'post_status', $this->args['status'] ); |
|
223 | - $this->__unset( 'status' ); |
|
222 | + $this->__set('post_status', $this->args['status']); |
|
223 | + $this->__unset('status'); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -231,12 +231,12 @@ discard block |
||
231 | 231 | * @return void |
232 | 232 | */ |
233 | 233 | public function page() { |
234 | - if ( ! isset ( $this->args['page'] ) ) { |
|
234 | + if ( ! isset ($this->args['page'])) { |
|
235 | 235 | return; |
236 | 236 | } |
237 | 237 | |
238 | - $this->__set( 'paged', $this->args['page'] ); |
|
239 | - $this->__unset( 'page' ); |
|
238 | + $this->__set('paged', $this->args['page']); |
|
239 | + $this->__unset('page'); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
@@ -248,17 +248,17 @@ discard block |
||
248 | 248 | */ |
249 | 249 | public function per_page() { |
250 | 250 | |
251 | - if ( ! isset( $this->args['number'] ) ) { |
|
251 | + if ( ! isset($this->args['number'])) { |
|
252 | 252 | return; |
253 | 253 | } |
254 | 254 | |
255 | - if ( $this->args['number'] == - 1 ) { |
|
256 | - $this->__set( 'nopaging', true ); |
|
255 | + if ($this->args['number'] == - 1) { |
|
256 | + $this->__set('nopaging', true); |
|
257 | 257 | } else { |
258 | - $this->__set( 'posts_per_page', $this->args['number'] ); |
|
258 | + $this->__set('posts_per_page', $this->args['number']); |
|
259 | 259 | } |
260 | 260 | |
261 | - $this->__unset( 'number' ); |
|
261 | + $this->__unset('number'); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -269,12 +269,12 @@ discard block |
||
269 | 269 | * @return void |
270 | 270 | */ |
271 | 271 | public function month() { |
272 | - if ( ! isset ( $this->args['month'] ) ) { |
|
272 | + if ( ! isset ($this->args['month'])) { |
|
273 | 273 | return; |
274 | 274 | } |
275 | 275 | |
276 | - $this->__set( 'monthnum', $this->args['month'] ); |
|
277 | - $this->__unset( 'month' ); |
|
276 | + $this->__set('monthnum', $this->args['month']); |
|
277 | + $this->__unset('month'); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -285,13 +285,13 @@ discard block |
||
285 | 285 | * @return void |
286 | 286 | */ |
287 | 287 | public function orderby() { |
288 | - switch ( $this->args['orderby'] ) { |
|
288 | + switch ($this->args['orderby']) { |
|
289 | 289 | case 'amount' : |
290 | - $this->__set( 'orderby', 'meta_value_num' ); |
|
291 | - $this->__set( 'meta_key', '_give_payment_total' ); |
|
290 | + $this->__set('orderby', 'meta_value_num'); |
|
291 | + $this->__set('meta_key', '_give_payment_total'); |
|
292 | 292 | break; |
293 | 293 | default : |
294 | - $this->__set( 'orderby', $this->args['orderby'] ); |
|
294 | + $this->__set('orderby', $this->args['orderby']); |
|
295 | 295 | break; |
296 | 296 | } |
297 | 297 | } |
@@ -304,20 +304,20 @@ discard block |
||
304 | 304 | * @return void |
305 | 305 | */ |
306 | 306 | public function user() { |
307 | - if ( is_null( $this->args['user'] ) ) { |
|
307 | + if (is_null($this->args['user'])) { |
|
308 | 308 | return; |
309 | 309 | } |
310 | 310 | |
311 | - if ( is_numeric( $this->args['user'] ) ) { |
|
311 | + if (is_numeric($this->args['user'])) { |
|
312 | 312 | $user_key = '_give_payment_user_id'; |
313 | 313 | } else { |
314 | 314 | $user_key = '_give_payment_user_email'; |
315 | 315 | } |
316 | 316 | |
317 | - $this->__set( 'meta_query', array( |
|
317 | + $this->__set('meta_query', array( |
|
318 | 318 | 'key' => $user_key, |
319 | 319 | 'value' => $this->args['user'] |
320 | - ) ); |
|
320 | + )); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
@@ -329,33 +329,33 @@ discard block |
||
329 | 329 | */ |
330 | 330 | public function search() { |
331 | 331 | |
332 | - if ( ! isset( $this->args['s'] ) ) { |
|
332 | + if ( ! isset($this->args['s'])) { |
|
333 | 333 | return; |
334 | 334 | } |
335 | 335 | |
336 | - $search = trim( $this->args['s'] ); |
|
336 | + $search = trim($this->args['s']); |
|
337 | 337 | |
338 | - if ( empty( $search ) ) { |
|
338 | + if (empty($search)) { |
|
339 | 339 | return; |
340 | 340 | } |
341 | 341 | |
342 | - $is_email = is_email( $search ) || strpos( $search, '@' ) !== false; |
|
343 | - $is_user = strpos( $search, strtolower( 'user:' ) ) !== false; |
|
342 | + $is_email = is_email($search) || strpos($search, '@') !== false; |
|
343 | + $is_user = strpos($search, strtolower('user:')) !== false; |
|
344 | 344 | |
345 | - if ( ! empty( $this->args['search_in_notes'] ) ) { |
|
345 | + if ( ! empty($this->args['search_in_notes'])) { |
|
346 | 346 | |
347 | - $notes = give_get_payment_notes( 0, $search ); |
|
347 | + $notes = give_get_payment_notes(0, $search); |
|
348 | 348 | |
349 | - if ( ! empty( $notes ) ) { |
|
349 | + if ( ! empty($notes)) { |
|
350 | 350 | |
351 | - $payment_ids = wp_list_pluck( (array) $notes, 'comment_post_ID' ); |
|
351 | + $payment_ids = wp_list_pluck((array) $notes, 'comment_post_ID'); |
|
352 | 352 | |
353 | - $this->__set( 'post__in', $payment_ids ); |
|
353 | + $this->__set('post__in', $payment_ids); |
|
354 | 354 | } |
355 | 355 | |
356 | - $this->__unset( 's' ); |
|
356 | + $this->__unset('s'); |
|
357 | 357 | |
358 | - } elseif ( $is_email || strlen( $search ) == 32 ) { |
|
358 | + } elseif ($is_email || strlen($search) == 32) { |
|
359 | 359 | |
360 | 360 | $key = $is_email ? '_give_payment_user_email' : '_give_payment_purchase_key'; |
361 | 361 | $search_meta = array( |
@@ -364,19 +364,19 @@ discard block |
||
364 | 364 | 'compare' => 'LIKE' |
365 | 365 | ); |
366 | 366 | |
367 | - $this->__set( 'meta_query', $search_meta ); |
|
368 | - $this->__unset( 's' ); |
|
367 | + $this->__set('meta_query', $search_meta); |
|
368 | + $this->__unset('s'); |
|
369 | 369 | |
370 | - } elseif ( $is_user ) { |
|
370 | + } elseif ($is_user) { |
|
371 | 371 | |
372 | 372 | $search_meta = array( |
373 | 373 | 'key' => '_give_payment_user_id', |
374 | - 'value' => trim( str_replace( 'user:', '', strtolower( $search ) ) ) |
|
374 | + 'value' => trim(str_replace('user:', '', strtolower($search))) |
|
375 | 375 | ); |
376 | 376 | |
377 | - $this->__set( 'meta_query', $search_meta ); |
|
377 | + $this->__set('meta_query', $search_meta); |
|
378 | 378 | |
379 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
379 | + if (give_get_option('enable_sequential')) { |
|
380 | 380 | |
381 | 381 | $search_meta = array( |
382 | 382 | 'key' => '_give_payment_number', |
@@ -384,19 +384,19 @@ discard block |
||
384 | 384 | 'compare' => 'LIKE' |
385 | 385 | ); |
386 | 386 | |
387 | - $this->__set( 'meta_query', $search_meta ); |
|
387 | + $this->__set('meta_query', $search_meta); |
|
388 | 388 | |
389 | 389 | $this->args['meta_query']['relation'] = 'OR'; |
390 | 390 | |
391 | 391 | } |
392 | 392 | |
393 | - $this->__unset( 's' ); |
|
393 | + $this->__unset('s'); |
|
394 | 394 | |
395 | 395 | } elseif ( |
396 | - give_get_option( 'enable_sequential' ) && |
|
396 | + give_get_option('enable_sequential') && |
|
397 | 397 | ( |
398 | - false !== strpos( $search, give_get_option( 'sequential_prefix' ) ) || |
|
399 | - false !== strpos( $search, give_get_option( 'sequential_postfix' ) ) |
|
398 | + false !== strpos($search, give_get_option('sequential_prefix')) || |
|
399 | + false !== strpos($search, give_get_option('sequential_postfix')) |
|
400 | 400 | ) |
401 | 401 | ) { |
402 | 402 | |
@@ -406,30 +406,30 @@ discard block |
||
406 | 406 | 'compare' => 'LIKE' |
407 | 407 | ); |
408 | 408 | |
409 | - $this->__set( 'meta_query', $search_meta ); |
|
410 | - $this->__unset( 's' ); |
|
409 | + $this->__set('meta_query', $search_meta); |
|
410 | + $this->__unset('s'); |
|
411 | 411 | |
412 | - } elseif ( is_numeric( $search ) ) { |
|
412 | + } elseif (is_numeric($search)) { |
|
413 | 413 | |
414 | - $post = get_post( $search ); |
|
414 | + $post = get_post($search); |
|
415 | 415 | |
416 | - if ( is_object( $post ) && $post->post_type == 'give_payment' ) { |
|
416 | + if (is_object($post) && $post->post_type == 'give_payment') { |
|
417 | 417 | |
418 | 418 | $arr = array(); |
419 | 419 | $arr[] = $search; |
420 | - $this->__set( 'post__in', $arr ); |
|
421 | - $this->__unset( 's' ); |
|
420 | + $this->__set('post__in', $arr); |
|
421 | + $this->__unset('s'); |
|
422 | 422 | } |
423 | 423 | |
424 | - } elseif ( '#' == substr( $search, 0, 1 ) ) { |
|
424 | + } elseif ('#' == substr($search, 0, 1)) { |
|
425 | 425 | |
426 | - $search = str_replace( '#:', '', $search ); |
|
427 | - $search = str_replace( '#', '', $search ); |
|
428 | - $this->__set( 'give_forms', $search ); |
|
429 | - $this->__unset( 's' ); |
|
426 | + $search = str_replace('#:', '', $search); |
|
427 | + $search = str_replace('#', '', $search); |
|
428 | + $this->__set('give_forms', $search); |
|
429 | + $this->__unset('s'); |
|
430 | 430 | |
431 | 431 | } else { |
432 | - $this->__set( 's', $search ); |
|
432 | + $this->__set('s', $search); |
|
433 | 433 | |
434 | 434 | } |
435 | 435 | |
@@ -443,16 +443,16 @@ discard block |
||
443 | 443 | * @return void |
444 | 444 | */ |
445 | 445 | public function mode() { |
446 | - if ( empty( $this->args['mode'] ) || $this->args['mode'] == 'all' ) { |
|
447 | - $this->__unset( 'mode' ); |
|
446 | + if (empty($this->args['mode']) || $this->args['mode'] == 'all') { |
|
447 | + $this->__unset('mode'); |
|
448 | 448 | |
449 | 449 | return; |
450 | 450 | } |
451 | 451 | |
452 | - $this->__set( 'meta_query', array( |
|
452 | + $this->__set('meta_query', array( |
|
453 | 453 | 'key' => '_give_payment_mode', |
454 | 454 | 'value' => $this->args['mode'] |
455 | - ) ); |
|
455 | + )); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | /** |
@@ -463,10 +463,10 @@ discard block |
||
463 | 463 | * @return void |
464 | 464 | */ |
465 | 465 | public function children() { |
466 | - if ( empty( $this->args['children'] ) ) { |
|
467 | - $this->__set( 'post_parent', 0 ); |
|
466 | + if (empty($this->args['children'])) { |
|
467 | + $this->__set('post_parent', 0); |
|
468 | 468 | } |
469 | - $this->__unset( 'children' ); |
|
469 | + $this->__unset('children'); |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | /** |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | */ |
479 | 479 | public function give_forms() { |
480 | 480 | |
481 | - if ( empty( $this->args['give_forms'] ) ) { |
|
481 | + if (empty($this->args['give_forms'])) { |
|
482 | 482 | return; |
483 | 483 | } |
484 | 484 | |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | $args = array( |
488 | 488 | 'post_parent' => $this->args['give_forms'], |
489 | 489 | 'log_type' => 'sale', |
490 | - 'post_status' => array( 'publish' ), |
|
490 | + 'post_status' => array('publish'), |
|
491 | 491 | 'nopaging' => true, |
492 | 492 | 'no_found_rows' => true, |
493 | 493 | 'update_post_term_cache' => false, |
@@ -496,31 +496,31 @@ discard block |
||
496 | 496 | 'fields' => 'ids' |
497 | 497 | ); |
498 | 498 | |
499 | - if ( is_array( $this->args['give_forms'] ) ) { |
|
500 | - unset( $args['post_parent'] ); |
|
499 | + if (is_array($this->args['give_forms'])) { |
|
500 | + unset($args['post_parent']); |
|
501 | 501 | $args['post_parent__in'] = $this->args['give_forms']; |
502 | 502 | } |
503 | 503 | |
504 | - $sales = $give_logs->get_connected_logs( $args ); |
|
504 | + $sales = $give_logs->get_connected_logs($args); |
|
505 | 505 | |
506 | - if ( ! empty( $sales ) ) { |
|
506 | + if ( ! empty($sales)) { |
|
507 | 507 | |
508 | 508 | $payments = array(); |
509 | 509 | |
510 | - foreach ( $sales as $sale ) { |
|
511 | - $payments[] = get_post_meta( $sale, '_give_log_payment_id', true ); |
|
510 | + foreach ($sales as $sale) { |
|
511 | + $payments[] = get_post_meta($sale, '_give_log_payment_id', true); |
|
512 | 512 | } |
513 | 513 | |
514 | - $this->__set( 'post__in', $payments ); |
|
514 | + $this->__set('post__in', $payments); |
|
515 | 515 | |
516 | 516 | } else { |
517 | 517 | |
518 | 518 | // Set post_parent to something crazy so it doesn't find anything |
519 | - $this->__set( 'post_parent', 999999999999999 ); |
|
519 | + $this->__set('post_parent', 999999999999999); |
|
520 | 520 | |
521 | 521 | } |
522 | 522 | |
523 | - $this->__unset( 'give_forms' ); |
|
523 | + $this->__unset('give_forms'); |
|
524 | 524 | |
525 | 525 | } |
526 | 526 | } |