@@ -64,11 +64,14 @@ |
||
64 | 64 | }, 250 ); |
65 | 65 | </script> |
66 | 66 | |
67 | - <?php else : ?> |
|
67 | + <?php else { |
|
68 | + : ?> |
|
68 | 69 | |
69 | 70 | <div id="give-upgrade-status"> |
70 | 71 | <p style="font-size: 20px;max-width: 900px;"> |
71 | - <?php esc_html_e( 'The upgrade process has started, please be patient and do not close this window or navigate away from this page. This could take several minutes depending on the upgrade and the size of your website. You will be automatically redirected when the upgrade is finished.', 'give' ); ?> |
|
72 | + <?php esc_html_e( 'The upgrade process has started, please be patient and do not close this window or navigate away from this page. This could take several minutes depending on the upgrade and the size of your website. You will be automatically redirected when the upgrade is finished.', 'give' ); |
|
73 | +} |
|
74 | +?> |
|
72 | 75 | <img src="<?php echo GIVE_PLUGIN_URL . '/assets/images/spinner.gif'; ?>" id="give-upgrade-loader" style=" position: relative; top: 3px; left: 6px;" /> |
73 | 76 | </p> |
74 | 77 | </div> |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | * @return void |
22 | 22 | */ |
23 | 23 | function give_upgrades_screen() { |
24 | - $action = isset( $_GET['give-upgrade'] ) ? sanitize_text_field( $_GET['give-upgrade'] ) : ''; |
|
25 | - $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; |
|
26 | - $total = isset( $_GET['total'] ) ? absint( $_GET['total'] ) : false; |
|
27 | - $custom = isset( $_GET['custom'] ) ? absint( $_GET['custom'] ) : 0; |
|
28 | - $number = isset( $_GET['number'] ) ? absint( $_GET['number'] ) : 100; |
|
29 | - $steps = round( ( $total / $number ), 0 ); |
|
24 | + $action = isset($_GET['give-upgrade']) ? sanitize_text_field($_GET['give-upgrade']) : ''; |
|
25 | + $step = isset($_GET['step']) ? absint($_GET['step']) : 1; |
|
26 | + $total = isset($_GET['total']) ? absint($_GET['total']) : false; |
|
27 | + $custom = isset($_GET['custom']) ? absint($_GET['custom']) : 0; |
|
28 | + $number = isset($_GET['number']) ? absint($_GET['number']) : 100; |
|
29 | + $steps = round(($total / $number), 0); |
|
30 | 30 | |
31 | 31 | $doing_upgrade_args = array( |
32 | 32 | 'page' => 'give-upgrades', |
@@ -36,25 +36,25 @@ discard block |
||
36 | 36 | 'custom' => $custom, |
37 | 37 | 'steps' => $steps |
38 | 38 | ); |
39 | - update_option( 'give_doing_upgrade', $doing_upgrade_args ); |
|
40 | - if ( $step > $steps ) { |
|
39 | + update_option('give_doing_upgrade', $doing_upgrade_args); |
|
40 | + if ($step > $steps) { |
|
41 | 41 | // Prevent a weird case where the estimate was off. Usually only a couple. |
42 | 42 | $steps = $step; |
43 | 43 | } |
44 | 44 | ?> |
45 | 45 | <div class="wrap"> |
46 | - <h2><?php esc_html_e( 'Give - Upgrades', 'give' ); ?></h2> |
|
46 | + <h2><?php esc_html_e('Give - Upgrades', 'give'); ?></h2> |
|
47 | 47 | |
48 | - <?php if ( ! empty( $action ) ) : ?> |
|
48 | + <?php if ( ! empty($action)) : ?> |
|
49 | 49 | |
50 | 50 | <div id="give-upgrade-status"> |
51 | - <p style="font-size: 20px;max-width: 900px;"><?php esc_html_e( 'The upgrade process has started, please be patient and do not close this window or navigate away from this page. This could take several minutes depending on the upgrade and the size of your website. You will be automatically redirected when the upgrade is finished.', 'give' ); ?> |
|
52 | - <img src="<?php echo GIVE_PLUGIN_URL . '/assets/images/spinner.gif'; ?>" id="give-upgrade-loader" style=" position: relative; top: 3px; left: 6px;" /> |
|
51 | + <p style="font-size: 20px;max-width: 900px;"><?php esc_html_e('The upgrade process has started, please be patient and do not close this window or navigate away from this page. This could take several minutes depending on the upgrade and the size of your website. You will be automatically redirected when the upgrade is finished.', 'give'); ?> |
|
52 | + <img src="<?php echo GIVE_PLUGIN_URL.'/assets/images/spinner.gif'; ?>" id="give-upgrade-loader" style=" position: relative; top: 3px; left: 6px;" /> |
|
53 | 53 | </p> |
54 | 54 | |
55 | - <?php if ( ! empty( $total ) ) : ?> |
|
55 | + <?php if ( ! empty($total)) : ?> |
|
56 | 56 | <p> |
57 | - <strong><?php printf( esc_html__( 'Step %d of approximately %d running', 'give' ), $step, $steps ); ?></strong> |
|
57 | + <strong><?php printf(esc_html__('Step %d of approximately %d running', 'give'), $step, $steps); ?></strong> |
|
58 | 58 | </p> |
59 | 59 | <?php endif; ?> |
60 | 60 | </div> |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | |
69 | 69 | <div id="give-upgrade-status"> |
70 | 70 | <p style="font-size: 20px;max-width: 900px;"> |
71 | - <?php esc_html_e( 'The upgrade process has started, please be patient and do not close this window or navigate away from this page. This could take several minutes depending on the upgrade and the size of your website. You will be automatically redirected when the upgrade is finished.', 'give' ); ?> |
|
72 | - <img src="<?php echo GIVE_PLUGIN_URL . '/assets/images/spinner.gif'; ?>" id="give-upgrade-loader" style=" position: relative; top: 3px; left: 6px;" /> |
|
71 | + <?php esc_html_e('The upgrade process has started, please be patient and do not close this window or navigate away from this page. This could take several minutes depending on the upgrade and the size of your website. You will be automatically redirected when the upgrade is finished.', 'give'); ?> |
|
72 | + <img src="<?php echo GIVE_PLUGIN_URL.'/assets/images/spinner.gif'; ?>" id="give-upgrade-loader" style=" position: relative; top: 3px; left: 6px;" /> |
|
73 | 73 | </p> |
74 | 74 | </div> |
75 | 75 | <script type="text/javascript"> |
@@ -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 esc_attr_e( $label ); ?>", |
|
192 | - id : "<?php echo sanitize_key( $label ); ?>", |
|
191 | + label : "<?php esc_attr_e($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 | } |
@@ -306,9 +306,9 @@ discard block |
||
306 | 306 | * @since 1.0 |
307 | 307 | */ |
308 | 308 | public function display() { |
309 | - do_action( 'give_before_graph', $this ); |
|
309 | + do_action('give_before_graph', $this); |
|
310 | 310 | echo $this->build_graph(); |
311 | - do_action( 'give_after_graph', $this ); |
|
311 | + do_action('give_after_graph', $this); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -defined( 'ABSPATH' ) or exit; |
|
13 | +defined('ABSPATH') or exit; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Give Form widget |
@@ -31,18 +31,18 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function __construct() |
33 | 33 | { |
34 | - $this->self = get_class( $this ); |
|
34 | + $this->self = get_class($this); |
|
35 | 35 | |
36 | 36 | parent::__construct( |
37 | - strtolower( $this->self ), |
|
38 | - esc_html__( 'Give - Donation Form', 'give' ), |
|
37 | + strtolower($this->self), |
|
38 | + esc_html__('Give - Donation Form', 'give'), |
|
39 | 39 | array( |
40 | - 'description' => esc_html__( 'Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give' ) |
|
40 | + 'description' => esc_html__('Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give') |
|
41 | 41 | ) |
42 | 42 | ); |
43 | 43 | |
44 | - add_action( 'widgets_init', array( $this, 'widget_init' ) ); |
|
45 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_widget_scripts' ) ); |
|
44 | + add_action('widgets_init', array($this, 'widget_init')); |
|
45 | + add_action('admin_enqueue_scripts', array($this, 'admin_widget_scripts')); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -52,24 +52,24 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return void |
54 | 54 | */ |
55 | - public function admin_widget_scripts( $hook ) |
|
55 | + public function admin_widget_scripts($hook) |
|
56 | 56 | { |
57 | 57 | // Directories of assets |
58 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
59 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
60 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
58 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
59 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
60 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
61 | 61 | |
62 | 62 | // Use minified libraries if SCRIPT_DEBUG is turned off |
63 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
63 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
64 | 64 | |
65 | 65 | // Widget Script |
66 | - if ( $hook == 'widgets.php' ) { |
|
66 | + if ($hook == 'widgets.php') { |
|
67 | 67 | |
68 | - wp_enqueue_style( 'give-qtip-css', $css_dir . 'jquery.qtip' . $suffix . '.css' ); |
|
68 | + wp_enqueue_style('give-qtip-css', $css_dir.'jquery.qtip'.$suffix.'.css'); |
|
69 | 69 | |
70 | - wp_enqueue_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
70 | + wp_enqueue_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
71 | 71 | |
72 | - wp_enqueue_script( 'give-admin-widgets-scripts', $js_dir . 'admin-widgets' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
72 | + wp_enqueue_script('give-admin-widgets-scripts', $js_dir.'admin-widgets'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
@@ -80,24 +80,24 @@ discard block |
||
80 | 80 | * before_widget, and after_widget. |
81 | 81 | * @param array $instance The settings for the particular instance of the widget. |
82 | 82 | */ |
83 | - public function widget( $args, $instance ) |
|
83 | + public function widget($args, $instance) |
|
84 | 84 | { |
85 | - extract( $args ); |
|
85 | + extract($args); |
|
86 | 86 | |
87 | - $title = !empty( $instance['title'] ) ? $instance['title'] : ''; |
|
88 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
87 | + $title = ! empty($instance['title']) ? $instance['title'] : ''; |
|
88 | + $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
|
89 | 89 | |
90 | 90 | echo $before_widget; |
91 | 91 | |
92 | - do_action( 'give_before_forms_widget' ); |
|
92 | + do_action('give_before_forms_widget'); |
|
93 | 93 | |
94 | - echo $title ? $before_title . $title . $after_title : ''; |
|
94 | + echo $title ? $before_title.$title.$after_title : ''; |
|
95 | 95 | |
96 | - give_get_donation_form( $instance ); |
|
96 | + give_get_donation_form($instance); |
|
97 | 97 | |
98 | 98 | echo $after_widget; |
99 | 99 | |
100 | - do_action( 'give_after_forms_widget' ); |
|
100 | + do_action('give_after_forms_widget'); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return string |
109 | 109 | */ |
110 | - public function form( $instance ) |
|
110 | + public function form($instance) |
|
111 | 111 | { |
112 | 112 | $defaults = array( |
113 | 113 | 'title' => '', |
@@ -115,61 +115,61 @@ discard block |
||
115 | 115 | 'float_labels' => '', |
116 | 116 | ); |
117 | 117 | |
118 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
118 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
119 | 119 | |
120 | - extract( $instance ); |
|
120 | + extract($instance); |
|
121 | 121 | |
122 | 122 | // Query Give Forms |
123 | 123 | |
124 | 124 | $args = array( |
125 | 125 | 'post_type' => 'give_forms', |
126 | - 'posts_per_page' => - 1, |
|
126 | + 'posts_per_page' => -1, |
|
127 | 127 | 'post_status' => 'publish', |
128 | 128 | ); |
129 | 129 | |
130 | - $give_forms = get_posts( $args ); |
|
130 | + $give_forms = get_posts($args); |
|
131 | 131 | |
132 | 132 | // Widget: Title |
133 | 133 | |
134 | 134 | ?><p> |
135 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ); ?></label> |
|
136 | - <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php esc_attr_e( $title ); ?>" /><br> |
|
137 | - <small><?php esc_html_e( 'Leave blank to hide the widget title.', 'give' ); ?></small> |
|
135 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give'); ?></label> |
|
136 | + <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php esc_attr_e($title); ?>" /><br> |
|
137 | + <small><?php esc_html_e('Leave blank to hide the widget title.', 'give'); ?></small> |
|
138 | 138 | </p><?php |
139 | 139 | |
140 | 140 | // Widget: Give Form |
141 | 141 | |
142 | 142 | ?><p> |
143 | - <label for="<?php esc_attr_e( $this->get_field_id( 'id' ) ); ?>"><?php |
|
143 | + <label for="<?php esc_attr_e($this->get_field_id('id')); ?>"><?php |
|
144 | 144 | printf( |
145 | 145 | /* translators: %s: form singular label */ |
146 | - esc_html__( 'Give %s:', 'give' ), |
|
146 | + esc_html__('Give %s:', 'give'), |
|
147 | 147 | give_get_forms_label_singular() |
148 | 148 | ); |
149 | 149 | ?></label> |
150 | - <select class="widefat" name="<?php esc_attr_e( $this->get_field_name( 'id' ) ); ?>" id="<?php esc_attr_e( $this->get_field_id( 'id' ) ); ?>"> |
|
151 | - <option value="current"><?php esc_html_e( '— Select —', 'give' ); ?></option> |
|
152 | - <?php foreach ( $give_forms as $give_form ) { ?> |
|
153 | - <option <?php selected( absint( $id ), $give_form->ID ); ?> value="<?php esc_attr_e( $give_form->ID ); ?>"><?php echo $give_form->post_title; ?></option> |
|
150 | + <select class="widefat" name="<?php esc_attr_e($this->get_field_name('id')); ?>" id="<?php esc_attr_e($this->get_field_id('id')); ?>"> |
|
151 | + <option value="current"><?php esc_html_e('— Select —', 'give'); ?></option> |
|
152 | + <?php foreach ($give_forms as $give_form) { ?> |
|
153 | + <option <?php selected(absint($id), $give_form->ID); ?> value="<?php esc_attr_e($give_form->ID); ?>"><?php echo $give_form->post_title; ?></option> |
|
154 | 154 | <?php } ?> |
155 | 155 | </select><br> |
156 | - <small><?php esc_html_e( 'Select a Give Form to embed in this widget.', 'give' ); ?></small> |
|
156 | + <small><?php esc_html_e('Select a Give Form to embed in this widget.', 'give'); ?></small> |
|
157 | 157 | </p><?php |
158 | 158 | |
159 | 159 | // Widget: Floating Labels |
160 | 160 | |
161 | 161 | ?><p> |
162 | - <label for="<?php esc_attr_e( $this->get_field_id( 'float_labels' ) ); ?>"><?php esc_html_e( 'Floating Labels (optional):', 'give' ); ?></label> |
|
163 | - <select class="widefat" name="<?php esc_attr_e( $this->get_field_name( 'float_labels' ) ); ?>" id="<?php esc_attr_e( $this->get_field_id( 'float_labels' ) ); ?>"> |
|
164 | - <option value="" <?php selected( esc_attr__( $float_labels ), '' ) ?>><?php esc_html_e( '- Select -', 'give' ); ?></option> |
|
165 | - <option value="enabled" <?php selected( esc_attr__( $float_labels ), 'enabled' ) ?>><?php esc_html_e( 'Enabled', 'give' ); ?></option> |
|
166 | - <option value="disabled" <?php selected( esc_attr__( $float_labels ), 'disabled' ) ?>><?php esc_html_e( 'Disabled', 'give' ); ?></option> |
|
162 | + <label for="<?php esc_attr_e($this->get_field_id('float_labels')); ?>"><?php esc_html_e('Floating Labels (optional):', 'give'); ?></label> |
|
163 | + <select class="widefat" name="<?php esc_attr_e($this->get_field_name('float_labels')); ?>" id="<?php esc_attr_e($this->get_field_id('float_labels')); ?>"> |
|
164 | + <option value="" <?php selected(esc_attr__($float_labels), '') ?>><?php esc_html_e('- Select -', 'give'); ?></option> |
|
165 | + <option value="enabled" <?php selected(esc_attr__($float_labels), 'enabled') ?>><?php esc_html_e('Enabled', 'give'); ?></option> |
|
166 | + <option value="disabled" <?php selected(esc_attr__($float_labels), 'disabled') ?>><?php esc_html_e('Disabled', 'give'); ?></option> |
|
167 | 167 | </select><br> |
168 | 168 | <small><?php |
169 | 169 | printf( |
170 | 170 | /* translators: %s: http://bradfrost.com/blog/post/float-label-pattern/ */ |
171 | - __( 'Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give' ), |
|
172 | - esc_url( 'http://bradfrost.com/blog/post/float-label-pattern/' ) |
|
171 | + __('Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give'), |
|
172 | + esc_url('http://bradfrost.com/blog/post/float-label-pattern/') |
|
173 | 173 | ); |
174 | 174 | ?></small> |
175 | 175 | </p><?php |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | function widget_init() |
184 | 184 | { |
185 | - register_widget( $this->self ); |
|
185 | + register_widget($this->self); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @return array |
195 | 195 | */ |
196 | - public function update( $new_instance, $old_instance ) |
|
196 | + public function update($new_instance, $old_instance) |
|
197 | 197 | { |
198 | 198 | $this->flush_widget_cache(); |
199 | 199 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public function flush_widget_cache() |
209 | 209 | { |
210 | - wp_cache_delete( $this->self, 'widget' ); |
|
210 | + wp_cache_delete($this->self, 'widget'); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 |
@@ -18,17 +18,17 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return array |
20 | 20 | */ |
21 | -function give_offline_register_gateway( $gateways ) { |
|
21 | +function give_offline_register_gateway($gateways) { |
|
22 | 22 | // Format: ID => Name |
23 | 23 | $gateways['offline'] = array( |
24 | - 'admin_label' => esc_html__( 'Offline Donation', 'give' ), |
|
25 | - 'checkout_label' => esc_html__( 'Offline Donation', 'give' ) |
|
24 | + 'admin_label' => esc_html__('Offline Donation', 'give'), |
|
25 | + 'checkout_label' => esc_html__('Offline Donation', 'give') |
|
26 | 26 | ); |
27 | 27 | |
28 | 28 | return $gateways; |
29 | 29 | } |
30 | 30 | |
31 | -add_filter( 'give_payment_gateways', 'give_offline_register_gateway', 1 ); |
|
31 | +add_filter('give_payment_gateways', 'give_offline_register_gateway', 1); |
|
32 | 32 | |
33 | 33 | |
34 | 34 | /** |
@@ -40,56 +40,56 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return void |
42 | 42 | */ |
43 | -function give_offline_payment_cc_form( $form_id ) { |
|
43 | +function give_offline_payment_cc_form($form_id) { |
|
44 | 44 | |
45 | - $post_offline_customization_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
46 | - $post_offline_instructions = get_post_meta( $form_id, '_give_offline_checkout_notes', true ); |
|
47 | - $global_offline_instruction = give_get_option( 'global_offline_donation_content' ); |
|
45 | + $post_offline_customization_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
46 | + $post_offline_instructions = get_post_meta($form_id, '_give_offline_checkout_notes', true); |
|
47 | + $global_offline_instruction = give_get_option('global_offline_donation_content'); |
|
48 | 48 | $offline_instructions = $global_offline_instruction; |
49 | 49 | |
50 | - if ( $post_offline_customization_option == 'yes' ) { |
|
50 | + if ($post_offline_customization_option == 'yes') { |
|
51 | 51 | $offline_instructions = $post_offline_instructions; |
52 | 52 | } |
53 | 53 | |
54 | 54 | |
55 | 55 | ob_start(); ?> |
56 | - <?php do_action( 'give_before_offline_info_fields', $form_id ); ?> |
|
56 | + <?php do_action('give_before_offline_info_fields', $form_id); ?> |
|
57 | 57 | <fieldset id="give_offline_payment_info"> |
58 | 58 | <?php |
59 | - $settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' ); |
|
59 | + $settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1'); |
|
60 | 60 | /* translators: %s: form settings url */ |
61 | - $offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( esc_html__( 'Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give' ), $settings_url ); |
|
62 | - echo wpautop( stripslashes( $offline_instructions ) ); |
|
61 | + $offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(esc_html__('Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give'), $settings_url); |
|
62 | + echo wpautop(stripslashes($offline_instructions)); |
|
63 | 63 | ?> |
64 | 64 | </fieldset> |
65 | - <?php do_action( 'give_after_offline_info_fields', $form_id ); ?> |
|
65 | + <?php do_action('give_after_offline_info_fields', $form_id); ?> |
|
66 | 66 | <?php |
67 | 67 | echo ob_get_clean(); |
68 | 68 | } |
69 | 69 | |
70 | -add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' ); |
|
70 | +add_action('give_offline_cc_form', 'give_offline_payment_cc_form'); |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Give Offline Billing Field |
74 | 74 | * |
75 | 75 | * @param $form_id |
76 | 76 | */ |
77 | -function give_offline_billing_fields( $form_id ) { |
|
77 | +function give_offline_billing_fields($form_id) { |
|
78 | 78 | //Enable Default CC fields (billing info) |
79 | - $post_offline_cc_fields = get_post_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true ); |
|
80 | - $post_offline_customize_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
79 | + $post_offline_cc_fields = get_post_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true); |
|
80 | + $post_offline_customize_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
81 | 81 | |
82 | - $global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' ); |
|
82 | + $global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields'); |
|
83 | 83 | |
84 | 84 | //Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options |
85 | - if ( $global_offline_cc_fields == 'on' && $post_offline_customize_option !== 'yes' ) { |
|
86 | - give_default_cc_address_fields( $form_id ); |
|
87 | - } elseif($post_offline_customize_option == 'yes' && $post_offline_cc_fields == 'on') { |
|
88 | - give_default_cc_address_fields( $form_id ); |
|
85 | + if ($global_offline_cc_fields == 'on' && $post_offline_customize_option !== 'yes') { |
|
86 | + give_default_cc_address_fields($form_id); |
|
87 | + } elseif ($post_offline_customize_option == 'yes' && $post_offline_cc_fields == 'on') { |
|
88 | + give_default_cc_address_fields($form_id); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | -add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 ); |
|
92 | +add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1); |
|
93 | 93 | |
94 | 94 | /** |
95 | 95 | * Process the payment |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return void |
102 | 102 | */ |
103 | -function give_offline_process_payment( $purchase_data ) { |
|
103 | +function give_offline_process_payment($purchase_data) { |
|
104 | 104 | |
105 | - $purchase_summary = give_get_purchase_summary( $purchase_data ); |
|
105 | + $purchase_summary = give_get_purchase_summary($purchase_data); |
|
106 | 106 | |
107 | 107 | // setup the payment details |
108 | 108 | $payment_data = array( |
109 | 109 | 'price' => $purchase_data['price'], |
110 | 110 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
111 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
112 | - 'give_price_id' => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '', |
|
111 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
112 | + 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
|
113 | 113 | 'date' => $purchase_data['date'], |
114 | 114 | 'user_email' => $purchase_data['user_email'], |
115 | 115 | 'purchase_key' => $purchase_data['purchase_key'], |
@@ -121,20 +121,20 @@ discard block |
||
121 | 121 | |
122 | 122 | |
123 | 123 | // record the pending payment |
124 | - $payment = give_insert_payment( $payment_data ); |
|
124 | + $payment = give_insert_payment($payment_data); |
|
125 | 125 | |
126 | - if ( $payment ) { |
|
127 | - give_offline_send_admin_notice( $payment ); |
|
128 | - give_offline_send_donor_instructions( $payment ); |
|
126 | + if ($payment) { |
|
127 | + give_offline_send_admin_notice($payment); |
|
128 | + give_offline_send_donor_instructions($payment); |
|
129 | 129 | give_send_to_success_page(); |
130 | 130 | } else { |
131 | 131 | // if errors are present, send the user back to the donation form so they can be corrected |
132 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
132 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | } |
136 | 136 | |
137 | -add_action( 'give_gateway_offline', 'give_offline_process_payment' ); |
|
137 | +add_action('give_gateway_offline', 'give_offline_process_payment'); |
|
138 | 138 | |
139 | 139 | |
140 | 140 | /** |
@@ -147,47 +147,47 @@ discard block |
||
147 | 147 | * @since 1.0 |
148 | 148 | * @return void |
149 | 149 | */ |
150 | -function give_offline_send_donor_instructions( $payment_id = 0 ) { |
|
150 | +function give_offline_send_donor_instructions($payment_id = 0) { |
|
151 | 151 | |
152 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
153 | - $post_offline_customization_option = get_post_meta( $payment_data['form_id'], '_give_customize_offline_donations', true ); |
|
152 | + $payment_data = give_get_payment_meta($payment_id); |
|
153 | + $post_offline_customization_option = get_post_meta($payment_data['form_id'], '_give_customize_offline_donations', true); |
|
154 | 154 | |
155 | 155 | //Customize email content depending on whether the single form has been customized |
156 | - $email_content = give_get_option( 'global_offline_donation_email' ); |
|
156 | + $email_content = give_get_option('global_offline_donation_email'); |
|
157 | 157 | |
158 | - if ( $post_offline_customization_option === 'yes' ) { |
|
159 | - $email_content = get_post_meta( $payment_data['form_id'], '_give_offline_donation_email', true ); |
|
158 | + if ($post_offline_customization_option === 'yes') { |
|
159 | + $email_content = get_post_meta($payment_data['form_id'], '_give_offline_donation_email', true); |
|
160 | 160 | } |
161 | 161 | |
162 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
163 | - $from_name = apply_filters( 'give_purchase_from_name', $from_name, $payment_id, $payment_data ); |
|
162 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
163 | + $from_name = apply_filters('give_purchase_from_name', $from_name, $payment_id, $payment_data); |
|
164 | 164 | |
165 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
166 | - $from_email = apply_filters( 'give_purchase_from_address', $from_email, $payment_id, $payment_data ); |
|
165 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
166 | + $from_email = apply_filters('give_purchase_from_address', $from_email, $payment_id, $payment_data); |
|
167 | 167 | |
168 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
168 | + $to_email = give_get_payment_user_email($payment_id); |
|
169 | 169 | |
170 | - $subject = give_get_option( 'offline_donation_subject', esc_html__( 'Offline Donation Instructions', 'give' ) ); |
|
171 | - if ( $post_offline_customization_option === 'yes' ) { |
|
172 | - $subject = get_post_meta( $payment_data['form_id'], '_give_offline_donation_subject', true ); |
|
170 | + $subject = give_get_option('offline_donation_subject', esc_html__('Offline Donation Instructions', 'give')); |
|
171 | + if ($post_offline_customization_option === 'yes') { |
|
172 | + $subject = get_post_meta($payment_data['form_id'], '_give_offline_donation_subject', true); |
|
173 | 173 | } |
174 | 174 | |
175 | - $subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
176 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
175 | + $subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
176 | + $subject = give_do_email_tags($subject, $payment_id); |
|
177 | 177 | |
178 | - $attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data ); |
|
179 | - $message = give_do_email_tags( $email_content, $payment_id ); |
|
178 | + $attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data); |
|
179 | + $message = give_do_email_tags($email_content, $payment_id); |
|
180 | 180 | |
181 | 181 | $emails = Give()->emails; |
182 | 182 | |
183 | - $emails->__set( 'from_name', $from_name ); |
|
184 | - $emails->__set( 'from_email', $from_email ); |
|
185 | - $emails->__set( 'heading', esc_html__( 'Offline Donation Instructions', 'give' ) ); |
|
183 | + $emails->__set('from_name', $from_name); |
|
184 | + $emails->__set('from_email', $from_email); |
|
185 | + $emails->__set('heading', esc_html__('Offline Donation Instructions', 'give')); |
|
186 | 186 | |
187 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
188 | - $emails->__set( 'headers', $headers ); |
|
187 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
188 | + $emails->__set('headers', $headers); |
|
189 | 189 | |
190 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
190 | + $emails->send($to_email, $subject, $message, $attachments); |
|
191 | 191 | |
192 | 192 | } |
193 | 193 | |
@@ -204,50 +204,50 @@ discard block |
||
204 | 204 | * @return void |
205 | 205 | * |
206 | 206 | */ |
207 | -function give_offline_send_admin_notice( $payment_id = 0 ) { |
|
207 | +function give_offline_send_admin_notice($payment_id = 0) { |
|
208 | 208 | |
209 | 209 | /* Send an email notification to the admin */ |
210 | 210 | $admin_email = give_get_admin_notice_emails(); |
211 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
211 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
212 | 212 | |
213 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
214 | - $user_data = get_userdata( $user_info['id'] ); |
|
213 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
214 | + $user_data = get_userdata($user_info['id']); |
|
215 | 215 | $name = $user_data->display_name; |
216 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
217 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
216 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
217 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
218 | 218 | } else { |
219 | 219 | $name = $user_info['email']; |
220 | 220 | } |
221 | 221 | |
222 | - $amount = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ); |
|
222 | + $amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))); |
|
223 | 223 | |
224 | - $admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', esc_html__( 'New Pending Donation', 'give' ), $payment_id ); |
|
224 | + $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', esc_html__('New Pending Donation', 'give'), $payment_id); |
|
225 | 225 | |
226 | - $admin_message = esc_html__( 'Dear Admin,', 'give' ) . "\n\n"; |
|
227 | - $admin_message .= esc_html__( 'An offline donation has been made on your website: ', 'give' ) . get_bloginfo( 'name' ) . ' '; |
|
228 | - $admin_message .= esc_html__( 'Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n"; |
|
226 | + $admin_message = esc_html__('Dear Admin,', 'give')."\n\n"; |
|
227 | + $admin_message .= esc_html__('An offline donation has been made on your website: ', 'give').get_bloginfo('name').' '; |
|
228 | + $admin_message .= esc_html__('Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n"; |
|
229 | 229 | |
230 | 230 | |
231 | - $admin_message .= '<strong>' . esc_html__( 'Donor: ', 'give' ) . '</strong>' . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n"; |
|
232 | - $admin_message .= '<strong>' . esc_html__( 'Amount: ', 'give' ) . '</strong>' . html_entity_decode( $amount, ENT_COMPAT, 'UTF-8' ) . "\n\n"; |
|
231 | + $admin_message .= '<strong>'.esc_html__('Donor: ', 'give').'</strong>'.html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n"; |
|
232 | + $admin_message .= '<strong>'.esc_html__('Amount: ', 'give').'</strong>'.html_entity_decode($amount, ENT_COMPAT, 'UTF-8')."\n\n"; |
|
233 | 233 | |
234 | 234 | $admin_message .= sprintf( |
235 | 235 | '<a href="%1$s">%2$s</a>', |
236 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ), |
|
237 | - esc_html__( 'Click Here to View and/or Update Donation Details', 'give' ) |
|
238 | - ) . "\n\n"; |
|
236 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment_id), |
|
237 | + esc_html__('Click Here to View and/or Update Donation Details', 'give') |
|
238 | + )."\n\n"; |
|
239 | 239 | |
240 | - $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
|
241 | - $attachments = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id ); |
|
242 | - $admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id ); |
|
240 | + $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id); |
|
241 | + $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id); |
|
242 | + $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id); |
|
243 | 243 | |
244 | 244 | //Send Email |
245 | 245 | $emails = Give()->emails; |
246 | - if ( ! empty( $admin_headers ) ) { |
|
247 | - $emails->__set( 'headers', $admin_headers ); |
|
246 | + if ( ! empty($admin_headers)) { |
|
247 | + $emails->__set('headers', $admin_headers); |
|
248 | 248 | } |
249 | 249 | |
250 | - $emails->send( $admin_email, $admin_subject, $admin_message, $attachments ); |
|
250 | + $emails->send($admin_email, $admin_subject, $admin_message, $attachments); |
|
251 | 251 | |
252 | 252 | } |
253 | 253 | |
@@ -258,15 +258,15 @@ discard block |
||
258 | 258 | * @since 1.0 |
259 | 259 | * @return array |
260 | 260 | */ |
261 | -function give_offline_add_settings( $settings ) { |
|
261 | +function give_offline_add_settings($settings) { |
|
262 | 262 | |
263 | 263 | //Vars |
264 | 264 | $prefix = '_give_'; |
265 | 265 | |
266 | - $is_gateway_active = give_is_gateway_active( 'offline' ); |
|
266 | + $is_gateway_active = give_is_gateway_active('offline'); |
|
267 | 267 | |
268 | 268 | //this gateway isn't active |
269 | - if ( ! $is_gateway_active ) { |
|
269 | + if ( ! $is_gateway_active) { |
|
270 | 270 | //return settings and bounce |
271 | 271 | return $settings; |
272 | 272 | } |
@@ -275,27 +275,27 @@ discard block |
||
275 | 275 | $check_settings = array( |
276 | 276 | |
277 | 277 | array( |
278 | - 'name' => esc_html__( 'Customize Offline Donations', 'give' ), |
|
279 | - 'desc' => esc_html__( 'If you would like to customize the donation instructions for this specific forms check this option.', 'give' ), |
|
280 | - 'id' => $prefix . 'customize_offline_donations', |
|
278 | + 'name' => esc_html__('Customize Offline Donations', 'give'), |
|
279 | + 'desc' => esc_html__('If you would like to customize the donation instructions for this specific forms check this option.', 'give'), |
|
280 | + 'id' => $prefix.'customize_offline_donations', |
|
281 | 281 | 'type' => 'radio_inline', |
282 | 282 | 'default' => 'no', |
283 | 283 | 'options' => array( |
284 | - 'yes' => esc_html__( 'Yes', 'give' ), |
|
285 | - 'no' => esc_html__( 'No', 'give' ), |
|
284 | + 'yes' => esc_html__('Yes', 'give'), |
|
285 | + 'no' => esc_html__('No', 'give'), |
|
286 | 286 | ), |
287 | 287 | ), |
288 | 288 | array( |
289 | - 'name' => esc_html__( 'Request Billing Information', 'give' ), |
|
290 | - 'desc' => esc_html__( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ), |
|
291 | - 'id' => $prefix . 'offline_donation_enable_billing_fields_single', |
|
289 | + 'name' => esc_html__('Request Billing Information', 'give'), |
|
290 | + 'desc' => esc_html__('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'), |
|
291 | + 'id' => $prefix.'offline_donation_enable_billing_fields_single', |
|
292 | 292 | 'row_classes' => 'give-subfield', |
293 | 293 | 'type' => 'checkbox' |
294 | 294 | ), |
295 | 295 | array( |
296 | - 'id' => $prefix . 'offline_checkout_notes', |
|
297 | - 'name' => esc_html__( 'Offline Donation Instructions', 'give' ), |
|
298 | - 'desc' => esc_html__( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
296 | + 'id' => $prefix.'offline_checkout_notes', |
|
297 | + 'name' => esc_html__('Offline Donation Instructions', 'give'), |
|
298 | + 'desc' => esc_html__('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
299 | 299 | 'default' => give_get_default_offline_donation_content(), |
300 | 300 | 'type' => 'wysiwyg', |
301 | 301 | 'row_classes' => 'give-subfield', |
@@ -304,17 +304,17 @@ discard block |
||
304 | 304 | ) |
305 | 305 | ), |
306 | 306 | array( |
307 | - 'id' => $prefix . 'offline_donation_subject', |
|
308 | - 'name' => esc_html__( 'Offline Donation Email Instructions Subject', 'give' ), |
|
309 | - 'desc' => esc_html__( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
310 | - 'default' => esc_html__( '{donation} - Offline Donation Instructions', 'give' ), |
|
307 | + 'id' => $prefix.'offline_donation_subject', |
|
308 | + 'name' => esc_html__('Offline Donation Email Instructions Subject', 'give'), |
|
309 | + 'desc' => esc_html__('Enter the subject line for the donation receipt email.', 'give'), |
|
310 | + 'default' => esc_html__('{donation} - Offline Donation Instructions', 'give'), |
|
311 | 311 | 'row_classes' => 'give-subfield', |
312 | 312 | 'type' => 'text' |
313 | 313 | ), |
314 | 314 | array( |
315 | - 'id' => $prefix . 'offline_donation_email', |
|
316 | - 'name' => esc_html__( 'Offline Donation Email Instructions', 'give' ), |
|
317 | - 'desc' => esc_html__( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
315 | + 'id' => $prefix.'offline_donation_email', |
|
316 | + 'name' => esc_html__('Offline Donation Email Instructions', 'give'), |
|
317 | + 'desc' => esc_html__('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
318 | 318 | 'default' => give_get_default_offline_donation_email_content(), |
319 | 319 | 'type' => 'wysiwyg', |
320 | 320 | 'row_classes' => 'give-subfield', |
@@ -324,10 +324,10 @@ discard block |
||
324 | 324 | ) |
325 | 325 | ); |
326 | 326 | |
327 | - return array_merge( $settings, $check_settings ); |
|
327 | + return array_merge($settings, $check_settings); |
|
328 | 328 | } |
329 | 329 | |
330 | -add_filter( 'give_forms_display_options_metabox_fields', 'give_offline_add_settings' ); |
|
330 | +add_filter('give_forms_display_options_metabox_fields', 'give_offline_add_settings'); |
|
331 | 331 | |
332 | 332 | |
333 | 333 | /** |
@@ -339,32 +339,32 @@ discard block |
||
339 | 339 | */ |
340 | 340 | function give_get_default_offline_donation_content() { |
341 | 341 | |
342 | - $sitename = get_bloginfo( 'sitename' ); |
|
342 | + $sitename = get_bloginfo('sitename'); |
|
343 | 343 | |
344 | - $default_text = '<p>' . esc_html__( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
344 | + $default_text = '<p>'.esc_html__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
345 | 345 | $default_text .= '<ol>'; |
346 | 346 | $default_text .= '<li>'; |
347 | 347 | $default_text .= sprintf( |
348 | 348 | /* translators: %s: site name */ |
349 | - esc_html__( 'Make a check payable to "%s"', 'give' ), |
|
349 | + esc_html__('Make a check payable to "%s"', 'give'), |
|
350 | 350 | $sitename |
351 | 351 | ); |
352 | 352 | $default_text .= '</li>'; |
353 | 353 | $default_text .= '<li>'; |
354 | 354 | $default_text .= sprintf( |
355 | 355 | /* translators: %s: site name */ |
356 | - esc_html__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
356 | + esc_html__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
357 | 357 | $sitename |
358 | 358 | ); |
359 | 359 | $default_text .= '</li>'; |
360 | - $default_text .= '<li>' . esc_html__( 'Please mail your check to:', 'give' ) . '</li>'; |
|
360 | + $default_text .= '<li>'.esc_html__('Please mail your check to:', 'give').'</li>'; |
|
361 | 361 | $default_text .= '</ol>'; |
362 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
362 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
363 | 363 | $default_text .= ' <em>123 G Street </em><br>'; |
364 | 364 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
365 | - $default_text .= '<p>' . esc_html__( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>'; |
|
365 | + $default_text .= '<p>'.esc_html__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>'; |
|
366 | 366 | |
367 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
367 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
368 | 368 | |
369 | 369 | } |
370 | 370 | |
@@ -377,33 +377,33 @@ discard block |
||
377 | 377 | */ |
378 | 378 | function give_get_default_offline_donation_email_content() { |
379 | 379 | |
380 | - $sitename = get_bloginfo( 'sitename' ); |
|
381 | - $default_text = '<p>' . esc_html__( 'Dear {name},', 'give' ) . '</p>'; |
|
382 | - $default_text .= '<p>' . esc_html__( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
380 | + $sitename = get_bloginfo('sitename'); |
|
381 | + $default_text = '<p>'.esc_html__('Dear {name},', 'give').'</p>'; |
|
382 | + $default_text .= '<p>'.esc_html__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
383 | 383 | $default_text .= '<ol>'; |
384 | 384 | $default_text .= '<li>'; |
385 | 385 | $default_text .= sprintf( |
386 | 386 | /* translators: %s: site name */ |
387 | - esc_html__( 'Make a check payable to "%s"', 'give' ), |
|
387 | + esc_html__('Make a check payable to "%s"', 'give'), |
|
388 | 388 | $sitename |
389 | 389 | ); |
390 | 390 | $default_text .= '</li>'; |
391 | 391 | $default_text .= '<li>'; |
392 | 392 | $default_text .= sprintf( |
393 | 393 | /* translators: %s: site name */ |
394 | - esc_html__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
394 | + esc_html__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
395 | 395 | $sitename |
396 | 396 | ); |
397 | 397 | $default_text .= '</li>'; |
398 | - $default_text .= '<li>' . esc_html__( 'Please mail your check to:', 'give' ) . '</li>'; |
|
398 | + $default_text .= '<li>'.esc_html__('Please mail your check to:', 'give').'</li>'; |
|
399 | 399 | $default_text .= '</ol>'; |
400 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
400 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
401 | 401 | $default_text .= ' <em>123 G Street </em><br>'; |
402 | 402 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
403 | - $default_text .= '<p>' . esc_html__( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>'; |
|
404 | - $default_text .= '<p>' . esc_html__( 'Sincerely,', 'give' ) . '</p>'; |
|
405 | - $default_text .= '<p>' . $sitename . '</p>'; |
|
403 | + $default_text .= '<p>'.esc_html__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>'; |
|
404 | + $default_text .= '<p>'.esc_html__('Sincerely,', 'give').'</p>'; |
|
405 | + $default_text .= '<p>'.$sitename.'</p>'; |
|
406 | 406 | |
407 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
407 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
408 | 408 | |
409 | 409 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.0 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @access private |
22 | 22 | * @since 1.0 |
23 | 23 | */ |
24 | -add_action( 'give_paypal_cc_form', '__return_false' ); |
|
24 | +add_action('give_paypal_cc_form', '__return_false'); |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Process PayPal Purchase |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return void |
34 | 34 | */ |
35 | -function give_process_paypal_purchase( $purchase_data ) { |
|
35 | +function give_process_paypal_purchase($purchase_data) { |
|
36 | 36 | |
37 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
38 | - wp_die( esc_html__( 'Nonce verification has failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
37 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
38 | + wp_die(esc_html__('Nonce verification has failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
39 | 39 | } |
40 | 40 | |
41 | - $form_id = intval( $purchase_data['post_data']['give-form-id'] ); |
|
41 | + $form_id = intval($purchase_data['post_data']['give-form-id']); |
|
42 | 42 | $price_id = isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : ''; |
43 | 43 | |
44 | 44 | // Collect payment data |
@@ -57,67 +57,67 @@ discard block |
||
57 | 57 | ); |
58 | 58 | |
59 | 59 | // Record the pending payment |
60 | - $payment = give_insert_payment( $payment_data ); |
|
60 | + $payment = give_insert_payment($payment_data); |
|
61 | 61 | |
62 | 62 | // Check payment |
63 | - if ( ! $payment ) { |
|
63 | + if ( ! $payment) { |
|
64 | 64 | // Record the error |
65 | 65 | give_record_gateway_error( |
66 | - esc_html__( 'Payment Error', 'give' ), |
|
66 | + esc_html__('Payment Error', 'give'), |
|
67 | 67 | sprintf( |
68 | 68 | /* translators: %s: payment data */ |
69 | - esc_html__( 'Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give' ), |
|
70 | - json_encode( $payment_data ) |
|
69 | + esc_html__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give'), |
|
70 | + json_encode($payment_data) |
|
71 | 71 | ), |
72 | 72 | $payment |
73 | 73 | ); |
74 | 74 | // Problems? send back |
75 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
75 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
76 | 76 | } else { |
77 | 77 | // Only send to PayPal if the pending payment is created successfully |
78 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
78 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
79 | 79 | |
80 | 80 | // Get the success url |
81 | - $return_url = add_query_arg( array( |
|
81 | + $return_url = add_query_arg(array( |
|
82 | 82 | 'payment-confirmation' => 'paypal', |
83 | 83 | 'payment-id' => $payment |
84 | 84 | |
85 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
85 | + ), get_permalink(give_get_option('success_page'))); |
|
86 | 86 | |
87 | 87 | // Get the PayPal redirect uri |
88 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
88 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
89 | 89 | |
90 | 90 | //Item name - pass level name if variable priced |
91 | 91 | $item_name = $purchase_data['post_data']['give-form-title']; |
92 | 92 | |
93 | 93 | //Verify has variable prices |
94 | - if ( give_has_variable_prices( $form_id ) && isset( $purchase_data['post_data']['give-price-id'] ) ) { |
|
94 | + if (give_has_variable_prices($form_id) && isset($purchase_data['post_data']['give-price-id'])) { |
|
95 | 95 | |
96 | - $item_price_level_text = give_get_price_option_name( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
96 | + $item_price_level_text = give_get_price_option_name($form_id, $purchase_data['post_data']['give-price-id']); |
|
97 | 97 | |
98 | - $price_level_amount = give_get_price_option_amount( $form_id, $purchase_data['post_data']['give-price-id'] ); |
|
98 | + $price_level_amount = give_get_price_option_amount($form_id, $purchase_data['post_data']['give-price-id']); |
|
99 | 99 | |
100 | 100 | //Donation given doesn't match selected level (must be a custom amount) |
101 | - if ( $price_level_amount != give_sanitize_amount( $purchase_data['price'] ) ) { |
|
102 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
101 | + if ($price_level_amount != give_sanitize_amount($purchase_data['price'])) { |
|
102 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
103 | 103 | //user custom amount text if any, fallback to default if not |
104 | - $item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ) ); |
|
104 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give')); |
|
105 | 105 | |
106 | 106 | } //Is there any donation level text? |
107 | - elseif ( ! empty( $item_price_level_text ) ) { |
|
108 | - $item_name .= ' - ' . $item_price_level_text; |
|
107 | + elseif ( ! empty($item_price_level_text)) { |
|
108 | + $item_name .= ' - '.$item_price_level_text; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | } //Single donation: Custom Amount |
112 | - elseif ( give_get_form_price( $form_id ) !== give_sanitize_amount( $purchase_data['price'] ) ) { |
|
113 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
112 | + elseif (give_get_form_price($form_id) !== give_sanitize_amount($purchase_data['price'])) { |
|
113 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
114 | 114 | //user custom amount text if any, fallback to default if not |
115 | - $item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ) ); |
|
115 | + $item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give')); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | // Setup PayPal arguments |
119 | 119 | $paypal_args = array( |
120 | - 'business' => give_get_option( 'paypal_email', false ), |
|
120 | + 'business' => give_get_option('paypal_email', false), |
|
121 | 121 | 'email' => $purchase_data['user_email'], |
122 | 122 | 'invoice' => $purchase_data['purchase_key'], |
123 | 123 | 'amount' => $purchase_data['price'], |
@@ -128,25 +128,25 @@ discard block |
||
128 | 128 | 'shipping' => '0', |
129 | 129 | 'no_note' => '1', |
130 | 130 | 'currency_code' => give_get_currency(), |
131 | - 'charset' => get_bloginfo( 'charset' ), |
|
131 | + 'charset' => get_bloginfo('charset'), |
|
132 | 132 | 'custom' => $payment, |
133 | 133 | 'rm' => '2', |
134 | 134 | 'return' => $return_url, |
135 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment ), |
|
135 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment), |
|
136 | 136 | 'notify_url' => $listener_url, |
137 | 137 | 'page_style' => give_get_paypal_page_style(), |
138 | - 'cbt' => get_bloginfo( 'name' ), |
|
138 | + 'cbt' => get_bloginfo('name'), |
|
139 | 139 | 'bn' => 'givewp_SP' |
140 | 140 | ); |
141 | 141 | |
142 | - if ( ! empty( $purchase_data['user_info']['address'] ) ) { |
|
142 | + if ( ! empty($purchase_data['user_info']['address'])) { |
|
143 | 143 | $paypal_args['address1'] = $purchase_data['user_info']['address']['line1']; |
144 | 144 | $paypal_args['address2'] = $purchase_data['user_info']['address']['line2']; |
145 | 145 | $paypal_args['city'] = $purchase_data['user_info']['address']['city']; |
146 | 146 | $paypal_args['country'] = $purchase_data['user_info']['address']['country']; |
147 | 147 | } |
148 | 148 | |
149 | - if ( give_get_option( 'paypal_button_type' ) === 'standard' ) { |
|
149 | + if (give_get_option('paypal_button_type') === 'standard') { |
|
150 | 150 | $paypal_extra_args = array( |
151 | 151 | 'cmd' => '_xclick', |
152 | 152 | ); |
@@ -156,23 +156,23 @@ discard block |
||
156 | 156 | ); |
157 | 157 | } |
158 | 158 | |
159 | - $paypal_args = array_merge( $paypal_extra_args, $paypal_args ); |
|
160 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $purchase_data ); |
|
159 | + $paypal_args = array_merge($paypal_extra_args, $paypal_args); |
|
160 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $purchase_data); |
|
161 | 161 | |
162 | 162 | // Build query |
163 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
163 | + $paypal_redirect .= http_build_query($paypal_args); |
|
164 | 164 | |
165 | 165 | // Fix for some sites that encode the entities |
166 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
166 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
167 | 167 | |
168 | 168 | // Redirect to PayPal |
169 | - wp_redirect( $paypal_redirect ); |
|
169 | + wp_redirect($paypal_redirect); |
|
170 | 170 | exit; |
171 | 171 | } |
172 | 172 | |
173 | 173 | } |
174 | 174 | |
175 | -add_action( 'give_gateway_paypal', 'give_process_paypal_purchase' ); |
|
175 | +add_action('give_gateway_paypal', 'give_process_paypal_purchase'); |
|
176 | 176 | |
177 | 177 | /** |
178 | 178 | * Listens for a PayPal IPN requests and then sends to the processing function |
@@ -182,12 +182,12 @@ discard block |
||
182 | 182 | */ |
183 | 183 | function give_listen_for_paypal_ipn() { |
184 | 184 | // Regular PayPal IPN |
185 | - if ( isset( $_GET['give-listener'] ) && $_GET['give-listener'] == 'IPN' ) { |
|
186 | - do_action( 'give_verify_paypal_ipn' ); |
|
185 | + if (isset($_GET['give-listener']) && $_GET['give-listener'] == 'IPN') { |
|
186 | + do_action('give_verify_paypal_ipn'); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
190 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
191 | 191 | |
192 | 192 | /** |
193 | 193 | * Process PayPal IPN |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | function give_process_paypal_ipn() { |
199 | 199 | |
200 | 200 | // Check the request method is POST |
201 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
201 | + if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') { |
|
202 | 202 | return; |
203 | 203 | } |
204 | 204 | |
@@ -206,11 +206,11 @@ discard block |
||
206 | 206 | $post_data = ''; |
207 | 207 | |
208 | 208 | // Fallback just in case post_max_size is lower than needed |
209 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
210 | - $post_data = file_get_contents( 'php://input' ); |
|
209 | + if (ini_get('allow_url_fopen')) { |
|
210 | + $post_data = file_get_contents('php://input'); |
|
211 | 211 | } else { |
212 | 212 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
213 | - ini_set( 'post_max_size', '12M' ); |
|
213 | + ini_set('post_max_size', '12M'); |
|
214 | 214 | } |
215 | 215 | // Start the encoded data collection with notification command |
216 | 216 | $encoded_data = 'cmd=_notify-validate'; |
@@ -219,40 +219,40 @@ discard block |
||
219 | 219 | $arg_separator = give_get_php_arg_separator_output(); |
220 | 220 | |
221 | 221 | // Verify there is a post_data |
222 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
222 | + if ($post_data || strlen($post_data) > 0) { |
|
223 | 223 | // Append the data |
224 | - $encoded_data .= $arg_separator . $post_data; |
|
224 | + $encoded_data .= $arg_separator.$post_data; |
|
225 | 225 | } else { |
226 | 226 | // Check if POST is empty |
227 | - if ( empty( $_POST ) ) { |
|
227 | + if (empty($_POST)) { |
|
228 | 228 | // Nothing to do |
229 | 229 | return; |
230 | 230 | } else { |
231 | 231 | // Loop through each POST |
232 | - foreach ( $_POST as $key => $value ) { |
|
232 | + foreach ($_POST as $key => $value) { |
|
233 | 233 | // Encode the value and append the data |
234 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
234 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
239 | 239 | // Convert collected post data to an array |
240 | - parse_str( $encoded_data, $encoded_data_array ); |
|
240 | + parse_str($encoded_data, $encoded_data_array); |
|
241 | 241 | |
242 | - foreach ( $encoded_data_array as $key => $value ) { |
|
242 | + foreach ($encoded_data_array as $key => $value) { |
|
243 | 243 | |
244 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
245 | - $new_key = str_replace( '&', '&', $key ); |
|
246 | - $new_key = str_replace( 'amp;', '&' , $new_key ); |
|
244 | + if (false !== strpos($key, 'amp;')) { |
|
245 | + $new_key = str_replace('&', '&', $key); |
|
246 | + $new_key = str_replace('amp;', '&', $new_key); |
|
247 | 247 | |
248 | - unset( $encoded_data_array[ $key ] ); |
|
249 | - $encoded_data_array[ $new_key ] = $value; |
|
248 | + unset($encoded_data_array[$key]); |
|
249 | + $encoded_data_array[$new_key] = $value; |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | } |
253 | 253 | |
254 | 254 | //Validate IPN request w/ PayPal if user hasn't disabled this security measure |
255 | - if ( ! give_get_option( 'disable_paypal_verification' ) ) { |
|
255 | + if ( ! give_get_option('disable_paypal_verification')) { |
|
256 | 256 | |
257 | 257 | $remote_post_vars = array( |
258 | 258 | 'method' => 'POST', |
@@ -272,27 +272,27 @@ discard block |
||
272 | 272 | ); |
273 | 273 | |
274 | 274 | // Validate the IPN |
275 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
275 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
276 | 276 | |
277 | - if ( is_wp_error( $api_response ) ) { |
|
277 | + if (is_wp_error($api_response)) { |
|
278 | 278 | give_record_gateway_error( |
279 | - esc_html__( 'IPN Error', 'give' ), |
|
279 | + esc_html__('IPN Error', 'give'), |
|
280 | 280 | sprintf( |
281 | 281 | /* translators: %s: Paypal IPN response */ |
282 | - esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ), |
|
283 | - json_encode( $api_response ) |
|
282 | + esc_html__('Invalid IPN verification response. IPN data: %s', 'give'), |
|
283 | + json_encode($api_response) |
|
284 | 284 | ) |
285 | 285 | ); |
286 | 286 | return; // Something went wrong |
287 | 287 | } |
288 | 288 | |
289 | - if ( $api_response['body'] !== 'VERIFIED' && give_get_option( 'disable_paypal_verification', false ) ) { |
|
289 | + if ($api_response['body'] !== 'VERIFIED' && give_get_option('disable_paypal_verification', false)) { |
|
290 | 290 | give_record_gateway_error( |
291 | - esc_html__( 'IPN Error', 'give' ), |
|
291 | + esc_html__('IPN Error', 'give'), |
|
292 | 292 | sprintf( |
293 | 293 | /* translators: %s: Paypal IPN response */ |
294 | - esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ), |
|
295 | - json_encode( $api_response ) |
|
294 | + esc_html__('Invalid IPN verification response. IPN data: %s', 'give'), |
|
295 | + json_encode($api_response) |
|
296 | 296 | ) |
297 | 297 | ); |
298 | 298 | return; // Response not okay |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | } |
302 | 302 | |
303 | 303 | // Check if $post_data_array has been populated |
304 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
304 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
305 | 305 | return; |
306 | 306 | } |
307 | 307 | |
@@ -310,21 +310,21 @@ discard block |
||
310 | 310 | 'payment_status' => '' |
311 | 311 | ); |
312 | 312 | |
313 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
313 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
314 | 314 | |
315 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
315 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
316 | 316 | |
317 | - if ( has_action( 'give_paypal_' . $encoded_data_array['txn_type'] ) ) { |
|
317 | + if (has_action('give_paypal_'.$encoded_data_array['txn_type'])) { |
|
318 | 318 | // Allow PayPal IPN types to be processed separately |
319 | - do_action( 'give_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $payment_id ); |
|
319 | + do_action('give_paypal_'.$encoded_data_array['txn_type'], $encoded_data_array, $payment_id); |
|
320 | 320 | } else { |
321 | 321 | // Fallback to web accept just in case the txn_type isn't present |
322 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
322 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
323 | 323 | } |
324 | 324 | exit; |
325 | 325 | } |
326 | 326 | |
327 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
327 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
328 | 328 | |
329 | 329 | /** |
330 | 330 | * Process web accept (one time) payment IPNs |
@@ -335,224 +335,224 @@ discard block |
||
335 | 335 | * |
336 | 336 | * @return void |
337 | 337 | */ |
338 | -function give_process_paypal_web_accept_and_cart( $data, $payment_id ) { |
|
338 | +function give_process_paypal_web_accept_and_cart($data, $payment_id) { |
|
339 | 339 | |
340 | - if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) { |
|
340 | + if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') { |
|
341 | 341 | return; |
342 | 342 | } |
343 | 343 | |
344 | - if ( empty( $payment_id ) ) { |
|
344 | + if (empty($payment_id)) { |
|
345 | 345 | return; |
346 | 346 | } |
347 | 347 | |
348 | 348 | // Collect payment details |
349 | - $purchase_key = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number']; |
|
349 | + $purchase_key = isset($data['invoice']) ? $data['invoice'] : $data['item_number']; |
|
350 | 350 | $paypal_amount = $data['mc_gross']; |
351 | - $payment_status = strtolower( $data['payment_status'] ); |
|
352 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
353 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
354 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
351 | + $payment_status = strtolower($data['payment_status']); |
|
352 | + $currency_code = strtolower($data['mc_currency']); |
|
353 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
354 | + $payment_meta = give_get_payment_meta($payment_id); |
|
355 | 355 | |
356 | 356 | |
357 | - if ( give_get_payment_gateway( $payment_id ) != 'paypal' ) { |
|
357 | + if (give_get_payment_gateway($payment_id) != 'paypal') { |
|
358 | 358 | return; // this isn't a PayPal standard IPN |
359 | 359 | } |
360 | 360 | |
361 | 361 | // Verify payment recipient |
362 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) != 0 ) { |
|
362 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) != 0) { |
|
363 | 363 | |
364 | 364 | give_record_gateway_error( |
365 | - esc_html__( 'IPN Error', 'give' ), |
|
365 | + esc_html__('IPN Error', 'give'), |
|
366 | 366 | sprintf( |
367 | 367 | /* translators: %s: Paypal IPN response */ |
368 | - esc_html__( 'Invalid business email in IPN response. IPN data: %s', 'give' ), |
|
369 | - json_encode( $data ) |
|
368 | + esc_html__('Invalid business email in IPN response. IPN data: %s', 'give'), |
|
369 | + json_encode($data) |
|
370 | 370 | ), |
371 | 371 | $payment_id |
372 | 372 | ); |
373 | - give_update_payment_status( $payment_id, 'failed' ); |
|
374 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
373 | + give_update_payment_status($payment_id, 'failed'); |
|
374 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid PayPal business email.', 'give')); |
|
375 | 375 | |
376 | 376 | return; |
377 | 377 | } |
378 | 378 | |
379 | 379 | // Verify payment currency |
380 | - if ( $currency_code != strtolower( $payment_meta['currency'] ) ) { |
|
380 | + if ($currency_code != strtolower($payment_meta['currency'])) { |
|
381 | 381 | |
382 | 382 | give_record_gateway_error( |
383 | - esc_html__( 'IPN Error', 'give' ), |
|
383 | + esc_html__('IPN Error', 'give'), |
|
384 | 384 | sprintf( |
385 | 385 | /* translators: %s: Paypal IPN response */ |
386 | - esc_html__( 'Invalid currency in IPN response. IPN data: %s', 'give' ), |
|
387 | - json_encode( $data ) |
|
386 | + esc_html__('Invalid currency in IPN response. IPN data: %s', 'give'), |
|
387 | + json_encode($data) |
|
388 | 388 | ), |
389 | 389 | $payment_id |
390 | 390 | ); |
391 | - give_update_payment_status( $payment_id, 'failed' ); |
|
392 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
391 | + give_update_payment_status($payment_id, 'failed'); |
|
392 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
393 | 393 | |
394 | 394 | return; |
395 | 395 | } |
396 | 396 | |
397 | - if ( ! give_get_payment_user_email( $payment_id ) ) { |
|
397 | + if ( ! give_get_payment_user_email($payment_id)) { |
|
398 | 398 | |
399 | 399 | // No email associated with purchase, so store from PayPal |
400 | - give_update_payment_meta( $payment_id, '_give_payment_user_email', $data['payer_email'] ); |
|
400 | + give_update_payment_meta($payment_id, '_give_payment_user_email', $data['payer_email']); |
|
401 | 401 | |
402 | 402 | // Setup and store the donors's details |
403 | 403 | $address = array(); |
404 | - $address['line1'] = ! empty( $data['address_street'] ) ? sanitize_text_field( $data['address_street'] ) : false; |
|
405 | - $address['city'] = ! empty( $data['address_city'] ) ? sanitize_text_field( $data['address_city'] ) : false; |
|
406 | - $address['state'] = ! empty( $data['address_state'] ) ? sanitize_text_field( $data['address_state'] ) : false; |
|
407 | - $address['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false; |
|
408 | - $address['zip'] = ! empty( $data['address_zip'] ) ? sanitize_text_field( $data['address_zip'] ) : false; |
|
404 | + $address['line1'] = ! empty($data['address_street']) ? sanitize_text_field($data['address_street']) : false; |
|
405 | + $address['city'] = ! empty($data['address_city']) ? sanitize_text_field($data['address_city']) : false; |
|
406 | + $address['state'] = ! empty($data['address_state']) ? sanitize_text_field($data['address_state']) : false; |
|
407 | + $address['country'] = ! empty($data['address_country_code']) ? sanitize_text_field($data['address_country_code']) : false; |
|
408 | + $address['zip'] = ! empty($data['address_zip']) ? sanitize_text_field($data['address_zip']) : false; |
|
409 | 409 | |
410 | 410 | $user_info = array( |
411 | 411 | 'id' => '-1', |
412 | - 'email' => sanitize_text_field( $data['payer_email'] ), |
|
413 | - 'first_name' => sanitize_text_field( $data['first_name'] ), |
|
414 | - 'last_name' => sanitize_text_field( $data['last_name'] ), |
|
412 | + 'email' => sanitize_text_field($data['payer_email']), |
|
413 | + 'first_name' => sanitize_text_field($data['first_name']), |
|
414 | + 'last_name' => sanitize_text_field($data['last_name']), |
|
415 | 415 | 'discount' => '', |
416 | 416 | 'address' => $address |
417 | 417 | ); |
418 | 418 | |
419 | 419 | $payment_meta['user_info'] = $user_info; |
420 | - give_update_payment_meta( $payment_id, '_give_payment_meta', $payment_meta ); |
|
420 | + give_update_payment_meta($payment_id, '_give_payment_meta', $payment_meta); |
|
421 | 421 | } |
422 | 422 | |
423 | - if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
423 | + if ($payment_status == 'refunded' || $payment_status == 'reversed') { |
|
424 | 424 | |
425 | 425 | // Process a refund |
426 | - give_process_paypal_refund( $data, $payment_id ); |
|
426 | + give_process_paypal_refund($data, $payment_id); |
|
427 | 427 | |
428 | 428 | } else { |
429 | 429 | |
430 | - if ( get_post_status( $payment_id ) == 'publish' ) { |
|
430 | + if (get_post_status($payment_id) == 'publish') { |
|
431 | 431 | return; // Only complete payments once |
432 | 432 | } |
433 | 433 | |
434 | 434 | // Retrieve the total purchase amount (before PayPal) |
435 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
435 | + $payment_amount = give_get_payment_amount($payment_id); |
|
436 | 436 | |
437 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
437 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
438 | 438 | // The prices don't match |
439 | 439 | give_record_gateway_error( |
440 | - esc_html__( 'IPN Error', 'give' ), |
|
440 | + esc_html__('IPN Error', 'give'), |
|
441 | 441 | sprintf( |
442 | 442 | /* translators: %s: Paypal IPN response */ |
443 | - esc_html__( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), |
|
444 | - json_encode( $data ) |
|
443 | + esc_html__('Invalid payment amount in IPN response. IPN data: %s', 'give'), |
|
444 | + json_encode($data) |
|
445 | 445 | ), |
446 | 446 | $payment_id |
447 | 447 | ); |
448 | - give_update_payment_status( $payment_id, 'failed' ); |
|
449 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
448 | + give_update_payment_status($payment_id, 'failed'); |
|
449 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
450 | 450 | |
451 | 451 | return; |
452 | 452 | } |
453 | - if ( $purchase_key != give_get_payment_key( $payment_id ) ) { |
|
453 | + if ($purchase_key != give_get_payment_key($payment_id)) { |
|
454 | 454 | // Purchase keys don't match |
455 | 455 | give_record_gateway_error( |
456 | - esc_html__( 'IPN Error', 'give' ), |
|
456 | + esc_html__('IPN Error', 'give'), |
|
457 | 457 | sprintf( |
458 | 458 | /* translators: %s: Paypal IPN response */ |
459 | - esc_html__( 'Invalid purchase key in IPN response. IPN data: %s', 'give' ), |
|
460 | - json_encode( $data ) |
|
459 | + esc_html__('Invalid purchase key in IPN response. IPN data: %s', 'give'), |
|
460 | + json_encode($data) |
|
461 | 461 | ), |
462 | 462 | $payment_id |
463 | 463 | ); |
464 | - give_update_payment_status( $payment_id, 'failed' ); |
|
465 | - give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid purchase key in PayPal IPN.', 'give' ) ); |
|
464 | + give_update_payment_status($payment_id, 'failed'); |
|
465 | + give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid purchase key in PayPal IPN.', 'give')); |
|
466 | 466 | |
467 | 467 | return; |
468 | 468 | } |
469 | 469 | |
470 | - if ( $payment_status == 'completed' || give_is_test_mode() ) { |
|
470 | + if ($payment_status == 'completed' || give_is_test_mode()) { |
|
471 | 471 | give_insert_payment_note( |
472 | 472 | $payment_id, |
473 | 473 | sprintf( |
474 | 474 | /* translators: %s: Paypal transaction ID */ |
475 | - esc_html__( 'PayPal Transaction ID: %s', 'give' ), |
|
475 | + esc_html__('PayPal Transaction ID: %s', 'give'), |
|
476 | 476 | $data['txn_id'] |
477 | 477 | ) |
478 | 478 | ); |
479 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
480 | - give_update_payment_status( $payment_id, 'publish' ); |
|
481 | - } else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) { |
|
479 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
480 | + give_update_payment_status($payment_id, 'publish'); |
|
481 | + } else if ('pending' == $payment_status && isset($data['pending_reason'])) { |
|
482 | 482 | |
483 | 483 | // Look for possible pending reasons, such as an echeck |
484 | 484 | |
485 | 485 | $note = ''; |
486 | 486 | |
487 | - switch ( strtolower( $data['pending_reason'] ) ) { |
|
487 | + switch (strtolower($data['pending_reason'])) { |
|
488 | 488 | |
489 | 489 | case 'echeck' : |
490 | 490 | |
491 | - $note = esc_html__( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' ); |
|
491 | + $note = esc_html__('Payment made via eCheck and will clear automatically in 5-8 days.', 'give'); |
|
492 | 492 | |
493 | 493 | break; |
494 | 494 | |
495 | 495 | case 'address' : |
496 | 496 | |
497 | - $note = esc_html__( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' ); |
|
497 | + $note = esc_html__('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give'); |
|
498 | 498 | |
499 | 499 | break; |
500 | 500 | |
501 | 501 | case 'intl' : |
502 | 502 | |
503 | - $note = esc_html__( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' ); |
|
503 | + $note = esc_html__('Payment must be accepted manually through PayPal due to international account regulations.', 'give'); |
|
504 | 504 | |
505 | 505 | break; |
506 | 506 | |
507 | 507 | case 'multi-currency' : |
508 | 508 | |
509 | - $note = esc_html__( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' ); |
|
509 | + $note = esc_html__('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give'); |
|
510 | 510 | |
511 | 511 | break; |
512 | 512 | |
513 | 513 | case 'paymentreview' : |
514 | 514 | case 'regulatory_review' : |
515 | 515 | |
516 | - $note = esc_html__( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' ); |
|
516 | + $note = esc_html__('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give'); |
|
517 | 517 | |
518 | 518 | break; |
519 | 519 | |
520 | 520 | case 'unilateral' : |
521 | 521 | |
522 | - $note = esc_html__( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
522 | + $note = esc_html__('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
523 | 523 | |
524 | 524 | break; |
525 | 525 | |
526 | 526 | case 'upgrade' : |
527 | 527 | |
528 | - $note = esc_html__( 'PayPal account must be upgraded before this payment can be accepted.', 'give' ); |
|
528 | + $note = esc_html__('PayPal account must be upgraded before this payment can be accepted.', 'give'); |
|
529 | 529 | |
530 | 530 | break; |
531 | 531 | |
532 | 532 | case 'verify' : |
533 | 533 | |
534 | - $note = esc_html__( 'PayPal account is not verified. Verify account in order to accept this payment.', 'give' ); |
|
534 | + $note = esc_html__('PayPal account is not verified. Verify account in order to accept this payment.', 'give'); |
|
535 | 535 | |
536 | 536 | break; |
537 | 537 | |
538 | 538 | case 'other' : |
539 | 539 | |
540 | - $note = esc_html__( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' ); |
|
540 | + $note = esc_html__('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give'); |
|
541 | 541 | |
542 | 542 | break; |
543 | 543 | |
544 | 544 | } |
545 | 545 | |
546 | - if ( ! empty( $note ) ) { |
|
546 | + if ( ! empty($note)) { |
|
547 | 547 | |
548 | - give_insert_payment_note( $payment_id, $note ); |
|
548 | + give_insert_payment_note($payment_id, $note); |
|
549 | 549 | |
550 | 550 | } |
551 | 551 | } |
552 | 552 | } |
553 | 553 | } |
554 | 554 | |
555 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2 ); |
|
555 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2); |
|
556 | 556 | |
557 | 557 | /** |
558 | 558 | * Process PayPal IPN Refunds |
@@ -563,28 +563,28 @@ discard block |
||
563 | 563 | * |
564 | 564 | * @return void |
565 | 565 | */ |
566 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
566 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
567 | 567 | |
568 | 568 | // Collect payment details |
569 | 569 | |
570 | - if ( empty( $payment_id ) ) { |
|
570 | + if (empty($payment_id)) { |
|
571 | 571 | return; |
572 | 572 | } |
573 | 573 | |
574 | - if ( get_post_status( $payment_id ) == 'refunded' ) { |
|
574 | + if (get_post_status($payment_id) == 'refunded') { |
|
575 | 575 | return; // Only refund payments once |
576 | 576 | } |
577 | 577 | |
578 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
578 | + $payment_amount = give_get_payment_amount($payment_id); |
|
579 | 579 | $refund_amount = $data['payment_gross'] * - 1; |
580 | 580 | |
581 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
581 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
582 | 582 | |
583 | 583 | give_insert_payment_note( |
584 | 584 | $payment_id, |
585 | 585 | sprintf( |
586 | 586 | /* translators: %s: Paypal parent transaction ID */ |
587 | - esc_html__( 'Partial PayPal refund processed: %s', 'give' ), |
|
587 | + esc_html__('Partial PayPal refund processed: %s', 'give'), |
|
588 | 588 | $data['parent_txn_id'] |
589 | 589 | ) |
590 | 590 | ); |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | $payment_id, |
598 | 598 | sprintf( |
599 | 599 | /* translators: %s: Paypal parent transaction ID */ |
600 | - esc_html__( 'PayPal Payment #%s Refunded for reason: %s', 'give' ), |
|
600 | + esc_html__('PayPal Payment #%s Refunded for reason: %s', 'give'), |
|
601 | 601 | $data['parent_txn_id'], $data['reason_code'] |
602 | 602 | ) |
603 | 603 | ); |
@@ -605,11 +605,11 @@ discard block |
||
605 | 605 | $payment_id, |
606 | 606 | sprintf( |
607 | 607 | /* translators: %s: Paypal transaction ID */ |
608 | - esc_html__( 'PayPal Refund Transaction ID: %s', 'give' ), |
|
608 | + esc_html__('PayPal Refund Transaction ID: %s', 'give'), |
|
609 | 609 | $data['txn_id'] |
610 | 610 | ) |
611 | 611 | ); |
612 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
612 | + give_update_payment_status($payment_id, 'refunded'); |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | /** |
@@ -621,24 +621,24 @@ discard block |
||
621 | 621 | * |
622 | 622 | * @return string |
623 | 623 | */ |
624 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
624 | +function give_get_paypal_redirect($ssl_check = false) { |
|
625 | 625 | |
626 | - if ( is_ssl() || ! $ssl_check ) { |
|
626 | + if (is_ssl() || ! $ssl_check) { |
|
627 | 627 | $protocal = 'https://'; |
628 | 628 | } else { |
629 | 629 | $protocal = 'http://'; |
630 | 630 | } |
631 | 631 | |
632 | 632 | // Check the current payment mode |
633 | - if ( give_is_test_mode() ) { |
|
633 | + if (give_is_test_mode()) { |
|
634 | 634 | // Test mode |
635 | - $paypal_uri = $protocal . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
635 | + $paypal_uri = $protocal.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
636 | 636 | } else { |
637 | 637 | // Live mode |
638 | - $paypal_uri = $protocal . 'www.paypal.com/cgi-bin/webscr'; |
|
638 | + $paypal_uri = $protocal.'www.paypal.com/cgi-bin/webscr'; |
|
639 | 639 | } |
640 | 640 | |
641 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
641 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | /** |
@@ -648,8 +648,8 @@ discard block |
||
648 | 648 | * @return string |
649 | 649 | */ |
650 | 650 | function give_get_paypal_page_style() { |
651 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
652 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
651 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
652 | + return apply_filters('give_paypal_page_style', $page_style); |
|
653 | 653 | } |
654 | 654 | |
655 | 655 | /** |
@@ -664,27 +664,27 @@ discard block |
||
664 | 664 | * @return string |
665 | 665 | * |
666 | 666 | */ |
667 | -function give_paypal_success_page_content( $content ) { |
|
667 | +function give_paypal_success_page_content($content) { |
|
668 | 668 | |
669 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
669 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
670 | 670 | return $content; |
671 | 671 | } |
672 | 672 | |
673 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
673 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
674 | 674 | |
675 | - if ( ! $payment_id ) { |
|
675 | + if ( ! $payment_id) { |
|
676 | 676 | $session = give_get_purchase_session(); |
677 | - $payment_id = give_get_purchase_id_by_key( $session['purchase_key'] ); |
|
677 | + $payment_id = give_get_purchase_id_by_key($session['purchase_key']); |
|
678 | 678 | } |
679 | 679 | |
680 | - $payment = get_post( $payment_id ); |
|
680 | + $payment = get_post($payment_id); |
|
681 | 681 | |
682 | - if ( $payment && 'pending' == $payment->post_status ) { |
|
682 | + if ($payment && 'pending' == $payment->post_status) { |
|
683 | 683 | |
684 | 684 | // Payment is still pending so show processing indicator to fix the Race Condition |
685 | 685 | ob_start(); |
686 | 686 | |
687 | - give_get_template_part( 'payment', 'processing' ); |
|
687 | + give_get_template_part('payment', 'processing'); |
|
688 | 688 | |
689 | 689 | $content = ob_get_clean(); |
690 | 690 | |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | |
695 | 695 | } |
696 | 696 | |
697 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
697 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
698 | 698 | |
699 | 699 | /** |
700 | 700 | * Given a Payment ID, extract the transaction ID |
@@ -705,22 +705,22 @@ discard block |
||
705 | 705 | * |
706 | 706 | * @return string Transaction ID |
707 | 707 | */ |
708 | -function give_paypal_get_payment_transaction_id( $payment_id ) { |
|
708 | +function give_paypal_get_payment_transaction_id($payment_id) { |
|
709 | 709 | |
710 | 710 | $transaction_id = ''; |
711 | - $notes = give_get_payment_notes( $payment_id ); |
|
711 | + $notes = give_get_payment_notes($payment_id); |
|
712 | 712 | |
713 | - foreach ( $notes as $note ) { |
|
714 | - if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) { |
|
713 | + foreach ($notes as $note) { |
|
714 | + if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) { |
|
715 | 715 | $transaction_id = $match[1]; |
716 | 716 | continue; |
717 | 717 | } |
718 | 718 | } |
719 | 719 | |
720 | - return apply_filters( 'give_paypal_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
720 | + return apply_filters('give_paypal_set_payment_transaction_id', $transaction_id, $payment_id); |
|
721 | 721 | } |
722 | 722 | |
723 | -add_filter( 'give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1 ); |
|
723 | +add_filter('give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1); |
|
724 | 724 | |
725 | 725 | /** |
726 | 726 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -732,13 +732,13 @@ discard block |
||
732 | 732 | * |
733 | 733 | * @return string A link to the PayPal transaction details |
734 | 734 | */ |
735 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
735 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
736 | 736 | |
737 | 737 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
738 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
738 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
739 | 739 | |
740 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
740 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
741 | 741 | |
742 | 742 | } |
743 | 743 | |
744 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
744 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |
@@ -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 | |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param $data |
23 | 23 | */ |
24 | -function give_process_gateway_select( $data ) { |
|
25 | - if ( isset( $_POST['gateway_submit'] ) ) { |
|
26 | - wp_redirect( esc_url( add_query_arg( 'payment-mode', $_POST['payment-mode'] ) ) ); |
|
24 | +function give_process_gateway_select($data) { |
|
25 | + if (isset($_POST['gateway_submit'])) { |
|
26 | + wp_redirect(esc_url(add_query_arg('payment-mode', $_POST['payment-mode']))); |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
31 | -add_action( 'give_gateway_select', 'give_process_gateway_select' ); |
|
31 | +add_action('give_gateway_select', 'give_process_gateway_select'); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Loads a payment gateway via AJAX |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | * @return void |
38 | 38 | */ |
39 | 39 | function give_load_ajax_gateway() { |
40 | - if ( isset( $_POST['give_payment_mode'] ) ) { |
|
41 | - do_action( 'give_purchase_form', $_POST['give_form_id'] ); |
|
40 | + if (isset($_POST['give_payment_mode'])) { |
|
41 | + do_action('give_purchase_form', $_POST['give_form_id']); |
|
42 | 42 | exit(); |
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | -add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' ); |
|
47 | -add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' ); |
|
46 | +add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway'); |
|
47 | +add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway'); |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Sets an error on checkout if no gateways are enabled |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | function give_no_gateway_error() { |
56 | 56 | $gateways = give_get_enabled_payment_gateways(); |
57 | 57 | |
58 | - if ( empty( $gateways ) ) { |
|
59 | - give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) ); |
|
58 | + if (empty($gateways)) { |
|
59 | + give_set_error('no_gateways', esc_html__('You must enable a payment gateway to use Give.', 'give')); |
|
60 | 60 | } else { |
61 | - give_unset_error( 'no_gateways' ); |
|
61 | + give_unset_error('no_gateways'); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
65 | -add_action( 'init', 'give_no_gateway_error' ); |
|
66 | 65 | \ No newline at end of file |
66 | +add_action('init', 'give_no_gateway_error'); |
|
67 | 67 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @since 1.0 |
21 | 21 | * @return void |
22 | 22 | */ |
23 | -add_action( 'give_manual_cc_form', '__return_false' ); |
|
23 | +add_action('give_manual_cc_form', '__return_false'); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Processes the purchase data and uses the Manual Payment gateway to record |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return void |
34 | 34 | */ |
35 | -function give_manual_payment( $purchase_data ) { |
|
35 | +function give_manual_payment($purchase_data) { |
|
36 | 36 | |
37 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
38 | - wp_die( esc_html__( 'Nonce verification has failed', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
37 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
38 | + wp_die(esc_html__('Nonce verification has failed', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | //Create payment_data array |
42 | 42 | $payment_data = array( |
43 | 43 | 'price' => $purchase_data['price'], |
44 | 44 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
45 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
45 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
46 | 46 | 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
47 | 47 | 'date' => $purchase_data['date'], |
48 | 48 | 'user_email' => $purchase_data['user_email'], |
@@ -52,24 +52,24 @@ discard block |
||
52 | 52 | 'status' => 'pending' |
53 | 53 | ); |
54 | 54 | // Record the pending payment |
55 | - $payment = give_insert_payment( $payment_data ); |
|
55 | + $payment = give_insert_payment($payment_data); |
|
56 | 56 | |
57 | - if ( $payment ) { |
|
58 | - give_update_payment_status( $payment, 'publish' ); |
|
57 | + if ($payment) { |
|
58 | + give_update_payment_status($payment, 'publish'); |
|
59 | 59 | give_send_to_success_page(); |
60 | 60 | } else { |
61 | 61 | give_record_gateway_error( |
62 | - esc_html__( 'Payment Error', 'give' ), |
|
62 | + esc_html__('Payment Error', 'give'), |
|
63 | 63 | sprintf( |
64 | 64 | /* translators: %s: payment data */ |
65 | - esc_html__( 'The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give' ), |
|
66 | - json_encode( $payment_data ) |
|
65 | + esc_html__('The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give'), |
|
66 | + json_encode($payment_data) |
|
67 | 67 | ), |
68 | 68 | $payment |
69 | 69 | ); |
70 | 70 | // If errors are present, send the user back to the purchase page so they can be corrected |
71 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
71 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | -add_action( 'give_gateway_manual', 'give_manual_payment' ); |
|
75 | +add_action('give_gateway_manual', 'give_manual_payment'); |
@@ -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 | |
@@ -28,94 +28,94 @@ discard block |
||
28 | 28 | |
29 | 29 | global $give_options; |
30 | 30 | |
31 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/frontend/'; |
|
32 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
33 | - $scripts_footer = ( give_get_option( 'scripts_footer' ) == 'on' ) ? true : false; |
|
31 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/frontend/'; |
|
32 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
33 | + $scripts_footer = (give_get_option('scripts_footer') == 'on') ? true : false; |
|
34 | 34 | |
35 | 35 | // Use minified libraries if SCRIPT_DEBUG is turned off |
36 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
36 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
37 | 37 | |
38 | 38 | //Localize / PHP to AJAX vars |
39 | - $localize_give_checkout = apply_filters( 'give_global_script_vars', array( |
|
39 | + $localize_give_checkout = apply_filters('give_global_script_vars', array( |
|
40 | 40 | 'ajaxurl' => give_get_ajax_url(), |
41 | - 'checkout_nonce' => wp_create_nonce( 'give_checkout_nonce' ), |
|
42 | - 'currency_sign' => give_currency_filter( '' ), |
|
41 | + 'checkout_nonce' => wp_create_nonce('give_checkout_nonce'), |
|
42 | + 'currency_sign' => give_currency_filter(''), |
|
43 | 43 | 'currency_pos' => give_get_currency_position(), |
44 | - 'thousands_separator' => isset( $give_options['thousands_separator'] ) ? $give_options['thousands_separator'] : ',', |
|
45 | - 'decimal_separator' => isset( $give_options['decimal_separator'] ) ? $give_options['decimal_separator'] : '.', |
|
46 | - 'no_gateway' => esc_html__( 'Please select a payment method.', 'give' ), |
|
47 | - 'bad_minimum' => esc_html__( 'The minimum donation amount for this form is', 'give' ), |
|
48 | - 'general_loading' => esc_html__( 'Loading...', 'give' ), |
|
49 | - 'purchase_loading' => esc_html__( 'Please Wait...', 'give' ), |
|
50 | - 'number_decimals' => apply_filters( 'give_format_amount_decimals', 2 ), |
|
44 | + 'thousands_separator' => isset($give_options['thousands_separator']) ? $give_options['thousands_separator'] : ',', |
|
45 | + 'decimal_separator' => isset($give_options['decimal_separator']) ? $give_options['decimal_separator'] : '.', |
|
46 | + 'no_gateway' => esc_html__('Please select a payment method.', 'give'), |
|
47 | + 'bad_minimum' => esc_html__('The minimum donation amount for this form is', 'give'), |
|
48 | + 'general_loading' => esc_html__('Loading...', 'give'), |
|
49 | + 'purchase_loading' => esc_html__('Please Wait...', 'give'), |
|
50 | + 'number_decimals' => apply_filters('give_format_amount_decimals', 2), |
|
51 | 51 | 'give_version' => GIVE_VERSION |
52 | - ) ); |
|
53 | - $localize_give_ajax = apply_filters( 'give_global_ajax_vars', array( |
|
52 | + )); |
|
53 | + $localize_give_ajax = apply_filters('give_global_ajax_vars', array( |
|
54 | 54 | 'ajaxurl' => give_get_ajax_url(), |
55 | - 'loading' => esc_html__( 'Loading', 'give' ), |
|
55 | + 'loading' => esc_html__('Loading', 'give'), |
|
56 | 56 | // General loading message |
57 | - 'select_option' => esc_html__( 'Please select an option', 'give' ), |
|
57 | + 'select_option' => esc_html__('Please select an option', 'give'), |
|
58 | 58 | // Variable pricing error with multi-purchase option enabled |
59 | - 'default_gateway' => give_get_default_gateway( null ), |
|
60 | - 'permalinks' => get_option( 'permalink_structure' ) ? '1' : '0', |
|
61 | - 'number_decimals' => apply_filters( 'give_format_amount_decimals', 2 ) |
|
62 | - ) ); |
|
59 | + 'default_gateway' => give_get_default_gateway(null), |
|
60 | + 'permalinks' => get_option('permalink_structure') ? '1' : '0', |
|
61 | + 'number_decimals' => apply_filters('give_format_amount_decimals', 2) |
|
62 | + )); |
|
63 | 63 | |
64 | 64 | //DEBUG is On |
65 | - if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { |
|
65 | + if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) { |
|
66 | 66 | |
67 | - if ( give_is_cc_verify_enabled() ) { |
|
68 | - wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
69 | - wp_enqueue_script( 'give-cc-validator' ); |
|
67 | + if (give_is_cc_verify_enabled()) { |
|
68 | + wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
69 | + wp_enqueue_script('give-cc-validator'); |
|
70 | 70 | } |
71 | 71 | |
72 | - wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
73 | - wp_enqueue_script( 'give-float-labels' ); |
|
72 | + wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
73 | + wp_enqueue_script('give-float-labels'); |
|
74 | 74 | |
75 | - wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
76 | - wp_enqueue_script( 'give-blockui' ); |
|
75 | + wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
76 | + wp_enqueue_script('give-blockui'); |
|
77 | 77 | |
78 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
79 | - wp_enqueue_script( 'give-qtip' ); |
|
78 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
79 | + wp_enqueue_script('give-qtip'); |
|
80 | 80 | |
81 | - wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
82 | - wp_enqueue_script( 'give-accounting' ); |
|
81 | + wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
82 | + wp_enqueue_script('give-accounting'); |
|
83 | 83 | |
84 | - wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
85 | - wp_enqueue_script( 'give-magnific' ); |
|
84 | + wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
85 | + wp_enqueue_script('give-magnific'); |
|
86 | 86 | |
87 | - wp_register_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
88 | - wp_enqueue_script( 'give-checkout-global' ); |
|
87 | + wp_register_script('give-checkout-global', $js_dir.'give-checkout-global'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
88 | + wp_enqueue_script('give-checkout-global'); |
|
89 | 89 | |
90 | 90 | //General scripts |
91 | - wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
92 | - wp_enqueue_script( 'give-scripts' ); |
|
91 | + wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
92 | + wp_enqueue_script('give-scripts'); |
|
93 | 93 | |
94 | 94 | // Load AJAX scripts, if enabled |
95 | - wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
96 | - wp_enqueue_script( 'give-ajax' ); |
|
95 | + wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
96 | + wp_enqueue_script('give-ajax'); |
|
97 | 97 | |
98 | 98 | //Localize / Pass AJAX vars from PHP |
99 | - wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_checkout ); |
|
100 | - wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax ); |
|
99 | + wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_checkout); |
|
100 | + wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax); |
|
101 | 101 | |
102 | 102 | |
103 | 103 | } else { |
104 | 104 | |
105 | 105 | //DEBUG is OFF (one JS file to rule them all!) |
106 | - wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer ); |
|
107 | - wp_enqueue_script( 'give' ); |
|
106 | + wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer); |
|
107 | + wp_enqueue_script('give'); |
|
108 | 108 | |
109 | 109 | //Localize / Pass AJAX vars from PHP |
110 | - wp_localize_script( 'give', 'give_global_vars', $localize_give_checkout ); |
|
111 | - wp_localize_script( 'give', 'give_scripts', $localize_give_ajax ); |
|
110 | + wp_localize_script('give', 'give_global_vars', $localize_give_checkout); |
|
111 | + wp_localize_script('give', 'give_scripts', $localize_give_ajax); |
|
112 | 112 | |
113 | 113 | } |
114 | 114 | |
115 | 115 | |
116 | 116 | } |
117 | 117 | |
118 | -add_action( 'wp_enqueue_scripts', 'give_load_scripts' ); |
|
118 | +add_action('wp_enqueue_scripts', 'give_load_scripts'); |
|
119 | 119 | |
120 | 120 | /** |
121 | 121 | * Register Styles |
@@ -127,47 +127,47 @@ discard block |
||
127 | 127 | */ |
128 | 128 | function give_register_styles() { |
129 | 129 | |
130 | - if ( give_get_option( 'disable_css', false ) ) { |
|
130 | + if (give_get_option('disable_css', false)) { |
|
131 | 131 | return; |
132 | 132 | } |
133 | 133 | |
134 | 134 | // Use minified libraries if SCRIPT_DEBUG is turned off |
135 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
135 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
136 | 136 | |
137 | - $file = 'give' . $suffix . '.css'; |
|
137 | + $file = 'give'.$suffix.'.css'; |
|
138 | 138 | $templates_dir = give_get_theme_template_dir_name(); |
139 | 139 | |
140 | - $child_theme_style_sheet = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file; |
|
141 | - $child_theme_style_sheet_2 = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give.css'; |
|
142 | - $parent_theme_style_sheet = trailingslashit( get_template_directory() ) . $templates_dir . $file; |
|
143 | - $parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give.css'; |
|
144 | - $give_plugin_style_sheet = trailingslashit( give_get_templates_dir() ) . $file; |
|
140 | + $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()).$templates_dir.$file; |
|
141 | + $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()).$templates_dir.'give.css'; |
|
142 | + $parent_theme_style_sheet = trailingslashit(get_template_directory()).$templates_dir.$file; |
|
143 | + $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give.css'; |
|
144 | + $give_plugin_style_sheet = trailingslashit(give_get_templates_dir()).$file; |
|
145 | 145 | |
146 | 146 | // Look in the child theme directory first, followed by the parent theme, followed by the Give core templates directory |
147 | 147 | // Also look for the min version first, followed by non minified version, even if SCRIPT_DEBUG is not enabled. |
148 | 148 | // This allows users to copy just give.css to their theme |
149 | - if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) { |
|
150 | - if ( ! empty( $nonmin ) ) { |
|
151 | - $url = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give.css'; |
|
149 | + if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) { |
|
150 | + if ( ! empty($nonmin)) { |
|
151 | + $url = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give.css'; |
|
152 | 152 | } else { |
153 | - $url = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file; |
|
153 | + $url = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file; |
|
154 | 154 | } |
155 | - } elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) { |
|
156 | - if ( ! empty( $nonmin ) ) { |
|
157 | - $url = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give.css'; |
|
155 | + } elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) { |
|
156 | + if ( ! empty($nonmin)) { |
|
157 | + $url = trailingslashit(get_template_directory_uri()).$templates_dir.'give.css'; |
|
158 | 158 | } else { |
159 | - $url = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file; |
|
159 | + $url = trailingslashit(get_template_directory_uri()).$templates_dir.$file; |
|
160 | 160 | } |
161 | - } elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) { |
|
162 | - $url = trailingslashit( give_get_templates_url() ) . $file; |
|
161 | + } elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) { |
|
162 | + $url = trailingslashit(give_get_templates_url()).$file; |
|
163 | 163 | } |
164 | 164 | |
165 | - wp_register_style( 'give-styles', $url, array(), GIVE_VERSION, 'all' ); |
|
166 | - wp_enqueue_style( 'give-styles' ); |
|
165 | + wp_register_style('give-styles', $url, array(), GIVE_VERSION, 'all'); |
|
166 | + wp_enqueue_style('give-styles'); |
|
167 | 167 | |
168 | 168 | } |
169 | 169 | |
170 | -add_action( 'wp_enqueue_scripts', 'give_register_styles' ); |
|
170 | +add_action('wp_enqueue_scripts', 'give_register_styles'); |
|
171 | 171 | |
172 | 172 | /** |
173 | 173 | * Load Admin Scripts |
@@ -181,107 +181,107 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @return void |
183 | 183 | */ |
184 | -function give_load_admin_scripts( $hook ) { |
|
184 | +function give_load_admin_scripts($hook) { |
|
185 | 185 | |
186 | 186 | global $wp_version, $post, $post_type; |
187 | 187 | |
188 | 188 | //Directories of assets |
189 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
190 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
191 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
189 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
190 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
191 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
192 | 192 | |
193 | 193 | // Use minified libraries if SCRIPT_DEBUG is turned off |
194 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
194 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
195 | 195 | |
196 | 196 | //Global Admin: |
197 | - wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' ); |
|
198 | - wp_enqueue_style( 'give-admin-bar-notification' ); |
|
197 | + wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css'); |
|
198 | + wp_enqueue_style('give-admin-bar-notification'); |
|
199 | 199 | |
200 | 200 | //Give Admin Only: |
201 | - if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) { |
|
201 | + if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) { |
|
202 | 202 | return; |
203 | 203 | } |
204 | 204 | |
205 | 205 | //CSS |
206 | - wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' ); |
|
207 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
208 | - wp_register_style( 'give-admin', $css_dir . 'give-admin' . $suffix . '.css', GIVE_VERSION ); |
|
209 | - wp_enqueue_style( 'give-admin' ); |
|
210 | - wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION ); |
|
211 | - wp_enqueue_style( 'jquery-chosen' ); |
|
212 | - wp_enqueue_style( 'thickbox' ); |
|
206 | + wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css'); |
|
207 | + wp_enqueue_style('jquery-ui-css'); |
|
208 | + wp_register_style('give-admin', $css_dir.'give-admin'.$suffix.'.css', GIVE_VERSION); |
|
209 | + wp_enqueue_style('give-admin'); |
|
210 | + wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION); |
|
211 | + wp_enqueue_style('jquery-chosen'); |
|
212 | + wp_enqueue_style('thickbox'); |
|
213 | 213 | |
214 | 214 | //JS |
215 | - wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION ); |
|
216 | - wp_enqueue_script( 'jquery-chosen' ); |
|
215 | + wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION); |
|
216 | + wp_enqueue_script('jquery-chosen'); |
|
217 | 217 | |
218 | - wp_register_script( 'give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
219 | - wp_enqueue_script( 'give-admin-scripts' ); |
|
218 | + wp_register_script('give-admin-scripts', $js_dir.'admin-scripts'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
219 | + wp_enqueue_script('give-admin-scripts'); |
|
220 | 220 | |
221 | - wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' ); |
|
222 | - wp_enqueue_script( 'jquery-flot' ); |
|
221 | + wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js'); |
|
222 | + wp_enqueue_script('jquery-flot'); |
|
223 | 223 | |
224 | - wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
225 | - wp_enqueue_script( 'give-qtip' ); |
|
224 | + wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
225 | + wp_enqueue_script('give-qtip'); |
|
226 | 226 | |
227 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
228 | - wp_enqueue_script( 'thickbox' ); |
|
227 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
228 | + wp_enqueue_script('thickbox'); |
|
229 | 229 | |
230 | 230 | //Forms CPT Script |
231 | - if ( $post_type === 'give_forms' ) { |
|
232 | - wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
233 | - wp_enqueue_script( 'give-admin-forms-scripts' ); |
|
231 | + if ($post_type === 'give_forms') { |
|
232 | + wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
233 | + wp_enqueue_script('give-admin-forms-scripts'); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | //Settings Scripts |
237 | - if (isset($_GET['page']) && $_GET['page'] == 'give-settings' ) { |
|
237 | + if (isset($_GET['page']) && $_GET['page'] == 'give-settings') { |
|
238 | 238 | wp_enqueue_script('jquery-ui-sortable'); |
239 | - wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
240 | - wp_enqueue_script( 'give-admin-settings-scripts' ); |
|
239 | + wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
240 | + wp_enqueue_script('give-admin-settings-scripts'); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | //Localize strings & variables for JS |
244 | - wp_localize_script( 'give-admin-scripts', 'give_vars', array( |
|
245 | - 'post_id' => isset( $post->ID ) ? $post->ID : null, |
|
244 | + wp_localize_script('give-admin-scripts', 'give_vars', array( |
|
245 | + 'post_id' => isset($post->ID) ? $post->ID : null, |
|
246 | 246 | 'give_version' => GIVE_VERSION, |
247 | - 'quick_edit_warning' => esc_html__( 'Sorry, not available for variable priced forms.', 'give' ), |
|
248 | - 'delete_payment' => esc_html__( 'Are you sure you wish to delete this payment?', 'give' ), |
|
249 | - 'delete_payment_note' => esc_html__( 'Are you sure you wish to delete this note?', 'give' ), |
|
250 | - 'revoke_api_key' => esc_html__( 'Are you sure you wish to revoke this API key?', 'give' ), |
|
251 | - 'regenerate_api_key' => esc_html__( 'Are you sure you wish to regenerate this API key?', 'give' ), |
|
252 | - 'resend_receipt' => esc_html__( 'Are you sure you wish to resend the donation receipt?', 'give' ), |
|
253 | - 'copy_download_link_text' => esc_html__( 'Copy these links to your clipboard and give them to your donor.', 'give' ), |
|
247 | + 'quick_edit_warning' => esc_html__('Sorry, not available for variable priced forms.', 'give'), |
|
248 | + 'delete_payment' => esc_html__('Are you sure you wish to delete this payment?', 'give'), |
|
249 | + 'delete_payment_note' => esc_html__('Are you sure you wish to delete this note?', 'give'), |
|
250 | + 'revoke_api_key' => esc_html__('Are you sure you wish to revoke this API key?', 'give'), |
|
251 | + 'regenerate_api_key' => esc_html__('Are you sure you wish to regenerate this API key?', 'give'), |
|
252 | + 'resend_receipt' => esc_html__('Are you sure you wish to resend the donation receipt?', 'give'), |
|
253 | + 'copy_download_link_text' => esc_html__('Copy these links to your clipboard and give them to your donor.', 'give'), |
|
254 | 254 | /* translators: %s: form singular label */ |
255 | - 'delete_payment_download' => sprintf( esc_html__( 'Are you sure you wish to delete this %s?', 'give' ), give_get_forms_label_singular() ), |
|
256 | - 'one_price_min' => esc_html__( 'You must have at least one price.', 'give' ), |
|
257 | - 'one_file_min' => esc_html__( 'You must have at least one file.', 'give' ), |
|
258 | - 'one_field_min' => esc_html__( 'You must have at least one field.', 'give' ), |
|
255 | + 'delete_payment_download' => sprintf(esc_html__('Are you sure you wish to delete this %s?', 'give'), give_get_forms_label_singular()), |
|
256 | + 'one_price_min' => esc_html__('You must have at least one price.', 'give'), |
|
257 | + 'one_file_min' => esc_html__('You must have at least one file.', 'give'), |
|
258 | + 'one_field_min' => esc_html__('You must have at least one field.', 'give'), |
|
259 | 259 | /* translators: %s: form singular label */ |
260 | - 'one_option' => sprintf( esc_html__( 'Choose a %s', 'give' ), give_get_forms_label_singular() ), |
|
260 | + 'one_option' => sprintf(esc_html__('Choose a %s', 'give'), give_get_forms_label_singular()), |
|
261 | 261 | /* translators: %s: form plural label */ |
262 | - 'one_or_more_option' => sprintf( esc_html__( 'Choose one or more %s', 'give' ), give_get_forms_label_plural() ), |
|
263 | - 'numeric_item_price' => esc_html__( 'Item price must be numeric.', 'give' ), |
|
264 | - 'numeric_quantity' => esc_html__( 'Quantity must be numeric.', 'give' ), |
|
265 | - 'currency_sign' => give_currency_filter( '' ), |
|
266 | - 'currency_pos' => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before', |
|
262 | + 'one_or_more_option' => sprintf(esc_html__('Choose one or more %s', 'give'), give_get_forms_label_plural()), |
|
263 | + 'numeric_item_price' => esc_html__('Item price must be numeric.', 'give'), |
|
264 | + 'numeric_quantity' => esc_html__('Quantity must be numeric.', 'give'), |
|
265 | + 'currency_sign' => give_currency_filter(''), |
|
266 | + 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', |
|
267 | 267 | 'currency_decimals' => give_currency_decimal_filter(), |
268 | - 'new_media_ui' => apply_filters( 'give_use_35_media_ui', 1 ), |
|
269 | - 'remove_text' => esc_html__( 'Remove', 'give' ), |
|
268 | + 'new_media_ui' => apply_filters('give_use_35_media_ui', 1), |
|
269 | + 'remove_text' => esc_html__('Remove', 'give'), |
|
270 | 270 | /* translators: %s: form plural label */ |
271 | - 'type_to_search' => sprintf( esc_html__( 'Type to search %s', 'give' ), give_get_forms_label_plural() ), |
|
272 | - 'batch_export_no_class' => esc_html__( 'You must choose a method.', 'give' ), |
|
273 | - 'batch_export_no_reqs' => esc_html__( 'Required fields not completed.', 'give' ), |
|
274 | - 'reset_stats_warn' => __( 'Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give' ), |
|
275 | - ) ); |
|
271 | + 'type_to_search' => sprintf(esc_html__('Type to search %s', 'give'), give_get_forms_label_plural()), |
|
272 | + 'batch_export_no_class' => esc_html__('You must choose a method.', 'give'), |
|
273 | + 'batch_export_no_reqs' => esc_html__('Required fields not completed.', 'give'), |
|
274 | + 'reset_stats_warn' => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'), |
|
275 | + )); |
|
276 | 276 | |
277 | - if ( function_exists( 'wp_enqueue_media' ) && version_compare( $wp_version, '3.5', '>=' ) ) { |
|
277 | + if (function_exists('wp_enqueue_media') && version_compare($wp_version, '3.5', '>=')) { |
|
278 | 278 | //call for new media manager |
279 | 279 | wp_enqueue_media(); |
280 | 280 | } |
281 | 281 | |
282 | 282 | } |
283 | 283 | |
284 | -add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 ); |
|
284 | +add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100); |
|
285 | 285 | |
286 | 286 | /** |
287 | 287 | * Admin Give Icon |
@@ -298,14 +298,14 @@ discard block |
||
298 | 298 | ?> |
299 | 299 | <style type="text/css" media="screen"> |
300 | 300 | |
301 | - <?php if( version_compare( $wp_version, '3.8-RC', '>=' ) || version_compare( $wp_version, '3.8', '>=' ) ) { ?> |
|
301 | + <?php if (version_compare($wp_version, '3.8-RC', '>=') || version_compare($wp_version, '3.8', '>=')) { ?> |
|
302 | 302 | @font-face { |
303 | 303 | font-family: 'give-icomoon'; |
304 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?-ngjl88'; ?>'); |
|
305 | - src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'), |
|
306 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'), |
|
307 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.ttf?-ngjl88'; ?>') format('truetype'), |
|
308 | - url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg'); |
|
304 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?-ngjl88'; ?>'); |
|
305 | + src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'), |
|
306 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'), |
|
307 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.ttf?-ngjl88'; ?>') format('truetype'), |
|
308 | + url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg'); |
|
309 | 309 | font-weight: normal; |
310 | 310 | font-style: normal; |
311 | 311 | } |
@@ -324,4 +324,4 @@ discard block |
||
324 | 324 | <?php |
325 | 325 | } |
326 | 326 | |
327 | -add_action( 'admin_head', 'give_admin_icon' ); |
|
327 | +add_action('admin_head', 'give_admin_icon'); |
@@ -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 | |
@@ -97,29 +97,29 @@ discard block |
||
97 | 97 | * @param bool $_id_or_email |
98 | 98 | * @param bool $by_user_id |
99 | 99 | */ |
100 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
100 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
101 | 101 | |
102 | 102 | $this->db = new Give_DB_Customers; |
103 | 103 | |
104 | - if ( false === $_id_or_email || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) ) { |
|
104 | + if (false === $_id_or_email || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))) { |
|
105 | 105 | return false; |
106 | 106 | } |
107 | 107 | |
108 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
108 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
109 | 109 | |
110 | - if ( is_numeric( $_id_or_email ) ) { |
|
110 | + if (is_numeric($_id_or_email)) { |
|
111 | 111 | $field = $by_user_id ? 'user_id' : 'id'; |
112 | 112 | } else { |
113 | 113 | $field = 'email'; |
114 | 114 | } |
115 | 115 | |
116 | - $customer = $this->db->get_customer_by( $field, $_id_or_email ); |
|
116 | + $customer = $this->db->get_customer_by($field, $_id_or_email); |
|
117 | 117 | |
118 | - if ( empty( $customer ) || ! is_object( $customer ) ) { |
|
118 | + if (empty($customer) || ! is_object($customer)) { |
|
119 | 119 | return false; |
120 | 120 | } |
121 | 121 | |
122 | - $this->setup_customer( $customer ); |
|
122 | + $this->setup_customer($customer); |
|
123 | 123 | |
124 | 124 | } |
125 | 125 | |
@@ -132,15 +132,15 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return bool If the setup was successful or not |
134 | 134 | */ |
135 | - private function setup_customer( $customer ) { |
|
135 | + private function setup_customer($customer) { |
|
136 | 136 | |
137 | - if ( ! is_object( $customer ) ) { |
|
137 | + if ( ! is_object($customer)) { |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
141 | - foreach ( $customer as $key => $value ) { |
|
141 | + foreach ($customer as $key => $value) { |
|
142 | 142 | |
143 | - switch ( $key ) { |
|
143 | + switch ($key) { |
|
144 | 144 | |
145 | 145 | case 'notes': |
146 | 146 | $this->$key = $this->get_notes(); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | // Customer ID and email are the only things that are necessary, make sure they exist |
158 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
158 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
159 | 159 | return true; |
160 | 160 | } |
161 | 161 | |
@@ -168,16 +168,16 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @since 1.0 |
170 | 170 | */ |
171 | - public function __get( $key ) { |
|
171 | + public function __get($key) { |
|
172 | 172 | |
173 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
173 | + if (method_exists($this, 'get_'.$key)) { |
|
174 | 174 | |
175 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
175 | + return call_user_func(array($this, 'get_'.$key)); |
|
176 | 176 | |
177 | 177 | } else { |
178 | 178 | |
179 | 179 | /* translators: %s: property key */ |
180 | - return new WP_Error( 'give-customer-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
180 | + return new WP_Error('give-customer-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
181 | 181 | |
182 | 182 | } |
183 | 183 | |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @return mixed False if not a valid creation, Customer ID if user is found or valid creation |
194 | 194 | */ |
195 | - public function create( $data = array() ) { |
|
195 | + public function create($data = array()) { |
|
196 | 196 | |
197 | - if ( $this->id != 0 || empty( $data ) ) { |
|
197 | + if ($this->id != 0 || empty($data)) { |
|
198 | 198 | return false; |
199 | 199 | } |
200 | 200 | |
@@ -202,34 +202,34 @@ discard block |
||
202 | 202 | 'payment_ids' => '' |
203 | 203 | ); |
204 | 204 | |
205 | - $args = wp_parse_args( $data, $defaults ); |
|
206 | - $args = $this->sanitize_columns( $args ); |
|
205 | + $args = wp_parse_args($data, $defaults); |
|
206 | + $args = $this->sanitize_columns($args); |
|
207 | 207 | |
208 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
208 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
209 | 209 | return false; |
210 | 210 | } |
211 | 211 | |
212 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
213 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
212 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
213 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
214 | 214 | } |
215 | 215 | |
216 | - do_action( 'give_customer_pre_create', $args ); |
|
216 | + do_action('give_customer_pre_create', $args); |
|
217 | 217 | |
218 | 218 | $created = false; |
219 | 219 | |
220 | 220 | // The DB class 'add' implies an update if the customer being asked to be created already exists |
221 | - if ( $this->db->add( $data ) ) { |
|
221 | + if ($this->db->add($data)) { |
|
222 | 222 | |
223 | 223 | // We've successfully added/updated the customer, reset the class vars with the new data |
224 | - $customer = $this->db->get_customer_by( 'email', $args['email'] ); |
|
224 | + $customer = $this->db->get_customer_by('email', $args['email']); |
|
225 | 225 | |
226 | 226 | // Setup the customer data with the values from DB |
227 | - $this->setup_customer( $customer ); |
|
227 | + $this->setup_customer($customer); |
|
228 | 228 | |
229 | 229 | $created = $this->id; |
230 | 230 | } |
231 | 231 | |
232 | - do_action( 'give_customer_post_create', $created, $args ); |
|
232 | + do_action('give_customer_post_create', $created, $args); |
|
233 | 233 | |
234 | 234 | return $created; |
235 | 235 | |
@@ -244,27 +244,27 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @return bool If the update was successful or not |
246 | 246 | */ |
247 | - public function update( $data = array() ) { |
|
247 | + public function update($data = array()) { |
|
248 | 248 | |
249 | - if ( empty( $data ) ) { |
|
249 | + if (empty($data)) { |
|
250 | 250 | return false; |
251 | 251 | } |
252 | 252 | |
253 | - $data = $this->sanitize_columns( $data ); |
|
253 | + $data = $this->sanitize_columns($data); |
|
254 | 254 | |
255 | - do_action( 'give_customer_pre_update', $this->id, $data ); |
|
255 | + do_action('give_customer_pre_update', $this->id, $data); |
|
256 | 256 | |
257 | 257 | $updated = false; |
258 | 258 | |
259 | - if ( $this->db->update( $this->id, $data ) ) { |
|
259 | + if ($this->db->update($this->id, $data)) { |
|
260 | 260 | |
261 | - $customer = $this->db->get_customer_by( 'id', $this->id ); |
|
262 | - $this->setup_customer( $customer ); |
|
261 | + $customer = $this->db->get_customer_by('id', $this->id); |
|
262 | + $this->setup_customer($customer); |
|
263 | 263 | |
264 | 264 | $updated = true; |
265 | 265 | } |
266 | 266 | |
267 | - do_action( 'give_customer_post_update', $updated, $this->id, $data ); |
|
267 | + do_action('give_customer_post_update', $updated, $this->id, $data); |
|
268 | 268 | |
269 | 269 | return $updated; |
270 | 270 | } |
@@ -280,44 +280,44 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @return bool If the attachment was successfuly |
282 | 282 | */ |
283 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
283 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
284 | 284 | |
285 | - if ( empty( $payment_id ) ) { |
|
285 | + if (empty($payment_id)) { |
|
286 | 286 | return false; |
287 | 287 | } |
288 | 288 | |
289 | - if ( empty( $this->payment_ids ) ) { |
|
289 | + if (empty($this->payment_ids)) { |
|
290 | 290 | |
291 | 291 | $new_payment_ids = $payment_id; |
292 | 292 | |
293 | 293 | } else { |
294 | 294 | |
295 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
295 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
296 | 296 | |
297 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
297 | + if (in_array($payment_id, $payment_ids)) { |
|
298 | 298 | $update_stats = false; |
299 | 299 | } |
300 | 300 | |
301 | 301 | $payment_ids[] = $payment_id; |
302 | 302 | |
303 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
303 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
304 | 304 | |
305 | 305 | } |
306 | 306 | |
307 | - do_action( 'give_customer_pre_attach_payment', $payment_id, $this->id ); |
|
307 | + do_action('give_customer_pre_attach_payment', $payment_id, $this->id); |
|
308 | 308 | |
309 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
309 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
310 | 310 | |
311 | - if ( $payment_added ) { |
|
311 | + if ($payment_added) { |
|
312 | 312 | |
313 | 313 | $this->payment_ids = $new_payment_ids; |
314 | 314 | |
315 | 315 | // We added this payment successfully, increment the stats |
316 | - if ( $update_stats ) { |
|
317 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
316 | + if ($update_stats) { |
|
317 | + $payment_amount = give_get_payment_amount($payment_id); |
|
318 | 318 | |
319 | - if ( ! empty( $payment_amount ) ) { |
|
320 | - $this->increase_value( $payment_amount ); |
|
319 | + if ( ! empty($payment_amount)) { |
|
320 | + $this->increase_value($payment_amount); |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | $this->increase_purchase_count(); |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | |
326 | 326 | } |
327 | 327 | |
328 | - do_action( 'give_customer_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
328 | + do_action('give_customer_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
329 | 329 | |
330 | 330 | return $payment_added; |
331 | 331 | } |
@@ -341,50 +341,50 @@ discard block |
||
341 | 341 | * |
342 | 342 | * @return boolean If the removal was successful |
343 | 343 | */ |
344 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
344 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
345 | 345 | |
346 | - if ( empty( $payment_id ) ) { |
|
346 | + if (empty($payment_id)) { |
|
347 | 347 | return false; |
348 | 348 | } |
349 | 349 | |
350 | - $payment = new Give_Payment( $payment_id ); |
|
350 | + $payment = new Give_Payment($payment_id); |
|
351 | 351 | |
352 | - if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { |
|
352 | + if ('publish' !== $payment->status && 'revoked' !== $payment->status) { |
|
353 | 353 | $update_stats = false; |
354 | 354 | } |
355 | 355 | |
356 | 356 | $new_payment_ids = ''; |
357 | 357 | |
358 | - if ( ! empty( $this->payment_ids ) ) { |
|
358 | + if ( ! empty($this->payment_ids)) { |
|
359 | 359 | |
360 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
360 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
361 | 361 | |
362 | - $pos = array_search( $payment_id, $payment_ids ); |
|
363 | - if ( false === $pos ) { |
|
362 | + $pos = array_search($payment_id, $payment_ids); |
|
363 | + if (false === $pos) { |
|
364 | 364 | return false; |
365 | 365 | } |
366 | 366 | |
367 | - unset( $payment_ids[ $pos ] ); |
|
368 | - $payment_ids = array_filter( $payment_ids ); |
|
367 | + unset($payment_ids[$pos]); |
|
368 | + $payment_ids = array_filter($payment_ids); |
|
369 | 369 | |
370 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
370 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
371 | 371 | |
372 | 372 | } |
373 | 373 | |
374 | - do_action( 'give_customer_pre_remove_payment', $payment_id, $this->id ); |
|
374 | + do_action('give_customer_pre_remove_payment', $payment_id, $this->id); |
|
375 | 375 | |
376 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
376 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
377 | 377 | |
378 | - if ( $payment_removed ) { |
|
378 | + if ($payment_removed) { |
|
379 | 379 | |
380 | 380 | $this->payment_ids = $new_payment_ids; |
381 | 381 | |
382 | - if ( $update_stats ) { |
|
382 | + if ($update_stats) { |
|
383 | 383 | // We removed this payment successfully, decrement the stats |
384 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
384 | + $payment_amount = give_get_payment_amount($payment_id); |
|
385 | 385 | |
386 | - if ( ! empty( $payment_amount ) ) { |
|
387 | - $this->decrease_value( $payment_amount ); |
|
386 | + if ( ! empty($payment_amount)) { |
|
387 | + $this->decrease_value($payment_amount); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | $this->decrease_purchase_count(); |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | |
393 | 393 | } |
394 | 394 | |
395 | - do_action( 'give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
395 | + do_action('give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
396 | 396 | |
397 | 397 | return $payment_removed; |
398 | 398 | |
@@ -407,22 +407,22 @@ discard block |
||
407 | 407 | * |
408 | 408 | * @return int The purchase count |
409 | 409 | */ |
410 | - public function increase_purchase_count( $count = 1 ) { |
|
410 | + public function increase_purchase_count($count = 1) { |
|
411 | 411 | |
412 | 412 | // Make sure it's numeric and not negative |
413 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
413 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
414 | 414 | return false; |
415 | 415 | } |
416 | 416 | |
417 | 417 | $new_total = (int) $this->purchase_count + (int) $count; |
418 | 418 | |
419 | - do_action( 'give_customer_pre_increase_purchase_count', $count, $this->id ); |
|
419 | + do_action('give_customer_pre_increase_purchase_count', $count, $this->id); |
|
420 | 420 | |
421 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
421 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
422 | 422 | $this->purchase_count = $new_total; |
423 | 423 | } |
424 | 424 | |
425 | - do_action( 'give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id ); |
|
425 | + do_action('give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id); |
|
426 | 426 | |
427 | 427 | return $this->purchase_count; |
428 | 428 | } |
@@ -436,26 +436,26 @@ discard block |
||
436 | 436 | * |
437 | 437 | * @return mixed If successful, the new count, otherwise false |
438 | 438 | */ |
439 | - public function decrease_purchase_count( $count = 1 ) { |
|
439 | + public function decrease_purchase_count($count = 1) { |
|
440 | 440 | |
441 | 441 | // Make sure it's numeric and not negative |
442 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
442 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
443 | 443 | return false; |
444 | 444 | } |
445 | 445 | |
446 | 446 | $new_total = (int) $this->purchase_count - (int) $count; |
447 | 447 | |
448 | - if ( $new_total < 0 ) { |
|
448 | + if ($new_total < 0) { |
|
449 | 449 | $new_total = 0; |
450 | 450 | } |
451 | 451 | |
452 | - do_action( 'give_customer_pre_decrease_purchase_count', $count, $this->id ); |
|
452 | + do_action('give_customer_pre_decrease_purchase_count', $count, $this->id); |
|
453 | 453 | |
454 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
454 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
455 | 455 | $this->purchase_count = $new_total; |
456 | 456 | } |
457 | 457 | |
458 | - do_action( 'give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id ); |
|
458 | + do_action('give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id); |
|
459 | 459 | |
460 | 460 | return $this->purchase_count; |
461 | 461 | } |
@@ -469,17 +469,17 @@ discard block |
||
469 | 469 | * |
470 | 470 | * @return mixed If successful, the new value, otherwise false |
471 | 471 | */ |
472 | - public function increase_value( $value = 0.00 ) { |
|
472 | + public function increase_value($value = 0.00) { |
|
473 | 473 | |
474 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
474 | + $new_value = floatval($this->purchase_value) + $value; |
|
475 | 475 | |
476 | - do_action( 'give_customer_pre_increase_value', $value, $this->id ); |
|
476 | + do_action('give_customer_pre_increase_value', $value, $this->id); |
|
477 | 477 | |
478 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
478 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
479 | 479 | $this->purchase_value = $new_value; |
480 | 480 | } |
481 | 481 | |
482 | - do_action( 'give_customer_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
482 | + do_action('give_customer_post_increase_value', $this->purchase_value, $value, $this->id); |
|
483 | 483 | |
484 | 484 | return $this->purchase_value; |
485 | 485 | } |
@@ -493,21 +493,21 @@ discard block |
||
493 | 493 | * |
494 | 494 | * @return mixed If successful, the new value, otherwise false |
495 | 495 | */ |
496 | - public function decrease_value( $value = 0.00 ) { |
|
496 | + public function decrease_value($value = 0.00) { |
|
497 | 497 | |
498 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
498 | + $new_value = floatval($this->purchase_value) - $value; |
|
499 | 499 | |
500 | - if ( $new_value < 0 ) { |
|
500 | + if ($new_value < 0) { |
|
501 | 501 | $new_value = 0.00; |
502 | 502 | } |
503 | 503 | |
504 | - do_action( 'give_customer_pre_decrease_value', $value, $this->id ); |
|
504 | + do_action('give_customer_pre_decrease_value', $value, $this->id); |
|
505 | 505 | |
506 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
506 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
507 | 507 | $this->purchase_value = $new_value; |
508 | 508 | } |
509 | 509 | |
510 | - do_action( 'give_customer_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
510 | + do_action('give_customer_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
511 | 511 | |
512 | 512 | return $this->purchase_value; |
513 | 513 | } |
@@ -522,15 +522,15 @@ discard block |
||
522 | 522 | * |
523 | 523 | * @return array The notes requsted |
524 | 524 | */ |
525 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
525 | + public function get_notes($length = 20, $paged = 1) { |
|
526 | 526 | |
527 | - $length = is_numeric( $length ) ? $length : 20; |
|
528 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
527 | + $length = is_numeric($length) ? $length : 20; |
|
528 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
529 | 529 | |
530 | 530 | $all_notes = $this->get_raw_notes(); |
531 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
531 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
532 | 532 | |
533 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
533 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
534 | 534 | |
535 | 535 | return $desired_notes; |
536 | 536 | |
@@ -545,9 +545,9 @@ discard block |
||
545 | 545 | public function get_notes_count() { |
546 | 546 | |
547 | 547 | $all_notes = $this->get_raw_notes(); |
548 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
548 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
549 | 549 | |
550 | - return count( $notes_array ); |
|
550 | + return count($notes_array); |
|
551 | 551 | |
552 | 552 | } |
553 | 553 | |
@@ -560,32 +560,32 @@ discard block |
||
560 | 560 | * |
561 | 561 | * @return string|boolean The new note if added succesfully, false otherwise |
562 | 562 | */ |
563 | - public function add_note( $note = '' ) { |
|
563 | + public function add_note($note = '') { |
|
564 | 564 | |
565 | - $note = trim( $note ); |
|
566 | - if ( empty( $note ) ) { |
|
565 | + $note = trim($note); |
|
566 | + if (empty($note)) { |
|
567 | 567 | return false; |
568 | 568 | } |
569 | 569 | |
570 | 570 | $notes = $this->get_raw_notes(); |
571 | 571 | |
572 | - if ( empty( $notes ) ) { |
|
572 | + if (empty($notes)) { |
|
573 | 573 | $notes = ''; |
574 | 574 | } |
575 | 575 | |
576 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
577 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
578 | - $notes .= "\n\n" . $new_note; |
|
576 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
577 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
578 | + $notes .= "\n\n".$new_note; |
|
579 | 579 | |
580 | - do_action( 'give_customer_pre_add_note', $new_note, $this->id ); |
|
580 | + do_action('give_customer_pre_add_note', $new_note, $this->id); |
|
581 | 581 | |
582 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
582 | + $updated = $this->update(array('notes' => $notes)); |
|
583 | 583 | |
584 | - if ( $updated ) { |
|
584 | + if ($updated) { |
|
585 | 585 | $this->notes = $this->get_notes(); |
586 | 586 | } |
587 | 587 | |
588 | - do_action( 'give_customer_post_add_note', $this->notes, $new_note, $this->id ); |
|
588 | + do_action('give_customer_post_add_note', $this->notes, $new_note, $this->id); |
|
589 | 589 | |
590 | 590 | // Return the formatted note, so we can test, as well as update any displays |
591 | 591 | return $new_note; |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | */ |
601 | 601 | private function get_raw_notes() { |
602 | 602 | |
603 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
603 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
604 | 604 | |
605 | 605 | return $all_notes; |
606 | 606 | |
@@ -615,51 +615,51 @@ discard block |
||
615 | 615 | * |
616 | 616 | * @return array The sanitized data, based off column defaults |
617 | 617 | */ |
618 | - private function sanitize_columns( $data ) { |
|
618 | + private function sanitize_columns($data) { |
|
619 | 619 | |
620 | 620 | $columns = $this->db->get_columns(); |
621 | 621 | $default_values = $this->db->get_column_defaults(); |
622 | 622 | |
623 | - foreach ( $columns as $key => $type ) { |
|
623 | + foreach ($columns as $key => $type) { |
|
624 | 624 | |
625 | 625 | // Only sanitize data that we were provided |
626 | - if ( ! array_key_exists( $key, $data ) ) { |
|
626 | + if ( ! array_key_exists($key, $data)) { |
|
627 | 627 | continue; |
628 | 628 | } |
629 | 629 | |
630 | - switch ( $type ) { |
|
630 | + switch ($type) { |
|
631 | 631 | |
632 | 632 | case '%s': |
633 | - if ( 'email' == $key ) { |
|
634 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
635 | - } elseif ( 'notes' == $key ) { |
|
636 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
633 | + if ('email' == $key) { |
|
634 | + $data[$key] = sanitize_email($data[$key]); |
|
635 | + } elseif ('notes' == $key) { |
|
636 | + $data[$key] = strip_tags($data[$key]); |
|
637 | 637 | } else { |
638 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
638 | + $data[$key] = sanitize_text_field($data[$key]); |
|
639 | 639 | } |
640 | 640 | break; |
641 | 641 | |
642 | 642 | case '%d': |
643 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
644 | - $data[ $key ] = $default_values[ $key ]; |
|
643 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
644 | + $data[$key] = $default_values[$key]; |
|
645 | 645 | } else { |
646 | - $data[ $key ] = absint( $data[ $key ] ); |
|
646 | + $data[$key] = absint($data[$key]); |
|
647 | 647 | } |
648 | 648 | break; |
649 | 649 | |
650 | 650 | case '%f': |
651 | 651 | // Convert what was given to a float |
652 | - $value = floatval( $data[ $key ] ); |
|
652 | + $value = floatval($data[$key]); |
|
653 | 653 | |
654 | - if ( ! is_float( $value ) ) { |
|
655 | - $data[ $key ] = $default_values[ $key ]; |
|
654 | + if ( ! is_float($value)) { |
|
655 | + $data[$key] = $default_values[$key]; |
|
656 | 656 | } else { |
657 | - $data[ $key ] = $value; |
|
657 | + $data[$key] = $value; |
|
658 | 658 | } |
659 | 659 | break; |
660 | 660 | |
661 | 661 | default: |
662 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
662 | + $data[$key] = sanitize_text_field($data[$key]); |
|
663 | 663 | break; |
664 | 664 | |
665 | 665 | } |