@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly. |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | * @since 1.0 |
36 | 36 | */ |
37 | 37 | public function __construct() { |
38 | - add_action( 'admin_menu', array( $this, 'admin_menus' ) ); |
|
39 | - add_action( 'admin_head', array( $this, 'admin_head' ) ); |
|
40 | - add_action( 'admin_init', array( $this, 'welcome' ) ); |
|
38 | + add_action('admin_menu', array($this, 'admin_menus')); |
|
39 | + add_action('admin_head', array($this, 'admin_head')); |
|
40 | + add_action('admin_init', array($this, 'welcome')); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -49,45 +49,45 @@ discard block |
||
49 | 49 | * @return void |
50 | 50 | */ |
51 | 51 | public function admin_menus() { |
52 | - list( $display_version ) = explode( '-', GIVE_VERSION ); |
|
52 | + list($display_version) = explode('-', GIVE_VERSION); |
|
53 | 53 | |
54 | 54 | // About Page |
55 | 55 | add_dashboard_page( |
56 | 56 | /* translators: %s: Give version */ |
57 | - sprintf( esc_html__( 'Welcome to Give %s', 'give' ), $display_version ), |
|
58 | - esc_html__( 'Welcome to Give', 'give' ), |
|
57 | + sprintf(esc_html__('Welcome to Give %s', 'give'), $display_version), |
|
58 | + esc_html__('Welcome to Give', 'give'), |
|
59 | 59 | $this->minimum_capability, |
60 | 60 | 'give-about', |
61 | - array( $this, 'about_screen' ) |
|
61 | + array($this, 'about_screen') |
|
62 | 62 | ); |
63 | 63 | |
64 | 64 | // Changelog Page |
65 | 65 | add_dashboard_page( |
66 | - esc_html__( 'Give Changelog', 'give' ), |
|
67 | - esc_html__( 'Give Changelog', 'give' ), |
|
66 | + esc_html__('Give Changelog', 'give'), |
|
67 | + esc_html__('Give Changelog', 'give'), |
|
68 | 68 | $this->minimum_capability, |
69 | 69 | 'give-changelog', |
70 | - array( $this, 'changelog_screen' ) |
|
70 | + array($this, 'changelog_screen') |
|
71 | 71 | ); |
72 | 72 | |
73 | 73 | // Getting Started Page |
74 | 74 | add_dashboard_page( |
75 | 75 | /* translators: %s: Give version */ |
76 | - sprintf( esc_html__( 'Give %s - Getting Started Guide', 'give' ), $display_version ), |
|
77 | - esc_html__( 'Getting started with Give', 'give' ), |
|
76 | + sprintf(esc_html__('Give %s - Getting Started Guide', 'give'), $display_version), |
|
77 | + esc_html__('Getting started with Give', 'give'), |
|
78 | 78 | $this->minimum_capability, |
79 | 79 | 'give-getting-started', |
80 | - array( $this, 'getting_started_screen' ) |
|
80 | + array($this, 'getting_started_screen') |
|
81 | 81 | ); |
82 | 82 | |
83 | 83 | // Credits Page |
84 | 84 | add_dashboard_page( |
85 | 85 | /* translators: %s: Give version */ |
86 | - sprintf( esc_html__( 'Give %s - Credits', 'give' ), $display_version ), |
|
87 | - esc_html__( 'The people that build Give', 'give' ), |
|
86 | + sprintf(esc_html__('Give %s - Credits', 'give'), $display_version), |
|
87 | + esc_html__('The people that build Give', 'give'), |
|
88 | 88 | $this->minimum_capability, |
89 | 89 | 'give-credits', |
90 | - array( $this, 'credits_screen' ) |
|
90 | + array($this, 'credits_screen') |
|
91 | 91 | ); |
92 | 92 | } |
93 | 93 | |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function admin_head() { |
102 | 102 | |
103 | - remove_submenu_page( 'index.php', 'give-about' ); |
|
104 | - remove_submenu_page( 'index.php', 'give-changelog' ); |
|
105 | - remove_submenu_page( 'index.php', 'give-getting-started' ); |
|
106 | - remove_submenu_page( 'index.php', 'give-credits' ); |
|
103 | + remove_submenu_page('index.php', 'give-about'); |
|
104 | + remove_submenu_page('index.php', 'give-changelog'); |
|
105 | + remove_submenu_page('index.php', 'give-getting-started'); |
|
106 | + remove_submenu_page('index.php', 'give-credits'); |
|
107 | 107 | |
108 | 108 | } |
109 | 109 | |
@@ -115,24 +115,24 @@ discard block |
||
115 | 115 | * @return void |
116 | 116 | */ |
117 | 117 | public function tabs() { |
118 | - $selected = isset( $_GET['page'] ) ? $_GET['page'] : 'give-about'; |
|
118 | + $selected = isset($_GET['page']) ? $_GET['page'] : 'give-about'; |
|
119 | 119 | ?> |
120 | 120 | <h2 class="nav-tab-wrapper"> |
121 | 121 | <a class="nav-tab <?php echo $selected == 'give-about' ? 'nav-tab-active' : ''; ?>" |
122 | - href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'give-about' ), 'index.php' ) ) ); ?>"> |
|
123 | - <?php esc_html_e( 'About Give', 'give' ); ?> |
|
122 | + href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'give-about'), 'index.php'))); ?>"> |
|
123 | + <?php esc_html_e('About Give', 'give'); ?> |
|
124 | 124 | </a> |
125 | 125 | <a class="nav-tab <?php echo $selected == 'give-getting-started' ? 'nav-tab-active' : ''; ?>" |
126 | - href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'give-getting-started' ), 'index.php' ) ) ); ?>"> |
|
127 | - <?php esc_html_e( 'Getting Started', 'give' ); ?> |
|
126 | + href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'give-getting-started'), 'index.php'))); ?>"> |
|
127 | + <?php esc_html_e('Getting Started', 'give'); ?> |
|
128 | 128 | </a> |
129 | 129 | <a class="nav-tab <?php echo $selected == 'give-credits' ? 'nav-tab-active' : ''; ?>" |
130 | - href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'give-credits' ), 'index.php' ) ) ); ?>"> |
|
131 | - <?php esc_html_e( 'Credits', 'give' ); ?> |
|
130 | + href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'give-credits'), 'index.php'))); ?>"> |
|
131 | + <?php esc_html_e('Credits', 'give'); ?> |
|
132 | 132 | </a> |
133 | 133 | <a class="nav-tab <?php echo $selected == 'give-add-ons' ? 'nav-tab-active' : ''; ?>" |
134 | - href="<?php echo esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-addons' ) ); ?>"> |
|
135 | - <?php esc_html_e( 'Add-ons', 'give' ); ?> |
|
134 | + href="<?php echo esc_url(admin_url('edit.php?post_type=give_forms&page=give-addons')); ?>"> |
|
135 | + <?php esc_html_e('Add-ons', 'give'); ?> |
|
136 | 136 | </a> |
137 | 137 | </h2> |
138 | 138 | <?php |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @return void |
147 | 147 | */ |
148 | 148 | public function about_screen() { |
149 | - list( $display_version ) = explode( '-', GIVE_VERSION ); |
|
149 | + list($display_version) = explode('-', GIVE_VERSION); |
|
150 | 150 | ?> |
151 | 151 | <div class="wrap about-wrap"> |
152 | 152 | |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | <p class="about-text"><?php |
156 | 156 | printf( |
157 | 157 | /* translators: %s: https://givewp.com/documenation/ */ |
158 | - __( 'Thank you for activating or updating to the latest version of Give! If you\'re a first time user, welcome! You\'re well on your way to empowering your cause. We encourage you to check out the <a href="%s" target="_blank">plugin documentation</a> and getting started guide below.', 'give' ), |
|
159 | - esc_url( 'https://givewp.com/documenation/' ) |
|
158 | + __('Thank you for activating or updating to the latest version of Give! If you\'re a first time user, welcome! You\'re well on your way to empowering your cause. We encourage you to check out the <a href="%s" target="_blank">plugin documentation</a> and getting started guide below.', 'give'), |
|
159 | + esc_url('https://givewp.com/documenation/') |
|
160 | 160 | ); |
161 | 161 | ?></p> |
162 | 162 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | <div class="give-badge"><?php |
166 | 166 | printf( |
167 | 167 | /* translators: %s: Give version */ |
168 | - esc_html__( 'Version %s', 'give' ), |
|
168 | + esc_html__('Version %s', 'give'), |
|
169 | 169 | $display_version |
170 | 170 | ); |
171 | 171 | ?></div> |
@@ -175,17 +175,17 @@ discard block |
||
175 | 175 | <div class="feature-section clearfix introduction"> |
176 | 176 | |
177 | 177 | <div class="video feature-section-item"> |
178 | - <img src="<?php echo GIVE_PLUGIN_URL . '/assets/images/give-logo-photo-mashup.png' ?>" |
|
179 | - alt="<?php esc_attr_e( 'Give', 'give' ); ?>"> |
|
178 | + <img src="<?php echo GIVE_PLUGIN_URL.'/assets/images/give-logo-photo-mashup.png' ?>" |
|
179 | + alt="<?php esc_attr_e('Give', 'give'); ?>"> |
|
180 | 180 | </div> |
181 | 181 | |
182 | 182 | <div class="content feature-section-item last-feature"> |
183 | 183 | |
184 | - <h3><?php esc_html_e( 'Give - Democratizing Generosity', 'give' ); ?></h3> |
|
184 | + <h3><?php esc_html_e('Give - Democratizing Generosity', 'give'); ?></h3> |
|
185 | 185 | |
186 | - <p><?php esc_html_e( 'Give empowers you to easily accept donations and setup fundraising campaigns, directly within WordPress. We created Give to provide a better donation experience for you and your users. Robust, flexible, and intuitive, the plugin is built from the ground up to be the goto donation solution for WordPress. Create powerful donation forms, embed them throughout your website, start a campaign, and exceed your fundraising goals with Give. This plugin is actively developed and proudly supported by folks who are dedicated to helping you and your cause.', 'give' ); ?></p> |
|
186 | + <p><?php esc_html_e('Give empowers you to easily accept donations and setup fundraising campaigns, directly within WordPress. We created Give to provide a better donation experience for you and your users. Robust, flexible, and intuitive, the plugin is built from the ground up to be the goto donation solution for WordPress. Create powerful donation forms, embed them throughout your website, start a campaign, and exceed your fundraising goals with Give. This plugin is actively developed and proudly supported by folks who are dedicated to helping you and your cause.', 'give'); ?></p> |
|
187 | 187 | <a href="https://givewp.com" target="_blank" class="button-secondary"> |
188 | - <?php esc_html_e( 'Learn More', 'give' ); ?> |
|
188 | + <?php esc_html_e('Learn More', 'give'); ?> |
|
189 | 189 | <span class="dashicons dashicons-external"></span> |
190 | 190 | </a> |
191 | 191 | |
@@ -198,22 +198,22 @@ discard block |
||
198 | 198 | |
199 | 199 | <div class="content feature-section-item"> |
200 | 200 | |
201 | - <h3><?php esc_html_e( 'Getting to Know Give', 'give' ); ?></h3> |
|
201 | + <h3><?php esc_html_e('Getting to Know Give', 'give'); ?></h3> |
|
202 | 202 | |
203 | - <p><?php esc_html_e( 'Before you get started with Give we suggest you take a look at the online documentation. There you will find the getting started guide which will help you get up and running quickly. If you have a question, issue or bug with the Core plugin please submit an issue on the Give website. We also welcome your feedback and feature requests. Welcome to Give. We hope you much success with your cause.', 'give' ); ?></p> |
|
203 | + <p><?php esc_html_e('Before you get started with Give we suggest you take a look at the online documentation. There you will find the getting started guide which will help you get up and running quickly. If you have a question, issue or bug with the Core plugin please submit an issue on the Give website. We also welcome your feedback and feature requests. Welcome to Give. We hope you much success with your cause.', 'give'); ?></p> |
|
204 | 204 | |
205 | 205 | <h4>Find Out More:</h4> |
206 | 206 | <ul class="ul-disc"> |
207 | - <li><a href="https://givewp.com/" target="_blank"><?php esc_html_e( 'Visit the Give Website', 'give' ); ?></a></li> |
|
208 | - <li><a href="https://givewp.com/features/" target="_blank"><?php esc_html_e( 'View the Give Features', 'give' ); ?></a></li> |
|
209 | - <li><a href="https://givewp.com/documentation/" target="_blank"><?php esc_html_e( 'Read the Documentation', 'give' ); ?></a></li> |
|
207 | + <li><a href="https://givewp.com/" target="_blank"><?php esc_html_e('Visit the Give Website', 'give'); ?></a></li> |
|
208 | + <li><a href="https://givewp.com/features/" target="_blank"><?php esc_html_e('View the Give Features', 'give'); ?></a></li> |
|
209 | + <li><a href="https://givewp.com/documentation/" target="_blank"><?php esc_html_e('Read the Documentation', 'give'); ?></a></li> |
|
210 | 210 | </ul> |
211 | 211 | |
212 | 212 | </div> |
213 | 213 | |
214 | 214 | <div class="content feature-section-item last-feature"> |
215 | - <img src="<?php echo GIVE_PLUGIN_URL . '/assets/images/admin/give-form-mockup.png' ?>" |
|
216 | - alt="<?php esc_attr_e( 'A Give donation form', 'give' ); ?>"> |
|
215 | + <img src="<?php echo GIVE_PLUGIN_URL.'/assets/images/admin/give-form-mockup.png' ?>" |
|
216 | + alt="<?php esc_attr_e('A Give donation form', 'give'); ?>"> |
|
217 | 217 | </div> |
218 | 218 | |
219 | 219 | </div> |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * @return void |
233 | 233 | */ |
234 | 234 | public function changelog_screen() { |
235 | - list( $display_version ) = explode( '-', GIVE_VERSION ); |
|
235 | + list($display_version) = explode('-', GIVE_VERSION); |
|
236 | 236 | ?> |
237 | 237 | <div class="wrap about-wrap"> |
238 | 238 | <h1><?php echo get_admin_page_title(); ?></h1> |
@@ -240,14 +240,14 @@ discard block |
||
240 | 240 | <p class="about-text"><?php |
241 | 241 | printf( |
242 | 242 | /* translators: %s: Give version */ |
243 | - esc_html__( 'Thank you for updating to the latest version! Give %s is ready to make your online store faster, safer, and better!', 'give' ), |
|
243 | + esc_html__('Thank you for updating to the latest version! Give %s is ready to make your online store faster, safer, and better!', 'give'), |
|
244 | 244 | $display_version |
245 | 245 | ); |
246 | 246 | ?></p> |
247 | 247 | <div class="give-badge"><?php |
248 | 248 | printf( |
249 | 249 | /* translators: %s: Give version */ |
250 | - esc_html__( 'Version %s', 'give' ), |
|
250 | + esc_html__('Version %s', 'give'), |
|
251 | 251 | $display_version |
252 | 252 | ); |
253 | 253 | ?></div> |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | <?php $this->tabs(); ?> |
256 | 256 | |
257 | 257 | <div class="changelog"> |
258 | - <h3><?php esc_html_e( 'Full Changelog', 'give' ); ?></h3> |
|
258 | + <h3><?php esc_html_e('Full Changelog', 'give'); ?></h3> |
|
259 | 259 | |
260 | 260 | <div class="feature-section"> |
261 | 261 | <?php echo $this->parse_readme(); ?> |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | </div> |
264 | 264 | |
265 | 265 | <div class="return-to-dashboard"> |
266 | - <a href="<?php echo esc_url( admin_url( add_query_arg( array( |
|
266 | + <a href="<?php echo esc_url(admin_url(add_query_arg(array( |
|
267 | 267 | 'post_type' => 'give_forms', |
268 | 268 | 'page' => 'give-settings' |
269 | - ), 'edit.php' ) ) ); ?>"><?php esc_html_e( 'Give Settings', 'give' ); ?></a> |
|
269 | + ), 'edit.php'))); ?>"><?php esc_html_e('Give Settings', 'give'); ?></a> |
|
270 | 270 | </div> |
271 | 271 | </div> |
272 | 272 | <?php |
@@ -280,36 +280,36 @@ discard block |
||
280 | 280 | * @return void |
281 | 281 | */ |
282 | 282 | public function getting_started_screen() { |
283 | - list( $display_version ) = explode( '-', GIVE_VERSION ); |
|
283 | + list($display_version) = explode('-', GIVE_VERSION); |
|
284 | 284 | ?> |
285 | 285 | <div class="wrap about-wrap get-started"> |
286 | 286 | |
287 | 287 | <?php $this->get_welcome_header() ?> |
288 | 288 | |
289 | - <p class="about-text"><?php esc_html_e( 'Welcome to the getting started guide.', 'give' ); ?></p> |
|
289 | + <p class="about-text"><?php esc_html_e('Welcome to the getting started guide.', 'give'); ?></p> |
|
290 | 290 | |
291 | 291 | <?php give_get_newsletter(); ?> |
292 | 292 | |
293 | 293 | <div class="give-badge"><?php |
294 | 294 | printf( |
295 | 295 | /* translators: %s: Give version */ |
296 | - esc_html__( 'Version %s', 'give' ), |
|
296 | + esc_html__('Version %s', 'give'), |
|
297 | 297 | $display_version |
298 | 298 | ); |
299 | 299 | ?></div> |
300 | 300 | |
301 | 301 | <?php $this->tabs(); ?> |
302 | 302 | |
303 | - <p class="about-text"><?php printf( esc_html__( 'Getting started with Give is easy! We put together this quick start guide to help first time users of the plugin. Our goal is to get you up and running in no time. Let\'s begin!', 'give' ), $display_version ); ?></p> |
|
303 | + <p class="about-text"><?php printf(esc_html__('Getting started with Give is easy! We put together this quick start guide to help first time users of the plugin. Our goal is to get you up and running in no time. Let\'s begin!', 'give'), $display_version); ?></p> |
|
304 | 304 | |
305 | 305 | <div class="feature-section clearfix"> |
306 | 306 | |
307 | 307 | <div class="content feature-section-item"> |
308 | - <h3><?php esc_html_e( 'STEP 1: Create a New Form', 'give' ); ?></h3> |
|
308 | + <h3><?php esc_html_e('STEP 1: Create a New Form', 'give'); ?></h3> |
|
309 | 309 | |
310 | - <p><?php esc_html_e( 'Give is driven by it\'s powerful donation form building features. However, it is much more than just a "donation form". From the "Add Form" page you\'ll be able to choose how and where you want to receive your donations. You will also be able to set the preferred donation amounts.', 'give' ); ?></p> |
|
310 | + <p><?php esc_html_e('Give is driven by it\'s powerful donation form building features. However, it is much more than just a "donation form". From the "Add Form" page you\'ll be able to choose how and where you want to receive your donations. You will also be able to set the preferred donation amounts.', 'give'); ?></p> |
|
311 | 311 | |
312 | - <p><?php esc_html_e( 'All of these features begin by simply going to the menu and choosing "Donations > Add Form".', 'give' ); ?></p> |
|
312 | + <p><?php esc_html_e('All of these features begin by simply going to the menu and choosing "Donations > Add Form".', 'give'); ?></p> |
|
313 | 313 | </div> |
314 | 314 | |
315 | 315 | <div class="content feature-section-item last-feature"> |
@@ -326,9 +326,9 @@ discard block |
||
326 | 326 | </div> |
327 | 327 | |
328 | 328 | <div class="content feature-section-item last-feature"> |
329 | - <h3><?php esc_html_e( 'STEP 2: Customize Your Donation Forms', 'give' ); ?></h3> |
|
329 | + <h3><?php esc_html_e('STEP 2: Customize Your Donation Forms', 'give'); ?></h3> |
|
330 | 330 | |
331 | - <p><?php esc_html_e( 'Each donation form you create can be customized to receive either a pre-determined set donation amount or have multiple suggested levels of giving. Choosing "Multi-level Donation" opens up the donation levels view where you can add as many levels as you\'d like with your own custom names and suggested amounts. As well, you can allow donors to give a custom amount and even set up donation goals.', 'give' ); ?></p> |
|
331 | + <p><?php esc_html_e('Each donation form you create can be customized to receive either a pre-determined set donation amount or have multiple suggested levels of giving. Choosing "Multi-level Donation" opens up the donation levels view where you can add as many levels as you\'d like with your own custom names and suggested amounts. As well, you can allow donors to give a custom amount and even set up donation goals.', 'give'); ?></p> |
|
332 | 332 | </div> |
333 | 333 | |
334 | 334 | </div> |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | <div class="feature-section clearfix"> |
338 | 338 | |
339 | 339 | <div class="content feature-section-item add-content"> |
340 | - <h3><?php esc_html_e( 'STEP 3: Add Additional Content', 'give' ); ?></h3> |
|
340 | + <h3><?php esc_html_e('STEP 3: Add Additional Content', 'give'); ?></h3> |
|
341 | 341 | |
342 | - <p><?php esc_html_e( 'Every donation form you create with Give can be used on its own stand-alone page, or it can be inserted into any other page or post throughout your site via a shortcode or widget.', 'give' ); ?></p> |
|
342 | + <p><?php esc_html_e('Every donation form you create with Give can be used on its own stand-alone page, or it can be inserted into any other page or post throughout your site via a shortcode or widget.', 'give'); ?></p> |
|
343 | 343 | |
344 | - <p><?php esc_html_e( 'You can choose these different modes by going to the "Form Content" section. From there, you can choose to add content before or after the donation form on a page, or if you choose "None" perhaps you want to instead use the shortcode. You can find the shortcode in the top right column directly under the Publish/Save button. This feature gives you the most amount of flexibility with controlling your content on your website all within the same page.', 'give' ); ?></p> |
|
344 | + <p><?php esc_html_e('You can choose these different modes by going to the "Form Content" section. From there, you can choose to add content before or after the donation form on a page, or if you choose "None" perhaps you want to instead use the shortcode. You can find the shortcode in the top right column directly under the Publish/Save button. This feature gives you the most amount of flexibility with controlling your content on your website all within the same page.', 'give'); ?></p> |
|
345 | 345 | </div> |
346 | 346 | |
347 | 347 | <div class="content feature-section-item last-feature"> |
@@ -358,9 +358,9 @@ discard block |
||
358 | 358 | </div> |
359 | 359 | |
360 | 360 | <div class="content feature-section-item last-feature"> |
361 | - <h3><?php esc_html_e( 'STEP 4: Configure Your Display Options', 'give' ); ?></h3> |
|
361 | + <h3><?php esc_html_e('STEP 4: Configure Your Display Options', 'give'); ?></h3> |
|
362 | 362 | |
363 | - <p><?php esc_html_e( 'Lastly, you can present the form in a number of different ways that each create their own unique donor experience. The "Modal" display mode opens the credit card fieldset within a popup window. The "Reveal" mode will slide into place the additional fields. If you\'re looking for a simple button, then "Button" more is the way to go. This allows you to create a customizable "Donate Now" button which will open the donation form upon clicking. There\'s tons of possibilities here, give it a try!', 'give' ); ?></p> |
|
363 | + <p><?php esc_html_e('Lastly, you can present the form in a number of different ways that each create their own unique donor experience. The "Modal" display mode opens the credit card fieldset within a popup window. The "Reveal" mode will slide into place the additional fields. If you\'re looking for a simple button, then "Button" more is the way to go. This allows you to create a customizable "Donate Now" button which will open the donation form upon clicking. There\'s tons of possibilities here, give it a try!', 'give'); ?></p> |
|
364 | 364 | </div> |
365 | 365 | |
366 | 366 | |
@@ -380,20 +380,20 @@ discard block |
||
380 | 380 | * @return void |
381 | 381 | */ |
382 | 382 | public function credits_screen() { |
383 | - list( $display_version ) = explode( '-', GIVE_VERSION ); |
|
383 | + list($display_version) = explode('-', GIVE_VERSION); |
|
384 | 384 | ?> |
385 | 385 | <div class="wrap about-wrap"> |
386 | 386 | |
387 | 387 | <?php $this->get_welcome_header() ?> |
388 | 388 | |
389 | - <p class="about-text"><?php esc_html_e( 'Thanks to all those who have contributed code directly or indirectly.', 'give' ); ?></p> |
|
389 | + <p class="about-text"><?php esc_html_e('Thanks to all those who have contributed code directly or indirectly.', 'give'); ?></p> |
|
390 | 390 | |
391 | 391 | <?php give_get_newsletter(); ?> |
392 | 392 | |
393 | 393 | <div class="give-badge"><?php |
394 | 394 | printf( |
395 | 395 | /* translators: %s: Give version */ |
396 | - esc_html__( 'Version %s', 'give' ), |
|
396 | + esc_html__('Version %s', 'give'), |
|
397 | 397 | $display_version |
398 | 398 | ); |
399 | 399 | ?></div> |
@@ -403,8 +403,8 @@ discard block |
||
403 | 403 | <p class="about-description"><?php |
404 | 404 | printf( |
405 | 405 | /* translators: %s: https://github.com/WordImpress/give */ |
406 | - __( 'Give is created by a dedicated team of developers. If you are interested in contributing please visit the <a href="%s" target="_blank">GitHub Repo</a>.', 'give' ), |
|
407 | - esc_url( 'https://github.com/WordImpress/give' ) |
|
406 | + __('Give is created by a dedicated team of developers. If you are interested in contributing please visit the <a href="%s" target="_blank">GitHub Repo</a>.', 'give'), |
|
407 | + esc_url('https://github.com/WordImpress/give') |
|
408 | 408 | ); |
409 | 409 | ?></p> |
410 | 410 | |
@@ -421,21 +421,21 @@ discard block |
||
421 | 421 | * @return string $readme HTML formatted readme file |
422 | 422 | */ |
423 | 423 | public function parse_readme() { |
424 | - $file = file_exists( GIVE_PLUGIN_DIR . 'readme.txt' ) ? GIVE_PLUGIN_DIR . 'readme.txt' : null; |
|
424 | + $file = file_exists(GIVE_PLUGIN_DIR.'readme.txt') ? GIVE_PLUGIN_DIR.'readme.txt' : null; |
|
425 | 425 | |
426 | - if ( ! $file ) { |
|
427 | - $readme = '<p>' . esc_html__( 'No valid changlog was found.', 'give' ) . '</p>'; |
|
426 | + if ( ! $file) { |
|
427 | + $readme = '<p>'.esc_html__('No valid changlog was found.', 'give').'</p>'; |
|
428 | 428 | } else { |
429 | - $readme = file_get_contents( $file ); |
|
430 | - $readme = nl2br( esc_html( $readme ) ); |
|
431 | - $readme = explode( '== Changelog ==', $readme ); |
|
432 | - $readme = end( $readme ); |
|
433 | - |
|
434 | - $readme = preg_replace( '/`(.*?)`/', '<code>\\1</code>', $readme ); |
|
435 | - $readme = preg_replace( '/[\040]\*\*(.*?)\*\*/', ' <strong>\\1</strong>', $readme ); |
|
436 | - $readme = preg_replace( '/[\040]\*(.*?)\*/', ' <em>\\1</em>', $readme ); |
|
437 | - $readme = preg_replace( '/= (.*?) =/', '<h4>\\1</h4>', $readme ); |
|
438 | - $readme = preg_replace( '/\[(.*?)\]\((.*?)\)/', '<a href="\\2">\\1</a>', $readme ); |
|
429 | + $readme = file_get_contents($file); |
|
430 | + $readme = nl2br(esc_html($readme)); |
|
431 | + $readme = explode('== Changelog ==', $readme); |
|
432 | + $readme = end($readme); |
|
433 | + |
|
434 | + $readme = preg_replace('/`(.*?)`/', '<code>\\1</code>', $readme); |
|
435 | + $readme = preg_replace('/[\040]\*\*(.*?)\*\*/', ' <strong>\\1</strong>', $readme); |
|
436 | + $readme = preg_replace('/[\040]\*(.*?)\*/', ' <em>\\1</em>', $readme); |
|
437 | + $readme = preg_replace('/= (.*?) =/', '<h4>\\1</h4>', $readme); |
|
438 | + $readme = preg_replace('/\[(.*?)\]\((.*?)\)/', '<a href="\\2">\\1</a>', $readme); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | return $readme; |
@@ -452,24 +452,24 @@ discard block |
||
452 | 452 | public function contributors() { |
453 | 453 | $contributors = $this->get_contributors(); |
454 | 454 | |
455 | - if ( empty( $contributors ) ) { |
|
455 | + if (empty($contributors)) { |
|
456 | 456 | return ''; |
457 | 457 | } |
458 | 458 | |
459 | 459 | $contributor_list = '<ul class="wp-people-group">'; |
460 | 460 | |
461 | - foreach ( $contributors as $contributor ) { |
|
461 | + foreach ($contributors as $contributor) { |
|
462 | 462 | $contributor_list .= '<li class="wp-person">'; |
463 | 463 | $contributor_list .= sprintf( |
464 | 464 | '<a href="%1$s" target="_blank"><img src="%2$s" width="64" height="64" class="gravatar" alt="%3$s" /></a>', |
465 | - esc_url( 'https://github.com/' . $contributor->login ), |
|
466 | - esc_url( $contributor->avatar_url ), |
|
467 | - esc_attr( $contributor->login ) |
|
465 | + esc_url('https://github.com/'.$contributor->login), |
|
466 | + esc_url($contributor->avatar_url), |
|
467 | + esc_attr($contributor->login) |
|
468 | 468 | ); |
469 | 469 | $contributor_list .= sprintf( |
470 | 470 | '<a class="web" target="_blank" href="%1$s">%2$s</a>', |
471 | - esc_url( 'https://github.com/' . $contributor->login ), |
|
472 | - esc_html( $contributor->login ) |
|
471 | + esc_url('https://github.com/'.$contributor->login), |
|
472 | + esc_html($contributor->login) |
|
473 | 473 | ); |
474 | 474 | $contributor_list .= '</li>'; |
475 | 475 | } |
@@ -487,25 +487,25 @@ discard block |
||
487 | 487 | * @return array $contributors List of contributors |
488 | 488 | */ |
489 | 489 | public function get_contributors() { |
490 | - $contributors = Give_Cache::get( 'give_contributors', true ); |
|
490 | + $contributors = Give_Cache::get('give_contributors', true); |
|
491 | 491 | |
492 | - if ( false !== $contributors ) { |
|
492 | + if (false !== $contributors) { |
|
493 | 493 | return $contributors; |
494 | 494 | } |
495 | 495 | |
496 | - $response = wp_remote_get( 'https://api.github.com/repos/WordImpress/Give/contributors', array( 'sslverify' => false ) ); |
|
496 | + $response = wp_remote_get('https://api.github.com/repos/WordImpress/Give/contributors', array('sslverify' => false)); |
|
497 | 497 | |
498 | - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { |
|
498 | + if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) { |
|
499 | 499 | return array(); |
500 | 500 | } |
501 | 501 | |
502 | - $contributors = json_decode( wp_remote_retrieve_body( $response ) ); |
|
502 | + $contributors = json_decode(wp_remote_retrieve_body($response)); |
|
503 | 503 | |
504 | - if ( ! is_array( $contributors ) ) { |
|
504 | + if ( ! is_array($contributors)) { |
|
505 | 505 | return array(); |
506 | 506 | } |
507 | 507 | |
508 | - Give_Cache::set( 'give_contributors', $contributors, HOUR_IN_SECONDS, true ); |
|
508 | + Give_Cache::set('give_contributors', $contributors, HOUR_IN_SECONDS, true); |
|
509 | 509 | |
510 | 510 | return $contributors; |
511 | 511 | } |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | */ |
518 | 518 | public function get_welcome_header() { |
519 | 519 | // Badge for welcome page |
520 | - $badge_url = GIVE_PLUGIN_URL . 'assets/images/give-badge.png'; |
|
520 | + $badge_url = GIVE_PLUGIN_URL.'assets/images/give-badge.png'; |
|
521 | 521 | ?> |
522 | 522 | <h1 class="welcome-h1"><?php echo get_admin_page_title(); ?></h1> |
523 | 523 | <?php $this->social_media_elements(); ?> |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | <a href="https://twitter.com/givewp" class="twitter-follow-button" data-show-count="false"><?php |
611 | 611 | printf( |
612 | 612 | /* translators: %s: Give twitter user @givewp */ |
613 | - esc_html_e( 'Follow %s', 'give' ), |
|
613 | + esc_html_e('Follow %s', 'give'), |
|
614 | 614 | '@givewp' |
615 | 615 | ); |
616 | 616 | ?></a> |
@@ -644,27 +644,27 @@ discard block |
||
644 | 644 | public function welcome() { |
645 | 645 | |
646 | 646 | // Bail if no activation redirect |
647 | - if ( ! Give_Cache::get( '_give_activation_redirect', true ) ) { |
|
647 | + if ( ! Give_Cache::get('_give_activation_redirect', true)) { |
|
648 | 648 | return; |
649 | 649 | } |
650 | 650 | |
651 | 651 | // Delete the redirect transient |
652 | - Give_Cache::delete( Give_Cache::get_key( '_give_activation_redirect' ) ); |
|
652 | + Give_Cache::delete(Give_Cache::get_key('_give_activation_redirect')); |
|
653 | 653 | |
654 | 654 | // Bail if activating from network, or bulk |
655 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
655 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
656 | 656 | return; |
657 | 657 | } |
658 | 658 | |
659 | - $upgrade = get_option( 'give_version_upgraded_from' ); |
|
659 | + $upgrade = get_option('give_version_upgraded_from'); |
|
660 | 660 | |
661 | - if ( ! $upgrade ) { // First time install |
|
662 | - wp_safe_redirect( admin_url( 'index.php?page=give-about' ) ); |
|
661 | + if ( ! $upgrade) { // First time install |
|
662 | + wp_safe_redirect(admin_url('index.php?page=give-about')); |
|
663 | 663 | exit; |
664 | - } elseif ( ! give_is_setting_enabled( give_get_option( 'welcome' ) ) ) { // Welcome is disabled in settings |
|
664 | + } elseif ( ! give_is_setting_enabled(give_get_option('welcome'))) { // Welcome is disabled in settings |
|
665 | 665 | |
666 | 666 | } else { // Welcome is NOT disabled in settings |
667 | - wp_safe_redirect( admin_url( 'index.php?page=give-about' ) ); |
|
667 | + wp_safe_redirect(admin_url('index.php?page=give-about')); |
|
668 | 668 | exit; |
669 | 669 | } |
670 | 670 | } |
@@ -254,8 +254,8 @@ |
||
254 | 254 | $args = array( |
255 | 255 | 'id' => 'give-api-user-search', |
256 | 256 | 'name' => 'user_id', |
257 | - ); |
|
258 | - echo Give()->html->ajax_user_search($args); ?> |
|
257 | + ); |
|
258 | + echo Give()->html->ajax_user_search($args); ?> |
|
259 | 259 | <?php submit_button( esc_html__( 'Generate New API Keys', 'give' ), 'secondary', 'submit', false ); ?> |
260 | 260 | <?php |
261 | 261 | $give_api_is_bottom = true; |
@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | 17 | // Load WP_List_Table if not loaded |
18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
18 | +if ( ! class_exists('WP_List_Table')) { |
|
19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | global $status, $page; |
54 | 54 | |
55 | 55 | // Set parent defaults |
56 | - parent::__construct( array( |
|
57 | - 'singular' => esc_html__( 'API Key', 'give' ), // Singular name of the listed records |
|
58 | - 'plural' => esc_html__( 'API Keys', 'give' ), // Plural name of the listed records |
|
59 | - 'ajax' => false,// Does this table support ajax? |
|
60 | - ) ); |
|
56 | + parent::__construct(array( |
|
57 | + 'singular' => esc_html__('API Key', 'give'), // Singular name of the listed records |
|
58 | + 'plural' => esc_html__('API Keys', 'give'), // Plural name of the listed records |
|
59 | + 'ajax' => false, // Does this table support ajax? |
|
60 | + )); |
|
61 | 61 | |
62 | 62 | $this->query(); |
63 | 63 | } |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return string Column Name |
75 | 75 | */ |
76 | - public function column_default( $item, $column_name ) { |
|
77 | - return $item[ $column_name ]; |
|
76 | + public function column_default($item, $column_name) { |
|
77 | + return $item[$column_name]; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return string Column Name |
89 | 89 | */ |
90 | - public function column_key( $item ) { |
|
91 | - return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['key'] ) . '"/>'; |
|
90 | + public function column_key($item) { |
|
91 | + return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['key']).'"/>'; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return string Column Name |
103 | 103 | */ |
104 | - public function column_token( $item ) { |
|
105 | - return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['token'] ) . '"/>'; |
|
104 | + public function column_token($item) { |
|
105 | + return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['token']).'"/>'; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @return string Column Name |
117 | 117 | */ |
118 | - public function column_secret( $item ) { |
|
119 | - return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="' . esc_attr( $item['secret'] ) . '"/>'; |
|
118 | + public function column_secret($item) { |
|
119 | + return '<input onClick="this.setSelectionRange(0, this.value.length)" readonly="readonly" type="text" class="large-text" value="'.esc_attr($item['secret']).'"/>'; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -126,46 +126,46 @@ discard block |
||
126 | 126 | * @since 1.1 |
127 | 127 | * @return string |
128 | 128 | */ |
129 | - public function column_user( $item ) { |
|
129 | + public function column_user($item) { |
|
130 | 130 | |
131 | 131 | $actions = array(); |
132 | 132 | |
133 | - if ( apply_filters( 'give_api_log_requests', true ) ) { |
|
133 | + if (apply_filters('give_api_log_requests', true)) { |
|
134 | 134 | $actions['view'] = sprintf( |
135 | 135 | '<a href="%s">%s</a>', |
136 | - esc_url( add_query_arg( array( |
|
136 | + esc_url(add_query_arg(array( |
|
137 | 137 | 'section' => 'api_requests', |
138 | 138 | 'post_type' => 'give_forms', |
139 | 139 | 'page' => 'give-tools', |
140 | 140 | 'tab' => 'logs', |
141 | 141 | 's' => $item['email'], |
142 | - ), 'edit.php' ) ), |
|
143 | - esc_html__( 'View API Log', 'give' ) |
|
142 | + ), 'edit.php')), |
|
143 | + esc_html__('View API Log', 'give') |
|
144 | 144 | ); |
145 | 145 | } |
146 | 146 | |
147 | 147 | $actions['reissue'] = sprintf( |
148 | 148 | '<a href="%s" class="give-regenerate-api-key">%s</a>', |
149 | - esc_url( wp_nonce_url( add_query_arg( array( |
|
149 | + esc_url(wp_nonce_url(add_query_arg(array( |
|
150 | 150 | 'user_id' => $item['id'], |
151 | 151 | 'give_action' => 'process_api_key', |
152 | 152 | 'give_api_process' => 'regenerate', |
153 | - ) ), 'give-api-nonce' ) ), |
|
154 | - esc_html__( 'Reissue', 'give' ) |
|
153 | + )), 'give-api-nonce')), |
|
154 | + esc_html__('Reissue', 'give') |
|
155 | 155 | ); |
156 | - $actions['revoke'] = sprintf( |
|
156 | + $actions['revoke'] = sprintf( |
|
157 | 157 | '<a href="%s" class="give-revoke-api-key give-delete">%s</a>', |
158 | - esc_url( wp_nonce_url( add_query_arg( array( |
|
158 | + esc_url(wp_nonce_url(add_query_arg(array( |
|
159 | 159 | 'user_id' => $item['id'], |
160 | 160 | 'give_action' => 'process_api_key', |
161 | 161 | 'give_api_process' => 'revoke', |
162 | - ) ), 'give-api-nonce' ) ), |
|
163 | - esc_html__( 'Revoke', 'give' ) |
|
162 | + )), 'give-api-nonce')), |
|
163 | + esc_html__('Revoke', 'give') |
|
164 | 164 | ); |
165 | 165 | |
166 | - $actions = apply_filters( 'give_api_row_actions', array_filter( $actions ) ); |
|
166 | + $actions = apply_filters('give_api_row_actions', array_filter($actions)); |
|
167 | 167 | |
168 | - return sprintf( '%1$s %2$s', $item['user'], $this->row_actions( $actions ) ); |
|
168 | + return sprintf('%1$s %2$s', $item['user'], $this->row_actions($actions)); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -189,10 +189,10 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function get_columns() { |
191 | 191 | $columns = array( |
192 | - 'user' => esc_html__( 'Username', 'give' ), |
|
193 | - 'key' => esc_html__( 'Public Key', 'give' ), |
|
194 | - 'token' => esc_html__( 'Token', 'give' ), |
|
195 | - 'secret' => esc_html__( 'Secret Key', 'give' ), |
|
192 | + 'user' => esc_html__('Username', 'give'), |
|
193 | + 'key' => esc_html__('Public Key', 'give'), |
|
194 | + 'token' => esc_html__('Token', 'give'), |
|
195 | + 'secret' => esc_html__('Secret Key', 'give'), |
|
196 | 196 | ); |
197 | 197 | |
198 | 198 | return $columns; |
@@ -206,20 +206,20 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @param string $which |
208 | 208 | */ |
209 | - protected function display_tablenav( $which ) { |
|
210 | - if ( 'top' === $which ) { |
|
211 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
209 | + protected function display_tablenav($which) { |
|
210 | + if ('top' === $which) { |
|
211 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
212 | 212 | } |
213 | 213 | ?> |
214 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
214 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
215 | 215 | |
216 | 216 | <div class="alignleft actions bulkactions"> |
217 | - <?php $this->bulk_actions( $which ); ?> |
|
217 | + <?php $this->bulk_actions($which); ?> |
|
218 | 218 | </div> |
219 | 219 | |
220 | 220 | <?php |
221 | - $this->extra_tablenav( $which ); |
|
222 | - $this->pagination( $which ); |
|
221 | + $this->extra_tablenav($which); |
|
222 | + $this->pagination($which); |
|
223 | 223 | ?> |
224 | 224 | |
225 | 225 | <br class="clear"/> |
@@ -237,17 +237,17 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return void |
239 | 239 | */ |
240 | - function bulk_actions( $which = '' ) { |
|
240 | + function bulk_actions($which = '') { |
|
241 | 241 | // These aren't really bulk actions but this outputs the markup in the right place. |
242 | 242 | static $give_api_is_bottom; |
243 | 243 | |
244 | - if ( $give_api_is_bottom ) { |
|
244 | + if ($give_api_is_bottom) { |
|
245 | 245 | return; |
246 | 246 | } |
247 | 247 | ?> |
248 | 248 | <input type="hidden" name="give_action" value="process_api_key"/> |
249 | 249 | <input type="hidden" name="give_api_process" value="generate"/> |
250 | - <?php wp_nonce_field( 'give-api-nonce' ); |
|
250 | + <?php wp_nonce_field('give-api-nonce'); |
|
251 | 251 | /** |
252 | 252 | * API Key user search. |
253 | 253 | */ |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | 'name' => 'user_id', |
257 | 257 | ); |
258 | 258 | echo Give()->html->ajax_user_search($args); ?> |
259 | - <?php submit_button( esc_html__( 'Generate New API Keys', 'give' ), 'secondary', 'submit', false ); ?> |
|
259 | + <?php submit_button(esc_html__('Generate New API Keys', 'give'), 'secondary', 'submit', false); ?> |
|
260 | 260 | <?php |
261 | 261 | $give_api_is_bottom = true; |
262 | 262 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @return int Current page number |
270 | 270 | */ |
271 | 271 | public function get_paged() { |
272 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
272 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | /** |
@@ -280,21 +280,21 @@ discard block |
||
280 | 280 | * @return array |
281 | 281 | */ |
282 | 282 | public function query() { |
283 | - $users = get_users( array( |
|
283 | + $users = get_users(array( |
|
284 | 284 | 'meta_value' => 'give_user_secret_key', |
285 | 285 | 'number' => $this->per_page, |
286 | - 'offset' => $this->per_page * ( $this->get_paged() - 1 ), |
|
287 | - ) ); |
|
288 | - $keys = array(); |
|
289 | - |
|
290 | - foreach ( $users as $user ) { |
|
291 | - $keys[ $user->ID ]['id'] = $user->ID; |
|
292 | - $keys[ $user->ID ]['email'] = $user->user_email; |
|
293 | - $keys[ $user->ID ]['user'] = '<a href="' . add_query_arg( 'user_id', $user->ID, 'user-edit.php' ) . '"><strong>' . $user->user_login . '</strong></a>'; |
|
294 | - |
|
295 | - $keys[ $user->ID ]['key'] = Give()->api->get_user_public_key( $user->ID ); |
|
296 | - $keys[ $user->ID ]['secret'] = Give()->api->get_user_secret_key( $user->ID ); |
|
297 | - $keys[ $user->ID ]['token'] = Give()->api->get_token( $user->ID ); |
|
286 | + 'offset' => $this->per_page * ($this->get_paged() - 1), |
|
287 | + )); |
|
288 | + $keys = array(); |
|
289 | + |
|
290 | + foreach ($users as $user) { |
|
291 | + $keys[$user->ID]['id'] = $user->ID; |
|
292 | + $keys[$user->ID]['email'] = $user->user_email; |
|
293 | + $keys[$user->ID]['user'] = '<a href="'.add_query_arg('user_id', $user->ID, 'user-edit.php').'"><strong>'.$user->user_login.'</strong></a>'; |
|
294 | + |
|
295 | + $keys[$user->ID]['key'] = Give()->api->get_user_public_key($user->ID); |
|
296 | + $keys[$user->ID]['secret'] = Give()->api->get_user_secret_key($user->ID); |
|
297 | + $keys[$user->ID]['token'] = Give()->api->get_token($user->ID); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | return $keys; |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | public function total_items() { |
312 | 312 | global $wpdb; |
313 | 313 | |
314 | - if ( ! ( $total_items = Give_Cache::get( 'give_total_api_keys', true ) ) ) { |
|
314 | + if ( ! ($total_items = Give_Cache::get('give_total_api_keys', true))) { |
|
315 | 315 | $total_items = $wpdb->get_var( |
316 | 316 | $wpdb->prepare( |
317 | 317 | "SELECT count(user_id) |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | ) |
321 | 321 | ); |
322 | 322 | |
323 | - Give_Cache::set( 'give_total_api_keys', $total_items, HOUR_IN_SECONDS, true ); |
|
323 | + Give_Cache::set('give_total_api_keys', $total_items, HOUR_IN_SECONDS, true); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | return $total_items; |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | $hidden = array(); // No hidden columns |
340 | 340 | $sortable = array(); // Not sortable... for now |
341 | 341 | |
342 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
342 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
343 | 343 | |
344 | 344 | $data = $this->query(); |
345 | 345 | |
@@ -347,10 +347,10 @@ discard block |
||
347 | 347 | |
348 | 348 | $this->items = $data; |
349 | 349 | |
350 | - $this->set_pagination_args( array( |
|
350 | + $this->set_pagination_args(array( |
|
351 | 351 | 'total_items' => $total_items, |
352 | 352 | 'per_page' => $this->per_page, |
353 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
353 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
354 | 354 | ) |
355 | 355 | ); |
356 | 356 | } |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | ) |
48 | 48 | ); |
49 | 49 | |
50 | - $categories_enabled = give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ); |
|
51 | - $tags_enabled = give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ); |
|
50 | + $categories_enabled = give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ); |
|
51 | + $tags_enabled = give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ); |
|
52 | 52 | |
53 | 53 | $pdf = new give_pdf(); |
54 | 54 | $pdf->AddPage( 'L', 'A4' ); |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | $pdf->Cell( 70, 6, utf8_decode( __( 'Form Name', 'give' ) ), 1, 0, 'L', true ); |
81 | 81 | $pdf->Cell( 30, 6, utf8_decode( __( 'Price', 'give' ) ), 1, 0, 'L', true ); |
82 | 82 | |
83 | - // Display Categories Heading only, if user has opted for it. |
|
84 | - if ( $categories_enabled ) { |
|
83 | + // Display Categories Heading only, if user has opted for it. |
|
84 | + if ( $categories_enabled ) { |
|
85 | 85 | $pdf->Cell( 45, 6, utf8_decode( __( 'Categories', 'give' ) ), 1, 0, 'L', true ); |
86 | - } |
|
86 | + } |
|
87 | 87 | |
88 | - // Display Tags Heading only, if user has opted for it. |
|
89 | - if ( $tags_enabled ) { |
|
88 | + // Display Tags Heading only, if user has opted for it. |
|
89 | + if ( $tags_enabled ) { |
|
90 | 90 | $pdf->Cell( 45, 6, utf8_decode( __( 'Tags', 'give' ) ), 1, 0, 'L', true ); |
91 | - } |
|
91 | + } |
|
92 | 92 | |
93 | 93 | $pdf->Cell( 45, 6, utf8_decode( __( 'Number of Donations', 'give' ) ), 1, 0, 'L', true ); |
94 | 94 | $pdf->Cell( 45, 6, utf8_decode( __( 'Income to Date', 'give' ) ), 1, 1, 'L', true ); |
@@ -125,17 +125,17 @@ discard block |
||
125 | 125 | $price = give_currency_filter( give_get_form_price( $form->ID ), '', true ); |
126 | 126 | } |
127 | 127 | |
128 | - // Display Categories Data only, if user has opted for it. |
|
129 | - if ( $categories_enabled ) { |
|
130 | - $categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' ); |
|
131 | - $categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : ''; |
|
132 | - } |
|
128 | + // Display Categories Data only, if user has opted for it. |
|
129 | + if ( $categories_enabled ) { |
|
130 | + $categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' ); |
|
131 | + $categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : ''; |
|
132 | + } |
|
133 | 133 | |
134 | - // Display Tags Data only, if user has opted for it. |
|
135 | - if ( $tags_enabled ) { |
|
136 | - $tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' ); |
|
137 | - $tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : ''; |
|
138 | - } |
|
134 | + // Display Tags Data only, if user has opted for it. |
|
135 | + if ( $tags_enabled ) { |
|
136 | + $tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' ); |
|
137 | + $tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : ''; |
|
138 | + } |
|
139 | 139 | |
140 | 140 | $sales = give_get_form_sales_stats( $form->ID ); |
141 | 141 | $link = get_permalink( $form->ID ); |
@@ -147,38 +147,38 @@ discard block |
||
147 | 147 | $earnings = iconv( 'UTF-8', 'windows-1252', utf8_encode( $earnings ) ); |
148 | 148 | } |
149 | 149 | |
150 | - // This will help filter data before appending it to PDF Receipt. |
|
151 | - $prepare_pdf_data = array(); |
|
152 | - $prepare_pdf_data[] = $title; |
|
153 | - $prepare_pdf_data[] = $price; |
|
150 | + // This will help filter data before appending it to PDF Receipt. |
|
151 | + $prepare_pdf_data = array(); |
|
152 | + $prepare_pdf_data[] = $title; |
|
153 | + $prepare_pdf_data[] = $price; |
|
154 | 154 | |
155 | - // Append Categories Data only, if user has opted for it. |
|
156 | - if ( $categories_enabled ) { |
|
157 | - $prepare_pdf_data[] = $categories; |
|
158 | - } |
|
155 | + // Append Categories Data only, if user has opted for it. |
|
156 | + if ( $categories_enabled ) { |
|
157 | + $prepare_pdf_data[] = $categories; |
|
158 | + } |
|
159 | 159 | |
160 | - // Append Tags Data only, if user has opted for it. |
|
161 | - if ( $tags_enabled ) { |
|
162 | - $prepare_pdf_data[] = $tags; |
|
163 | - } |
|
160 | + // Append Tags Data only, if user has opted for it. |
|
161 | + if ( $tags_enabled ) { |
|
162 | + $prepare_pdf_data[] = $tags; |
|
163 | + } |
|
164 | 164 | |
165 | - $prepare_pdf_data[] = $sales; |
|
166 | - $prepare_pdf_data[] = $earnings; |
|
165 | + $prepare_pdf_data[] = $sales; |
|
166 | + $prepare_pdf_data[] = $earnings; |
|
167 | 167 | |
168 | 168 | $pdf->Row( $prepare_pdf_data ); |
169 | 169 | endforeach; |
170 | 170 | } else { |
171 | 171 | |
172 | - // Fix: Minor Styling Alignment Issue for PDF |
|
173 | - if( $categories_enabled && $tags_enabled ) { |
|
174 | - $pdf->SetWidths( array( 280 ) ); |
|
175 | - } elseif( $categories_enabled || $tags_enabled ) { |
|
176 | - $pdf->SetWidths( array( 235 ) ); |
|
177 | - } else { |
|
178 | - $pdf->SetWidths( array( 190 ) ); |
|
179 | - } |
|
172 | + // Fix: Minor Styling Alignment Issue for PDF |
|
173 | + if( $categories_enabled && $tags_enabled ) { |
|
174 | + $pdf->SetWidths( array( 280 ) ); |
|
175 | + } elseif( $categories_enabled || $tags_enabled ) { |
|
176 | + $pdf->SetWidths( array( 235 ) ); |
|
177 | + } else { |
|
178 | + $pdf->SetWidths( array( 190 ) ); |
|
179 | + } |
|
180 | 180 | |
181 | - $title = utf8_decode( __( 'No forms found.', 'give' ) ); |
|
181 | + $title = utf8_decode( __( 'No forms found.', 'give' ) ); |
|
182 | 182 | $pdf->Row( array( $title ) ); |
183 | 183 | } |
184 | 184 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly.. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,94 +25,94 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @uses give_pdf |
27 | 27 | */ |
28 | -function give_generate_pdf( $data ) { |
|
28 | +function give_generate_pdf($data) { |
|
29 | 29 | |
30 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
31 | - wp_die( __( 'You do not have permission to generate PDF sales reports.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
30 | + if ( ! current_user_can('view_give_reports')) { |
|
31 | + wp_die(__('You do not have permission to generate PDF sales reports.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
32 | 32 | } |
33 | 33 | |
34 | - if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'give_generate_pdf' ) ) { |
|
35 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
34 | + if ( ! wp_verify_nonce($_GET['_wpnonce'], 'give_generate_pdf')) { |
|
35 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403)); |
|
36 | 36 | } |
37 | 37 | |
38 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/fpdf.php'; |
|
39 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/give_pdf.php'; |
|
38 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/fpdf/fpdf.php'; |
|
39 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/fpdf/give_pdf.php'; |
|
40 | 40 | |
41 | 41 | $daterange = utf8_decode( |
42 | 42 | sprintf( |
43 | 43 | /* translators: 1: start date 2: end date */ |
44 | - __( '%1$s to %2$s', 'give' ), |
|
45 | - date_i18n( give_date_format(), mktime( 0, 0, 0, 1, 1, date( 'Y' ) ) ), |
|
46 | - date_i18n( give_date_format() ) |
|
44 | + __('%1$s to %2$s', 'give'), |
|
45 | + date_i18n(give_date_format(), mktime(0, 0, 0, 1, 1, date('Y'))), |
|
46 | + date_i18n(give_date_format()) |
|
47 | 47 | ) |
48 | 48 | ); |
49 | 49 | |
50 | - $categories_enabled = give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ); |
|
51 | - $tags_enabled = give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ); |
|
50 | + $categories_enabled = give_is_setting_enabled(give_get_option('categories', 'disabled')); |
|
51 | + $tags_enabled = give_is_setting_enabled(give_get_option('tags', 'disabled')); |
|
52 | 52 | |
53 | 53 | $pdf = new give_pdf(); |
54 | - $pdf->AddPage( 'L', 'A4' ); |
|
54 | + $pdf->AddPage('L', 'A4'); |
|
55 | 55 | |
56 | - $pdf->SetTitle( utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ) ); |
|
57 | - $pdf->SetAuthor( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) ); |
|
58 | - $pdf->SetCreator( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) ); |
|
56 | + $pdf->SetTitle(utf8_decode(__('Donation report for the current year for all forms', 'give'))); |
|
57 | + $pdf->SetAuthor(utf8_decode(__('Give - Democratizing Generosity', 'give'))); |
|
58 | + $pdf->SetCreator(utf8_decode(__('Give - Democratizing Generosity', 'give'))); |
|
59 | 59 | |
60 | - $pdf->Image( apply_filters( 'give_pdf_export_logo', GIVE_PLUGIN_URL . 'assets/images/give-logo-small.png' ), 247, 8 ); |
|
60 | + $pdf->Image(apply_filters('give_pdf_export_logo', GIVE_PLUGIN_URL.'assets/images/give-logo-small.png'), 247, 8); |
|
61 | 61 | |
62 | - $pdf->SetMargins( 8, 8, 8 ); |
|
63 | - $pdf->SetX( 8 ); |
|
62 | + $pdf->SetMargins(8, 8, 8); |
|
63 | + $pdf->SetX(8); |
|
64 | 64 | |
65 | - $pdf->SetFont( 'Helvetica', '', 16 ); |
|
66 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
67 | - $pdf->Cell( 0, 3, utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ), 0, 2, 'L', false ); |
|
65 | + $pdf->SetFont('Helvetica', '', 16); |
|
66 | + $pdf->SetTextColor(50, 50, 50); |
|
67 | + $pdf->Cell(0, 3, utf8_decode(__('Donation report for the current year for all forms', 'give')), 0, 2, 'L', false); |
|
68 | 68 | |
69 | - $pdf->SetFont( 'Helvetica', '', 13 ); |
|
69 | + $pdf->SetFont('Helvetica', '', 13); |
|
70 | 70 | $pdf->Ln(); |
71 | - $pdf->SetTextColor( 150, 150, 150 ); |
|
72 | - $pdf->Cell( 0, 6, utf8_decode( __( 'Date Range: ', 'give' ) ) . $daterange, 0, 2, 'L', false ); |
|
71 | + $pdf->SetTextColor(150, 150, 150); |
|
72 | + $pdf->Cell(0, 6, utf8_decode(__('Date Range: ', 'give')).$daterange, 0, 2, 'L', false); |
|
73 | 73 | $pdf->Ln(); |
74 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
75 | - $pdf->SetFont( 'Helvetica', '', 14 ); |
|
76 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Table View', 'give' ) ), 0, 2, 'L', false ); |
|
77 | - $pdf->SetFont( 'Helvetica', '', 12 ); |
|
74 | + $pdf->SetTextColor(50, 50, 50); |
|
75 | + $pdf->SetFont('Helvetica', '', 14); |
|
76 | + $pdf->Cell(0, 10, utf8_decode(__('Table View', 'give')), 0, 2, 'L', false); |
|
77 | + $pdf->SetFont('Helvetica', '', 12); |
|
78 | 78 | |
79 | - $pdf->SetFillColor( 238, 238, 238 ); |
|
80 | - $pdf->Cell( 70, 6, utf8_decode( __( 'Form Name', 'give' ) ), 1, 0, 'L', true ); |
|
81 | - $pdf->Cell( 30, 6, utf8_decode( __( 'Price', 'give' ) ), 1, 0, 'L', true ); |
|
79 | + $pdf->SetFillColor(238, 238, 238); |
|
80 | + $pdf->Cell(70, 6, utf8_decode(__('Form Name', 'give')), 1, 0, 'L', true); |
|
81 | + $pdf->Cell(30, 6, utf8_decode(__('Price', 'give')), 1, 0, 'L', true); |
|
82 | 82 | |
83 | 83 | // Display Categories Heading only, if user has opted for it. |
84 | - if ( $categories_enabled ) { |
|
85 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Categories', 'give' ) ), 1, 0, 'L', true ); |
|
84 | + if ($categories_enabled) { |
|
85 | + $pdf->Cell(45, 6, utf8_decode(__('Categories', 'give')), 1, 0, 'L', true); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | // Display Tags Heading only, if user has opted for it. |
89 | - if ( $tags_enabled ) { |
|
90 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Tags', 'give' ) ), 1, 0, 'L', true ); |
|
89 | + if ($tags_enabled) { |
|
90 | + $pdf->Cell(45, 6, utf8_decode(__('Tags', 'give')), 1, 0, 'L', true); |
|
91 | 91 | } |
92 | 92 | |
93 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Number of Donations', 'give' ) ), 1, 0, 'L', true ); |
|
94 | - $pdf->Cell( 45, 6, utf8_decode( __( 'Income to Date', 'give' ) ), 1, 1, 'L', true ); |
|
93 | + $pdf->Cell(45, 6, utf8_decode(__('Number of Donations', 'give')), 1, 0, 'L', true); |
|
94 | + $pdf->Cell(45, 6, utf8_decode(__('Income to Date', 'give')), 1, 1, 'L', true); |
|
95 | 95 | |
96 | - $year = date( 'Y' ); |
|
97 | - $give_forms = get_posts( array( 'post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => - 1 ) ); |
|
96 | + $year = date('Y'); |
|
97 | + $give_forms = get_posts(array('post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => -1)); |
|
98 | 98 | |
99 | - if ( $give_forms ) { |
|
100 | - $pdf->SetWidths( array( 70, 30, 45, 45, 45, 45 ) ); |
|
99 | + if ($give_forms) { |
|
100 | + $pdf->SetWidths(array(70, 30, 45, 45, 45, 45)); |
|
101 | 101 | |
102 | - foreach ( $give_forms as $form ): |
|
103 | - $pdf->SetFillColor( 255, 255, 255 ); |
|
102 | + foreach ($give_forms as $form): |
|
103 | + $pdf->SetFillColor(255, 255, 255); |
|
104 | 104 | |
105 | 105 | $title = $form->post_title; |
106 | 106 | |
107 | - if ( give_has_variable_prices( $form->ID ) ) { |
|
107 | + if (give_has_variable_prices($form->ID)) { |
|
108 | 108 | |
109 | - $prices = give_get_variable_prices( $form->ID ); |
|
109 | + $prices = give_get_variable_prices($form->ID); |
|
110 | 110 | |
111 | 111 | $first = $prices[0]['_give_amount']; |
112 | - $last = array_pop( $prices ); |
|
112 | + $last = array_pop($prices); |
|
113 | 113 | $last = $last['_give_amount']; |
114 | 114 | |
115 | - if ( $first < $last ) { |
|
115 | + if ($first < $last) { |
|
116 | 116 | $min = $first; |
117 | 117 | $max = $last; |
118 | 118 | } else { |
@@ -120,31 +120,31 @@ discard block |
||
120 | 120 | $max = $first; |
121 | 121 | } |
122 | 122 | |
123 | - $price = give_currency_filter( give_format_amount( $min, array( 'sanitize' => false ) ), '', true ) . ' - ' . give_currency_filter( give_format_amount( $max ), '', true ); |
|
123 | + $price = give_currency_filter(give_format_amount($min, array('sanitize' => false)), '', true).' - '.give_currency_filter(give_format_amount($max), '', true); |
|
124 | 124 | } else { |
125 | - $price = give_currency_filter( give_get_form_price( $form->ID ), '', true ); |
|
125 | + $price = give_currency_filter(give_get_form_price($form->ID), '', true); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | // Display Categories Data only, if user has opted for it. |
129 | - if ( $categories_enabled ) { |
|
130 | - $categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' ); |
|
131 | - $categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : ''; |
|
129 | + if ($categories_enabled) { |
|
130 | + $categories = get_the_term_list($form->ID, 'give_forms_category', '', ', ', ''); |
|
131 | + $categories = ! is_wp_error($categories) ? strip_tags($categories) : ''; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | // Display Tags Data only, if user has opted for it. |
135 | - if ( $tags_enabled ) { |
|
136 | - $tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' ); |
|
137 | - $tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : ''; |
|
135 | + if ($tags_enabled) { |
|
136 | + $tags = get_the_term_list($form->ID, 'give_forms_tag', '', ', ', ''); |
|
137 | + $tags = ! is_wp_error($tags) ? strip_tags($tags) : ''; |
|
138 | 138 | } |
139 | 139 | |
140 | - $sales = give_get_form_sales_stats( $form->ID ); |
|
141 | - $link = get_permalink( $form->ID ); |
|
142 | - $earnings = give_currency_filter( give_get_form_earnings_stats( $form->ID ), '', true ); |
|
140 | + $sales = give_get_form_sales_stats($form->ID); |
|
141 | + $link = get_permalink($form->ID); |
|
142 | + $earnings = give_currency_filter(give_get_form_earnings_stats($form->ID), '', true); |
|
143 | 143 | |
144 | - if ( function_exists( 'iconv' ) ) { |
|
144 | + if (function_exists('iconv')) { |
|
145 | 145 | // Ensure characters like euro; are properly converted. |
146 | - $price = iconv( 'UTF-8', 'windows-1252', utf8_encode( $price ) ); |
|
147 | - $earnings = iconv( 'UTF-8', 'windows-1252', utf8_encode( $earnings ) ); |
|
146 | + $price = iconv('UTF-8', 'windows-1252', utf8_encode($price)); |
|
147 | + $earnings = iconv('UTF-8', 'windows-1252', utf8_encode($earnings)); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | // This will help filter data before appending it to PDF Receipt. |
@@ -153,51 +153,51 @@ discard block |
||
153 | 153 | $prepare_pdf_data[] = $price; |
154 | 154 | |
155 | 155 | // Append Categories Data only, if user has opted for it. |
156 | - if ( $categories_enabled ) { |
|
156 | + if ($categories_enabled) { |
|
157 | 157 | $prepare_pdf_data[] = $categories; |
158 | 158 | } |
159 | 159 | |
160 | 160 | // Append Tags Data only, if user has opted for it. |
161 | - if ( $tags_enabled ) { |
|
161 | + if ($tags_enabled) { |
|
162 | 162 | $prepare_pdf_data[] = $tags; |
163 | 163 | } |
164 | 164 | |
165 | 165 | $prepare_pdf_data[] = $sales; |
166 | 166 | $prepare_pdf_data[] = $earnings; |
167 | 167 | |
168 | - $pdf->Row( $prepare_pdf_data ); |
|
168 | + $pdf->Row($prepare_pdf_data); |
|
169 | 169 | endforeach; |
170 | 170 | } else { |
171 | 171 | |
172 | 172 | // Fix: Minor Styling Alignment Issue for PDF |
173 | - if( $categories_enabled && $tags_enabled ) { |
|
174 | - $pdf->SetWidths( array( 280 ) ); |
|
175 | - } elseif( $categories_enabled || $tags_enabled ) { |
|
176 | - $pdf->SetWidths( array( 235 ) ); |
|
173 | + if ($categories_enabled && $tags_enabled) { |
|
174 | + $pdf->SetWidths(array(280)); |
|
175 | + } elseif ($categories_enabled || $tags_enabled) { |
|
176 | + $pdf->SetWidths(array(235)); |
|
177 | 177 | } else { |
178 | - $pdf->SetWidths( array( 190 ) ); |
|
178 | + $pdf->SetWidths(array(190)); |
|
179 | 179 | } |
180 | 180 | |
181 | - $title = utf8_decode( __( 'No forms found.', 'give' ) ); |
|
182 | - $pdf->Row( array( $title ) ); |
|
181 | + $title = utf8_decode(__('No forms found.', 'give')); |
|
182 | + $pdf->Row(array($title)); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | $pdf->Ln(); |
186 | - $pdf->SetTextColor( 50, 50, 50 ); |
|
187 | - $pdf->SetFont( 'Helvetica', '', 14 ); |
|
188 | - $pdf->Cell( 0, 10, utf8_decode( __( 'Graph View', 'give' ) ), 0, 2, 'L', false ); |
|
189 | - $pdf->SetFont( 'Helvetica', '', 12 ); |
|
190 | - |
|
191 | - $image = html_entity_decode( urldecode( give_draw_chart_image() ) ); |
|
192 | - $image = str_replace( ' ', '%20', $image ); |
|
193 | - |
|
194 | - $pdf->SetX( 25 ); |
|
195 | - $pdf->Image( $image . '&file=.png' ); |
|
196 | - $pdf->Ln( 7 ); |
|
197 | - $pdf->Output( apply_filters( 'give_sales_earnings_pdf_export_filename', 'give-report-' . date_i18n( 'Y-m-d' ) ) . '.pdf', 'D' ); |
|
186 | + $pdf->SetTextColor(50, 50, 50); |
|
187 | + $pdf->SetFont('Helvetica', '', 14); |
|
188 | + $pdf->Cell(0, 10, utf8_decode(__('Graph View', 'give')), 0, 2, 'L', false); |
|
189 | + $pdf->SetFont('Helvetica', '', 12); |
|
190 | + |
|
191 | + $image = html_entity_decode(urldecode(give_draw_chart_image())); |
|
192 | + $image = str_replace(' ', '%20', $image); |
|
193 | + |
|
194 | + $pdf->SetX(25); |
|
195 | + $pdf->Image($image.'&file=.png'); |
|
196 | + $pdf->Ln(7); |
|
197 | + $pdf->Output(apply_filters('give_sales_earnings_pdf_export_filename', 'give-report-'.date_i18n('Y-m-d')).'.pdf', 'D'); |
|
198 | 198 | } |
199 | 199 | |
200 | -add_action( 'give_generate_pdf', 'give_generate_pdf' ); |
|
200 | +add_action('give_generate_pdf', 'give_generate_pdf'); |
|
201 | 201 | |
202 | 202 | /** |
203 | 203 | * Draws Chart for PDF Report. |
@@ -214,38 +214,38 @@ discard block |
||
214 | 214 | * @return string $chart->getUrl() URL for the Google Chart |
215 | 215 | */ |
216 | 216 | function give_draw_chart_image() { |
217 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/GoogleChart.php'; |
|
218 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
219 | - require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
217 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/GoogleChart.php'; |
|
218 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php'; |
|
219 | + require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php'; |
|
220 | 220 | |
221 | - $chart = new GoogleChart( 'lc', 900, 330 ); |
|
221 | + $chart = new GoogleChart('lc', 900, 330); |
|
222 | 222 | |
223 | 223 | $i = 1; |
224 | 224 | $earnings = ""; |
225 | 225 | $sales = ""; |
226 | 226 | |
227 | - while ( $i <= 12 ) : |
|
228 | - $earnings .= give_get_earnings_by_date( null, $i, date( 'Y' ) ) . ","; |
|
229 | - $sales .= give_get_sales_by_date( null, $i, date( 'Y' ) ) . ","; |
|
230 | - $i ++; |
|
227 | + while ($i <= 12) : |
|
228 | + $earnings .= give_get_earnings_by_date(null, $i, date('Y')).","; |
|
229 | + $sales .= give_get_sales_by_date(null, $i, date('Y')).","; |
|
230 | + $i++; |
|
231 | 231 | endwhile; |
232 | 232 | |
233 | - $earnings_array = explode( ",", $earnings ); |
|
234 | - $sales_array = explode( ",", $sales ); |
|
233 | + $earnings_array = explode(",", $earnings); |
|
234 | + $sales_array = explode(",", $sales); |
|
235 | 235 | |
236 | 236 | $i = 0; |
237 | - while ( $i <= 11 ) { |
|
238 | - if ( empty( $sales_array[ $i ] ) ) { |
|
239 | - $sales_array[ $i ] = 0; |
|
237 | + while ($i <= 11) { |
|
238 | + if (empty($sales_array[$i])) { |
|
239 | + $sales_array[$i] = 0; |
|
240 | 240 | } |
241 | - $i ++; |
|
241 | + $i++; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | $min_earnings = 0; |
245 | - $max_earnings = max( $earnings_array ); |
|
246 | - $earnings_scale = round( $max_earnings, - 1 ); |
|
245 | + $max_earnings = max($earnings_array); |
|
246 | + $earnings_scale = round($max_earnings, - 1); |
|
247 | 247 | |
248 | - $data = new GoogleChartData( array( |
|
248 | + $data = new GoogleChartData(array( |
|
249 | 249 | $earnings_array[0], |
250 | 250 | $earnings_array[1], |
251 | 251 | $earnings_array[2], |
@@ -258,25 +258,25 @@ discard block |
||
258 | 258 | $earnings_array[9], |
259 | 259 | $earnings_array[10], |
260 | 260 | $earnings_array[11] |
261 | - ) ); |
|
261 | + )); |
|
262 | 262 | |
263 | - $data->setLegend( __( 'Income', 'give' ) ); |
|
264 | - $data->setColor( '1b58a3' ); |
|
265 | - $chart->addData( $data ); |
|
263 | + $data->setLegend(__('Income', 'give')); |
|
264 | + $data->setColor('1b58a3'); |
|
265 | + $chart->addData($data); |
|
266 | 266 | |
267 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
268 | - $shape_marker->setColor( '000000' ); |
|
269 | - $shape_marker->setSize( 7 ); |
|
270 | - $shape_marker->setBorder( 2 ); |
|
271 | - $shape_marker->setData( $data ); |
|
272 | - $chart->addMarker( $shape_marker ); |
|
267 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
268 | + $shape_marker->setColor('000000'); |
|
269 | + $shape_marker->setSize(7); |
|
270 | + $shape_marker->setBorder(2); |
|
271 | + $shape_marker->setData($data); |
|
272 | + $chart->addMarker($shape_marker); |
|
273 | 273 | |
274 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
275 | - $value_marker->setColor( '000000' ); |
|
276 | - $value_marker->setData( $data ); |
|
277 | - $chart->addMarker( $value_marker ); |
|
274 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
275 | + $value_marker->setColor('000000'); |
|
276 | + $value_marker->setData($data); |
|
277 | + $chart->addMarker($value_marker); |
|
278 | 278 | |
279 | - $data = new GoogleChartData( array( |
|
279 | + $data = new GoogleChartData(array( |
|
280 | 280 | $sales_array[0], |
281 | 281 | $sales_array[1], |
282 | 282 | $sales_array[2], |
@@ -289,46 +289,46 @@ discard block |
||
289 | 289 | $sales_array[9], |
290 | 290 | $sales_array[10], |
291 | 291 | $sales_array[11] |
292 | - ) ); |
|
293 | - $data->setLegend( __( 'Donations', 'give' ) ); |
|
294 | - $data->setColor( 'ff6c1c' ); |
|
295 | - $chart->addData( $data ); |
|
296 | - |
|
297 | - $chart->setTitle( __( 'Donations by Month for all Give Forms', 'give' ), '336699', 18 ); |
|
298 | - |
|
299 | - $chart->setScale( 0, $max_earnings ); |
|
300 | - |
|
301 | - $y_axis = new GoogleChartAxis( 'y' ); |
|
302 | - $y_axis->setDrawTickMarks( true )->setLabels( array( 0, $max_earnings ) ); |
|
303 | - $chart->addAxis( $y_axis ); |
|
304 | - |
|
305 | - $x_axis = new GoogleChartAxis( 'x' ); |
|
306 | - $x_axis->setTickMarks( 5 ); |
|
307 | - $x_axis->setLabels( array( |
|
308 | - __( 'Jan', 'give' ), |
|
309 | - __( 'Feb', 'give' ), |
|
310 | - __( 'Mar', 'give' ), |
|
311 | - __( 'Apr', 'give' ), |
|
312 | - __( 'May', 'give' ), |
|
313 | - __( 'June', 'give' ), |
|
314 | - __( 'July', 'give' ), |
|
315 | - __( 'Aug', 'give' ), |
|
316 | - __( 'Sept', 'give' ), |
|
317 | - __( 'Oct', 'give' ), |
|
318 | - __( 'Nov', 'give' ), |
|
319 | - __( 'Dec', 'give' ) |
|
320 | - ) ); |
|
321 | - $chart->addAxis( $x_axis ); |
|
322 | - |
|
323 | - $shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE ); |
|
324 | - $shape_marker->setSize( 6 ); |
|
325 | - $shape_marker->setBorder( 2 ); |
|
326 | - $shape_marker->setData( $data ); |
|
327 | - $chart->addMarker( $shape_marker ); |
|
328 | - |
|
329 | - $value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE ); |
|
330 | - $value_marker->setData( $data ); |
|
331 | - $chart->addMarker( $value_marker ); |
|
292 | + )); |
|
293 | + $data->setLegend(__('Donations', 'give')); |
|
294 | + $data->setColor('ff6c1c'); |
|
295 | + $chart->addData($data); |
|
296 | + |
|
297 | + $chart->setTitle(__('Donations by Month for all Give Forms', 'give'), '336699', 18); |
|
298 | + |
|
299 | + $chart->setScale(0, $max_earnings); |
|
300 | + |
|
301 | + $y_axis = new GoogleChartAxis('y'); |
|
302 | + $y_axis->setDrawTickMarks(true)->setLabels(array(0, $max_earnings)); |
|
303 | + $chart->addAxis($y_axis); |
|
304 | + |
|
305 | + $x_axis = new GoogleChartAxis('x'); |
|
306 | + $x_axis->setTickMarks(5); |
|
307 | + $x_axis->setLabels(array( |
|
308 | + __('Jan', 'give'), |
|
309 | + __('Feb', 'give'), |
|
310 | + __('Mar', 'give'), |
|
311 | + __('Apr', 'give'), |
|
312 | + __('May', 'give'), |
|
313 | + __('June', 'give'), |
|
314 | + __('July', 'give'), |
|
315 | + __('Aug', 'give'), |
|
316 | + __('Sept', 'give'), |
|
317 | + __('Oct', 'give'), |
|
318 | + __('Nov', 'give'), |
|
319 | + __('Dec', 'give') |
|
320 | + )); |
|
321 | + $chart->addAxis($x_axis); |
|
322 | + |
|
323 | + $shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE); |
|
324 | + $shape_marker->setSize(6); |
|
325 | + $shape_marker->setBorder(2); |
|
326 | + $shape_marker->setData($data); |
|
327 | + $chart->addMarker($shape_marker); |
|
328 | + |
|
329 | + $value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE); |
|
330 | + $value_marker->setData($data); |
|
331 | + $chart->addMarker($value_marker); |
|
332 | 332 | |
333 | 333 | return $chart->getUrl(); |
334 | 334 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -41,20 +41,20 @@ discard block |
||
41 | 41 | public function csv_cols() { |
42 | 42 | |
43 | 43 | $cols = array( |
44 | - 'ID' => __( 'ID', 'give' ), |
|
45 | - 'post_name' => __( 'Slug', 'give' ), |
|
46 | - 'post_title' => __( 'Name', 'give' ), |
|
47 | - 'post_date' => __( 'Date Created', 'give' ), |
|
48 | - 'post_author' => __( 'Author', 'give' ), |
|
49 | - 'post_content' => __( 'Description', 'give' ), |
|
50 | - 'post_excerpt' => __( 'Excerpt', 'give' ), |
|
51 | - 'post_status' => __( 'Status', 'give' ), |
|
52 | - 'categories' => __( 'Categories', 'give' ), |
|
53 | - 'tags' => __( 'Tags', 'give' ), |
|
54 | - 'give_price' => __( 'Price', 'give' ), |
|
55 | - '_thumbnail_id' => __( 'Featured Image', 'give' ), |
|
56 | - '_give_form_sales' => __( 'Donations', 'give' ), |
|
57 | - '_give_download_earnings' => __( 'Income', 'give' ), |
|
44 | + 'ID' => __('ID', 'give'), |
|
45 | + 'post_name' => __('Slug', 'give'), |
|
46 | + 'post_title' => __('Name', 'give'), |
|
47 | + 'post_date' => __('Date Created', 'give'), |
|
48 | + 'post_author' => __('Author', 'give'), |
|
49 | + 'post_content' => __('Description', 'give'), |
|
50 | + 'post_excerpt' => __('Excerpt', 'give'), |
|
51 | + 'post_status' => __('Status', 'give'), |
|
52 | + 'categories' => __('Categories', 'give'), |
|
53 | + 'tags' => __('Tags', 'give'), |
|
54 | + 'give_price' => __('Price', 'give'), |
|
55 | + '_thumbnail_id' => __('Featured Image', 'give'), |
|
56 | + '_give_form_sales' => __('Donations', 'give'), |
|
57 | + '_give_download_earnings' => __('Income', 'give'), |
|
58 | 58 | ); |
59 | 59 | |
60 | 60 | return $cols; |
@@ -84,43 +84,43 @@ discard block |
||
84 | 84 | 'paged' => $this->step |
85 | 85 | ); |
86 | 86 | |
87 | - $forms = new WP_Query( $args ); |
|
87 | + $forms = new WP_Query($args); |
|
88 | 88 | |
89 | - if ( $forms->posts ) { |
|
90 | - foreach ( $forms->posts as $form ) { |
|
89 | + if ($forms->posts) { |
|
90 | + foreach ($forms->posts as $form) { |
|
91 | 91 | |
92 | 92 | $row = []; |
93 | 93 | |
94 | - foreach ( $this->csv_cols() as $key => $value ) { |
|
94 | + foreach ($this->csv_cols() as $key => $value) { |
|
95 | 95 | |
96 | 96 | // Setup default value/ |
97 | - $row[ $key ] = ''; |
|
97 | + $row[$key] = ''; |
|
98 | 98 | |
99 | - if ( in_array( $key, $meta ) ) { |
|
99 | + if (in_array($key, $meta)) { |
|
100 | 100 | |
101 | - switch ( $key ) { |
|
101 | + switch ($key) { |
|
102 | 102 | |
103 | 103 | case '_thumbnail_id' : |
104 | 104 | |
105 | - $image_id = get_post_thumbnail_id( $form->ID ); |
|
106 | - $row[ $key ] = wp_get_attachment_url( $image_id ); |
|
105 | + $image_id = get_post_thumbnail_id($form->ID); |
|
106 | + $row[$key] = wp_get_attachment_url($image_id); |
|
107 | 107 | |
108 | 108 | break; |
109 | 109 | |
110 | 110 | case 'give_price' : |
111 | 111 | |
112 | - if ( give_has_variable_prices( $form->ID ) ) { |
|
112 | + if (give_has_variable_prices($form->ID)) { |
|
113 | 113 | |
114 | 114 | $prices = []; |
115 | - foreach ( give_get_variable_prices( $form->ID ) as $price ) { |
|
116 | - $prices[] = $price['name'] . ': ' . $price['amount']; |
|
115 | + foreach (give_get_variable_prices($form->ID) as $price) { |
|
116 | + $prices[] = $price['name'].': '.$price['amount']; |
|
117 | 117 | } |
118 | 118 | |
119 | - $row[ $key ] = implode( ' | ', $prices ); |
|
119 | + $row[$key] = implode(' | ', $prices); |
|
120 | 120 | |
121 | 121 | } else { |
122 | 122 | |
123 | - $row[ $key ] = give_get_form_price( $form->ID ); |
|
123 | + $row[$key] = give_get_form_price($form->ID); |
|
124 | 124 | |
125 | 125 | } |
126 | 126 | |
@@ -128,44 +128,44 @@ discard block |
||
128 | 128 | |
129 | 129 | default : |
130 | 130 | |
131 | - $row[ $key ] = give_get_meta( $form->ID, $key, TRUE ); |
|
131 | + $row[$key] = give_get_meta($form->ID, $key, TRUE); |
|
132 | 132 | |
133 | 133 | break; |
134 | 134 | |
135 | 135 | } |
136 | 136 | |
137 | - } elseif ( isset( $form->$key ) ) { |
|
137 | + } elseif (isset($form->$key)) { |
|
138 | 138 | |
139 | - switch ( $key ) { |
|
139 | + switch ($key) { |
|
140 | 140 | |
141 | 141 | case 'post_author' : |
142 | 142 | |
143 | - $row[ $key ] = get_the_author_meta( 'user_login', $form->post_author ); |
|
143 | + $row[$key] = get_the_author_meta('user_login', $form->post_author); |
|
144 | 144 | |
145 | 145 | break; |
146 | 146 | |
147 | 147 | default : |
148 | 148 | |
149 | - $row[ $key ] = $form->$key; |
|
149 | + $row[$key] = $form->$key; |
|
150 | 150 | |
151 | 151 | break; |
152 | 152 | } |
153 | 153 | |
154 | - } elseif ( 'tags' == $key ) { |
|
154 | + } elseif ('tags' == $key) { |
|
155 | 155 | |
156 | - $terms = get_the_terms( $form->ID, 'form_tag' ); |
|
157 | - if ( $terms ) { |
|
158 | - $terms = wp_list_pluck( $terms, 'name' ); |
|
159 | - $row[ $key ] = implode( ' | ', $terms ); |
|
156 | + $terms = get_the_terms($form->ID, 'form_tag'); |
|
157 | + if ($terms) { |
|
158 | + $terms = wp_list_pluck($terms, 'name'); |
|
159 | + $row[$key] = implode(' | ', $terms); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
163 | - } elseif ( 'categories' == $key ) { |
|
163 | + } elseif ('categories' == $key) { |
|
164 | 164 | |
165 | - $terms = get_the_terms( $form->ID, 'form_category' ); |
|
166 | - if ( $terms ) { |
|
167 | - $terms = wp_list_pluck( $terms, 'name' ); |
|
168 | - $row[ $key ] = implode( ' | ', $terms ); |
|
165 | + $terms = get_the_terms($form->ID, 'form_category'); |
|
166 | + if ($terms) { |
|
167 | + $terms = wp_list_pluck($terms, 'name'); |
|
168 | + $row[$key] = implode(' | ', $terms); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | } |
@@ -176,8 +176,8 @@ discard block |
||
176 | 176 | |
177 | 177 | } |
178 | 178 | |
179 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
180 | - $data = apply_filters( "give_export_get_data_{$this->export_type}", $data ); |
|
179 | + $data = apply_filters('give_export_get_data', $data); |
|
180 | + $data = apply_filters("give_export_get_data_{$this->export_type}", $data); |
|
181 | 181 | |
182 | 182 | return $data; |
183 | 183 | |
@@ -197,20 +197,20 @@ discard block |
||
197 | 197 | |
198 | 198 | $args = array( |
199 | 199 | 'post_type' => 'give_forms', |
200 | - 'posts_per_page' => - 1, |
|
200 | + 'posts_per_page' => -1, |
|
201 | 201 | 'post_status' => 'any', |
202 | 202 | 'fields' => 'ids', |
203 | 203 | ); |
204 | 204 | |
205 | - $forms = new WP_Query( $args ); |
|
205 | + $forms = new WP_Query($args); |
|
206 | 206 | $total = (int) $forms->post_count; |
207 | 207 | $percentage = 100; |
208 | 208 | |
209 | - if ( $total > 0 ) { |
|
210 | - $percentage = ( ( 30 * $this->step ) / $total ) * 100; |
|
209 | + if ($total > 0) { |
|
210 | + $percentage = ((30 * $this->step) / $total) * 100; |
|
211 | 211 | } |
212 | 212 | |
213 | - if ( $percentage > 100 ) { |
|
213 | + if ($percentage > 100) { |
|
214 | 214 | $percentage = 100; |
215 | 215 | } |
216 | 216 |
@@ -216,7 +216,6 @@ |
||
216 | 216 | /** |
217 | 217 | * Set Donation Amount for Multi Level Donation Forms |
218 | 218 | * |
219 | - * @param int $form_id |
|
220 | 219 | * @param object $form |
221 | 220 | * |
222 | 221 | * @since 1.8.9 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_get_actions() { |
27 | 27 | |
28 | - $_get_action = ! empty( $_GET['give_action'] ) ? $_GET['give_action'] : null; |
|
28 | + $_get_action = ! empty($_GET['give_action']) ? $_GET['give_action'] : null; |
|
29 | 29 | |
30 | 30 | // Add backward compatibility to give-action param ( $_GET ) |
31 | - if( empty( $_get_action ) ) { |
|
32 | - $_get_action = ! empty( $_GET['give-action'] ) ? $_GET['give-action'] : null; |
|
31 | + if (empty($_get_action)) { |
|
32 | + $_get_action = ! empty($_GET['give-action']) ? $_GET['give-action'] : null; |
|
33 | 33 | } |
34 | 34 | |
35 | - if ( isset( $_get_action ) ) { |
|
35 | + if (isset($_get_action)) { |
|
36 | 36 | /** |
37 | 37 | * Fires in WordPress init or admin init, when give_action is present in $_GET. |
38 | 38 | * |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @param array $_GET Array of HTTP GET variables. |
42 | 42 | */ |
43 | - do_action( "give_{$_get_action}", $_GET ); |
|
43 | + do_action("give_{$_get_action}", $_GET); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | } |
47 | 47 | |
48 | -add_action( 'init', 'give_get_actions' ); |
|
48 | +add_action('init', 'give_get_actions'); |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Hooks Give actions, when present in the $_POST super global. Every give_action |
@@ -58,15 +58,15 @@ discard block |
||
58 | 58 | */ |
59 | 59 | function give_post_actions() { |
60 | 60 | |
61 | - $_post_action = ! empty( $_POST['give_action'] ) ? $_POST['give_action'] : null; |
|
61 | + $_post_action = ! empty($_POST['give_action']) ? $_POST['give_action'] : null; |
|
62 | 62 | |
63 | 63 | |
64 | 64 | // Add backward compatibility to give-action param ( $_POST ). |
65 | - if( empty( $_post_action ) ) { |
|
66 | - $_post_action = ! empty( $_POST['give-action'] ) ? $_POST['give-action'] : null; |
|
65 | + if (empty($_post_action)) { |
|
66 | + $_post_action = ! empty($_POST['give-action']) ? $_POST['give-action'] : null; |
|
67 | 67 | } |
68 | 68 | |
69 | - if ( isset( $_post_action ) ) { |
|
69 | + if (isset($_post_action)) { |
|
70 | 70 | /** |
71 | 71 | * Fires in WordPress init or admin init, when give_action is present in $_POST. |
72 | 72 | * |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @param array $_POST Array of HTTP POST variables. |
76 | 76 | */ |
77 | - do_action( "give_{$_post_action}", $_POST ); |
|
77 | + do_action("give_{$_post_action}", $_POST); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | } |
81 | 81 | |
82 | -add_action( 'init', 'give_post_actions' ); |
|
82 | +add_action('init', 'give_post_actions'); |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Connect WordPress user with Donor. |
@@ -89,28 +89,28 @@ discard block |
||
89 | 89 | * @param array $user_data User Data |
90 | 90 | * @return void |
91 | 91 | */ |
92 | -function give_connect_donor_to_wpuser( $user_id, $user_data ){ |
|
92 | +function give_connect_donor_to_wpuser($user_id, $user_data) { |
|
93 | 93 | /* @var Give_Donor $donor */ |
94 | - $donor = new Give_Donor( $user_data['user_email'] ); |
|
94 | + $donor = new Give_Donor($user_data['user_email']); |
|
95 | 95 | |
96 | 96 | // Validate donor id and check if do nor is already connect to wp user or not. |
97 | - if( $donor->id && ! $donor->user_id ) { |
|
97 | + if ($donor->id && ! $donor->user_id) { |
|
98 | 98 | |
99 | 99 | // Update donor user_id. |
100 | - if( $donor->update( array( 'user_id' => $user_id ) ) ) { |
|
101 | - $donor_note = sprintf( esc_html__( 'WordPress user #%d is connected to #%d', 'give' ), $user_id, $donor->id ); |
|
102 | - $donor->add_note( $donor_note ); |
|
100 | + if ($donor->update(array('user_id' => $user_id))) { |
|
101 | + $donor_note = sprintf(esc_html__('WordPress user #%d is connected to #%d', 'give'), $user_id, $donor->id); |
|
102 | + $donor->add_note($donor_note); |
|
103 | 103 | |
104 | 104 | // Update user_id meta in payments. |
105 | - if( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) { |
|
106 | - foreach ( $donations as $donation ) { |
|
107 | - give_update_meta( $donation, '_give_payment_user_id', $user_id ); |
|
105 | + if ( ! empty($donor->payment_ids) && ($donations = explode(',', $donor->payment_ids))) { |
|
106 | + foreach ($donations as $donation) { |
|
107 | + give_update_meta($donation, '_give_payment_user_id', $user_id); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | } |
111 | 111 | } |
112 | 112 | } |
113 | -add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 ); |
|
113 | +add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2); |
|
114 | 114 | |
115 | 115 | |
116 | 116 | /** |
@@ -124,24 +124,24 @@ discard block |
||
124 | 124 | function give_validate_license_when_site_migrated() { |
125 | 125 | // Store current site address if not already stored. |
126 | 126 | $homeurl = home_url(); |
127 | - if( ! get_option( 'give_site_address_before_migrate' ) ) { |
|
127 | + if ( ! get_option('give_site_address_before_migrate')) { |
|
128 | 128 | // Update site address. |
129 | - update_option( 'give_site_address_before_migrate', $homeurl ); |
|
129 | + update_option('give_site_address_before_migrate', $homeurl); |
|
130 | 130 | |
131 | 131 | return; |
132 | 132 | } |
133 | 133 | |
134 | - if( $homeurl !== get_option( 'give_site_address_before_migrate' ) ) { |
|
134 | + if ($homeurl !== get_option('give_site_address_before_migrate')) { |
|
135 | 135 | // Immediately run cron. |
136 | - wp_schedule_single_event( time() , 'give_validate_license_when_site_migrated' ); |
|
136 | + wp_schedule_single_event(time(), 'give_validate_license_when_site_migrated'); |
|
137 | 137 | |
138 | 138 | // Update site address. |
139 | - update_option( 'give_site_address_before_migrate', home_url() ); |
|
139 | + update_option('give_site_address_before_migrate', home_url()); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | } |
143 | -add_action( 'init', 'give_validate_license_when_site_migrated' ); |
|
144 | -add_action( 'admin_init', 'give_validate_license_when_site_migrated' ); |
|
143 | +add_action('init', 'give_validate_license_when_site_migrated'); |
|
144 | +add_action('admin_init', 'give_validate_license_when_site_migrated'); |
|
145 | 145 | |
146 | 146 | |
147 | 147 | /** |
@@ -150,18 +150,18 @@ discard block |
||
150 | 150 | * @since 1.8 |
151 | 151 | * @param $data |
152 | 152 | */ |
153 | -function give_donor_batch_export_complete( $data ) { |
|
153 | +function give_donor_batch_export_complete($data) { |
|
154 | 154 | // Remove donor ids cache. |
155 | - if( |
|
156 | - isset( $data['class'] ) |
|
155 | + if ( |
|
156 | + isset($data['class']) |
|
157 | 157 | && 'Give_Batch_Donors_Export' === $data['class'] |
158 | - && ! empty( $data['forms'] ) |
|
159 | - && isset( $data['give_export_option']['query_id'] ) |
|
158 | + && ! empty($data['forms']) |
|
159 | + && isset($data['give_export_option']['query_id']) |
|
160 | 160 | ) { |
161 | - Give_Cache::delete( Give_Cache::get_key( $data['give_export_option']['query_id'] ) ); |
|
161 | + Give_Cache::delete(Give_Cache::get_key($data['give_export_option']['query_id'])); |
|
162 | 162 | } |
163 | 163 | } |
164 | -add_action('give_file_export_complete', 'give_donor_batch_export_complete' ); |
|
164 | +add_action('give_file_export_complete', 'give_donor_batch_export_complete'); |
|
165 | 165 | |
166 | 166 | /** |
167 | 167 | * Print css for wordpress setting pages. |
@@ -172,12 +172,12 @@ discard block |
||
172 | 172 | /* @var WP_Screen $screen */ |
173 | 173 | $screen = get_current_screen(); |
174 | 174 | |
175 | - if( ! ( $screen instanceof WP_Screen ) ) { |
|
175 | + if ( ! ($screen instanceof WP_Screen)) { |
|
176 | 176 | return false; |
177 | 177 | } |
178 | 178 | |
179 | - switch ( true ) { |
|
180 | - case ( 'plugins' === $screen->base || 'plugins-network' === $screen->base ): |
|
179 | + switch (true) { |
|
180 | + case ('plugins' === $screen->base || 'plugins-network' === $screen->base): |
|
181 | 181 | ?> |
182 | 182 | <style> |
183 | 183 | tr.active.update + tr.give-addon-notice-tr td{ |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | <?php |
211 | 211 | } |
212 | 212 | } |
213 | -add_action( 'admin_head', 'give_admin_quick_css' ); |
|
213 | +add_action('admin_head', 'give_admin_quick_css'); |
|
214 | 214 | |
215 | 215 | |
216 | 216 | /** |
@@ -223,28 +223,28 @@ discard block |
||
223 | 223 | * |
224 | 224 | * @return void |
225 | 225 | */ |
226 | -function give_set_donation_levels_max_min_amount( $form_id ) { |
|
226 | +function give_set_donation_levels_max_min_amount($form_id) { |
|
227 | 227 | if ( |
228 | - ( 'set' === $_POST['_give_price_option'] ) || |
|
229 | - ( in_array( '_give_donation_levels', $_POST ) && count( $_POST['_give_donation_levels'] ) <= 0 ) || |
|
230 | - ! ( $donation_levels_amounts = wp_list_pluck( $_POST['_give_donation_levels'], '_give_amount' ) ) |
|
228 | + ('set' === $_POST['_give_price_option']) || |
|
229 | + (in_array('_give_donation_levels', $_POST) && count($_POST['_give_donation_levels']) <= 0) || |
|
230 | + ! ($donation_levels_amounts = wp_list_pluck($_POST['_give_donation_levels'], '_give_amount')) |
|
231 | 231 | ) { |
232 | 232 | // Delete old meta. |
233 | - give_delete_meta( $form_id, '_give_levels_minimum_amount' ); |
|
234 | - give_delete_meta( $form_id, '_give_levels_maximum_amount' ); |
|
233 | + give_delete_meta($form_id, '_give_levels_minimum_amount'); |
|
234 | + give_delete_meta($form_id, '_give_levels_maximum_amount'); |
|
235 | 235 | |
236 | 236 | return; |
237 | 237 | } |
238 | 238 | |
239 | 239 | // Sanitize donation level amounts. |
240 | - $donation_levels_amounts = array_map( 'give_maybe_sanitize_amount', $donation_levels_amounts ); |
|
240 | + $donation_levels_amounts = array_map('give_maybe_sanitize_amount', $donation_levels_amounts); |
|
241 | 241 | |
242 | - $min_amount = min( $donation_levels_amounts ); |
|
243 | - $max_amount = max( $donation_levels_amounts ); |
|
242 | + $min_amount = min($donation_levels_amounts); |
|
243 | + $max_amount = max($donation_levels_amounts); |
|
244 | 244 | |
245 | 245 | // Set Minimum and Maximum amount for Multi Level Donation Forms |
246 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db( $min_amount ) : 0 ); |
|
247 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount? give_sanitize_amount_for_db( $max_amount ) : 0 ); |
|
246 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db($min_amount) : 0); |
|
247 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db($max_amount) : 0); |
|
248 | 248 | } |
249 | 249 | |
250 | -add_action( 'give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30 ); |
|
251 | 250 | \ No newline at end of file |
251 | +add_action('give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30); |
|
252 | 252 | \ No newline at end of file |
@@ -253,7 +253,7 @@ |
||
253 | 253 | * |
254 | 254 | * @access public |
255 | 255 | * @since 1.0 |
256 | - * @return mixed string If search is present, false otherwise. |
|
256 | + * @return string|false string If search is present, false otherwise. |
|
257 | 257 | */ |
258 | 258 | public function get_search() { |
259 | 259 | return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
19 | 19 | // Load WP_List_Table if not loaded |
20 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
21 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
20 | +if ( ! class_exists('WP_List_Table')) { |
|
21 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | public function __construct() { |
62 | 62 | |
63 | 63 | // Set parent defaults |
64 | - parent::__construct( array( |
|
65 | - 'singular' => __( 'Donor', 'give' ), // Singular name of the listed records. |
|
66 | - 'plural' => __( 'Donors', 'give' ), // Plural name of the listed records. |
|
67 | - 'ajax' => false,// Does this table support ajax?. |
|
68 | - ) ); |
|
64 | + parent::__construct(array( |
|
65 | + 'singular' => __('Donor', 'give'), // Singular name of the listed records. |
|
66 | + 'plural' => __('Donors', 'give'), // Plural name of the listed records. |
|
67 | + 'ajax' => false, // Does this table support ajax?. |
|
68 | + )); |
|
69 | 69 | |
70 | 70 | } |
71 | 71 | |
@@ -80,22 +80,22 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return void |
82 | 82 | */ |
83 | - public function search_box( $text, $input_id ) { |
|
84 | - $input_id = $input_id . '-search-input'; |
|
83 | + public function search_box($text, $input_id) { |
|
84 | + $input_id = $input_id.'-search-input'; |
|
85 | 85 | |
86 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
87 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
86 | + if ( ! empty($_REQUEST['orderby'])) { |
|
87 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
88 | 88 | } |
89 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
90 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
89 | + if ( ! empty($_REQUEST['order'])) { |
|
90 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
91 | 91 | } |
92 | 92 | ?> |
93 | 93 | <p class="search-box" role="search"> |
94 | 94 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
95 | 95 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/> |
96 | - <?php submit_button( $text, 'button', false, false, array( |
|
96 | + <?php submit_button($text, 'button', false, false, array( |
|
97 | 97 | 'ID' => 'search-submit', |
98 | - ) ); ?> |
|
98 | + )); ?> |
|
99 | 99 | </p> |
100 | 100 | <?php |
101 | 101 | } |
@@ -111,27 +111,27 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return string Column Name. |
113 | 113 | */ |
114 | - public function column_default( $donor, $column_name ) { |
|
115 | - switch ( $column_name ) { |
|
114 | + public function column_default($donor, $column_name) { |
|
115 | + switch ($column_name) { |
|
116 | 116 | |
117 | 117 | case 'num_donations' : |
118 | - $value = '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . urlencode( $donor['id'] ) ) . '&status=publish' . ' ">' . esc_html( $donor['num_donations'] ) . '</a>'; |
|
118 | + $value = '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.urlencode($donor['id'])).'&status=publish'.' ">'.esc_html($donor['num_donations']).'</a>'; |
|
119 | 119 | break; |
120 | 120 | |
121 | 121 | case 'amount_spent' : |
122 | - $value = give_currency_filter( give_format_amount( $donor[ $column_name ], array( 'sanitize' => false ) ) ); |
|
122 | + $value = give_currency_filter(give_format_amount($donor[$column_name], array('sanitize' => false))); |
|
123 | 123 | break; |
124 | 124 | |
125 | 125 | case 'date_created' : |
126 | - $value = date_i18n( give_date_format(), strtotime( $donor['date_created'] ) ); |
|
126 | + $value = date_i18n(give_date_format(), strtotime($donor['date_created'])); |
|
127 | 127 | break; |
128 | 128 | |
129 | 129 | default: |
130 | - $value = isset( $donor[ $column_name ] ) ? $donor[ $column_name ] : null; |
|
130 | + $value = isset($donor[$column_name]) ? $donor[$column_name] : null; |
|
131 | 131 | break; |
132 | 132 | } |
133 | 133 | |
134 | - return apply_filters( "give_report_column_{$column_name}", $value, $donor['id'] ); |
|
134 | + return apply_filters("give_report_column_{$column_name}", $value, $donor['id']); |
|
135 | 135 | |
136 | 136 | } |
137 | 137 | |
@@ -142,13 +142,13 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @return string |
144 | 144 | */ |
145 | - public function column_name( $donor ) { |
|
146 | - $name = '#' . $donor['id'] . ' '; |
|
147 | - $name .= ! empty( $donor['name'] ) ? $donor['name'] : '<em>' . esc_html__( 'Unnamed Donor', 'give' ) . '</em>'; |
|
148 | - $view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ); |
|
149 | - $actions = $this->get_row_actions( $donor ); |
|
145 | + public function column_name($donor) { |
|
146 | + $name = '#'.$donor['id'].' '; |
|
147 | + $name .= ! empty($donor['name']) ? $donor['name'] : '<em>'.esc_html__('Unnamed Donor', 'give').'</em>'; |
|
148 | + $view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']); |
|
149 | + $actions = $this->get_row_actions($donor); |
|
150 | 150 | |
151 | - return '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>' . $this->row_actions( $actions ); |
|
151 | + return '<a href="'.esc_url($view_url).'">'.$name.'</a>'.$this->row_actions($actions); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -160,14 +160,14 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function get_columns() { |
162 | 162 | $columns = array( |
163 | - 'name' => __( 'Name', 'give' ), |
|
164 | - 'email' => __( 'Email', 'give' ), |
|
165 | - 'num_donations' => __( 'Donations', 'give' ), |
|
166 | - 'amount_spent' => __( 'Total Donated', 'give' ), |
|
167 | - 'date_created' => __( 'Date Created', 'give' ), |
|
163 | + 'name' => __('Name', 'give'), |
|
164 | + 'email' => __('Email', 'give'), |
|
165 | + 'num_donations' => __('Donations', 'give'), |
|
166 | + 'amount_spent' => __('Total Donated', 'give'), |
|
167 | + 'date_created' => __('Date Created', 'give'), |
|
168 | 168 | ); |
169 | 169 | |
170 | - return apply_filters( 'give_list_donors_columns', $columns ); |
|
170 | + return apply_filters('give_list_donors_columns', $columns); |
|
171 | 171 | |
172 | 172 | } |
173 | 173 | |
@@ -181,13 +181,13 @@ discard block |
||
181 | 181 | public function get_sortable_columns() { |
182 | 182 | |
183 | 183 | $columns = array( |
184 | - 'date_created' => array( 'date_created', true ), |
|
185 | - 'name' => array( 'name', true ), |
|
186 | - 'num_donations' => array( 'purchase_count', false ), |
|
187 | - 'amount_spent' => array( 'purchase_value', false ), |
|
184 | + 'date_created' => array('date_created', true), |
|
185 | + 'name' => array('name', true), |
|
186 | + 'num_donations' => array('purchase_count', false), |
|
187 | + 'amount_spent' => array('purchase_value', false), |
|
188 | 188 | ); |
189 | 189 | |
190 | - return apply_filters( 'give_list_donors_sortable_columns', $columns ); |
|
190 | + return apply_filters('give_list_donors_sortable_columns', $columns); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -200,19 +200,19 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return array An array of action links. |
202 | 202 | */ |
203 | - public function get_row_actions( $donor ) { |
|
203 | + public function get_row_actions($donor) { |
|
204 | 204 | |
205 | 205 | $actions = array( |
206 | 206 | |
207 | - 'view' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ), sprintf( esc_attr__( 'View "%s"', 'give' ), $donor['name'] ), __( 'View Donor', 'give' ) ), |
|
207 | + 'view' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']), sprintf(esc_attr__('View "%s"', 'give'), $donor['name']), __('View Donor', 'give')), |
|
208 | 208 | |
209 | - 'notes' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor['id'] ), sprintf( esc_attr__( 'Notes for "%s"', 'give' ), $donor['name'] ), __( 'Notes', 'give' ) ), |
|
209 | + 'notes' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor['id']), sprintf(esc_attr__('Notes for "%s"', 'give'), $donor['name']), __('Notes', 'give')), |
|
210 | 210 | |
211 | - 'delete' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor['id'] ), sprintf( esc_attr__( 'Delete "%s"', 'give' ), $donor['name'] ), __( 'Delete', 'give' ) ), |
|
211 | + 'delete' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor['id']), sprintf(esc_attr__('Delete "%s"', 'give'), $donor['name']), __('Delete', 'give')), |
|
212 | 212 | |
213 | 213 | ); |
214 | 214 | |
215 | - return apply_filters( 'give_donor_row_actions', $actions, $donor ); |
|
215 | + return apply_filters('give_donor_row_actions', $actions, $donor); |
|
216 | 216 | |
217 | 217 | } |
218 | 218 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * @since 1.0 |
227 | 227 | * @return void |
228 | 228 | */ |
229 | - public function bulk_actions( $which = '' ) { |
|
229 | + public function bulk_actions($which = '') { |
|
230 | 230 | // These aren't really bulk actions but this outputs the markup in the right place. |
231 | 231 | } |
232 | 232 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * @return int Current page number. |
239 | 239 | */ |
240 | 240 | public function get_paged() { |
241 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
241 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @return mixed string If search is present, false otherwise. |
250 | 250 | */ |
251 | 251 | public function get_search() { |
252 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
252 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -266,13 +266,13 @@ discard block |
||
266 | 266 | |
267 | 267 | // Get donor query. |
268 | 268 | $args = $this->get_donor_query(); |
269 | - $donors = Give()->donors->get_donors( $args ); |
|
269 | + $donors = Give()->donors->get_donors($args); |
|
270 | 270 | |
271 | - if ( $donors ) { |
|
271 | + if ($donors) { |
|
272 | 272 | |
273 | - foreach ( $donors as $donor ) { |
|
273 | + foreach ($donors as $donor) { |
|
274 | 274 | |
275 | - $user_id = ! empty( $donor->user_id ) ? intval( $donor->user_id ) : 0; |
|
275 | + $user_id = ! empty($donor->user_id) ? intval($donor->user_id) : 0; |
|
276 | 276 | |
277 | 277 | $data[] = array( |
278 | 278 | 'id' => $donor->id, |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | } |
287 | 287 | } |
288 | 288 | |
289 | - return apply_filters( 'give_donors_column_query_data', $data ); |
|
289 | + return apply_filters('give_donors_column_query_data', $data); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | |
302 | 302 | $_donor_query['number'] = - 1; |
303 | 303 | $_donor_query['offset'] = 0; |
304 | - $donors = Give()->donors->get_donors( $_donor_query ); |
|
304 | + $donors = Give()->donors->get_donors($_donor_query); |
|
305 | 305 | |
306 | - return count( $donors ); |
|
306 | + return count($donors); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -315,10 +315,10 @@ discard block |
||
315 | 315 | */ |
316 | 316 | public function get_donor_query() { |
317 | 317 | $paged = $this->get_paged(); |
318 | - $offset = $this->per_page * ( $paged - 1 ); |
|
318 | + $offset = $this->per_page * ($paged - 1); |
|
319 | 319 | $search = $this->get_search(); |
320 | - $order = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC'; |
|
321 | - $orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id'; |
|
320 | + $order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC'; |
|
321 | + $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id'; |
|
322 | 322 | |
323 | 323 | $args = array( |
324 | 324 | 'number' => $this->per_page, |
@@ -327,10 +327,10 @@ discard block |
||
327 | 327 | 'orderby' => $orderby, |
328 | 328 | ); |
329 | 329 | |
330 | - if ( $search ) { |
|
331 | - if ( is_email( $search ) ) { |
|
330 | + if ($search) { |
|
331 | + if (is_email($search)) { |
|
332 | 332 | $args['email'] = $search; |
333 | - } elseif ( is_numeric( $search ) ) { |
|
333 | + } elseif (is_numeric($search)) { |
|
334 | 334 | $args['id'] = $search; |
335 | 335 | } else { |
336 | 336 | $args['name'] = $search; |
@@ -353,16 +353,16 @@ discard block |
||
353 | 353 | $hidden = array(); // No hidden columns. |
354 | 354 | $sortable = $this->get_sortable_columns(); |
355 | 355 | |
356 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
356 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
357 | 357 | |
358 | 358 | $this->items = $this->donor_data(); |
359 | 359 | |
360 | 360 | $this->total = $this->get_donor_count(); |
361 | 361 | |
362 | - $this->set_pagination_args( array( |
|
362 | + $this->set_pagination_args(array( |
|
363 | 363 | 'total_items' => $this->total, |
364 | 364 | 'per_page' => $this->per_page, |
365 | - 'total_pages' => ceil( $this->total / $this->per_page ), |
|
366 | - ) ); |
|
365 | + 'total_pages' => ceil($this->total / $this->per_page), |
|
366 | + )); |
|
367 | 367 | } |
368 | 368 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @param array $args The $_POST array being passed. |
274 | 274 | * |
275 | - * @return int Whether it was a successful deletion. |
|
275 | + * @return false|null Whether it was a successful deletion. |
|
276 | 276 | */ |
277 | 277 | function give_donor_delete( $args ) { |
278 | 278 | |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | * Remove an email address to the donor from within the admin and log a donor note and redirect back to the donor interface for feedback. |
547 | 547 | * |
548 | 548 | * @since 1.7 |
549 | - * @return bool|null |
|
549 | + * @return false|null |
|
550 | 550 | */ |
551 | 551 | function give_remove_donor_email() { |
552 | 552 | if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | * and redirect back to the donor interface for feedback |
590 | 590 | * |
591 | 591 | * @since 1.7 |
592 | - * @return bool|null |
|
592 | + * @return false|null |
|
593 | 593 | */ |
594 | 594 | function give_set_donor_primary_email() { |
595 | 595 | if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,17 +23,17 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return array|bool $output Response messages |
25 | 25 | */ |
26 | -function give_edit_donor( $args ) { |
|
26 | +function give_edit_donor($args) { |
|
27 | 27 | |
28 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
28 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
29 | 29 | |
30 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
31 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array( |
|
30 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
31 | + wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array( |
|
32 | 32 | 'response' => 403, |
33 | - ) ); |
|
33 | + )); |
|
34 | 34 | } |
35 | 35 | |
36 | - if ( empty( $args ) ) { |
|
36 | + if (empty($args)) { |
|
37 | 37 | return false; |
38 | 38 | } |
39 | 39 | |
@@ -41,15 +41,15 @@ discard block |
||
41 | 41 | $donor_id = (int) $args['customerinfo']['id']; |
42 | 42 | $nonce = $args['_wpnonce']; |
43 | 43 | |
44 | - if ( ! wp_verify_nonce( $nonce, 'edit-donor' ) ) { |
|
45 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
44 | + if ( ! wp_verify_nonce($nonce, 'edit-donor')) { |
|
45 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
46 | 46 | 'response' => 400, |
47 | - ) ); |
|
47 | + )); |
|
48 | 48 | } |
49 | 49 | |
50 | - $donor = new Give_Donor( $donor_id ); |
|
50 | + $donor = new Give_Donor($donor_id); |
|
51 | 51 | |
52 | - if ( empty( $donor->id ) ) { |
|
52 | + if (empty($donor->id)) { |
|
53 | 53 | return false; |
54 | 54 | } |
55 | 55 | |
@@ -58,70 +58,70 @@ discard block |
||
58 | 58 | 'user_id' => 0, |
59 | 59 | ); |
60 | 60 | |
61 | - $donor_info = wp_parse_args( $donor_info, $defaults ); |
|
61 | + $donor_info = wp_parse_args($donor_info, $defaults); |
|
62 | 62 | |
63 | - if ( (int) $donor_info['user_id'] !== (int) $donor->user_id ) { |
|
63 | + if ((int) $donor_info['user_id'] !== (int) $donor->user_id) { |
|
64 | 64 | |
65 | 65 | // Make sure we don't already have this user attached to a donor. |
66 | - if ( ! empty( $donor_info['user_id'] ) && false !== Give()->donors->get_donor_by( 'user_id', $donor_info['user_id'] ) ) { |
|
67 | - give_set_error( 'give-invalid-donor-user_id', sprintf( __( 'The User ID #%d is already associated with a different donor.', 'give' ), $donor_info['user_id'] ) ); |
|
66 | + if ( ! empty($donor_info['user_id']) && false !== Give()->donors->get_donor_by('user_id', $donor_info['user_id'])) { |
|
67 | + give_set_error('give-invalid-donor-user_id', sprintf(__('The User ID #%d is already associated with a different donor.', 'give'), $donor_info['user_id'])); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | // Make sure it's actually a user. |
71 | - $user = get_user_by( 'id', $donor_info['user_id'] ); |
|
72 | - if ( ! empty( $donor_info['user_id'] ) && false === $user ) { |
|
73 | - give_set_error( 'give-invalid-user_id', sprintf( __( 'The User ID #%d does not exist. Please assign an existing user.', 'give' ), $donor_info['user_id'] ) ); |
|
71 | + $user = get_user_by('id', $donor_info['user_id']); |
|
72 | + if ( ! empty($donor_info['user_id']) && false === $user) { |
|
73 | + give_set_error('give-invalid-user_id', sprintf(__('The User ID #%d does not exist. Please assign an existing user.', 'give'), $donor_info['user_id'])); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | 77 | // Record this for later. |
78 | 78 | $previous_user_id = $donor->user_id; |
79 | 79 | |
80 | - if ( give_get_errors() ) { |
|
80 | + if (give_get_errors()) { |
|
81 | 81 | return false; |
82 | 82 | } |
83 | 83 | |
84 | 84 | // Setup the donor address, if present. |
85 | 85 | $address = array(); |
86 | - if ( intval( $donor_info['user_id'] ) > 0 ) { |
|
86 | + if (intval($donor_info['user_id']) > 0) { |
|
87 | 87 | |
88 | - $current_address = get_user_meta( $donor_info['user_id'], '_give_user_address', true ); |
|
88 | + $current_address = get_user_meta($donor_info['user_id'], '_give_user_address', true); |
|
89 | 89 | |
90 | - if ( false === $current_address ) { |
|
91 | - $address['line1'] = isset( $donor_info['line1'] ) ? $donor_info['line1'] : ''; |
|
92 | - $address['line2'] = isset( $donor_info['line2'] ) ? $donor_info['line2'] : ''; |
|
93 | - $address['city'] = isset( $donor_info['city'] ) ? $donor_info['city'] : ''; |
|
94 | - $address['country'] = isset( $donor_info['country'] ) ? $donor_info['country'] : ''; |
|
95 | - $address['zip'] = isset( $donor_info['zip'] ) ? $donor_info['zip'] : ''; |
|
96 | - $address['state'] = isset( $donor_info['state'] ) ? $donor_info['state'] : ''; |
|
90 | + if (false === $current_address) { |
|
91 | + $address['line1'] = isset($donor_info['line1']) ? $donor_info['line1'] : ''; |
|
92 | + $address['line2'] = isset($donor_info['line2']) ? $donor_info['line2'] : ''; |
|
93 | + $address['city'] = isset($donor_info['city']) ? $donor_info['city'] : ''; |
|
94 | + $address['country'] = isset($donor_info['country']) ? $donor_info['country'] : ''; |
|
95 | + $address['zip'] = isset($donor_info['zip']) ? $donor_info['zip'] : ''; |
|
96 | + $address['state'] = isset($donor_info['state']) ? $donor_info['state'] : ''; |
|
97 | 97 | } else { |
98 | - $current_address = wp_parse_args( $current_address, array( |
|
98 | + $current_address = wp_parse_args($current_address, array( |
|
99 | 99 | 'line1', |
100 | 100 | 'line2', |
101 | 101 | 'city', |
102 | 102 | 'zip', |
103 | 103 | 'state', |
104 | 104 | 'country', |
105 | - ) ); |
|
106 | - $address['line1'] = isset( $donor_info['line1'] ) ? $donor_info['line1'] : $current_address['line1']; |
|
107 | - $address['line2'] = isset( $donor_info['line2'] ) ? $donor_info['line2'] : $current_address['line2']; |
|
108 | - $address['city'] = isset( $donor_info['city'] ) ? $donor_info['city'] : $current_address['city']; |
|
109 | - $address['country'] = isset( $donor_info['country'] ) ? $donor_info['country'] : $current_address['country']; |
|
110 | - $address['zip'] = isset( $donor_info['zip'] ) ? $donor_info['zip'] : $current_address['zip']; |
|
111 | - $address['state'] = isset( $donor_info['state'] ) ? $donor_info['state'] : $current_address['state']; |
|
105 | + )); |
|
106 | + $address['line1'] = isset($donor_info['line1']) ? $donor_info['line1'] : $current_address['line1']; |
|
107 | + $address['line2'] = isset($donor_info['line2']) ? $donor_info['line2'] : $current_address['line2']; |
|
108 | + $address['city'] = isset($donor_info['city']) ? $donor_info['city'] : $current_address['city']; |
|
109 | + $address['country'] = isset($donor_info['country']) ? $donor_info['country'] : $current_address['country']; |
|
110 | + $address['zip'] = isset($donor_info['zip']) ? $donor_info['zip'] : $current_address['zip']; |
|
111 | + $address['state'] = isset($donor_info['state']) ? $donor_info['state'] : $current_address['state']; |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | 115 | // Sanitize the inputs |
116 | 116 | $donor_data = array(); |
117 | - $donor_data['name'] = strip_tags( stripslashes( $donor_info['name'] ) ); |
|
117 | + $donor_data['name'] = strip_tags(stripslashes($donor_info['name'])); |
|
118 | 118 | $donor_data['user_id'] = $donor_info['user_id']; |
119 | 119 | |
120 | - $donor_data = apply_filters( 'give_edit_donor_info', $donor_data, $donor_id ); |
|
121 | - $address = apply_filters( 'give_edit_donor_address', $address, $donor_id ); |
|
120 | + $donor_data = apply_filters('give_edit_donor_info', $donor_data, $donor_id); |
|
121 | + $address = apply_filters('give_edit_donor_address', $address, $donor_id); |
|
122 | 122 | |
123 | - $donor_data = array_map( 'sanitize_text_field', $donor_data ); |
|
124 | - $address = array_map( 'sanitize_text_field', $address ); |
|
123 | + $donor_data = array_map('sanitize_text_field', $donor_data); |
|
124 | + $address = array_map('sanitize_text_field', $address); |
|
125 | 125 | |
126 | 126 | /** |
127 | 127 | * Fires before editing a donor. |
@@ -132,27 +132,27 @@ discard block |
||
132 | 132 | * @param array $donor_data The donor data. |
133 | 133 | * @param array $address The donor's address. |
134 | 134 | */ |
135 | - do_action( 'give_pre_edit_donor', $donor_id, $donor_data, $address ); |
|
135 | + do_action('give_pre_edit_donor', $donor_id, $donor_data, $address); |
|
136 | 136 | |
137 | 137 | $output = array(); |
138 | 138 | |
139 | - if ( $donor->update( $donor_data ) ) { |
|
139 | + if ($donor->update($donor_data)) { |
|
140 | 140 | |
141 | - if ( ! empty( $donor->user_id ) && $donor->user_id > 0 ) { |
|
142 | - update_user_meta( $donor->user_id, '_give_user_address', $address ); |
|
141 | + if ( ! empty($donor->user_id) && $donor->user_id > 0) { |
|
142 | + update_user_meta($donor->user_id, '_give_user_address', $address); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | // Update some donation meta if we need to. |
146 | - $payments_array = explode( ',', $donor->payment_ids ); |
|
146 | + $payments_array = explode(',', $donor->payment_ids); |
|
147 | 147 | |
148 | - if ( $donor->user_id != $previous_user_id ) { |
|
149 | - foreach ( $payments_array as $payment_id ) { |
|
150 | - give_update_payment_meta( $payment_id, '_give_payment_user_id', $donor->user_id ); |
|
148 | + if ($donor->user_id != $previous_user_id) { |
|
149 | + foreach ($payments_array as $payment_id) { |
|
150 | + give_update_payment_meta($payment_id, '_give_payment_user_id', $donor->user_id); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | 154 | $output['success'] = true; |
155 | - $donor_data = array_merge( $donor_data, $address ); |
|
155 | + $donor_data = array_merge($donor_data, $address); |
|
156 | 156 | $output['customer_info'] = $donor_data; |
157 | 157 | |
158 | 158 | } else { |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | * @param int $donor_id The ID of the donor. |
170 | 170 | * @param array $donor_data The donor data. |
171 | 171 | */ |
172 | - do_action( 'give_post_edit_donor', $donor_id, $donor_data ); |
|
172 | + do_action('give_post_edit_donor', $donor_id, $donor_data); |
|
173 | 173 | |
174 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
175 | - header( 'Content-Type: application/json' ); |
|
176 | - echo json_encode( $output ); |
|
174 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
175 | + header('Content-Type: application/json'); |
|
176 | + echo json_encode($output); |
|
177 | 177 | wp_die(); |
178 | 178 | } |
179 | 179 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | |
182 | 182 | } |
183 | 183 | |
184 | -add_action( 'give_edit-donor', 'give_edit_donor', 10, 1 ); |
|
184 | +add_action('give_edit-donor', 'give_edit_donor', 10, 1); |
|
185 | 185 | |
186 | 186 | /** |
187 | 187 | * Save a donor note. |
@@ -192,40 +192,40 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @return int The Note ID that was saved, or 0 if nothing was saved. |
194 | 194 | */ |
195 | -function give_donor_save_note( $args ) { |
|
195 | +function give_donor_save_note($args) { |
|
196 | 196 | |
197 | - $donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' ); |
|
197 | + $donor_view_role = apply_filters('give_view_donors_role', 'view_give_reports'); |
|
198 | 198 | |
199 | - if ( ! is_admin() || ! current_user_can( $donor_view_role ) ) { |
|
200 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array( |
|
199 | + if ( ! is_admin() || ! current_user_can($donor_view_role)) { |
|
200 | + wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array( |
|
201 | 201 | 'response' => 403, |
202 | - ) ); |
|
202 | + )); |
|
203 | 203 | } |
204 | 204 | |
205 | - if ( empty( $args ) ) { |
|
205 | + if (empty($args)) { |
|
206 | 206 | return false; |
207 | 207 | } |
208 | 208 | |
209 | - $donor_note = trim( sanitize_text_field( $args['donor_note'] ) ); |
|
209 | + $donor_note = trim(sanitize_text_field($args['donor_note'])); |
|
210 | 210 | $donor_id = (int) $args['customer_id']; |
211 | 211 | $nonce = $args['add_donor_note_nonce']; |
212 | 212 | |
213 | - if ( ! wp_verify_nonce( $nonce, 'add-donor-note' ) ) { |
|
214 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
213 | + if ( ! wp_verify_nonce($nonce, 'add-donor-note')) { |
|
214 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
215 | 215 | 'response' => 400, |
216 | - ) ); |
|
216 | + )); |
|
217 | 217 | } |
218 | 218 | |
219 | - if ( empty( $donor_note ) ) { |
|
220 | - give_set_error( 'empty-donor-note', __( 'A note is required.', 'give' ) ); |
|
219 | + if (empty($donor_note)) { |
|
220 | + give_set_error('empty-donor-note', __('A note is required.', 'give')); |
|
221 | 221 | } |
222 | 222 | |
223 | - if ( give_get_errors() ) { |
|
223 | + if (give_get_errors()) { |
|
224 | 224 | return false; |
225 | 225 | } |
226 | 226 | |
227 | - $donor = new Give_Donor( $donor_id ); |
|
228 | - $new_note = $donor->add_note( $donor_note ); |
|
227 | + $donor = new Give_Donor($donor_id); |
|
228 | + $new_note = $donor->add_note($donor_note); |
|
229 | 229 | |
230 | 230 | /** |
231 | 231 | * Fires before inserting donor note. |
@@ -235,22 +235,22 @@ discard block |
||
235 | 235 | * @param int $donor_id The ID of the donor. |
236 | 236 | * @param string $new_note Note content. |
237 | 237 | */ |
238 | - do_action( 'give_pre_insert_donor_note', $donor_id, $new_note ); |
|
238 | + do_action('give_pre_insert_donor_note', $donor_id, $new_note); |
|
239 | 239 | |
240 | - if ( ! empty( $new_note ) && ! empty( $donor->id ) ) { |
|
240 | + if ( ! empty($new_note) && ! empty($donor->id)) { |
|
241 | 241 | |
242 | 242 | ob_start(); |
243 | 243 | ?> |
244 | 244 | <div class="donor-note-wrapper dashboard-comment-wrap comment-item"> |
245 | 245 | <span class="note-content-wrap"> |
246 | - <?php echo stripslashes( $new_note ); ?> |
|
246 | + <?php echo stripslashes($new_note); ?> |
|
247 | 247 | </span> |
248 | 248 | </div> |
249 | 249 | <?php |
250 | 250 | $output = ob_get_contents(); |
251 | 251 | ob_end_clean(); |
252 | 252 | |
253 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
253 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
254 | 254 | echo $output; |
255 | 255 | exit; |
256 | 256 | } |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | |
264 | 264 | } |
265 | 265 | |
266 | -add_action( 'give_add-donor-note', 'give_donor_save_note', 10, 1 ); |
|
266 | +add_action('give_add-donor-note', 'give_donor_save_note', 10, 1); |
|
267 | 267 | |
268 | 268 | /** |
269 | 269 | * Delete a donor. |
@@ -274,41 +274,41 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @return int Whether it was a successful deletion. |
276 | 276 | */ |
277 | -function give_donor_delete( $args ) { |
|
277 | +function give_donor_delete($args) { |
|
278 | 278 | |
279 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
279 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
280 | 280 | |
281 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
282 | - wp_die( __( 'You do not have permission to delete donors.', 'give' ), __( 'Error', 'give' ), array( |
|
281 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
282 | + wp_die(__('You do not have permission to delete donors.', 'give'), __('Error', 'give'), array( |
|
283 | 283 | 'response' => 403, |
284 | - ) ); |
|
284 | + )); |
|
285 | 285 | } |
286 | 286 | |
287 | - if ( empty( $args ) ) { |
|
287 | + if (empty($args)) { |
|
288 | 288 | return false; |
289 | 289 | } |
290 | 290 | |
291 | 291 | $donor_id = (int) $args['customer_id']; |
292 | - $confirm = ! empty( $args['give-donor-delete-confirm'] ) ? true : false; |
|
293 | - $remove_data = ! empty( $args['give-donor-delete-records'] ) ? true : false; |
|
292 | + $confirm = ! empty($args['give-donor-delete-confirm']) ? true : false; |
|
293 | + $remove_data = ! empty($args['give-donor-delete-records']) ? true : false; |
|
294 | 294 | $nonce = $args['_wpnonce']; |
295 | 295 | |
296 | - if ( ! wp_verify_nonce( $nonce, 'delete-donor' ) ) { |
|
297 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
296 | + if ( ! wp_verify_nonce($nonce, 'delete-donor')) { |
|
297 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
298 | 298 | 'response' => 400, |
299 | - ) ); |
|
299 | + )); |
|
300 | 300 | } |
301 | 301 | |
302 | - if ( ! $confirm ) { |
|
303 | - give_set_error( 'donor-delete-no-confirm', __( 'Please confirm you want to delete this donor.', 'give' ) ); |
|
302 | + if ( ! $confirm) { |
|
303 | + give_set_error('donor-delete-no-confirm', __('Please confirm you want to delete this donor.', 'give')); |
|
304 | 304 | } |
305 | 305 | |
306 | - if ( give_get_errors() ) { |
|
307 | - wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id ) ); |
|
306 | + if (give_get_errors()) { |
|
307 | + wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id)); |
|
308 | 308 | exit; |
309 | 309 | } |
310 | 310 | |
311 | - $donor = new Give_Donor( $donor_id ); |
|
311 | + $donor = new Give_Donor($donor_id); |
|
312 | 312 | |
313 | 313 | /** |
314 | 314 | * Fires before deleting donor. |
@@ -319,50 +319,50 @@ discard block |
||
319 | 319 | * @param bool $confirm Delete confirmation. |
320 | 320 | * @param bool $remove_data Records delete confirmation. |
321 | 321 | */ |
322 | - do_action( 'give_pre_delete_donor', $donor_id, $confirm, $remove_data ); |
|
322 | + do_action('give_pre_delete_donor', $donor_id, $confirm, $remove_data); |
|
323 | 323 | |
324 | - if ( $donor->id > 0 ) { |
|
324 | + if ($donor->id > 0) { |
|
325 | 325 | |
326 | - $payments_array = explode( ',', $donor->payment_ids ); |
|
327 | - $success = Give()->donors->delete( $donor->id ); |
|
326 | + $payments_array = explode(',', $donor->payment_ids); |
|
327 | + $success = Give()->donors->delete($donor->id); |
|
328 | 328 | |
329 | - if ( $success ) { |
|
329 | + if ($success) { |
|
330 | 330 | |
331 | - if ( $remove_data ) { |
|
331 | + if ($remove_data) { |
|
332 | 332 | |
333 | 333 | // Remove all donations, logs, etc |
334 | - foreach ( $payments_array as $payment_id ) { |
|
335 | - give_delete_donation( $payment_id ); |
|
334 | + foreach ($payments_array as $payment_id) { |
|
335 | + give_delete_donation($payment_id); |
|
336 | 336 | } |
337 | 337 | } else { |
338 | 338 | |
339 | 339 | // Just set the donations to customer_id of 0 |
340 | - foreach ( $payments_array as $payment_id ) { |
|
341 | - give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 ); |
|
340 | + foreach ($payments_array as $payment_id) { |
|
341 | + give_update_payment_meta($payment_id, '_give_payment_customer_id', 0); |
|
342 | 342 | } |
343 | 343 | } |
344 | 344 | |
345 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=donor-deleted' ); |
|
345 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=donor-deleted'); |
|
346 | 346 | |
347 | 347 | } else { |
348 | 348 | |
349 | - give_set_error( 'give-donor-delete-failed', esc_html__( 'Error deleting donor.', 'give' ) ); |
|
350 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor_id ); |
|
349 | + give_set_error('give-donor-delete-failed', esc_html__('Error deleting donor.', 'give')); |
|
350 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor_id); |
|
351 | 351 | |
352 | 352 | } |
353 | 353 | } else { |
354 | 354 | |
355 | - give_set_error( 'give-donor-delete-invalid-id', esc_html__( 'Invalid Donor ID.', 'give' ) ); |
|
356 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); |
|
355 | + give_set_error('give-donor-delete-invalid-id', esc_html__('Invalid Donor ID.', 'give')); |
|
356 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors'); |
|
357 | 357 | |
358 | 358 | } |
359 | 359 | |
360 | - wp_redirect( $redirect ); |
|
360 | + wp_redirect($redirect); |
|
361 | 361 | exit; |
362 | 362 | |
363 | 363 | } |
364 | 364 | |
365 | -add_action( 'give_delete-donor', 'give_donor_delete', 10, 1 ); |
|
365 | +add_action('give_delete-donor', 'give_donor_delete', 10, 1); |
|
366 | 366 | |
367 | 367 | /** |
368 | 368 | * Disconnect a user ID from a donor |
@@ -373,17 +373,17 @@ discard block |
||
373 | 373 | * |
374 | 374 | * @return bool|array If the disconnect was successful. |
375 | 375 | */ |
376 | -function give_disconnect_donor_user_id( $args ) { |
|
376 | +function give_disconnect_donor_user_id($args) { |
|
377 | 377 | |
378 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
378 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
379 | 379 | |
380 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
381 | - wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array( |
|
380 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
381 | + wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array( |
|
382 | 382 | 'response' => 403, |
383 | - ) ); |
|
383 | + )); |
|
384 | 384 | } |
385 | 385 | |
386 | - if ( empty( $args ) ) { |
|
386 | + if (empty($args)) { |
|
387 | 387 | return false; |
388 | 388 | } |
389 | 389 | |
@@ -391,14 +391,14 @@ discard block |
||
391 | 391 | |
392 | 392 | $nonce = $args['_wpnonce']; |
393 | 393 | |
394 | - if ( ! wp_verify_nonce( $nonce, 'edit-donor' ) ) { |
|
395 | - wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array( |
|
394 | + if ( ! wp_verify_nonce($nonce, 'edit-donor')) { |
|
395 | + wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array( |
|
396 | 396 | 'response' => 400, |
397 | - ) ); |
|
397 | + )); |
|
398 | 398 | } |
399 | 399 | |
400 | - $donor = new Give_Donor( $donor_id ); |
|
401 | - if ( empty( $donor->id ) ) { |
|
400 | + $donor = new Give_Donor($donor_id); |
|
401 | + if (empty($donor->id)) { |
|
402 | 402 | return false; |
403 | 403 | } |
404 | 404 | |
@@ -412,18 +412,18 @@ discard block |
||
412 | 412 | * @param int $donor_id The ID of the donor. |
413 | 413 | * @param int $user_id The ID of the user. |
414 | 414 | */ |
415 | - do_action( 'give_pre_donor_disconnect_user_id', $donor_id, $user_id ); |
|
415 | + do_action('give_pre_donor_disconnect_user_id', $donor_id, $user_id); |
|
416 | 416 | |
417 | 417 | $output = array(); |
418 | 418 | $donor_args = array( |
419 | 419 | 'user_id' => 0, |
420 | 420 | ); |
421 | 421 | |
422 | - if ( $donor->update( $donor_args ) ) { |
|
422 | + if ($donor->update($donor_args)) { |
|
423 | 423 | global $wpdb; |
424 | 424 | |
425 | - if ( ! empty( $donor->payment_ids ) ) { |
|
426 | - $wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $donor->payment_ids )" ); |
|
425 | + if ( ! empty($donor->payment_ids)) { |
|
426 | + $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $donor->payment_ids )"); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | $output['success'] = true; |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | } else { |
432 | 432 | |
433 | 433 | $output['success'] = false; |
434 | - give_set_error( 'give-disconnect-user-fail', __( 'Failed to disconnect user from donor.', 'give' ) ); |
|
434 | + give_set_error('give-disconnect-user-fail', __('Failed to disconnect user from donor.', 'give')); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | /** |
@@ -441,11 +441,11 @@ discard block |
||
441 | 441 | * |
442 | 442 | * @param int $donor_id The ID of the donor. |
443 | 443 | */ |
444 | - do_action( 'give_post_donor_disconnect_user_id', $donor_id ); |
|
444 | + do_action('give_post_donor_disconnect_user_id', $donor_id); |
|
445 | 445 | |
446 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
447 | - header( 'Content-Type: application/json' ); |
|
448 | - echo json_encode( $output ); |
|
446 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
447 | + header('Content-Type: application/json'); |
|
448 | + echo json_encode($output); |
|
449 | 449 | wp_die(); |
450 | 450 | } |
451 | 451 | |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | |
454 | 454 | } |
455 | 455 | |
456 | -add_action( 'give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1 ); |
|
456 | +add_action('give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1); |
|
457 | 457 | |
458 | 458 | /** |
459 | 459 | * Add an email address to the donor from within the admin and log a donor note. |
@@ -464,84 +464,84 @@ discard block |
||
464 | 464 | * |
465 | 465 | * @return mixed If DOING_AJAX echos out JSON, otherwise returns array of success (bool) and message (string). |
466 | 466 | */ |
467 | -function give_add_donor_email( $args ) { |
|
468 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
467 | +function give_add_donor_email($args) { |
|
468 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
469 | 469 | |
470 | - if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) { |
|
471 | - wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
470 | + if ( ! is_admin() || ! current_user_can($donor_edit_role)) { |
|
471 | + wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array( |
|
472 | 472 | 'response' => 403, |
473 | - ) ); |
|
473 | + )); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | $output = array(); |
477 | - if ( empty( $args ) || empty( $args['email'] ) || empty( $args['customer_id'] ) ) { |
|
477 | + if (empty($args) || empty($args['email']) || empty($args['customer_id'])) { |
|
478 | 478 | $output['success'] = false; |
479 | - if ( empty( $args['email'] ) ) { |
|
480 | - $output['message'] = __( 'Email address is required.', 'give' ); |
|
481 | - } elseif ( empty( $args['customer_id'] ) ) { |
|
482 | - $output['message'] = __( 'Donor ID is required.', 'give' ); |
|
479 | + if (empty($args['email'])) { |
|
480 | + $output['message'] = __('Email address is required.', 'give'); |
|
481 | + } elseif (empty($args['customer_id'])) { |
|
482 | + $output['message'] = __('Donor ID is required.', 'give'); |
|
483 | 483 | } else { |
484 | - $output['message'] = __( 'An error has occurred. Please try again.', 'give' ); |
|
484 | + $output['message'] = __('An error has occurred. Please try again.', 'give'); |
|
485 | 485 | } |
486 | - } elseif ( ! wp_verify_nonce( $args['_wpnonce'], 'give_add_donor_email' ) ) { |
|
486 | + } elseif ( ! wp_verify_nonce($args['_wpnonce'], 'give_add_donor_email')) { |
|
487 | 487 | $output = array( |
488 | 488 | 'success' => false, |
489 | - 'message' => esc_html__( 'Nonce verification failed.', 'give' ), |
|
489 | + 'message' => esc_html__('Nonce verification failed.', 'give'), |
|
490 | 490 | ); |
491 | - } elseif ( ! is_email( $args['email'] ) ) { |
|
491 | + } elseif ( ! is_email($args['email'])) { |
|
492 | 492 | $output = array( |
493 | 493 | 'success' => false, |
494 | - 'message' => esc_html__( 'Invalid email.', 'give' ), |
|
494 | + 'message' => esc_html__('Invalid email.', 'give'), |
|
495 | 495 | ); |
496 | 496 | } else { |
497 | - $email = sanitize_email( $args['email'] ); |
|
497 | + $email = sanitize_email($args['email']); |
|
498 | 498 | $donor_id = (int) $args['customer_id']; |
499 | 499 | $primary = 'true' === $args['primary'] ? true : false; |
500 | - $donor = new Give_Donor( $donor_id ); |
|
501 | - if ( false === $donor->add_email( $email, $primary ) ) { |
|
502 | - if ( in_array( $email, $donor->emails ) ) { |
|
500 | + $donor = new Give_Donor($donor_id); |
|
501 | + if (false === $donor->add_email($email, $primary)) { |
|
502 | + if (in_array($email, $donor->emails)) { |
|
503 | 503 | $output = array( |
504 | 504 | 'success' => false, |
505 | - 'message' => __( 'Email already associated with this donor.', 'give' ), |
|
505 | + 'message' => __('Email already associated with this donor.', 'give'), |
|
506 | 506 | ); |
507 | 507 | } else { |
508 | 508 | $output = array( |
509 | 509 | 'success' => false, |
510 | - 'message' => __( 'Email address is already associated with another donor.', 'give' ), |
|
510 | + 'message' => __('Email address is already associated with another donor.', 'give'), |
|
511 | 511 | ); |
512 | 512 | } |
513 | 513 | } else { |
514 | - $redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&give-message=email-added' ); |
|
514 | + $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&give-message=email-added'); |
|
515 | 515 | $output = array( |
516 | 516 | 'success' => true, |
517 | - 'message' => __( 'Email successfully added to donor.', 'give' ), |
|
517 | + 'message' => __('Email successfully added to donor.', 'give'), |
|
518 | 518 | 'redirect' => $redirect, |
519 | 519 | ); |
520 | 520 | |
521 | 521 | $user = wp_get_current_user(); |
522 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' ); |
|
523 | - $donor_note = sprintf( __( 'Email address %1$s added by %2$s', 'give' ), $email, $user_login ); |
|
524 | - $donor->add_note( $donor_note ); |
|
522 | + $user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give'); |
|
523 | + $donor_note = sprintf(__('Email address %1$s added by %2$s', 'give'), $email, $user_login); |
|
524 | + $donor->add_note($donor_note); |
|
525 | 525 | |
526 | - if ( $primary ) { |
|
527 | - $donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $email, $user_login ); |
|
528 | - $donor->add_note( $donor_note ); |
|
526 | + if ($primary) { |
|
527 | + $donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $email, $user_login); |
|
528 | + $donor->add_note($donor_note); |
|
529 | 529 | } |
530 | 530 | } |
531 | 531 | }// End if(). |
532 | 532 | |
533 | - do_action( 'give_post_add_donor_email', $donor_id, $args ); |
|
533 | + do_action('give_post_add_donor_email', $donor_id, $args); |
|
534 | 534 | |
535 | - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
536 | - header( 'Content-Type: application/json' ); |
|
537 | - echo json_encode( $output ); |
|
535 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
536 | + header('Content-Type: application/json'); |
|
537 | + echo json_encode($output); |
|
538 | 538 | wp_die(); |
539 | 539 | } |
540 | 540 | |
541 | 541 | return $output; |
542 | 542 | } |
543 | 543 | |
544 | -add_action( 'give_add_donor_email', 'give_add_donor_email', 10, 1 ); |
|
544 | +add_action('give_add_donor_email', 'give_add_donor_email', 10, 1); |
|
545 | 545 | |
546 | 546 | |
547 | 547 | /** |
@@ -551,39 +551,39 @@ discard block |
||
551 | 551 | * @return bool|null |
552 | 552 | */ |
553 | 553 | function give_remove_donor_email() { |
554 | - if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
554 | + if (empty($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
555 | 555 | return false; |
556 | 556 | } |
557 | - if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) { |
|
557 | + if (empty($_GET['email']) || ! is_email($_GET['email'])) { |
|
558 | 558 | return false; |
559 | 559 | } |
560 | - if ( empty( $_GET['_wpnonce'] ) ) { |
|
560 | + if (empty($_GET['_wpnonce'])) { |
|
561 | 561 | return false; |
562 | 562 | } |
563 | 563 | |
564 | 564 | $nonce = $_GET['_wpnonce']; |
565 | - if ( ! wp_verify_nonce( $nonce, 'give-remove-donor-email' ) ) { |
|
566 | - wp_die( esc_html__( 'Nonce verification failed', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
565 | + if ( ! wp_verify_nonce($nonce, 'give-remove-donor-email')) { |
|
566 | + wp_die(esc_html__('Nonce verification failed', 'give'), esc_html__('Error', 'give'), array( |
|
567 | 567 | 'response' => 403, |
568 | - ) ); |
|
568 | + )); |
|
569 | 569 | } |
570 | 570 | |
571 | - $donor = new Give_Donor( $_GET['id'] ); |
|
572 | - if ( $donor->remove_email( $_GET['email'] ) ) { |
|
573 | - $url = add_query_arg( 'give-message', 'email-removed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
571 | + $donor = new Give_Donor($_GET['id']); |
|
572 | + if ($donor->remove_email($_GET['email'])) { |
|
573 | + $url = add_query_arg('give-message', 'email-removed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
574 | 574 | $user = wp_get_current_user(); |
575 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' ); |
|
576 | - $donor_note = sprintf( __( 'Email address %1$s removed by %2$s', 'give' ), $_GET['email'], $user_login ); |
|
577 | - $donor->add_note( $donor_note ); |
|
575 | + $user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give'); |
|
576 | + $donor_note = sprintf(__('Email address %1$s removed by %2$s', 'give'), $_GET['email'], $user_login); |
|
577 | + $donor->add_note($donor_note); |
|
578 | 578 | } else { |
579 | - $url = add_query_arg( 'give-message', 'email-remove-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
579 | + $url = add_query_arg('give-message', 'email-remove-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
580 | 580 | } |
581 | 581 | |
582 | - wp_safe_redirect( $url ); |
|
582 | + wp_safe_redirect($url); |
|
583 | 583 | exit; |
584 | 584 | } |
585 | 585 | |
586 | -add_action( 'give_remove_donor_email', 'give_remove_donor_email', 10 ); |
|
586 | +add_action('give_remove_donor_email', 'give_remove_donor_email', 10); |
|
587 | 587 | |
588 | 588 | |
589 | 589 | /** |
@@ -594,41 +594,41 @@ discard block |
||
594 | 594 | * @return bool|null |
595 | 595 | */ |
596 | 596 | function give_set_donor_primary_email() { |
597 | - if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
597 | + if (empty($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
598 | 598 | return false; |
599 | 599 | } |
600 | 600 | |
601 | - if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) { |
|
601 | + if (empty($_GET['email']) || ! is_email($_GET['email'])) { |
|
602 | 602 | return false; |
603 | 603 | } |
604 | 604 | |
605 | - if ( empty( $_GET['_wpnonce'] ) ) { |
|
605 | + if (empty($_GET['_wpnonce'])) { |
|
606 | 606 | return false; |
607 | 607 | } |
608 | 608 | |
609 | 609 | $nonce = $_GET['_wpnonce']; |
610 | 610 | |
611 | - if ( ! wp_verify_nonce( $nonce, 'give-set-donor-primary-email' ) ) { |
|
612 | - wp_die( esc_html__( 'Nonce verification failed', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
611 | + if ( ! wp_verify_nonce($nonce, 'give-set-donor-primary-email')) { |
|
612 | + wp_die(esc_html__('Nonce verification failed', 'give'), esc_html__('Error', 'give'), array( |
|
613 | 613 | 'response' => 403, |
614 | - ) ); |
|
614 | + )); |
|
615 | 615 | } |
616 | 616 | |
617 | - $donor = new Give_Donor( $_GET['id'] ); |
|
617 | + $donor = new Give_Donor($_GET['id']); |
|
618 | 618 | |
619 | - if ( $donor->set_primary_email( $_GET['email'] ) ) { |
|
620 | - $url = add_query_arg( 'give-message', 'primary-email-updated', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
619 | + if ($donor->set_primary_email($_GET['email'])) { |
|
620 | + $url = add_query_arg('give-message', 'primary-email-updated', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
621 | 621 | $user = wp_get_current_user(); |
622 | - $user_login = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' ); |
|
623 | - $donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $_GET['email'], $user_login ); |
|
622 | + $user_login = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give'); |
|
623 | + $donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $_GET['email'], $user_login); |
|
624 | 624 | |
625 | - $donor->add_note( $donor_note ); |
|
625 | + $donor->add_note($donor_note); |
|
626 | 626 | } else { |
627 | - $url = add_query_arg( 'give-message', 'primary-email-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) ); |
|
627 | + $url = add_query_arg('give-message', 'primary-email-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id)); |
|
628 | 628 | } |
629 | 629 | |
630 | - wp_safe_redirect( $url ); |
|
630 | + wp_safe_redirect($url); |
|
631 | 631 | exit; |
632 | 632 | } |
633 | 633 | |
634 | -add_action( 'give_set_donor_primary_email', 'give_set_donor_primary_email', 10 ); |
|
634 | +add_action('give_set_donor_primary_email', 'give_set_donor_primary_email', 10); |
@@ -49,7 +49,7 @@ |
||
49 | 49 | * @access public |
50 | 50 | * @since 1.5 |
51 | 51 | * |
52 | - * @return array $data The data for the CSV file |
|
52 | + * @return boolean $data The data for the CSV file |
|
53 | 53 | */ |
54 | 54 | public function get_data() { |
55 | 55 |
@@ -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 | |
@@ -57,32 +57,32 @@ discard block |
||
57 | 57 | |
58 | 58 | $args = array( |
59 | 59 | 'number' => $this->per_step, |
60 | - 'offset' => $this->per_step * ( $this->step - 1 ), |
|
60 | + 'offset' => $this->per_step * ($this->step - 1), |
|
61 | 61 | 'orderby' => 'id', |
62 | 62 | 'order' => 'DESC', |
63 | 63 | ); |
64 | 64 | |
65 | - $donors = Give()->donors->get_donors( $args ); |
|
65 | + $donors = Give()->donors->get_donors($args); |
|
66 | 66 | |
67 | - if ( $donors ) { |
|
67 | + if ($donors) { |
|
68 | 68 | |
69 | - $allowed_payment_status = apply_filters( 'give_recount_donors_donation_statuses', give_get_payment_status_keys() ); |
|
69 | + $allowed_payment_status = apply_filters('give_recount_donors_donation_statuses', give_get_payment_status_keys()); |
|
70 | 70 | |
71 | - foreach ( $donors as $donor ) { |
|
71 | + foreach ($donors as $donor) { |
|
72 | 72 | |
73 | - $attached_payment_ids = explode( ',', $donor->payment_ids ); |
|
73 | + $attached_payment_ids = explode(',', $donor->payment_ids); |
|
74 | 74 | |
75 | 75 | $attached_args = array( |
76 | 76 | 'post__in' => $attached_payment_ids, |
77 | - 'number' => - 1, |
|
77 | + 'number' => -1, |
|
78 | 78 | 'status' => $allowed_payment_status, |
79 | 79 | ); |
80 | 80 | |
81 | - $attached_payments = (array) give_get_payments( $attached_args ); |
|
81 | + $attached_payments = (array) give_get_payments($attached_args); |
|
82 | 82 | |
83 | 83 | $unattached_args = array( |
84 | 84 | 'post__not_in' => $attached_payment_ids, |
85 | - 'number' => - 1, |
|
85 | + 'number' => -1, |
|
86 | 86 | 'status' => $allowed_payment_status, |
87 | 87 | 'meta_query' => array( |
88 | 88 | array( |
@@ -93,29 +93,29 @@ discard block |
||
93 | 93 | ), |
94 | 94 | ); |
95 | 95 | |
96 | - $unattached_payments = give_get_payments( $unattached_args ); |
|
96 | + $unattached_payments = give_get_payments($unattached_args); |
|
97 | 97 | |
98 | - $payments = array_merge( $attached_payments, $unattached_payments ); |
|
98 | + $payments = array_merge($attached_payments, $unattached_payments); |
|
99 | 99 | |
100 | 100 | $purchase_value = 0.00; |
101 | 101 | $purchase_count = 0; |
102 | 102 | $payment_ids = array(); |
103 | 103 | |
104 | - if ( $payments ) { |
|
104 | + if ($payments) { |
|
105 | 105 | |
106 | - foreach ( $payments as $payment ) { |
|
106 | + foreach ($payments as $payment) { |
|
107 | 107 | |
108 | 108 | $should_process_payment = 'publish' == $payment->post_status ? true : false; |
109 | - $should_process_payment = apply_filters( 'give_donor_recount_should_process_donation', $should_process_payment, $payment ); |
|
109 | + $should_process_payment = apply_filters('give_donor_recount_should_process_donation', $should_process_payment, $payment); |
|
110 | 110 | |
111 | - if ( true === $should_process_payment ) { |
|
111 | + if (true === $should_process_payment) { |
|
112 | 112 | |
113 | - if ( apply_filters( 'give_donor_recount_should_increase_value', true, $payment ) ) { |
|
114 | - $purchase_value += give_get_payment_amount( $payment->ID ); |
|
113 | + if (apply_filters('give_donor_recount_should_increase_value', true, $payment)) { |
|
114 | + $purchase_value += give_get_payment_amount($payment->ID); |
|
115 | 115 | } |
116 | 116 | |
117 | - if ( apply_filters( 'give_donor_recount_should_increase_count', true, $payment ) ) { |
|
118 | - $purchase_count ++; |
|
117 | + if (apply_filters('give_donor_recount_should_increase_count', true, $payment)) { |
|
118 | + $purchase_count++; |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - $payment_ids = implode( ',', $payment_ids ); |
|
126 | + $payment_ids = implode(',', $payment_ids); |
|
127 | 127 | |
128 | 128 | $donor_update_data = array( |
129 | 129 | 'purchase_count' => $purchase_count, |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | 'payment_ids' => $payment_ids, |
132 | 132 | ); |
133 | 133 | |
134 | - $donor_instance = new Give_Donor( $donor->id ); |
|
135 | - $donor_instance->update( $donor_update_data ); |
|
134 | + $donor_instance = new Give_Donor($donor->id); |
|
135 | + $donor_instance->update($donor_update_data); |
|
136 | 136 | |
137 | 137 | }// End foreach(). |
138 | 138 | |
@@ -152,21 +152,21 @@ discard block |
||
152 | 152 | public function get_percentage_complete() { |
153 | 153 | |
154 | 154 | $args = array( |
155 | - 'number' => - 1, |
|
155 | + 'number' => -1, |
|
156 | 156 | 'orderby' => 'id', |
157 | 157 | 'order' => 'DESC', |
158 | 158 | ); |
159 | 159 | |
160 | - $donors = Give()->donors->get_donors( $args ); |
|
161 | - $total = count( $donors ); |
|
160 | + $donors = Give()->donors->get_donors($args); |
|
161 | + $total = count($donors); |
|
162 | 162 | |
163 | 163 | $percentage = 100; |
164 | 164 | |
165 | - if ( $total > 0 ) { |
|
166 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
165 | + if ($total > 0) { |
|
166 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
167 | 167 | } |
168 | 168 | |
169 | - if ( $percentage > 100 ) { |
|
169 | + if ($percentage > 100) { |
|
170 | 170 | $percentage = 100; |
171 | 171 | } |
172 | 172 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @param array $request The Form Data passed into the batch processing |
182 | 182 | */ |
183 | - public function set_properties( $request ) { |
|
183 | + public function set_properties($request) { |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -191,21 +191,21 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function process_step() { |
193 | 193 | |
194 | - if ( ! $this->can_export() ) { |
|
195 | - wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
194 | + if ( ! $this->can_export()) { |
|
195 | + wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array( |
|
196 | 196 | 'response' => 403, |
197 | - ) ); |
|
197 | + )); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | $had_data = $this->get_data(); |
201 | 201 | |
202 | - if ( $had_data ) { |
|
202 | + if ($had_data) { |
|
203 | 203 | $this->done = false; |
204 | 204 | |
205 | 205 | return true; |
206 | 206 | } else { |
207 | 207 | $this->done = true; |
208 | - $this->message = esc_html__( 'Donor stats have been successfully recounted.', 'give' ); |
|
208 | + $this->message = esc_html__('Donor stats have been successfully recounted.', 'give'); |
|
209 | 209 | |
210 | 210 | return false; |
211 | 211 | } |
@@ -215,10 +215,10 @@ discard block |
||
215 | 215 | * Headers |
216 | 216 | */ |
217 | 217 | public function headers() { |
218 | - ignore_user_abort( true ); |
|
218 | + ignore_user_abort(true); |
|
219 | 219 | |
220 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
221 | - set_time_limit( 0 ); |
|
220 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
221 | + set_time_limit(0); |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @access public |
218 | 218 | * @since 1.1 |
219 | - * @return array |
|
219 | + * @return string |
|
220 | 220 | */ |
221 | 221 | public function get_versions() { |
222 | 222 | return $this->versions; |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @uses Give_API::invalid_key() |
303 | 303 | * @uses Give_API::invalid_auth() |
304 | 304 | * @since 1.1 |
305 | - * @return bool |
|
305 | + * @return false|null |
|
306 | 306 | */ |
307 | 307 | private function validate_request() { |
308 | 308 | global $wp_query; |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | * |
695 | 695 | * @param array $args Arguments to override defaults |
696 | 696 | * |
697 | - * @return array $dates |
|
697 | + * @return integer|null $dates |
|
698 | 698 | */ |
699 | 699 | public function get_dates( $args = array() ) { |
700 | 700 | $dates = array(); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -141,27 +141,27 @@ discard block |
||
141 | 141 | 'v1' => 'GIVE_API_V1', |
142 | 142 | ); |
143 | 143 | |
144 | - foreach ( $this->get_versions() as $version => $class ) { |
|
145 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php'; |
|
144 | + foreach ($this->get_versions() as $version => $class) { |
|
145 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php'; |
|
146 | 146 | } |
147 | 147 | |
148 | - add_action( 'init', array( $this, 'add_endpoint' ) ); |
|
149 | - add_action( 'wp', array( $this, 'process_query' ), - 1 ); |
|
150 | - add_filter( 'query_vars', array( $this, 'query_vars' ) ); |
|
151 | - add_action( 'show_user_profile', array( $this, 'user_key_field' ) ); |
|
152 | - add_action( 'edit_user_profile', array( $this, 'user_key_field' ) ); |
|
153 | - add_action( 'personal_options_update', array( $this, 'update_key' ) ); |
|
154 | - add_action( 'edit_user_profile_update', array( $this, 'update_key' ) ); |
|
155 | - add_action( 'give_process_api_key', array( $this, 'process_api_key' ) ); |
|
148 | + add_action('init', array($this, 'add_endpoint')); |
|
149 | + add_action('wp', array($this, 'process_query'), - 1); |
|
150 | + add_filter('query_vars', array($this, 'query_vars')); |
|
151 | + add_action('show_user_profile', array($this, 'user_key_field')); |
|
152 | + add_action('edit_user_profile', array($this, 'user_key_field')); |
|
153 | + add_action('personal_options_update', array($this, 'update_key')); |
|
154 | + add_action('edit_user_profile_update', array($this, 'update_key')); |
|
155 | + add_action('give_process_api_key', array($this, 'process_api_key')); |
|
156 | 156 | |
157 | 157 | // Setup a backwards compatibility check for user API Keys |
158 | - add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 ); |
|
158 | + add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4); |
|
159 | 159 | |
160 | 160 | // Determine if JSON_PRETTY_PRINT is available |
161 | - $this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null; |
|
161 | + $this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null; |
|
162 | 162 | |
163 | 163 | // Allow API request logging to be turned off |
164 | - $this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests ); |
|
164 | + $this->log_requests = apply_filters('give_api_log_requests', $this->log_requests); |
|
165 | 165 | |
166 | 166 | // Setup Give_Payment_Stats instance |
167 | 167 | $this->stats = new Give_Payment_Stats(); |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @since 1.1 |
179 | 179 | */ |
180 | - public function add_endpoint( $rewrite_rules ) { |
|
181 | - add_rewrite_endpoint( 'give-api', EP_ALL ); |
|
180 | + public function add_endpoint($rewrite_rules) { |
|
181 | + add_rewrite_endpoint('give-api', EP_ALL); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @return string[] $vars New query vars |
193 | 193 | */ |
194 | - public function query_vars( $vars ) { |
|
194 | + public function query_vars($vars) { |
|
195 | 195 | |
196 | 196 | $vars[] = 'token'; |
197 | 197 | $vars[] = 'key'; |
@@ -242,11 +242,11 @@ discard block |
||
242 | 242 | */ |
243 | 243 | public function get_default_version() { |
244 | 244 | |
245 | - $version = get_option( 'give_default_api_version' ); |
|
245 | + $version = get_option('give_default_api_version'); |
|
246 | 246 | |
247 | - if ( defined( 'GIVE_API_VERSION' ) ) { |
|
247 | + if (defined('GIVE_API_VERSION')) { |
|
248 | 248 | $version = GIVE_API_VERSION; |
249 | - } elseif ( ! $version ) { |
|
249 | + } elseif ( ! $version) { |
|
250 | 250 | $version = 'v1'; |
251 | 251 | } |
252 | 252 | |
@@ -267,14 +267,14 @@ discard block |
||
267 | 267 | |
268 | 268 | $version = $wp_query->query_vars['give-api']; |
269 | 269 | |
270 | - if ( strpos( $version, '/' ) ) { |
|
270 | + if (strpos($version, '/')) { |
|
271 | 271 | |
272 | - $version = explode( '/', $version ); |
|
273 | - $version = strtolower( $version[0] ); |
|
272 | + $version = explode('/', $version); |
|
273 | + $version = strtolower($version[0]); |
|
274 | 274 | |
275 | - $wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] ); |
|
275 | + $wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']); |
|
276 | 276 | |
277 | - if ( array_key_exists( $version, $this->versions ) ) { |
|
277 | + if (array_key_exists($version, $this->versions)) { |
|
278 | 278 | |
279 | 279 | $this->queried_version = $version; |
280 | 280 | |
@@ -310,26 +310,26 @@ discard block |
||
310 | 310 | $this->override = false; |
311 | 311 | |
312 | 312 | // Make sure we have both user and api key |
313 | - if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] !== 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) { |
|
313 | + if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] !== 'forms' || ! empty($wp_query->query_vars['token']))) { |
|
314 | 314 | |
315 | - if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) { |
|
315 | + if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) { |
|
316 | 316 | $this->missing_auth(); |
317 | 317 | return false; |
318 | 318 | } |
319 | 319 | |
320 | 320 | // Retrieve the user by public API key and ensure they exist |
321 | - if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) { |
|
321 | + if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) { |
|
322 | 322 | |
323 | 323 | $this->invalid_key(); |
324 | 324 | return false; |
325 | 325 | |
326 | 326 | } else { |
327 | 327 | |
328 | - $token = urldecode( $wp_query->query_vars['token'] ); |
|
329 | - $secret = $this->get_user_secret_key( $user ); |
|
330 | - $public = urldecode( $wp_query->query_vars['key'] ); |
|
328 | + $token = urldecode($wp_query->query_vars['token']); |
|
329 | + $secret = $this->get_user_secret_key($user); |
|
330 | + $public = urldecode($wp_query->query_vars['key']); |
|
331 | 331 | |
332 | - if ( hash_equals( md5( $secret . $public ), $token ) ) { |
|
332 | + if (hash_equals(md5($secret.$public), $token)) { |
|
333 | 333 | $this->is_valid_request = true; |
334 | 334 | } else { |
335 | 335 | $this->invalid_auth(); |
@@ -337,9 +337,9 @@ discard block |
||
337 | 337 | } |
338 | 338 | |
339 | 339 | } |
340 | - } elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] === 'forms' ) { |
|
340 | + } elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] === 'forms') { |
|
341 | 341 | $this->is_valid_request = true; |
342 | - $wp_query->set( 'key', 'public' ); |
|
342 | + $wp_query->set('key', 'public'); |
|
343 | 343 | } |
344 | 344 | } |
345 | 345 | |
@@ -355,25 +355,25 @@ discard block |
||
355 | 355 | * |
356 | 356 | * @return bool if user ID is found, false otherwise |
357 | 357 | */ |
358 | - public function get_user( $key = '' ) { |
|
358 | + public function get_user($key = '') { |
|
359 | 359 | global $wpdb, $wp_query; |
360 | 360 | |
361 | - if ( empty( $key ) ) { |
|
362 | - $key = urldecode( $wp_query->query_vars['key'] ); |
|
361 | + if (empty($key)) { |
|
362 | + $key = urldecode($wp_query->query_vars['key']); |
|
363 | 363 | } |
364 | 364 | |
365 | - if ( empty( $key ) ) { |
|
365 | + if (empty($key)) { |
|
366 | 366 | return false; |
367 | 367 | } |
368 | 368 | |
369 | - $user = Give_Cache::get( md5( 'give_api_user_' . $key ), true ); |
|
369 | + $user = Give_Cache::get(md5('give_api_user_'.$key), true); |
|
370 | 370 | |
371 | - if ( false === $user ) { |
|
372 | - $user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) ); |
|
373 | - Give_Cache::set( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS, true ); |
|
371 | + if (false === $user) { |
|
372 | + $user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key)); |
|
373 | + Give_Cache::set(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS, true); |
|
374 | 374 | } |
375 | 375 | |
376 | - if ( $user != null ) { |
|
376 | + if ($user != null) { |
|
377 | 377 | $this->user_id = $user; |
378 | 378 | |
379 | 379 | return $user; |
@@ -389,19 +389,19 @@ discard block |
||
389 | 389 | * |
390 | 390 | * @return mixed|null|string |
391 | 391 | */ |
392 | - public function get_user_public_key( $user_id = 0 ) { |
|
392 | + public function get_user_public_key($user_id = 0) { |
|
393 | 393 | global $wpdb; |
394 | 394 | |
395 | - if ( empty( $user_id ) ) { |
|
395 | + if (empty($user_id)) { |
|
396 | 396 | return ''; |
397 | 397 | } |
398 | 398 | |
399 | - $cache_key = md5( 'give_api_user_public_key' . $user_id ); |
|
400 | - $user_public_key = Give_Cache::get( $cache_key, true ); |
|
399 | + $cache_key = md5('give_api_user_public_key'.$user_id); |
|
400 | + $user_public_key = Give_Cache::get($cache_key, true); |
|
401 | 401 | |
402 | - if ( empty( $user_public_key ) ) { |
|
403 | - $user_public_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id ) ); |
|
404 | - Give_Cache::set( $cache_key, $user_public_key, HOUR_IN_SECONDS, true ); |
|
402 | + if (empty($user_public_key)) { |
|
403 | + $user_public_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id)); |
|
404 | + Give_Cache::set($cache_key, $user_public_key, HOUR_IN_SECONDS, true); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | return $user_public_key; |
@@ -414,19 +414,19 @@ discard block |
||
414 | 414 | * |
415 | 415 | * @return mixed|null|string |
416 | 416 | */ |
417 | - public function get_user_secret_key( $user_id = 0 ) { |
|
417 | + public function get_user_secret_key($user_id = 0) { |
|
418 | 418 | global $wpdb; |
419 | 419 | |
420 | - if ( empty( $user_id ) ) { |
|
420 | + if (empty($user_id)) { |
|
421 | 421 | return ''; |
422 | 422 | } |
423 | 423 | |
424 | - $cache_key = md5( 'give_api_user_secret_key' . $user_id ); |
|
425 | - $user_secret_key = Give_Cache::get( $cache_key, true ); |
|
424 | + $cache_key = md5('give_api_user_secret_key'.$user_id); |
|
425 | + $user_secret_key = Give_Cache::get($cache_key, true); |
|
426 | 426 | |
427 | - if ( empty( $user_secret_key ) ) { |
|
428 | - $user_secret_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id ) ); |
|
429 | - Give_Cache::set( $cache_key, $user_secret_key, HOUR_IN_SECONDS, true ); |
|
427 | + if (empty($user_secret_key)) { |
|
428 | + $user_secret_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id)); |
|
429 | + Give_Cache::set($cache_key, $user_secret_key, HOUR_IN_SECONDS, true); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | return $user_secret_key; |
@@ -442,10 +442,10 @@ discard block |
||
442 | 442 | */ |
443 | 443 | private function missing_auth() { |
444 | 444 | $error = array(); |
445 | - $error['error'] = esc_html__( 'You must specify both a token and API key.', 'give' ); |
|
445 | + $error['error'] = esc_html__('You must specify both a token and API key.', 'give'); |
|
446 | 446 | |
447 | 447 | $this->data = $error; |
448 | - $this->output( 401 ); |
|
448 | + $this->output(401); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | /** |
@@ -459,10 +459,10 @@ discard block |
||
459 | 459 | */ |
460 | 460 | private function invalid_auth() { |
461 | 461 | $error = array(); |
462 | - $error['error'] = esc_html__( 'Your request could not be authenticated.', 'give' ); |
|
462 | + $error['error'] = esc_html__('Your request could not be authenticated.', 'give'); |
|
463 | 463 | |
464 | 464 | $this->data = $error; |
465 | - $this->output( 403 ); |
|
465 | + $this->output(403); |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | /** |
@@ -476,10 +476,10 @@ discard block |
||
476 | 476 | */ |
477 | 477 | private function invalid_key() { |
478 | 478 | $error = array(); |
479 | - $error['error'] = esc_html__( 'Invalid API key.', 'give' ); |
|
479 | + $error['error'] = esc_html__('Invalid API key.', 'give'); |
|
480 | 480 | |
481 | 481 | $this->data = $error; |
482 | - $this->output( 403 ); |
|
482 | + $this->output(403); |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | /** |
@@ -492,10 +492,10 @@ discard block |
||
492 | 492 | */ |
493 | 493 | private function invalid_version() { |
494 | 494 | $error = array(); |
495 | - $error['error'] = esc_html__( 'Invalid API version.', 'give' ); |
|
495 | + $error['error'] = esc_html__('Invalid API version.', 'give'); |
|
496 | 496 | |
497 | 497 | $this->data = $error; |
498 | - $this->output( 404 ); |
|
498 | + $this->output(404); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | /** |
@@ -511,10 +511,10 @@ discard block |
||
511 | 511 | global $wp_query; |
512 | 512 | |
513 | 513 | // Start logging how long the request takes for logging |
514 | - $before = microtime( true ); |
|
514 | + $before = microtime(true); |
|
515 | 515 | |
516 | 516 | // Check for give-api var. Get out if not present |
517 | - if ( empty( $wp_query->query_vars['give-api'] ) ) { |
|
517 | + if (empty($wp_query->query_vars['give-api'])) { |
|
518 | 518 | return; |
519 | 519 | } |
520 | 520 | |
@@ -528,45 +528,45 @@ discard block |
||
528 | 528 | $this->validate_request(); |
529 | 529 | |
530 | 530 | // Only proceed if no errors have been noted |
531 | - if ( ! $this->is_valid_request ) { |
|
531 | + if ( ! $this->is_valid_request) { |
|
532 | 532 | return; |
533 | 533 | } |
534 | 534 | |
535 | - if ( ! defined( 'GIVE_DOING_API' ) ) { |
|
536 | - define( 'GIVE_DOING_API', true ); |
|
535 | + if ( ! defined('GIVE_DOING_API')) { |
|
536 | + define('GIVE_DOING_API', true); |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | $data = array(); |
540 | 540 | $this->routes = new $this->versions[$this->get_queried_version()]; |
541 | 541 | $this->routes->validate_request(); |
542 | 542 | |
543 | - switch ( $this->endpoint ) : |
|
543 | + switch ($this->endpoint) : |
|
544 | 544 | |
545 | 545 | case 'stats' : |
546 | 546 | |
547 | - $data = $this->routes->get_stats( array( |
|
548 | - 'type' => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null, |
|
549 | - 'form' => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null, |
|
550 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
551 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
552 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, |
|
553 | - ) ); |
|
547 | + $data = $this->routes->get_stats(array( |
|
548 | + 'type' => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null, |
|
549 | + 'form' => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null, |
|
550 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
551 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
552 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, |
|
553 | + )); |
|
554 | 554 | |
555 | 555 | break; |
556 | 556 | |
557 | 557 | case 'forms' : |
558 | 558 | |
559 | - $form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null; |
|
559 | + $form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null; |
|
560 | 560 | |
561 | - $data = $this->routes->get_forms( $form ); |
|
561 | + $data = $this->routes->get_forms($form); |
|
562 | 562 | |
563 | 563 | break; |
564 | 564 | |
565 | 565 | case 'donors' : |
566 | 566 | |
567 | - $donor = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null; |
|
567 | + $donor = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null; |
|
568 | 568 | |
569 | - $data = $this->routes->get_donors( $donor ); |
|
569 | + $data = $this->routes->get_donors($donor); |
|
570 | 570 | |
571 | 571 | break; |
572 | 572 | |
@@ -579,25 +579,25 @@ discard block |
||
579 | 579 | * @params date startdate | required when date = range and format to be YYYYMMDD (i.e. 20170524) |
580 | 580 | * @params date enddate | required when date = range and format to be YYYYMMDD (i.e. 20170524) |
581 | 581 | */ |
582 | - $data = $this->routes->get_recent_donations( array( |
|
583 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
584 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
585 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, |
|
586 | - ) ); |
|
582 | + $data = $this->routes->get_recent_donations(array( |
|
583 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
584 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
585 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, |
|
586 | + )); |
|
587 | 587 | |
588 | 588 | break; |
589 | 589 | |
590 | 590 | endswitch; |
591 | 591 | |
592 | 592 | // Allow extensions to setup their own return data |
593 | - $this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this ); |
|
593 | + $this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this); |
|
594 | 594 | |
595 | - $after = microtime( true ); |
|
596 | - $request_time = ( $after - $before ); |
|
595 | + $after = microtime(true); |
|
596 | + $request_time = ($after - $before); |
|
597 | 597 | $this->data['request_speed'] = $request_time; |
598 | 598 | |
599 | 599 | // Log this API request, if enabled. We log it here because we have access to errors. |
600 | - $this->log_request( $this->data ); |
|
600 | + $this->log_request($this->data); |
|
601 | 601 | |
602 | 602 | // Send out data to the output function |
603 | 603 | $this->output(); |
@@ -627,25 +627,25 @@ discard block |
||
627 | 627 | global $wp_query; |
628 | 628 | |
629 | 629 | // Whitelist our query options |
630 | - $accepted = apply_filters( 'give_api_valid_query_modes', array( |
|
630 | + $accepted = apply_filters('give_api_valid_query_modes', array( |
|
631 | 631 | 'stats', |
632 | 632 | 'forms', |
633 | 633 | 'donors', |
634 | 634 | 'donations', |
635 | - ) ); |
|
635 | + )); |
|
636 | 636 | |
637 | - $query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null; |
|
638 | - $query = str_replace( $this->queried_version . '/', '', $query ); |
|
637 | + $query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null; |
|
638 | + $query = str_replace($this->queried_version.'/', '', $query); |
|
639 | 639 | |
640 | 640 | $error = array(); |
641 | 641 | |
642 | 642 | // Make sure our query is valid |
643 | - if ( ! in_array( $query, $accepted ) ) { |
|
644 | - $error['error'] = esc_html__( 'Invalid query.', 'give' ); |
|
643 | + if ( ! in_array($query, $accepted)) { |
|
644 | + $error['error'] = esc_html__('Invalid query.', 'give'); |
|
645 | 645 | |
646 | 646 | $this->data = $error; |
647 | 647 | // 400 is Bad Request |
648 | - $this->output( 400 ); |
|
648 | + $this->output(400); |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | $this->endpoint = $query; |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | public function get_paged() { |
663 | 663 | global $wp_query; |
664 | 664 | |
665 | - return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1; |
|
665 | + return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1; |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | |
@@ -677,13 +677,13 @@ discard block |
||
677 | 677 | public function per_page() { |
678 | 678 | global $wp_query; |
679 | 679 | |
680 | - $per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10; |
|
680 | + $per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10; |
|
681 | 681 | |
682 | - if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) { |
|
682 | + if ($per_page < 0 && $this->get_query_mode() == 'donors') { |
|
683 | 683 | $per_page = 99999999; |
684 | 684 | } // End if(). |
685 | 685 | |
686 | - return apply_filters( 'give_api_results_per_page', $per_page ); |
|
686 | + return apply_filters('give_api_results_per_page', $per_page); |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | /** |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | * |
697 | 697 | * @return array $dates |
698 | 698 | */ |
699 | - public function get_dates( $args = array() ) { |
|
699 | + public function get_dates($args = array()) { |
|
700 | 700 | $dates = array(); |
701 | 701 | |
702 | 702 | $defaults = array( |
@@ -707,60 +707,60 @@ discard block |
||
707 | 707 | 'enddate' => null, |
708 | 708 | ); |
709 | 709 | |
710 | - $args = wp_parse_args( $args, $defaults ); |
|
710 | + $args = wp_parse_args($args, $defaults); |
|
711 | 711 | |
712 | - $current_time = current_time( 'timestamp' ); |
|
712 | + $current_time = current_time('timestamp'); |
|
713 | 713 | |
714 | - if ( 'range' === $args['date'] ) { |
|
715 | - $startdate = strtotime( $args['startdate'] ); |
|
716 | - $enddate = strtotime( $args['enddate'] ); |
|
717 | - $dates['day_start'] = date( 'd', $startdate ); |
|
718 | - $dates['day_end'] = date( 'd', $enddate ); |
|
719 | - $dates['m_start'] = date( 'n', $startdate ); |
|
720 | - $dates['m_end'] = date( 'n', $enddate ); |
|
721 | - $dates['year'] = date( 'Y', $startdate ); |
|
722 | - $dates['year_end'] = date( 'Y', $enddate ); |
|
714 | + if ('range' === $args['date']) { |
|
715 | + $startdate = strtotime($args['startdate']); |
|
716 | + $enddate = strtotime($args['enddate']); |
|
717 | + $dates['day_start'] = date('d', $startdate); |
|
718 | + $dates['day_end'] = date('d', $enddate); |
|
719 | + $dates['m_start'] = date('n', $startdate); |
|
720 | + $dates['m_end'] = date('n', $enddate); |
|
721 | + $dates['year'] = date('Y', $startdate); |
|
722 | + $dates['year_end'] = date('Y', $enddate); |
|
723 | 723 | } else { |
724 | 724 | // Modify dates based on predefined ranges |
725 | - switch ( $args['date'] ) : |
|
725 | + switch ($args['date']) : |
|
726 | 726 | |
727 | 727 | case 'this_month' : |
728 | 728 | $dates['day'] = null; |
729 | - $dates['m_start'] = date( 'n', $current_time ); |
|
730 | - $dates['m_end'] = date( 'n', $current_time ); |
|
731 | - $dates['year'] = date( 'Y', $current_time ); |
|
729 | + $dates['m_start'] = date('n', $current_time); |
|
730 | + $dates['m_end'] = date('n', $current_time); |
|
731 | + $dates['year'] = date('Y', $current_time); |
|
732 | 732 | break; |
733 | 733 | |
734 | 734 | case 'last_month' : |
735 | 735 | $dates['day'] = null; |
736 | - $dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1; |
|
736 | + $dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1; |
|
737 | 737 | $dates['m_end'] = $dates['m_start']; |
738 | - $dates['year'] = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time ); |
|
738 | + $dates['year'] = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time); |
|
739 | 739 | break; |
740 | 740 | |
741 | 741 | case 'today' : |
742 | - $dates['day'] = date( 'd', $current_time ); |
|
743 | - $dates['m_start'] = date( 'n', $current_time ); |
|
744 | - $dates['m_end'] = date( 'n', $current_time ); |
|
745 | - $dates['year'] = date( 'Y', $current_time ); |
|
742 | + $dates['day'] = date('d', $current_time); |
|
743 | + $dates['m_start'] = date('n', $current_time); |
|
744 | + $dates['m_end'] = date('n', $current_time); |
|
745 | + $dates['year'] = date('Y', $current_time); |
|
746 | 746 | break; |
747 | 747 | |
748 | 748 | case 'yesterday' : |
749 | 749 | |
750 | - $year = date( 'Y', $current_time ); |
|
751 | - $month = date( 'n', $current_time ); |
|
752 | - $day = date( 'd', $current_time ); |
|
750 | + $year = date('Y', $current_time); |
|
751 | + $month = date('n', $current_time); |
|
752 | + $day = date('d', $current_time); |
|
753 | 753 | |
754 | - if ( $month == 1 && $day == 1 ) { |
|
754 | + if ($month == 1 && $day == 1) { |
|
755 | 755 | |
756 | - $year -= 1; |
|
756 | + $year -= 1; |
|
757 | 757 | $month = 12; |
758 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
758 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
759 | 759 | |
760 | - } elseif ( $month > 1 && $day == 1 ) { |
|
760 | + } elseif ($month > 1 && $day == 1) { |
|
761 | 761 | |
762 | 762 | $month -= 1; |
763 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
763 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
764 | 764 | |
765 | 765 | } else { |
766 | 766 | |
@@ -776,65 +776,65 @@ discard block |
||
776 | 776 | break; |
777 | 777 | |
778 | 778 | case 'this_quarter' : |
779 | - $month_now = date( 'n', $current_time ); |
|
779 | + $month_now = date('n', $current_time); |
|
780 | 780 | |
781 | 781 | $dates['day'] = null; |
782 | 782 | |
783 | - if ( $month_now <= 3 ) { |
|
783 | + if ($month_now <= 3) { |
|
784 | 784 | |
785 | 785 | $dates['m_start'] = 1; |
786 | 786 | $dates['m_end'] = 3; |
787 | - $dates['year'] = date( 'Y', $current_time ); |
|
787 | + $dates['year'] = date('Y', $current_time); |
|
788 | 788 | |
789 | - } elseif ( $month_now <= 6 ) { |
|
789 | + } elseif ($month_now <= 6) { |
|
790 | 790 | |
791 | 791 | $dates['m_start'] = 4; |
792 | 792 | $dates['m_end'] = 6; |
793 | - $dates['year'] = date( 'Y', $current_time ); |
|
793 | + $dates['year'] = date('Y', $current_time); |
|
794 | 794 | |
795 | - } elseif ( $month_now <= 9 ) { |
|
795 | + } elseif ($month_now <= 9) { |
|
796 | 796 | |
797 | 797 | $dates['m_start'] = 7; |
798 | 798 | $dates['m_end'] = 9; |
799 | - $dates['year'] = date( 'Y', $current_time ); |
|
799 | + $dates['year'] = date('Y', $current_time); |
|
800 | 800 | |
801 | 801 | } else { |
802 | 802 | |
803 | 803 | $dates['m_start'] = 10; |
804 | 804 | $dates['m_end'] = 12; |
805 | - $dates['year'] = date( 'Y', $current_time ); |
|
805 | + $dates['year'] = date('Y', $current_time); |
|
806 | 806 | |
807 | 807 | } |
808 | 808 | break; |
809 | 809 | |
810 | 810 | case 'last_quarter' : |
811 | - $month_now = date( 'n', $current_time ); |
|
811 | + $month_now = date('n', $current_time); |
|
812 | 812 | |
813 | 813 | $dates['day'] = null; |
814 | 814 | |
815 | - if ( $month_now <= 3 ) { |
|
815 | + if ($month_now <= 3) { |
|
816 | 816 | |
817 | 817 | $dates['m_start'] = 10; |
818 | 818 | $dates['m_end'] = 12; |
819 | - $dates['year'] = date( 'Y', $current_time ) - 1; // Previous year |
|
819 | + $dates['year'] = date('Y', $current_time) - 1; // Previous year |
|
820 | 820 | |
821 | - } elseif ( $month_now <= 6 ) { |
|
821 | + } elseif ($month_now <= 6) { |
|
822 | 822 | |
823 | 823 | $dates['m_start'] = 1; |
824 | 824 | $dates['m_end'] = 3; |
825 | - $dates['year'] = date( 'Y', $current_time ); |
|
825 | + $dates['year'] = date('Y', $current_time); |
|
826 | 826 | |
827 | - } elseif ( $month_now <= 9 ) { |
|
827 | + } elseif ($month_now <= 9) { |
|
828 | 828 | |
829 | 829 | $dates['m_start'] = 4; |
830 | 830 | $dates['m_end'] = 6; |
831 | - $dates['year'] = date( 'Y', $current_time ); |
|
831 | + $dates['year'] = date('Y', $current_time); |
|
832 | 832 | |
833 | 833 | } else { |
834 | 834 | |
835 | 835 | $dates['m_start'] = 7; |
836 | 836 | $dates['m_end'] = 9; |
837 | - $dates['year'] = date( 'Y', $current_time ); |
|
837 | + $dates['year'] = date('Y', $current_time); |
|
838 | 838 | |
839 | 839 | } |
840 | 840 | break; |
@@ -843,14 +843,14 @@ discard block |
||
843 | 843 | $dates['day'] = null; |
844 | 844 | $dates['m_start'] = null; |
845 | 845 | $dates['m_end'] = null; |
846 | - $dates['year'] = date( 'Y', $current_time ); |
|
846 | + $dates['year'] = date('Y', $current_time); |
|
847 | 847 | break; |
848 | 848 | |
849 | 849 | case 'last_year' : |
850 | 850 | $dates['day'] = null; |
851 | 851 | $dates['m_start'] = null; |
852 | 852 | $dates['m_end'] = null; |
853 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
853 | + $dates['year'] = date('Y', $current_time) - 1; |
|
854 | 854 | break; |
855 | 855 | |
856 | 856 | endswitch; |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | * |
864 | 864 | * @param array $dates The dates used for retrieving earnings. |
865 | 865 | */ |
866 | - return apply_filters( 'give_api_stat_dates', $dates ); |
|
866 | + return apply_filters('give_api_stat_dates', $dates); |
|
867 | 867 | } |
868 | 868 | |
869 | 869 | /** |
@@ -877,78 +877,78 @@ discard block |
||
877 | 877 | * |
878 | 878 | * @return array $donors Multidimensional array of the donors. |
879 | 879 | */ |
880 | - public function get_donors( $donor = null ) { |
|
880 | + public function get_donors($donor = null) { |
|
881 | 881 | |
882 | 882 | $donors = array(); |
883 | 883 | $error = array(); |
884 | - if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) { |
|
884 | + if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) { |
|
885 | 885 | return $donors; |
886 | 886 | } |
887 | 887 | |
888 | 888 | $paged = $this->get_paged(); |
889 | 889 | $per_page = $this->per_page(); |
890 | - $offset = $per_page * ( $paged - 1 ); |
|
890 | + $offset = $per_page * ($paged - 1); |
|
891 | 891 | |
892 | - if ( is_numeric( $donor ) ) { |
|
892 | + if (is_numeric($donor)) { |
|
893 | 893 | $field = 'id'; |
894 | 894 | } else { |
895 | 895 | $field = 'email'; |
896 | 896 | } |
897 | 897 | |
898 | - $donor_query = Give()->donors->get_donors( array( |
|
898 | + $donor_query = Give()->donors->get_donors(array( |
|
899 | 899 | 'number' => $per_page, |
900 | 900 | 'offset' => $offset, |
901 | 901 | $field => $donor, |
902 | - ) ); |
|
902 | + )); |
|
903 | 903 | $donor_count = 0; |
904 | 904 | |
905 | - if ( $donor_query ) { |
|
905 | + if ($donor_query) { |
|
906 | 906 | |
907 | - foreach ( $donor_query as $donor_obj ) { |
|
907 | + foreach ($donor_query as $donor_obj) { |
|
908 | 908 | |
909 | - $names = explode( ' ', $donor_obj->name ); |
|
910 | - $first_name = ! empty( $names[0] ) ? $names[0] : ''; |
|
909 | + $names = explode(' ', $donor_obj->name); |
|
910 | + $first_name = ! empty($names[0]) ? $names[0] : ''; |
|
911 | 911 | $last_name = ''; |
912 | - if ( ! empty( $names[1] ) ) { |
|
913 | - unset( $names[0] ); |
|
914 | - $last_name = implode( ' ', $names ); |
|
912 | + if ( ! empty($names[1])) { |
|
913 | + unset($names[0]); |
|
914 | + $last_name = implode(' ', $names); |
|
915 | 915 | } |
916 | 916 | |
917 | - $donors['donors'][ $donor_count ]['info']['user_id'] = ''; |
|
918 | - $donors['donors'][ $donor_count ]['info']['username'] = ''; |
|
919 | - $donors['donors'][ $donor_count ]['info']['display_name'] = ''; |
|
920 | - $donors['donors'][ $donor_count ]['info']['donor_id'] = $donor_obj->id; |
|
921 | - $donors['donors'][ $donor_count ]['info']['first_name'] = $first_name; |
|
922 | - $donors['donors'][ $donor_count ]['info']['last_name'] = $last_name; |
|
923 | - $donors['donors'][ $donor_count ]['info']['email'] = $donor_obj->email; |
|
917 | + $donors['donors'][$donor_count]['info']['user_id'] = ''; |
|
918 | + $donors['donors'][$donor_count]['info']['username'] = ''; |
|
919 | + $donors['donors'][$donor_count]['info']['display_name'] = ''; |
|
920 | + $donors['donors'][$donor_count]['info']['donor_id'] = $donor_obj->id; |
|
921 | + $donors['donors'][$donor_count]['info']['first_name'] = $first_name; |
|
922 | + $donors['donors'][$donor_count]['info']['last_name'] = $last_name; |
|
923 | + $donors['donors'][$donor_count]['info']['email'] = $donor_obj->email; |
|
924 | 924 | |
925 | - if ( ! empty( $donor_obj->user_id ) ) { |
|
925 | + if ( ! empty($donor_obj->user_id)) { |
|
926 | 926 | |
927 | - $user_data = get_userdata( $donor_obj->user_id ); |
|
927 | + $user_data = get_userdata($donor_obj->user_id); |
|
928 | 928 | |
929 | 929 | // Donor with registered account. |
930 | - $donors['donors'][ $donor_count ]['info']['user_id'] = $donor_obj->user_id; |
|
931 | - $donors['donors'][ $donor_count ]['info']['username'] = $user_data->user_login; |
|
932 | - $donors['donors'][ $donor_count ]['info']['display_name'] = $user_data->display_name; |
|
930 | + $donors['donors'][$donor_count]['info']['user_id'] = $donor_obj->user_id; |
|
931 | + $donors['donors'][$donor_count]['info']['username'] = $user_data->user_login; |
|
932 | + $donors['donors'][$donor_count]['info']['display_name'] = $user_data->display_name; |
|
933 | 933 | |
934 | 934 | } |
935 | 935 | |
936 | - $donors['donors'][ $donor_count ]['stats']['total_donations'] = $donor_obj->purchase_count; |
|
937 | - $donors['donors'][ $donor_count ]['stats']['total_spent'] = $donor_obj->purchase_value; |
|
936 | + $donors['donors'][$donor_count]['stats']['total_donations'] = $donor_obj->purchase_count; |
|
937 | + $donors['donors'][$donor_count]['stats']['total_spent'] = $donor_obj->purchase_value; |
|
938 | 938 | |
939 | - $donor_count ++; |
|
939 | + $donor_count++; |
|
940 | 940 | |
941 | 941 | } |
942 | - } elseif ( $donor ) { |
|
942 | + } elseif ($donor) { |
|
943 | 943 | |
944 | 944 | $error['error'] = sprintf( /* translators: %s: donor */ |
945 | - esc_html__( 'Donor %s not found.', 'give' ), $donor ); |
|
945 | + esc_html__('Donor %s not found.', 'give'), $donor ); |
|
946 | 946 | |
947 | 947 | return $error; |
948 | 948 | |
949 | 949 | } else { |
950 | 950 | |
951 | - $error['error'] = esc_html__( 'No donors found.', 'give' ); |
|
951 | + $error['error'] = esc_html__('No donors found.', 'give'); |
|
952 | 952 | |
953 | 953 | return $error; |
954 | 954 | |
@@ -967,37 +967,37 @@ discard block |
||
967 | 967 | * |
968 | 968 | * @return array $donors Multidimensional array of the forms. |
969 | 969 | */ |
970 | - public function get_forms( $form = null ) { |
|
970 | + public function get_forms($form = null) { |
|
971 | 971 | |
972 | 972 | $forms = array(); |
973 | 973 | $error = array(); |
974 | 974 | |
975 | - if ( $form == null ) { |
|
975 | + if ($form == null) { |
|
976 | 976 | $forms['forms'] = array(); |
977 | 977 | |
978 | - $form_list = get_posts( array( |
|
978 | + $form_list = get_posts(array( |
|
979 | 979 | 'post_type' => 'give_forms', |
980 | 980 | 'posts_per_page' => $this->per_page(), |
981 | 981 | 'suppress_filters' => true, |
982 | 982 | 'paged' => $this->get_paged(), |
983 | - ) ); |
|
983 | + )); |
|
984 | 984 | |
985 | - if ( $form_list ) { |
|
985 | + if ($form_list) { |
|
986 | 986 | $i = 0; |
987 | - foreach ( $form_list as $form_info ) { |
|
988 | - $forms['forms'][ $i ] = $this->get_form_data( $form_info ); |
|
989 | - $i ++; |
|
987 | + foreach ($form_list as $form_info) { |
|
988 | + $forms['forms'][$i] = $this->get_form_data($form_info); |
|
989 | + $i++; |
|
990 | 990 | } |
991 | 991 | } |
992 | 992 | } else { |
993 | - if ( get_post_type( $form ) == 'give_forms' ) { |
|
994 | - $form_info = get_post( $form ); |
|
993 | + if (get_post_type($form) == 'give_forms') { |
|
994 | + $form_info = get_post($form); |
|
995 | 995 | |
996 | - $forms['forms'][0] = $this->get_form_data( $form_info ); |
|
996 | + $forms['forms'][0] = $this->get_form_data($form_info); |
|
997 | 997 | |
998 | 998 | } else { |
999 | 999 | $error['error'] = sprintf( /* translators: %s: form */ |
1000 | - esc_html__( 'Form %s not found.', 'give' ), $form ); |
|
1000 | + esc_html__('Form %s not found.', 'give'), $form ); |
|
1001 | 1001 | |
1002 | 1002 | return $error; |
1003 | 1003 | } |
@@ -1015,7 +1015,7 @@ discard block |
||
1015 | 1015 | * |
1016 | 1016 | * @return array Array of post data to return back in the API. |
1017 | 1017 | */ |
1018 | - private function get_form_data( $form_info ) { |
|
1018 | + private function get_form_data($form_info) { |
|
1019 | 1019 | |
1020 | 1020 | $form = array(); |
1021 | 1021 | |
@@ -1025,60 +1025,60 @@ discard block |
||
1025 | 1025 | $form['info']['create_date'] = $form_info->post_date; |
1026 | 1026 | $form['info']['modified_date'] = $form_info->post_modified; |
1027 | 1027 | $form['info']['status'] = $form_info->post_status; |
1028 | - $form['info']['link'] = html_entity_decode( $form_info->guid ); |
|
1029 | - $form['info']['content'] = give_get_meta( $form_info->ID, '_give_form_content', true ); |
|
1030 | - $form['info']['thumbnail'] = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) ); |
|
1028 | + $form['info']['link'] = html_entity_decode($form_info->guid); |
|
1029 | + $form['info']['content'] = give_get_meta($form_info->ID, '_give_form_content', true); |
|
1030 | + $form['info']['thumbnail'] = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID)); |
|
1031 | 1031 | |
1032 | - if ( give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) { |
|
1033 | - $form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' ); |
|
1034 | - $form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' ); |
|
1032 | + if (give_is_setting_enabled(give_get_option('categories', 'disabled'))) { |
|
1033 | + $form['info']['category'] = get_the_terms($form_info, 'give_forms_category'); |
|
1034 | + $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag'); |
|
1035 | 1035 | } |
1036 | - if ( give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) { |
|
1037 | - $form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' ); |
|
1036 | + if (give_is_setting_enabled(give_get_option('tags', 'disabled'))) { |
|
1037 | + $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag'); |
|
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | // Check whether any goal is to be achieved for the donation form. |
1041 | - $goal_option = give_get_meta( $form_info->ID, '_give_goal_option', true ); |
|
1042 | - $goal_amount = give_get_meta( $form_info->ID, '_give_set_goal', true ); |
|
1043 | - if ( give_is_setting_enabled( $goal_option ) && $goal_amount ) { |
|
1044 | - $total_income = give_get_form_earnings_stats( $form_info->ID ); |
|
1045 | - $goal_percentage_completed = ( $total_income < $goal_amount ) ? round( ( $total_income / $goal_amount ) * 100, 2 ) : 100; |
|
1046 | - $form['goal']['amount'] = isset( $goal_amount ) ? $goal_amount : ''; |
|
1047 | - $form['goal']['percentage_completed'] = isset( $goal_percentage_completed ) ? $goal_percentage_completed : ''; |
|
1041 | + $goal_option = give_get_meta($form_info->ID, '_give_goal_option', true); |
|
1042 | + $goal_amount = give_get_meta($form_info->ID, '_give_set_goal', true); |
|
1043 | + if (give_is_setting_enabled($goal_option) && $goal_amount) { |
|
1044 | + $total_income = give_get_form_earnings_stats($form_info->ID); |
|
1045 | + $goal_percentage_completed = ($total_income < $goal_amount) ? round(($total_income / $goal_amount) * 100, 2) : 100; |
|
1046 | + $form['goal']['amount'] = isset($goal_amount) ? $goal_amount : ''; |
|
1047 | + $form['goal']['percentage_completed'] = isset($goal_percentage_completed) ? $goal_percentage_completed : ''; |
|
1048 | 1048 | } |
1049 | 1049 | |
1050 | - if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) { |
|
1051 | - $form['stats']['total']['donations'] = give_get_form_sales_stats( $form_info->ID ); |
|
1052 | - $form['stats']['total']['earnings'] = give_get_form_earnings_stats( $form_info->ID ); |
|
1053 | - $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID ); |
|
1054 | - $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings( $form_info->ID ); |
|
1050 | + if (user_can($this->user_id, 'view_give_reports') || $this->override) { |
|
1051 | + $form['stats']['total']['donations'] = give_get_form_sales_stats($form_info->ID); |
|
1052 | + $form['stats']['total']['earnings'] = give_get_form_earnings_stats($form_info->ID); |
|
1053 | + $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID); |
|
1054 | + $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings($form_info->ID); |
|
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | $counter = 0; |
1058 | - if ( give_has_variable_prices( $form_info->ID ) ) { |
|
1059 | - foreach ( give_get_variable_prices( $form_info->ID ) as $price ) { |
|
1060 | - $counter ++; |
|
1058 | + if (give_has_variable_prices($form_info->ID)) { |
|
1059 | + foreach (give_get_variable_prices($form_info->ID) as $price) { |
|
1060 | + $counter++; |
|
1061 | 1061 | // multi-level item |
1062 | - $level = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter; |
|
1063 | - $form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount']; |
|
1062 | + $level = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter; |
|
1063 | + $form['pricing'][sanitize_key($level)] = $price['_give_amount']; |
|
1064 | 1064 | |
1065 | 1065 | } |
1066 | 1066 | } else { |
1067 | - $form['pricing']['amount'] = give_get_form_price( $form_info->ID ); |
|
1067 | + $form['pricing']['amount'] = give_get_form_price($form_info->ID); |
|
1068 | 1068 | } |
1069 | 1069 | |
1070 | - if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) { |
|
1070 | + if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) { |
|
1071 | 1071 | |
1072 | 1072 | /** |
1073 | 1073 | * Fires when generating API sensitive data. |
1074 | 1074 | * |
1075 | 1075 | * @since 1.1 |
1076 | 1076 | */ |
1077 | - do_action( 'give_api_sensitive_data' ); |
|
1077 | + do_action('give_api_sensitive_data'); |
|
1078 | 1078 | |
1079 | 1079 | } |
1080 | 1080 | |
1081 | - return apply_filters( 'give_api_forms_form', $form ); |
|
1081 | + return apply_filters('give_api_forms_form', $form); |
|
1082 | 1082 | |
1083 | 1083 | } |
1084 | 1084 | |
@@ -1093,7 +1093,7 @@ discard block |
||
1093 | 1093 | * |
1094 | 1094 | * @return array |
1095 | 1095 | */ |
1096 | - public function get_stats( $args = array() ) { |
|
1096 | + public function get_stats($args = array()) { |
|
1097 | 1097 | $defaults = array( |
1098 | 1098 | 'type' => null, |
1099 | 1099 | 'form' => null, |
@@ -1102,9 +1102,9 @@ discard block |
||
1102 | 1102 | 'enddate' => null, |
1103 | 1103 | ); |
1104 | 1104 | |
1105 | - $args = wp_parse_args( $args, $defaults ); |
|
1105 | + $args = wp_parse_args($args, $defaults); |
|
1106 | 1106 | |
1107 | - $dates = $this->get_dates( $args ); |
|
1107 | + $dates = $this->get_dates($args); |
|
1108 | 1108 | |
1109 | 1109 | $stats = array(); |
1110 | 1110 | $earnings = array( |
@@ -1115,40 +1115,40 @@ discard block |
||
1115 | 1115 | ); |
1116 | 1116 | $error = array(); |
1117 | 1117 | |
1118 | - if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) { |
|
1118 | + if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) { |
|
1119 | 1119 | return $stats; |
1120 | 1120 | } |
1121 | 1121 | |
1122 | - if ( $args['type'] == 'donations' ) { |
|
1122 | + if ($args['type'] == 'donations') { |
|
1123 | 1123 | |
1124 | - if ( $args['form'] == null ) { |
|
1125 | - if ( $args['date'] == null ) { |
|
1124 | + if ($args['form'] == null) { |
|
1125 | + if ($args['date'] == null) { |
|
1126 | 1126 | $sales = $this->get_default_sales_stats(); |
1127 | - } elseif ( $args['date'] === 'range' ) { |
|
1127 | + } elseif ($args['date'] === 'range') { |
|
1128 | 1128 | // Return donations for a date range. |
1129 | 1129 | // Ensure the end date is later than the start date. |
1130 | - if ( $args['enddate'] < $args['startdate'] ) { |
|
1131 | - $error['error'] = esc_html__( 'The end date must be later than the start date.', 'give' ); |
|
1130 | + if ($args['enddate'] < $args['startdate']) { |
|
1131 | + $error['error'] = esc_html__('The end date must be later than the start date.', 'give'); |
|
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | // Ensure both the start and end date are specified |
1135 | - if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) { |
|
1136 | - $error['error'] = esc_html__( 'Invalid or no date range specified.', 'give' ); |
|
1135 | + if (empty($args['startdate']) || empty($args['enddate'])) { |
|
1136 | + $error['error'] = esc_html__('Invalid or no date range specified.', 'give'); |
|
1137 | 1137 | } |
1138 | 1138 | |
1139 | 1139 | $total = 0; |
1140 | 1140 | |
1141 | 1141 | // Loop through the years |
1142 | 1142 | $y = $dates['year']; |
1143 | - while ( $y <= $dates['year_end'] ) : |
|
1143 | + while ($y <= $dates['year_end']) : |
|
1144 | 1144 | |
1145 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
1145 | + if ($dates['year'] == $dates['year_end']) { |
|
1146 | 1146 | $month_start = $dates['m_start']; |
1147 | 1147 | $month_end = $dates['m_end']; |
1148 | - } elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { |
|
1148 | + } elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) { |
|
1149 | 1149 | $month_start = $dates['m_start']; |
1150 | 1150 | $month_end = 12; |
1151 | - } elseif ( $y == $dates['year_end'] ) { |
|
1151 | + } elseif ($y == $dates['year_end']) { |
|
1152 | 1152 | $month_start = 1; |
1153 | 1153 | $month_end = $dates['m_end']; |
1154 | 1154 | } else { |
@@ -1157,116 +1157,116 @@ discard block |
||
1157 | 1157 | } |
1158 | 1158 | |
1159 | 1159 | $i = $month_start; |
1160 | - while ( $i <= $month_end ) : |
|
1160 | + while ($i <= $month_end) : |
|
1161 | 1161 | |
1162 | - if ( $i == $dates['m_start'] ) { |
|
1162 | + if ($i == $dates['m_start']) { |
|
1163 | 1163 | $d = $dates['day_start']; |
1164 | 1164 | } else { |
1165 | 1165 | $d = 1; |
1166 | 1166 | } |
1167 | 1167 | |
1168 | - if ( $i == $dates['m_end'] ) { |
|
1168 | + if ($i == $dates['m_end']) { |
|
1169 | 1169 | $num_of_days = $dates['day_end']; |
1170 | 1170 | } else { |
1171 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
1171 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
1172 | 1172 | } |
1173 | 1173 | |
1174 | - while ( $d <= $num_of_days ) : |
|
1175 | - $sale_count = give_get_sales_by_date( $d, $i, $y ); |
|
1176 | - $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); |
|
1177 | - if ( ! isset( $sales['sales'][ $date_key ] ) ) { |
|
1178 | - $sales['sales'][ $date_key ] = 0; |
|
1174 | + while ($d <= $num_of_days) : |
|
1175 | + $sale_count = give_get_sales_by_date($d, $i, $y); |
|
1176 | + $date_key = date('Ymd', strtotime($y.'/'.$i.'/'.$d)); |
|
1177 | + if ( ! isset($sales['sales'][$date_key])) { |
|
1178 | + $sales['sales'][$date_key] = 0; |
|
1179 | 1179 | } |
1180 | - $sales['sales'][ $date_key ] += $sale_count; |
|
1180 | + $sales['sales'][$date_key] += $sale_count; |
|
1181 | 1181 | $total += $sale_count; |
1182 | - $d ++; |
|
1182 | + $d++; |
|
1183 | 1183 | endwhile; |
1184 | - $i ++; |
|
1184 | + $i++; |
|
1185 | 1185 | endwhile; |
1186 | 1186 | |
1187 | - $y ++; |
|
1187 | + $y++; |
|
1188 | 1188 | endwhile; |
1189 | 1189 | |
1190 | 1190 | $sales['totals'] = $total; |
1191 | 1191 | } else { |
1192 | - if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) { |
|
1192 | + if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') { |
|
1193 | 1193 | $sales_count = 0; |
1194 | 1194 | |
1195 | 1195 | // Loop through the months |
1196 | 1196 | $month = $dates['m_start']; |
1197 | 1197 | |
1198 | - while ( $month <= $dates['m_end'] ) : |
|
1199 | - $sales_count += give_get_sales_by_date( null, $month, $dates['year'] ); |
|
1200 | - $month ++; |
|
1198 | + while ($month <= $dates['m_end']) : |
|
1199 | + $sales_count += give_get_sales_by_date(null, $month, $dates['year']); |
|
1200 | + $month++; |
|
1201 | 1201 | endwhile; |
1202 | 1202 | |
1203 | - $sales['donations'][ $args['date'] ] = $sales_count; |
|
1203 | + $sales['donations'][$args['date']] = $sales_count; |
|
1204 | 1204 | } else { |
1205 | - $sales['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] ); |
|
1205 | + $sales['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']); |
|
1206 | 1206 | } |
1207 | 1207 | }// End if(). |
1208 | - } elseif ( $args['form'] == 'all' ) { |
|
1209 | - $forms = get_posts( array( |
|
1208 | + } elseif ($args['form'] == 'all') { |
|
1209 | + $forms = get_posts(array( |
|
1210 | 1210 | 'post_type' => 'give_forms', |
1211 | 1211 | 'nopaging' => true, |
1212 | - ) ); |
|
1213 | - $i = 0; |
|
1214 | - foreach ( $forms as $form_info ) { |
|
1215 | - $sales['donations'][ $i ] = array( |
|
1216 | - $form_info->post_name => give_get_form_sales_stats( $form_info->ID ), |
|
1212 | + )); |
|
1213 | + $i = 0; |
|
1214 | + foreach ($forms as $form_info) { |
|
1215 | + $sales['donations'][$i] = array( |
|
1216 | + $form_info->post_name => give_get_form_sales_stats($form_info->ID), |
|
1217 | 1217 | ); |
1218 | - $i ++; |
|
1218 | + $i++; |
|
1219 | 1219 | } |
1220 | 1220 | } else { |
1221 | - if ( get_post_type( $args['form'] ) == 'give_forms' ) { |
|
1222 | - $form_info = get_post( $args['form'] ); |
|
1221 | + if (get_post_type($args['form']) == 'give_forms') { |
|
1222 | + $form_info = get_post($args['form']); |
|
1223 | 1223 | $sales['donations'][0] = array( |
1224 | - $form_info->post_name => give_get_form_sales_stats( $args['form'] ), |
|
1224 | + $form_info->post_name => give_get_form_sales_stats($args['form']), |
|
1225 | 1225 | ); |
1226 | 1226 | } else { |
1227 | 1227 | $error['error'] = sprintf( /* translators: %s: form */ |
1228 | - esc_html__( 'Form %s not found.', 'give' ), $args['form'] ); |
|
1228 | + esc_html__('Form %s not found.', 'give'), $args['form'] ); |
|
1229 | 1229 | } |
1230 | 1230 | }// End if(). |
1231 | 1231 | |
1232 | - if ( ! empty( $error ) ) { |
|
1232 | + if ( ! empty($error)) { |
|
1233 | 1233 | return $error; |
1234 | 1234 | } |
1235 | 1235 | |
1236 | 1236 | return $sales; |
1237 | 1237 | |
1238 | - } elseif ( $args['type'] == 'earnings' ) { |
|
1239 | - if ( $args['form'] == null ) { |
|
1240 | - if ( $args['date'] == null ) { |
|
1238 | + } elseif ($args['type'] == 'earnings') { |
|
1239 | + if ($args['form'] == null) { |
|
1240 | + if ($args['date'] == null) { |
|
1241 | 1241 | $earnings = $this->get_default_earnings_stats(); |
1242 | - } elseif ( $args['date'] === 'range' ) { |
|
1242 | + } elseif ($args['date'] === 'range') { |
|
1243 | 1243 | // Return sales for a date range |
1244 | 1244 | // Ensure the end date is later than the start date |
1245 | - if ( $args['enddate'] < $args['startdate'] ) { |
|
1246 | - $error['error'] = esc_html__( 'The end date must be later than the start date.', 'give' ); |
|
1245 | + if ($args['enddate'] < $args['startdate']) { |
|
1246 | + $error['error'] = esc_html__('The end date must be later than the start date.', 'give'); |
|
1247 | 1247 | } |
1248 | 1248 | |
1249 | 1249 | // Ensure both the start and end date are specified |
1250 | - if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) { |
|
1251 | - $error['error'] = esc_html__( 'Invalid or no date range specified.', 'give' ); |
|
1250 | + if (empty($args['startdate']) || empty($args['enddate'])) { |
|
1251 | + $error['error'] = esc_html__('Invalid or no date range specified.', 'give'); |
|
1252 | 1252 | } |
1253 | 1253 | |
1254 | 1254 | $total = (float) 0.00; |
1255 | 1255 | |
1256 | 1256 | // Loop through the years |
1257 | 1257 | $y = $dates['year']; |
1258 | - if ( ! isset( $earnings['earnings'] ) ) { |
|
1258 | + if ( ! isset($earnings['earnings'])) { |
|
1259 | 1259 | $earnings['earnings'] = array(); |
1260 | 1260 | } |
1261 | - while ( $y <= $dates['year_end'] ) : |
|
1261 | + while ($y <= $dates['year_end']) : |
|
1262 | 1262 | |
1263 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
1263 | + if ($dates['year'] == $dates['year_end']) { |
|
1264 | 1264 | $month_start = $dates['m_start']; |
1265 | 1265 | $month_end = $dates['m_end']; |
1266 | - } elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { |
|
1266 | + } elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) { |
|
1267 | 1267 | $month_start = $dates['m_start']; |
1268 | 1268 | $month_end = 12; |
1269 | - } elseif ( $y == $dates['year_end'] ) { |
|
1269 | + } elseif ($y == $dates['year_end']) { |
|
1270 | 1270 | $month_start = 1; |
1271 | 1271 | $month_end = $dates['m_end']; |
1272 | 1272 | } else { |
@@ -1275,94 +1275,94 @@ discard block |
||
1275 | 1275 | } |
1276 | 1276 | |
1277 | 1277 | $i = $month_start; |
1278 | - while ( $i <= $month_end ) : |
|
1278 | + while ($i <= $month_end) : |
|
1279 | 1279 | |
1280 | - if ( $i == $dates['m_start'] ) { |
|
1280 | + if ($i == $dates['m_start']) { |
|
1281 | 1281 | $d = $dates['day_start']; |
1282 | 1282 | } else { |
1283 | 1283 | $d = 1; |
1284 | 1284 | } |
1285 | 1285 | |
1286 | - if ( $i == $dates['m_end'] ) { |
|
1286 | + if ($i == $dates['m_end']) { |
|
1287 | 1287 | $num_of_days = $dates['day_end']; |
1288 | 1288 | } else { |
1289 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
1289 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
1290 | 1290 | } |
1291 | 1291 | |
1292 | - while ( $d <= $num_of_days ) : |
|
1293 | - $earnings_stat = give_get_earnings_by_date( $d, $i, $y ); |
|
1294 | - $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); |
|
1295 | - if ( ! isset( $earnings['earnings'][ $date_key ] ) ) { |
|
1296 | - $earnings['earnings'][ $date_key ] = 0; |
|
1292 | + while ($d <= $num_of_days) : |
|
1293 | + $earnings_stat = give_get_earnings_by_date($d, $i, $y); |
|
1294 | + $date_key = date('Ymd', strtotime($y.'/'.$i.'/'.$d)); |
|
1295 | + if ( ! isset($earnings['earnings'][$date_key])) { |
|
1296 | + $earnings['earnings'][$date_key] = 0; |
|
1297 | 1297 | } |
1298 | - $earnings['earnings'][ $date_key ] += $earnings_stat; |
|
1298 | + $earnings['earnings'][$date_key] += $earnings_stat; |
|
1299 | 1299 | $total += $earnings_stat; |
1300 | - $d ++; |
|
1300 | + $d++; |
|
1301 | 1301 | endwhile; |
1302 | 1302 | |
1303 | - $i ++; |
|
1303 | + $i++; |
|
1304 | 1304 | endwhile; |
1305 | 1305 | |
1306 | - $y ++; |
|
1306 | + $y++; |
|
1307 | 1307 | endwhile; |
1308 | 1308 | |
1309 | 1309 | $earnings['totals'] = $total; |
1310 | 1310 | } else { |
1311 | - if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) { |
|
1311 | + if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') { |
|
1312 | 1312 | $earnings_count = (float) 0.00; |
1313 | 1313 | |
1314 | 1314 | // Loop through the months |
1315 | 1315 | $month = $dates['m_start']; |
1316 | 1316 | |
1317 | - while ( $month <= $dates['m_end'] ) : |
|
1318 | - $earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] ); |
|
1319 | - $month ++; |
|
1317 | + while ($month <= $dates['m_end']) : |
|
1318 | + $earnings_count += give_get_earnings_by_date(null, $month, $dates['year']); |
|
1319 | + $month++; |
|
1320 | 1320 | endwhile; |
1321 | 1321 | |
1322 | - $earnings['earnings'][ $args['date'] ] = $earnings_count; |
|
1322 | + $earnings['earnings'][$args['date']] = $earnings_count; |
|
1323 | 1323 | } else { |
1324 | - $earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] ); |
|
1324 | + $earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']); |
|
1325 | 1325 | } |
1326 | 1326 | }// End if(). |
1327 | - } elseif ( $args['form'] == 'all' ) { |
|
1328 | - $forms = get_posts( array( |
|
1327 | + } elseif ($args['form'] == 'all') { |
|
1328 | + $forms = get_posts(array( |
|
1329 | 1329 | 'post_type' => 'give_forms', |
1330 | 1330 | 'nopaging' => true, |
1331 | - ) ); |
|
1331 | + )); |
|
1332 | 1332 | |
1333 | 1333 | $i = 0; |
1334 | - foreach ( $forms as $form_info ) { |
|
1335 | - $earnings['earnings'][ $i ] = array( |
|
1336 | - $form_info->post_name => give_get_form_earnings_stats( $form_info->ID ), |
|
1334 | + foreach ($forms as $form_info) { |
|
1335 | + $earnings['earnings'][$i] = array( |
|
1336 | + $form_info->post_name => give_get_form_earnings_stats($form_info->ID), |
|
1337 | 1337 | ); |
1338 | - $i ++; |
|
1338 | + $i++; |
|
1339 | 1339 | } |
1340 | 1340 | } else { |
1341 | - if ( get_post_type( $args['form'] ) == 'give_forms' ) { |
|
1342 | - $form_info = get_post( $args['form'] ); |
|
1341 | + if (get_post_type($args['form']) == 'give_forms') { |
|
1342 | + $form_info = get_post($args['form']); |
|
1343 | 1343 | $earnings['earnings'][0] = array( |
1344 | - $form_info->post_name => give_get_form_earnings_stats( $args['form'] ), |
|
1344 | + $form_info->post_name => give_get_form_earnings_stats($args['form']), |
|
1345 | 1345 | ); |
1346 | 1346 | } else { |
1347 | 1347 | $error['error'] = sprintf( /* translators: %s: form */ |
1348 | - esc_html__( 'Form %s not found.', 'give' ), $args['form'] ); |
|
1348 | + esc_html__('Form %s not found.', 'give'), $args['form'] ); |
|
1349 | 1349 | } |
1350 | 1350 | }// End if(). |
1351 | 1351 | |
1352 | - if ( ! empty( $error ) ) { |
|
1352 | + if ( ! empty($error)) { |
|
1353 | 1353 | return $error; |
1354 | 1354 | } |
1355 | 1355 | |
1356 | 1356 | return $earnings; |
1357 | - } elseif ( $args['type'] == 'donors' ) { |
|
1357 | + } elseif ($args['type'] == 'donors') { |
|
1358 | 1358 | $donors = new Give_DB_Donors(); |
1359 | 1359 | $stats['donations']['total_donors'] = $donors->count(); |
1360 | 1360 | |
1361 | 1361 | return $stats; |
1362 | 1362 | |
1363 | - } elseif ( empty( $args['type'] ) ) { |
|
1364 | - $stats = array_merge( $stats, $this->get_default_sales_stats() ); |
|
1365 | - $stats = array_merge( $stats, $this->get_default_earnings_stats() ); |
|
1363 | + } elseif (empty($args['type'])) { |
|
1364 | + $stats = array_merge($stats, $this->get_default_sales_stats()); |
|
1365 | + $stats = array_merge($stats, $this->get_default_earnings_stats()); |
|
1366 | 1366 | |
1367 | 1367 | return array( |
1368 | 1368 | 'stats' => $stats, |
@@ -1380,7 +1380,7 @@ discard block |
||
1380 | 1380 | * |
1381 | 1381 | * @return array |
1382 | 1382 | */ |
1383 | - public function get_recent_donations( $args = array() ) { |
|
1383 | + public function get_recent_donations($args = array()) { |
|
1384 | 1384 | global $wp_query; |
1385 | 1385 | |
1386 | 1386 | $defaults = array( |
@@ -1389,22 +1389,22 @@ discard block |
||
1389 | 1389 | 'enddate' => null, |
1390 | 1390 | ); |
1391 | 1391 | |
1392 | - $args = wp_parse_args( $args, $defaults ); |
|
1392 | + $args = wp_parse_args($args, $defaults); |
|
1393 | 1393 | |
1394 | 1394 | $sales = array(); |
1395 | 1395 | |
1396 | - if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) { |
|
1396 | + if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) { |
|
1397 | 1397 | return $sales; |
1398 | 1398 | } |
1399 | 1399 | |
1400 | - if ( isset( $wp_query->query_vars['id'] ) ) { |
|
1400 | + if (isset($wp_query->query_vars['id'])) { |
|
1401 | 1401 | $query = array(); |
1402 | - $query[] = new Give_Payment( $wp_query->query_vars['id'] ); |
|
1403 | - } elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) { |
|
1402 | + $query[] = new Give_Payment($wp_query->query_vars['id']); |
|
1403 | + } elseif (isset($wp_query->query_vars['purchasekey'])) { |
|
1404 | 1404 | $query = array(); |
1405 | - $query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] ); |
|
1406 | - } elseif ( isset( $wp_query->query_vars['email'] ) ) { |
|
1407 | - $args = array( |
|
1405 | + $query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']); |
|
1406 | + } elseif (isset($wp_query->query_vars['email'])) { |
|
1407 | + $args = array( |
|
1408 | 1408 | 'fields' => 'ids', |
1409 | 1409 | 'meta_key' => '_give_payment_user_email', |
1410 | 1410 | 'meta_value' => $wp_query->query_vars['email'], |
@@ -1412,11 +1412,11 @@ discard block |
||
1412 | 1412 | 'page' => $this->get_paged(), |
1413 | 1413 | 'status' => 'publish', |
1414 | 1414 | ); |
1415 | - $query = give_get_payments( $args ); |
|
1416 | - } elseif ( isset( $wp_query->query_vars['date'] ) ) { |
|
1415 | + $query = give_get_payments($args); |
|
1416 | + } elseif (isset($wp_query->query_vars['date'])) { |
|
1417 | 1417 | |
1418 | - $current_time = current_time( 'timestamp' ); |
|
1419 | - $dates = $this->get_dates( $args ); |
|
1418 | + $current_time = current_time('timestamp'); |
|
1419 | + $dates = $this->get_dates($args); |
|
1420 | 1420 | |
1421 | 1421 | /** |
1422 | 1422 | * Switch case for date query argument |
@@ -1427,27 +1427,27 @@ discard block |
||
1427 | 1427 | * @params date startdate | required when date = range and format to be YYYYMMDD (i.e. 20170524) |
1428 | 1428 | * @params date enddate | required when date = range and format to be YYYYMMDD (i.e. 20170524) |
1429 | 1429 | */ |
1430 | - switch ( $wp_query->query_vars['date'] ) { |
|
1430 | + switch ($wp_query->query_vars['date']) { |
|
1431 | 1431 | |
1432 | 1432 | case 'today': |
1433 | 1433 | |
1434 | 1434 | // Set and Format Start and End Date to be date of today. |
1435 | - $start_date = $end_date = date( 'Y/m/d', $current_time ); |
|
1435 | + $start_date = $end_date = date('Y/m/d', $current_time); |
|
1436 | 1436 | |
1437 | 1437 | break; |
1438 | 1438 | |
1439 | 1439 | case 'yesterday': |
1440 | 1440 | |
1441 | 1441 | // Set and Format Start and End Date to be date of yesterday. |
1442 | - $start_date = $end_date = date( 'Y/m', $current_time ) . '/' . ( date( 'd', $current_time ) - 1 ); |
|
1442 | + $start_date = $end_date = date('Y/m', $current_time).'/'.(date('d', $current_time) - 1); |
|
1443 | 1443 | |
1444 | 1444 | break; |
1445 | 1445 | |
1446 | 1446 | case 'range': |
1447 | 1447 | |
1448 | 1448 | // Format Start Date and End Date for filtering payment based on date range. |
1449 | - $start_date = $dates['year'] . '/' . $dates['m_start'] . '/' . $dates['day_start']; |
|
1450 | - $end_date = $dates['year_end'] . '/' . $dates['m_end'] . '/' . $dates['day_end']; |
|
1449 | + $start_date = $dates['year'].'/'.$dates['m_start'].'/'.$dates['day_start']; |
|
1450 | + $end_date = $dates['year_end'].'/'.$dates['m_end'].'/'.$dates['day_end']; |
|
1451 | 1451 | |
1452 | 1452 | break; |
1453 | 1453 | |
@@ -1462,7 +1462,7 @@ discard block |
||
1462 | 1462 | 'status' => 'publish', |
1463 | 1463 | ); |
1464 | 1464 | |
1465 | - $query = give_get_payments( $args ); |
|
1465 | + $query = give_get_payments($args); |
|
1466 | 1466 | } else { |
1467 | 1467 | $args = array( |
1468 | 1468 | 'fields' => 'ids', |
@@ -1470,14 +1470,14 @@ discard block |
||
1470 | 1470 | 'page' => $this->get_paged(), |
1471 | 1471 | 'status' => 'publish', |
1472 | 1472 | ); |
1473 | - $query = give_get_payments( $args ); |
|
1473 | + $query = give_get_payments($args); |
|
1474 | 1474 | }// End if(). |
1475 | - if ( $query ) { |
|
1475 | + if ($query) { |
|
1476 | 1476 | $i = 0; |
1477 | - foreach ( $query as $payment ) { |
|
1477 | + foreach ($query as $payment) { |
|
1478 | 1478 | |
1479 | - if ( is_numeric( $payment ) ) { |
|
1480 | - $payment = new Give_Payment( $payment ); |
|
1479 | + if (is_numeric($payment)) { |
|
1480 | + $payment = new Give_Payment($payment); |
|
1481 | 1481 | $payment_meta = $payment->get_meta(); |
1482 | 1482 | $user_info = $payment->user_info; |
1483 | 1483 | } else { |
@@ -1487,40 +1487,40 @@ discard block |
||
1487 | 1487 | $payment_meta = $payment->get_meta(); |
1488 | 1488 | $user_info = $payment->user_info; |
1489 | 1489 | |
1490 | - $first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : ''; |
|
1491 | - $last_name = isset( $user_info['last_name'] ) ? $user_info['last_name'] : ''; |
|
1492 | - |
|
1493 | - $sales['donations'][ $i ]['ID'] = $payment->number; |
|
1494 | - $sales['donations'][ $i ]['transaction_id'] = $payment->transaction_id; |
|
1495 | - $sales['donations'][ $i ]['key'] = $payment->key; |
|
1496 | - $sales['donations'][ $i ]['total'] = $payment->total; |
|
1497 | - $sales['donations'][ $i ]['gateway'] = $payment->gateway; |
|
1498 | - $sales['donations'][ $i ]['name'] = $first_name . ' ' . $last_name; |
|
1499 | - $sales['donations'][ $i ]['fname'] = $first_name; |
|
1500 | - $sales['donations'][ $i ]['lname'] = $last_name; |
|
1501 | - $sales['donations'][ $i ]['email'] = $payment->email; |
|
1502 | - $sales['donations'][ $i ]['date'] = $payment->date; |
|
1503 | - |
|
1504 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta; |
|
1505 | - $price = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false; |
|
1506 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
1507 | - |
|
1508 | - $sales['donations'][ $i ]['form']['id'] = $form_id; |
|
1509 | - $sales['donations'][ $i ]['form']['name'] = get_the_title( $payment_meta['form_id'] ); |
|
1510 | - $sales['donations'][ $i ]['form']['price'] = $price; |
|
1511 | - |
|
1512 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1513 | - if ( isset( $payment_meta['price_id'] ) ) { |
|
1514 | - $price_name = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID ); |
|
1515 | - $sales['donations'][ $i ]['form']['price_name'] = $price_name; |
|
1516 | - $sales['donations'][ $i ]['form']['price_id'] = $price_id; |
|
1517 | - $sales['donations'][ $i ]['form']['price'] = give_get_price_option_amount( $form_id, $price_id ); |
|
1490 | + $first_name = isset($user_info['first_name']) ? $user_info['first_name'] : ''; |
|
1491 | + $last_name = isset($user_info['last_name']) ? $user_info['last_name'] : ''; |
|
1492 | + |
|
1493 | + $sales['donations'][$i]['ID'] = $payment->number; |
|
1494 | + $sales['donations'][$i]['transaction_id'] = $payment->transaction_id; |
|
1495 | + $sales['donations'][$i]['key'] = $payment->key; |
|
1496 | + $sales['donations'][$i]['total'] = $payment->total; |
|
1497 | + $sales['donations'][$i]['gateway'] = $payment->gateway; |
|
1498 | + $sales['donations'][$i]['name'] = $first_name.' '.$last_name; |
|
1499 | + $sales['donations'][$i]['fname'] = $first_name; |
|
1500 | + $sales['donations'][$i]['lname'] = $last_name; |
|
1501 | + $sales['donations'][$i]['email'] = $payment->email; |
|
1502 | + $sales['donations'][$i]['date'] = $payment->date; |
|
1503 | + |
|
1504 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta; |
|
1505 | + $price = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false; |
|
1506 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
1507 | + |
|
1508 | + $sales['donations'][$i]['form']['id'] = $form_id; |
|
1509 | + $sales['donations'][$i]['form']['name'] = get_the_title($payment_meta['form_id']); |
|
1510 | + $sales['donations'][$i]['form']['price'] = $price; |
|
1511 | + |
|
1512 | + if (give_has_variable_prices($form_id)) { |
|
1513 | + if (isset($payment_meta['price_id'])) { |
|
1514 | + $price_name = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID); |
|
1515 | + $sales['donations'][$i]['form']['price_name'] = $price_name; |
|
1516 | + $sales['donations'][$i]['form']['price_id'] = $price_id; |
|
1517 | + $sales['donations'][$i]['form']['price'] = give_get_price_option_amount($form_id, $price_id); |
|
1518 | 1518 | |
1519 | 1519 | } |
1520 | 1520 | } |
1521 | 1521 | |
1522 | 1522 | // Add custom meta to API |
1523 | - foreach ( $payment_meta as $meta_key => $meta_value ) { |
|
1523 | + foreach ($payment_meta as $meta_key => $meta_value) { |
|
1524 | 1524 | |
1525 | 1525 | $exceptions = array( |
1526 | 1526 | 'form_title', |
@@ -1533,19 +1533,19 @@ discard block |
||
1533 | 1533 | ); |
1534 | 1534 | |
1535 | 1535 | // Don't clutter up results with dupes |
1536 | - if ( in_array( $meta_key, $exceptions ) ) { |
|
1536 | + if (in_array($meta_key, $exceptions)) { |
|
1537 | 1537 | continue; |
1538 | 1538 | } |
1539 | 1539 | |
1540 | - $sales['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value; |
|
1540 | + $sales['donations'][$i]['payment_meta'][$meta_key] = $meta_value; |
|
1541 | 1541 | |
1542 | 1542 | } |
1543 | 1543 | |
1544 | - $i ++; |
|
1544 | + $i++; |
|
1545 | 1545 | }// End foreach(). |
1546 | 1546 | }// End if(). |
1547 | 1547 | |
1548 | - return apply_filters( 'give_api_donations_endpoint', $sales ); |
|
1548 | + return apply_filters('give_api_donations_endpoint', $sales); |
|
1549 | 1549 | } |
1550 | 1550 | |
1551 | 1551 | /** |
@@ -1561,9 +1561,9 @@ discard block |
||
1561 | 1561 | public function get_output_format() { |
1562 | 1562 | global $wp_query; |
1563 | 1563 | |
1564 | - $format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json'; |
|
1564 | + $format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json'; |
|
1565 | 1565 | |
1566 | - return apply_filters( 'give_api_output_format', $format ); |
|
1566 | + return apply_filters('give_api_output_format', $format); |
|
1567 | 1567 | } |
1568 | 1568 | |
1569 | 1569 | |
@@ -1580,8 +1580,8 @@ discard block |
||
1580 | 1580 | * |
1581 | 1581 | * @return void |
1582 | 1582 | */ |
1583 | - private function log_request( $data = array() ) { |
|
1584 | - if ( ! $this->log_requests ) { |
|
1583 | + private function log_request($data = array()) { |
|
1584 | + if ( ! $this->log_requests) { |
|
1585 | 1585 | return; |
1586 | 1586 | } |
1587 | 1587 | |
@@ -1597,36 +1597,36 @@ discard block |
||
1597 | 1597 | |
1598 | 1598 | $query = array( |
1599 | 1599 | 'give-api' => $wp_query->query_vars['give-api'], |
1600 | - 'key' => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null, |
|
1601 | - 'token' => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null, |
|
1602 | - 'query' => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null, |
|
1603 | - 'type' => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null, |
|
1604 | - 'form' => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null, |
|
1605 | - 'donor' => isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null, |
|
1606 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
1607 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
1608 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, |
|
1609 | - 'id' => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null, |
|
1610 | - 'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null, |
|
1611 | - 'email' => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null, |
|
1600 | + 'key' => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null, |
|
1601 | + 'token' => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null, |
|
1602 | + 'query' => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null, |
|
1603 | + 'type' => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null, |
|
1604 | + 'form' => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null, |
|
1605 | + 'donor' => isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null, |
|
1606 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
1607 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
1608 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, |
|
1609 | + 'id' => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null, |
|
1610 | + 'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null, |
|
1611 | + 'email' => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null, |
|
1612 | 1612 | ); |
1613 | 1613 | |
1614 | 1614 | $log_data = array( |
1615 | 1615 | 'log_type' => 'api_request', |
1616 | - 'post_excerpt' => http_build_query( $query ), |
|
1617 | - 'post_content' => ! empty( $data['error'] ) ? $data['error'] : '', |
|
1616 | + 'post_excerpt' => http_build_query($query), |
|
1617 | + 'post_content' => ! empty($data['error']) ? $data['error'] : '', |
|
1618 | 1618 | ); |
1619 | 1619 | |
1620 | 1620 | $log_meta = array( |
1621 | 1621 | 'request_ip' => give_get_ip(), |
1622 | 1622 | 'user' => $this->user_id, |
1623 | - 'key' => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null, |
|
1624 | - 'token' => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null, |
|
1623 | + 'key' => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null, |
|
1624 | + 'token' => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null, |
|
1625 | 1625 | 'time' => $data['request_speed'], |
1626 | 1626 | 'version' => $this->get_queried_version(), |
1627 | 1627 | ); |
1628 | 1628 | |
1629 | - $give_logs->insert_log( $log_data, $log_meta ); |
|
1629 | + $give_logs->insert_log($log_data, $log_meta); |
|
1630 | 1630 | } |
1631 | 1631 | |
1632 | 1632 | |
@@ -1650,11 +1650,11 @@ discard block |
||
1650 | 1650 | * |
1651 | 1651 | * @param int $status_code |
1652 | 1652 | */ |
1653 | - public function output( $status_code = 200 ) { |
|
1653 | + public function output($status_code = 200) { |
|
1654 | 1654 | |
1655 | 1655 | $format = $this->get_output_format(); |
1656 | 1656 | |
1657 | - status_header( $status_code ); |
|
1657 | + status_header($status_code); |
|
1658 | 1658 | |
1659 | 1659 | /** |
1660 | 1660 | * Fires before outputting the API. |
@@ -1665,25 +1665,25 @@ discard block |
||
1665 | 1665 | * @param Give_API $this The Give_API object. |
1666 | 1666 | * @param string $format Output format, XML or JSON. Default is JSON. |
1667 | 1667 | */ |
1668 | - do_action( 'give_api_output_before', $this->data, $this, $format ); |
|
1668 | + do_action('give_api_output_before', $this->data, $this, $format); |
|
1669 | 1669 | |
1670 | - switch ( $format ) : |
|
1670 | + switch ($format) : |
|
1671 | 1671 | |
1672 | 1672 | case 'xml' : |
1673 | 1673 | |
1674 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php'; |
|
1675 | - $xml = Array2XML::createXML( 'give', $this->data ); |
|
1674 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php'; |
|
1675 | + $xml = Array2XML::createXML('give', $this->data); |
|
1676 | 1676 | echo $xml->saveXML(); |
1677 | 1677 | |
1678 | 1678 | break; |
1679 | 1679 | |
1680 | 1680 | case 'json' : |
1681 | 1681 | |
1682 | - header( 'Content-Type: application/json' ); |
|
1683 | - if ( ! empty( $this->pretty_print ) ) { |
|
1684 | - echo json_encode( $this->data, $this->pretty_print ); |
|
1682 | + header('Content-Type: application/json'); |
|
1683 | + if ( ! empty($this->pretty_print)) { |
|
1684 | + echo json_encode($this->data, $this->pretty_print); |
|
1685 | 1685 | } else { |
1686 | - echo json_encode( $this->data ); |
|
1686 | + echo json_encode($this->data); |
|
1687 | 1687 | } |
1688 | 1688 | |
1689 | 1689 | break; |
@@ -1698,7 +1698,7 @@ discard block |
||
1698 | 1698 | * @param array $data Response data to return. |
1699 | 1699 | * @param Give_API $this The Give_API object. |
1700 | 1700 | */ |
1701 | - do_action( "give_api_output_{$format}", $this->data, $this ); |
|
1701 | + do_action("give_api_output_{$format}", $this->data, $this); |
|
1702 | 1702 | |
1703 | 1703 | break; |
1704 | 1704 | |
@@ -1713,7 +1713,7 @@ discard block |
||
1713 | 1713 | * @param Give_API $this The Give_API object. |
1714 | 1714 | * @param string $format Output format, XML or JSON. Default is JSON. |
1715 | 1715 | */ |
1716 | - do_action( 'give_api_output_after', $this->data, $this, $format ); |
|
1716 | + do_action('give_api_output_after', $this->data, $this, $format); |
|
1717 | 1717 | |
1718 | 1718 | give_die(); |
1719 | 1719 | } |
@@ -1730,40 +1730,40 @@ discard block |
||
1730 | 1730 | * |
1731 | 1731 | * @return void |
1732 | 1732 | */ |
1733 | - function user_key_field( $user ) { |
|
1733 | + function user_key_field($user) { |
|
1734 | 1734 | |
1735 | - if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) { |
|
1736 | - $user = get_userdata( $user->ID ); |
|
1735 | + if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) { |
|
1736 | + $user = get_userdata($user->ID); |
|
1737 | 1737 | ?> |
1738 | 1738 | <table class="form-table"> |
1739 | 1739 | <tbody> |
1740 | 1740 | <tr> |
1741 | 1741 | <th> |
1742 | - <?php esc_html_e( 'Give API Keys', 'give' ); ?> |
|
1742 | + <?php esc_html_e('Give API Keys', 'give'); ?> |
|
1743 | 1743 | </th> |
1744 | 1744 | <td> |
1745 | 1745 | <?php |
1746 | - $public_key = $this->get_user_public_key( $user->ID ); |
|
1747 | - $secret_key = $this->get_user_secret_key( $user->ID ); |
|
1746 | + $public_key = $this->get_user_public_key($user->ID); |
|
1747 | + $secret_key = $this->get_user_secret_key($user->ID); |
|
1748 | 1748 | ?> |
1749 | - <?php if ( empty( $user->give_user_public_key ) ) { ?> |
|
1749 | + <?php if (empty($user->give_user_public_key)) { ?> |
|
1750 | 1750 | <input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/> |
1751 | - <span class="description"><?php esc_html_e( 'Generate API Key', 'give' ); ?></span> |
|
1751 | + <span class="description"><?php esc_html_e('Generate API Key', 'give'); ?></span> |
|
1752 | 1752 | <?php } else { ?> |
1753 | - <strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Public key:', 'give' ); ?> |
|
1753 | + <strong style="display:inline-block; width: 125px;"><?php esc_html_e('Public key:', 'give'); ?> |
|
1754 | 1754 | </strong> |
1755 | - <input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>"/> |
|
1755 | + <input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>"/> |
|
1756 | 1756 | <br/> |
1757 | - <strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Secret key:', 'give' ); ?> |
|
1757 | + <strong style="display:inline-block; width: 125px;"><?php esc_html_e('Secret key:', 'give'); ?> |
|
1758 | 1758 | </strong> |
1759 | - <input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>"/> |
|
1759 | + <input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>"/> |
|
1760 | 1760 | <br/> |
1761 | - <strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Token:', 'give' ); ?> |
|
1761 | + <strong style="display:inline-block; width: 125px;"><?php esc_html_e('Token:', 'give'); ?> |
|
1762 | 1762 | </strong> |
1763 | - <input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>"/> |
|
1763 | + <input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>"/> |
|
1764 | 1764 | <br/> |
1765 | 1765 | <input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/> |
1766 | - <span class="description"><label for="give_set_api_key"><?php esc_html_e( 'Revoke API Keys', 'give' ); ?></label></span> |
|
1766 | + <span class="description"><label for="give_set_api_key"><?php esc_html_e('Revoke API Keys', 'give'); ?></label></span> |
|
1767 | 1767 | <?php } ?> |
1768 | 1768 | </td> |
1769 | 1769 | </tr> |
@@ -1782,61 +1782,61 @@ discard block |
||
1782 | 1782 | * |
1783 | 1783 | * @return void |
1784 | 1784 | */ |
1785 | - public function process_api_key( $args ) { |
|
1785 | + public function process_api_key($args) { |
|
1786 | 1786 | |
1787 | - if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) { |
|
1788 | - wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( |
|
1787 | + if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) { |
|
1788 | + wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array( |
|
1789 | 1789 | 'response' => 403, |
1790 | - ) ); |
|
1790 | + )); |
|
1791 | 1791 | } |
1792 | 1792 | |
1793 | - if ( empty( $args['user_id'] ) ) { |
|
1794 | - wp_die( __( 'User ID Required.', 'give' ), __( 'Error', 'give' ), array( |
|
1793 | + if (empty($args['user_id'])) { |
|
1794 | + wp_die(__('User ID Required.', 'give'), __('Error', 'give'), array( |
|
1795 | 1795 | 'response' => 401, |
1796 | - ) ); |
|
1796 | + )); |
|
1797 | 1797 | } |
1798 | 1798 | |
1799 | - if ( is_numeric( $args['user_id'] ) ) { |
|
1800 | - $user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id(); |
|
1799 | + if (is_numeric($args['user_id'])) { |
|
1800 | + $user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id(); |
|
1801 | 1801 | } else { |
1802 | - $userdata = get_user_by( 'login', $args['user_id'] ); |
|
1802 | + $userdata = get_user_by('login', $args['user_id']); |
|
1803 | 1803 | $user_id = $userdata->ID; |
1804 | 1804 | } |
1805 | - $process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false; |
|
1805 | + $process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false; |
|
1806 | 1806 | |
1807 | - if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) { |
|
1808 | - wp_die( sprintf( /* translators: %s: process */ |
|
1809 | - esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), esc_html__( 'Error', 'give' ), array( |
|
1807 | + if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) { |
|
1808 | + wp_die(sprintf( /* translators: %s: process */ |
|
1809 | + esc_html__('You do not have permission to %s API keys for this user.', 'give'), $process ), esc_html__('Error', 'give'), array( |
|
1810 | 1810 | 'response' => 403, |
1811 | - ) ); |
|
1812 | - } elseif ( ! current_user_can( 'manage_give_settings' ) ) { |
|
1813 | - wp_die( sprintf( /* translators: %s: process */ |
|
1814 | - esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), esc_html__( 'Error', 'give' ), array( |
|
1811 | + )); |
|
1812 | + } elseif ( ! current_user_can('manage_give_settings')) { |
|
1813 | + wp_die(sprintf( /* translators: %s: process */ |
|
1814 | + esc_html__('You do not have permission to %s API keys for this user.', 'give'), $process ), esc_html__('Error', 'give'), array( |
|
1815 | 1815 | 'response' => 403, |
1816 | - ) ); |
|
1816 | + )); |
|
1817 | 1817 | } |
1818 | 1818 | |
1819 | - switch ( $process ) { |
|
1819 | + switch ($process) { |
|
1820 | 1820 | case 'generate': |
1821 | - if ( $this->generate_api_key( $user_id ) ) { |
|
1822 | - Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) ); |
|
1823 | - wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1821 | + if ($this->generate_api_key($user_id)) { |
|
1822 | + Give_Cache::delete(Give_Cache::get_key('give_total_api_keys')); |
|
1823 | + wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1824 | 1824 | exit(); |
1825 | 1825 | } else { |
1826 | - wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1826 | + wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1827 | 1827 | exit(); |
1828 | 1828 | } |
1829 | 1829 | break; |
1830 | 1830 | case 'regenerate': |
1831 | - $this->generate_api_key( $user_id, true ); |
|
1832 | - Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) ); |
|
1833 | - wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1831 | + $this->generate_api_key($user_id, true); |
|
1832 | + Give_Cache::delete(Give_Cache::get_key('give_total_api_keys')); |
|
1833 | + wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1834 | 1834 | exit(); |
1835 | 1835 | break; |
1836 | 1836 | case 'revoke': |
1837 | - $this->revoke_api_key( $user_id ); |
|
1838 | - Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) ); |
|
1839 | - wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) ); |
|
1837 | + $this->revoke_api_key($user_id); |
|
1838 | + Give_Cache::delete(Give_Cache::get_key('give_total_api_keys')); |
|
1839 | + wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api')); |
|
1840 | 1840 | exit(); |
1841 | 1841 | break; |
1842 | 1842 | default; |
@@ -1855,34 +1855,34 @@ discard block |
||
1855 | 1855 | * |
1856 | 1856 | * @return boolean True if (re)generated succesfully, false otherwise. |
1857 | 1857 | */ |
1858 | - public function generate_api_key( $user_id = 0, $regenerate = false ) { |
|
1858 | + public function generate_api_key($user_id = 0, $regenerate = false) { |
|
1859 | 1859 | |
1860 | - if ( empty( $user_id ) ) { |
|
1860 | + if (empty($user_id)) { |
|
1861 | 1861 | return false; |
1862 | 1862 | } |
1863 | 1863 | |
1864 | - $user = get_userdata( $user_id ); |
|
1864 | + $user = get_userdata($user_id); |
|
1865 | 1865 | |
1866 | - if ( ! $user ) { |
|
1866 | + if ( ! $user) { |
|
1867 | 1867 | return false; |
1868 | 1868 | } |
1869 | 1869 | |
1870 | - $public_key = $this->get_user_public_key( $user_id ); |
|
1871 | - $secret_key = $this->get_user_secret_key( $user_id ); |
|
1870 | + $public_key = $this->get_user_public_key($user_id); |
|
1871 | + $secret_key = $this->get_user_secret_key($user_id); |
|
1872 | 1872 | |
1873 | - if ( empty( $public_key ) || $regenerate == true ) { |
|
1874 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
1875 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
1873 | + if (empty($public_key) || $regenerate == true) { |
|
1874 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
1875 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
1876 | 1876 | } else { |
1877 | 1877 | return false; |
1878 | 1878 | } |
1879 | 1879 | |
1880 | - if ( $regenerate == true ) { |
|
1881 | - $this->revoke_api_key( $user->ID ); |
|
1880 | + if ($regenerate == true) { |
|
1881 | + $this->revoke_api_key($user->ID); |
|
1882 | 1882 | } |
1883 | 1883 | |
1884 | - update_user_meta( $user_id, $new_public_key, 'give_user_public_key' ); |
|
1885 | - update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' ); |
|
1884 | + update_user_meta($user_id, $new_public_key, 'give_user_public_key'); |
|
1885 | + update_user_meta($user_id, $new_secret_key, 'give_user_secret_key'); |
|
1886 | 1886 | |
1887 | 1887 | return true; |
1888 | 1888 | } |
@@ -1897,26 +1897,26 @@ discard block |
||
1897 | 1897 | * |
1898 | 1898 | * @return bool |
1899 | 1899 | */ |
1900 | - public function revoke_api_key( $user_id = 0 ) { |
|
1900 | + public function revoke_api_key($user_id = 0) { |
|
1901 | 1901 | |
1902 | - if ( empty( $user_id ) ) { |
|
1902 | + if (empty($user_id)) { |
|
1903 | 1903 | return false; |
1904 | 1904 | } |
1905 | 1905 | |
1906 | - $user = get_userdata( $user_id ); |
|
1906 | + $user = get_userdata($user_id); |
|
1907 | 1907 | |
1908 | - if ( ! $user ) { |
|
1908 | + if ( ! $user) { |
|
1909 | 1909 | return false; |
1910 | 1910 | } |
1911 | 1911 | |
1912 | - $public_key = $this->get_user_public_key( $user_id ); |
|
1913 | - $secret_key = $this->get_user_secret_key( $user_id ); |
|
1914 | - if ( ! empty( $public_key ) ) { |
|
1915 | - Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_' . $public_key ) ) ); |
|
1916 | - Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_public_key' . $user_id ) ) ); |
|
1917 | - Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_secret_key' . $user_id ) ) ); |
|
1918 | - delete_user_meta( $user_id, $public_key ); |
|
1919 | - delete_user_meta( $user_id, $secret_key ); |
|
1912 | + $public_key = $this->get_user_public_key($user_id); |
|
1913 | + $secret_key = $this->get_user_secret_key($user_id); |
|
1914 | + if ( ! empty($public_key)) { |
|
1915 | + Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_'.$public_key))); |
|
1916 | + Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_public_key'.$user_id))); |
|
1917 | + Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_secret_key'.$user_id))); |
|
1918 | + delete_user_meta($user_id, $public_key); |
|
1919 | + delete_user_meta($user_id, $secret_key); |
|
1920 | 1920 | } else { |
1921 | 1921 | return false; |
1922 | 1922 | } |
@@ -1941,22 +1941,22 @@ discard block |
||
1941 | 1941 | * |
1942 | 1942 | * @return void |
1943 | 1943 | */ |
1944 | - public function update_key( $user_id ) { |
|
1945 | - if ( current_user_can( 'edit_user', $user_id ) && isset( $_POST['give_set_api_key'] ) ) { |
|
1944 | + public function update_key($user_id) { |
|
1945 | + if (current_user_can('edit_user', $user_id) && isset($_POST['give_set_api_key'])) { |
|
1946 | 1946 | |
1947 | - $user = get_userdata( $user_id ); |
|
1947 | + $user = get_userdata($user_id); |
|
1948 | 1948 | |
1949 | - $public_key = $this->get_user_public_key( $user_id ); |
|
1950 | - $secret_key = $this->get_user_secret_key( $user_id ); |
|
1949 | + $public_key = $this->get_user_public_key($user_id); |
|
1950 | + $secret_key = $this->get_user_secret_key($user_id); |
|
1951 | 1951 | |
1952 | - if ( empty( $public_key ) ) { |
|
1953 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
1954 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
1952 | + if (empty($public_key)) { |
|
1953 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
1954 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
1955 | 1955 | |
1956 | - update_user_meta( $user_id, $new_public_key, 'give_user_public_key' ); |
|
1957 | - update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' ); |
|
1956 | + update_user_meta($user_id, $new_public_key, 'give_user_public_key'); |
|
1957 | + update_user_meta($user_id, $new_secret_key, 'give_user_secret_key'); |
|
1958 | 1958 | } else { |
1959 | - $this->revoke_api_key( $user_id ); |
|
1959 | + $this->revoke_api_key($user_id); |
|
1960 | 1960 | } |
1961 | 1961 | } |
1962 | 1962 | } |
@@ -1971,9 +1971,9 @@ discard block |
||
1971 | 1971 | * |
1972 | 1972 | * @return string |
1973 | 1973 | */ |
1974 | - private function generate_public_key( $user_email = '' ) { |
|
1975 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
1976 | - $public = hash( 'md5', $user_email . $auth_key . date( 'U' ) ); |
|
1974 | + private function generate_public_key($user_email = '') { |
|
1975 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
1976 | + $public = hash('md5', $user_email.$auth_key.date('U')); |
|
1977 | 1977 | |
1978 | 1978 | return $public; |
1979 | 1979 | } |
@@ -1988,9 +1988,9 @@ discard block |
||
1988 | 1988 | * |
1989 | 1989 | * @return string |
1990 | 1990 | */ |
1991 | - private function generate_private_key( $user_id = 0 ) { |
|
1992 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
1993 | - $secret = hash( 'md5', $user_id . $auth_key . date( 'U' ) ); |
|
1991 | + private function generate_private_key($user_id = 0) { |
|
1992 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
1993 | + $secret = hash('md5', $user_id.$auth_key.date('U')); |
|
1994 | 1994 | |
1995 | 1995 | return $secret; |
1996 | 1996 | } |
@@ -2005,8 +2005,8 @@ discard block |
||
2005 | 2005 | * |
2006 | 2006 | * @return string |
2007 | 2007 | */ |
2008 | - public function get_token( $user_id = 0 ) { |
|
2009 | - return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) ); |
|
2008 | + public function get_token($user_id = 0) { |
|
2009 | + return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id)); |
|
2010 | 2010 | } |
2011 | 2011 | |
2012 | 2012 | /** |
@@ -2020,9 +2020,9 @@ discard block |
||
2020 | 2020 | |
2021 | 2021 | // Default sales return |
2022 | 2022 | $sales = array(); |
2023 | - $sales['donations']['today'] = $this->stats->get_sales( 0, 'today' ); |
|
2024 | - $sales['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' ); |
|
2025 | - $sales['donations']['last_month'] = $this->stats->get_sales( 0, 'last_month' ); |
|
2023 | + $sales['donations']['today'] = $this->stats->get_sales(0, 'today'); |
|
2024 | + $sales['donations']['current_month'] = $this->stats->get_sales(0, 'this_month'); |
|
2025 | + $sales['donations']['last_month'] = $this->stats->get_sales(0, 'last_month'); |
|
2026 | 2026 | $sales['donations']['totals'] = give_get_total_donations(); |
2027 | 2027 | |
2028 | 2028 | return $sales; |
@@ -2039,9 +2039,9 @@ discard block |
||
2039 | 2039 | |
2040 | 2040 | // Default earnings return |
2041 | 2041 | $earnings = array(); |
2042 | - $earnings['earnings']['today'] = $this->stats->get_earnings( 0, 'today' ); |
|
2043 | - $earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' ); |
|
2044 | - $earnings['earnings']['last_month'] = $this->stats->get_earnings( 0, 'last_month' ); |
|
2042 | + $earnings['earnings']['today'] = $this->stats->get_earnings(0, 'today'); |
|
2043 | + $earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month'); |
|
2044 | + $earnings['earnings']['last_month'] = $this->stats->get_earnings(0, 'last_month'); |
|
2045 | 2045 | $earnings['earnings']['totals'] = give_get_total_earnings(); |
2046 | 2046 | |
2047 | 2047 | return $earnings; |
@@ -2061,25 +2061,25 @@ discard block |
||
2061 | 2061 | * |
2062 | 2062 | * @return string The API key/secret for the user supplied |
2063 | 2063 | */ |
2064 | - public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) { |
|
2064 | + public function api_key_backwards_compat($check, $object_id, $meta_key, $single) { |
|
2065 | 2065 | |
2066 | - if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) { |
|
2066 | + if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') { |
|
2067 | 2067 | return $check; |
2068 | 2068 | } |
2069 | 2069 | |
2070 | 2070 | $return = $check; |
2071 | 2071 | |
2072 | - switch ( $meta_key ) { |
|
2072 | + switch ($meta_key) { |
|
2073 | 2073 | case 'give_user_public_key': |
2074 | - $return = Give()->api->get_user_public_key( $object_id ); |
|
2074 | + $return = Give()->api->get_user_public_key($object_id); |
|
2075 | 2075 | break; |
2076 | 2076 | case 'give_user_secret_key': |
2077 | - $return = Give()->api->get_user_secret_key( $object_id ); |
|
2077 | + $return = Give()->api->get_user_secret_key($object_id); |
|
2078 | 2078 | break; |
2079 | 2079 | } |
2080 | 2080 | |
2081 | - if ( ! $single ) { |
|
2082 | - $return = array( $return ); |
|
2081 | + if ( ! $single) { |
|
2082 | + $return = array($return); |
|
2083 | 2083 | } |
2084 | 2084 | |
2085 | 2085 | return $return; |