@@ -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 | |
@@ -32,18 +32,18 @@ discard block |
||
32 | 32 | * Instantiate the class |
33 | 33 | */ |
34 | 34 | public function __construct() { |
35 | - $this->self = get_class( $this ); |
|
35 | + $this->self = get_class($this); |
|
36 | 36 | |
37 | 37 | parent::__construct( |
38 | - strtolower( $this->self ), |
|
39 | - esc_html__( 'Give - Donation Form', 'give' ), |
|
38 | + strtolower($this->self), |
|
39 | + esc_html__('Give - Donation Form', 'give'), |
|
40 | 40 | array( |
41 | - 'description' => esc_html__( 'Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give' ), |
|
41 | + 'description' => esc_html__('Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give'), |
|
42 | 42 | ) |
43 | 43 | ); |
44 | 44 | |
45 | - add_action( 'widgets_init', array( $this, 'widget_init' ) ); |
|
46 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_widget_scripts' ) ); |
|
45 | + add_action('widgets_init', array($this, 'widget_init')); |
|
46 | + add_action('admin_enqueue_scripts', array($this, 'admin_widget_scripts')); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -53,20 +53,20 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @return void |
55 | 55 | */ |
56 | - public function admin_widget_scripts( $hook ) { |
|
56 | + public function admin_widget_scripts($hook) { |
|
57 | 57 | |
58 | 58 | // Directories of assets. |
59 | - $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; |
|
60 | - $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; |
|
61 | - $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; |
|
59 | + $js_dir = GIVE_PLUGIN_URL.'assets/js/admin/'; |
|
60 | + $js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/'; |
|
61 | + $css_dir = GIVE_PLUGIN_URL.'assets/css/'; |
|
62 | 62 | |
63 | 63 | // Use minified libraries if SCRIPT_DEBUG is turned off. |
64 | - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
64 | + $suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
65 | 65 | |
66 | 66 | // Widget Script. |
67 | - if ( 'widgets.php' === $hook ) { |
|
67 | + if ('widgets.php' === $hook) { |
|
68 | 68 | |
69 | - wp_enqueue_script( 'give-admin-widgets-scripts', $js_dir . 'admin-widgets' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false ); |
|
69 | + wp_enqueue_script('give-admin-widgets-scripts', $js_dir.'admin-widgets'.$suffix.'.js', array('jquery'), GIVE_VERSION, false); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | * before_widget, and after_widget. |
78 | 78 | * @param array $instance The settings for the particular instance of the widget. |
79 | 79 | */ |
80 | - public function widget( $args, $instance ) { |
|
81 | - $title = ! empty( $instance['title'] ) ? $instance['title'] : ''; |
|
82 | - $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); |
|
80 | + public function widget($args, $instance) { |
|
81 | + $title = ! empty($instance['title']) ? $instance['title'] : ''; |
|
82 | + $title = apply_filters('widget_title', $title, $instance, $this->id_base); |
|
83 | 83 | $form_id = (int) $instance['id']; |
84 | 84 | |
85 | 85 | echo $args['before_widget']; // XSS ok. |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @since 1.0 |
93 | 93 | */ |
94 | - do_action( 'give_before_forms_widget', $form_id ); |
|
94 | + do_action('give_before_forms_widget', $form_id); |
|
95 | 95 | |
96 | - echo $title ? $args['before_title'] . $title . $args['after_title'] : ''; // XSS ok. |
|
96 | + echo $title ? $args['before_title'].$title.$args['after_title'] : ''; // XSS ok. |
|
97 | 97 | |
98 | - give_get_donation_form( $instance ); |
|
98 | + give_get_donation_form($instance); |
|
99 | 99 | |
100 | 100 | echo $args['after_widget']; // XSS ok. |
101 | 101 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @since 1.0 |
108 | 108 | */ |
109 | - do_action( 'give_after_forms_widget', $form_id ); |
|
109 | + do_action('give_after_forms_widget', $form_id); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @param array $instance Current settings. |
116 | 116 | */ |
117 | - public function form( $instance ) { |
|
117 | + public function form($instance) { |
|
118 | 118 | $defaults = array( |
119 | 119 | 'title' => '', |
120 | 120 | 'id' => '', |
@@ -124,74 +124,74 @@ discard block |
||
124 | 124 | 'continue_button_title' => '', |
125 | 125 | ); |
126 | 126 | |
127 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
127 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
128 | 128 | |
129 | 129 | // Backward compatibility: Set float labels as default if, it was set as empty previous. |
130 | - $instance['float_labels'] = empty( $instance['float_labels'] ) ? 'global' : $instance['float_labels']; |
|
130 | + $instance['float_labels'] = empty($instance['float_labels']) ? 'global' : $instance['float_labels']; |
|
131 | 131 | |
132 | 132 | // Query Give Forms. |
133 | 133 | $args = array( |
134 | 134 | 'post_type' => 'give_forms', |
135 | - 'posts_per_page' => - 1, |
|
135 | + 'posts_per_page' => -1, |
|
136 | 136 | 'post_status' => 'publish', |
137 | 137 | ); |
138 | 138 | |
139 | - $give_forms = get_posts( $args ); |
|
139 | + $give_forms = get_posts($args); |
|
140 | 140 | ?> |
141 | 141 | <div class="give_forms_widget_container"> |
142 | 142 | |
143 | 143 | <?php // Widget: widget Title. ?> |
144 | 144 | <p> |
145 | - <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'give' ); ?></label> |
|
146 | - <input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" /><br> |
|
147 | - <small class="give-field-description"><?php esc_html_e( 'Leave blank to hide the widget title.', 'give' ); ?></small> |
|
145 | + <label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_html_e('Title:', 'give'); ?></label> |
|
146 | + <input type="text" class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" value="<?php echo esc_attr($instance['title']); ?>" /><br> |
|
147 | + <small class="give-field-description"><?php esc_html_e('Leave blank to hide the widget title.', 'give'); ?></small> |
|
148 | 148 | </p> |
149 | 149 | |
150 | 150 | <?php // Widget: Give Form. ?> |
151 | 151 | <p> |
152 | - <label for="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"><?php esc_html_e( 'Give Form:', 'give' ); ?></label> |
|
153 | - <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"> |
|
154 | - <option value="current"><?php esc_html_e( '- Select -', 'give' ); ?></option> |
|
155 | - <?php foreach ( $give_forms as $give_form ) { ?> |
|
152 | + <label for="<?php echo esc_attr($this->get_field_id('id')); ?>"><?php esc_html_e('Give Form:', 'give'); ?></label> |
|
153 | + <select class="widefat" name="<?php echo esc_attr($this->get_field_name('id')); ?>" id="<?php echo esc_attr($this->get_field_id('id')); ?>"> |
|
154 | + <option value="current"><?php esc_html_e('- Select -', 'give'); ?></option> |
|
155 | + <?php foreach ($give_forms as $give_form) { ?> |
|
156 | 156 | <?php /* translators: %s: Title */ ?> |
157 | - <?php $form_title = empty( $give_form->post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $give_form->ID ) : $give_form->post_title; ?> |
|
158 | - <option <?php selected( absint( $instance['id'] ), $give_form->ID ); ?> value="<?php echo esc_attr( $give_form->ID ); ?>"><?php echo esc_html( $form_title ); ?></option> |
|
157 | + <?php $form_title = empty($give_form->post_title) ? sprintf(__('Untitled (#%s)', 'give'), $give_form->ID) : $give_form->post_title; ?> |
|
158 | + <option <?php selected(absint($instance['id']), $give_form->ID); ?> value="<?php echo esc_attr($give_form->ID); ?>"><?php echo esc_html($form_title); ?></option> |
|
159 | 159 | <?php } ?> |
160 | 160 | </select><br> |
161 | - <small class="give-field-description"><?php esc_html_e( 'Select a Give Form to embed in this widget.', 'give' ); ?></small> |
|
161 | + <small class="give-field-description"><?php esc_html_e('Select a Give Form to embed in this widget.', 'give'); ?></small> |
|
162 | 162 | </p> |
163 | 163 | |
164 | 164 | <?php // Widget: Display Style. ?> |
165 | 165 | <p class="give_forms_display_style_setting_row"> |
166 | - <label for="<?php echo esc_attr( $this->get_field_id( 'display_style' ) ); ?>"><?php esc_html_e( 'Display Style:', 'give' ); ?></label><br> |
|
167 | - <label for="<?php echo esc_attr( $this->get_field_id( 'display_style' ) ); ?>-onpage"><input type="radio" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'display_style' ) ); ?>-onpage" name="<?php echo esc_attr( $this->get_field_name( 'display_style' ) ); ?>" value="onpage" <?php checked( $instance['display_style'], 'onpage' ); ?>> <?php echo esc_html__( 'All Fields', 'give' ); ?></label> |
|
168 | - <label for="<?php echo esc_attr( $this->get_field_id( 'display_style' ) ); ?>-reveal"><input type="radio" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'display_style' ) ); ?>-reveal" name="<?php echo esc_attr( $this->get_field_name( 'display_style' ) ); ?>" value="reveal" <?php checked( $instance['display_style'], 'reveal' ); ?>> <?php echo esc_html__( 'Reveal', 'give' ); ?></label> |
|
169 | - <label for="<?php echo esc_attr( $this->get_field_id( 'display_style' ) ); ?>-modal"><input type="radio" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'display_style' ) ); ?>-modal" name="<?php echo esc_attr( $this->get_field_name( 'display_style' ) ); ?>" value="modal" <?php checked( $instance['display_style'], 'modal' ); ?>> <?php echo esc_html__( 'Modal', 'give' ); ?></label> |
|
170 | - <label for="<?php echo esc_attr( $this->get_field_id( 'display_style' ) ); ?>-button"><input type="radio" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'display_style' ) ); ?>-button" name="<?php echo esc_attr( $this->get_field_name( 'display_style' ) ); ?>" value="button" <?php checked( $instance['display_style'], 'button' ); ?>> <?php echo esc_html__( 'Button', 'give' ); ?></label><br> |
|
166 | + <label for="<?php echo esc_attr($this->get_field_id('display_style')); ?>"><?php esc_html_e('Display Style:', 'give'); ?></label><br> |
|
167 | + <label for="<?php echo esc_attr($this->get_field_id('display_style')); ?>-onpage"><input type="radio" class="widefat" id="<?php echo esc_attr($this->get_field_id('display_style')); ?>-onpage" name="<?php echo esc_attr($this->get_field_name('display_style')); ?>" value="onpage" <?php checked($instance['display_style'], 'onpage'); ?>> <?php echo esc_html__('All Fields', 'give'); ?></label> |
|
168 | + <label for="<?php echo esc_attr($this->get_field_id('display_style')); ?>-reveal"><input type="radio" class="widefat" id="<?php echo esc_attr($this->get_field_id('display_style')); ?>-reveal" name="<?php echo esc_attr($this->get_field_name('display_style')); ?>" value="reveal" <?php checked($instance['display_style'], 'reveal'); ?>> <?php echo esc_html__('Reveal', 'give'); ?></label> |
|
169 | + <label for="<?php echo esc_attr($this->get_field_id('display_style')); ?>-modal"><input type="radio" class="widefat" id="<?php echo esc_attr($this->get_field_id('display_style')); ?>-modal" name="<?php echo esc_attr($this->get_field_name('display_style')); ?>" value="modal" <?php checked($instance['display_style'], 'modal'); ?>> <?php echo esc_html__('Modal', 'give'); ?></label> |
|
170 | + <label for="<?php echo esc_attr($this->get_field_id('display_style')); ?>-button"><input type="radio" class="widefat" id="<?php echo esc_attr($this->get_field_id('display_style')); ?>-button" name="<?php echo esc_attr($this->get_field_name('display_style')); ?>" value="button" <?php checked($instance['display_style'], 'button'); ?>> <?php echo esc_html__('Button', 'give'); ?></label><br> |
|
171 | 171 | <small class="give-field-description"> |
172 | - <?php echo esc_html__( 'Select a Give Form style.', 'give' ); ?> |
|
172 | + <?php echo esc_html__('Select a Give Form style.', 'give'); ?> |
|
173 | 173 | </small> |
174 | 174 | </p> |
175 | 175 | |
176 | 176 | <?php // Widget: Continue Button Title. ?> |
177 | 177 | <p class="give_forms_continue_button_title_setting_row"> |
178 | - <label for="<?php echo esc_attr( $this->get_field_id( 'continue_button_title' ) ); ?>"><?php esc_html_e( 'Button Text:', 'give' ); ?></label> |
|
179 | - <input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'continue_button_title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'continue_button_title' ) ); ?>" value="<?php echo esc_attr( $instance['continue_button_title'] ); ?>" /><br> |
|
180 | - <small class="give-field-description"><?php esc_html_e( 'The button label for displaying the additional payment fields.', 'give' ); ?></small> |
|
178 | + <label for="<?php echo esc_attr($this->get_field_id('continue_button_title')); ?>"><?php esc_html_e('Button Text:', 'give'); ?></label> |
|
179 | + <input type="text" class="widefat" id="<?php echo esc_attr($this->get_field_id('continue_button_title')); ?>" name="<?php echo esc_attr($this->get_field_name('continue_button_title')); ?>" value="<?php echo esc_attr($instance['continue_button_title']); ?>" /><br> |
|
180 | + <small class="give-field-description"><?php esc_html_e('The button label for displaying the additional payment fields.', 'give'); ?></small> |
|
181 | 181 | </p> |
182 | 182 | |
183 | 183 | <?php // Widget: Floating Labels. ?> |
184 | 184 | <p> |
185 | - <label for="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>"><?php esc_html_e( 'Floating Labels (optional):', 'give' ); ?></label><br> |
|
186 | - <label for="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>-global"><input type="radio" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>-global" name="<?php echo esc_attr( $this->get_field_name( 'float_labels' ) ); ?>" value="global" <?php checked( $instance['float_labels'], 'global' ); ?>> <?php echo esc_html__( 'Global Option', 'give' ); ?></label> |
|
187 | - <label for="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>-enabled"><input type="radio" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>-enabled" name="<?php echo esc_attr( $this->get_field_name( 'float_labels' ) ); ?>" value="enabled" <?php checked( $instance['float_labels'], 'enabled' ); ?>> <?php echo esc_html__( 'Yes', 'give' ); ?></label> |
|
188 | - <label for="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>-disabled"><input type="radio" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>-disabled" name="<?php echo esc_attr( $this->get_field_name( 'float_labels' ) ); ?>" value="disabled" <?php checked( $instance['float_labels'], 'disabled' ); ?>> <?php echo esc_html__( 'No', 'give' ); ?></label><br> |
|
185 | + <label for="<?php echo esc_attr($this->get_field_id('float_labels')); ?>"><?php esc_html_e('Floating Labels (optional):', 'give'); ?></label><br> |
|
186 | + <label for="<?php echo esc_attr($this->get_field_id('float_labels')); ?>-global"><input type="radio" class="widefat" id="<?php echo esc_attr($this->get_field_id('float_labels')); ?>-global" name="<?php echo esc_attr($this->get_field_name('float_labels')); ?>" value="global" <?php checked($instance['float_labels'], 'global'); ?>> <?php echo esc_html__('Global Option', 'give'); ?></label> |
|
187 | + <label for="<?php echo esc_attr($this->get_field_id('float_labels')); ?>-enabled"><input type="radio" class="widefat" id="<?php echo esc_attr($this->get_field_id('float_labels')); ?>-enabled" name="<?php echo esc_attr($this->get_field_name('float_labels')); ?>" value="enabled" <?php checked($instance['float_labels'], 'enabled'); ?>> <?php echo esc_html__('Yes', 'give'); ?></label> |
|
188 | + <label for="<?php echo esc_attr($this->get_field_id('float_labels')); ?>-disabled"><input type="radio" class="widefat" id="<?php echo esc_attr($this->get_field_id('float_labels')); ?>-disabled" name="<?php echo esc_attr($this->get_field_name('float_labels')); ?>" value="disabled" <?php checked($instance['float_labels'], 'disabled'); ?>> <?php echo esc_html__('No', 'give'); ?></label><br> |
|
189 | 189 | <small class="give-field-description"> |
190 | 190 | <?php |
191 | 191 | printf( |
192 | 192 | /* translators: %s: http://docs.givewp.com/form-floating-labels */ |
193 | - esc_html__( 'Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give' ), |
|
194 | - esc_url( 'http://docs.givewp.com/form-floating-labels' ) |
|
193 | + esc_html__('Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give'), |
|
194 | + esc_url('http://docs.givewp.com/form-floating-labels') |
|
195 | 195 | ); |
196 | 196 | ?> |
197 | 197 | </small> |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | |
200 | 200 | <?php // Widget: Display Content. ?> |
201 | 201 | <p> |
202 | - <label for="<?php echo esc_attr( $this->get_field_id( 'show_content' ) ); ?>"><?php esc_html_e( 'Display Content (optional):', 'give' ); ?></label><br> |
|
203 | - <label for="<?php echo esc_attr( $this->get_field_id( 'show_content' ) ); ?>-none"><input type="radio" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'show_content' ) ); ?>-none" name="<?php echo esc_attr( $this->get_field_name( 'show_content' ) ); ?>" value="none" <?php checked( $instance['show_content'], 'none' ); ?>> <?php echo esc_html__( 'None', 'give' ); ?></label> |
|
204 | - <label for="<?php echo esc_attr( $this->get_field_id( 'show_content' ) ); ?>-above"><input type="radio" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'show_content' ) ); ?>-above" name="<?php echo esc_attr( $this->get_field_name( 'show_content' ) ); ?>" value="above" <?php checked( $instance['show_content'], 'above' ); ?>> <?php echo esc_html__( 'Above', 'give' ); ?></label> |
|
205 | - <label for="<?php echo esc_attr( $this->get_field_id( 'show_content' ) ); ?>-below"><input type="radio" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'show_content' ) ); ?>-below" name="<?php echo esc_attr( $this->get_field_name( 'show_content' ) ); ?>" value="below" <?php checked( $instance['show_content'], 'below' ); ?>> <?php echo esc_html__( 'Below', 'give' ); ?></label><br> |
|
206 | - <small class="give-field-description"><?php esc_html_e( 'Override the display content setting for this Give form.', 'give' ); ?></small> |
|
202 | + <label for="<?php echo esc_attr($this->get_field_id('show_content')); ?>"><?php esc_html_e('Display Content (optional):', 'give'); ?></label><br> |
|
203 | + <label for="<?php echo esc_attr($this->get_field_id('show_content')); ?>-none"><input type="radio" class="widefat" id="<?php echo esc_attr($this->get_field_id('show_content')); ?>-none" name="<?php echo esc_attr($this->get_field_name('show_content')); ?>" value="none" <?php checked($instance['show_content'], 'none'); ?>> <?php echo esc_html__('None', 'give'); ?></label> |
|
204 | + <label for="<?php echo esc_attr($this->get_field_id('show_content')); ?>-above"><input type="radio" class="widefat" id="<?php echo esc_attr($this->get_field_id('show_content')); ?>-above" name="<?php echo esc_attr($this->get_field_name('show_content')); ?>" value="above" <?php checked($instance['show_content'], 'above'); ?>> <?php echo esc_html__('Above', 'give'); ?></label> |
|
205 | + <label for="<?php echo esc_attr($this->get_field_id('show_content')); ?>-below"><input type="radio" class="widefat" id="<?php echo esc_attr($this->get_field_id('show_content')); ?>-below" name="<?php echo esc_attr($this->get_field_name('show_content')); ?>" value="below" <?php checked($instance['show_content'], 'below'); ?>> <?php echo esc_html__('Below', 'give'); ?></label><br> |
|
206 | + <small class="give-field-description"><?php esc_html_e('Override the display content setting for this Give form.', 'give'); ?></small> |
|
207 | 207 | </div> |
208 | 208 | <?php |
209 | 209 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * @return void |
215 | 215 | */ |
216 | 216 | public function widget_init() { |
217 | - register_widget( $this->self ); |
|
217 | + register_widget($this->self); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * |
226 | 226 | * @return array |
227 | 227 | */ |
228 | - public function update( $new_instance, $old_instance ) { |
|
228 | + public function update($new_instance, $old_instance) { |
|
229 | 229 | $this->flush_widget_cache(); |
230 | 230 | |
231 | 231 | return $new_instance; |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @return void |
238 | 238 | */ |
239 | 239 | public function flush_widget_cache() { |
240 | - wp_cache_delete( $this->self, 'widget' ); |
|
240 | + wp_cache_delete($this->self, 'widget'); |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 |
@@ -12,11 +12,11 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if access directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
19 | -if ( ! class_exists( 'Give_Offline_Donation_Instruction_Email' ) ) : |
|
19 | +if ( ! class_exists('Give_Offline_Donation_Instruction_Email')) : |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Give_Offline_Donation_Instruction_Email |
@@ -36,33 +36,33 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function init() { |
38 | 38 | // Initialize empty payment. |
39 | - $this->payment = new Give_Payment( 0 ); |
|
39 | + $this->payment = new Give_Payment(0); |
|
40 | 40 | |
41 | - $this->load( array( |
|
41 | + $this->load(array( |
|
42 | 42 | 'id' => 'offline-donation-instruction', |
43 | - 'label' => __( 'Offline Donation Instructions', 'give' ), |
|
44 | - 'description' => __( 'Sent to the donor when they submit an offline donation.', 'give' ), |
|
45 | - 'notification_status' => give_is_gateway_active( 'offline' ) ? 'enabled' : 'disabled', |
|
43 | + 'label' => __('Offline Donation Instructions', 'give'), |
|
44 | + 'description' => __('Sent to the donor when they submit an offline donation.', 'give'), |
|
45 | + 'notification_status' => give_is_gateway_active('offline') ? 'enabled' : 'disabled', |
|
46 | 46 | 'form_metabox_setting' => true, |
47 | 47 | 'notification_status_editable' => false, |
48 | 48 | 'preview_email_tag_values' => array( |
49 | - 'payment_method' => esc_html__( 'Offline', 'give' ), |
|
49 | + 'payment_method' => esc_html__('Offline', 'give'), |
|
50 | 50 | ), |
51 | - 'default_email_subject' => esc_attr__( '{donation} - Offline Donation Instructions', 'give' ), |
|
51 | + 'default_email_subject' => esc_attr__('{donation} - Offline Donation Instructions', 'give'), |
|
52 | 52 | 'default_email_message' => give_get_default_offline_donation_email_content(), |
53 | - 'default_email_header' => __( 'Offline Donation Instructions', 'give' ), |
|
53 | + 'default_email_header' => __('Offline Donation Instructions', 'give'), |
|
54 | 54 | 'notices' => array( |
55 | 55 | 'non-notification-status-editable' => sprintf( |
56 | 56 | '%1$s <a href="%2$s">%3$s »</a>', |
57 | - __( 'This notification is automatically toggled based on whether the gateway is enabled or not.', 'give' ), |
|
58 | - esc_url( admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways§ion=offline-donations') ), |
|
59 | - __( 'Edit Setting', 'give' ) |
|
57 | + __('This notification is automatically toggled based on whether the gateway is enabled or not.', 'give'), |
|
58 | + esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways§ion=offline-donations')), |
|
59 | + __('Edit Setting', 'give') |
|
60 | 60 | ) |
61 | 61 | ), |
62 | - ) ); |
|
62 | + )); |
|
63 | 63 | |
64 | - add_action( 'give_insert_payment', array( $this, 'setup_email_notification' ) ); |
|
65 | - add_action( 'give_save_settings_give_settings', array( $this, 'set_notification_status' ), 10, 2 ); |
|
64 | + add_action('give_insert_payment', array($this, 'setup_email_notification')); |
|
65 | + add_action('give_save_settings_give_settings', array($this, 'set_notification_status'), 10, 2); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @return string |
76 | 76 | */ |
77 | - public function get_email_message( $form_id = null ) { |
|
77 | + public function get_email_message($form_id = null) { |
|
78 | 78 | $message = Give_Email_Notification_Util::get_value( |
79 | 79 | $this, |
80 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_message', |
|
80 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_message', |
|
81 | 81 | $form_id, |
82 | 82 | $this->config['default_email_message'] |
83 | 83 | ); |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @return string |
108 | 108 | */ |
109 | - public function get_email_subject( $form_id = null ) { |
|
109 | + public function get_email_subject($form_id = null) { |
|
110 | 110 | $subject = wp_strip_all_tags( |
111 | 111 | Give_Email_Notification_Util::get_value( |
112 | 112 | $this, |
113 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_subject', |
|
113 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_subject', |
|
114 | 114 | $form_id, |
115 | 115 | $this->config['default_email_subject'] |
116 | 116 | ) |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * @param int $form_id |
140 | 140 | * @return array |
141 | 141 | */ |
142 | - public function get_email_attachments( $form_id = null ) { |
|
142 | + public function get_email_attachments($form_id = null) { |
|
143 | 143 | /** |
144 | 144 | * Filter the attachments. |
145 | 145 | * Note: This filter will deprecate soon. |
@@ -202,9 +202,9 @@ discard block |
||
202 | 202 | $this->payment->payment_meta |
203 | 203 | ); |
204 | 204 | |
205 | - Give()->emails->__set( 'from_name', $from_name ); |
|
206 | - Give()->emails->__set( 'from_email', $from_email ); |
|
207 | - Give()->emails->__set( 'headers', apply_filters( 'give_receipt_headers', Give()->emails->get_headers(), $this->payment->ID, $this->payment->payment_meta ) ); |
|
205 | + Give()->emails->__set('from_name', $from_name); |
|
206 | + Give()->emails->__set('from_email', $from_email); |
|
207 | + Give()->emails->__set('headers', apply_filters('give_receipt_headers', Give()->emails->get_headers(), $this->payment->ID, $this->payment->payment_meta)); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -215,11 +215,11 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @param int $payment_id |
217 | 217 | */ |
218 | - public function setup_email_notification( $payment_id ) { |
|
219 | - $this->payment = new Give_Payment( $payment_id ); |
|
218 | + public function setup_email_notification($payment_id) { |
|
219 | + $this->payment = new Give_Payment($payment_id); |
|
220 | 220 | |
221 | 221 | // Exit if not donation was not with offline donation. |
222 | - if ( 'offline' !== $this->payment->gateway ) { |
|
222 | + if ('offline' !== $this->payment->gateway) { |
|
223 | 223 | return; |
224 | 224 | } |
225 | 225 | |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | $this->setup_email_data(); |
228 | 228 | |
229 | 229 | // Send email. |
230 | - $this->send_email_notification( array( |
|
230 | + $this->send_email_notification(array( |
|
231 | 231 | 'payment_id' => $this->payment->ID, |
232 | - ) ); |
|
232 | + )); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -241,18 +241,18 @@ discard block |
||
241 | 241 | * @param $update_options |
242 | 242 | * @param $option_name |
243 | 243 | */ |
244 | - public function set_notification_status( $update_options, $option_name ) { |
|
244 | + public function set_notification_status($update_options, $option_name) { |
|
245 | 245 | // Get updated settings. |
246 | 246 | $update_options = give_get_settings(); |
247 | 247 | |
248 | - $notification_status = isset( $update_options['gateways']['offline'] ) ? 'enabled' : 'disabled'; |
|
248 | + $notification_status = isset($update_options['gateways']['offline']) ? 'enabled' : 'disabled'; |
|
249 | 249 | |
250 | 250 | if ( |
251 | - empty( $update_options["{$this->config['id']}_notification"] ) |
|
251 | + empty($update_options["{$this->config['id']}_notification"]) |
|
252 | 252 | || $notification_status !== $update_options["{$this->config['id']}_notification"] |
253 | 253 | ) { |
254 | 254 | $update_options["{$this->config['id']}_notification"] = $notification_status; |
255 | - update_option( $option_name, $update_options, false ); |
|
255 | + update_option($option_name, $update_options, false); |
|
256 | 256 | } |
257 | 257 | } |
258 | 258 | |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @return array |
270 | 270 | */ |
271 | - public function add_metabox_setting_field( $settings, $form_id ) { |
|
272 | - if ( in_array( 'offline', array_keys( give_get_enabled_payment_gateways($form_id) ) ) ) { |
|
271 | + public function add_metabox_setting_field($settings, $form_id) { |
|
272 | + if (in_array('offline', array_keys(give_get_enabled_payment_gateways($form_id)))) { |
|
273 | 273 | $settings[] = array( |
274 | 274 | 'id' => $this->config['id'], |
275 | 275 | 'title' => $this->config['label'], |
276 | - 'fields' => $this->get_setting_fields( $form_id ), |
|
276 | + 'fields' => $this->get_setting_fields($form_id), |
|
277 | 277 | ); |
278 | 278 | } |
279 | 279 |
@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if access directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | -if ( ! class_exists( 'Give_New_Donor_Register_Email' ) ) : |
|
17 | +if ( ! class_exists('Give_New_Donor_Register_Email')) : |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Give_New_Donor_Register_Email |
@@ -31,35 +31,35 @@ discard block |
||
31 | 31 | * @since 2.0 |
32 | 32 | */ |
33 | 33 | public function init() { |
34 | - $this->load( array( |
|
34 | + $this->load(array( |
|
35 | 35 | 'id' => 'new-donor-register', |
36 | - 'label' => __( 'New User Registration', 'give' ), |
|
37 | - 'description' => __( 'Sent to designated recipient(s) when a new user registers on the site via a donation form.', 'give' ), |
|
36 | + 'label' => __('New User Registration', 'give'), |
|
37 | + 'description' => __('Sent to designated recipient(s) when a new user registers on the site via a donation form.', 'give'), |
|
38 | 38 | 'has_recipient_field' => true, |
39 | 39 | 'notification_status' => 'enabled', |
40 | 40 | 'has_preview_header' => true, |
41 | - 'email_tag_context' => array( 'donor', 'general' ), |
|
41 | + 'email_tag_context' => array('donor', 'general'), |
|
42 | 42 | 'form_metabox_setting' => false, |
43 | 43 | 'default_email_subject' => sprintf( |
44 | 44 | /* translators: %s: site name */ |
45 | - esc_attr__( '[%s] New User Registration', 'give' ), |
|
46 | - get_bloginfo( 'name' ) |
|
45 | + esc_attr__('[%s] New User Registration', 'give'), |
|
46 | + get_bloginfo('name') |
|
47 | 47 | ), |
48 | 48 | 'default_email_message' => $this->get_default_email_message(), |
49 | - 'default_email_header' => __( 'New User Registration', 'give' ), |
|
50 | - ) ); |
|
49 | + 'default_email_header' => __('New User Registration', 'give'), |
|
50 | + )); |
|
51 | 51 | |
52 | 52 | // Setup action hook. |
53 | 53 | add_action( |
54 | 54 | "give_{$this->config['id']}_email_notification", |
55 | - array( $this, 'setup_email_notification' ), |
|
55 | + array($this, 'setup_email_notification'), |
|
56 | 56 | 10, |
57 | 57 | 2 |
58 | 58 | ); |
59 | 59 | |
60 | 60 | add_filter( |
61 | 61 | 'give_email_preview_header', |
62 | - array( $this, 'email_preview_header' ), |
|
62 | + array($this, 'email_preview_header'), |
|
63 | 63 | 10, |
64 | 64 | 2 |
65 | 65 | ); |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * @return string |
75 | 75 | */ |
76 | 76 | function get_default_email_message() { |
77 | - $message = esc_attr__( 'New user registration on your site {sitename}:', 'give' ) . "\r\n\r\n"; |
|
78 | - $message .= esc_attr__( 'Username: {username}', 'give' ) . "\r\n\r\n"; |
|
79 | - $message .= esc_attr__( 'Email: {user_email}', 'give' ) . "\r\n"; |
|
77 | + $message = esc_attr__('New user registration on your site {sitename}:', 'give')."\r\n\r\n"; |
|
78 | + $message .= esc_attr__('Username: {username}', 'give')."\r\n\r\n"; |
|
79 | + $message .= esc_attr__('Email: {user_email}', 'give')."\r\n"; |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Filter the default email message |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return string |
103 | 103 | */ |
104 | - public function setup_email_notification( $user_id, $user_data ) { |
|
104 | + public function setup_email_notification($user_id, $user_data) { |
|
105 | 105 | $this->setup_email_data(); |
106 | 106 | |
107 | - $this->send_email_notification( array( |
|
107 | + $this->send_email_notification(array( |
|
108 | 108 | 'user_id' => $user_id, |
109 | - ) ); |
|
109 | + )); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
@@ -120,42 +120,42 @@ discard block |
||
120 | 120 | * @param Give_New_Donor_Register_Email $email |
121 | 121 | * @return string |
122 | 122 | */ |
123 | - public function email_preview_header( $email_preview_header, $email ) { |
|
123 | + public function email_preview_header($email_preview_header, $email) { |
|
124 | 124 | // Bailout. |
125 | - if ( $this->config['id'] !== $email->config['id'] ) { |
|
125 | + if ($this->config['id'] !== $email->config['id']) { |
|
126 | 126 | return $email_preview_header; |
127 | 127 | } |
128 | 128 | |
129 | 129 | // Payment receipt switcher |
130 | - $user_id = give_check_variable( give_clean( $_GET ), 'isset', 0, 'user_id' ); |
|
130 | + $user_id = give_check_variable(give_clean($_GET), 'isset', 0, 'user_id'); |
|
131 | 131 | |
132 | 132 | // Get payments. |
133 | 133 | $donors = new Give_API(); |
134 | - $donors = give_check_variable( $donors->get_donors(), 'empty', array(), 'donors' ); |
|
134 | + $donors = give_check_variable($donors->get_donors(), 'empty', array(), 'donors'); |
|
135 | 135 | $options = array(); |
136 | 136 | |
137 | 137 | // Default option. |
138 | - $options[0] = esc_html__( 'No donor(s) found.', 'give' ); |
|
138 | + $options[0] = esc_html__('No donor(s) found.', 'give'); |
|
139 | 139 | |
140 | 140 | // Provide nice human readable options. |
141 | - if ( $donors ) { |
|
142 | - $options[0] = esc_html__( '- Select a donor -', 'give' ); |
|
143 | - foreach ( $donors as $donor ) { |
|
141 | + if ($donors) { |
|
142 | + $options[0] = esc_html__('- Select a donor -', 'give'); |
|
143 | + foreach ($donors as $donor) { |
|
144 | 144 | // Exclude customers for which wp user not exist. |
145 | - if ( ! $donor['info']['user_id'] ) { |
|
145 | + if ( ! $donor['info']['user_id']) { |
|
146 | 146 | continue; |
147 | 147 | } |
148 | - $options[ $donor['info']['user_id'] ] = esc_html( '#' . $donor['info']['donor_id'] . ' - ' . $donor['info']['email'] ); |
|
148 | + $options[$donor['info']['user_id']] = esc_html('#'.$donor['info']['donor_id'].' - '.$donor['info']['email']); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
152 | - $request_url_data = wp_parse_url( $_SERVER['REQUEST_URI'] ); |
|
152 | + $request_url_data = wp_parse_url($_SERVER['REQUEST_URI']); |
|
153 | 153 | $query = $request_url_data['query']; |
154 | 154 | |
155 | 155 | // Remove user id query param if set from request url. |
156 | - $query = remove_query_arg( array( 'user_id' ), $query ); |
|
156 | + $query = remove_query_arg(array('user_id'), $query); |
|
157 | 157 | |
158 | - $request_url = home_url( '/?' . str_replace( '', '', $query ) ); |
|
158 | + $request_url = home_url('/?'.str_replace('', '', $query)); |
|
159 | 159 | ?> |
160 | 160 | <script type="text/javascript"> |
161 | 161 | function change_preview() { |
@@ -189,12 +189,12 @@ discard block |
||
189 | 189 | <div class="give_preview_email_user_id_main"> |
190 | 190 | |
191 | 191 | <label for="give_preview_email_user_id" class="give_preview_email_user_id_label"> |
192 | - <?php echo esc_html__( 'Preview email with a donor:', 'give' ); ?> |
|
192 | + <?php echo esc_html__('Preview email with a donor:', 'give'); ?> |
|
193 | 193 | </label> |
194 | 194 | |
195 | 195 | <?php |
196 | 196 | // The select field with 100 latest transactions |
197 | - echo Give()->html->select( array( |
|
197 | + echo Give()->html->select(array( |
|
198 | 198 | 'name' => 'preview_email_user_id', |
199 | 199 | 'selected' => $user_id, |
200 | 200 | 'id' => 'give_preview_email_user_id', |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | 'select_atts' => 'onchange="change_preview()"', |
205 | 205 | 'show_option_all' => false, |
206 | 206 | 'show_option_none' => false, |
207 | - ) ); |
|
207 | + )); |
|
208 | 208 | ?> |
209 | 209 | <!-- Closing tag--> |
210 | 210 | </div> |
@@ -12,11 +12,11 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if access directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
19 | -if ( ! class_exists( 'Give_New_Offline_Donation_Email' ) ) : |
|
19 | +if ( ! class_exists('Give_New_Offline_Donation_Email')) : |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Give_New_Offline_Donation_Email |
@@ -36,33 +36,33 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function init() { |
38 | 38 | // Initialize empty payment. |
39 | - $this->payment = new Give_Payment( 0 ); |
|
39 | + $this->payment = new Give_Payment(0); |
|
40 | 40 | |
41 | - $this->load( array( |
|
41 | + $this->load(array( |
|
42 | 42 | 'id' => 'new-offline-donation', |
43 | - 'label' => __( 'New Offline Donation', 'give' ), |
|
44 | - 'description' => __( 'Sent to designated recipient(s) for a new (pending) offline donation.', 'give' ), |
|
43 | + 'label' => __('New Offline Donation', 'give'), |
|
44 | + 'description' => __('Sent to designated recipient(s) for a new (pending) offline donation.', 'give'), |
|
45 | 45 | 'has_recipient_field' => true, |
46 | - 'notification_status' => give_is_gateway_active( 'offline' ) ? 'enabled' : 'disabled', |
|
46 | + 'notification_status' => give_is_gateway_active('offline') ? 'enabled' : 'disabled', |
|
47 | 47 | 'notification_status_editable' => false, |
48 | 48 | 'preview_email_tags_values' => array( |
49 | - 'payment_method' => esc_html__( 'Offline', 'give' ), |
|
49 | + 'payment_method' => esc_html__('Offline', 'give'), |
|
50 | 50 | ), |
51 | 51 | 'default_email_subject' => $this->get_default_email_subject(), |
52 | 52 | 'default_email_message' => $this->get_default_email_message(), |
53 | - 'default_email_header' => __( 'New Offline Donation!', 'give' ), |
|
53 | + 'default_email_header' => __('New Offline Donation!', 'give'), |
|
54 | 54 | 'notices' => array( |
55 | 55 | 'non-notification-status-editable' => sprintf( |
56 | 56 | '%1$s <a href="%2$s">%3$s »</a>', |
57 | - __( 'This notification is automatically toggled based on whether the gateway is enabled or not.', 'give' ), |
|
58 | - esc_url( admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways§ion=offline-donations') ), |
|
59 | - __( 'Edit Setting', 'give' ) |
|
57 | + __('This notification is automatically toggled based on whether the gateway is enabled or not.', 'give'), |
|
58 | + esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=gateways§ion=offline-donations')), |
|
59 | + __('Edit Setting', 'give') |
|
60 | 60 | ) |
61 | 61 | ), |
62 | - ) ); |
|
62 | + )); |
|
63 | 63 | |
64 | - add_action( 'give_insert_payment', array( $this, 'setup_email_notification' ) ); |
|
65 | - add_action( 'give_save_settings_give_settings', array( $this, 'set_notification_status' ), 10, 2 ); |
|
64 | + add_action('give_insert_payment', array($this, 'setup_email_notification')); |
|
65 | + add_action('give_save_settings_give_settings', array($this, 'set_notification_status'), 10, 2); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | $subject = apply_filters( |
83 | 83 | 'give_offline_admin_donation_notification_subject', |
84 | - __( 'New Pending Donation', 'give' ) |
|
84 | + __('New Pending Donation', 'give') |
|
85 | 85 | ); |
86 | 86 | |
87 | 87 | /** |
@@ -106,18 +106,18 @@ discard block |
||
106 | 106 | * @return string |
107 | 107 | */ |
108 | 108 | public function get_default_email_message() { |
109 | - $message = __( 'Dear Admin,', 'give' ) . "\n\n"; |
|
110 | - $message .= __( 'An offline donation has been made on your website:', 'give' ) . ' ' . get_bloginfo( 'name' ) . ' '; |
|
111 | - $message .= __( '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"; |
|
109 | + $message = __('Dear Admin,', 'give')."\n\n"; |
|
110 | + $message .= __('An offline donation has been made on your website:', 'give').' '.get_bloginfo('name').' '; |
|
111 | + $message .= __('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"; |
|
112 | 112 | |
113 | - $message .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
114 | - $message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n"; |
|
113 | + $message .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
114 | + $message .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n\n"; |
|
115 | 115 | |
116 | 116 | $message .= sprintf( |
117 | 117 | '<a href="%1$s">%2$s</a>', |
118 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $this->payment->ID ), |
|
119 | - __( 'Click Here to View and/or Update Donation Details', 'give' ) |
|
120 | - ) . "\n\n"; |
|
118 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$this->payment->ID), |
|
119 | + __('Click Here to View and/or Update Donation Details', 'give') |
|
120 | + )."\n\n"; |
|
121 | 121 | |
122 | 122 | /** |
123 | 123 | * Filter the donation receipt email message |
@@ -155,10 +155,10 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @return string |
157 | 157 | */ |
158 | - public function get_email_message( $form_id = null ) { |
|
158 | + public function get_email_message($form_id = null) { |
|
159 | 159 | $message = Give_Email_Notification_Util::get_value( |
160 | 160 | $this, |
161 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_message', |
|
161 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_message', |
|
162 | 162 | $form_id, |
163 | 163 | $this->config['default_email_message'] |
164 | 164 | ); |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * |
199 | 199 | * @return array |
200 | 200 | */ |
201 | - public function get_email_attachments( $form_id = null ) { |
|
201 | + public function get_email_attachments($form_id = null) { |
|
202 | 202 | /** |
203 | 203 | * Filter the attachments. |
204 | 204 | * Note: This filter will deprecate soon. |
@@ -249,11 +249,11 @@ discard block |
||
249 | 249 | * |
250 | 250 | * @param int $payment_id |
251 | 251 | */ |
252 | - public function setup_email_notification( $payment_id ) { |
|
253 | - $this->payment = new Give_Payment( $payment_id ); |
|
252 | + public function setup_email_notification($payment_id) { |
|
253 | + $this->payment = new Give_Payment($payment_id); |
|
254 | 254 | |
255 | 255 | // Exit if not donation was not with offline donation. |
256 | - if ( 'offline' !== $this->payment->gateway ) { |
|
256 | + if ('offline' !== $this->payment->gateway) { |
|
257 | 257 | return; |
258 | 258 | } |
259 | 259 | |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | $this->setup_email_data(); |
262 | 262 | |
263 | 263 | // Send email. |
264 | - $this->send_email_notification( array( |
|
264 | + $this->send_email_notification(array( |
|
265 | 265 | 'payment_id' => $this->payment->ID, |
266 | - ) ); |
|
266 | + )); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -275,18 +275,18 @@ discard block |
||
275 | 275 | * @param $update_options |
276 | 276 | * @param $option_name |
277 | 277 | */ |
278 | - public function set_notification_status( $update_options, $option_name ) { |
|
278 | + public function set_notification_status($update_options, $option_name) { |
|
279 | 279 | // Get updated settings. |
280 | 280 | $update_options = give_get_settings(); |
281 | 281 | |
282 | - $notification_status = isset( $update_options['gateways']['offline'] ) ? 'enabled' : 'disabled'; |
|
282 | + $notification_status = isset($update_options['gateways']['offline']) ? 'enabled' : 'disabled'; |
|
283 | 283 | |
284 | 284 | if ( |
285 | - empty( $update_options[ "{$this->config['id']}_notification" ] ) |
|
286 | - || $notification_status !== $update_options[ "{$this->config['id']}_notification" ] |
|
285 | + empty($update_options["{$this->config['id']}_notification"]) |
|
286 | + || $notification_status !== $update_options["{$this->config['id']}_notification"] |
|
287 | 287 | ) { |
288 | - $update_options[ "{$this->config['id']}_notification" ] = $notification_status; |
|
289 | - update_option( $option_name, $update_options, false ); |
|
288 | + $update_options["{$this->config['id']}_notification"] = $notification_status; |
|
289 | + update_option($option_name, $update_options, false); |
|
290 | 290 | } |
291 | 291 | } |
292 | 292 | |
@@ -301,13 +301,13 @@ discard block |
||
301 | 301 | * |
302 | 302 | * @return array |
303 | 303 | */ |
304 | - public function add_metabox_setting_field( $settings, $form_id ) { |
|
304 | + public function add_metabox_setting_field($settings, $form_id) { |
|
305 | 305 | |
306 | - if ( in_array( 'offline', array_keys( give_get_enabled_payment_gateways($form_id) ) ) ) { |
|
306 | + if (in_array('offline', array_keys(give_get_enabled_payment_gateways($form_id)))) { |
|
307 | 307 | $settings[] = array( |
308 | 308 | 'id' => $this->config['id'], |
309 | 309 | 'title' => $this->config['label'], |
310 | - 'fields' => $this->get_setting_fields( $form_id ), |
|
310 | + 'fields' => $this->get_setting_fields($form_id), |
|
311 | 311 | ); |
312 | 312 | } |
313 | 313 |
@@ -11,11 +11,11 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if access directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
18 | -if ( ! class_exists( 'Give_Donation_Receipt_Email' ) ) : |
|
18 | +if ( ! class_exists('Give_Donation_Receipt_Email')) : |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Give_Donation_Receipt_Email |
@@ -35,22 +35,22 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function init() { |
37 | 37 | // Initialize empty payment. |
38 | - $this->payment = new Give_Payment( 0 ); |
|
38 | + $this->payment = new Give_Payment(0); |
|
39 | 39 | |
40 | - $this->load( array( |
|
40 | + $this->load(array( |
|
41 | 41 | 'id' => 'donation-receipt', |
42 | - 'label' => __( 'Donation Receipt', 'give' ), |
|
43 | - 'description' => __( 'Sent to the donor when their donation completes or a pending donation is marked as complete.', 'give' ), |
|
42 | + 'label' => __('Donation Receipt', 'give'), |
|
43 | + 'description' => __('Sent to the donor when their donation completes or a pending donation is marked as complete.', 'give'), |
|
44 | 44 | 'notification_status' => 'enabled', |
45 | 45 | 'form_metabox_setting' => true, |
46 | - 'recipient_group_name' => __( 'Donor', 'give' ), |
|
47 | - 'default_email_subject' => esc_attr__( 'Donation Receipt', 'give' ), |
|
46 | + 'recipient_group_name' => __('Donor', 'give'), |
|
47 | + 'default_email_subject' => esc_attr__('Donation Receipt', 'give'), |
|
48 | 48 | 'default_email_message' => give_get_default_donation_receipt_email(), |
49 | - 'default_email_header' => __( 'Donation Receipt', 'give' ), |
|
50 | - ) ); |
|
49 | + 'default_email_header' => __('Donation Receipt', 'give'), |
|
50 | + )); |
|
51 | 51 | |
52 | - add_action( "give_{$this->config['id']}_email_notification", array( $this, 'send_donation_receipt' ) ); |
|
53 | - add_action( 'give_email_links', array( $this, 'resend_donation_receipt' ) ); |
|
52 | + add_action("give_{$this->config['id']}_email_notification", array($this, 'send_donation_receipt')); |
|
53 | + add_action('give_email_links', array($this, 'resend_donation_receipt')); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | * @param int $form_id |
63 | 63 | * @return string |
64 | 64 | */ |
65 | - public function get_email_subject( $form_id = null ) { |
|
65 | + public function get_email_subject($form_id = null) { |
|
66 | 66 | $subject = wp_strip_all_tags( |
67 | 67 | Give_Email_Notification_Util::get_value( |
68 | 68 | $this, |
69 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_subject', |
|
69 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_subject', |
|
70 | 70 | $form_id, |
71 | 71 | $this->config['default_email_subject'] |
72 | 72 | ) |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | * @param int $form_id |
110 | 110 | * @return string |
111 | 111 | */ |
112 | - public function get_email_message( $form_id = null ) { |
|
112 | + public function get_email_message($form_id = null) { |
|
113 | 113 | $message = Give_Email_Notification_Util::get_value( |
114 | 114 | $this, |
115 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_message', |
|
115 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_message', |
|
116 | 116 | $form_id, |
117 | 117 | $this->config['default_email_message'] |
118 | 118 | ); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @since 1.0 |
125 | 125 | */ |
126 | 126 | $message = apply_filters( |
127 | - 'give_donation_receipt_' . Give()->emails->get_template(), |
|
127 | + 'give_donation_receipt_'.Give()->emails->get_template(), |
|
128 | 128 | $message, |
129 | 129 | $this->payment->ID, |
130 | 130 | $this->payment->payment_meta |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @param int $form_id |
168 | 168 | * @return array |
169 | 169 | */ |
170 | - public function get_email_attachments( $form_id = null) { |
|
170 | + public function get_email_attachments($form_id = null) { |
|
171 | 171 | /** |
172 | 172 | * Filter the attachments. |
173 | 173 | * Note: this filter will deprecate soon. |
@@ -236,8 +236,8 @@ discard block |
||
236 | 236 | $this->payment->payment_meta |
237 | 237 | ); |
238 | 238 | |
239 | - Give()->emails->__set( 'from_name', $from_name ); |
|
240 | - Give()->emails->__set( 'from_email', $from_email ); |
|
239 | + Give()->emails->__set('from_name', $from_name); |
|
240 | + Give()->emails->__set('from_email', $from_email); |
|
241 | 241 | |
242 | 242 | /** |
243 | 243 | * Filters the donation receipt's email headers. |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $this->payment->payment_meta |
255 | 255 | ); |
256 | 256 | |
257 | - Give()->emails->__set( 'headers', $headers ); |
|
257 | + Give()->emails->__set('headers', $headers); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
@@ -265,16 +265,16 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @param $payment_id |
267 | 267 | */ |
268 | - public function send_donation_receipt( $payment_id ) { |
|
269 | - $this->payment = new Give_Payment( $payment_id ); |
|
268 | + public function send_donation_receipt($payment_id) { |
|
269 | + $this->payment = new Give_Payment($payment_id); |
|
270 | 270 | |
271 | 271 | // Setup email data. |
272 | 272 | $this->setup_email_data(); |
273 | 273 | |
274 | 274 | // Send email. |
275 | - $this->send_email_notification( array( |
|
275 | + $this->send_email_notification(array( |
|
276 | 276 | 'payment_id' => $this->payment->ID, |
277 | - ) ); |
|
277 | + )); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -285,35 +285,35 @@ discard block |
||
285 | 285 | * |
286 | 286 | * @param array $data Donation details. |
287 | 287 | */ |
288 | - public function resend_donation_receipt( $data ) { |
|
289 | - $purchase_id = absint( $data['purchase_id'] ); |
|
288 | + public function resend_donation_receipt($data) { |
|
289 | + $purchase_id = absint($data['purchase_id']); |
|
290 | 290 | |
291 | - if ( empty( $purchase_id ) ) { |
|
291 | + if (empty($purchase_id)) { |
|
292 | 292 | return; |
293 | 293 | } |
294 | 294 | |
295 | 295 | // Get donation payment information. |
296 | - $this->payment = new Give_Payment( $purchase_id ); |
|
296 | + $this->payment = new Give_Payment($purchase_id); |
|
297 | 297 | |
298 | - if ( ! current_user_can( 'edit_give_payments', $this->payment->ID ) ) { |
|
299 | - wp_die( esc_html__( 'You do not have permission to edit donations.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
298 | + if ( ! current_user_can('edit_give_payments', $this->payment->ID)) { |
|
299 | + wp_die(esc_html__('You do not have permission to edit donations.', 'give'), esc_html__('Error', 'give'), array( |
|
300 | 300 | 'response' => 403, |
301 | - ) ); |
|
301 | + )); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | // Setup email data. |
305 | 305 | $this->setup_email_data(); |
306 | 306 | |
307 | 307 | // Send email. |
308 | - $this->send_email_notification( array( |
|
308 | + $this->send_email_notification(array( |
|
309 | 309 | 'payment_id' => $this->payment->ID, |
310 | - ) ); |
|
310 | + )); |
|
311 | 311 | |
312 | - wp_redirect( add_query_arg( array( |
|
312 | + wp_redirect(add_query_arg(array( |
|
313 | 313 | 'give-messages[]' => 'email-sent', |
314 | 314 | 'give-action' => false, |
315 | 315 | 'purchase_id' => false, |
316 | - ) ) ); |
|
316 | + ))); |
|
317 | 317 | exit; |
318 | 318 | } |
319 | 319 | } |
@@ -13,11 +13,11 @@ discard block |
||
13 | 13 | */ |
14 | 14 | |
15 | 15 | // Exit if access directly. |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if ( ! defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
20 | -if ( ! class_exists( 'Give_New_Donation_Email' ) ) : |
|
20 | +if ( ! class_exists('Give_New_Donation_Email')) : |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * Give_New_Donation_Email |
@@ -37,21 +37,21 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function init() { |
39 | 39 | // Initialize empty payment. |
40 | - $this->payment = new Give_Payment( 0 ); |
|
40 | + $this->payment = new Give_Payment(0); |
|
41 | 41 | |
42 | - $this->load( array( |
|
42 | + $this->load(array( |
|
43 | 43 | 'id' => 'new-donation', |
44 | - 'label' => __( 'New Donation', 'give' ), |
|
45 | - 'description' => __( 'Sent to designated recipient(s) when a new donation is received or a pending donation is marked as complete.', 'give' ), |
|
44 | + 'label' => __('New Donation', 'give'), |
|
45 | + 'description' => __('Sent to designated recipient(s) when a new donation is received or a pending donation is marked as complete.', 'give'), |
|
46 | 46 | 'has_recipient_field' => true, |
47 | 47 | 'notification_status' => 'enabled', |
48 | 48 | 'form_metabox_setting' => true, |
49 | - 'default_email_subject' => esc_attr__( 'New Donation - #{payment_id}', 'give' ), |
|
49 | + 'default_email_subject' => esc_attr__('New Donation - #{payment_id}', 'give'), |
|
50 | 50 | 'default_email_message' => give_get_default_donation_notification_email(), |
51 | - 'default_email_header' => __( 'New Donation!', 'give' ), |
|
52 | - ) ); |
|
51 | + 'default_email_header' => __('New Donation!', 'give'), |
|
52 | + )); |
|
53 | 53 | |
54 | - add_action( "give_{$this->config['id']}_email_notification", array( $this, 'setup_email_notification' ) ); |
|
54 | + add_action("give_{$this->config['id']}_email_notification", array($this, 'setup_email_notification')); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return string |
66 | 66 | */ |
67 | - public function get_email_subject( $form_id = null ) { |
|
67 | + public function get_email_subject($form_id = null) { |
|
68 | 68 | $subject = wp_strip_all_tags( |
69 | 69 | Give_Email_Notification_Util::get_value( |
70 | 70 | $this, |
71 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_subject', |
|
71 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_subject', |
|
72 | 72 | $form_id, |
73 | 73 | $this->config['default_email_subject'] |
74 | 74 | ) |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @since 1.0 |
82 | 82 | */ |
83 | - $subject = apply_filters( 'give_admin_donation_notification_subject', $subject, $this->payment->ID ); |
|
83 | + $subject = apply_filters('give_admin_donation_notification_subject', $subject, $this->payment->ID); |
|
84 | 84 | |
85 | 85 | /** |
86 | 86 | * Filters the donation notification subject. |
87 | 87 | * |
88 | 88 | * @since 2.0 |
89 | 89 | */ |
90 | - $subject = apply_filters( "give_{$this->config['id']}_get_email_subject", $subject, $this, $form_id ); |
|
90 | + $subject = apply_filters("give_{$this->config['id']}_get_email_subject", $subject, $this, $form_id); |
|
91 | 91 | |
92 | 92 | return $subject; |
93 | 93 | } |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @return string |
105 | 105 | */ |
106 | - public function get_email_message( $form_id = null ) { |
|
106 | + public function get_email_message($form_id = null) { |
|
107 | 107 | $message = Give_Email_Notification_Util::get_value( |
108 | 108 | $this, |
109 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_message', |
|
109 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_message', |
|
110 | 110 | $form_id, |
111 | 111 | $this->config['default_email_message'] |
112 | 112 | ); |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @param int $form_id |
150 | 150 | * @return array |
151 | 151 | */ |
152 | - public function get_email_attachments( $form_id = null ) { |
|
152 | + public function get_email_attachments($form_id = null) { |
|
153 | 153 | /** |
154 | 154 | * Filters the donation notification email attachments. |
155 | 155 | * By default, there is no attachment but plugins can hook in to provide one more multiple. |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | $this->payment->payment_meta |
213 | 213 | ); |
214 | 214 | |
215 | - Give()->emails->__set( 'from_name', $from_name ); |
|
216 | - Give()->emails->__set( 'from_email', $from_email ); |
|
215 | + Give()->emails->__set('from_name', $from_name); |
|
216 | + Give()->emails->__set('from_email', $from_email); |
|
217 | 217 | |
218 | 218 | /** |
219 | 219 | * Filters the donation notification email headers. |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | $this->payment->payment_meta |
228 | 228 | ); |
229 | 229 | |
230 | - Give()->emails->__set( 'headers', $headers ); |
|
230 | + Give()->emails->__set('headers', $headers); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -238,16 +238,16 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @param int $payment_id |
240 | 240 | */ |
241 | - public function setup_email_notification( $payment_id ) { |
|
242 | - $this->payment = new Give_Payment( $payment_id ); |
|
241 | + public function setup_email_notification($payment_id) { |
|
242 | + $this->payment = new Give_Payment($payment_id); |
|
243 | 243 | |
244 | 244 | // Set email data. |
245 | 245 | $this->setup_email_data(); |
246 | 246 | |
247 | 247 | // Send email. |
248 | - $this->send_email_notification( array( |
|
248 | + $this->send_email_notification(array( |
|
249 | 249 | 'payment_id' => $payment_id, |
250 | - ) ); |
|
250 | + )); |
|
251 | 251 | } |
252 | 252 | } |
253 | 253 |
@@ -11,11 +11,11 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if access directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
18 | -if ( ! class_exists( 'Give_Email_Access_Email' ) ) : |
|
18 | +if ( ! class_exists('Give_Email_Access_Email')) : |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Give_Email_Access_Email |
@@ -31,31 +31,31 @@ discard block |
||
31 | 31 | * @since 2.0 |
32 | 32 | */ |
33 | 33 | public function init() { |
34 | - $this->load( array( |
|
34 | + $this->load(array( |
|
35 | 35 | 'id' => 'email-access', |
36 | - 'label' => __( 'Email access', 'give' ), |
|
37 | - 'description' => __( 'Sent when donors request access to their donation history using only their email as verification. (See Settings > General > Access Control)', 'give' ), |
|
38 | - 'notification_status' => give_get_option( 'email_access', 'disabled' ), |
|
36 | + 'label' => __('Email access', 'give'), |
|
37 | + 'description' => __('Sent when donors request access to their donation history using only their email as verification. (See Settings > General > Access Control)', 'give'), |
|
38 | + 'notification_status' => give_get_option('email_access', 'disabled'), |
|
39 | 39 | 'form_metabox_setting' => false, |
40 | 40 | 'notification_status_editable' => false, |
41 | 41 | 'email_tag_context' => 'donor', |
42 | - 'recipient_group_name' => __( 'Donor', 'give' ), |
|
43 | - 'default_email_subject' => sprintf( __( 'Please confirm your email for %s', 'give' ), get_bloginfo( 'url' ) ), |
|
42 | + 'recipient_group_name' => __('Donor', 'give'), |
|
43 | + 'default_email_subject' => sprintf(__('Please confirm your email for %s', 'give'), get_bloginfo('url')), |
|
44 | 44 | 'default_email_message' => $this->get_default_email_message(), |
45 | - 'default_email_header' => __( 'Confirm Email', 'give' ), |
|
45 | + 'default_email_header' => __('Confirm Email', 'give'), |
|
46 | 46 | 'notices' => array( |
47 | 47 | 'non-notification-status-editable' => sprintf( |
48 | 48 | '%1$s <a href="%2$s">%3$s »</a>', |
49 | - __( 'This notification is automatically toggled based on whether the email access is enabled or not.', 'give' ), |
|
50 | - esc_url( admin_url('edit.php?post_type=give_forms&page=give-settings&tab=general§ion=access-control') ), |
|
51 | - __( 'Edit Setting', 'give' ) |
|
49 | + __('This notification is automatically toggled based on whether the email access is enabled or not.', 'give'), |
|
50 | + esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=general§ion=access-control')), |
|
51 | + __('Edit Setting', 'give') |
|
52 | 52 | ) |
53 | 53 | ), |
54 | - ) ); |
|
54 | + )); |
|
55 | 55 | |
56 | - add_filter( "give_{$this->config['id']}_email_notification", array( $this, 'setup_email_notification' ), 10, 2 ); |
|
57 | - add_action( 'give_save_settings_give_settings', array( $this, 'set_notification_status' ), 10, 2 ); |
|
58 | - add_filter( 'give_email_preview_header', array( $this, 'email_preview_header' ), 10, 2 ); |
|
56 | + add_filter("give_{$this->config['id']}_email_notification", array($this, 'setup_email_notification'), 10, 2); |
|
57 | + add_action('give_save_settings_give_settings', array($this, 'set_notification_status'), 10, 2); |
|
58 | + add_filter('give_email_preview_header', array($this, 'email_preview_header'), 10, 2); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @return string |
70 | 70 | */ |
71 | - public function get_email_subject( $form_id = null ) { |
|
71 | + public function get_email_subject($form_id = null) { |
|
72 | 72 | $subject = wp_strip_all_tags( |
73 | 73 | Give_Email_Notification_Util::get_value( |
74 | 74 | $this, |
75 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_subject', |
|
75 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_subject', |
|
76 | 76 | $form_id, |
77 | 77 | $this->config['default_email_subject'] |
78 | 78 | ) |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @since 1.0 |
86 | 86 | */ |
87 | - $subject = apply_filters( 'give_email_access_token_subject', $subject ); |
|
87 | + $subject = apply_filters('give_email_access_token_subject', $subject); |
|
88 | 88 | |
89 | 89 | /** |
90 | 90 | * Filters the donation notification subject. |
91 | 91 | * |
92 | 92 | * @since 2.0 |
93 | 93 | */ |
94 | - $subject = apply_filters( "give_{$this->config['id']}_get_email_subject", $subject, $this, $form_id ); |
|
94 | + $subject = apply_filters("give_{$this->config['id']}_get_email_subject", $subject, $this, $form_id); |
|
95 | 95 | |
96 | 96 | return $subject; |
97 | 97 | } |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return string |
109 | 109 | */ |
110 | - public function get_email_message( $form_id = null ) { |
|
110 | + public function get_email_message($form_id = null) { |
|
111 | 111 | $message = Give_Email_Notification_Util::get_value( |
112 | 112 | $this, |
113 | - Give_Email_Setting_Field::get_prefix( $this, $form_id ) . 'email_message', |
|
113 | + Give_Email_Setting_Field::get_prefix($this, $form_id).'email_message', |
|
114 | 114 | $form_id, |
115 | 115 | $this->config['default_email_message'] |
116 | 116 | ); |
@@ -121,14 +121,14 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @since 1.0 |
123 | 123 | */ |
124 | - $message = apply_filters( 'give_email_access_token_message', $message ); |
|
124 | + $message = apply_filters('give_email_access_token_message', $message); |
|
125 | 125 | |
126 | 126 | /** |
127 | 127 | * Filter the email message |
128 | 128 | * |
129 | 129 | * @since 2.0 |
130 | 130 | */ |
131 | - $message = apply_filters( "give_{$this->config['id']}_get_default_email_message", $message, $this, $form_id ); |
|
131 | + $message = apply_filters("give_{$this->config['id']}_get_default_email_message", $message, $this, $form_id); |
|
132 | 132 | |
133 | 133 | return $message; |
134 | 134 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @param int $form_id |
144 | 144 | * @return array |
145 | 145 | */ |
146 | - public function get_email_attachments( $form_id = null ) { |
|
146 | + public function get_email_attachments($form_id = null) { |
|
147 | 147 | /** |
148 | 148 | * Filters the donation notification email attachments. |
149 | 149 | * By default, there is no attachment but plugins can hook in to provide one more multiple. |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @since 1.0 |
153 | 153 | */ |
154 | - $attachments = apply_filters( 'give_admin_donation_notification_attachments', array() ); |
|
154 | + $attachments = apply_filters('give_admin_donation_notification_attachments', array()); |
|
155 | 155 | |
156 | 156 | /** |
157 | 157 | * Filters the donation notification email attachments. |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * |
160 | 160 | * @since 2.0 |
161 | 161 | */ |
162 | - $attachments = apply_filters( "give_{$this->config['id']}_get_email_attachments", $attachments, $this, $form_id ); |
|
162 | + $attachments = apply_filters("give_{$this->config['id']}_get_email_attachments", $attachments, $this, $form_id); |
|
163 | 163 | |
164 | 164 | return $attachments; |
165 | 165 | } |
@@ -174,11 +174,11 @@ discard block |
||
174 | 174 | * @return string |
175 | 175 | */ |
176 | 176 | public function get_default_email_message() { |
177 | - $message = __( 'Please click the link to access your donation history on {site_url}. If you did not request this email, please contact {admin_email}.', 'give' ) . "\n\n"; |
|
178 | - $message .= '{email_access_link}' . "\n\n"; |
|
177 | + $message = __('Please click the link to access your donation history on {site_url}. If you did not request this email, please contact {admin_email}.', 'give')."\n\n"; |
|
178 | + $message .= '{email_access_link}'."\n\n"; |
|
179 | 179 | $message .= "\n\n"; |
180 | - $message .= __( 'Sincerely,', 'give' ) . "\n"; |
|
181 | - $message .= get_bloginfo( 'name' ) . "\n"; |
|
180 | + $message .= __('Sincerely,', 'give')."\n"; |
|
181 | + $message .= get_bloginfo('name')."\n"; |
|
182 | 182 | |
183 | 183 | /** |
184 | 184 | * Filter the new donation email message |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @param string $message |
189 | 189 | */ |
190 | - return apply_filters( "give_{$this->config['id']}_get_default_email_message", $message, $this ); |
|
190 | + return apply_filters("give_{$this->config['id']}_get_default_email_message", $message, $this); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -201,15 +201,15 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @return string |
203 | 203 | */ |
204 | - public function get_email_header( $form_id = null ) { |
|
205 | - $subject = parent::get_email_header( $form_id ); |
|
204 | + public function get_email_header($form_id = null) { |
|
205 | + $subject = parent::get_email_header($form_id); |
|
206 | 206 | |
207 | 207 | /** |
208 | 208 | * Filter the email header |
209 | 209 | * |
210 | 210 | * @since 1.0 |
211 | 211 | */ |
212 | - $subject = apply_filters( 'give_email_access_token_heading', $subject ); |
|
212 | + $subject = apply_filters('give_email_access_token_heading', $subject); |
|
213 | 213 | |
214 | 214 | return $subject; |
215 | 215 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @since 1.0 |
229 | 229 | */ |
230 | - $from_name = apply_filters( 'give_donation_from_name', Give()->emails->get_from_name() ); |
|
230 | + $from_name = apply_filters('give_donation_from_name', Give()->emails->get_from_name()); |
|
231 | 231 | |
232 | 232 | /** |
233 | 233 | * Filters the from email. |
@@ -235,19 +235,19 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @since 1.0 |
237 | 237 | */ |
238 | - $from_email = apply_filters( 'give_donation_from_address', Give()->emails->get_from_address() ); |
|
238 | + $from_email = apply_filters('give_donation_from_address', Give()->emails->get_from_address()); |
|
239 | 239 | |
240 | - Give()->emails->__set( 'from_name', $from_name ); |
|
241 | - Give()->emails->__set( 'from_email', $from_email ); |
|
240 | + Give()->emails->__set('from_name', $from_name); |
|
241 | + Give()->emails->__set('from_email', $from_email); |
|
242 | 242 | |
243 | 243 | /** |
244 | 244 | * Filters the donation notification email headers. |
245 | 245 | * |
246 | 246 | * @since 1.0 |
247 | 247 | */ |
248 | - $headers = apply_filters( 'give_admin_donation_notification_headers', Give()->emails->get_headers() ); |
|
248 | + $headers = apply_filters('give_admin_donation_notification_headers', Give()->emails->get_headers()); |
|
249 | 249 | |
250 | - Give()->emails->__set( 'headers', $headers ); |
|
250 | + Give()->emails->__set('headers', $headers); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return bool |
263 | 263 | */ |
264 | - public function setup_email_notification( $donor_id, $email ) { |
|
265 | - $donor = Give()->donors->get_donor_by( 'email', $email ); |
|
264 | + public function setup_email_notification($donor_id, $email) { |
|
265 | + $donor = Give()->donors->get_donor_by('email', $email); |
|
266 | 266 | $this->recipient_email = $email; |
267 | 267 | |
268 | 268 | // Set email data. |
@@ -287,17 +287,17 @@ discard block |
||
287 | 287 | * @param $update_options |
288 | 288 | * @param $option_name |
289 | 289 | */ |
290 | - public function set_notification_status( $update_options, $option_name ) { |
|
290 | + public function set_notification_status($update_options, $option_name) { |
|
291 | 291 | // Get updated settings. |
292 | 292 | $update_options = give_get_settings(); |
293 | 293 | |
294 | 294 | if ( |
295 | - ! empty( $update_options['email_access'] ) |
|
296 | - && ! empty( $update_options[ "{$this->config['id']}_notification" ] ) |
|
297 | - && $update_options['email_access'] !== $update_options[ "{$this->config['id']}_notification" ] |
|
295 | + ! empty($update_options['email_access']) |
|
296 | + && ! empty($update_options["{$this->config['id']}_notification"]) |
|
297 | + && $update_options['email_access'] !== $update_options["{$this->config['id']}_notification"] |
|
298 | 298 | ) { |
299 | - $update_options[ "{$this->config['id']}_notification" ] = $update_options['email_access']; |
|
300 | - update_option( $option_name, $update_options, false ); |
|
299 | + $update_options["{$this->config['id']}_notification"] = $update_options['email_access']; |
|
300 | + update_option($option_name, $update_options, false); |
|
301 | 301 | } |
302 | 302 | } |
303 | 303 | |
@@ -312,8 +312,8 @@ discard block |
||
312 | 312 | * @param Give_Email_Access_Email $email |
313 | 313 | * @return string |
314 | 314 | */ |
315 | - public function email_preview_header( $email_preview_header, $email ) { |
|
316 | - if( $this->config['id'] === $email->config['id'] ) { |
|
315 | + public function email_preview_header($email_preview_header, $email) { |
|
316 | + if ($this->config['id'] === $email->config['id']) { |
|
317 | 317 | $email_preview_header = ''; |
318 | 318 | } |
319 | 319 |
@@ -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 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | $dates = give_get_report_dates(); |
27 | 27 | |
28 | 28 | // Determine graph options. |
29 | - switch ( $dates['range'] ) : |
|
29 | + switch ($dates['range']) : |
|
30 | 30 | case 'today': |
31 | 31 | case 'yesterday': |
32 | 32 | $day_by_day = true; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $day_by_day = false; |
39 | 39 | break; |
40 | 40 | case 'other': |
41 | - if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ( $dates['m_start'] != '12' && $dates['m_end'] != '1' ) ) { |
|
41 | + if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ($dates['m_start'] != '12' && $dates['m_end'] != '1')) { |
|
42 | 42 | $day_by_day = false; |
43 | 43 | } else { |
44 | 44 | $day_by_day = true; |
@@ -55,60 +55,60 @@ discard block |
||
55 | 55 | $earnings_data = array(); |
56 | 56 | $sales_data = array(); |
57 | 57 | |
58 | - if ( 'today' === $dates['range'] || 'yesterday' === $dates['range'] ) { |
|
58 | + if ('today' === $dates['range'] || 'yesterday' === $dates['range']) { |
|
59 | 59 | |
60 | 60 | // Hour by hour. |
61 | 61 | $hour = 0; |
62 | - $month = date( 'n', current_time( 'timestamp' ) ); |
|
63 | - while ( $hour <= 23 ) : |
|
62 | + $month = date('n', current_time('timestamp')); |
|
63 | + while ($hour <= 23) : |
|
64 | 64 | |
65 | - $start_date = mktime( $hour, 0, 0, $month, $dates['day'], $dates['year'] ); |
|
66 | - $end_date = mktime( $hour, 59, 59, $month, $dates['day'], $dates['year'] ); |
|
67 | - $sales = $donation_stats->get_sales( 0, $start_date, $end_date ); |
|
68 | - $earnings = $donation_stats->get_earnings( 0, $start_date, $end_date ); |
|
65 | + $start_date = mktime($hour, 0, 0, $month, $dates['day'], $dates['year']); |
|
66 | + $end_date = mktime($hour, 59, 59, $month, $dates['day'], $dates['year']); |
|
67 | + $sales = $donation_stats->get_sales(0, $start_date, $end_date); |
|
68 | + $earnings = $donation_stats->get_earnings(0, $start_date, $end_date); |
|
69 | 69 | |
70 | 70 | $sales_totals += $sales; |
71 | 71 | $earnings_totals += $earnings; |
72 | 72 | |
73 | - $sales_data[] = array( $start_date * 1000, $sales ); |
|
74 | - $earnings_data[] = array( $start_date * 1000, $earnings ); |
|
73 | + $sales_data[] = array($start_date * 1000, $sales); |
|
74 | + $earnings_data[] = array($start_date * 1000, $earnings); |
|
75 | 75 | |
76 | - $hour ++; |
|
76 | + $hour++; |
|
77 | 77 | endwhile; |
78 | 78 | |
79 | - } elseif ( 'this_week' === $dates['range'] || 'last_week' === $dates['range'] ) { |
|
79 | + } elseif ('this_week' === $dates['range'] || 'last_week' === $dates['range']) { |
|
80 | 80 | |
81 | 81 | // Day by day. |
82 | 82 | $day = $dates['day']; |
83 | 83 | $day_end = $dates['day_end']; |
84 | 84 | $month = $dates['m_start']; |
85 | - while ( $day <= $day_end ) : |
|
85 | + while ($day <= $day_end) : |
|
86 | 86 | |
87 | - $start_date = mktime( 0, 0, 0, $month, $day, $dates['year'] ); |
|
88 | - $end_date = mktime( 23, 59, 59, $month, $day, $dates['year'] ); |
|
89 | - $sales = $donation_stats->get_sales( 0, $start_date, $end_date ); |
|
90 | - $earnings = $donation_stats->get_earnings( 0, $start_date, $end_date ); |
|
87 | + $start_date = mktime(0, 0, 0, $month, $day, $dates['year']); |
|
88 | + $end_date = mktime(23, 59, 59, $month, $day, $dates['year']); |
|
89 | + $sales = $donation_stats->get_sales(0, $start_date, $end_date); |
|
90 | + $earnings = $donation_stats->get_earnings(0, $start_date, $end_date); |
|
91 | 91 | |
92 | 92 | $sales_totals += $sales; |
93 | 93 | $earnings_totals += $earnings; |
94 | 94 | |
95 | - $sales_data[] = array( $start_date * 1000, $sales ); |
|
96 | - $earnings_data[] = array( $start_date * 1000, $earnings ); |
|
97 | - $day ++; |
|
95 | + $sales_data[] = array($start_date * 1000, $sales); |
|
96 | + $earnings_data[] = array($start_date * 1000, $earnings); |
|
97 | + $day++; |
|
98 | 98 | endwhile; |
99 | 99 | |
100 | 100 | } else { |
101 | 101 | |
102 | 102 | $y = $dates['year']; |
103 | - while ( $y <= $dates['year_end'] ) : |
|
103 | + while ($y <= $dates['year_end']) : |
|
104 | 104 | |
105 | - if ( $dates['year'] === $dates['year_end'] ) { |
|
105 | + if ($dates['year'] === $dates['year_end']) { |
|
106 | 106 | $month_start = $dates['m_start']; |
107 | 107 | $month_end = $dates['m_end']; |
108 | - } elseif ( $y === $dates['year'] ) { |
|
108 | + } elseif ($y === $dates['year']) { |
|
109 | 109 | $month_start = $dates['m_start']; |
110 | 110 | $month_end = 12; |
111 | - } elseif ( $y === $dates['year_end'] ) { |
|
111 | + } elseif ($y === $dates['year_end']) { |
|
112 | 112 | $month_start = 1; |
113 | 113 | $month_end = $dates['m_end']; |
114 | 114 | } else { |
@@ -117,67 +117,67 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | $i = $month_start; |
120 | - while ( $i <= $month_end ) : |
|
120 | + while ($i <= $month_end) : |
|
121 | 121 | |
122 | - if ( $day_by_day ) { |
|
122 | + if ($day_by_day) { |
|
123 | 123 | |
124 | - if ( $i === $month_end ) { |
|
124 | + if ($i === $month_end) { |
|
125 | 125 | |
126 | 126 | $num_of_days = $dates['day_end']; |
127 | 127 | |
128 | 128 | } else { |
129 | 129 | |
130 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
130 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
131 | 131 | |
132 | 132 | } |
133 | 133 | |
134 | 134 | $d = $dates['day']; |
135 | 135 | |
136 | - while ( $d <= $num_of_days ) : |
|
136 | + while ($d <= $num_of_days) : |
|
137 | 137 | |
138 | - $start_date = mktime( 0, 0, 0, $i, $d, $y ); |
|
139 | - $end_date = mktime( 23, 59, 59, $i, $d, $y ); |
|
140 | - $sales = $donation_stats->get_sales( 0, $start_date, $end_date ); |
|
141 | - $earnings = $donation_stats->get_earnings( 0, $start_date, $end_date ); |
|
138 | + $start_date = mktime(0, 0, 0, $i, $d, $y); |
|
139 | + $end_date = mktime(23, 59, 59, $i, $d, $y); |
|
140 | + $sales = $donation_stats->get_sales(0, $start_date, $end_date); |
|
141 | + $earnings = $donation_stats->get_earnings(0, $start_date, $end_date); |
|
142 | 142 | |
143 | 143 | $sales_totals += $sales; |
144 | 144 | $earnings_totals += $earnings; |
145 | 145 | |
146 | - $sales_data[] = array( $start_date * 1000, $sales ); |
|
147 | - $earnings_data[] = array( $start_date * 1000, $earnings ); |
|
146 | + $sales_data[] = array($start_date * 1000, $sales); |
|
147 | + $earnings_data[] = array($start_date * 1000, $earnings); |
|
148 | 148 | |
149 | - $d ++; |
|
149 | + $d++; |
|
150 | 150 | |
151 | 151 | endwhile; |
152 | 152 | |
153 | 153 | } else { |
154 | 154 | |
155 | 155 | // This Quarter, Last Quarter, This Year, Last Year. |
156 | - $start_date = mktime( 0, 0, 0, $i, 1, $y ); |
|
157 | - $end_date = mktime( 23, 59, 59, $i + 1, 0, $y ); |
|
158 | - $sales = $donation_stats->get_sales( 0, $start_date, $end_date ); |
|
159 | - $earnings = $donation_stats->get_earnings( 0, $start_date, $end_date ); |
|
156 | + $start_date = mktime(0, 0, 0, $i, 1, $y); |
|
157 | + $end_date = mktime(23, 59, 59, $i + 1, 0, $y); |
|
158 | + $sales = $donation_stats->get_sales(0, $start_date, $end_date); |
|
159 | + $earnings = $donation_stats->get_earnings(0, $start_date, $end_date); |
|
160 | 160 | |
161 | 161 | $sales_totals += $sales; |
162 | 162 | $earnings_totals += $earnings; |
163 | 163 | |
164 | - $sales_data[] = array( $start_date * 1000, $sales ); |
|
165 | - $earnings_data[] = array( $start_date * 1000, $earnings ); |
|
164 | + $sales_data[] = array($start_date * 1000, $sales); |
|
165 | + $earnings_data[] = array($start_date * 1000, $earnings); |
|
166 | 166 | |
167 | 167 | } |
168 | 168 | |
169 | - $i ++; |
|
169 | + $i++; |
|
170 | 170 | |
171 | 171 | endwhile; |
172 | 172 | |
173 | - $y ++; |
|
173 | + $y++; |
|
174 | 174 | endwhile; |
175 | 175 | |
176 | 176 | } |
177 | 177 | |
178 | 178 | $data = array( |
179 | - __( 'Income', 'give' ) => $earnings_data, |
|
180 | - __( 'Donations', 'give' ) => $sales_data, |
|
179 | + __('Income', 'give') => $earnings_data, |
|
180 | + __('Donations', 'give') => $sales_data, |
|
181 | 181 | ); |
182 | 182 | |
183 | 183 | // start our own output buffer. |
@@ -190,12 +190,12 @@ discard block |
||
190 | 190 | <div class="inside"> |
191 | 191 | <?php give_reports_graph_controls(); ?> |
192 | 192 | <?php |
193 | - $graph = new Give_Graph( $data, array( 'dataType' => array( 'amount', 'count' ) ) ); |
|
194 | - $graph->set( 'x_mode', 'time' ); |
|
195 | - $graph->set( 'multiple_y_axes', true ); |
|
193 | + $graph = new Give_Graph($data, array('dataType' => array('amount', 'count'))); |
|
194 | + $graph->set('x_mode', 'time'); |
|
195 | + $graph->set('multiple_y_axes', true); |
|
196 | 196 | $graph->display(); |
197 | 197 | |
198 | - if ( 'this_month' === $dates['range'] ) { |
|
198 | + if ('this_month' === $dates['range']) { |
|
199 | 199 | $estimated = give_estimated_monthly_stats(); |
200 | 200 | } |
201 | 201 | ?> |
@@ -204,21 +204,21 @@ discard block |
||
204 | 204 | <table class="widefat reports-table alignleft" style="max-width:450px"> |
205 | 205 | <tbody> |
206 | 206 | <tr> |
207 | - <th scope="row"><strong><?php _e( 'Total income for period:', 'give' ); ?></strong></th> |
|
208 | - <td><?php echo give_currency_filter( give_format_amount( $earnings_totals, array( 'sanitize' => false ) ) ); ?></td> |
|
207 | + <th scope="row"><strong><?php _e('Total income for period:', 'give'); ?></strong></th> |
|
208 | + <td><?php echo give_currency_filter(give_format_amount($earnings_totals, array('sanitize' => false))); ?></td> |
|
209 | 209 | </tr> |
210 | 210 | <tr class="alternate"> |
211 | - <th scope="row"><strong><?php _e( 'Total donations for period:', 'give' ); ?><strong></th> |
|
211 | + <th scope="row"><strong><?php _e('Total donations for period:', 'give'); ?><strong></th> |
|
212 | 212 | <td><?php echo $sales_totals; ?></td> |
213 | 213 | </tr> |
214 | - <?php if ( 'this_month' === $dates['range'] ) : ?> |
|
214 | + <?php if ('this_month' === $dates['range']) : ?> |
|
215 | 215 | <tr> |
216 | - <th scope="row"><strong><?php _e( 'Estimated monthly income:', 'give' ); ?></strong></th> |
|
217 | - <td><?php echo give_currency_filter( give_format_amount( $estimated['earnings'], array( 'sanitize' => false ) ) ); ?></td> |
|
216 | + <th scope="row"><strong><?php _e('Estimated monthly income:', 'give'); ?></strong></th> |
|
217 | + <td><?php echo give_currency_filter(give_format_amount($estimated['earnings'], array('sanitize' => false))); ?></td> |
|
218 | 218 | </tr> |
219 | 219 | <tr class="alternate"> |
220 | - <th scope="row"><strong><?php _e( 'Estimated monthly donations:', 'give' ); ?></strong></th> |
|
221 | - <td><?php echo floor( $estimated['sales'] ); ?></td> |
|
220 | + <th scope="row"><strong><?php _e('Estimated monthly donations:', 'give'); ?></strong></th> |
|
221 | + <td><?php echo floor($estimated['sales']); ?></td> |
|
222 | 222 | </tr> |
223 | 223 | <?php endif; ?> |
224 | 224 | </table> |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @since 1.0 |
233 | 233 | */ |
234 | - do_action( 'give_reports_graph_additional_stats' ); |
|
234 | + do_action('give_reports_graph_additional_stats'); |
|
235 | 235 | ?> |
236 | 236 | |
237 | 237 | </div> |
@@ -253,12 +253,12 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return void |
255 | 255 | */ |
256 | -function give_reports_graph_of_form( $form_id = 0 ) { |
|
256 | +function give_reports_graph_of_form($form_id = 0) { |
|
257 | 257 | // Retrieve the queried dates. |
258 | 258 | $dates = give_get_report_dates(); |
259 | 259 | |
260 | 260 | // Determine graph options. |
261 | - switch ( $dates['range'] ) : |
|
261 | + switch ($dates['range']) : |
|
262 | 262 | case 'today': |
263 | 263 | case 'yesterday': |
264 | 264 | $day_by_day = true; |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $day_by_day = false; |
277 | 277 | break; |
278 | 278 | case 'other': |
279 | - if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] ) { |
|
279 | + if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year']) { |
|
280 | 280 | $day_by_day = false; |
281 | 281 | } else { |
282 | 282 | $day_by_day = true; |
@@ -288,75 +288,75 @@ discard block |
||
288 | 288 | endswitch; |
289 | 289 | |
290 | 290 | $earnings_totals = (float) 0.00; // Total earnings for time period shown. |
291 | - $sales_totals = 0; // Total sales for time period shown. |
|
291 | + $sales_totals = 0; // Total sales for time period shown. |
|
292 | 292 | |
293 | 293 | $earnings_data = array(); |
294 | 294 | $sales_data = array(); |
295 | 295 | $stats = new Give_Payment_Stats(); |
296 | 296 | |
297 | - if ( $dates['range'] == 'today' || $dates['range'] == 'yesterday' ) { |
|
297 | + if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') { |
|
298 | 298 | |
299 | 299 | // Hour by hour |
300 | 300 | $month = $dates['m_start']; |
301 | 301 | $hour = 0; |
302 | 302 | $minute = 0; |
303 | 303 | $second = 0; |
304 | - while ( $hour <= 23 ) : |
|
304 | + while ($hour <= 23) : |
|
305 | 305 | |
306 | - if ( $hour == 23 ) { |
|
306 | + if ($hour == 23) { |
|
307 | 307 | $minute = $second = 59; |
308 | 308 | } |
309 | 309 | |
310 | - $date = mktime( $hour, $minute, $second, $month, $dates['day'], $dates['year'] ); |
|
311 | - $date_end = mktime( $hour + 1, $minute, $second, $month, $dates['day'], $dates['year'] ); |
|
310 | + $date = mktime($hour, $minute, $second, $month, $dates['day'], $dates['year']); |
|
311 | + $date_end = mktime($hour + 1, $minute, $second, $month, $dates['day'], $dates['year']); |
|
312 | 312 | |
313 | - $sales = $stats->get_sales( $form_id, $date, $date_end ); |
|
313 | + $sales = $stats->get_sales($form_id, $date, $date_end); |
|
314 | 314 | $sales_totals += $sales; |
315 | 315 | |
316 | - $earnings = $stats->get_earnings( $form_id, $date, $date_end ); |
|
316 | + $earnings = $stats->get_earnings($form_id, $date, $date_end); |
|
317 | 317 | $earnings_totals += $earnings; |
318 | 318 | |
319 | - $sales_data[] = array( $date * 1000, $sales ); |
|
320 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
319 | + $sales_data[] = array($date * 1000, $sales); |
|
320 | + $earnings_data[] = array($date * 1000, $earnings); |
|
321 | 321 | |
322 | - $hour ++; |
|
322 | + $hour++; |
|
323 | 323 | endwhile; |
324 | 324 | |
325 | - } elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) { |
|
325 | + } elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') { |
|
326 | 326 | |
327 | 327 | // Day by day. |
328 | 328 | $day = $dates['day']; |
329 | 329 | $day_end = $dates['day_end']; |
330 | 330 | $month = $dates['m_start']; |
331 | - while ( $day <= $day_end ) : |
|
331 | + while ($day <= $day_end) : |
|
332 | 332 | |
333 | - $date = mktime( 0, 0, 0, $month, $day, $dates['year'] ); |
|
334 | - $date_end = mktime( 0, 0, 0, $month, $day + 1, $dates['year'] ); |
|
335 | - $sales = $stats->get_sales( $form_id, $date, $date_end ); |
|
333 | + $date = mktime(0, 0, 0, $month, $day, $dates['year']); |
|
334 | + $date_end = mktime(0, 0, 0, $month, $day + 1, $dates['year']); |
|
335 | + $sales = $stats->get_sales($form_id, $date, $date_end); |
|
336 | 336 | $sales_totals += $sales; |
337 | 337 | |
338 | - $earnings = $stats->get_earnings( $form_id, $date, $date_end ); |
|
338 | + $earnings = $stats->get_earnings($form_id, $date, $date_end); |
|
339 | 339 | $earnings_totals += $earnings; |
340 | 340 | |
341 | - $sales_data[] = array( $date * 1000, $sales ); |
|
342 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
341 | + $sales_data[] = array($date * 1000, $sales); |
|
342 | + $earnings_data[] = array($date * 1000, $earnings); |
|
343 | 343 | |
344 | - $day ++; |
|
344 | + $day++; |
|
345 | 345 | endwhile; |
346 | 346 | |
347 | 347 | } else { |
348 | 348 | |
349 | 349 | $y = $dates['year']; |
350 | 350 | |
351 | - while ( $y <= $dates['year_end'] ) : |
|
351 | + while ($y <= $dates['year_end']) : |
|
352 | 352 | |
353 | 353 | $last_year = false; |
354 | 354 | |
355 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
355 | + if ($dates['year'] == $dates['year_end']) { |
|
356 | 356 | $month_start = $dates['m_start']; |
357 | 357 | $month_end = $dates['m_end']; |
358 | 358 | $last_year = true; |
359 | - } elseif ( $y == $dates['year'] ) { |
|
359 | + } elseif ($y == $dates['year']) { |
|
360 | 360 | $month_start = $dates['m_start']; |
361 | 361 | $month_end = 12; |
362 | 362 | } else { |
@@ -365,68 +365,68 @@ discard block |
||
365 | 365 | } |
366 | 366 | |
367 | 367 | $i = $month_start; |
368 | - while ( $i <= $month_end ) : |
|
368 | + while ($i <= $month_end) : |
|
369 | 369 | |
370 | - if ( $day_by_day ) { |
|
370 | + if ($day_by_day) { |
|
371 | 371 | |
372 | - if ( $i == $month_end && $last_year ) { |
|
372 | + if ($i == $month_end && $last_year) { |
|
373 | 373 | |
374 | 374 | $num_of_days = $dates['day_end']; |
375 | 375 | |
376 | 376 | } else { |
377 | 377 | |
378 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
378 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
379 | 379 | |
380 | 380 | } |
381 | 381 | |
382 | 382 | $d = $dates['day']; |
383 | - while ( $d <= $num_of_days ) : |
|
383 | + while ($d <= $num_of_days) : |
|
384 | 384 | |
385 | - $date = mktime( 0, 0, 0, $i, $d, $y ); |
|
386 | - $end_date = mktime( 23, 59, 59, $i, $d, $y ); |
|
385 | + $date = mktime(0, 0, 0, $i, $d, $y); |
|
386 | + $end_date = mktime(23, 59, 59, $i, $d, $y); |
|
387 | 387 | |
388 | - $sales = $stats->get_sales( $form_id, $date, $end_date ); |
|
388 | + $sales = $stats->get_sales($form_id, $date, $end_date); |
|
389 | 389 | $sales_totals += $sales; |
390 | 390 | |
391 | - $earnings = $stats->get_earnings( $form_id, $date, $end_date ); |
|
391 | + $earnings = $stats->get_earnings($form_id, $date, $end_date); |
|
392 | 392 | $earnings_totals += $earnings; |
393 | 393 | |
394 | - $sales_data[] = array( $date * 1000, $sales ); |
|
395 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
396 | - $d ++; |
|
394 | + $sales_data[] = array($date * 1000, $sales); |
|
395 | + $earnings_data[] = array($date * 1000, $earnings); |
|
396 | + $d++; |
|
397 | 397 | |
398 | 398 | endwhile; |
399 | 399 | |
400 | 400 | } else { |
401 | 401 | |
402 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
402 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
403 | 403 | |
404 | - $date = mktime( 0, 0, 0, $i, 1, $y ); |
|
405 | - $end_date = mktime( 23, 59, 59, $i, $num_of_days, $y ); |
|
404 | + $date = mktime(0, 0, 0, $i, 1, $y); |
|
405 | + $end_date = mktime(23, 59, 59, $i, $num_of_days, $y); |
|
406 | 406 | |
407 | - $sales = $stats->get_sales( $form_id, $date, $end_date ); |
|
407 | + $sales = $stats->get_sales($form_id, $date, $end_date); |
|
408 | 408 | $sales_totals += $sales; |
409 | 409 | |
410 | - $earnings = $stats->get_earnings( $form_id, $date, $end_date ); |
|
410 | + $earnings = $stats->get_earnings($form_id, $date, $end_date); |
|
411 | 411 | $earnings_totals += $earnings; |
412 | 412 | |
413 | - $sales_data[] = array( $date * 1000, $sales ); |
|
414 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
413 | + $sales_data[] = array($date * 1000, $sales); |
|
414 | + $earnings_data[] = array($date * 1000, $earnings); |
|
415 | 415 | |
416 | 416 | } |
417 | 417 | |
418 | - $i ++; |
|
418 | + $i++; |
|
419 | 419 | |
420 | 420 | endwhile; |
421 | 421 | |
422 | - $y ++; |
|
422 | + $y++; |
|
423 | 423 | endwhile; |
424 | 424 | |
425 | 425 | } |
426 | 426 | |
427 | 427 | $data = array( |
428 | - __( 'Income', 'give' ) => $earnings_data, |
|
429 | - __( 'Donations', 'give' ) => $sales_data, |
|
428 | + __('Income', 'give') => $earnings_data, |
|
429 | + __('Donations', 'give') => $sales_data, |
|
430 | 430 | ); |
431 | 431 | |
432 | 432 | ?> |
@@ -434,8 +434,8 @@ discard block |
||
434 | 434 | <?php |
435 | 435 | printf( |
436 | 436 | /* translators: %s: form title */ |
437 | - esc_html__( 'Income Report for %s', 'give' ), |
|
438 | - get_the_title( $form_id ) |
|
437 | + esc_html__('Income Report for %s', 'give'), |
|
438 | + get_the_title($form_id) |
|
439 | 439 | ); |
440 | 440 | ?> |
441 | 441 | </span></h3> |
@@ -445,9 +445,9 @@ discard block |
||
445 | 445 | <div class="inside"> |
446 | 446 | <?php give_reports_graph_controls(); ?> |
447 | 447 | <?php |
448 | - $graph = new Give_Graph( $data, array( 'dataType' => array( 'amount', 'count' ) ) ); |
|
449 | - $graph->set( 'x_mode', 'time' ); |
|
450 | - $graph->set( 'multiple_y_axes', true ); |
|
448 | + $graph = new Give_Graph($data, array('dataType' => array('amount', 'count'))); |
|
449 | + $graph->set('x_mode', 'time'); |
|
450 | + $graph->set('multiple_y_axes', true); |
|
451 | 451 | $graph->display(); |
452 | 452 | ?> |
453 | 453 | </div> |
@@ -456,20 +456,20 @@ discard block |
||
456 | 456 | <table class="widefat reports-table alignleft" style="max-width:450px"> |
457 | 457 | <tbody> |
458 | 458 | <tr> |
459 | - <th scope="row"><strong><?php _e( 'Total income for period:', 'give' ); ?></strong></th> |
|
460 | - <td><?php echo give_currency_filter( give_format_amount( $earnings_totals, array( 'sanitize' => false ) ) ); ?></td> |
|
459 | + <th scope="row"><strong><?php _e('Total income for period:', 'give'); ?></strong></th> |
|
460 | + <td><?php echo give_currency_filter(give_format_amount($earnings_totals, array('sanitize' => false))); ?></td> |
|
461 | 461 | </tr> |
462 | 462 | <tr class="alternate"> |
463 | - <th scope="row"><strong><?php _e( 'Total donations for period:', 'give' ); ?></strong></th> |
|
463 | + <th scope="row"><strong><?php _e('Total donations for period:', 'give'); ?></strong></th> |
|
464 | 464 | <td><?php echo $sales_totals; ?></td> |
465 | 465 | </tr> |
466 | 466 | <tr> |
467 | - <th scope="row"><strong><?php _e( 'Average monthly income:', 'give' ); ?></strong></th> |
|
468 | - <td><?php echo give_currency_filter( give_format_amount( give_get_average_monthly_form_earnings( $form_id ), array( 'sanitize' => false ) ) ); ?></td> |
|
467 | + <th scope="row"><strong><?php _e('Average monthly income:', 'give'); ?></strong></th> |
|
468 | + <td><?php echo give_currency_filter(give_format_amount(give_get_average_monthly_form_earnings($form_id), array('sanitize' => false))); ?></td> |
|
469 | 469 | </tr> |
470 | 470 | <tr class="alternate"> |
471 | - <th scope="row"><strong><?php _e( 'Average monthly donations:', 'give' ); ?></strong></th> |
|
472 | - <td><?php echo number_format( give_get_average_monthly_form_sales( $form_id ), 0 ); ?></td> |
|
471 | + <th scope="row"><strong><?php _e('Average monthly donations:', 'give'); ?></strong></th> |
|
472 | + <td><?php echo number_format(give_get_average_monthly_form_sales($form_id), 0); ?></td> |
|
473 | 473 | </tr> |
474 | 474 | </tbody> |
475 | 475 | </table> |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | * |
483 | 483 | * @since 1.0 |
484 | 484 | */ |
485 | - do_action( 'give_reports_graph_additional_stats' ); |
|
485 | + do_action('give_reports_graph_additional_stats'); |
|
486 | 486 | ?> |
487 | 487 | |
488 | 488 | </div> |
@@ -502,26 +502,26 @@ discard block |
||
502 | 502 | function give_reports_graph_controls() { |
503 | 503 | $date_options = apply_filters( |
504 | 504 | 'give_report_date_options', array( |
505 | - 'today' => __( 'Today', 'give' ), |
|
506 | - 'yesterday' => __( 'Yesterday', 'give' ), |
|
507 | - 'this_week' => __( 'This Week', 'give' ), |
|
508 | - 'last_week' => __( 'Last Week', 'give' ), |
|
509 | - 'this_month' => __( 'This Month', 'give' ), |
|
510 | - 'last_month' => __( 'Last Month', 'give' ), |
|
511 | - 'this_quarter' => __( 'This Quarter', 'give' ), |
|
512 | - 'last_quarter' => __( 'Last Quarter', 'give' ), |
|
513 | - 'this_year' => __( 'This Year', 'give' ), |
|
514 | - 'last_year' => __( 'Last Year', 'give' ), |
|
515 | - 'other' => __( 'Custom', 'give' ), |
|
505 | + 'today' => __('Today', 'give'), |
|
506 | + 'yesterday' => __('Yesterday', 'give'), |
|
507 | + 'this_week' => __('This Week', 'give'), |
|
508 | + 'last_week' => __('Last Week', 'give'), |
|
509 | + 'this_month' => __('This Month', 'give'), |
|
510 | + 'last_month' => __('Last Month', 'give'), |
|
511 | + 'this_quarter' => __('This Quarter', 'give'), |
|
512 | + 'last_quarter' => __('Last Quarter', 'give'), |
|
513 | + 'this_year' => __('This Year', 'give'), |
|
514 | + 'last_year' => __('Last Year', 'give'), |
|
515 | + 'other' => __('Custom', 'give'), |
|
516 | 516 | ) |
517 | 517 | ); |
518 | 518 | |
519 | 519 | $dates = give_get_report_dates(); |
520 | 520 | $display = $dates['range'] == 'other' ? '' : 'display: none;'; |
521 | - $tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings'; |
|
521 | + $tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings'; |
|
522 | 522 | |
523 | - if ( empty( $dates['day_end'] ) ) { |
|
524 | - $dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, date( 'n' ), date( 'Y' ) ); |
|
523 | + if (empty($dates['day_end'])) { |
|
524 | + $dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, date('n'), date('Y')); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | /** |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | * |
530 | 530 | * @since 1.0 |
531 | 531 | */ |
532 | - do_action( 'give_report_graph_controls_before' ); |
|
532 | + do_action('give_report_graph_controls_before'); |
|
533 | 533 | ?> |
534 | 534 | <form id="give-graphs-filter" method="get"> |
535 | 535 | <div class="tablenav top"> |
@@ -537,56 +537,56 @@ discard block |
||
537 | 537 | |
538 | 538 | <input type="hidden" name="post_type" value="give_forms" /> |
539 | 539 | <input type="hidden" name="page" value="give-reports" /> |
540 | - <input type="hidden" name="tab" value="<?php echo esc_attr( $tab ); ?>" /> |
|
540 | + <input type="hidden" name="tab" value="<?php echo esc_attr($tab); ?>" /> |
|
541 | 541 | |
542 | - <?php if ( isset( $_GET['form-id'] ) ) : ?> |
|
543 | - <input type="hidden" name="form-id" value="<?php echo absint( $_GET['form-id'] ); ?>" /> |
|
542 | + <?php if (isset($_GET['form-id'])) : ?> |
|
543 | + <input type="hidden" name="form-id" value="<?php echo absint($_GET['form-id']); ?>" /> |
|
544 | 544 | <?php endif; ?> |
545 | 545 | |
546 | 546 | <div id="give-graphs-date-options-wrap"> |
547 | 547 | <select id="give-graphs-date-options" name="range"> |
548 | - <?php foreach ( $date_options as $key => $option ) : ?> |
|
549 | - <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $dates['range'] ); ?>><?php echo esc_html( $option ); ?></option> |
|
548 | + <?php foreach ($date_options as $key => $option) : ?> |
|
549 | + <option value="<?php echo esc_attr($key); ?>"<?php selected($key, $dates['range']); ?>><?php echo esc_html($option); ?></option> |
|
550 | 550 | <?php endforeach; ?> |
551 | 551 | </select> |
552 | 552 | |
553 | - <div id="give-date-range-options" style="<?php echo esc_attr( $display ); ?>"> |
|
554 | - <span class="screen-reader-text"><?php _e( 'From', 'give' ); ?> </span> |
|
553 | + <div id="give-date-range-options" style="<?php echo esc_attr($display); ?>"> |
|
554 | + <span class="screen-reader-text"><?php _e('From', 'give'); ?> </span> |
|
555 | 555 | <select id="give-graphs-month-start" name="m_start" aria-label="Start Month"> |
556 | - <?php for ( $i = 1; $i <= 12; $i ++ ) : ?> |
|
557 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['m_start'] ) ); ?>><?php echo esc_html( give_month_num_to_name( $i ) ); ?></option> |
|
556 | + <?php for ($i = 1; $i <= 12; $i++) : ?> |
|
557 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['m_start'])); ?>><?php echo esc_html(give_month_num_to_name($i)); ?></option> |
|
558 | 558 | <?php endfor; ?> |
559 | 559 | </select> |
560 | 560 | <select id="give-graphs-day-start" name="day" aria-label="Start Day"> |
561 | - <?php for ( $i = 1; $i <= 31; $i ++ ) : ?> |
|
562 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['day'] ) ); ?>><?php echo esc_html( $i ); ?></option> |
|
561 | + <?php for ($i = 1; $i <= 31; $i++) : ?> |
|
562 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['day'])); ?>><?php echo esc_html($i); ?></option> |
|
563 | 563 | <?php endfor; ?> |
564 | 564 | </select> |
565 | 565 | <select id="give-graphs-year-start" name="year" aria-label="Start Year"> |
566 | - <?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?> |
|
567 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['year'] ) ); ?>><?php echo esc_html( $i ); ?></option> |
|
566 | + <?php for ($i = 2007; $i <= date('Y'); $i++) : ?> |
|
567 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['year'])); ?>><?php echo esc_html($i); ?></option> |
|
568 | 568 | <?php endfor; ?> |
569 | 569 | </select> |
570 | - <span class="screen-reader-text"><?php esc_html_e( 'To', 'give' ); ?> </span> |
|
570 | + <span class="screen-reader-text"><?php esc_html_e('To', 'give'); ?> </span> |
|
571 | 571 | <span>–</span> |
572 | 572 | <select id="give-graphs-month-end" name="m_end" aria-label="End Month"> |
573 | - <?php for ( $i = 1; $i <= 12; $i ++ ) : ?> |
|
574 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['m_end'] ) ); ?>><?php echo esc_html( give_month_num_to_name( $i ) ); ?></option> |
|
573 | + <?php for ($i = 1; $i <= 12; $i++) : ?> |
|
574 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['m_end'])); ?>><?php echo esc_html(give_month_num_to_name($i)); ?></option> |
|
575 | 575 | <?php endfor; ?> |
576 | 576 | </select> |
577 | 577 | <select id="give-graphs-day-end" name="day_end" aria-label="End Day"> |
578 | - <?php for ( $i = 1; $i <= 31; $i ++ ) : ?> |
|
579 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['day_end'] ) ); ?>><?php echo esc_html( $i ); ?></option> |
|
578 | + <?php for ($i = 1; $i <= 31; $i++) : ?> |
|
579 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['day_end'])); ?>><?php echo esc_html($i); ?></option> |
|
580 | 580 | <?php endfor; ?> |
581 | 581 | </select> |
582 | 582 | <select id="give-graphs-year-end" name="year_end" aria-label="End Year"> |
583 | - <?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?> |
|
584 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['year_end'] ) ); ?>><?php echo esc_html( $i ); ?></option> |
|
583 | + <?php for ($i = 2007; $i <= date('Y'); $i++) : ?> |
|
584 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['year_end'])); ?>><?php echo esc_html($i); ?></option> |
|
585 | 585 | <?php endfor; ?> |
586 | 586 | </select> |
587 | 587 | </div> |
588 | 588 | |
589 | - <input type="submit" class="button-secondary" value="<?php _e( 'Filter', 'give' ); ?>" /> |
|
589 | + <input type="submit" class="button-secondary" value="<?php _e('Filter', 'give'); ?>" /> |
|
590 | 590 | </div> |
591 | 591 | |
592 | 592 | <input type="hidden" name="give_action" value="filter_reports" /> |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | * |
600 | 600 | * @since 1.0 |
601 | 601 | */ |
602 | - do_action( 'give_report_graph_controls_after' ); |
|
602 | + do_action('give_report_graph_controls_after'); |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | /** |
@@ -615,66 +615,66 @@ discard block |
||
615 | 615 | function give_get_report_dates() { |
616 | 616 | $dates = array(); |
617 | 617 | |
618 | - $current_time = current_time( 'timestamp' ); |
|
618 | + $current_time = current_time('timestamp'); |
|
619 | 619 | |
620 | - $dates['range'] = isset( $_GET['range'] ) ? $_GET['range'] : 'this_month'; |
|
621 | - $dates['year'] = isset( $_GET['year'] ) ? $_GET['year'] : date( 'Y' ); |
|
622 | - $dates['year_end'] = isset( $_GET['year_end'] ) ? $_GET['year_end'] : date( 'Y' ); |
|
623 | - $dates['m_start'] = isset( $_GET['m_start'] ) ? $_GET['m_start'] : 1; |
|
624 | - $dates['m_end'] = isset( $_GET['m_end'] ) ? $_GET['m_end'] : 12; |
|
625 | - $dates['day'] = isset( $_GET['day'] ) ? $_GET['day'] : 1; |
|
626 | - $dates['day_end'] = isset( $_GET['day_end'] ) ? $_GET['day_end'] : cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] ); |
|
620 | + $dates['range'] = isset($_GET['range']) ? $_GET['range'] : 'this_month'; |
|
621 | + $dates['year'] = isset($_GET['year']) ? $_GET['year'] : date('Y'); |
|
622 | + $dates['year_end'] = isset($_GET['year_end']) ? $_GET['year_end'] : date('Y'); |
|
623 | + $dates['m_start'] = isset($_GET['m_start']) ? $_GET['m_start'] : 1; |
|
624 | + $dates['m_end'] = isset($_GET['m_end']) ? $_GET['m_end'] : 12; |
|
625 | + $dates['day'] = isset($_GET['day']) ? $_GET['day'] : 1; |
|
626 | + $dates['day_end'] = isset($_GET['day_end']) ? $_GET['day_end'] : cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']); |
|
627 | 627 | |
628 | 628 | // Modify dates based on predefined ranges. |
629 | - switch ( $dates['range'] ) : |
|
629 | + switch ($dates['range']) : |
|
630 | 630 | |
631 | 631 | case 'this_month': |
632 | - $dates['m_start'] = date( 'n', $current_time ); |
|
633 | - $dates['m_end'] = date( 'n', $current_time ); |
|
632 | + $dates['m_start'] = date('n', $current_time); |
|
633 | + $dates['m_end'] = date('n', $current_time); |
|
634 | 634 | $dates['day'] = 1; |
635 | - $dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] ); |
|
636 | - $dates['year'] = date( 'Y' ); |
|
637 | - $dates['year_end'] = date( 'Y' ); |
|
635 | + $dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']); |
|
636 | + $dates['year'] = date('Y'); |
|
637 | + $dates['year_end'] = date('Y'); |
|
638 | 638 | break; |
639 | 639 | |
640 | 640 | case 'last_month': |
641 | - if ( date( 'n' ) == 1 ) { |
|
641 | + if (date('n') == 1) { |
|
642 | 642 | $dates['m_start'] = 12; |
643 | 643 | $dates['m_end'] = 12; |
644 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
645 | - $dates['year_end'] = date( 'Y', $current_time ) - 1; |
|
644 | + $dates['year'] = date('Y', $current_time) - 1; |
|
645 | + $dates['year_end'] = date('Y', $current_time) - 1; |
|
646 | 646 | } else { |
647 | - $dates['m_start'] = date( 'n' ) - 1; |
|
648 | - $dates['m_end'] = date( 'n' ) - 1; |
|
647 | + $dates['m_start'] = date('n') - 1; |
|
648 | + $dates['m_end'] = date('n') - 1; |
|
649 | 649 | $dates['year_end'] = $dates['year']; |
650 | 650 | } |
651 | - $dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] ); |
|
651 | + $dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']); |
|
652 | 652 | break; |
653 | 653 | |
654 | 654 | case 'today': |
655 | - $dates['day'] = date( 'd', $current_time ); |
|
656 | - $dates['day_end'] = date( 'd', $current_time ); |
|
657 | - $dates['m_start'] = date( 'n', $current_time ); |
|
658 | - $dates['m_end'] = date( 'n', $current_time ); |
|
659 | - $dates['year'] = date( 'Y', $current_time ); |
|
660 | - $dates['year_end'] = date( 'Y', $current_time ); |
|
655 | + $dates['day'] = date('d', $current_time); |
|
656 | + $dates['day_end'] = date('d', $current_time); |
|
657 | + $dates['m_start'] = date('n', $current_time); |
|
658 | + $dates['m_end'] = date('n', $current_time); |
|
659 | + $dates['year'] = date('Y', $current_time); |
|
660 | + $dates['year_end'] = date('Y', $current_time); |
|
661 | 661 | break; |
662 | 662 | |
663 | 663 | case 'yesterday': |
664 | - $year = date( 'Y', $current_time ); |
|
665 | - $month = date( 'n', $current_time ); |
|
666 | - $day = date( 'd', $current_time ); |
|
664 | + $year = date('Y', $current_time); |
|
665 | + $month = date('n', $current_time); |
|
666 | + $day = date('d', $current_time); |
|
667 | 667 | |
668 | - if ( $month == 1 && $day == 1 ) { |
|
668 | + if ($month == 1 && $day == 1) { |
|
669 | 669 | |
670 | 670 | $year -= 1; |
671 | 671 | $month = 12; |
672 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
672 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
673 | 673 | |
674 | - } elseif ( $month > 1 && $day == 1 ) { |
|
674 | + } elseif ($month > 1 && $day == 1) { |
|
675 | 675 | |
676 | 676 | $month -= 1; |
677 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
677 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
678 | 678 | |
679 | 679 | } else { |
680 | 680 | |
@@ -690,48 +690,48 @@ discard block |
||
690 | 690 | break; |
691 | 691 | |
692 | 692 | case 'this_week': |
693 | - $dates['day'] = date( 'd', $current_time - ( date( 'w', $current_time ) - 1 ) * 60 * 60 * 24 ) - 1; |
|
694 | - $dates['day'] += get_option( 'start_of_week' ); |
|
693 | + $dates['day'] = date('d', $current_time - (date('w', $current_time) - 1) * 60 * 60 * 24) - 1; |
|
694 | + $dates['day'] += get_option('start_of_week'); |
|
695 | 695 | $dates['day_end'] = $dates['day'] + 6; |
696 | - $dates['m_start'] = date( 'n', $current_time ); |
|
697 | - $dates['m_end'] = date( 'n', $current_time ); |
|
698 | - $dates['year'] = date( 'Y', $current_time ); |
|
696 | + $dates['m_start'] = date('n', $current_time); |
|
697 | + $dates['m_end'] = date('n', $current_time); |
|
698 | + $dates['year'] = date('Y', $current_time); |
|
699 | 699 | break; |
700 | 700 | |
701 | 701 | case 'last_week': |
702 | - $dates['day'] = date( 'd', $current_time - ( date( 'w' ) - 1 ) * 60 * 60 * 24 ) - 8; |
|
703 | - $dates['day'] += get_option( 'start_of_week' ); |
|
702 | + $dates['day'] = date('d', $current_time - (date('w') - 1) * 60 * 60 * 24) - 8; |
|
703 | + $dates['day'] += get_option('start_of_week'); |
|
704 | 704 | $dates['day_end'] = $dates['day'] + 6; |
705 | - $dates['year'] = date( 'Y' ); |
|
706 | - |
|
707 | - if ( date( 'j', $current_time ) <= 7 ) { |
|
708 | - $dates['m_start'] = date( 'n', $current_time ) - 1; |
|
709 | - $dates['m_end'] = date( 'n', $current_time ) - 1; |
|
710 | - if ( $dates['m_start'] <= 1 ) { |
|
711 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
712 | - $dates['year_end'] = date( 'Y', $current_time ) - 1; |
|
705 | + $dates['year'] = date('Y'); |
|
706 | + |
|
707 | + if (date('j', $current_time) <= 7) { |
|
708 | + $dates['m_start'] = date('n', $current_time) - 1; |
|
709 | + $dates['m_end'] = date('n', $current_time) - 1; |
|
710 | + if ($dates['m_start'] <= 1) { |
|
711 | + $dates['year'] = date('Y', $current_time) - 1; |
|
712 | + $dates['year_end'] = date('Y', $current_time) - 1; |
|
713 | 713 | } |
714 | 714 | } else { |
715 | - $dates['m_start'] = date( 'n', $current_time ); |
|
716 | - $dates['m_end'] = date( 'n', $current_time ); |
|
715 | + $dates['m_start'] = date('n', $current_time); |
|
716 | + $dates['m_end'] = date('n', $current_time); |
|
717 | 717 | } |
718 | 718 | break; |
719 | 719 | |
720 | 720 | case 'this_quarter': |
721 | - $month_now = date( 'n', $current_time ); |
|
722 | - $dates['year'] = date( 'Y', $current_time ); |
|
721 | + $month_now = date('n', $current_time); |
|
722 | + $dates['year'] = date('Y', $current_time); |
|
723 | 723 | |
724 | - if ( $month_now <= 3 ) { |
|
724 | + if ($month_now <= 3) { |
|
725 | 725 | |
726 | 726 | $dates['m_start'] = 1; |
727 | 727 | $dates['m_end'] = 4; |
728 | 728 | |
729 | - } elseif ( $month_now <= 6 ) { |
|
729 | + } elseif ($month_now <= 6) { |
|
730 | 730 | |
731 | 731 | $dates['m_start'] = 4; |
732 | 732 | $dates['m_end'] = 7; |
733 | 733 | |
734 | - } elseif ( $month_now <= 9 ) { |
|
734 | + } elseif ($month_now <= 9) { |
|
735 | 735 | |
736 | 736 | $dates['m_start'] = 7; |
737 | 737 | $dates['m_end'] = 10; |
@@ -740,28 +740,28 @@ discard block |
||
740 | 740 | |
741 | 741 | $dates['m_start'] = 10; |
742 | 742 | $dates['m_end'] = 1; |
743 | - $dates['year_end'] = date( 'Y', $current_time ) + 1; |
|
743 | + $dates['year_end'] = date('Y', $current_time) + 1; |
|
744 | 744 | |
745 | 745 | } |
746 | 746 | break; |
747 | 747 | |
748 | 748 | case 'last_quarter': |
749 | - $month_now = date( 'n', $current_time ); |
|
750 | - $dates['year'] = date( 'Y', $current_time ); |
|
751 | - $dates['year_end'] = date( 'Y', $current_time ); |
|
749 | + $month_now = date('n', $current_time); |
|
750 | + $dates['year'] = date('Y', $current_time); |
|
751 | + $dates['year_end'] = date('Y', $current_time); |
|
752 | 752 | |
753 | - if ( $month_now <= 3 ) { |
|
753 | + if ($month_now <= 3) { |
|
754 | 754 | |
755 | 755 | $dates['m_start'] = 10; |
756 | 756 | $dates['m_end'] = 1; |
757 | - $dates['year'] = date( 'Y', $current_time ) - 1; // Previous year. |
|
757 | + $dates['year'] = date('Y', $current_time) - 1; // Previous year. |
|
758 | 758 | |
759 | - } elseif ( $month_now <= 6 ) { |
|
759 | + } elseif ($month_now <= 6) { |
|
760 | 760 | |
761 | 761 | $dates['m_start'] = 1; |
762 | 762 | $dates['m_end'] = 4; |
763 | 763 | |
764 | - } elseif ( $month_now <= 9 ) { |
|
764 | + } elseif ($month_now <= 9) { |
|
765 | 765 | |
766 | 766 | $dates['m_start'] = 4; |
767 | 767 | $dates['m_end'] = 7; |
@@ -777,20 +777,20 @@ discard block |
||
777 | 777 | case 'this_year': |
778 | 778 | $dates['m_start'] = 1; |
779 | 779 | $dates['m_end'] = 12; |
780 | - $dates['year'] = date( 'Y', $current_time ); |
|
781 | - $dates['year_end'] = date( 'Y', $current_time ); |
|
780 | + $dates['year'] = date('Y', $current_time); |
|
781 | + $dates['year_end'] = date('Y', $current_time); |
|
782 | 782 | break; |
783 | 783 | |
784 | 784 | case 'last_year': |
785 | 785 | $dates['m_start'] = 1; |
786 | 786 | $dates['m_end'] = 12; |
787 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
788 | - $dates['year_end'] = date( 'Y', $current_time ) - 1; |
|
787 | + $dates['year'] = date('Y', $current_time) - 1; |
|
788 | + $dates['year_end'] = date('Y', $current_time) - 1; |
|
789 | 789 | break; |
790 | 790 | |
791 | 791 | endswitch; |
792 | 792 | |
793 | - return apply_filters( 'give_report_dates', $dates ); |
|
793 | + return apply_filters('give_report_dates', $dates); |
|
794 | 794 | } |
795 | 795 | |
796 | 796 | /** |
@@ -801,18 +801,18 @@ discard block |
||
801 | 801 | * |
802 | 802 | * @param $data |
803 | 803 | */ |
804 | -function give_parse_report_dates( $data ) { |
|
804 | +function give_parse_report_dates($data) { |
|
805 | 805 | $dates = give_get_report_dates(); |
806 | 806 | |
807 | 807 | $view = give_get_reporting_view(); |
808 | - $tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings'; |
|
809 | - $id = isset( $_GET['form-id'] ) ? $_GET['form-id'] : null; |
|
808 | + $tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings'; |
|
809 | + $id = isset($_GET['form-id']) ? $_GET['form-id'] : null; |
|
810 | 810 | |
811 | - wp_redirect( add_query_arg( $dates, admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=' . esc_attr( $tab ) . '&view=' . esc_attr( $view ) . '&form-id=' . absint( $id ) ) ) ); |
|
811 | + wp_redirect(add_query_arg($dates, admin_url('edit.php?post_type=give_forms&page=give-reports&tab='.esc_attr($tab).'&view='.esc_attr($view).'&form-id='.absint($id)))); |
|
812 | 812 | give_die(); |
813 | 813 | } |
814 | 814 | |
815 | -add_action( 'give_filter_reports', 'give_parse_report_dates' ); |
|
815 | +add_action('give_filter_reports', 'give_parse_report_dates'); |
|
816 | 816 | |
817 | 817 | |
818 | 818 | /** |
@@ -835,8 +835,8 @@ discard block |
||
835 | 835 | |
836 | 836 | echo Give()->tooltips->render_link( |
837 | 837 | array( |
838 | - 'label' => esc_attr__( 'Clicking this will clear the reports cache.', 'give' ), |
|
839 | - 'tag_content' => '<span class="give-admin-button-icon give-admin-button-icon-update"></span>' . esc_html__( 'Refresh Report Data', 'give' ), |
|
838 | + 'label' => esc_attr__('Clicking this will clear the reports cache.', 'give'), |
|
839 | + 'tag_content' => '<span class="give-admin-button-icon give-admin-button-icon-update"></span>'.esc_html__('Refresh Report Data', 'give'), |
|
840 | 840 | 'link' => $url, |
841 | 841 | 'position' => 'left', |
842 | 842 | 'attributes' => array( |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | ); |
847 | 847 | } |
848 | 848 | |
849 | -add_action( 'give_reports_graph_additional_stats', 'give_reports_refresh_button' ); |
|
849 | +add_action('give_reports_graph_additional_stats', 'give_reports_refresh_button'); |
|
850 | 850 | |
851 | 851 | /** |
852 | 852 | * Trigger the refresh of reports transients |
@@ -857,20 +857,20 @@ discard block |
||
857 | 857 | * |
858 | 858 | * @return void |
859 | 859 | */ |
860 | -function give_run_refresh_reports_transients( $data ) { |
|
860 | +function give_run_refresh_reports_transients($data) { |
|
861 | 861 | |
862 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give-refresh-reports' ) ) { |
|
862 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give-refresh-reports')) { |
|
863 | 863 | return; |
864 | 864 | } |
865 | 865 | |
866 | 866 | // Monthly stats. |
867 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
867 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
868 | 868 | |
869 | 869 | // Total earning. |
870 | - delete_option( 'give_earnings_total' ); |
|
870 | + delete_option('give_earnings_total'); |
|
871 | 871 | |
872 | 872 | // @todo: Refresh only range related stat cache |
873 | 873 | give_delete_donation_stats(); |
874 | 874 | } |
875 | 875 | |
876 | -add_action( 'give_refresh_reports_transients', 'give_run_refresh_reports_transients' ); |
|
876 | +add_action('give_refresh_reports_transients', 'give_run_refresh_reports_transients'); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * |
156 | 156 | * Used to redirect a user back to the donation form if there are errors present. |
157 | 157 | * |
158 | - * @param array|string $args |
|
158 | + * @param string $args |
|
159 | 159 | * |
160 | 160 | * @access public |
161 | 161 | * @since 1.0 |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @since 1.0 |
302 | 302 | * @since 1.8.16 Add security check |
303 | 303 | * |
304 | - * @return bool |
|
304 | + * @return false|null |
|
305 | 305 | */ |
306 | 306 | function give_listen_for_failed_payments() { |
307 | 307 | |
@@ -1292,7 +1292,7 @@ discard block |
||
1292 | 1292 | * @since 2.2.0 |
1293 | 1293 | * |
1294 | 1294 | * @param array|integer $price_or_level_id Price level data. |
1295 | - * @param boolean|integer $form_id Donation Form ID. |
|
1295 | + * @param integer $form_id Donation Form ID. |
|
1296 | 1296 | * |
1297 | 1297 | * @return boolean |
1298 | 1298 | */ |
@@ -1396,7 +1396,7 @@ discard block |
||
1396 | 1396 | * |
1397 | 1397 | * @since 2.2.0 |
1398 | 1398 | * |
1399 | - * @return object |
|
1399 | + * @return Give_Donor |
|
1400 | 1400 | */ |
1401 | 1401 | function give_get_name_with_title_prefixes( $donor ) { |
1402 | 1402 | |
@@ -1441,7 +1441,7 @@ discard block |
||
1441 | 1441 | * |
1442 | 1442 | * @since 2.2.0 |
1443 | 1443 | * |
1444 | - * @return array |
|
1444 | + * @return string|boolean |
|
1445 | 1445 | */ |
1446 | 1446 | function give_get_default_title_prefixes() { |
1447 | 1447 | /** |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | |
24 | 24 | global $typenow; |
25 | 25 | |
26 | - if ( $typenow != 'give_forms' ) { |
|
26 | + if ($typenow != 'give_forms') { |
|
27 | 27 | return true; |
28 | 28 | } |
29 | 29 | |
30 | 30 | return false; |
31 | 31 | } |
32 | 32 | |
33 | -add_filter( 'give_shortcode_button_condition', 'give_shortcode_button_condition' ); |
|
33 | +add_filter('give_shortcode_button_condition', 'give_shortcode_button_condition'); |
|
34 | 34 | |
35 | 35 | |
36 | 36 | /** |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return int|false |
42 | 42 | */ |
43 | -function get_form_id_from_args( $args ) { |
|
43 | +function get_form_id_from_args($args) { |
|
44 | 44 | |
45 | - if ( isset( $args['form_id'] ) && $args['form_id'] != 0 ) { |
|
45 | + if (isset($args['form_id']) && $args['form_id'] != 0) { |
|
46 | 46 | |
47 | - return intval( $args['form_id'] ); |
|
47 | + return intval($args['form_id']); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | return false; |
@@ -59,23 +59,23 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return bool |
61 | 61 | */ |
62 | -function give_is_float_labels_enabled( $args ) { |
|
62 | +function give_is_float_labels_enabled($args) { |
|
63 | 63 | |
64 | 64 | $float_labels = ''; |
65 | 65 | |
66 | - if ( ! empty( $args['float_labels'] ) ) { |
|
66 | + if ( ! empty($args['float_labels'])) { |
|
67 | 67 | $float_labels = $args['float_labels']; |
68 | 68 | } |
69 | 69 | |
70 | - if ( empty( $float_labels ) ) { |
|
71 | - $float_labels = give_get_meta( $args['form_id'], '_give_form_floating_labels', true ); |
|
70 | + if (empty($float_labels)) { |
|
71 | + $float_labels = give_get_meta($args['form_id'], '_give_form_floating_labels', true); |
|
72 | 72 | } |
73 | 73 | |
74 | - if ( empty( $float_labels ) || ( 'global' === $float_labels ) ) { |
|
75 | - $float_labels = give_get_option( 'floatlabels', 'disabled' ); |
|
74 | + if (empty($float_labels) || ('global' === $float_labels)) { |
|
75 | + $float_labels = give_get_option('floatlabels', 'disabled'); |
|
76 | 76 | } |
77 | 77 | |
78 | - return give_is_setting_enabled( $float_labels ); |
|
78 | + return give_is_setting_enabled($float_labels); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $can_checkout = true; |
93 | 93 | |
94 | - return (bool) apply_filters( 'give_can_checkout', $can_checkout ); |
|
94 | + return (bool) apply_filters('give_can_checkout', $can_checkout); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | function give_get_success_page_uri() { |
106 | 106 | $give_options = give_get_settings(); |
107 | 107 | |
108 | - $success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' ); |
|
108 | + $success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url'); |
|
109 | 109 | |
110 | - return apply_filters( 'give_get_success_page_uri', $success_page ); |
|
110 | + return apply_filters('give_get_success_page_uri', $success_page); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @return bool True if on the Success page, false otherwise. |
119 | 119 | */ |
120 | 120 | function give_is_success_page() { |
121 | - return apply_filters( 'give_is_success_page', is_page( give_get_success_page_uri() ) ); |
|
121 | + return apply_filters('give_is_success_page', is_page(give_get_success_page_uri())); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -132,17 +132,17 @@ discard block |
||
132 | 132 | * @since 1.0 |
133 | 133 | * @return void |
134 | 134 | */ |
135 | -function give_send_to_success_page( $query_string = null ) { |
|
135 | +function give_send_to_success_page($query_string = null) { |
|
136 | 136 | |
137 | 137 | $redirect = give_get_success_page_uri(); |
138 | 138 | |
139 | - if ( $query_string ) { |
|
139 | + if ($query_string) { |
|
140 | 140 | $redirect .= $query_string; |
141 | 141 | } |
142 | 142 | |
143 | - $gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : ''; |
|
143 | + $gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : ''; |
|
144 | 144 | |
145 | - wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) ); |
|
145 | + wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string)); |
|
146 | 146 | give_die(); |
147 | 147 | } |
148 | 148 | |
@@ -158,19 +158,19 @@ discard block |
||
158 | 158 | * @since 1.0 |
159 | 159 | * @return Void |
160 | 160 | */ |
161 | -function give_send_back_to_checkout( $args = array() ) { |
|
161 | +function give_send_back_to_checkout($args = array()) { |
|
162 | 162 | |
163 | - $url = isset( $_POST['give-current-url'] ) ? sanitize_text_field( $_POST['give-current-url'] ) : ''; |
|
163 | + $url = isset($_POST['give-current-url']) ? sanitize_text_field($_POST['give-current-url']) : ''; |
|
164 | 164 | $form_id = 0; |
165 | 165 | |
166 | 166 | // Set the form_id. |
167 | - if ( isset( $_POST['give-form-id'] ) ) { |
|
168 | - $form_id = sanitize_text_field( $_POST['give-form-id'] ); |
|
167 | + if (isset($_POST['give-form-id'])) { |
|
168 | + $form_id = sanitize_text_field($_POST['give-form-id']); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | // Need a URL to continue. If none, redirect back to single form. |
172 | - if ( empty( $url ) ) { |
|
173 | - wp_safe_redirect( get_permalink( $form_id ) ); |
|
172 | + if (empty($url)) { |
|
173 | + wp_safe_redirect(get_permalink($form_id)); |
|
174 | 174 | give_die(); |
175 | 175 | } |
176 | 176 | |
@@ -179,41 +179,41 @@ discard block |
||
179 | 179 | ); |
180 | 180 | |
181 | 181 | // Set the $level_id. |
182 | - if ( isset( $_POST['give-price-id'] ) ) { |
|
183 | - $defaults['level-id'] = sanitize_text_field( $_POST['give-price-id'] ); |
|
182 | + if (isset($_POST['give-price-id'])) { |
|
183 | + $defaults['level-id'] = sanitize_text_field($_POST['give-price-id']); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | // Check for backward compatibility. |
187 | - if ( is_string( $args ) ) { |
|
188 | - $args = str_replace( '?', '', $args ); |
|
187 | + if (is_string($args)) { |
|
188 | + $args = str_replace('?', '', $args); |
|
189 | 189 | } |
190 | 190 | |
191 | - $args = wp_parse_args( $args, $defaults ); |
|
191 | + $args = wp_parse_args($args, $defaults); |
|
192 | 192 | |
193 | 193 | // Merge URL query with $args to maintain third-party URL parameters after redirect. |
194 | - $url_data = wp_parse_url( $url ); |
|
194 | + $url_data = wp_parse_url($url); |
|
195 | 195 | |
196 | 196 | // Check if an array to prevent notices before parsing. |
197 | - if ( isset( $url_data['query'] ) && ! empty( $url_data['query'] ) ) { |
|
198 | - parse_str( $url_data['query'], $query ); |
|
197 | + if (isset($url_data['query']) && ! empty($url_data['query'])) { |
|
198 | + parse_str($url_data['query'], $query); |
|
199 | 199 | |
200 | 200 | // Precaution: don't allow any CC info. |
201 | - unset( $query['card_number'] ); |
|
202 | - unset( $query['card_cvc'] ); |
|
201 | + unset($query['card_number']); |
|
202 | + unset($query['card_cvc']); |
|
203 | 203 | |
204 | 204 | } else { |
205 | 205 | // No $url_data so pass empty array. |
206 | 206 | $query = array(); |
207 | 207 | } |
208 | 208 | |
209 | - $new_query = array_merge( $args, $query ); |
|
210 | - $new_query_string = http_build_query( $new_query ); |
|
209 | + $new_query = array_merge($args, $query); |
|
210 | + $new_query_string = http_build_query($new_query); |
|
211 | 211 | |
212 | 212 | // Assemble URL parts. |
213 | - $redirect = home_url( '/' . $url_data['path'] . '?' . $new_query_string . '#give-form-' . $form_id . '-wrap' ); |
|
213 | + $redirect = home_url('/'.$url_data['path'].'?'.$new_query_string.'#give-form-'.$form_id.'-wrap'); |
|
214 | 214 | |
215 | 215 | // Redirect them. |
216 | - wp_safe_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) ); |
|
216 | + wp_safe_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args)); |
|
217 | 217 | give_die(); |
218 | 218 | |
219 | 219 | } |
@@ -229,16 +229,16 @@ discard block |
||
229 | 229 | * @since 1.0 |
230 | 230 | * @return string |
231 | 231 | */ |
232 | -function give_get_success_page_url( $query_string = null ) { |
|
232 | +function give_get_success_page_url($query_string = null) { |
|
233 | 233 | |
234 | - $success_page = give_get_option( 'success_page', 0 ); |
|
235 | - $success_page = get_permalink( $success_page ); |
|
234 | + $success_page = give_get_option('success_page', 0); |
|
235 | + $success_page = get_permalink($success_page); |
|
236 | 236 | |
237 | - if ( $query_string ) { |
|
237 | + if ($query_string) { |
|
238 | 238 | $success_page .= $query_string; |
239 | 239 | } |
240 | 240 | |
241 | - return apply_filters( 'give_success_page_url', $success_page ); |
|
241 | + return apply_filters('give_success_page_url', $success_page); |
|
242 | 242 | |
243 | 243 | } |
244 | 244 | |
@@ -251,32 +251,31 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @return mixed Full URL to the Failed Donation Page, if present, home page if it doesn't exist. |
253 | 253 | */ |
254 | -function give_get_failed_transaction_uri( $extras = false ) { |
|
254 | +function give_get_failed_transaction_uri($extras = false) { |
|
255 | 255 | $give_options = give_get_settings(); |
256 | 256 | |
257 | 257 | // Remove question mark. |
258 | - if ( 0 === strpos( $extras, '?' ) ) { |
|
259 | - $extras = substr( $extras, 1 ); |
|
258 | + if (0 === strpos($extras, '?')) { |
|
259 | + $extras = substr($extras, 1); |
|
260 | 260 | } |
261 | 261 | |
262 | - $extras_args = wp_parse_args( $extras ); |
|
262 | + $extras_args = wp_parse_args($extras); |
|
263 | 263 | |
264 | 264 | // Set nonce if payment id exist in extra params. |
265 | - if ( array_key_exists( 'payment-id', $extras_args ) ) { |
|
266 | - $extras_args['_wpnonce'] = wp_create_nonce( "give-failed-donation-{$extras_args['payment-id']}" ); |
|
267 | - $extras = http_build_query( $extras_args ); |
|
265 | + if (array_key_exists('payment-id', $extras_args)) { |
|
266 | + $extras_args['_wpnonce'] = wp_create_nonce("give-failed-donation-{$extras_args['payment-id']}"); |
|
267 | + $extras = http_build_query($extras_args); |
|
268 | 268 | } |
269 | 269 | |
270 | - $uri = ! empty( $give_options['failure_page'] ) ? |
|
271 | - trailingslashit( get_permalink( $give_options['failure_page'] ) ) : |
|
272 | - home_url(); |
|
270 | + $uri = ! empty($give_options['failure_page']) ? |
|
271 | + trailingslashit(get_permalink($give_options['failure_page'])) : home_url(); |
|
273 | 272 | |
274 | 273 | |
275 | - if ( $extras ) { |
|
274 | + if ($extras) { |
|
276 | 275 | $uri .= "?{$extras}"; |
277 | 276 | } |
278 | 277 | |
279 | - return apply_filters( 'give_get_failed_transaction_uri', $uri ); |
|
278 | + return apply_filters('give_get_failed_transaction_uri', $uri); |
|
280 | 279 | } |
281 | 280 | |
282 | 281 | /** |
@@ -287,9 +286,9 @@ discard block |
||
287 | 286 | */ |
288 | 287 | function give_is_failed_transaction_page() { |
289 | 288 | $give_options = give_get_settings(); |
290 | - $ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false; |
|
289 | + $ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false; |
|
291 | 290 | |
292 | - return apply_filters( 'give_is_failure_page', $ret ); |
|
291 | + return apply_filters('give_is_failure_page', $ret); |
|
293 | 292 | } |
294 | 293 | |
295 | 294 | /** |
@@ -302,25 +301,25 @@ discard block |
||
302 | 301 | */ |
303 | 302 | function give_listen_for_failed_payments() { |
304 | 303 | |
305 | - $failed_page = give_get_option( 'failure_page', 0 ); |
|
306 | - $payment_id = ! empty( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : 0; |
|
307 | - $nonce = ! empty( $_GET['_wpnonce'] ) ? give_clean( $_GET['_wpnonce'] ) : false; |
|
304 | + $failed_page = give_get_option('failure_page', 0); |
|
305 | + $payment_id = ! empty($_GET['payment-id']) ? absint($_GET['payment-id']) : 0; |
|
306 | + $nonce = ! empty($_GET['_wpnonce']) ? give_clean($_GET['_wpnonce']) : false; |
|
308 | 307 | |
309 | 308 | // Bailout. |
310 | - if ( ! $failed_page || ! is_page( $failed_page ) || ! $payment_id || ! $nonce ) { |
|
309 | + if ( ! $failed_page || ! is_page($failed_page) || ! $payment_id || ! $nonce) { |
|
311 | 310 | return false; |
312 | 311 | } |
313 | 312 | |
314 | 313 | // Security check. |
315 | - if ( ! wp_verify_nonce( $nonce, "give-failed-donation-{$payment_id}" ) ) { |
|
316 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ) ); |
|
314 | + if ( ! wp_verify_nonce($nonce, "give-failed-donation-{$payment_id}")) { |
|
315 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give')); |
|
317 | 316 | } |
318 | 317 | |
319 | 318 | // Set payment status to failure |
320 | - give_update_payment_status( $payment_id, 'failed' ); |
|
319 | + give_update_payment_status($payment_id, 'failed'); |
|
321 | 320 | } |
322 | 321 | |
323 | -add_action( 'template_redirect', 'give_listen_for_failed_payments' ); |
|
322 | +add_action('template_redirect', 'give_listen_for_failed_payments'); |
|
324 | 323 | |
325 | 324 | /** |
326 | 325 | * Retrieve the Donation History page URI |
@@ -333,9 +332,9 @@ discard block |
||
333 | 332 | function give_get_history_page_uri() { |
334 | 333 | $give_options = give_get_settings(); |
335 | 334 | |
336 | - $history_page = isset( $give_options['history_page'] ) ? get_permalink( absint( $give_options['history_page'] ) ) : get_bloginfo( 'url' ); |
|
335 | + $history_page = isset($give_options['history_page']) ? get_permalink(absint($give_options['history_page'])) : get_bloginfo('url'); |
|
337 | 336 | |
338 | - return apply_filters( 'give_get_history_page_uri', $history_page ); |
|
337 | + return apply_filters('give_get_history_page_uri', $history_page); |
|
339 | 338 | } |
340 | 339 | |
341 | 340 | /** |
@@ -348,11 +347,11 @@ discard block |
||
348 | 347 | * @since 1.0 |
349 | 348 | * @return bool |
350 | 349 | */ |
351 | -function give_field_is_required( $field = '', $form_id ) { |
|
350 | +function give_field_is_required($field = '', $form_id) { |
|
352 | 351 | |
353 | - $required_fields = give_get_required_fields( $form_id ); |
|
352 | + $required_fields = give_get_required_fields($form_id); |
|
354 | 353 | |
355 | - return array_key_exists( $field, $required_fields ); |
|
354 | + return array_key_exists($field, $required_fields); |
|
356 | 355 | } |
357 | 356 | |
358 | 357 | /** |
@@ -369,12 +368,12 @@ discard block |
||
369 | 368 | * |
370 | 369 | * @return void |
371 | 370 | */ |
372 | -function give_record_donation_in_log( $give_form_id = 0, $payment_id, $price_id = false, $donation_date = null ) { |
|
371 | +function give_record_donation_in_log($give_form_id = 0, $payment_id, $price_id = false, $donation_date = null) { |
|
373 | 372 | $log_data = array( |
374 | 373 | 'log_parent' => $payment_id, |
375 | 374 | 'log_type' => 'sale', |
376 | - 'log_date' => isset( $donation_date ) ? $donation_date : null, |
|
377 | - 'log_date_gmt' => isset( $donation_date ) ? $donation_date : null, |
|
375 | + 'log_date' => isset($donation_date) ? $donation_date : null, |
|
376 | + 'log_date_gmt' => isset($donation_date) ? $donation_date : null, |
|
378 | 377 | ); |
379 | 378 | |
380 | 379 | $log_meta = array( |
@@ -382,7 +381,7 @@ discard block |
||
382 | 381 | 'price_id' => (int) $price_id, |
383 | 382 | ); |
384 | 383 | |
385 | - Give()->logs->insert_log( $log_data, $log_meta ); |
|
384 | + Give()->logs->insert_log($log_data, $log_meta); |
|
386 | 385 | } |
387 | 386 | |
388 | 387 | |
@@ -396,13 +395,13 @@ discard block |
||
396 | 395 | * |
397 | 396 | * @return bool|int |
398 | 397 | */ |
399 | -function give_increase_donation_count( $form_id = 0, $quantity = 1 ) { |
|
398 | +function give_increase_donation_count($form_id = 0, $quantity = 1) { |
|
400 | 399 | $quantity = (int) $quantity; |
401 | 400 | |
402 | 401 | /** @var \Give_Donate_Form $form */ |
403 | - $form = new Give_Donate_Form( $form_id ); |
|
402 | + $form = new Give_Donate_Form($form_id); |
|
404 | 403 | |
405 | - return $form->increase_sales( $quantity ); |
|
404 | + return $form->increase_sales($quantity); |
|
406 | 405 | } |
407 | 406 | |
408 | 407 | /** |
@@ -415,13 +414,13 @@ discard block |
||
415 | 414 | * |
416 | 415 | * @return bool|int |
417 | 416 | */ |
418 | -function give_decrease_donation_count( $form_id = 0, $quantity = 1 ) { |
|
417 | +function give_decrease_donation_count($form_id = 0, $quantity = 1) { |
|
419 | 418 | $quantity = (int) $quantity; |
420 | 419 | |
421 | 420 | /** @var \Give_Donate_Form $form */ |
422 | - $form = new Give_Donate_Form( $form_id ); |
|
421 | + $form = new Give_Donate_Form($form_id); |
|
423 | 422 | |
424 | - return $form->decrease_sales( $quantity ); |
|
423 | + return $form->decrease_sales($quantity); |
|
425 | 424 | } |
426 | 425 | |
427 | 426 | /** |
@@ -437,11 +436,11 @@ discard block |
||
437 | 436 | * |
438 | 437 | * @return bool|int |
439 | 438 | */ |
440 | -function give_increase_earnings( $give_form_id = 0, $amount, $payment_id = 0 ) { |
|
439 | +function give_increase_earnings($give_form_id = 0, $amount, $payment_id = 0) { |
|
441 | 440 | /** @var \Give_Donate_Form $form */ |
442 | - $form = new Give_Donate_Form( $give_form_id ); |
|
441 | + $form = new Give_Donate_Form($give_form_id); |
|
443 | 442 | |
444 | - return $form->increase_earnings( $amount, $payment_id ); |
|
443 | + return $form->increase_earnings($amount, $payment_id); |
|
445 | 444 | } |
446 | 445 | |
447 | 446 | /** |
@@ -459,11 +458,11 @@ discard block |
||
459 | 458 | * |
460 | 459 | * @return bool|int |
461 | 460 | */ |
462 | -function give_decrease_form_earnings( $form_id = 0, $amount, $payment_id = 0 ) { |
|
461 | +function give_decrease_form_earnings($form_id = 0, $amount, $payment_id = 0) { |
|
463 | 462 | /** @var \Give_Donate_Form $form */ |
464 | - $form = new Give_Donate_Form( $form_id ); |
|
463 | + $form = new Give_Donate_Form($form_id); |
|
465 | 464 | |
466 | - return $form->decrease_earnings( $amount, $payment_id ); |
|
465 | + return $form->decrease_earnings($amount, $payment_id); |
|
467 | 466 | } |
468 | 467 | |
469 | 468 | |
@@ -476,15 +475,15 @@ discard block |
||
476 | 475 | * |
477 | 476 | * @return int $earnings Earnings for a certain form |
478 | 477 | */ |
479 | -function give_get_form_earnings_stats( $form_id = 0 ) { |
|
480 | - $give_form = new Give_Donate_Form( $form_id ); |
|
478 | +function give_get_form_earnings_stats($form_id = 0) { |
|
479 | + $give_form = new Give_Donate_Form($form_id); |
|
481 | 480 | |
482 | 481 | /** |
483 | 482 | * Filter the form earnings |
484 | 483 | * |
485 | 484 | * @since 1.8.17 |
486 | 485 | */ |
487 | - return apply_filters( 'give_get_form_earnings_stats', $give_form->earnings, $form_id, $give_form ); |
|
486 | + return apply_filters('give_get_form_earnings_stats', $give_form->earnings, $form_id, $give_form); |
|
488 | 487 | } |
489 | 488 | |
490 | 489 | |
@@ -497,8 +496,8 @@ discard block |
||
497 | 496 | * |
498 | 497 | * @return int $sales Amount of sales for a certain form |
499 | 498 | */ |
500 | -function give_get_form_sales_stats( $give_form_id = 0 ) { |
|
501 | - $give_form = new Give_Donate_Form( $give_form_id ); |
|
499 | +function give_get_form_sales_stats($give_form_id = 0) { |
|
500 | + $give_form = new Give_Donate_Form($give_form_id); |
|
502 | 501 | |
503 | 502 | return $give_form->sales; |
504 | 503 | } |
@@ -513,16 +512,16 @@ discard block |
||
513 | 512 | * |
514 | 513 | * @return float $sales Average monthly sales |
515 | 514 | */ |
516 | -function give_get_average_monthly_form_sales( $form_id = 0 ) { |
|
517 | - $sales = give_get_form_sales_stats( $form_id ); |
|
518 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
515 | +function give_get_average_monthly_form_sales($form_id = 0) { |
|
516 | + $sales = give_get_form_sales_stats($form_id); |
|
517 | + $release_date = get_post_field('post_date', $form_id); |
|
519 | 518 | |
520 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
519 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
521 | 520 | |
522 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
521 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
523 | 522 | |
524 | - if ( $months > 0 ) { |
|
525 | - $sales = ( $sales / $months ); |
|
523 | + if ($months > 0) { |
|
524 | + $sales = ($sales / $months); |
|
526 | 525 | } |
527 | 526 | |
528 | 527 | return $sales; |
@@ -538,16 +537,16 @@ discard block |
||
538 | 537 | * |
539 | 538 | * @return float $earnings Average monthly earnings |
540 | 539 | */ |
541 | -function give_get_average_monthly_form_earnings( $form_id = 0 ) { |
|
542 | - $earnings = give_get_form_earnings_stats( $form_id ); |
|
543 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
540 | +function give_get_average_monthly_form_earnings($form_id = 0) { |
|
541 | + $earnings = give_get_form_earnings_stats($form_id); |
|
542 | + $release_date = get_post_field('post_date', $form_id); |
|
544 | 543 | |
545 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
544 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
546 | 545 | |
547 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
546 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
548 | 547 | |
549 | - if ( $months > 0 ) { |
|
550 | - $earnings = ( $earnings / $months ); |
|
548 | + if ($months > 0) { |
|
549 | + $earnings = ($earnings / $months); |
|
551 | 550 | } |
552 | 551 | |
553 | 552 | return $earnings < 0 ? 0 : $earnings; |
@@ -568,34 +567,34 @@ discard block |
||
568 | 567 | * |
569 | 568 | * @return string $price_name Name of the price option |
570 | 569 | */ |
571 | -function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0, $use_fallback = true ) { |
|
570 | +function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0, $use_fallback = true) { |
|
572 | 571 | |
573 | - $prices = give_get_variable_prices( $form_id ); |
|
572 | + $prices = give_get_variable_prices($form_id); |
|
574 | 573 | $price_name = ''; |
575 | 574 | |
576 | - if ( false === $prices ) { |
|
575 | + if (false === $prices) { |
|
577 | 576 | return $price_name; |
578 | 577 | } |
579 | 578 | |
580 | - foreach ( $prices as $price ) { |
|
579 | + foreach ($prices as $price) { |
|
581 | 580 | |
582 | - if ( intval( $price['_give_id']['level_id'] ) === intval( $price_id ) ) { |
|
581 | + if (intval($price['_give_id']['level_id']) === intval($price_id)) { |
|
583 | 582 | |
584 | - $price_text = isset( $price['_give_text'] ) ? $price['_give_text'] : ''; |
|
583 | + $price_text = isset($price['_give_text']) ? $price['_give_text'] : ''; |
|
585 | 584 | $price_fallback = $use_fallback ? |
586 | 585 | give_currency_filter( |
587 | 586 | give_format_amount( |
588 | 587 | $price['_give_amount'], |
589 | - array( 'sanitize' => false ) |
|
588 | + array('sanitize' => false) |
|
590 | 589 | ), |
591 | - array( 'decode_currency' => true ) |
|
590 | + array('decode_currency' => true) |
|
592 | 591 | ) : ''; |
593 | - $price_name = ! empty( $price_text ) ? $price_text : $price_fallback; |
|
592 | + $price_name = ! empty($price_text) ? $price_text : $price_fallback; |
|
594 | 593 | |
595 | 594 | } |
596 | 595 | } |
597 | 596 | |
598 | - return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id ); |
|
597 | + return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id); |
|
599 | 598 | } |
600 | 599 | |
601 | 600 | |
@@ -609,25 +608,25 @@ discard block |
||
609 | 608 | * |
610 | 609 | * @return string $range A fully formatted price range |
611 | 610 | */ |
612 | -function give_price_range( $form_id = 0, $formatted = true ) { |
|
613 | - $low = give_get_lowest_price_option( $form_id ); |
|
614 | - $high = give_get_highest_price_option( $form_id ); |
|
615 | - $order_type = ! empty( $_REQUEST['order'] ) ? $_REQUEST['order'] : 'asc'; |
|
611 | +function give_price_range($form_id = 0, $formatted = true) { |
|
612 | + $low = give_get_lowest_price_option($form_id); |
|
613 | + $high = give_get_highest_price_option($form_id); |
|
614 | + $order_type = ! empty($_REQUEST['order']) ? $_REQUEST['order'] : 'asc'; |
|
616 | 615 | |
617 | 616 | $range = sprintf( |
618 | 617 | '<span class="give_price_range_%1$s">%2$s</span><span class="give_price_range_sep"> – </span><span class="give_price_range_%3$s">%4$s</span>', |
619 | 618 | 'asc' === $order_type ? 'low' : 'high', |
620 | - 'asc' === $order_type ? give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ), |
|
619 | + 'asc' === $order_type ? give_currency_filter(give_format_amount($low, array('sanitize' => false))) : give_currency_filter(give_format_amount($high, array('sanitize' => false))), |
|
621 | 620 | 'asc' === $order_type ? 'high' : 'low', |
622 | - 'asc' === $order_type ? give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) ) |
|
621 | + 'asc' === $order_type ? give_currency_filter(give_format_amount($high, array('sanitize' => false))) : give_currency_filter(give_format_amount($low, array('sanitize' => false))) |
|
623 | 622 | |
624 | 623 | ); |
625 | 624 | |
626 | - if ( ! $formatted ) { |
|
627 | - $range = wp_strip_all_tags( $range ); |
|
625 | + if ( ! $formatted) { |
|
626 | + $range = wp_strip_all_tags($range); |
|
628 | 627 | } |
629 | 628 | |
630 | - return apply_filters( 'give_price_range', $range, $form_id, $low, $high ); |
|
629 | + return apply_filters('give_price_range', $range, $form_id, $low, $high); |
|
631 | 630 | } |
632 | 631 | |
633 | 632 | |
@@ -642,35 +641,35 @@ discard block |
||
642 | 641 | * |
643 | 642 | * @return int ID of the lowest price |
644 | 643 | */ |
645 | -function give_get_lowest_price_id( $form_id = 0 ) { |
|
644 | +function give_get_lowest_price_id($form_id = 0) { |
|
646 | 645 | |
647 | - if ( empty( $form_id ) ) { |
|
646 | + if (empty($form_id)) { |
|
648 | 647 | $form_id = get_the_ID(); |
649 | 648 | } |
650 | 649 | |
651 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
652 | - return give_get_form_price( $form_id ); |
|
650 | + if ( ! give_has_variable_prices($form_id)) { |
|
651 | + return give_get_form_price($form_id); |
|
653 | 652 | } |
654 | 653 | |
655 | - $prices = give_get_variable_prices( $form_id ); |
|
654 | + $prices = give_get_variable_prices($form_id); |
|
656 | 655 | |
657 | 656 | $min = $min_id = 0; |
658 | 657 | |
659 | - if ( ! empty( $prices ) ) { |
|
658 | + if ( ! empty($prices)) { |
|
660 | 659 | |
661 | - foreach ( $prices as $key => $price ) { |
|
660 | + foreach ($prices as $key => $price) { |
|
662 | 661 | |
663 | - if ( empty( $price['_give_amount'] ) ) { |
|
662 | + if (empty($price['_give_amount'])) { |
|
664 | 663 | continue; |
665 | 664 | } |
666 | 665 | |
667 | - if ( ! isset( $min ) ) { |
|
666 | + if ( ! isset($min)) { |
|
668 | 667 | $min = $price['_give_amount']; |
669 | 668 | } else { |
670 | - $min = min( $min, $price['_give_amount'] ); |
|
669 | + $min = min($min, $price['_give_amount']); |
|
671 | 670 | } |
672 | 671 | |
673 | - if ( $price['_give_amount'] == $min ) { |
|
672 | + if ($price['_give_amount'] == $min) { |
|
674 | 673 | $min_id = $price['_give_id']['level_id']; |
675 | 674 | } |
676 | 675 | } |
@@ -688,22 +687,22 @@ discard block |
||
688 | 687 | * |
689 | 688 | * @return float Amount of the lowest price |
690 | 689 | */ |
691 | -function give_get_lowest_price_option( $form_id = 0 ) { |
|
692 | - if ( empty( $form_id ) ) { |
|
690 | +function give_get_lowest_price_option($form_id = 0) { |
|
691 | + if (empty($form_id)) { |
|
693 | 692 | $form_id = get_the_ID(); |
694 | 693 | } |
695 | 694 | |
696 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
697 | - return give_get_form_price( $form_id ); |
|
695 | + if ( ! give_has_variable_prices($form_id)) { |
|
696 | + return give_get_form_price($form_id); |
|
698 | 697 | } |
699 | 698 | |
700 | - if ( ! ( $low = get_post_meta( $form_id, '_give_levels_minimum_amount', true ) ) ) { |
|
699 | + if ( ! ($low = get_post_meta($form_id, '_give_levels_minimum_amount', true))) { |
|
701 | 700 | // Backward compatibility. |
702 | - $prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' ); |
|
703 | - $low = ! empty( $prices ) ? min( $prices ) : 0; |
|
701 | + $prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount'); |
|
702 | + $low = ! empty($prices) ? min($prices) : 0; |
|
704 | 703 | } |
705 | 704 | |
706 | - return give_maybe_sanitize_amount( $low ); |
|
705 | + return give_maybe_sanitize_amount($low); |
|
707 | 706 | } |
708 | 707 | |
709 | 708 | /** |
@@ -715,23 +714,23 @@ discard block |
||
715 | 714 | * |
716 | 715 | * @return float Amount of the highest price |
717 | 716 | */ |
718 | -function give_get_highest_price_option( $form_id = 0 ) { |
|
717 | +function give_get_highest_price_option($form_id = 0) { |
|
719 | 718 | |
720 | - if ( empty( $form_id ) ) { |
|
719 | + if (empty($form_id)) { |
|
721 | 720 | $form_id = get_the_ID(); |
722 | 721 | } |
723 | 722 | |
724 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
725 | - return give_get_form_price( $form_id ); |
|
723 | + if ( ! give_has_variable_prices($form_id)) { |
|
724 | + return give_get_form_price($form_id); |
|
726 | 725 | } |
727 | 726 | |
728 | - if ( ! ( $high = get_post_meta( $form_id, '_give_levels_maximum_amount', true ) ) ) { |
|
727 | + if ( ! ($high = get_post_meta($form_id, '_give_levels_maximum_amount', true))) { |
|
729 | 728 | // Backward compatibility. |
730 | - $prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' ); |
|
731 | - $high = ! empty( $prices ) ? max( $prices ) : 0; |
|
729 | + $prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount'); |
|
730 | + $high = ! empty($prices) ? max($prices) : 0; |
|
732 | 731 | } |
733 | 732 | |
734 | - return give_maybe_sanitize_amount( $high ); |
|
733 | + return give_maybe_sanitize_amount($high); |
|
735 | 734 | } |
736 | 735 | |
737 | 736 | /** |
@@ -743,15 +742,15 @@ discard block |
||
743 | 742 | * |
744 | 743 | * @return mixed string|int Price of the form |
745 | 744 | */ |
746 | -function give_get_form_price( $form_id = 0 ) { |
|
745 | +function give_get_form_price($form_id = 0) { |
|
747 | 746 | |
748 | - if ( empty( $form_id ) ) { |
|
747 | + if (empty($form_id)) { |
|
749 | 748 | return false; |
750 | 749 | } |
751 | 750 | |
752 | - $form = new Give_Donate_Form( $form_id ); |
|
751 | + $form = new Give_Donate_Form($form_id); |
|
753 | 752 | |
754 | - return $form->__get( 'price' ); |
|
753 | + return $form->__get('price'); |
|
755 | 754 | } |
756 | 755 | |
757 | 756 | /** |
@@ -763,13 +762,13 @@ discard block |
||
763 | 762 | * |
764 | 763 | * @return mixed string|int Minimum price of the form |
765 | 764 | */ |
766 | -function give_get_form_minimum_price( $form_id = 0 ) { |
|
765 | +function give_get_form_minimum_price($form_id = 0) { |
|
767 | 766 | |
768 | - if ( empty( $form_id ) ) { |
|
767 | + if (empty($form_id)) { |
|
769 | 768 | return false; |
770 | 769 | } |
771 | 770 | |
772 | - $form = new Give_Donate_Form( $form_id ); |
|
771 | + $form = new Give_Donate_Form($form_id); |
|
773 | 772 | |
774 | 773 | return $form->get_minimum_price(); |
775 | 774 | |
@@ -784,13 +783,13 @@ discard block |
||
784 | 783 | * |
785 | 784 | * @return bool|float |
786 | 785 | */ |
787 | -function give_get_form_maximum_price( $form_id = 0 ) { |
|
786 | +function give_get_form_maximum_price($form_id = 0) { |
|
788 | 787 | |
789 | - if ( empty( $form_id ) ) { |
|
788 | + if (empty($form_id)) { |
|
790 | 789 | return false; |
791 | 790 | } |
792 | 791 | |
793 | - $form = new Give_Donate_Form( $form_id ); |
|
792 | + $form = new Give_Donate_Form($form_id); |
|
794 | 793 | |
795 | 794 | return $form->get_maximum_price(); |
796 | 795 | } |
@@ -806,48 +805,48 @@ discard block |
||
806 | 805 | * |
807 | 806 | * @return int $formatted_price |
808 | 807 | */ |
809 | -function give_price( $form_id = 0, $echo = true, $price_id = false ) { |
|
808 | +function give_price($form_id = 0, $echo = true, $price_id = false) { |
|
810 | 809 | $price = 0; |
811 | 810 | |
812 | - if ( empty( $form_id ) ) { |
|
811 | + if (empty($form_id)) { |
|
813 | 812 | $form_id = get_the_ID(); |
814 | 813 | } |
815 | 814 | |
816 | - if ( give_has_variable_prices( $form_id ) ) { |
|
815 | + if (give_has_variable_prices($form_id)) { |
|
817 | 816 | |
818 | - $prices = give_get_variable_prices( $form_id ); |
|
817 | + $prices = give_get_variable_prices($form_id); |
|
819 | 818 | |
820 | - if ( false !== $price_id ) { |
|
819 | + if (false !== $price_id) { |
|
821 | 820 | |
822 | 821 | // loop through multi-prices to see which is default |
823 | - foreach ( $prices as $price ) { |
|
822 | + foreach ($prices as $price) { |
|
824 | 823 | // this is the default price |
825 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
824 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
826 | 825 | $price = (float) $price['_give_amount']; |
827 | 826 | }; |
828 | 827 | } |
829 | 828 | } else { |
830 | 829 | |
831 | - $price = give_get_lowest_price_option( $form_id ); |
|
830 | + $price = give_get_lowest_price_option($form_id); |
|
832 | 831 | } |
833 | 832 | } else { |
834 | 833 | |
835 | - $price = give_get_form_price( $form_id ); |
|
834 | + $price = give_get_form_price($form_id); |
|
836 | 835 | } |
837 | 836 | |
838 | - $price = apply_filters( 'give_form_price', give_maybe_sanitize_amount( $price ), $form_id ); |
|
839 | - $formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>'; |
|
840 | - $formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price ); |
|
837 | + $price = apply_filters('give_form_price', give_maybe_sanitize_amount($price), $form_id); |
|
838 | + $formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>'; |
|
839 | + $formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price); |
|
841 | 840 | |
842 | - if ( $echo ) { |
|
841 | + if ($echo) { |
|
843 | 842 | echo $formatted_price; |
844 | 843 | } else { |
845 | 844 | return $formatted_price; |
846 | 845 | } |
847 | 846 | } |
848 | 847 | |
849 | -add_filter( 'give_form_price', 'give_format_amount', 10 ); |
|
850 | -add_filter( 'give_form_price', 'give_currency_filter', 20 ); |
|
848 | +add_filter('give_form_price', 'give_format_amount', 10); |
|
849 | +add_filter('give_form_price', 'give_currency_filter', 20); |
|
851 | 850 | |
852 | 851 | |
853 | 852 | /** |
@@ -860,19 +859,19 @@ discard block |
||
860 | 859 | * |
861 | 860 | * @return float $amount Amount of the price option |
862 | 861 | */ |
863 | -function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) { |
|
864 | - $prices = give_get_variable_prices( $form_id ); |
|
862 | +function give_get_price_option_amount($form_id = 0, $price_id = 0) { |
|
863 | + $prices = give_get_variable_prices($form_id); |
|
865 | 864 | |
866 | 865 | $amount = 0.00; |
867 | 866 | |
868 | - foreach ( $prices as $price ) { |
|
869 | - if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) { |
|
870 | - $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; |
|
867 | + foreach ($prices as $price) { |
|
868 | + if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) { |
|
869 | + $amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00; |
|
871 | 870 | break; |
872 | 871 | }; |
873 | 872 | } |
874 | 873 | |
875 | - return apply_filters( 'give_get_price_option_amount', give_maybe_sanitize_amount( $amount ), $form_id, $price_id ); |
|
874 | + return apply_filters('give_get_price_option_amount', give_maybe_sanitize_amount($amount), $form_id, $price_id); |
|
876 | 875 | } |
877 | 876 | |
878 | 877 | /** |
@@ -884,13 +883,13 @@ discard block |
||
884 | 883 | * |
885 | 884 | * @return mixed string|int Goal of the form |
886 | 885 | */ |
887 | -function give_get_form_goal( $form_id = 0 ) { |
|
886 | +function give_get_form_goal($form_id = 0) { |
|
888 | 887 | |
889 | - if ( empty( $form_id ) ) { |
|
888 | + if (empty($form_id)) { |
|
890 | 889 | return false; |
891 | 890 | } |
892 | 891 | |
893 | - $form = new Give_Donate_Form( $form_id ); |
|
892 | + $form = new Give_Donate_Form($form_id); |
|
894 | 893 | |
895 | 894 | return $form->goal; |
896 | 895 | |
@@ -905,13 +904,13 @@ discard block |
||
905 | 904 | * |
906 | 905 | * @return mixed string|int Goal of the form |
907 | 906 | */ |
908 | -function give_get_form_goal_format( $form_id = 0 ) { |
|
907 | +function give_get_form_goal_format($form_id = 0) { |
|
909 | 908 | |
910 | - if ( empty( $form_id ) ) { |
|
909 | + if (empty($form_id)) { |
|
911 | 910 | return false; |
912 | 911 | } |
913 | 912 | |
914 | - return give_get_meta( $form_id, '_give_goal_format', true ); |
|
913 | + return give_get_meta($form_id, '_give_goal_format', true); |
|
915 | 914 | |
916 | 915 | } |
917 | 916 | |
@@ -925,19 +924,19 @@ discard block |
||
925 | 924 | * |
926 | 925 | * @return string $formatted_goal |
927 | 926 | */ |
928 | -function give_goal( $form_id = 0, $echo = true ) { |
|
927 | +function give_goal($form_id = 0, $echo = true) { |
|
929 | 928 | |
930 | - if ( empty( $form_id ) ) { |
|
929 | + if (empty($form_id)) { |
|
931 | 930 | $form_id = get_the_ID(); |
932 | 931 | } |
933 | 932 | |
934 | - $goal = give_get_form_goal( $form_id ); |
|
935 | - $goal_format = give_get_form_goal_format( $form_id ); |
|
933 | + $goal = give_get_form_goal($form_id); |
|
934 | + $goal_format = give_get_form_goal_format($form_id); |
|
936 | 935 | |
937 | - if ( 'donation' === $goal_format ) { |
|
936 | + if ('donation' === $goal_format) { |
|
938 | 937 | $goal = "{$goal} donations"; |
939 | 938 | } else { |
940 | - $goal = apply_filters( 'give_form_goal', give_maybe_sanitize_amount( $goal ), $form_id ); |
|
939 | + $goal = apply_filters('give_form_goal', give_maybe_sanitize_amount($goal), $form_id); |
|
941 | 940 | } |
942 | 941 | |
943 | 942 | $formatted_goal = sprintf( |
@@ -945,17 +944,17 @@ discard block |
||
945 | 944 | $form_id, |
946 | 945 | $goal |
947 | 946 | ); |
948 | - $formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal ); |
|
947 | + $formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal); |
|
949 | 948 | |
950 | - if ( $echo ) { |
|
949 | + if ($echo) { |
|
951 | 950 | echo $formatted_goal; |
952 | 951 | } else { |
953 | 952 | return $formatted_goal; |
954 | 953 | } |
955 | 954 | } |
956 | 955 | |
957 | -add_filter( 'give_form_goal', 'give_format_amount', 10 ); |
|
958 | -add_filter( 'give_form_goal', 'give_currency_filter', 20 ); |
|
956 | +add_filter('give_form_goal', 'give_format_amount', 10); |
|
957 | +add_filter('give_form_goal', 'give_currency_filter', 20); |
|
959 | 958 | |
960 | 959 | |
961 | 960 | /** |
@@ -967,15 +966,15 @@ discard block |
||
967 | 966 | * |
968 | 967 | * @return bool $ret Whether or not the logged_in_only setting is set |
969 | 968 | */ |
970 | -function give_logged_in_only( $form_id ) { |
|
969 | +function give_logged_in_only($form_id) { |
|
971 | 970 | // If _give_logged_in_only is set to enable then guest can donate from that specific form. |
972 | 971 | // Otherwise it is member only donation form. |
973 | - $val = give_get_meta( $form_id, '_give_logged_in_only', true ); |
|
974 | - $val = ! empty( $val ) ? $val : 'enabled'; |
|
972 | + $val = give_get_meta($form_id, '_give_logged_in_only', true); |
|
973 | + $val = ! empty($val) ? $val : 'enabled'; |
|
975 | 974 | |
976 | - $ret = ! give_is_setting_enabled( $val ); |
|
975 | + $ret = ! give_is_setting_enabled($val); |
|
977 | 976 | |
978 | - return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id ); |
|
977 | + return (bool) apply_filters('give_logged_in_only', $ret, $form_id); |
|
979 | 978 | } |
980 | 979 | |
981 | 980 | |
@@ -988,11 +987,11 @@ discard block |
||
988 | 987 | * |
989 | 988 | * @return string |
990 | 989 | */ |
991 | -function give_show_login_register_option( $form_id ) { |
|
990 | +function give_show_login_register_option($form_id) { |
|
992 | 991 | |
993 | - $show_register_form = give_get_meta( $form_id, '_give_show_register_form', true ); |
|
992 | + $show_register_form = give_get_meta($form_id, '_give_show_register_form', true); |
|
994 | 993 | |
995 | - return apply_filters( 'give_show_register_form', $show_register_form, $form_id ); |
|
994 | + return apply_filters('give_show_register_form', $show_register_form, $form_id); |
|
996 | 995 | |
997 | 996 | } |
998 | 997 | |
@@ -1008,12 +1007,12 @@ discard block |
||
1008 | 1007 | * |
1009 | 1008 | * @return array |
1010 | 1009 | */ |
1011 | -function _give_get_prefill_form_field_values( $form_id ) { |
|
1010 | +function _give_get_prefill_form_field_values($form_id) { |
|
1012 | 1011 | $logged_in_donor_info = array(); |
1013 | 1012 | |
1014 | - if ( is_user_logged_in() ) : |
|
1015 | - $donor_data = get_userdata( get_current_user_id() ); |
|
1016 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
1013 | + if (is_user_logged_in()) : |
|
1014 | + $donor_data = get_userdata(get_current_user_id()); |
|
1015 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
1017 | 1016 | $donor_address = $donor->get_donor_address(); |
1018 | 1017 | $company_name = $donor->get_company_name(); |
1019 | 1018 | |
@@ -1025,7 +1024,7 @@ discard block |
||
1025 | 1024 | 'give_last' => $donor_data->last_name, |
1026 | 1025 | |
1027 | 1026 | // Title Prefix. |
1028 | - 'give_title' => $donor->get_meta( '_give_donor_title_prefix', true ), |
|
1027 | + 'give_title' => $donor->get_meta('_give_donor_title_prefix', true), |
|
1029 | 1028 | |
1030 | 1029 | // Company name. |
1031 | 1030 | 'company_name' => $company_name, |
@@ -1055,23 +1054,23 @@ discard block |
||
1055 | 1054 | |
1056 | 1055 | // Bailout: Auto fill form field values only form form which donor is donating. |
1057 | 1056 | if ( |
1058 | - empty( $_GET['form-id'] ) |
|
1057 | + empty($_GET['form-id']) |
|
1059 | 1058 | || ! $form_id |
1060 | - || ( $form_id !== absint( $_GET['form-id'] ) ) |
|
1059 | + || ($form_id !== absint($_GET['form-id'])) |
|
1061 | 1060 | ) { |
1062 | 1061 | return $logged_in_donor_info; |
1063 | 1062 | } |
1064 | 1063 | |
1065 | 1064 | // Get purchase data. |
1066 | - $give_purchase_data = Give()->session->get( 'give_purchase' ); |
|
1065 | + $give_purchase_data = Give()->session->get('give_purchase'); |
|
1067 | 1066 | |
1068 | 1067 | // Get donor info from form data. |
1069 | - $give_donor_info_in_session = empty( $give_purchase_data['post_data'] ) |
|
1068 | + $give_donor_info_in_session = empty($give_purchase_data['post_data']) |
|
1070 | 1069 | ? array() |
1071 | 1070 | : $give_purchase_data['post_data']; |
1072 | 1071 | |
1073 | 1072 | // Output. |
1074 | - return wp_parse_args( $give_donor_info_in_session, $logged_in_donor_info ); |
|
1073 | + return wp_parse_args($give_donor_info_in_session, $logged_in_donor_info); |
|
1075 | 1074 | } |
1076 | 1075 | |
1077 | 1076 | /** |
@@ -1084,13 +1083,13 @@ discard block |
||
1084 | 1083 | * |
1085 | 1084 | * @return int |
1086 | 1085 | */ |
1087 | -function give_get_form_donor_count( $form_id, $args = array() ) { |
|
1086 | +function give_get_form_donor_count($form_id, $args = array()) { |
|
1088 | 1087 | global $wpdb; |
1089 | 1088 | |
1090 | - $cache_key = Give_Cache::get_key( "form_donor_count_{$form_id}", $args, false ); |
|
1091 | - $donor_count = absint( Give_Cache::get_db_query( $cache_key ) ); |
|
1089 | + $cache_key = Give_Cache::get_key("form_donor_count_{$form_id}", $args, false); |
|
1090 | + $donor_count = absint(Give_Cache::get_db_query($cache_key)); |
|
1092 | 1091 | |
1093 | - if ( $form_id && ! $donor_count ) { |
|
1092 | + if ($form_id && ! $donor_count) { |
|
1094 | 1093 | // Set arguments. |
1095 | 1094 | $args = wp_parse_args( |
1096 | 1095 | $args, |
@@ -1100,7 +1099,7 @@ discard block |
||
1100 | 1099 | ); |
1101 | 1100 | |
1102 | 1101 | $donation_meta_table = Give()->payment_meta->table_name; |
1103 | - $donation_id_col_name = Give()->payment_meta->get_meta_type() . '_id'; |
|
1102 | + $donation_id_col_name = Give()->payment_meta->get_meta_type().'_id'; |
|
1104 | 1103 | |
1105 | 1104 | $distinct = $args['unique'] ? 'DISTINCT meta_value' : 'meta_value'; |
1106 | 1105 | |
@@ -1125,7 +1124,7 @@ discard block |
||
1125 | 1124 | 'publish' |
1126 | 1125 | ); |
1127 | 1126 | |
1128 | - $donor_count = absint( $wpdb->get_var( $query ) ); |
|
1127 | + $donor_count = absint($wpdb->get_var($query)); |
|
1129 | 1128 | } |
1130 | 1129 | |
1131 | 1130 | |
@@ -1134,7 +1133,7 @@ discard block |
||
1134 | 1133 | * |
1135 | 1134 | * @since 2.1.0 |
1136 | 1135 | */ |
1137 | - $donor_count = apply_filters( 'give_get_form_donor_count', $donor_count, $form_id, $args ); |
|
1136 | + $donor_count = apply_filters('give_get_form_donor_count', $donor_count, $form_id, $args); |
|
1138 | 1137 | |
1139 | 1138 | return $donor_count; |
1140 | 1139 | } |
@@ -1148,33 +1147,33 @@ discard block |
||
1148 | 1147 | * |
1149 | 1148 | * @return void |
1150 | 1149 | */ |
1151 | -function give_set_form_closed_status( $form_id ) { |
|
1150 | +function give_set_form_closed_status($form_id) { |
|
1152 | 1151 | |
1153 | 1152 | // Bailout. |
1154 | - if ( empty( $form_id ) ) { |
|
1153 | + if (empty($form_id)) { |
|
1155 | 1154 | return; |
1156 | 1155 | } |
1157 | 1156 | |
1158 | 1157 | $open_form = false; |
1159 | - $is_goal_enabled = give_is_setting_enabled( give_get_meta( $form_id, '_give_goal_option', true, 'disabled' ) ); |
|
1158 | + $is_goal_enabled = give_is_setting_enabled(give_get_meta($form_id, '_give_goal_option', true, 'disabled')); |
|
1160 | 1159 | |
1161 | 1160 | // Proceed, if the form goal is enabled. |
1162 | - if ( $is_goal_enabled ) { |
|
1161 | + if ($is_goal_enabled) { |
|
1163 | 1162 | |
1164 | - $close_form_when_goal_achieved = give_is_setting_enabled( give_get_meta( $form_id, '_give_close_form_when_goal_achieved', true, 'disabled' ) ); |
|
1163 | + $close_form_when_goal_achieved = give_is_setting_enabled(give_get_meta($form_id, '_give_close_form_when_goal_achieved', true, 'disabled')); |
|
1165 | 1164 | |
1166 | 1165 | // Proceed, if close form when goal achieved option is enabled. |
1167 | - if ( $close_form_when_goal_achieved ) { |
|
1166 | + if ($close_form_when_goal_achieved) { |
|
1168 | 1167 | |
1169 | - $form = new Give_Donate_Form( $form_id ); |
|
1170 | - $goal_progress_stats = give_goal_progress_stats( $form ); |
|
1168 | + $form = new Give_Donate_Form($form_id); |
|
1169 | + $goal_progress_stats = give_goal_progress_stats($form); |
|
1171 | 1170 | |
1172 | 1171 | // Verify whether the form is closed or not after processing data. |
1173 | 1172 | $closed = $goal_progress_stats['raw_goal'] <= $goal_progress_stats['raw_actual']; |
1174 | 1173 | |
1175 | 1174 | // Update form meta if verified that the form is closed. |
1176 | - if ( $closed ) { |
|
1177 | - give_update_meta( $form_id, '_give_form_status', 'closed' ); |
|
1175 | + if ($closed) { |
|
1176 | + give_update_meta($form_id, '_give_form_status', 'closed'); |
|
1178 | 1177 | } else { |
1179 | 1178 | $open_form = true; |
1180 | 1179 | } |
@@ -1186,8 +1185,8 @@ discard block |
||
1186 | 1185 | } |
1187 | 1186 | |
1188 | 1187 | // If $open_form is true, then update form status to open. |
1189 | - if ( $open_form ) { |
|
1190 | - give_update_meta( $form_id, '_give_form_status', 'open' ); |
|
1188 | + if ($open_form) { |
|
1189 | + give_update_meta($form_id, '_give_form_status', 'open'); |
|
1191 | 1190 | } |
1192 | 1191 | } |
1193 | 1192 | |
@@ -1200,32 +1199,31 @@ discard block |
||
1200 | 1199 | * |
1201 | 1200 | * @return string |
1202 | 1201 | */ |
1203 | -function give_admin_form_goal_stats( $form_id ) { |
|
1202 | +function give_admin_form_goal_stats($form_id) { |
|
1204 | 1203 | |
1205 | 1204 | $html = ''; |
1206 | - $goal_stats = give_goal_progress_stats( $form_id ); |
|
1207 | - $percent_complete = round( ( $goal_stats['raw_actual'] / $goal_stats['raw_goal'] ), 3 ) * 100; |
|
1205 | + $goal_stats = give_goal_progress_stats($form_id); |
|
1206 | + $percent_complete = round(($goal_stats['raw_actual'] / $goal_stats['raw_goal']), 3) * 100; |
|
1208 | 1207 | |
1209 | 1208 | $html .= sprintf( |
1210 | 1209 | '<div class="give-admin-progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="%1$s"> |
1211 | 1210 | <span style="width:%1$s%%;"></span> |
1212 | 1211 | </div>', |
1213 | - esc_attr( $goal_stats['progress'] ) |
|
1212 | + esc_attr($goal_stats['progress']) |
|
1214 | 1213 | ); |
1215 | 1214 | |
1216 | 1215 | $html .= sprintf( |
1217 | - ( 'percentage' !== $goal_stats['format'] ) ? |
|
1218 | - '<div class="give-goal-text"><span>%1$s</span> %2$s <a href="%3$s">%4$s</a> %5$s ' : |
|
1219 | - '<div class="give-goal-text"><a href="%3$s">%1$s </a>', |
|
1220 | - ( 'percentage' !== $goal_stats['format'] ) ? $goal_stats['actual'] : $percent_complete . '%', |
|
1221 | - ( 'percentage' !== $goal_stats['format'] ) ? __( 'of', 'give' ) : '', |
|
1222 | - esc_url( admin_url( "post.php?post={$form_id}&action=edit&give_tab=donation_goal_options" ) ), |
|
1216 | + ('percentage' !== $goal_stats['format']) ? |
|
1217 | + '<div class="give-goal-text"><span>%1$s</span> %2$s <a href="%3$s">%4$s</a> %5$s ' : '<div class="give-goal-text"><a href="%3$s">%1$s </a>', |
|
1218 | + ('percentage' !== $goal_stats['format']) ? $goal_stats['actual'] : $percent_complete.'%', |
|
1219 | + ('percentage' !== $goal_stats['format']) ? __('of', 'give') : '', |
|
1220 | + esc_url(admin_url("post.php?post={$form_id}&action=edit&give_tab=donation_goal_options")), |
|
1223 | 1221 | $goal_stats['goal'], |
1224 | - ( 'donors' === $goal_stats['format'] ? __( 'Donors', 'give' ) : ( 'donation' === $goal_stats['format'] ? __( 'Donations', 'give' ) : '' ) ) |
|
1222 | + ('donors' === $goal_stats['format'] ? __('Donors', 'give') : ('donation' === $goal_stats['format'] ? __('Donations', 'give') : '')) |
|
1225 | 1223 | ); |
1226 | 1224 | |
1227 | - if ( $goal_stats['raw_actual'] >= $goal_stats['raw_goal'] ) { |
|
1228 | - $html .= sprintf( '<span class="give-admin-goal-achieved"><span class="dashicons dashicons-star-filled"></span> %s</span>', __( 'Goal achieved', 'give' ) ); |
|
1225 | + if ($goal_stats['raw_actual'] >= $goal_stats['raw_goal']) { |
|
1226 | + $html .= sprintf('<span class="give-admin-goal-achieved"><span class="dashicons dashicons-star-filled"></span> %s</span>', __('Goal achieved', 'give')); |
|
1229 | 1227 | } |
1230 | 1228 | |
1231 | 1229 | $html .= '</div>'; |
@@ -1243,11 +1241,11 @@ discard block |
||
1243 | 1241 | * |
1244 | 1242 | * @return null | array |
1245 | 1243 | */ |
1246 | -function give_form_get_default_level( $form_id ) { |
|
1244 | +function give_form_get_default_level($form_id) { |
|
1247 | 1245 | $default_level = null; |
1248 | 1246 | |
1249 | 1247 | // If donation form has variable prices. |
1250 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1248 | + if (give_has_variable_prices($form_id)) { |
|
1251 | 1249 | /** |
1252 | 1250 | * Filter the variable pricing |
1253 | 1251 | * |
@@ -1259,12 +1257,12 @@ discard block |
||
1259 | 1257 | * @param array $prices Array of variable prices. |
1260 | 1258 | * @param int $form Form ID. |
1261 | 1259 | */ |
1262 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
1260 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
1263 | 1261 | |
1264 | 1262 | // Go through each of the level and get the default level id. |
1265 | - foreach ( $prices as $level ) { |
|
1263 | + foreach ($prices as $level) { |
|
1266 | 1264 | if ( |
1267 | - isset( $level['_give_default'] ) |
|
1265 | + isset($level['_give_default']) |
|
1268 | 1266 | && $level['_give_default'] === 'default' |
1269 | 1267 | ) { |
1270 | 1268 | $default_level = $level; |
@@ -1280,7 +1278,7 @@ discard block |
||
1280 | 1278 | * @param array $default_level Default level price data. |
1281 | 1279 | * @param integer $form_id Donation form ID. |
1282 | 1280 | */ |
1283 | - return apply_filters( 'give_form_get_default_level', $default_level, $form_id ); |
|
1281 | + return apply_filters('give_form_get_default_level', $default_level, $form_id); |
|
1284 | 1282 | } |
1285 | 1283 | |
1286 | 1284 | /** |
@@ -1293,21 +1291,21 @@ discard block |
||
1293 | 1291 | * |
1294 | 1292 | * @return boolean |
1295 | 1293 | */ |
1296 | -function give_is_default_level_id( $price_or_level_id, $form_id = 0 ) { |
|
1294 | +function give_is_default_level_id($price_or_level_id, $form_id = 0) { |
|
1297 | 1295 | $is_default = false; |
1298 | 1296 | |
1299 | 1297 | if ( |
1300 | - ! empty( $form_id ) |
|
1301 | - && is_numeric( $price_or_level_id ) |
|
1298 | + ! empty($form_id) |
|
1299 | + && is_numeric($price_or_level_id) |
|
1302 | 1300 | ) { |
1303 | 1301 | // Get default level id. |
1304 | - $form_price_data = give_form_get_default_level( $form_id ); |
|
1302 | + $form_price_data = give_form_get_default_level($form_id); |
|
1305 | 1303 | |
1306 | - $is_default = ! is_null( $form_price_data ) && ( $price_or_level_id === absint( $form_price_data['_give_id']['level_id'] ) ); |
|
1304 | + $is_default = ! is_null($form_price_data) && ($price_or_level_id === absint($form_price_data['_give_id']['level_id'])); |
|
1307 | 1305 | } |
1308 | 1306 | |
1309 | - $is_default = false === $is_default && is_array( $price_or_level_id ) ? |
|
1310 | - ( isset( $price_or_level_id['_give_default'] ) && $price_or_level_id['_give_default'] === 'default' ) |
|
1307 | + $is_default = false === $is_default && is_array($price_or_level_id) ? |
|
1308 | + (isset($price_or_level_id['_give_default']) && $price_or_level_id['_give_default'] === 'default') |
|
1311 | 1309 | : $is_default; |
1312 | 1310 | |
1313 | 1311 | /** |
@@ -1318,7 +1316,7 @@ discard block |
||
1318 | 1316 | * @param bool $is_default True if it is default price level id otherwise false. |
1319 | 1317 | * @param array|integer $price_or_level_id Price Data. |
1320 | 1318 | */ |
1321 | - return apply_filters( 'give_is_default_level_id', $is_default, $price_or_level_id ); |
|
1319 | + return apply_filters('give_is_default_level_id', $is_default, $price_or_level_id); |
|
1322 | 1320 | } |
1323 | 1321 | |
1324 | 1322 | |
@@ -1331,20 +1329,20 @@ discard block |
||
1331 | 1329 | * |
1332 | 1330 | * @return mixed |
1333 | 1331 | */ |
1334 | -function give_get_name_title_prefixes( $form_id = 0 ) { |
|
1332 | +function give_get_name_title_prefixes($form_id = 0) { |
|
1335 | 1333 | |
1336 | - $name_title_prefix = give_is_name_title_prefix_enabled( $form_id ); |
|
1337 | - $title_prefixes = give_get_option( 'title_prefixes', give_get_default_title_prefixes() ); |
|
1334 | + $name_title_prefix = give_is_name_title_prefix_enabled($form_id); |
|
1335 | + $title_prefixes = give_get_option('title_prefixes', give_get_default_title_prefixes()); |
|
1338 | 1336 | |
1339 | 1337 | // If form id exists, then fetch form specific title prefixes. |
1340 | - if ( intval( $form_id ) > 0 && $name_title_prefix ) { |
|
1338 | + if (intval($form_id) > 0 && $name_title_prefix) { |
|
1341 | 1339 | |
1342 | - $form_title_prefix = give_get_meta( $form_id, '_give_name_title_prefix', true ); |
|
1343 | - if ( 'global' !== $form_title_prefix ) { |
|
1344 | - $form_title_prefixes = give_get_meta( $form_id, '_give_title_prefixes', true, give_get_default_title_prefixes() ); |
|
1340 | + $form_title_prefix = give_get_meta($form_id, '_give_name_title_prefix', true); |
|
1341 | + if ('global' !== $form_title_prefix) { |
|
1342 | + $form_title_prefixes = give_get_meta($form_id, '_give_title_prefixes', true, give_get_default_title_prefixes()); |
|
1345 | 1343 | |
1346 | 1344 | // Check whether the form based title prefixes exists or not. |
1347 | - if ( is_array( $form_title_prefixes ) && count( $form_title_prefixes ) > 0 ) { |
|
1345 | + if (is_array($form_title_prefixes) && count($form_title_prefixes) > 0) { |
|
1348 | 1346 | $title_prefixes = $form_title_prefixes; |
1349 | 1347 | } |
1350 | 1348 | } |
@@ -1363,22 +1361,22 @@ discard block |
||
1363 | 1361 | * |
1364 | 1362 | * @return bool |
1365 | 1363 | */ |
1366 | -function give_is_name_title_prefix_enabled( $form_id = 0, $status = '' ) { |
|
1367 | - if ( empty( $status ) ) { |
|
1368 | - $status = array( 'required', 'optional' ); |
|
1364 | +function give_is_name_title_prefix_enabled($form_id = 0, $status = '') { |
|
1365 | + if (empty($status)) { |
|
1366 | + $status = array('required', 'optional'); |
|
1369 | 1367 | } else { |
1370 | - $status = array( $status ); |
|
1368 | + $status = array($status); |
|
1371 | 1369 | } |
1372 | 1370 | |
1373 | - $title_prefix_status = give_is_setting_enabled( give_get_option( 'name_title_prefix' ), $status ); |
|
1371 | + $title_prefix_status = give_is_setting_enabled(give_get_option('name_title_prefix'), $status); |
|
1374 | 1372 | |
1375 | - if ( intval( $form_id ) > 0 ) { |
|
1376 | - $form_title_prefix = give_get_meta( $form_id, '_give_name_title_prefix', true ); |
|
1373 | + if (intval($form_id) > 0) { |
|
1374 | + $form_title_prefix = give_get_meta($form_id, '_give_name_title_prefix', true); |
|
1377 | 1375 | |
1378 | - if ( 'disabled' === $form_title_prefix ) { |
|
1376 | + if ('disabled' === $form_title_prefix) { |
|
1379 | 1377 | $title_prefix_status = false; |
1380 | - } elseif ( in_array( $form_title_prefix, $status, true ) ) { |
|
1381 | - $title_prefix_status = give_is_setting_enabled( $form_title_prefix, $status ); |
|
1378 | + } elseif (in_array($form_title_prefix, $status, true)) { |
|
1379 | + $title_prefix_status = give_is_setting_enabled($form_title_prefix, $status); |
|
1382 | 1380 | } |
1383 | 1381 | } |
1384 | 1382 | |
@@ -1395,18 +1393,18 @@ discard block |
||
1395 | 1393 | * |
1396 | 1394 | * @return object |
1397 | 1395 | */ |
1398 | -function give_get_name_with_title_prefixes( $donor ) { |
|
1396 | +function give_get_name_with_title_prefixes($donor) { |
|
1399 | 1397 | |
1400 | 1398 | // Prepare Give_Donor object, if $donor is numeric. |
1401 | - if ( is_numeric( $donor ) ) { |
|
1402 | - $donor = new Give_Donor( $donor ); |
|
1399 | + if (is_numeric($donor)) { |
|
1400 | + $donor = new Give_Donor($donor); |
|
1403 | 1401 | } |
1404 | 1402 | |
1405 | - $title_prefix = Give()->donor_meta->get_meta( $donor->id, '_give_donor_title_prefix', true ); |
|
1403 | + $title_prefix = Give()->donor_meta->get_meta($donor->id, '_give_donor_title_prefix', true); |
|
1406 | 1404 | |
1407 | 1405 | // Update Donor name, if non empty title prefix. |
1408 | - if ( ! empty( $title_prefix ) ) { |
|
1409 | - $donor->name = give_get_donor_name_with_title_prefixes( $title_prefix, $donor->name ); |
|
1406 | + if ( ! empty($title_prefix)) { |
|
1407 | + $donor->name = give_get_donor_name_with_title_prefixes($title_prefix, $donor->name); |
|
1410 | 1408 | } |
1411 | 1409 | |
1412 | 1410 | return $donor; |
@@ -1422,15 +1420,15 @@ discard block |
||
1422 | 1420 | * |
1423 | 1421 | * @return string |
1424 | 1422 | */ |
1425 | -function give_get_donor_name_with_title_prefixes( $title_prefix, $name ) { |
|
1423 | +function give_get_donor_name_with_title_prefixes($title_prefix, $name) { |
|
1426 | 1424 | |
1427 | 1425 | $donor_name = $name; |
1428 | 1426 | |
1429 | - if ( ! empty( $title_prefix ) && ! empty( $name ) ) { |
|
1427 | + if ( ! empty($title_prefix) && ! empty($name)) { |
|
1430 | 1428 | $donor_name = "{$title_prefix} {$name}"; |
1431 | 1429 | } |
1432 | 1430 | |
1433 | - return trim( $donor_name ); |
|
1431 | + return trim($donor_name); |
|
1434 | 1432 | } |
1435 | 1433 | |
1436 | 1434 | /** |
@@ -1450,9 +1448,9 @@ discard block |
||
1450 | 1448 | return apply_filters( |
1451 | 1449 | 'give_get_default_title_prefixes', |
1452 | 1450 | array( |
1453 | - 'Mr.' => __( 'Mr.', 'give' ), |
|
1454 | - 'Mrs.' => __( 'Mrs.', 'give' ), |
|
1455 | - 'Ms.' => __( 'Ms.', 'give' ), |
|
1451 | + 'Mr.' => __('Mr.', 'give'), |
|
1452 | + 'Mrs.' => __('Mrs.', 'give'), |
|
1453 | + 'Ms.' => __('Ms.', 'give'), |
|
1456 | 1454 | ) |
1457 | 1455 | ); |
1458 | 1456 | } |
@@ -1466,25 +1464,25 @@ discard block |
||
1466 | 1464 | * |
1467 | 1465 | * @return bool |
1468 | 1466 | */ |
1469 | -function give_is_name_title_prefix_required( $form_id = 0 ) { |
|
1467 | +function give_is_name_title_prefix_required($form_id = 0) { |
|
1470 | 1468 | |
1471 | 1469 | // Bail out, if name title prefix is not enabled. |
1472 | - if ( ! give_is_name_title_prefix_enabled( $form_id ) ) { |
|
1470 | + if ( ! give_is_name_title_prefix_enabled($form_id)) { |
|
1473 | 1471 | return false; |
1474 | 1472 | } |
1475 | 1473 | |
1476 | - $status = array( 'optional' ); |
|
1477 | - $is_optional = give_is_setting_enabled( give_get_option( 'name_title_prefix' ), $status ); |
|
1474 | + $status = array('optional'); |
|
1475 | + $is_optional = give_is_setting_enabled(give_get_option('name_title_prefix'), $status); |
|
1478 | 1476 | |
1479 | - if ( intval( $form_id ) > 0 ) { |
|
1480 | - $form_title_prefix = give_get_meta( $form_id, '_give_name_title_prefix', true ); |
|
1477 | + if (intval($form_id) > 0) { |
|
1478 | + $form_title_prefix = give_get_meta($form_id, '_give_name_title_prefix', true); |
|
1481 | 1479 | |
1482 | - if ( 'required' === $form_title_prefix ) { |
|
1480 | + if ('required' === $form_title_prefix) { |
|
1483 | 1481 | $is_optional = false; |
1484 | - } elseif ( 'optional' === $form_title_prefix ) { |
|
1482 | + } elseif ('optional' === $form_title_prefix) { |
|
1485 | 1483 | $is_optional = true; |
1486 | 1484 | } |
1487 | 1485 | } |
1488 | 1486 | |
1489 | - return ( ! $is_optional ); |
|
1487 | + return ( ! $is_optional); |
|
1490 | 1488 | } |