@@ -1,14 +1,14 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Give Welcome Page Class |
|
4 | - * |
|
5 | - * @description Displays on plugin activation |
|
6 | - * @package Give |
|
7 | - * @subpackage Admin/Welcome |
|
8 | - * @copyright Copyright (c) 2015, WordImpress |
|
9 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
10 | - * @since 1.0 |
|
11 | - */ |
|
3 | + * Give Welcome Page Class |
|
4 | + * |
|
5 | + * @description Displays on plugin activation |
|
6 | + * @package Give |
|
7 | + * @subpackage Admin/Welcome |
|
8 | + * @copyright Copyright (c) 2015, WordImpress |
|
9 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
10 | + * @since 1.0 |
|
11 | + */ |
|
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | 14 | if ( ! defined( 'ABSPATH' ) ) { |
@@ -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 | /** |
@@ -51,38 +51,38 @@ discard block |
||
51 | 51 | public function admin_menus() { |
52 | 52 | // About Page |
53 | 53 | add_dashboard_page( |
54 | - __( 'Welcome to Give', 'give' ), |
|
55 | - __( 'Welcome to Give', 'give' ), |
|
54 | + __('Welcome to Give', 'give'), |
|
55 | + __('Welcome to Give', 'give'), |
|
56 | 56 | $this->minimum_capability, |
57 | 57 | 'give-about', |
58 | - array( $this, 'about_screen' ) |
|
58 | + array($this, 'about_screen') |
|
59 | 59 | ); |
60 | 60 | |
61 | 61 | // Changelog Page |
62 | 62 | add_dashboard_page( |
63 | - __( 'Give Changelog', 'give' ), |
|
64 | - __( 'Give Changelog', 'give' ), |
|
63 | + __('Give Changelog', 'give'), |
|
64 | + __('Give Changelog', 'give'), |
|
65 | 65 | $this->minimum_capability, |
66 | 66 | 'give-changelog', |
67 | - array( $this, 'changelog_screen' ) |
|
67 | + array($this, 'changelog_screen') |
|
68 | 68 | ); |
69 | 69 | |
70 | 70 | // Getting Started Page |
71 | 71 | add_dashboard_page( |
72 | - __( 'Getting started with Give', 'give' ), |
|
73 | - __( 'Getting started with Give', 'give' ), |
|
72 | + __('Getting started with Give', 'give'), |
|
73 | + __('Getting started with Give', 'give'), |
|
74 | 74 | $this->minimum_capability, |
75 | 75 | 'give-getting-started', |
76 | - array( $this, 'getting_started_screen' ) |
|
76 | + array($this, 'getting_started_screen') |
|
77 | 77 | ); |
78 | 78 | |
79 | 79 | // Credits Page |
80 | 80 | add_dashboard_page( |
81 | - __( 'The people that build Give', 'give' ), |
|
82 | - __( 'The people that build Give', 'give' ), |
|
81 | + __('The people that build Give', 'give'), |
|
82 | + __('The people that build Give', 'give'), |
|
83 | 83 | $this->minimum_capability, |
84 | 84 | 'give-credits', |
85 | - array( $this, 'credits_screen' ) |
|
85 | + array($this, 'credits_screen') |
|
86 | 86 | ); |
87 | 87 | } |
88 | 88 | |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function admin_head() { |
97 | 97 | |
98 | - remove_submenu_page( 'index.php', 'give-about' ); |
|
99 | - remove_submenu_page( 'index.php', 'give-changelog' ); |
|
100 | - remove_submenu_page( 'index.php', 'give-getting-started' ); |
|
101 | - remove_submenu_page( 'index.php', 'give-credits' ); |
|
98 | + remove_submenu_page('index.php', 'give-about'); |
|
99 | + remove_submenu_page('index.php', 'give-changelog'); |
|
100 | + remove_submenu_page('index.php', 'give-getting-started'); |
|
101 | + remove_submenu_page('index.php', 'give-credits'); |
|
102 | 102 | |
103 | 103 | // Badge for welcome page |
104 | - $badge_url = GIVE_PLUGIN_URL . 'assets/images/give-badge.png'; |
|
104 | + $badge_url = GIVE_PLUGIN_URL.'assets/images/give-badge.png'; |
|
105 | 105 | |
106 | 106 | ?> |
107 | 107 | <style type="text/css" media="screen"> |
@@ -215,20 +215,20 @@ discard block |
||
215 | 215 | * @return void |
216 | 216 | */ |
217 | 217 | public function tabs() { |
218 | - $selected = isset( $_GET['page'] ) ? $_GET['page'] : 'give-about'; |
|
218 | + $selected = isset($_GET['page']) ? $_GET['page'] : 'give-about'; |
|
219 | 219 | ?> |
220 | 220 | <h1 class="nav-tab-wrapper"> |
221 | - <a class="nav-tab <?php echo $selected == 'give-about' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'give-about' ), 'index.php' ) ) ); ?>"> |
|
222 | - <?php _e( "About Give", 'give' ); ?> |
|
221 | + <a class="nav-tab <?php echo $selected == 'give-about' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'give-about'), 'index.php'))); ?>"> |
|
222 | + <?php _e("About Give", 'give'); ?> |
|
223 | 223 | </a> |
224 | - <a class="nav-tab <?php echo $selected == 'give-getting-started' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'give-getting-started' ), 'index.php' ) ) ); ?>"> |
|
225 | - <?php _e( 'Getting Started', 'give' ); ?> |
|
224 | + <a class="nav-tab <?php echo $selected == 'give-getting-started' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'give-getting-started'), 'index.php'))); ?>"> |
|
225 | + <?php _e('Getting Started', 'give'); ?> |
|
226 | 226 | </a> |
227 | - <a class="nav-tab <?php echo $selected == 'give-credits' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'give-credits' ), 'index.php' ) ) ); ?>"> |
|
228 | - <?php _e( 'Credits', 'give' ); ?> |
|
227 | + <a class="nav-tab <?php echo $selected == 'give-credits' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'give-credits'), 'index.php'))); ?>"> |
|
228 | + <?php _e('Credits', 'give'); ?> |
|
229 | 229 | </a> |
230 | - <a class="nav-tab <?php echo $selected == 'give-add-ons' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( null, 'index.php' ) ) . 'edit.php?post_type=give_forms&page=give-addons'; ?>"> |
|
231 | - <?php _e( 'Add-ons', 'give' ); ?> |
|
230 | + <a class="nav-tab <?php echo $selected == 'give-add-ons' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url(admin_url(null, 'index.php')).'edit.php?post_type=give_forms&page=give-addons'; ?>"> |
|
231 | + <?php _e('Add-ons', 'give'); ?> |
|
232 | 232 | </a> |
233 | 233 | </h1> |
234 | 234 | <?php |
@@ -242,20 +242,20 @@ discard block |
||
242 | 242 | * @return void |
243 | 243 | */ |
244 | 244 | public function about_screen() { |
245 | - list( $display_version ) = explode( '-', GIVE_VERSION ); |
|
245 | + list($display_version) = explode('-', GIVE_VERSION); |
|
246 | 246 | ?> |
247 | 247 | <div class="wrap about-wrap"> |
248 | - <h1 class="welcome-h1"><?php printf( __( 'Welcome to Give %s', 'give' ), $display_version ); ?></h1> |
|
248 | + <h1 class="welcome-h1"><?php printf(__('Welcome to Give %s', 'give'), $display_version); ?></h1> |
|
249 | 249 | |
250 | 250 | <?php give_social_media_elements() ?> |
251 | 251 | |
252 | - <div class="about-text"><?php printf( __( '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. </You>We encourage you to check out the <a href="%s" title="View the Give plugin documentation online" target="_blank">plugin documentation</a> and getting started guide below.', 'give' ), 'https://givewp.com/documenation/' ); ?></div> |
|
252 | + <div class="about-text"><?php printf(__('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. </You>We encourage you to check out the <a href="%s" title="View the Give plugin documentation online" target="_blank">plugin documentation</a> and getting started guide below.', 'give'), 'https://givewp.com/documenation/'); ?></div> |
|
253 | 253 | |
254 | - <p class="newsletter-intro"><?php _e( 'Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give' ); ?></p> |
|
254 | + <p class="newsletter-intro"><?php _e('Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give'); ?></p> |
|
255 | 255 | |
256 | 256 | <?php give_get_newsletter() ?> |
257 | 257 | |
258 | - <div class="give-badge"><?php printf( __( 'Version %s', 'give' ), $display_version ); ?></div> |
|
258 | + <div class="give-badge"><?php printf(__('Version %s', 'give'), $display_version); ?></div> |
|
259 | 259 | |
260 | 260 | |
261 | 261 | |
@@ -264,15 +264,15 @@ discard block |
||
264 | 264 | <div class="feature-section clearfix introduction"> |
265 | 265 | |
266 | 266 | <div class="video feature-section-item"> |
267 | - <img src="<?php echo GIVE_PLUGIN_URL . '/assets/images/give-form-mockup.png' ?>" title="A Give donation form" alt="A Give donation form"> |
|
267 | + <img src="<?php echo GIVE_PLUGIN_URL.'/assets/images/give-form-mockup.png' ?>" title="A Give donation form" alt="A Give donation form"> |
|
268 | 268 | |
269 | 269 | </div> |
270 | 270 | |
271 | 271 | <div class="content feature-section-item last-feature"> |
272 | 272 | |
273 | - <h3><?php _e( 'Give - Democratizing Generosity', 'give' ); ?></h3> |
|
273 | + <h3><?php _e('Give - Democratizing Generosity', 'give'); ?></h3> |
|
274 | 274 | |
275 | - <p><?php _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> |
|
275 | + <p><?php _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> |
|
276 | 276 | <a href="https://givewp.com" target="_blank" class="button-secondary" title="Visit the Give Website">Learn More |
277 | 277 | <span class="dashicons dashicons-external"></span></a> |
278 | 278 | |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | |
286 | 286 | <div class="content feature-section-item"> |
287 | 287 | |
288 | - <h3><?php _e( 'Getting to Know Give', 'give' ); ?></h3> |
|
288 | + <h3><?php _e('Getting to Know Give', 'give'); ?></h3> |
|
289 | 289 | |
290 | - <p><?php _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 an 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> |
|
290 | + <p><?php _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 an 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> |
|
291 | 291 | <a href="https://givewp.com/documentation" target="_blank" class="button-secondary" title="Visit the Give Website">View Documentation |
292 | 292 | <span class="dashicons dashicons-external"></span></a> |
293 | 293 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | |
296 | 296 | <div class="content feature-section-item last-feature"> |
297 | 297 | |
298 | - <img src="<?php echo GIVE_PLUGIN_URL . '/assets/images/give-logo-photo-mashup.png' ?>" title="Give" alt="Give"> |
|
298 | + <img src="<?php echo GIVE_PLUGIN_URL.'/assets/images/give-logo-photo-mashup.png' ?>" title="Give" alt="Give"> |
|
299 | 299 | |
300 | 300 | </div> |
301 | 301 | |
@@ -315,18 +315,18 @@ discard block |
||
315 | 315 | * @return void |
316 | 316 | */ |
317 | 317 | public function changelog_screen() { |
318 | - list( $display_version ) = explode( '-', GIVE_VERSION ); |
|
318 | + list($display_version) = explode('-', GIVE_VERSION); |
|
319 | 319 | ?> |
320 | 320 | <div class="wrap about-wrap"> |
321 | - <h1><?php _e( 'Give Changelog', 'give' ); ?></h1> |
|
321 | + <h1><?php _e('Give Changelog', 'give'); ?></h1> |
|
322 | 322 | |
323 | - <div class="about-text"><?php printf( __( 'Thank you for updating to the latest version! Give %s is ready to make your online store faster, safer, and better!', 'give' ), $display_version ); ?></div> |
|
324 | - <div class="give-badge"><?php printf( __( 'Version %s', 'give' ), $display_version ); ?></div> |
|
323 | + <div class="about-text"><?php printf(__('Thank you for updating to the latest version! Give %s is ready to make your online store faster, safer, and better!', 'give'), $display_version); ?></div> |
|
324 | + <div class="give-badge"><?php printf(__('Version %s', 'give'), $display_version); ?></div> |
|
325 | 325 | |
326 | 326 | <?php $this->tabs(); ?> |
327 | 327 | |
328 | 328 | <div class="changelog"> |
329 | - <h3><?php _e( 'Full Changelog', 'give' ); ?></h3> |
|
329 | + <h3><?php _e('Full Changelog', 'give'); ?></h3> |
|
330 | 330 | |
331 | 331 | <div class="feature-section"> |
332 | 332 | <?php echo $this->parse_readme(); ?> |
@@ -334,10 +334,10 @@ discard block |
||
334 | 334 | </div> |
335 | 335 | |
336 | 336 | <div class="return-to-dashboard"> |
337 | - <a href="<?php echo esc_url( admin_url( add_query_arg( array( |
|
337 | + <a href="<?php echo esc_url(admin_url(add_query_arg(array( |
|
338 | 338 | 'post_type' => 'give_forms', |
339 | 339 | 'page' => 'give-settings' |
340 | - ), 'edit.php' ) ) ); ?>"><?php _e( 'Go to Give Settings', 'give' ); ?></a> |
|
340 | + ), 'edit.php'))); ?>"><?php _e('Go to Give Settings', 'give'); ?></a> |
|
341 | 341 | </div> |
342 | 342 | </div> |
343 | 343 | <?php |
@@ -351,35 +351,35 @@ discard block |
||
351 | 351 | * @return void |
352 | 352 | */ |
353 | 353 | public function getting_started_screen() { |
354 | - list( $display_version ) = explode( '-', GIVE_VERSION ); |
|
354 | + list($display_version) = explode('-', GIVE_VERSION); |
|
355 | 355 | ?> |
356 | 356 | <div class="wrap about-wrap get-started"> |
357 | - <h1 class="welcome-h1"><?php printf( __( 'Give %s - Getting Started Guide', 'give' ), $display_version ); ?></h1> |
|
357 | + <h1 class="welcome-h1"><?php printf(__('Give %s - Getting Started Guide', 'give'), $display_version); ?></h1> |
|
358 | 358 | |
359 | 359 | <?php give_social_media_elements() ?> |
360 | 360 | |
361 | - <div class="about-text"><?php _e( 'Welcome to the getting started guide.', 'give' ); ?></div> |
|
361 | + <div class="about-text"><?php _e('Welcome to the getting started guide.', 'give'); ?></div> |
|
362 | 362 | |
363 | - <p class="newsletter-intro"><?php _e( 'Don\'t forget to sign up for the newsletter!', 'give' ); ?>.</p> |
|
363 | + <p class="newsletter-intro"><?php _e('Don\'t forget to sign up for the newsletter!', 'give'); ?>.</p> |
|
364 | 364 | |
365 | 365 | <?php give_get_newsletter() ?> |
366 | 366 | |
367 | - <div class="give-badge"><?php printf( __( 'Version %s', 'give' ), $display_version ); ?></div> |
|
367 | + <div class="give-badge"><?php printf(__('Version %s', 'give'), $display_version); ?></div> |
|
368 | 368 | |
369 | 369 | <?php $this->tabs(); ?> |
370 | 370 | |
371 | 371 | |
372 | - <div class="about-text"><?php printf( __( '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 ); ?></div> |
|
372 | + <div class="about-text"><?php printf(__('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); ?></div> |
|
373 | 373 | |
374 | 374 | |
375 | 375 | <div class="feature-section clearfix"> |
376 | 376 | |
377 | 377 | <div class="content feature-section-item"> |
378 | - <h3><?php _e( 'STEP 1: Create a New Form', 'give' ); ?></h3> |
|
378 | + <h3><?php _e('STEP 1: Create a New Form', 'give'); ?></h3> |
|
379 | 379 | |
380 | - <p><?php _e( 'Give is driven by it\'s powerful form building features. But it is not simply a "form". From the "Add New Form" page you\'ll be able to choose how and where you want to receive your donations. You\'ll be able to set the donation amounts. You even get to choose whether you want to create a whole page for your form, or embed it on a different page of your site.', 'give' ); ?></p> |
|
380 | + <p><?php _e('Give is driven by it\'s powerful form building features. But it is not simply a "form". From the "Add New Form" page you\'ll be able to choose how and where you want to receive your donations. You\'ll be able to set the donation amounts. You even get to choose whether you want to create a whole page for your form, or embed it on a different page of your site.', 'give'); ?></p> |
|
381 | 381 | |
382 | - <p><?php _e( 'But all of these features begin simply by going to the menu and choosing "Add New Form."', 'give' ); ?></p> |
|
382 | + <p><?php _e('But all of these features begin simply by going to the menu and choosing "Add New Form."', 'give'); ?></p> |
|
383 | 383 | </div> |
384 | 384 | |
385 | 385 | <div class="content feature-section-item last-feature"> |
@@ -396,9 +396,9 @@ discard block |
||
396 | 396 | </div> |
397 | 397 | |
398 | 398 | <div class="content feature-section-item last-feature"> |
399 | - <h3><?php _e( 'STEP 2: Choose Your Levels', 'give' ); ?></h3> |
|
399 | + <h3><?php _e('STEP 2: Choose Your Levels', 'give'); ?></h3> |
|
400 | 400 | |
401 | - <p><?php _e( 'Each Form can be set to receive either a pre-determined amount or have multiple suggested levels of giving. Choosing "Multi-level Donation" opens up the levels section where you can add as many levels as you like with your own custom names and amounts.', 'give' ); ?></p> |
|
401 | + <p><?php _e('Each Form can be set to receive either a pre-determined amount or have multiple suggested levels of giving. Choosing "Multi-level Donation" opens up the levels section where you can add as many levels as you like with your own custom names and amounts.', 'give'); ?></p> |
|
402 | 402 | </div> |
403 | 403 | |
404 | 404 | </div> |
@@ -407,11 +407,11 @@ discard block |
||
407 | 407 | <div class="feature-section clearfix"> |
408 | 408 | |
409 | 409 | <div class="content feature-section-item add-content"> |
410 | - <h3><?php _e( 'STEP 3: Landing Page or Shortcode Mode?', 'give' ); ?></h3> |
|
410 | + <h3><?php _e('STEP 3: Landing Page or Shortcode Mode?', 'give'); ?></h3> |
|
411 | 411 | |
412 | - <p><?php _e( 'Every form you create in Give can either become it\'s own stand-alone page, or it can be inserted into any other page or post throughout your site as a Shortcode.', 'give' ); ?></p> |
|
412 | + <p><?php _e('Every form you create in Give can either become it\'s own stand-alone page, or it can be inserted into any other page or post throughout your site as a Shortcode.', 'give'); ?></p> |
|
413 | 413 | |
414 | - <p><?php _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> |
|
414 | + <p><?php _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> |
|
415 | 415 | </div> |
416 | 416 | |
417 | 417 | <div class="content feature-section-item last-feature"> |
@@ -428,9 +428,9 @@ discard block |
||
428 | 428 | </div> |
429 | 429 | |
430 | 430 | <div class="content feature-section-item last-feature"> |
431 | - <h3><?php _e( 'STEP 4: Configure Your Display Options', 'give' ); ?></h3> |
|
431 | + <h3><?php _e('STEP 4: Configure Your Display Options', 'give'); ?></h3> |
|
432 | 432 | |
433 | - <p><?php _e( 'Lastly, you can present the form in a lot of different ways. With the "Display Options" section you can configure how the credit card field appears, the submit button text, which Gateway you want to use, whether Guests (non-logged in users) can donate or not, and a log-in form.', 'give' ); ?></p> |
|
433 | + <p><?php _e('Lastly, you can present the form in a lot of different ways. With the "Display Options" section you can configure how the credit card field appears, the submit button text, which Gateway you want to use, whether Guests (non-logged in users) can donate or not, and a log-in form.', 'give'); ?></p> |
|
434 | 434 | </div> |
435 | 435 | |
436 | 436 | |
@@ -450,26 +450,26 @@ discard block |
||
450 | 450 | * @return void |
451 | 451 | */ |
452 | 452 | public function credits_screen() { |
453 | - list( $display_version ) = explode( '-', GIVE_VERSION ); |
|
453 | + list($display_version) = explode('-', GIVE_VERSION); |
|
454 | 454 | ?> |
455 | 455 | <div class="wrap about-wrap"> |
456 | - <h1 class="welcome-h1"><?php printf( __( 'Give %s - Credits', 'give' ), $display_version ); ?></h1> |
|
456 | + <h1 class="welcome-h1"><?php printf(__('Give %s - Credits', 'give'), $display_version); ?></h1> |
|
457 | 457 | |
458 | 458 | <?php give_social_media_elements() ?> |
459 | 459 | |
460 | - <div class="about-text"><?php printf( __( 'Thanks to all those who have contributed code directly or indirectly. ', 'give' ), $display_version ); ?></div> |
|
460 | + <div class="about-text"><?php printf(__('Thanks to all those who have contributed code directly or indirectly. ', 'give'), $display_version); ?></div> |
|
461 | 461 | |
462 | - <div class="about-text"><?php _e( 'Welcome to the getting started guide.', 'give' ); ?></div> |
|
462 | + <div class="about-text"><?php _e('Welcome to the getting started guide.', 'give'); ?></div> |
|
463 | 463 | |
464 | 464 | <p class="newsletter-intro">Be sure to sign up for the Give newsletter below to stay informed of important updates and news.</p> |
465 | 465 | |
466 | 466 | <?php give_get_newsletter() ?> |
467 | 467 | |
468 | - <div class="give-badge"><?php printf( __( 'Version %s', 'give' ), $display_version ); ?></div> |
|
468 | + <div class="give-badge"><?php printf(__('Version %s', 'give'), $display_version); ?></div> |
|
469 | 469 | |
470 | 470 | <?php $this->tabs(); ?> |
471 | 471 | |
472 | - <p class="about-description"><?php _e( 'Give is created by a dedicated team of developers. If you are interested in contributing please visit the <a href="https://github.com/WordImpress/give" target="_blank">GitHub Repo</a>.', 'give' ); ?></p> |
|
472 | + <p class="about-description"><?php _e('Give is created by a dedicated team of developers. If you are interested in contributing please visit the <a href="https://github.com/WordImpress/give" target="_blank">GitHub Repo</a>.', 'give'); ?></p> |
|
473 | 473 | |
474 | 474 | <?php echo $this->contributors(); ?> |
475 | 475 | </div> |
@@ -484,21 +484,21 @@ discard block |
||
484 | 484 | * @return string $readme HTML formatted readme file |
485 | 485 | */ |
486 | 486 | public function parse_readme() { |
487 | - $file = file_exists( GIVE_PLUGIN_DIR . 'readme.txt' ) ? GIVE_PLUGIN_DIR . 'readme.txt' : null; |
|
487 | + $file = file_exists(GIVE_PLUGIN_DIR.'readme.txt') ? GIVE_PLUGIN_DIR.'readme.txt' : null; |
|
488 | 488 | |
489 | - if ( ! $file ) { |
|
490 | - $readme = '<p>' . __( 'No valid changlog was found.', 'give' ) . '</p>'; |
|
489 | + if ( ! $file) { |
|
490 | + $readme = '<p>'.__('No valid changlog was found.', 'give').'</p>'; |
|
491 | 491 | } else { |
492 | - $readme = file_get_contents( $file ); |
|
493 | - $readme = nl2br( esc_html( $readme ) ); |
|
494 | - $readme = explode( '== Changelog ==', $readme ); |
|
495 | - $readme = end( $readme ); |
|
496 | - |
|
497 | - $readme = preg_replace( '/`(.*?)`/', '<code>\\1</code>', $readme ); |
|
498 | - $readme = preg_replace( '/[\040]\*\*(.*?)\*\*/', ' <strong>\\1</strong>', $readme ); |
|
499 | - $readme = preg_replace( '/[\040]\*(.*?)\*/', ' <em>\\1</em>', $readme ); |
|
500 | - $readme = preg_replace( '/= (.*?) =/', '<h4>\\1</h4>', $readme ); |
|
501 | - $readme = preg_replace( '/\[(.*?)\]\((.*?)\)/', '<a href="\\2">\\1</a>', $readme ); |
|
492 | + $readme = file_get_contents($file); |
|
493 | + $readme = nl2br(esc_html($readme)); |
|
494 | + $readme = explode('== Changelog ==', $readme); |
|
495 | + $readme = end($readme); |
|
496 | + |
|
497 | + $readme = preg_replace('/`(.*?)`/', '<code>\\1</code>', $readme); |
|
498 | + $readme = preg_replace('/[\040]\*\*(.*?)\*\*/', ' <strong>\\1</strong>', $readme); |
|
499 | + $readme = preg_replace('/[\040]\*(.*?)\*/', ' <em>\\1</em>', $readme); |
|
500 | + $readme = preg_replace('/= (.*?) =/', '<h4>\\1</h4>', $readme); |
|
501 | + $readme = preg_replace('/\[(.*?)\]\((.*?)\)/', '<a href="\\2">\\1</a>', $readme); |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | return $readme; |
@@ -515,21 +515,21 @@ discard block |
||
515 | 515 | public function contributors() { |
516 | 516 | $contributors = $this->get_contributors(); |
517 | 517 | |
518 | - if ( empty( $contributors ) ) { |
|
518 | + if (empty($contributors)) { |
|
519 | 519 | return ''; |
520 | 520 | } |
521 | 521 | |
522 | 522 | $contributor_list = '<ul class="wp-people-group">'; |
523 | 523 | |
524 | - foreach ( $contributors as $contributor ) { |
|
524 | + foreach ($contributors as $contributor) { |
|
525 | 525 | $contributor_list .= '<li class="wp-person">'; |
526 | - $contributor_list .= sprintf( '<a href="%s" title="%s">', |
|
527 | - esc_url( 'https://github.com/' . $contributor->login ), |
|
528 | - esc_html( sprintf( __( 'View %s', 'give' ), $contributor->login ) ) |
|
526 | + $contributor_list .= sprintf('<a href="%s" title="%s">', |
|
527 | + esc_url('https://github.com/'.$contributor->login), |
|
528 | + esc_html(sprintf(__('View %s', 'give'), $contributor->login)) |
|
529 | 529 | ); |
530 | - $contributor_list .= sprintf( '<img src="%s" width="64" height="64" class="gravatar" alt="%s" />', esc_url( $contributor->avatar_url ), esc_html( $contributor->login ) ); |
|
530 | + $contributor_list .= sprintf('<img src="%s" width="64" height="64" class="gravatar" alt="%s" />', esc_url($contributor->avatar_url), esc_html($contributor->login)); |
|
531 | 531 | $contributor_list .= '</a>'; |
532 | - $contributor_list .= sprintf( '<a class="web" href="%s">%s</a>', esc_url( 'https://github.com/' . $contributor->login ), esc_html( $contributor->login ) ); |
|
532 | + $contributor_list .= sprintf('<a class="web" href="%s">%s</a>', esc_url('https://github.com/'.$contributor->login), esc_html($contributor->login)); |
|
533 | 533 | $contributor_list .= '</a>'; |
534 | 534 | $contributor_list .= '</li>'; |
535 | 535 | } |
@@ -547,25 +547,25 @@ discard block |
||
547 | 547 | * @return array $contributors List of contributors |
548 | 548 | */ |
549 | 549 | public function get_contributors() { |
550 | - $contributors = get_transient( 'give_contributors' ); |
|
550 | + $contributors = get_transient('give_contributors'); |
|
551 | 551 | |
552 | - if ( false !== $contributors ) { |
|
552 | + if (false !== $contributors) { |
|
553 | 553 | return $contributors; |
554 | 554 | } |
555 | 555 | |
556 | - $response = wp_remote_get( 'https://api.github.com/repos/WordImpress/Give/contributors', array( 'sslverify' => false ) ); |
|
556 | + $response = wp_remote_get('https://api.github.com/repos/WordImpress/Give/contributors', array('sslverify' => false)); |
|
557 | 557 | |
558 | - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { |
|
558 | + if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) { |
|
559 | 559 | return array(); |
560 | 560 | } |
561 | 561 | |
562 | - $contributors = json_decode( wp_remote_retrieve_body( $response ) ); |
|
562 | + $contributors = json_decode(wp_remote_retrieve_body($response)); |
|
563 | 563 | |
564 | - if ( ! is_array( $contributors ) ) { |
|
564 | + if ( ! is_array($contributors)) { |
|
565 | 565 | return array(); |
566 | 566 | } |
567 | 567 | |
568 | - set_transient( 'give_contributors', $contributors, 3600 ); |
|
568 | + set_transient('give_contributors', $contributors, 3600); |
|
569 | 569 | |
570 | 570 | return $contributors; |
571 | 571 | } |
@@ -584,24 +584,24 @@ discard block |
||
584 | 584 | |
585 | 585 | |
586 | 586 | // Bail if no activation redirect |
587 | - if ( ! get_transient( '_give_activation_redirect' ) ) { |
|
587 | + if ( ! get_transient('_give_activation_redirect')) { |
|
588 | 588 | return; |
589 | 589 | } |
590 | 590 | |
591 | 591 | // Delete the redirect transient |
592 | - delete_transient( '_give_activation_redirect' ); |
|
592 | + delete_transient('_give_activation_redirect'); |
|
593 | 593 | |
594 | 594 | // Bail if activating from network, or bulk |
595 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
595 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
596 | 596 | return; |
597 | 597 | } |
598 | 598 | |
599 | - $upgrade = get_option( 'give_version_upgraded_from' ); |
|
599 | + $upgrade = get_option('give_version_upgraded_from'); |
|
600 | 600 | |
601 | - if ( ! $upgrade ) { // First time install |
|
602 | - wp_safe_redirect( admin_url( 'index.php?page=give-about' ) ); |
|
601 | + if ( ! $upgrade) { // First time install |
|
602 | + wp_safe_redirect(admin_url('index.php?page=give-about')); |
|
603 | 603 | exit; |
604 | - } elseif( isset( $give_options['disable_welcome'] ) ) { // Welcome is disabled in settings |
|
604 | + } elseif (isset($give_options['disable_welcome'])) { // Welcome is disabled in settings |
|
605 | 605 | |
606 | 606 | } else { // Welcome is NOT disabled in settings |
607 | 607 | wp_safe_redirect(admin_url('index.php?page=give-about')); |
@@ -10,7 +10,7 @@ |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
13 | +if ( ! defined('ABSPATH')) exit; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Give_API_V1 Class |
@@ -10,7 +10,9 @@ |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
13 | +if ( ! defined( 'ABSPATH' ) ) { |
|
14 | + exit; |
|
15 | +} |
|
14 | 16 | |
15 | 17 | /** |
16 | 18 | * Give_API_V1 Class |
@@ -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 | |
@@ -96,29 +96,29 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @since 1.0 |
98 | 98 | */ |
99 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
99 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
100 | 100 | |
101 | 101 | $this->db = new Give_DB_Customers; |
102 | 102 | |
103 | - if ( false === $_id_or_email || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) ) { |
|
103 | + if (false === $_id_or_email || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))) { |
|
104 | 104 | return false; |
105 | 105 | } |
106 | 106 | |
107 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
107 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
108 | 108 | |
109 | - if ( is_numeric( $_id_or_email ) ) { |
|
109 | + if (is_numeric($_id_or_email)) { |
|
110 | 110 | $field = $by_user_id ? 'user_id' : 'id'; |
111 | 111 | } else { |
112 | 112 | $field = 'email'; |
113 | 113 | } |
114 | 114 | |
115 | - $customer = $this->db->get_customer_by( $field, $_id_or_email ); |
|
115 | + $customer = $this->db->get_customer_by($field, $_id_or_email); |
|
116 | 116 | |
117 | - if ( empty( $customer ) || ! is_object( $customer ) ) { |
|
117 | + if (empty($customer) || ! is_object($customer)) { |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | |
121 | - $this->setup_customer( $customer ); |
|
121 | + $this->setup_customer($customer); |
|
122 | 122 | |
123 | 123 | } |
124 | 124 | |
@@ -131,15 +131,15 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @return bool If the setup was successful or not |
133 | 133 | */ |
134 | - private function setup_customer( $customer ) { |
|
134 | + private function setup_customer($customer) { |
|
135 | 135 | |
136 | - if ( ! is_object( $customer ) ) { |
|
136 | + if ( ! is_object($customer)) { |
|
137 | 137 | return false; |
138 | 138 | } |
139 | 139 | |
140 | - foreach ( $customer as $key => $value ) { |
|
140 | + foreach ($customer as $key => $value) { |
|
141 | 141 | |
142 | - switch ( $key ) { |
|
142 | + switch ($key) { |
|
143 | 143 | |
144 | 144 | case 'notes': |
145 | 145 | $this->$key = $this->get_notes(); |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | } |
155 | 155 | |
156 | 156 | // Customer ID and email are the only things that are necessary, make sure they exist |
157 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
157 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
158 | 158 | return true; |
159 | 159 | } |
160 | 160 | |
@@ -167,15 +167,15 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @since 1.0 |
169 | 169 | */ |
170 | - public function __get( $key ) { |
|
170 | + public function __get($key) { |
|
171 | 171 | |
172 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
172 | + if (method_exists($this, 'get_'.$key)) { |
|
173 | 173 | |
174 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
174 | + return call_user_func(array($this, 'get_'.$key)); |
|
175 | 175 | |
176 | 176 | } else { |
177 | 177 | |
178 | - return new WP_Error( 'give-customer-invalid-property', sprintf( __( 'Can\'t get property %s', 'give' ), $key ) ); |
|
178 | + return new WP_Error('give-customer-invalid-property', sprintf(__('Can\'t get property %s', 'give'), $key)); |
|
179 | 179 | |
180 | 180 | } |
181 | 181 | |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | * |
191 | 191 | * @return mixed False if not a valid creation, Customer ID if user is found or valid creation |
192 | 192 | */ |
193 | - public function create( $data = array() ) { |
|
193 | + public function create($data = array()) { |
|
194 | 194 | |
195 | - if ( $this->id != 0 || empty( $data ) ) { |
|
195 | + if ($this->id != 0 || empty($data)) { |
|
196 | 196 | return false; |
197 | 197 | } |
198 | 198 | |
@@ -200,34 +200,34 @@ discard block |
||
200 | 200 | 'payment_ids' => '' |
201 | 201 | ); |
202 | 202 | |
203 | - $args = wp_parse_args( $data, $defaults ); |
|
204 | - $args = $this->sanitize_columns( $args ); |
|
203 | + $args = wp_parse_args($data, $defaults); |
|
204 | + $args = $this->sanitize_columns($args); |
|
205 | 205 | |
206 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
206 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
207 | 207 | return false; |
208 | 208 | } |
209 | 209 | |
210 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
211 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
210 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
211 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
212 | 212 | } |
213 | 213 | |
214 | - do_action( 'give_customer_pre_create', $args ); |
|
214 | + do_action('give_customer_pre_create', $args); |
|
215 | 215 | |
216 | 216 | $created = false; |
217 | 217 | |
218 | 218 | // The DB class 'add' implies an update if the customer being asked to be created already exists |
219 | - if ( $this->db->add( $data ) ) { |
|
219 | + if ($this->db->add($data)) { |
|
220 | 220 | |
221 | 221 | // We've successfully added/updated the customer, reset the class vars with the new data |
222 | - $customer = $this->db->get_customer_by( 'email', $args['email'] ); |
|
222 | + $customer = $this->db->get_customer_by('email', $args['email']); |
|
223 | 223 | |
224 | 224 | // Setup the customer data with the values from DB |
225 | - $this->setup_customer( $customer ); |
|
225 | + $this->setup_customer($customer); |
|
226 | 226 | |
227 | 227 | $created = $this->id; |
228 | 228 | } |
229 | 229 | |
230 | - do_action( 'give_customer_post_create', $created, $args ); |
|
230 | + do_action('give_customer_post_create', $created, $args); |
|
231 | 231 | |
232 | 232 | return $created; |
233 | 233 | |
@@ -242,27 +242,27 @@ discard block |
||
242 | 242 | * |
243 | 243 | * @return bool If the update was successful or not |
244 | 244 | */ |
245 | - public function update( $data = array() ) { |
|
245 | + public function update($data = array()) { |
|
246 | 246 | |
247 | - if ( empty( $data ) ) { |
|
247 | + if (empty($data)) { |
|
248 | 248 | return false; |
249 | 249 | } |
250 | 250 | |
251 | - $data = $this->sanitize_columns( $data ); |
|
251 | + $data = $this->sanitize_columns($data); |
|
252 | 252 | |
253 | - do_action( 'give_customer_pre_update', $this->id, $data ); |
|
253 | + do_action('give_customer_pre_update', $this->id, $data); |
|
254 | 254 | |
255 | 255 | $updated = false; |
256 | 256 | |
257 | - if ( $this->db->update( $this->id, $data ) ) { |
|
257 | + if ($this->db->update($this->id, $data)) { |
|
258 | 258 | |
259 | - $customer = $this->db->get_customer_by( 'id', $this->id ); |
|
260 | - $this->setup_customer( $customer ); |
|
259 | + $customer = $this->db->get_customer_by('id', $this->id); |
|
260 | + $this->setup_customer($customer); |
|
261 | 261 | |
262 | 262 | $updated = true; |
263 | 263 | } |
264 | 264 | |
265 | - do_action( 'give_customer_post_update', $updated, $this->id, $data ); |
|
265 | + do_action('give_customer_post_update', $updated, $this->id, $data); |
|
266 | 266 | |
267 | 267 | return $updated; |
268 | 268 | } |
@@ -278,44 +278,44 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @return bool If the attachment was successfuly |
280 | 280 | */ |
281 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
281 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
282 | 282 | |
283 | - if ( empty( $payment_id ) ) { |
|
283 | + if (empty($payment_id)) { |
|
284 | 284 | return false; |
285 | 285 | } |
286 | 286 | |
287 | - if ( empty( $this->payment_ids ) ) { |
|
287 | + if (empty($this->payment_ids)) { |
|
288 | 288 | |
289 | 289 | $new_payment_ids = $payment_id; |
290 | 290 | |
291 | 291 | } else { |
292 | 292 | |
293 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
293 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
294 | 294 | |
295 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
295 | + if (in_array($payment_id, $payment_ids)) { |
|
296 | 296 | $update_stats = false; |
297 | 297 | } |
298 | 298 | |
299 | 299 | $payment_ids[] = $payment_id; |
300 | 300 | |
301 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
301 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
302 | 302 | |
303 | 303 | } |
304 | 304 | |
305 | - do_action( 'give_customer_pre_attach_payment', $payment_id, $this->id ); |
|
305 | + do_action('give_customer_pre_attach_payment', $payment_id, $this->id); |
|
306 | 306 | |
307 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
307 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
308 | 308 | |
309 | - if ( $payment_added ) { |
|
309 | + if ($payment_added) { |
|
310 | 310 | |
311 | 311 | $this->payment_ids = $new_payment_ids; |
312 | 312 | |
313 | 313 | // We added this payment successfully, increment the stats |
314 | - if ( $update_stats ) { |
|
315 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
314 | + if ($update_stats) { |
|
315 | + $payment_amount = give_get_payment_amount($payment_id); |
|
316 | 316 | |
317 | - if ( ! empty( $payment_amount ) ) { |
|
318 | - $this->increase_value( $payment_amount ); |
|
317 | + if ( ! empty($payment_amount)) { |
|
318 | + $this->increase_value($payment_amount); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | $this->increase_purchase_count(); |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | |
324 | 324 | } |
325 | 325 | |
326 | - do_action( 'give_customer_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
326 | + do_action('give_customer_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
327 | 327 | |
328 | 328 | return $payment_added; |
329 | 329 | } |
@@ -339,44 +339,44 @@ discard block |
||
339 | 339 | * |
340 | 340 | * @return boolean If the removal was successful |
341 | 341 | */ |
342 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
342 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
343 | 343 | |
344 | - if ( empty( $payment_id ) ) { |
|
344 | + if (empty($payment_id)) { |
|
345 | 345 | return false; |
346 | 346 | } |
347 | 347 | |
348 | 348 | $new_payment_ids = ''; |
349 | 349 | |
350 | - if ( ! empty( $this->payment_ids ) ) { |
|
350 | + if ( ! empty($this->payment_ids)) { |
|
351 | 351 | |
352 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
352 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
353 | 353 | |
354 | - $pos = array_search( $payment_id, $payment_ids ); |
|
355 | - if ( false === $pos ) { |
|
354 | + $pos = array_search($payment_id, $payment_ids); |
|
355 | + if (false === $pos) { |
|
356 | 356 | return false; |
357 | 357 | } |
358 | 358 | |
359 | - unset( $payment_ids[ $pos ] ); |
|
360 | - $payment_ids = array_filter( $payment_ids ); |
|
359 | + unset($payment_ids[$pos]); |
|
360 | + $payment_ids = array_filter($payment_ids); |
|
361 | 361 | |
362 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
362 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
363 | 363 | |
364 | 364 | } |
365 | 365 | |
366 | - do_action( 'give_customer_pre_remove_payment', $payment_id, $this->id ); |
|
366 | + do_action('give_customer_pre_remove_payment', $payment_id, $this->id); |
|
367 | 367 | |
368 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
368 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
369 | 369 | |
370 | - if ( $payment_removed ) { |
|
370 | + if ($payment_removed) { |
|
371 | 371 | |
372 | 372 | $this->payment_ids = $new_payment_ids; |
373 | 373 | |
374 | - if ( $update_stats ) { |
|
374 | + if ($update_stats) { |
|
375 | 375 | // We removed this payment successfully, decrement the stats |
376 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
376 | + $payment_amount = give_get_payment_amount($payment_id); |
|
377 | 377 | |
378 | - if ( ! empty( $payment_amount ) ) { |
|
379 | - $this->decrease_value( $payment_amount ); |
|
378 | + if ( ! empty($payment_amount)) { |
|
379 | + $this->decrease_value($payment_amount); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | $this->decrease_purchase_count(); |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | |
385 | 385 | } |
386 | 386 | |
387 | - do_action( 'give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
387 | + do_action('give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
388 | 388 | |
389 | 389 | return $payment_removed; |
390 | 390 | |
@@ -399,22 +399,22 @@ discard block |
||
399 | 399 | * |
400 | 400 | * @return int The purchase count |
401 | 401 | */ |
402 | - public function increase_purchase_count( $count = 1 ) { |
|
402 | + public function increase_purchase_count($count = 1) { |
|
403 | 403 | |
404 | 404 | // Make sure it's numeric and not negative |
405 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
405 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
406 | 406 | return false; |
407 | 407 | } |
408 | 408 | |
409 | 409 | $new_total = (int) $this->purchase_count + (int) $count; |
410 | 410 | |
411 | - do_action( 'give_customer_pre_increase_purchase_count', $count, $this->id ); |
|
411 | + do_action('give_customer_pre_increase_purchase_count', $count, $this->id); |
|
412 | 412 | |
413 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
413 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
414 | 414 | $this->purchase_count = $new_total; |
415 | 415 | } |
416 | 416 | |
417 | - do_action( 'give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id ); |
|
417 | + do_action('give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id); |
|
418 | 418 | |
419 | 419 | return $this->purchase_count; |
420 | 420 | } |
@@ -428,26 +428,26 @@ discard block |
||
428 | 428 | * |
429 | 429 | * @return mixed If successful, the new count, otherwise false |
430 | 430 | */ |
431 | - public function decrease_purchase_count( $count = 1 ) { |
|
431 | + public function decrease_purchase_count($count = 1) { |
|
432 | 432 | |
433 | 433 | // Make sure it's numeric and not negative |
434 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
434 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
435 | 435 | return false; |
436 | 436 | } |
437 | 437 | |
438 | 438 | $new_total = (int) $this->purchase_count - (int) $count; |
439 | 439 | |
440 | - if ( $new_total < 0 ) { |
|
440 | + if ($new_total < 0) { |
|
441 | 441 | $new_total = 0; |
442 | 442 | } |
443 | 443 | |
444 | - do_action( 'give_customer_pre_decrease_purchase_count', $count, $this->id ); |
|
444 | + do_action('give_customer_pre_decrease_purchase_count', $count, $this->id); |
|
445 | 445 | |
446 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
446 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
447 | 447 | $this->purchase_count = $new_total; |
448 | 448 | } |
449 | 449 | |
450 | - do_action( 'give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id ); |
|
450 | + do_action('give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id); |
|
451 | 451 | |
452 | 452 | return $this->purchase_count; |
453 | 453 | } |
@@ -461,17 +461,17 @@ discard block |
||
461 | 461 | * |
462 | 462 | * @return mixed If successful, the new value, otherwise false |
463 | 463 | */ |
464 | - public function increase_value( $value = 0.00 ) { |
|
464 | + public function increase_value($value = 0.00) { |
|
465 | 465 | |
466 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
466 | + $new_value = floatval($this->purchase_value) + $value; |
|
467 | 467 | |
468 | - do_action( 'give_customer_pre_increase_value', $value, $this->id ); |
|
468 | + do_action('give_customer_pre_increase_value', $value, $this->id); |
|
469 | 469 | |
470 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
470 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
471 | 471 | $this->purchase_value = $new_value; |
472 | 472 | } |
473 | 473 | |
474 | - do_action( 'give_customer_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
474 | + do_action('give_customer_post_increase_value', $this->purchase_value, $value, $this->id); |
|
475 | 475 | |
476 | 476 | return $this->purchase_value; |
477 | 477 | } |
@@ -485,21 +485,21 @@ discard block |
||
485 | 485 | * |
486 | 486 | * @return mixed If successful, the new value, otherwise false |
487 | 487 | */ |
488 | - public function decrease_value( $value = 0.00 ) { |
|
488 | + public function decrease_value($value = 0.00) { |
|
489 | 489 | |
490 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
490 | + $new_value = floatval($this->purchase_value) - $value; |
|
491 | 491 | |
492 | - if ( $new_value < 0 ) { |
|
492 | + if ($new_value < 0) { |
|
493 | 493 | $new_value = 0.00; |
494 | 494 | } |
495 | 495 | |
496 | - do_action( 'give_customer_pre_decrease_value', $value, $this->id ); |
|
496 | + do_action('give_customer_pre_decrease_value', $value, $this->id); |
|
497 | 497 | |
498 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
498 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
499 | 499 | $this->purchase_value = $new_value; |
500 | 500 | } |
501 | 501 | |
502 | - do_action( 'give_customer_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
502 | + do_action('give_customer_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
503 | 503 | |
504 | 504 | return $this->purchase_value; |
505 | 505 | } |
@@ -514,15 +514,15 @@ discard block |
||
514 | 514 | * |
515 | 515 | * @return array The notes requsted |
516 | 516 | */ |
517 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
517 | + public function get_notes($length = 20, $paged = 1) { |
|
518 | 518 | |
519 | - $length = is_numeric( $length ) ? $length : 20; |
|
520 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
519 | + $length = is_numeric($length) ? $length : 20; |
|
520 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
521 | 521 | |
522 | 522 | $all_notes = $this->get_raw_notes(); |
523 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
523 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
524 | 524 | |
525 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
525 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
526 | 526 | |
527 | 527 | return $desired_notes; |
528 | 528 | |
@@ -537,9 +537,9 @@ discard block |
||
537 | 537 | public function get_notes_count() { |
538 | 538 | |
539 | 539 | $all_notes = $this->get_raw_notes(); |
540 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
540 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
541 | 541 | |
542 | - return count( $notes_array ); |
|
542 | + return count($notes_array); |
|
543 | 543 | |
544 | 544 | } |
545 | 545 | |
@@ -552,32 +552,32 @@ discard block |
||
552 | 552 | * |
553 | 553 | * @return string|boolean The new note if added succesfully, false otherwise |
554 | 554 | */ |
555 | - public function add_note( $note = '' ) { |
|
555 | + public function add_note($note = '') { |
|
556 | 556 | |
557 | - $note = trim( $note ); |
|
558 | - if ( empty( $note ) ) { |
|
557 | + $note = trim($note); |
|
558 | + if (empty($note)) { |
|
559 | 559 | return false; |
560 | 560 | } |
561 | 561 | |
562 | 562 | $notes = $this->get_raw_notes(); |
563 | 563 | |
564 | - if ( empty( $notes ) ) { |
|
564 | + if (empty($notes)) { |
|
565 | 565 | $notes = ''; |
566 | 566 | } |
567 | 567 | |
568 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
569 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
570 | - $notes .= "\n\n" . $new_note; |
|
568 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
569 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
570 | + $notes .= "\n\n".$new_note; |
|
571 | 571 | |
572 | - do_action( 'give_customer_pre_add_note', $new_note, $this->id ); |
|
572 | + do_action('give_customer_pre_add_note', $new_note, $this->id); |
|
573 | 573 | |
574 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
574 | + $updated = $this->update(array('notes' => $notes)); |
|
575 | 575 | |
576 | - if ( $updated ) { |
|
576 | + if ($updated) { |
|
577 | 577 | $this->notes = $this->get_notes(); |
578 | 578 | } |
579 | 579 | |
580 | - do_action( 'give_customer_post_add_note', $this->notes, $new_note, $this->id ); |
|
580 | + do_action('give_customer_post_add_note', $this->notes, $new_note, $this->id); |
|
581 | 581 | |
582 | 582 | // Return the formatted note, so we can test, as well as update any displays |
583 | 583 | return $new_note; |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | */ |
593 | 593 | private function get_raw_notes() { |
594 | 594 | |
595 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
595 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
596 | 596 | |
597 | 597 | return $all_notes; |
598 | 598 | |
@@ -607,51 +607,51 @@ discard block |
||
607 | 607 | * |
608 | 608 | * @return array The sanitized data, based off column defaults |
609 | 609 | */ |
610 | - private function sanitize_columns( $data ) { |
|
610 | + private function sanitize_columns($data) { |
|
611 | 611 | |
612 | 612 | $columns = $this->db->get_columns(); |
613 | 613 | $default_values = $this->db->get_column_defaults(); |
614 | 614 | |
615 | - foreach ( $columns as $key => $type ) { |
|
615 | + foreach ($columns as $key => $type) { |
|
616 | 616 | |
617 | 617 | // Only sanitize data that we were provided |
618 | - if ( ! array_key_exists( $key, $data ) ) { |
|
618 | + if ( ! array_key_exists($key, $data)) { |
|
619 | 619 | continue; |
620 | 620 | } |
621 | 621 | |
622 | - switch ( $type ) { |
|
622 | + switch ($type) { |
|
623 | 623 | |
624 | 624 | case '%s': |
625 | - if ( 'email' == $key ) { |
|
626 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
627 | - } elseif ( 'notes' == $key ) { |
|
628 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
625 | + if ('email' == $key) { |
|
626 | + $data[$key] = sanitize_email($data[$key]); |
|
627 | + } elseif ('notes' == $key) { |
|
628 | + $data[$key] = strip_tags($data[$key]); |
|
629 | 629 | } else { |
630 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
630 | + $data[$key] = sanitize_text_field($data[$key]); |
|
631 | 631 | } |
632 | 632 | break; |
633 | 633 | |
634 | 634 | case '%d': |
635 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
636 | - $data[ $key ] = $default_values[ $key ]; |
|
635 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
636 | + $data[$key] = $default_values[$key]; |
|
637 | 637 | } else { |
638 | - $data[ $key ] = absint( $data[ $key ] ); |
|
638 | + $data[$key] = absint($data[$key]); |
|
639 | 639 | } |
640 | 640 | break; |
641 | 641 | |
642 | 642 | case '%f': |
643 | 643 | // Convert what was given to a float |
644 | - $value = floatval( $data[ $key ] ); |
|
644 | + $value = floatval($data[$key]); |
|
645 | 645 | |
646 | - if ( ! is_float( $value ) ) { |
|
647 | - $data[ $key ] = $default_values[ $key ]; |
|
646 | + if ( ! is_float($value)) { |
|
647 | + $data[$key] = $default_values[$key]; |
|
648 | 648 | } else { |
649 | - $data[ $key ] = $value; |
|
649 | + $data[$key] = $value; |
|
650 | 650 | } |
651 | 651 | break; |
652 | 652 | |
653 | 653 | default: |
654 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
654 | + $data[$key] = sanitize_text_field($data[$key]); |
|
655 | 655 | break; |
656 | 656 | |
657 | 657 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | global $wpdb; |
35 | 35 | |
36 | - $this->table_name = $wpdb->prefix . 'give_customers'; |
|
36 | + $this->table_name = $wpdb->prefix.'give_customers'; |
|
37 | 37 | $this->primary_key = 'id'; |
38 | 38 | $this->version = '1.0'; |
39 | 39 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | 'purchase_value' => 0.00, |
75 | 75 | 'purchase_count' => 0, |
76 | 76 | 'notes' => '', |
77 | - 'date_created' => date( 'Y-m-d H:i:s' ), |
|
77 | + 'date_created' => date('Y-m-d H:i:s'), |
|
78 | 78 | ); |
79 | 79 | } |
80 | 80 | |
@@ -84,40 +84,40 @@ discard block |
||
84 | 84 | * @access public |
85 | 85 | * @since 1.0 |
86 | 86 | */ |
87 | - public function add( $data = array() ) { |
|
87 | + public function add($data = array()) { |
|
88 | 88 | |
89 | 89 | $defaults = array( |
90 | 90 | 'payment_ids' => '' |
91 | 91 | ); |
92 | 92 | |
93 | - $args = wp_parse_args( $data, $defaults ); |
|
93 | + $args = wp_parse_args($data, $defaults); |
|
94 | 94 | |
95 | - if ( empty( $args['email'] ) ) { |
|
95 | + if (empty($args['email'])) { |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | |
99 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
100 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
99 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
100 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
101 | 101 | } |
102 | 102 | |
103 | - $customer = $this->get_customer_by( 'email', $args['email'] ); |
|
103 | + $customer = $this->get_customer_by('email', $args['email']); |
|
104 | 104 | |
105 | - if ( $customer ) { |
|
105 | + if ($customer) { |
|
106 | 106 | // update an existing customer |
107 | 107 | |
108 | 108 | // Update the payment IDs attached to the customer |
109 | - if ( ! empty( $args['payment_ids'] ) ) { |
|
109 | + if ( ! empty($args['payment_ids'])) { |
|
110 | 110 | |
111 | - if ( empty( $customer->payment_ids ) ) { |
|
111 | + if (empty($customer->payment_ids)) { |
|
112 | 112 | |
113 | 113 | $customer->payment_ids = $args['payment_ids']; |
114 | 114 | |
115 | 115 | } else { |
116 | 116 | |
117 | - $existing_ids = array_map( 'absint', explode( ',', $customer->payment_ids ) ); |
|
118 | - $payment_ids = array_map( 'absint', explode( ',', $args['payment_ids'] ) ); |
|
119 | - $payment_ids = array_merge( $payment_ids, $existing_ids ); |
|
120 | - $customer->payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
117 | + $existing_ids = array_map('absint', explode(',', $customer->payment_ids)); |
|
118 | + $payment_ids = array_map('absint', explode(',', $args['payment_ids'])); |
|
119 | + $payment_ids = array_merge($payment_ids, $existing_ids); |
|
120 | + $customer->payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
121 | 121 | |
122 | 122 | } |
123 | 123 | |
@@ -125,13 +125,13 @@ discard block |
||
125 | 125 | |
126 | 126 | } |
127 | 127 | |
128 | - $this->update( $customer->id, $args ); |
|
128 | + $this->update($customer->id, $args); |
|
129 | 129 | |
130 | 130 | return $customer->id; |
131 | 131 | |
132 | 132 | } else { |
133 | 133 | |
134 | - return $this->insert( $args, 'customer' ); |
|
134 | + return $this->insert($args, 'customer'); |
|
135 | 135 | |
136 | 136 | } |
137 | 137 | |
@@ -146,20 +146,20 @@ discard block |
||
146 | 146 | * @access public |
147 | 147 | * @since 1.0 |
148 | 148 | */ |
149 | - public function delete( $_id_or_email = false ) { |
|
149 | + public function delete($_id_or_email = false) { |
|
150 | 150 | |
151 | - if ( empty( $_id_or_email ) ) { |
|
151 | + if (empty($_id_or_email)) { |
|
152 | 152 | return false; |
153 | 153 | } |
154 | 154 | |
155 | - $column = is_email( $_id_or_email ) ? 'email' : 'id'; |
|
156 | - $customer = $this->get_customer_by( $column, $_id_or_email ); |
|
155 | + $column = is_email($_id_or_email) ? 'email' : 'id'; |
|
156 | + $customer = $this->get_customer_by($column, $_id_or_email); |
|
157 | 157 | |
158 | - if ( $customer->id > 0 ) { |
|
158 | + if ($customer->id > 0) { |
|
159 | 159 | |
160 | 160 | global $wpdb; |
161 | 161 | |
162 | - return $wpdb->delete( $this->table_name, array( 'id' => $customer->id ), array( '%d' ) ); |
|
162 | + return $wpdb->delete($this->table_name, array('id' => $customer->id), array('%d')); |
|
163 | 163 | |
164 | 164 | } else { |
165 | 165 | return false; |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | * @access public |
174 | 174 | * @since 1.0 |
175 | 175 | */ |
176 | - public function exists( $email = '' ) { |
|
176 | + public function exists($email = '') { |
|
177 | 177 | |
178 | - return (bool) $this->get_column_by( 'id', 'email', $email ); |
|
178 | + return (bool) $this->get_column_by('id', 'email', $email); |
|
179 | 179 | |
180 | 180 | } |
181 | 181 | |
@@ -185,16 +185,16 @@ discard block |
||
185 | 185 | * @access public |
186 | 186 | * @since 1.0 |
187 | 187 | */ |
188 | - public function attach_payment( $customer_id = 0, $payment_id = 0 ) { |
|
188 | + public function attach_payment($customer_id = 0, $payment_id = 0) { |
|
189 | 189 | |
190 | - $customer = new Give_Customer( $customer_id ); |
|
190 | + $customer = new Give_Customer($customer_id); |
|
191 | 191 | |
192 | - if ( empty( $customer->id ) ) { |
|
192 | + if (empty($customer->id)) { |
|
193 | 193 | return false; |
194 | 194 | } |
195 | 195 | |
196 | 196 | // Attach the payment, but don't increment stats, as this function previously did not |
197 | - return $customer->attach_payment( $payment_id, false ); |
|
197 | + return $customer->attach_payment($payment_id, false); |
|
198 | 198 | |
199 | 199 | } |
200 | 200 | |
@@ -204,16 +204,16 @@ discard block |
||
204 | 204 | * @access public |
205 | 205 | * @since 1.0 |
206 | 206 | */ |
207 | - public function remove_payment( $customer_id = 0, $payment_id = 0 ) { |
|
207 | + public function remove_payment($customer_id = 0, $payment_id = 0) { |
|
208 | 208 | |
209 | - $customer = new Give_Customer( $customer_id ); |
|
209 | + $customer = new Give_Customer($customer_id); |
|
210 | 210 | |
211 | - if ( ! $customer ) { |
|
211 | + if ( ! $customer) { |
|
212 | 212 | return false; |
213 | 213 | } |
214 | 214 | |
215 | 215 | // Remove the payment, but don't decrease stats, as this function previously did not |
216 | - return $customer->remove_payment( $payment_id, false ); |
|
216 | + return $customer->remove_payment($payment_id, false); |
|
217 | 217 | |
218 | 218 | } |
219 | 219 | |
@@ -225,18 +225,18 @@ discard block |
||
225 | 225 | * |
226 | 226 | * @return bool |
227 | 227 | */ |
228 | - public function increment_stats( $customer_id = 0, $amount = 0.00 ) { |
|
228 | + public function increment_stats($customer_id = 0, $amount = 0.00) { |
|
229 | 229 | |
230 | - $customer = new Give_Customer( $customer_id ); |
|
230 | + $customer = new Give_Customer($customer_id); |
|
231 | 231 | |
232 | - if ( empty( $customer->id ) ) { |
|
232 | + if (empty($customer->id)) { |
|
233 | 233 | return false; |
234 | 234 | } |
235 | 235 | |
236 | 236 | $increased_count = $customer->increase_purchase_count(); |
237 | - $increased_value = $customer->increase_value( $amount ); |
|
237 | + $increased_value = $customer->increase_value($amount); |
|
238 | 238 | |
239 | - return ( $increased_count && $increased_value ) ? true : false; |
|
239 | + return ($increased_count && $increased_value) ? true : false; |
|
240 | 240 | |
241 | 241 | } |
242 | 242 | |
@@ -246,18 +246,18 @@ discard block |
||
246 | 246 | * @access public |
247 | 247 | * @since 1.0 |
248 | 248 | */ |
249 | - public function decrement_stats( $customer_id = 0, $amount = 0.00 ) { |
|
249 | + public function decrement_stats($customer_id = 0, $amount = 0.00) { |
|
250 | 250 | |
251 | - $customer = new Give_Customer( $customer_id ); |
|
251 | + $customer = new Give_Customer($customer_id); |
|
252 | 252 | |
253 | - if ( ! $customer ) { |
|
253 | + if ( ! $customer) { |
|
254 | 254 | return false; |
255 | 255 | } |
256 | 256 | |
257 | 257 | $decreased_count = $customer->decrease_purchase_count(); |
258 | - $decreased_value = $customer->decrease_value( $amount ); |
|
258 | + $decreased_value = $customer->decrease_value($amount); |
|
259 | 259 | |
260 | - return ( $decreased_count && $decreased_value ) ? true : false; |
|
260 | + return ($decreased_count && $decreased_value) ? true : false; |
|
261 | 261 | |
262 | 262 | } |
263 | 263 | |
@@ -272,45 +272,45 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @return mixed Upon success, an object of the customer. Upon failure, NULL |
274 | 274 | */ |
275 | - public function get_customer_by( $field = 'id', $value = 0 ) { |
|
275 | + public function get_customer_by($field = 'id', $value = 0) { |
|
276 | 276 | global $wpdb; |
277 | 277 | |
278 | - if ( empty( $field ) || empty( $value ) ) { |
|
278 | + if (empty($field) || empty($value)) { |
|
279 | 279 | return null; |
280 | 280 | } |
281 | 281 | |
282 | - if ( 'id' == $field || 'user_id' == $field ) { |
|
282 | + if ('id' == $field || 'user_id' == $field) { |
|
283 | 283 | // Make sure the value is numeric to avoid casting objects, for example, |
284 | 284 | // to int 1. |
285 | - if ( ! is_numeric( $value ) ) { |
|
285 | + if ( ! is_numeric($value)) { |
|
286 | 286 | return false; |
287 | 287 | } |
288 | 288 | |
289 | - $value = intval( $value ); |
|
289 | + $value = intval($value); |
|
290 | 290 | |
291 | - if ( $value < 1 ) { |
|
291 | + if ($value < 1) { |
|
292 | 292 | return false; |
293 | 293 | } |
294 | 294 | |
295 | - } elseif ( 'email' === $field ) { |
|
295 | + } elseif ('email' === $field) { |
|
296 | 296 | |
297 | - if ( ! is_email( $value ) ) { |
|
297 | + if ( ! is_email($value)) { |
|
298 | 298 | return false; |
299 | 299 | } |
300 | 300 | |
301 | - $value = trim( $value ); |
|
301 | + $value = trim($value); |
|
302 | 302 | } |
303 | 303 | |
304 | - if ( ! $value ) { |
|
304 | + if ( ! $value) { |
|
305 | 305 | return false; |
306 | 306 | } |
307 | 307 | |
308 | - switch ( $field ) { |
|
308 | + switch ($field) { |
|
309 | 309 | case 'id': |
310 | 310 | $db_field = 'id'; |
311 | 311 | break; |
312 | 312 | case 'email': |
313 | - $value = sanitize_text_field( $value ); |
|
313 | + $value = sanitize_text_field($value); |
|
314 | 314 | $db_field = 'email'; |
315 | 315 | break; |
316 | 316 | case 'user_id': |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | return false; |
321 | 321 | } |
322 | 322 | |
323 | - if ( ! $customer = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value ) ) ) { |
|
323 | + if ( ! $customer = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value))) { |
|
324 | 324 | return false; |
325 | 325 | } |
326 | 326 | |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * @access public |
334 | 334 | * @since 1.0 |
335 | 335 | */ |
336 | - public function get_customers( $args = array() ) { |
|
336 | + public function get_customers($args = array()) { |
|
337 | 337 | |
338 | 338 | global $wpdb; |
339 | 339 | |
@@ -345,21 +345,21 @@ discard block |
||
345 | 345 | 'order' => 'DESC' |
346 | 346 | ); |
347 | 347 | |
348 | - $args = wp_parse_args( $args, $defaults ); |
|
348 | + $args = wp_parse_args($args, $defaults); |
|
349 | 349 | |
350 | - if ( $args['number'] < 1 ) { |
|
350 | + if ($args['number'] < 1) { |
|
351 | 351 | $args['number'] = 999999999999; |
352 | 352 | } |
353 | 353 | |
354 | 354 | $where = ' WHERE 1=1 '; |
355 | 355 | |
356 | 356 | // specific customers |
357 | - if ( ! empty( $args['id'] ) ) { |
|
357 | + if ( ! empty($args['id'])) { |
|
358 | 358 | |
359 | - if ( is_array( $args['id'] ) ) { |
|
360 | - $ids = implode( ',', array_map( 'intval', $args['id'] ) ); |
|
359 | + if (is_array($args['id'])) { |
|
360 | + $ids = implode(',', array_map('intval', $args['id'])); |
|
361 | 361 | } else { |
362 | - $ids = intval( $args['id'] ); |
|
362 | + $ids = intval($args['id']); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | $where .= " AND `id` IN( {$ids} ) "; |
@@ -367,12 +367,12 @@ discard block |
||
367 | 367 | } |
368 | 368 | |
369 | 369 | // customers for specific user accounts |
370 | - if ( ! empty( $args['user_id'] ) ) { |
|
370 | + if ( ! empty($args['user_id'])) { |
|
371 | 371 | |
372 | - if ( is_array( $args['user_id'] ) ) { |
|
373 | - $user_ids = implode( ',', array_map( 'intval', $args['user_id'] ) ); |
|
372 | + if (is_array($args['user_id'])) { |
|
373 | + $user_ids = implode(',', array_map('intval', $args['user_id'])); |
|
374 | 374 | } else { |
375 | - $user_ids = intval( $args['user_id'] ); |
|
375 | + $user_ids = intval($args['user_id']); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | $where .= " AND `user_id` IN( {$user_ids} ) "; |
@@ -380,15 +380,15 @@ discard block |
||
380 | 380 | } |
381 | 381 | |
382 | 382 | //specific customers by email |
383 | - if ( ! empty( $args['email'] ) ) { |
|
383 | + if ( ! empty($args['email'])) { |
|
384 | 384 | |
385 | - if ( is_array( $args['email'] ) ) { |
|
386 | - $emails = "'" . implode( "', '", $args['email'] ) . "'"; |
|
385 | + if (is_array($args['email'])) { |
|
386 | + $emails = "'".implode("', '", $args['email'])."'"; |
|
387 | 387 | } else { |
388 | - $emails = "'" . $args['email'] . "'"; |
|
388 | + $emails = "'".$args['email']."'"; |
|
389 | 389 | } |
390 | 390 | |
391 | - if ( ! empty( $where ) ) { |
|
391 | + if ( ! empty($where)) { |
|
392 | 392 | $where .= " AND `email` IN( {$emails} ) "; |
393 | 393 | } else { |
394 | 394 | $where .= "WHERE `email` IN( {$emails} ) "; |
@@ -397,31 +397,31 @@ discard block |
||
397 | 397 | } |
398 | 398 | |
399 | 399 | // specific customers by name |
400 | - if ( ! empty( $args['name'] ) ) { |
|
400 | + if ( ! empty($args['name'])) { |
|
401 | 401 | |
402 | - if ( ! empty( $where ) ) { |
|
403 | - $where .= " AND `name` LIKE '%%" . $args['name'] . "%%' "; |
|
402 | + if ( ! empty($where)) { |
|
403 | + $where .= " AND `name` LIKE '%%".$args['name']."%%' "; |
|
404 | 404 | } else { |
405 | - $where .= "WHERE `name` LIKE '%%" . $args['name'] . "%%' "; |
|
405 | + $where .= "WHERE `name` LIKE '%%".$args['name']."%%' "; |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
409 | 409 | // Customers created for a specific date or in a date range |
410 | - if ( ! empty( $args['date'] ) ) { |
|
410 | + if ( ! empty($args['date'])) { |
|
411 | 411 | |
412 | - if ( is_array( $args['date'] ) ) { |
|
412 | + if (is_array($args['date'])) { |
|
413 | 413 | |
414 | - if ( ! empty( $args['date']['start'] ) ) { |
|
414 | + if ( ! empty($args['date']['start'])) { |
|
415 | 415 | |
416 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
416 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
417 | 417 | |
418 | 418 | $where .= " AND `date_created` >= '{$start}'"; |
419 | 419 | |
420 | 420 | } |
421 | 421 | |
422 | - if ( ! empty( $args['date']['end'] ) ) { |
|
422 | + if ( ! empty($args['date']['end'])) { |
|
423 | 423 | |
424 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
424 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
425 | 425 | |
426 | 426 | $where .= " AND `date_created` <= '{$end}'"; |
427 | 427 | |
@@ -429,31 +429,31 @@ discard block |
||
429 | 429 | |
430 | 430 | } else { |
431 | 431 | |
432 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
433 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
434 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
432 | + $year = date('Y', strtotime($args['date'])); |
|
433 | + $month = date('m', strtotime($args['date'])); |
|
434 | + $day = date('d', strtotime($args['date'])); |
|
435 | 435 | |
436 | 436 | $where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )"; |
437 | 437 | } |
438 | 438 | |
439 | 439 | } |
440 | 440 | |
441 | - $args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'id' : $args['orderby']; |
|
441 | + $args['orderby'] = ! array_key_exists($args['orderby'], $this->get_columns()) ? 'id' : $args['orderby']; |
|
442 | 442 | |
443 | - if ( 'purchase_value' == $args['orderby'] ) { |
|
443 | + if ('purchase_value' == $args['orderby']) { |
|
444 | 444 | $args['orderby'] = 'purchase_value+0'; |
445 | 445 | } |
446 | 446 | |
447 | - $cache_key = md5( 'give_customers_' . serialize( $args ) ); |
|
447 | + $cache_key = md5('give_customers_'.serialize($args)); |
|
448 | 448 | |
449 | - $customers = wp_cache_get( $cache_key, 'customers' ); |
|
449 | + $customers = wp_cache_get($cache_key, 'customers'); |
|
450 | 450 | |
451 | - $args['orderby'] = esc_sql( $args['orderby'] ); |
|
452 | - $args['order'] = esc_sql( $args['order'] ); |
|
451 | + $args['orderby'] = esc_sql($args['orderby']); |
|
452 | + $args['order'] = esc_sql($args['order']); |
|
453 | 453 | |
454 | - if ( $customers === false ) { |
|
455 | - $customers = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint( $args['offset'] ), absint( $args['number'] ) ) ); |
|
456 | - wp_cache_set( $cache_key, $customers, 'customers', 3600 ); |
|
454 | + if ($customers === false) { |
|
455 | + $customers = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint($args['offset']), absint($args['number']))); |
|
456 | + wp_cache_set($cache_key, $customers, 'customers', 3600); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | return $customers; |
@@ -467,26 +467,26 @@ discard block |
||
467 | 467 | * @access public |
468 | 468 | * @since 1.0 |
469 | 469 | */ |
470 | - public function count( $args = array() ) { |
|
470 | + public function count($args = array()) { |
|
471 | 471 | |
472 | 472 | global $wpdb; |
473 | 473 | |
474 | 474 | $where = ' WHERE 1=1 '; |
475 | 475 | |
476 | - if ( ! empty( $args['date'] ) ) { |
|
476 | + if ( ! empty($args['date'])) { |
|
477 | 477 | |
478 | - if ( is_array( $args['date'] ) ) { |
|
478 | + if (is_array($args['date'])) { |
|
479 | 479 | |
480 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
481 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
480 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
481 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
482 | 482 | |
483 | 483 | $where .= " AND `date_created` >= '{$start}' AND `date_created` <= '{$end}'"; |
484 | 484 | |
485 | 485 | } else { |
486 | 486 | |
487 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
488 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
489 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
487 | + $year = date('Y', strtotime($args['date'])); |
|
488 | + $month = date('m', strtotime($args['date'])); |
|
489 | + $day = date('d', strtotime($args['date'])); |
|
490 | 490 | |
491 | 491 | $where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )"; |
492 | 492 | } |
@@ -494,16 +494,16 @@ discard block |
||
494 | 494 | } |
495 | 495 | |
496 | 496 | |
497 | - $cache_key = md5( 'give_customers_count' . serialize( $args ) ); |
|
497 | + $cache_key = md5('give_customers_count'.serialize($args)); |
|
498 | 498 | |
499 | - $count = wp_cache_get( $cache_key, 'customers' ); |
|
499 | + $count = wp_cache_get($cache_key, 'customers'); |
|
500 | 500 | |
501 | - if ( $count === false ) { |
|
502 | - $count = $wpdb->get_var( "SELECT COUNT($this->primary_key) FROM " . $this->table_name . "{$where};" ); |
|
503 | - wp_cache_set( $cache_key, $count, 'customers', 3600 ); |
|
501 | + if ($count === false) { |
|
502 | + $count = $wpdb->get_var("SELECT COUNT($this->primary_key) FROM ".$this->table_name."{$where};"); |
|
503 | + wp_cache_set($cache_key, $count, 'customers', 3600); |
|
504 | 504 | } |
505 | 505 | |
506 | - return absint( $count ); |
|
506 | + return absint($count); |
|
507 | 507 | |
508 | 508 | } |
509 | 509 | |
@@ -517,9 +517,9 @@ discard block |
||
517 | 517 | |
518 | 518 | global $wpdb; |
519 | 519 | |
520 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
520 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
521 | 521 | |
522 | - $sql = "CREATE TABLE " . $this->table_name . " ( |
|
522 | + $sql = "CREATE TABLE ".$this->table_name." ( |
|
523 | 523 | id bigint(20) NOT NULL AUTO_INCREMENT, |
524 | 524 | user_id bigint(20) NOT NULL, |
525 | 525 | email varchar(50) NOT NULL, |
@@ -534,8 +534,8 @@ discard block |
||
534 | 534 | KEY user (user_id) |
535 | 535 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
536 | 536 | |
537 | - dbDelta( $sql ); |
|
537 | + dbDelta($sql); |
|
538 | 538 | |
539 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
539 | + update_option($this->table_name.'_db_version', $this->version); |
|
540 | 540 | } |
541 | 541 | } |
@@ -272,7 +272,7 @@ |
||
272 | 272 | * @since 1.0 |
273 | 273 | * |
274 | 274 | * @param string $field id or email |
275 | - * @param mixed $value The Customer ID or email to search |
|
275 | + * @param integer $value The Customer ID or email to search |
|
276 | 276 | * |
277 | 277 | * @return mixed Upon success, an object of the customer. Upon failure, NULL |
278 | 278 | */ |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Customers DB class |
|
4 | - * |
|
5 | - * This class is for interacting with the customers' database table |
|
6 | - * |
|
7 | - * @package Give |
|
8 | - * @subpackage Classes/DB Customers |
|
9 | - * @copyright Copyright (c) 2015, WordImpress |
|
10 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
11 | - * @since 1.0 |
|
12 | - */ |
|
3 | + * Customers DB class |
|
4 | + * |
|
5 | + * This class is for interacting with the customers' database table |
|
6 | + * |
|
7 | + * @package Give |
|
8 | + * @subpackage Classes/DB Customers |
|
9 | + * @copyright Copyright (c) 2015, WordImpress |
|
10 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
11 | + * @since 1.0 |
|
12 | + */ |
|
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
9 | 9 | * @since 1.0 |
10 | 10 | */ |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } // Exit if accessed directly |
14 | 14 | |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | * @since 1.0 |
78 | 78 | * @return object |
79 | 79 | */ |
80 | - public function get( $row_id ) { |
|
80 | + public function get($row_id) { |
|
81 | 81 | global $wpdb; |
82 | 82 | |
83 | - return $wpdb->get_row( "SELECT * FROM $this->table_name WHERE $this->primary_key = $row_id LIMIT 1;" ); |
|
83 | + return $wpdb->get_row("SELECT * FROM $this->table_name WHERE $this->primary_key = $row_id LIMIT 1;"); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | * @since 1.0 |
91 | 91 | * @return object |
92 | 92 | */ |
93 | - public function get_by( $column, $row_id ) { |
|
93 | + public function get_by($column, $row_id) { |
|
94 | 94 | global $wpdb; |
95 | 95 | |
96 | - return $wpdb->get_row( "SELECT * FROM $this->table_name WHERE $column = '$row_id' LIMIT 1;" ); |
|
96 | + return $wpdb->get_row("SELECT * FROM $this->table_name WHERE $column = '$row_id' LIMIT 1;"); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | * @since 1.0 |
104 | 104 | * @return string |
105 | 105 | */ |
106 | - public function get_column( $column, $row_id ) { |
|
106 | + public function get_column($column, $row_id) { |
|
107 | 107 | global $wpdb; |
108 | 108 | |
109 | - return $wpdb->get_var( "SELECT $column FROM $this->table_name WHERE $this->primary_key = $row_id LIMIT 1;" ); |
|
109 | + return $wpdb->get_var("SELECT $column FROM $this->table_name WHERE $this->primary_key = $row_id LIMIT 1;"); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -116,10 +116,10 @@ discard block |
||
116 | 116 | * @since 1.0 |
117 | 117 | * @return string |
118 | 118 | */ |
119 | - public function get_column_by( $column, $column_where, $column_value ) { |
|
119 | + public function get_column_by($column, $column_where, $column_value) { |
|
120 | 120 | global $wpdb; |
121 | 121 | |
122 | - return $wpdb->get_var( "SELECT $column FROM $this->table_name WHERE $column_where = '$column_value' LIMIT 1;" ); |
|
122 | + return $wpdb->get_var("SELECT $column FROM $this->table_name WHERE $column_where = '$column_value' LIMIT 1;"); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -129,30 +129,30 @@ discard block |
||
129 | 129 | * @since 1.0 |
130 | 130 | * @return int |
131 | 131 | */ |
132 | - public function insert( $data, $type = '' ) { |
|
132 | + public function insert($data, $type = '') { |
|
133 | 133 | global $wpdb; |
134 | 134 | |
135 | 135 | // Set default values |
136 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
136 | + $data = wp_parse_args($data, $this->get_column_defaults()); |
|
137 | 137 | |
138 | - do_action( 'give_pre_insert_' . $type, $data ); |
|
138 | + do_action('give_pre_insert_'.$type, $data); |
|
139 | 139 | |
140 | 140 | // Initialise column format array |
141 | 141 | $column_formats = $this->get_columns(); |
142 | 142 | |
143 | 143 | // Force fields to lower case |
144 | - $data = array_change_key_case( $data ); |
|
144 | + $data = array_change_key_case($data); |
|
145 | 145 | |
146 | 146 | // White list columns |
147 | - $data = array_intersect_key( $data, $column_formats ); |
|
147 | + $data = array_intersect_key($data, $column_formats); |
|
148 | 148 | |
149 | 149 | // Reorder $column_formats to match the order of columns given in $data |
150 | - $data_keys = array_keys( $data ); |
|
151 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
150 | + $data_keys = array_keys($data); |
|
151 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
152 | 152 | |
153 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
153 | + $wpdb->insert($this->table_name, $data, $column_formats); |
|
154 | 154 | |
155 | - do_action( 'give_post_insert_' . $type, $wpdb->insert_id, $data ); |
|
155 | + do_action('give_post_insert_'.$type, $wpdb->insert_id, $data); |
|
156 | 156 | |
157 | 157 | return $wpdb->insert_id; |
158 | 158 | } |
@@ -164,18 +164,18 @@ discard block |
||
164 | 164 | * @since 1.0 |
165 | 165 | * @return bool |
166 | 166 | */ |
167 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
167 | + public function update($row_id, $data = array(), $where = '') { |
|
168 | 168 | |
169 | 169 | global $wpdb; |
170 | 170 | |
171 | 171 | // Row ID must be positive integer |
172 | - $row_id = absint( $row_id ); |
|
172 | + $row_id = absint($row_id); |
|
173 | 173 | |
174 | - if ( empty( $row_id ) ) { |
|
174 | + if (empty($row_id)) { |
|
175 | 175 | return false; |
176 | 176 | } |
177 | 177 | |
178 | - if ( empty( $where ) ) { |
|
178 | + if (empty($where)) { |
|
179 | 179 | $where = $this->primary_key; |
180 | 180 | } |
181 | 181 | |
@@ -183,16 +183,16 @@ discard block |
||
183 | 183 | $column_formats = $this->get_columns(); |
184 | 184 | |
185 | 185 | // Force fields to lower case |
186 | - $data = array_change_key_case( $data ); |
|
186 | + $data = array_change_key_case($data); |
|
187 | 187 | |
188 | 188 | // White list columns |
189 | - $data = array_intersect_key( $data, $column_formats ); |
|
189 | + $data = array_intersect_key($data, $column_formats); |
|
190 | 190 | |
191 | 191 | // Reorder $column_formats to match the order of columns given in $data |
192 | - $data_keys = array_keys( $data ); |
|
193 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
192 | + $data_keys = array_keys($data); |
|
193 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
194 | 194 | |
195 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
195 | + if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) { |
|
196 | 196 | return false; |
197 | 197 | } |
198 | 198 | |
@@ -206,18 +206,18 @@ discard block |
||
206 | 206 | * @since 1.0 |
207 | 207 | * @return bool |
208 | 208 | */ |
209 | - public function delete( $row_id = 0 ) { |
|
209 | + public function delete($row_id = 0) { |
|
210 | 210 | |
211 | 211 | global $wpdb; |
212 | 212 | |
213 | 213 | // Row ID must be positive integer |
214 | - $row_id = absint( $row_id ); |
|
214 | + $row_id = absint($row_id); |
|
215 | 215 | |
216 | - if ( empty( $row_id ) ) { |
|
216 | + if (empty($row_id)) { |
|
217 | 217 | return false; |
218 | 218 | } |
219 | 219 | |
220 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
220 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) { |
|
221 | 221 | return false; |
222 | 222 | } |
223 | 223 | |
@@ -231,11 +231,11 @@ discard block |
||
231 | 231 | * @param string $table The table name |
232 | 232 | * @return bool If the table name exists |
233 | 233 | */ |
234 | - public function table_exists( $table ) { |
|
234 | + public function table_exists($table) { |
|
235 | 235 | global $wpdb; |
236 | - $table = sanitize_text_field( $table ); |
|
236 | + $table = sanitize_text_field($table); |
|
237 | 237 | |
238 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
238 | + return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table; |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | } |
@@ -297,10 +297,12 @@ discard block |
||
297 | 297 | public function decrease_sales() { |
298 | 298 | |
299 | 299 | $sales = give_get_form_sales_stats( $this->ID ); |
300 | - if ( $sales > 0 ) // Only decrease if not already zero |
|
300 | + if ( $sales > 0 ) { |
|
301 | + // Only decrease if not already zero |
|
301 | 302 | { |
302 | 303 | $sales = $sales - 1; |
303 | 304 | } |
305 | + } |
|
304 | 306 | |
305 | 307 | if ( update_post_meta( $this->ID, '_give_form_sales', $sales ) ) { |
306 | 308 | $this->sales = $sales; |
@@ -370,10 +372,12 @@ discard block |
||
370 | 372 | |
371 | 373 | $earnings = give_get_form_earnings_stats( $this->ID ); |
372 | 374 | |
373 | - if ( $earnings > 0 ) // Only decrease if greater than zero |
|
375 | + if ( $earnings > 0 ) { |
|
376 | + // Only decrease if greater than zero |
|
374 | 377 | { |
375 | 378 | $earnings = $earnings - (float) $amount; |
376 | 379 | } |
380 | + } |
|
377 | 381 | |
378 | 382 | if ( update_post_meta( $this->ID, '_give_form_earnings', $earnings ) ) { |
379 | 383 | $this->earnings = $earnings; |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Donate Form Object |
|
4 | - * |
|
5 | - * @package Give |
|
6 | - * @subpackage Classes/Forms |
|
7 | - * @copyright Copyright (c) 2015, WordImpress |
|
8 | - * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
9 | - * @since 1.0 |
|
10 | - */ |
|
3 | + * Donate Form Object |
|
4 | + * |
|
5 | + * @package Give |
|
6 | + * @subpackage Classes/Forms |
|
7 | + * @copyright Copyright (c) 2015, WordImpress |
|
8 | + * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
|
9 | + * @since 1.0 |
|
10 | + */ |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * Give_Donate_Form Class |
@@ -73,37 +73,37 @@ discard block |
||
73 | 73 | * @param bool $_id |
74 | 74 | * @param array $_args |
75 | 75 | */ |
76 | - public function __construct( $_id = false, $_args = array() ) { |
|
76 | + public function __construct($_id = false, $_args = array()) { |
|
77 | 77 | |
78 | - if ( false === $_id ) { |
|
78 | + if (false === $_id) { |
|
79 | 79 | |
80 | 80 | $defaults = array( |
81 | 81 | 'post_type' => 'give_forms', |
82 | 82 | 'post_status' => 'draft', |
83 | - 'post_title' => __( 'New Give Form', 'give' ) |
|
83 | + 'post_title' => __('New Give Form', 'give') |
|
84 | 84 | ); |
85 | 85 | |
86 | - $args = wp_parse_args( $_args, $defaults ); |
|
86 | + $args = wp_parse_args($_args, $defaults); |
|
87 | 87 | |
88 | - $_id = wp_insert_post( $args, true ); |
|
88 | + $_id = wp_insert_post($args, true); |
|
89 | 89 | |
90 | 90 | } |
91 | 91 | |
92 | - $donate_form = WP_Post::get_instance( $_id ); |
|
92 | + $donate_form = WP_Post::get_instance($_id); |
|
93 | 93 | |
94 | - if ( ! is_object( $donate_form ) ) { |
|
94 | + if ( ! is_object($donate_form)) { |
|
95 | 95 | return false; |
96 | 96 | } |
97 | 97 | |
98 | - if ( ! is_a( $donate_form, 'WP_Post' ) ) { |
|
98 | + if ( ! is_a($donate_form, 'WP_Post')) { |
|
99 | 99 | return false; |
100 | 100 | } |
101 | 101 | |
102 | - if ( 'give_forms' !== $donate_form->post_type ) { |
|
102 | + if ('give_forms' !== $donate_form->post_type) { |
|
103 | 103 | return false; |
104 | 104 | } |
105 | 105 | |
106 | - foreach ( $donate_form as $key => $value ) { |
|
106 | + foreach ($donate_form as $key => $value) { |
|
107 | 107 | |
108 | 108 | $this->$key = $value; |
109 | 109 | |
@@ -121,15 +121,15 @@ discard block |
||
121 | 121 | * @return mixed |
122 | 122 | * @throws Exception |
123 | 123 | */ |
124 | - public function __get( $key ) { |
|
124 | + public function __get($key) { |
|
125 | 125 | |
126 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
126 | + if (method_exists($this, 'get_'.$key)) { |
|
127 | 127 | |
128 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
128 | + return call_user_func(array($this, 'get_'.$key)); |
|
129 | 129 | |
130 | 130 | } else { |
131 | 131 | |
132 | - throw new Exception( 'Can\'t get property ' . $key ); |
|
132 | + throw new Exception('Can\'t get property '.$key); |
|
133 | 133 | |
134 | 134 | } |
135 | 135 | |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function get_price() { |
157 | 157 | |
158 | - if ( ! isset( $this->price ) ) { |
|
158 | + if ( ! isset($this->price)) { |
|
159 | 159 | |
160 | - $this->price = get_post_meta( $this->ID, '_give_set_price', true ); |
|
160 | + $this->price = get_post_meta($this->ID, '_give_set_price', true); |
|
161 | 161 | |
162 | - if ( $this->price ) { |
|
162 | + if ($this->price) { |
|
163 | 163 | |
164 | - $this->price = give_sanitize_amount( $this->price ); |
|
164 | + $this->price = give_sanitize_amount($this->price); |
|
165 | 165 | |
166 | 166 | } else { |
167 | 167 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | |
172 | 172 | } |
173 | 173 | |
174 | - return apply_filters( 'give_get_set_price', $this->price, $this->ID ); |
|
174 | + return apply_filters('give_get_set_price', $this->price, $this->ID); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -182,14 +182,14 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public function get_minimum_price() { |
184 | 184 | |
185 | - if ( ! isset( $this->minimum_price ) ) { |
|
185 | + if ( ! isset($this->minimum_price)) { |
|
186 | 186 | |
187 | - $allow_custom_amount = get_post_meta( $this->ID, '_give_custom_amount', true ); |
|
188 | - $this->minimum_price = get_post_meta( $this->ID, '_give_custom_amount_minimum', true ); |
|
187 | + $allow_custom_amount = get_post_meta($this->ID, '_give_custom_amount', true); |
|
188 | + $this->minimum_price = get_post_meta($this->ID, '_give_custom_amount_minimum', true); |
|
189 | 189 | |
190 | - if ( $allow_custom_amount != 'no' && $this->minimum_price ) { |
|
190 | + if ($allow_custom_amount != 'no' && $this->minimum_price) { |
|
191 | 191 | |
192 | - $this->minimum_price = give_sanitize_amount( $this->minimum_price ); |
|
192 | + $this->minimum_price = give_sanitize_amount($this->minimum_price); |
|
193 | 193 | |
194 | 194 | } else { |
195 | 195 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | |
200 | 200 | } |
201 | 201 | |
202 | - return apply_filters( 'give_get_set_minimum_price', $this->minimum_price, $this->ID ); |
|
202 | + return apply_filters('give_get_set_minimum_price', $this->minimum_price, $this->ID); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -210,13 +210,13 @@ discard block |
||
210 | 210 | */ |
211 | 211 | public function get_prices() { |
212 | 212 | |
213 | - if ( ! isset( $this->prices ) ) { |
|
213 | + if ( ! isset($this->prices)) { |
|
214 | 214 | |
215 | - $this->prices = get_post_meta( $this->ID, '_give_donation_levels', true ); |
|
215 | + $this->prices = get_post_meta($this->ID, '_give_donation_levels', true); |
|
216 | 216 | |
217 | 217 | } |
218 | 218 | |
219 | - return apply_filters( 'give_get_donation_levels', $this->prices, $this->ID ); |
|
219 | + return apply_filters('give_get_donation_levels', $this->prices, $this->ID); |
|
220 | 220 | |
221 | 221 | } |
222 | 222 | |
@@ -228,13 +228,13 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public function get_goal() { |
230 | 230 | |
231 | - if ( ! isset( $this->goal ) ) { |
|
231 | + if ( ! isset($this->goal)) { |
|
232 | 232 | |
233 | - $this->goal = get_post_meta( $this->ID, '_give_set_goal', true ); |
|
233 | + $this->goal = get_post_meta($this->ID, '_give_set_goal', true); |
|
234 | 234 | |
235 | - if ( $this->goal ) { |
|
235 | + if ($this->goal) { |
|
236 | 236 | |
237 | - $this->goal = give_sanitize_amount( $this->goal ); |
|
237 | + $this->goal = give_sanitize_amount($this->goal); |
|
238 | 238 | |
239 | 239 | } else { |
240 | 240 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | |
245 | 245 | } |
246 | 246 | |
247 | - return apply_filters( 'give_get_set_goal', $this->goal, $this->ID ); |
|
247 | + return apply_filters('give_get_set_goal', $this->goal, $this->ID); |
|
248 | 248 | |
249 | 249 | } |
250 | 250 | |
@@ -256,14 +256,14 @@ discard block |
||
256 | 256 | */ |
257 | 257 | public function is_single_price_mode() { |
258 | 258 | |
259 | - $option = get_post_meta( $this->ID, '_give_price_options_mode', true ); |
|
259 | + $option = get_post_meta($this->ID, '_give_price_options_mode', true); |
|
260 | 260 | $ret = 0; |
261 | 261 | |
262 | - if ( empty( $option ) || $option === 'set' ) { |
|
262 | + if (empty($option) || $option === 'set') { |
|
263 | 263 | $ret = 1; |
264 | 264 | } |
265 | 265 | |
266 | - return (bool) apply_filters( 'give_single_price_option_mode', $ret, $this->ID ); |
|
266 | + return (bool) apply_filters('give_single_price_option_mode', $ret, $this->ID); |
|
267 | 267 | |
268 | 268 | } |
269 | 269 | |
@@ -277,14 +277,14 @@ discard block |
||
277 | 277 | */ |
278 | 278 | public function has_variable_prices() { |
279 | 279 | |
280 | - $option = get_post_meta( $this->ID, '_give_price_option', true ); |
|
280 | + $option = get_post_meta($this->ID, '_give_price_option', true); |
|
281 | 281 | $ret = 0; |
282 | 282 | |
283 | - if ( $option === 'multi' ) { |
|
283 | + if ($option === 'multi') { |
|
284 | 284 | $ret = 1; |
285 | 285 | } |
286 | 286 | |
287 | - return (bool) apply_filters( 'give_has_variable_prices', $ret, $this->ID ); |
|
287 | + return (bool) apply_filters('give_has_variable_prices', $ret, $this->ID); |
|
288 | 288 | |
289 | 289 | } |
290 | 290 | |
@@ -297,15 +297,15 @@ discard block |
||
297 | 297 | */ |
298 | 298 | public function get_sales() { |
299 | 299 | |
300 | - if ( ! isset( $this->sales ) ) { |
|
300 | + if ( ! isset($this->sales)) { |
|
301 | 301 | |
302 | - if ( '' == get_post_meta( $this->ID, '_give_form_sales', true ) ) { |
|
303 | - add_post_meta( $this->ID, '_give_form_sales', 0 ); |
|
302 | + if ('' == get_post_meta($this->ID, '_give_form_sales', true)) { |
|
303 | + add_post_meta($this->ID, '_give_form_sales', 0); |
|
304 | 304 | } // End if |
305 | 305 | |
306 | - $this->sales = get_post_meta( $this->ID, '_give_form_sales', true ); |
|
306 | + $this->sales = get_post_meta($this->ID, '_give_form_sales', true); |
|
307 | 307 | |
308 | - if ( $this->sales < 0 ) { |
|
308 | + if ($this->sales < 0) { |
|
309 | 309 | // Never let sales be less than zero |
310 | 310 | $this->sales = 0; |
311 | 311 | } |
@@ -324,10 +324,10 @@ discard block |
||
324 | 324 | */ |
325 | 325 | public function increase_sales() { |
326 | 326 | |
327 | - $sales = give_get_form_sales_stats( $this->ID ); |
|
327 | + $sales = give_get_form_sales_stats($this->ID); |
|
328 | 328 | $sales = $sales + 1; |
329 | 329 | |
330 | - if ( update_post_meta( $this->ID, '_give_form_sales', $sales ) ) { |
|
330 | + if (update_post_meta($this->ID, '_give_form_sales', $sales)) { |
|
331 | 331 | $this->sales = $sales; |
332 | 332 | |
333 | 333 | return $sales; |
@@ -344,13 +344,13 @@ discard block |
||
344 | 344 | */ |
345 | 345 | public function decrease_sales() { |
346 | 346 | |
347 | - $sales = give_get_form_sales_stats( $this->ID ); |
|
348 | - if ( $sales > 0 ) // Only decrease if not already zero |
|
347 | + $sales = give_get_form_sales_stats($this->ID); |
|
348 | + if ($sales > 0) // Only decrease if not already zero |
|
349 | 349 | { |
350 | 350 | $sales = $sales - 1; |
351 | 351 | } |
352 | 352 | |
353 | - if ( update_post_meta( $this->ID, '_give_form_sales', $sales ) ) { |
|
353 | + if (update_post_meta($this->ID, '_give_form_sales', $sales)) { |
|
354 | 354 | $this->sales = $sales; |
355 | 355 | |
356 | 356 | return $sales; |
@@ -368,15 +368,15 @@ discard block |
||
368 | 368 | */ |
369 | 369 | public function get_earnings() { |
370 | 370 | |
371 | - if ( ! isset( $this->earnings ) ) { |
|
371 | + if ( ! isset($this->earnings)) { |
|
372 | 372 | |
373 | - if ( '' == get_post_meta( $this->ID, '_give_form_earnings', true ) ) { |
|
374 | - add_post_meta( $this->ID, '_give_form_earnings', 0 ); |
|
373 | + if ('' == get_post_meta($this->ID, '_give_form_earnings', true)) { |
|
374 | + add_post_meta($this->ID, '_give_form_earnings', 0); |
|
375 | 375 | } |
376 | 376 | |
377 | - $this->earnings = get_post_meta( $this->ID, '_give_form_earnings', true ); |
|
377 | + $this->earnings = get_post_meta($this->ID, '_give_form_earnings', true); |
|
378 | 378 | |
379 | - if ( $this->earnings < 0 ) { |
|
379 | + if ($this->earnings < 0) { |
|
380 | 380 | // Never let earnings be less than zero |
381 | 381 | $this->earnings = 0; |
382 | 382 | } |
@@ -393,12 +393,12 @@ discard block |
||
393 | 393 | * @since 1.0 |
394 | 394 | * @return float|false |
395 | 395 | */ |
396 | - public function increase_earnings( $amount = 0 ) { |
|
396 | + public function increase_earnings($amount = 0) { |
|
397 | 397 | |
398 | - $earnings = give_get_form_earnings_stats( $this->ID ); |
|
398 | + $earnings = give_get_form_earnings_stats($this->ID); |
|
399 | 399 | $earnings = $earnings + (float) $amount; |
400 | 400 | |
401 | - if ( update_post_meta( $this->ID, '_give_form_earnings', $earnings ) ) { |
|
401 | + if (update_post_meta($this->ID, '_give_form_earnings', $earnings)) { |
|
402 | 402 | $this->earnings = $earnings; |
403 | 403 | |
404 | 404 | return $earnings; |
@@ -414,16 +414,16 @@ discard block |
||
414 | 414 | * @since 1.0 |
415 | 415 | * @return float|false |
416 | 416 | */ |
417 | - public function decrease_earnings( $amount ) { |
|
417 | + public function decrease_earnings($amount) { |
|
418 | 418 | |
419 | - $earnings = give_get_form_earnings_stats( $this->ID ); |
|
419 | + $earnings = give_get_form_earnings_stats($this->ID); |
|
420 | 420 | |
421 | - if ( $earnings > 0 ) // Only decrease if greater than zero |
|
421 | + if ($earnings > 0) // Only decrease if greater than zero |
|
422 | 422 | { |
423 | 423 | $earnings = $earnings - (float) $amount; |
424 | 424 | } |
425 | 425 | |
426 | - if ( update_post_meta( $this->ID, '_give_form_earnings', $earnings ) ) { |
|
426 | + if (update_post_meta($this->ID, '_give_form_earnings', $earnings)) { |
|
427 | 427 | $this->earnings = $earnings; |
428 | 428 | |
429 | 429 | return $earnings; |
@@ -439,22 +439,22 @@ discard block |
||
439 | 439 | * @since 1.0 |
440 | 440 | * @return bool |
441 | 441 | */ |
442 | - public function is_free( $price_id = false ) { |
|
442 | + public function is_free($price_id = false) { |
|
443 | 443 | |
444 | 444 | $is_free = false; |
445 | - $variable_pricing = give_has_variable_prices( $this->ID ); |
|
445 | + $variable_pricing = give_has_variable_prices($this->ID); |
|
446 | 446 | |
447 | - if ( $variable_pricing && ! is_null( $price_id ) && $price_id !== false ) { |
|
448 | - $price = give_get_price_option_amount( $this->ID, $price_id ); |
|
449 | - } elseif ( ! $variable_pricing ) { |
|
450 | - $price = get_post_meta( $this->ID, '_give_set_price', true ); |
|
447 | + if ($variable_pricing && ! is_null($price_id) && $price_id !== false) { |
|
448 | + $price = give_get_price_option_amount($this->ID, $price_id); |
|
449 | + } elseif ( ! $variable_pricing) { |
|
450 | + $price = get_post_meta($this->ID, '_give_set_price', true); |
|
451 | 451 | } |
452 | 452 | |
453 | - if ( isset( $price ) && (float) $price == 0 ) { |
|
453 | + if (isset($price) && (float) $price == 0) { |
|
454 | 454 | $is_free = true; |
455 | 455 | } |
456 | 456 | |
457 | - return (bool) apply_filters( 'give_is_free_donation', $is_free, $this->ID, $price_id ); |
|
457 | + return (bool) apply_filters('give_is_free_donation', $is_free, $this->ID, $price_id); |
|
458 | 458 | |
459 | 459 | } |
460 | 460 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @return string $output Give forms dropdown |
35 | 35 | */ |
36 | - public function forms_dropdown( $args = array() ) { |
|
36 | + public function forms_dropdown($args = array()) { |
|
37 | 37 | |
38 | 38 | $defaults = array( |
39 | 39 | 'name' => 'forms', |
@@ -43,43 +43,43 @@ discard block |
||
43 | 43 | 'selected' => 0, |
44 | 44 | 'chosen' => false, |
45 | 45 | 'number' => 30, |
46 | - 'placeholder' => sprintf( __( 'Select a %s', 'give' ), give_get_forms_label_singular() ) |
|
46 | + 'placeholder' => sprintf(__('Select a %s', 'give'), give_get_forms_label_singular()) |
|
47 | 47 | ); |
48 | 48 | |
49 | - $args = wp_parse_args( $args, $defaults ); |
|
49 | + $args = wp_parse_args($args, $defaults); |
|
50 | 50 | |
51 | - $forms = get_posts( array( |
|
51 | + $forms = get_posts(array( |
|
52 | 52 | 'post_type' => 'give_forms', |
53 | 53 | 'orderby' => 'title', |
54 | 54 | 'order' => 'ASC', |
55 | 55 | 'posts_per_page' => $args['number'] |
56 | - ) ); |
|
56 | + )); |
|
57 | 57 | |
58 | 58 | $options = array(); |
59 | 59 | |
60 | - if ( $forms ) { |
|
61 | - $options[0] = sprintf( __( 'Select a %s', 'give' ), give_get_forms_label_singular() ); |
|
62 | - foreach ( $forms as $form ) { |
|
63 | - $options[ absint( $form->ID ) ] = esc_html( $form->post_title ); |
|
60 | + if ($forms) { |
|
61 | + $options[0] = sprintf(__('Select a %s', 'give'), give_get_forms_label_singular()); |
|
62 | + foreach ($forms as $form) { |
|
63 | + $options[absint($form->ID)] = esc_html($form->post_title); |
|
64 | 64 | } |
65 | 65 | } else { |
66 | - $options[0] = __( 'No Give Forms Found', 'give' ); |
|
66 | + $options[0] = __('No Give Forms Found', 'give'); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // This ensures that any selected forms are included in the drop down |
70 | - if ( is_array( $args['selected'] ) ) { |
|
71 | - foreach ( $args['selected'] as $item ) { |
|
72 | - if ( ! in_array( $item, $options ) ) { |
|
73 | - $options[ $item ] = get_the_title( $item ); |
|
70 | + if (is_array($args['selected'])) { |
|
71 | + foreach ($args['selected'] as $item) { |
|
72 | + if ( ! in_array($item, $options)) { |
|
73 | + $options[$item] = get_the_title($item); |
|
74 | 74 | } |
75 | 75 | } |
76 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
77 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
78 | - $options[ $args['selected'] ] = get_the_title( $args['selected'] ); |
|
76 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
77 | + if ( ! in_array($args['selected'], $options)) { |
|
78 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | - $output = $this->select( array( |
|
82 | + $output = $this->select(array( |
|
83 | 83 | 'name' => $args['name'], |
84 | 84 | 'selected' => $args['selected'], |
85 | 85 | 'id' => $args['id'], |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | 'placeholder' => $args['placeholder'], |
91 | 91 | 'show_option_all' => false, |
92 | 92 | 'show_option_none' => false |
93 | - ) ); |
|
93 | + )); |
|
94 | 94 | |
95 | 95 | return $output; |
96 | 96 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return string $output Donor dropdown |
107 | 107 | */ |
108 | - public function donor_dropdown( $args = array() ) { |
|
108 | + public function donor_dropdown($args = array()) { |
|
109 | 109 | |
110 | 110 | $defaults = array( |
111 | 111 | 'name' => 'customers', |
@@ -114,38 +114,38 @@ discard block |
||
114 | 114 | 'multiple' => false, |
115 | 115 | 'selected' => 0, |
116 | 116 | 'chosen' => true, |
117 | - 'placeholder' => __( 'Select a Donor', 'give' ), |
|
117 | + 'placeholder' => __('Select a Donor', 'give'), |
|
118 | 118 | 'number' => 30 |
119 | 119 | ); |
120 | 120 | |
121 | - $args = wp_parse_args( $args, $defaults ); |
|
121 | + $args = wp_parse_args($args, $defaults); |
|
122 | 122 | |
123 | - $customers = Give()->customers->get_customers( array( |
|
123 | + $customers = Give()->customers->get_customers(array( |
|
124 | 124 | 'number' => $args['number'] |
125 | - ) ); |
|
125 | + )); |
|
126 | 126 | |
127 | 127 | $options = array(); |
128 | 128 | |
129 | - if ( $customers ) { |
|
130 | - $options[0] = __( 'No donor attached', 'give' ); |
|
131 | - foreach ( $customers as $customer ) { |
|
132 | - $options[ absint( $customer->id ) ] = esc_html( $customer->name . ' (' . $customer->email . ')' ); |
|
129 | + if ($customers) { |
|
130 | + $options[0] = __('No donor attached', 'give'); |
|
131 | + foreach ($customers as $customer) { |
|
132 | + $options[absint($customer->id)] = esc_html($customer->name.' ('.$customer->email.')'); |
|
133 | 133 | } |
134 | 134 | } else { |
135 | - $options[0] = __( 'No donors found', 'give' ); |
|
135 | + $options[0] = __('No donors found', 'give'); |
|
136 | 136 | } |
137 | 137 | |
138 | - if ( ! empty( $args['selected'] ) ) { |
|
138 | + if ( ! empty($args['selected'])) { |
|
139 | 139 | |
140 | 140 | // If a selected customer has been specified, we need to ensure it's in the initial list of customers displayed |
141 | 141 | |
142 | - if ( ! array_key_exists( $args['selected'], $options ) ) { |
|
142 | + if ( ! array_key_exists($args['selected'], $options)) { |
|
143 | 143 | |
144 | - $customer = new Give_Customer( $args['selected'] ); |
|
144 | + $customer = new Give_Customer($args['selected']); |
|
145 | 145 | |
146 | - if ( $customer ) { |
|
146 | + if ($customer) { |
|
147 | 147 | |
148 | - $options[ absint( $args['selected'] ) ] = esc_html( $customer->name . ' (' . $customer->email . ')' ); |
|
148 | + $options[absint($args['selected'])] = esc_html($customer->name.' ('.$customer->email.')'); |
|
149 | 149 | |
150 | 150 | } |
151 | 151 | |
@@ -153,17 +153,17 @@ discard block |
||
153 | 153 | |
154 | 154 | } |
155 | 155 | |
156 | - $output = $this->select( array( |
|
156 | + $output = $this->select(array( |
|
157 | 157 | 'name' => $args['name'], |
158 | 158 | 'selected' => $args['selected'], |
159 | 159 | 'id' => $args['id'], |
160 | - 'class' => $args['class'] . ' give-customer-select', |
|
160 | + 'class' => $args['class'].' give-customer-select', |
|
161 | 161 | 'options' => $options, |
162 | 162 | 'multiple' => $args['multiple'], |
163 | 163 | 'chosen' => $args['chosen'], |
164 | 164 | 'show_option_all' => false, |
165 | 165 | 'show_option_none' => false |
166 | - ) ); |
|
166 | + )); |
|
167 | 167 | |
168 | 168 | return $output; |
169 | 169 | } |
@@ -180,21 +180,21 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return string $output Category dropdown |
182 | 182 | */ |
183 | - public function category_dropdown( $name = 'give_forms_categories', $selected = 0 ) { |
|
184 | - $categories = get_terms( 'give_forms_category', apply_filters( 'give_forms_category_dropdown', array() ) ); |
|
183 | + public function category_dropdown($name = 'give_forms_categories', $selected = 0) { |
|
184 | + $categories = get_terms('give_forms_category', apply_filters('give_forms_category_dropdown', array())); |
|
185 | 185 | $options = array(); |
186 | 186 | |
187 | - foreach ( $categories as $category ) { |
|
188 | - $options[ absint( $category->term_id ) ] = esc_html( $category->name ); |
|
187 | + foreach ($categories as $category) { |
|
188 | + $options[absint($category->term_id)] = esc_html($category->name); |
|
189 | 189 | } |
190 | 190 | |
191 | - $output = $this->select( array( |
|
191 | + $output = $this->select(array( |
|
192 | 192 | 'name' => $name, |
193 | 193 | 'selected' => $selected, |
194 | 194 | 'options' => $options, |
195 | - 'show_option_all' => __( 'All Categories', 'give' ), |
|
195 | + 'show_option_all' => __('All Categories', 'give'), |
|
196 | 196 | 'show_option_none' => false |
197 | - ) ); |
|
197 | + )); |
|
198 | 198 | |
199 | 199 | return $output; |
200 | 200 | } |
@@ -212,25 +212,25 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @return string $output Year dropdown |
214 | 214 | */ |
215 | - public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) { |
|
216 | - $current = date( 'Y' ); |
|
217 | - $start_year = $current - absint( $years_before ); |
|
218 | - $end_year = $current + absint( $years_after ); |
|
219 | - $selected = empty( $selected ) ? date( 'Y' ) : $selected; |
|
215 | + public function year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) { |
|
216 | + $current = date('Y'); |
|
217 | + $start_year = $current - absint($years_before); |
|
218 | + $end_year = $current + absint($years_after); |
|
219 | + $selected = empty($selected) ? date('Y') : $selected; |
|
220 | 220 | $options = array(); |
221 | 221 | |
222 | - while ( $start_year <= $end_year ) { |
|
223 | - $options[ absint( $start_year ) ] = $start_year; |
|
224 | - $start_year ++; |
|
222 | + while ($start_year <= $end_year) { |
|
223 | + $options[absint($start_year)] = $start_year; |
|
224 | + $start_year++; |
|
225 | 225 | } |
226 | 226 | |
227 | - $output = $this->select( array( |
|
227 | + $output = $this->select(array( |
|
228 | 228 | 'name' => $name, |
229 | 229 | 'selected' => $selected, |
230 | 230 | 'options' => $options, |
231 | 231 | 'show_option_all' => false, |
232 | 232 | 'show_option_none' => false |
233 | - ) ); |
|
233 | + )); |
|
234 | 234 | |
235 | 235 | return $output; |
236 | 236 | } |
@@ -247,23 +247,23 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return string $output Month dropdown |
249 | 249 | */ |
250 | - public function month_dropdown( $name = 'month', $selected = 0 ) { |
|
250 | + public function month_dropdown($name = 'month', $selected = 0) { |
|
251 | 251 | $month = 1; |
252 | 252 | $options = array(); |
253 | - $selected = empty( $selected ) ? date( 'n' ) : $selected; |
|
253 | + $selected = empty($selected) ? date('n') : $selected; |
|
254 | 254 | |
255 | - while ( $month <= 12 ) { |
|
256 | - $options[ absint( $month ) ] = give_month_num_to_name( $month ); |
|
257 | - $month ++; |
|
255 | + while ($month <= 12) { |
|
256 | + $options[absint($month)] = give_month_num_to_name($month); |
|
257 | + $month++; |
|
258 | 258 | } |
259 | 259 | |
260 | - $output = $this->select( array( |
|
260 | + $output = $this->select(array( |
|
261 | 261 | 'name' => $name, |
262 | 262 | 'selected' => $selected, |
263 | 263 | 'options' => $options, |
264 | 264 | 'show_option_all' => false, |
265 | 265 | 'show_option_none' => false |
266 | - ) ); |
|
266 | + )); |
|
267 | 267 | |
268 | 268 | return $output; |
269 | 269 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * |
278 | 278 | * @return string |
279 | 279 | */ |
280 | - public function select( $args = array() ) { |
|
280 | + public function select($args = array()) { |
|
281 | 281 | $defaults = array( |
282 | 282 | 'options' => array(), |
283 | 283 | 'name' => null, |
@@ -287,60 +287,60 @@ discard block |
||
287 | 287 | 'chosen' => false, |
288 | 288 | 'placeholder' => null, |
289 | 289 | 'multiple' => false, |
290 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'give' ), |
|
291 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'give' ) |
|
290 | + 'show_option_all' => _x('All', 'all dropdown items', 'give'), |
|
291 | + 'show_option_none' => _x('None', 'no dropdown items', 'give') |
|
292 | 292 | ); |
293 | 293 | |
294 | - $args = wp_parse_args( $args, $defaults ); |
|
294 | + $args = wp_parse_args($args, $defaults); |
|
295 | 295 | |
296 | 296 | |
297 | - if ( $args['multiple'] ) { |
|
297 | + if ($args['multiple']) { |
|
298 | 298 | $multiple = ' MULTIPLE'; |
299 | 299 | } else { |
300 | 300 | $multiple = ''; |
301 | 301 | } |
302 | 302 | |
303 | - if ( $args['chosen'] ) { |
|
303 | + if ($args['chosen']) { |
|
304 | 304 | $args['class'] .= ' give-select-chosen'; |
305 | 305 | } |
306 | 306 | |
307 | - if ( $args['placeholder'] ) { |
|
307 | + if ($args['placeholder']) { |
|
308 | 308 | $placeholder = $args['placeholder']; |
309 | 309 | } else { |
310 | 310 | $placeholder = ''; |
311 | 311 | } |
312 | 312 | |
313 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ) . '" class="give-select ' . esc_attr( $args['class'] ) . '"' . $multiple . ' data-placeholder="' . $placeholder . '">'; |
|
313 | + $output = '<select name="'.esc_attr($args['name']).'" id="'.esc_attr(sanitize_key(str_replace('-', '_', $args['id']))).'" class="give-select '.esc_attr($args['class']).'"'.$multiple.' data-placeholder="'.$placeholder.'">'; |
|
314 | 314 | |
315 | - if ( $args['show_option_all'] ) { |
|
316 | - if ( $args['multiple'] ) { |
|
317 | - $selected = selected( true, in_array( 0, $args['selected'] ), false ); |
|
315 | + if ($args['show_option_all']) { |
|
316 | + if ($args['multiple']) { |
|
317 | + $selected = selected(true, in_array(0, $args['selected']), false); |
|
318 | 318 | } else { |
319 | - $selected = selected( $args['selected'], 0, false ); |
|
319 | + $selected = selected($args['selected'], 0, false); |
|
320 | 320 | } |
321 | - $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
321 | + $output .= '<option value="all"'.$selected.'>'.esc_html($args['show_option_all']).'</option>'; |
|
322 | 322 | } |
323 | 323 | |
324 | - if ( ! empty( $args['options'] ) ) { |
|
324 | + if ( ! empty($args['options'])) { |
|
325 | 325 | |
326 | - if ( $args['show_option_none'] ) { |
|
327 | - if ( $args['multiple'] ) { |
|
328 | - $selected = selected( true, in_array( - 1, $args['selected'] ), false ); |
|
326 | + if ($args['show_option_none']) { |
|
327 | + if ($args['multiple']) { |
|
328 | + $selected = selected(true, in_array( -1, $args['selected'] ), false); |
|
329 | 329 | } else { |
330 | - $selected = selected( $args['selected'], - 1, false ); |
|
330 | + $selected = selected($args['selected'], - 1, false); |
|
331 | 331 | } |
332 | - $output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
332 | + $output .= '<option value="-1"'.$selected.'>'.esc_html($args['show_option_none']).'</option>'; |
|
333 | 333 | } |
334 | 334 | |
335 | - foreach ( $args['options'] as $key => $option ) { |
|
335 | + foreach ($args['options'] as $key => $option) { |
|
336 | 336 | |
337 | - if ( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
338 | - $selected = selected( true, in_array( $key, $args['selected'] ), false ); |
|
337 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
338 | + $selected = selected(true, in_array($key, $args['selected']), false); |
|
339 | 339 | } else { |
340 | - $selected = selected( $args['selected'], $key, false ); |
|
340 | + $selected = selected($args['selected'], $key, false); |
|
341 | 341 | } |
342 | 342 | |
343 | - $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
|
343 | + $output .= '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option).'</option>'; |
|
344 | 344 | } |
345 | 345 | } |
346 | 346 | |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @return string |
360 | 360 | */ |
361 | - public function checkbox( $args = array() ) { |
|
361 | + public function checkbox($args = array()) { |
|
362 | 362 | $defaults = array( |
363 | 363 | 'name' => null, |
364 | 364 | 'current' => null, |
@@ -369,16 +369,16 @@ discard block |
||
369 | 369 | ) |
370 | 370 | ); |
371 | 371 | |
372 | - $args = wp_parse_args( $args, $defaults ); |
|
372 | + $args = wp_parse_args($args, $defaults); |
|
373 | 373 | |
374 | 374 | $options = ''; |
375 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
375 | + if ( ! empty($args['options']['disabled'])) { |
|
376 | 376 | $options .= ' disabled="disabled"'; |
377 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
377 | + } elseif ( ! empty($args['options']['readonly'])) { |
|
378 | 378 | $options .= ' readonly'; |
379 | 379 | } |
380 | 380 | |
381 | - $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
381 | + $output = '<input type="checkbox"'.$options.' name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].' '.esc_attr($args['name']).'" '.checked(1, $args['current'], false).' />'; |
|
382 | 382 | |
383 | 383 | return $output; |
384 | 384 | } |
@@ -392,22 +392,22 @@ discard block |
||
392 | 392 | * |
393 | 393 | * @return string Text field |
394 | 394 | */ |
395 | - public function text( $args = array() ) { |
|
395 | + public function text($args = array()) { |
|
396 | 396 | // Backwards compatabliity |
397 | - if ( func_num_args() > 1 ) { |
|
397 | + if (func_num_args() > 1) { |
|
398 | 398 | $args = func_get_args(); |
399 | 399 | |
400 | 400 | $name = $args[0]; |
401 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
402 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
403 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
401 | + $value = isset($args[1]) ? $args[1] : ''; |
|
402 | + $label = isset($args[2]) ? $args[2] : ''; |
|
403 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | $defaults = array( |
407 | - 'name' => isset( $name ) ? $name : 'text', |
|
408 | - 'value' => isset( $value ) ? $value : null, |
|
409 | - 'label' => isset( $label ) ? $label : null, |
|
410 | - 'desc' => isset( $desc ) ? $desc : null, |
|
407 | + 'name' => isset($name) ? $name : 'text', |
|
408 | + 'value' => isset($value) ? $value : null, |
|
409 | + 'label' => isset($label) ? $label : null, |
|
410 | + 'desc' => isset($desc) ? $desc : null, |
|
411 | 411 | 'placeholder' => '', |
412 | 412 | 'class' => 'regular-text', |
413 | 413 | 'disabled' => false, |
@@ -415,29 +415,29 @@ discard block |
||
415 | 415 | 'data' => false |
416 | 416 | ); |
417 | 417 | |
418 | - $args = wp_parse_args( $args, $defaults ); |
|
418 | + $args = wp_parse_args($args, $defaults); |
|
419 | 419 | |
420 | 420 | $disabled = ''; |
421 | - if ( $args['disabled'] ) { |
|
421 | + if ($args['disabled']) { |
|
422 | 422 | $disabled = ' disabled="disabled"'; |
423 | 423 | } |
424 | 424 | |
425 | 425 | $data = ''; |
426 | - if ( ! empty( $args['data'] ) ) { |
|
427 | - foreach ( $args['data'] as $key => $value ) { |
|
428 | - $data .= 'data-' . $key . '="' . $value . '" '; |
|
426 | + if ( ! empty($args['data'])) { |
|
427 | + foreach ($args['data'] as $key => $value) { |
|
428 | + $data .= 'data-'.$key.'="'.$value.'" '; |
|
429 | 429 | } |
430 | 430 | } |
431 | 431 | |
432 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
432 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
433 | 433 | |
434 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
434 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
435 | 435 | |
436 | - if ( ! empty( $args['desc'] ) ) { |
|
437 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
436 | + if ( ! empty($args['desc'])) { |
|
437 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
438 | 438 | } |
439 | 439 | |
440 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>'; |
|
440 | + $output .= '<input type="text" name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" autocomplete="'.esc_attr($args['autocomplete']).'" value="'.esc_attr($args['value']).'" placeholder="'.esc_attr($args['placeholder']).'" class="'.$args['class'].'" '.$data.''.$disabled.'/>'; |
|
441 | 441 | |
442 | 442 | $output .= '</span>'; |
443 | 443 | |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | * |
454 | 454 | * @return string textarea |
455 | 455 | */ |
456 | - public function textarea( $args = array() ) { |
|
456 | + public function textarea($args = array()) { |
|
457 | 457 | $defaults = array( |
458 | 458 | 'name' => 'textarea', |
459 | 459 | 'value' => null, |
@@ -463,21 +463,21 @@ discard block |
||
463 | 463 | 'disabled' => false |
464 | 464 | ); |
465 | 465 | |
466 | - $args = wp_parse_args( $args, $defaults ); |
|
466 | + $args = wp_parse_args($args, $defaults); |
|
467 | 467 | |
468 | 468 | $disabled = ''; |
469 | - if ( $args['disabled'] ) { |
|
469 | + if ($args['disabled']) { |
|
470 | 470 | $disabled = ' disabled="disabled"'; |
471 | 471 | } |
472 | 472 | |
473 | - $output = '<span id="give-' . sanitize_key( $args['name'] ) . '-wrap">'; |
|
473 | + $output = '<span id="give-'.sanitize_key($args['name']).'-wrap">'; |
|
474 | 474 | |
475 | - $output .= '<label class="give-label" for="give-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
475 | + $output .= '<label class="give-label" for="give-'.sanitize_key($args['name']).'">'.esc_html($args['label']).'</label>'; |
|
476 | 476 | |
477 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
477 | + $output .= '<textarea name="'.esc_attr($args['name']).'" id="'.esc_attr($args['name']).'" class="'.$args['class'].'"'.$disabled.'>'.esc_attr($args['value']).'</textarea>'; |
|
478 | 478 | |
479 | - if ( ! empty( $args['desc'] ) ) { |
|
480 | - $output .= '<span class="give-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
479 | + if ( ! empty($args['desc'])) { |
|
480 | + $output .= '<span class="give-description">'.esc_html($args['desc']).'</span>'; |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | $output .= '</span>'; |
@@ -494,12 +494,12 @@ discard block |
||
494 | 494 | * |
495 | 495 | * @return string text field with ajax search |
496 | 496 | */ |
497 | - public function ajax_user_search( $args = array() ) { |
|
497 | + public function ajax_user_search($args = array()) { |
|
498 | 498 | |
499 | 499 | $defaults = array( |
500 | 500 | 'name' => 'user_id', |
501 | 501 | 'value' => null, |
502 | - 'placeholder' => __( 'Enter username', 'give' ), |
|
502 | + 'placeholder' => __('Enter username', 'give'), |
|
503 | 503 | 'label' => null, |
504 | 504 | 'desc' => null, |
505 | 505 | 'class' => '', |
@@ -508,13 +508,13 @@ discard block |
||
508 | 508 | 'data' => false |
509 | 509 | ); |
510 | 510 | |
511 | - $args = wp_parse_args( $args, $defaults ); |
|
511 | + $args = wp_parse_args($args, $defaults); |
|
512 | 512 | |
513 | - $args['class'] = 'give-ajax-user-search ' . $args['class']; |
|
513 | + $args['class'] = 'give-ajax-user-search '.$args['class']; |
|
514 | 514 | |
515 | 515 | $output = '<span class="give_user_search_wrap">'; |
516 | - $output .= $this->text( $args ); |
|
517 | - $output .= '<span class="give_user_search_results hidden"><a class="give-ajax-user-cancel" title="' . __( 'Cancel', 'give' ) . '" aria-label="' . __( 'Cancel', 'give' ) . '" href="#">x</a><span></span></span>'; |
|
516 | + $output .= $this->text($args); |
|
517 | + $output .= '<span class="give_user_search_results hidden"><a class="give-ajax-user-cancel" title="'.__('Cancel', 'give').'" aria-label="'.__('Cancel', 'give').'" href="#">x</a><span></span></span>'; |
|
518 | 518 | $output .= '</span>'; |
519 | 519 | |
520 | 520 | return $output; |
@@ -8,11 +8,11 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | // Exit if accessed directly |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if ( ! defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
15 | -if ( ! class_exists( 'Give_License' ) ) : |
|
15 | +if ( ! class_exists('Give_License')) : |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * Give_License Class |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | * @param string $_optname |
39 | 39 | * @param string $_api_url |
40 | 40 | */ |
41 | - public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null ) { |
|
41 | + public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null) { |
|
42 | 42 | global $give_options; |
43 | 43 | |
44 | 44 | $this->file = $_file; |
45 | 45 | $this->item_name = $_item_name; |
46 | - $this->item_shortname = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) ); |
|
46 | + $this->item_shortname = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name))); |
|
47 | 47 | $this->version = $_version; |
48 | - $this->license = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : ''; |
|
48 | + $this->license = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : ''; |
|
49 | 49 | $this->author = $_author; |
50 | - $this->api_url = is_null( $_api_url ) ? $this->api_url : $_api_url; |
|
50 | + $this->api_url = is_null($_api_url) ? $this->api_url : $_api_url; |
|
51 | 51 | |
52 | 52 | |
53 | 53 | // Setup hooks |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @return void |
64 | 64 | */ |
65 | 65 | private function includes() { |
66 | - if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
66 | + if ( ! class_exists('EDD_SL_Plugin_Updater')) { |
|
67 | 67 | require_once 'admin/EDD_SL_Plugin_Updater.php'; |
68 | 68 | } |
69 | 69 | } |
@@ -77,18 +77,18 @@ discard block |
||
77 | 77 | private function hooks() { |
78 | 78 | |
79 | 79 | // Register settings |
80 | - add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 ); |
|
80 | + add_filter('give_settings_licenses', array($this, 'settings'), 1); |
|
81 | 81 | |
82 | 82 | // Activate license key on settings save |
83 | - add_action( 'admin_init', array( $this, 'activate_license' ) ); |
|
83 | + add_action('admin_init', array($this, 'activate_license')); |
|
84 | 84 | |
85 | 85 | // Deactivate license key |
86 | - add_action( 'admin_init', array( $this, 'deactivate_license' ) ); |
|
86 | + add_action('admin_init', array($this, 'deactivate_license')); |
|
87 | 87 | |
88 | 88 | // Updater |
89 | - add_action( 'admin_init', array( $this, 'auto_updater' ), 0 ); |
|
89 | + add_action('admin_init', array($this, 'auto_updater'), 0); |
|
90 | 90 | |
91 | - add_action( 'admin_notices', array( $this, 'notices' ) ); |
|
91 | + add_action('admin_notices', array($this, 'notices')); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function auto_updater() { |
102 | 102 | |
103 | - if ( 'valid' !== get_option( $this->item_shortname . '_license_active' ) ) { |
|
103 | + if ('valid' !== get_option($this->item_shortname.'_license_active')) { |
|
104 | 104 | return; |
105 | 105 | } |
106 | 106 | |
@@ -127,20 +127,20 @@ discard block |
||
127 | 127 | * |
128 | 128 | * @return array |
129 | 129 | */ |
130 | - public function settings( $settings ) { |
|
130 | + public function settings($settings) { |
|
131 | 131 | |
132 | 132 | $give_license_settings = array( |
133 | 133 | array( |
134 | - 'name' => sprintf( __( '%1$s', 'give' ), $this->item_name ), |
|
135 | - 'id' => $this->item_shortname . '_license_key', |
|
134 | + 'name' => sprintf(__('%1$s', 'give'), $this->item_name), |
|
135 | + 'id' => $this->item_shortname.'_license_key', |
|
136 | 136 | 'desc' => '', |
137 | 137 | 'type' => 'license_key', |
138 | - 'options' => array( 'is_valid_license_option' => $this->item_shortname . '_license_active' ), |
|
138 | + 'options' => array('is_valid_license_option' => $this->item_shortname.'_license_active'), |
|
139 | 139 | 'size' => 'regular' |
140 | 140 | ) |
141 | 141 | ); |
142 | 142 | |
143 | - return array_merge( $settings, $give_license_settings ); |
|
143 | + return array_merge($settings, $give_license_settings); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -152,18 +152,18 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return array |
154 | 154 | */ |
155 | - public function license_settings_content( $settings ) { |
|
155 | + public function license_settings_content($settings) { |
|
156 | 156 | |
157 | 157 | $give_license_settings = array( |
158 | 158 | array( |
159 | - 'name' => __( 'Add-on Licenses', 'give' ), |
|
159 | + 'name' => __('Add-on Licenses', 'give'), |
|
160 | 160 | 'desc' => '<hr>', |
161 | 161 | 'type' => 'give_title', |
162 | 162 | 'id' => 'give_title' |
163 | 163 | ), |
164 | 164 | ); |
165 | 165 | |
166 | - return array_merge( $settings, $give_license_settings ); |
|
166 | + return array_merge($settings, $give_license_settings); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | |
@@ -175,34 +175,34 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function activate_license() { |
177 | 177 | |
178 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
178 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
179 | 179 | return; |
180 | 180 | } |
181 | 181 | |
182 | - foreach ( $_POST as $key => $value ) { |
|
183 | - if ( false !== strpos( $key, 'license_key_deactivate' ) ) { |
|
182 | + foreach ($_POST as $key => $value) { |
|
183 | + if (false !== strpos($key, 'license_key_deactivate')) { |
|
184 | 184 | // Don't activate a key when deactivating a different key |
185 | 185 | return; |
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
189 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
189 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
190 | 190 | |
191 | - wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
191 | + wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array('response' => 403)); |
|
192 | 192 | |
193 | 193 | } |
194 | 194 | |
195 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
195 | + if ( ! current_user_can('manage_give_settings')) { |
|
196 | 196 | return; |
197 | 197 | } |
198 | 198 | |
199 | - if ( 'valid' === get_option( $this->item_shortname . '_license_active' ) ) { |
|
199 | + if ('valid' === get_option($this->item_shortname.'_license_active')) { |
|
200 | 200 | return; |
201 | 201 | } |
202 | 202 | |
203 | - $license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] ); |
|
203 | + $license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']); |
|
204 | 204 | |
205 | - if ( empty( $license ) ) { |
|
205 | + if (empty($license)) { |
|
206 | 206 | return; |
207 | 207 | } |
208 | 208 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $api_params = array( |
211 | 211 | 'edd_action' => 'activate_license', //never change from "edd_" to "give_"! |
212 | 212 | 'license' => $license, |
213 | - 'item_name' => urlencode( $this->item_name ), |
|
213 | + 'item_name' => urlencode($this->item_name), |
|
214 | 214 | 'url' => home_url() |
215 | 215 | ); |
216 | 216 | |
@@ -225,22 +225,22 @@ discard block |
||
225 | 225 | ); |
226 | 226 | |
227 | 227 | // Make sure there are no errors |
228 | - if ( is_wp_error( $response ) ) { |
|
228 | + if (is_wp_error($response)) { |
|
229 | 229 | return; |
230 | 230 | } |
231 | 231 | |
232 | 232 | // Tell WordPress to look for updates |
233 | - set_site_transient( 'update_plugins', null ); |
|
233 | + set_site_transient('update_plugins', null); |
|
234 | 234 | |
235 | 235 | // Decode license data |
236 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
236 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
237 | 237 | |
238 | - update_option( $this->item_shortname . '_license_active', $license_data->license ); |
|
238 | + update_option($this->item_shortname.'_license_active', $license_data->license); |
|
239 | 239 | |
240 | - if ( ! (bool) $license_data->success ) { |
|
241 | - set_transient( 'give_license_error', $license_data, 1000 ); |
|
240 | + if ( ! (bool) $license_data->success) { |
|
241 | + set_transient('give_license_error', $license_data, 1000); |
|
242 | 242 | } else { |
243 | - delete_transient( 'give_license_error' ); |
|
243 | + delete_transient('give_license_error'); |
|
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
@@ -253,28 +253,28 @@ discard block |
||
253 | 253 | */ |
254 | 254 | public function deactivate_license() { |
255 | 255 | |
256 | - if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) { |
|
256 | + if ( ! isset($_POST[$this->item_shortname.'_license_key'])) { |
|
257 | 257 | return; |
258 | 258 | } |
259 | 259 | |
260 | - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { |
|
260 | + if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) { |
|
261 | 261 | |
262 | - wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
262 | + wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array('response' => 403)); |
|
263 | 263 | |
264 | 264 | } |
265 | 265 | |
266 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
266 | + if ( ! current_user_can('manage_give_settings')) { |
|
267 | 267 | return; |
268 | 268 | } |
269 | 269 | |
270 | 270 | // Run on deactivate button press |
271 | - if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) { |
|
271 | + if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) { |
|
272 | 272 | |
273 | 273 | // Data to send to the API |
274 | 274 | $api_params = array( |
275 | 275 | 'edd_action' => 'deactivate_license', //never change from "edd_" to "give_"! |
276 | 276 | 'license' => $this->license, |
277 | - 'item_name' => urlencode( $this->item_name ), |
|
277 | + 'item_name' => urlencode($this->item_name), |
|
278 | 278 | 'url' => home_url() |
279 | 279 | ); |
280 | 280 | |
@@ -290,19 +290,19 @@ discard block |
||
290 | 290 | |
291 | 291 | |
292 | 292 | // Make sure there are no errors |
293 | - if ( is_wp_error( $response ) ) { |
|
293 | + if (is_wp_error($response)) { |
|
294 | 294 | return; |
295 | 295 | } |
296 | 296 | |
297 | 297 | // Decode the license data |
298 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
298 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
299 | 299 | |
300 | - delete_option( $this->item_shortname . '_license_active' ); |
|
300 | + delete_option($this->item_shortname.'_license_active'); |
|
301 | 301 | |
302 | - if ( ! (bool) $license_data->success ) { |
|
303 | - set_transient( 'give_license_error', $license_data, 1000 ); |
|
302 | + if ( ! (bool) $license_data->success) { |
|
303 | + set_transient('give_license_error', $license_data, 1000); |
|
304 | 304 | } else { |
305 | - delete_transient( 'give_license_error' ); |
|
305 | + delete_transient('give_license_error'); |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | } |
@@ -316,57 +316,57 @@ discard block |
||
316 | 316 | */ |
317 | 317 | public function notices() { |
318 | 318 | |
319 | - if ( ! isset( $_GET['page'] ) || 'give-settings' !== $_GET['page'] ) { |
|
319 | + if ( ! isset($_GET['page']) || 'give-settings' !== $_GET['page']) { |
|
320 | 320 | return; |
321 | 321 | } |
322 | 322 | |
323 | - if ( ! isset( $_GET['tab'] ) || 'licenses' !== $_GET['tab'] ) { |
|
323 | + if ( ! isset($_GET['tab']) || 'licenses' !== $_GET['tab']) { |
|
324 | 324 | return; |
325 | 325 | } |
326 | 326 | |
327 | - $license_error = get_transient( 'give_license_error' ); |
|
327 | + $license_error = get_transient('give_license_error'); |
|
328 | 328 | |
329 | - if ( false === $license_error ) { |
|
329 | + if (false === $license_error) { |
|
330 | 330 | return; |
331 | 331 | } |
332 | 332 | |
333 | - if ( ! empty( $license_error->error ) ) { |
|
333 | + if ( ! empty($license_error->error)) { |
|
334 | 334 | |
335 | - switch ( $license_error->error ) { |
|
335 | + switch ($license_error->error) { |
|
336 | 336 | |
337 | 337 | case 'item_name_mismatch' : |
338 | 338 | |
339 | - $message = __( 'This license does not belong to the product you have entered it for.', 'give' ); |
|
339 | + $message = __('This license does not belong to the product you have entered it for.', 'give'); |
|
340 | 340 | break; |
341 | 341 | |
342 | 342 | case 'no_activations_left' : |
343 | 343 | |
344 | - $message = __( 'This license does not have any activations left', 'give' ); |
|
344 | + $message = __('This license does not have any activations left', 'give'); |
|
345 | 345 | break; |
346 | 346 | |
347 | 347 | case 'expired' : |
348 | 348 | |
349 | - $message = __( 'This license key is expired. Please renew it.', 'give' ); |
|
349 | + $message = __('This license key is expired. Please renew it.', 'give'); |
|
350 | 350 | break; |
351 | 351 | |
352 | 352 | default : |
353 | 353 | |
354 | - $message = sprintf( __( 'There was a problem activating your license key, please try again or contact support. Error code: %s', 'give' ), $license_error->error ); |
|
354 | + $message = sprintf(__('There was a problem activating your license key, please try again or contact support. Error code: %s', 'give'), $license_error->error); |
|
355 | 355 | break; |
356 | 356 | |
357 | 357 | } |
358 | 358 | |
359 | 359 | } |
360 | 360 | |
361 | - if ( ! empty( $message ) ) { |
|
361 | + if ( ! empty($message)) { |
|
362 | 362 | |
363 | 363 | echo '<div class="error">'; |
364 | - echo '<p>' . $message . '</p>'; |
|
364 | + echo '<p>'.$message.'</p>'; |
|
365 | 365 | echo '</div>'; |
366 | 366 | |
367 | 367 | } |
368 | 368 | |
369 | - delete_transient( 'give_license_error' ); |
|
369 | + delete_transient('give_license_error'); |
|
370 | 370 | |
371 | 371 | } |
372 | 372 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function __construct() { |
30 | 30 | |
31 | - add_filter( 'give_map_meta_cap', array( $this, 'meta_caps' ), 10, 4 ); |
|
31 | + add_filter('give_map_meta_cap', array($this, 'meta_caps'), 10, 4); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @return void |
40 | 40 | */ |
41 | 41 | public function add_roles() { |
42 | - add_role( 'give_manager', __( 'Give Manager', 'give' ), array( |
|
42 | + add_role('give_manager', __('Give Manager', 'give'), array( |
|
43 | 43 | 'read' => true, |
44 | 44 | 'edit_posts' => true, |
45 | 45 | 'delete_posts' => true, |
@@ -68,20 +68,20 @@ discard block |
||
68 | 68 | 'publish_posts' => true, |
69 | 69 | 'read_private_pages' => true, |
70 | 70 | 'read_private_posts' => true |
71 | - ) ); |
|
71 | + )); |
|
72 | 72 | |
73 | - add_role( 'give_accountant', __( 'Give Accountant', 'give' ), array( |
|
73 | + add_role('give_accountant', __('Give Accountant', 'give'), array( |
|
74 | 74 | 'read' => true, |
75 | 75 | 'edit_posts' => false, |
76 | 76 | 'delete_posts' => false |
77 | - ) ); |
|
77 | + )); |
|
78 | 78 | |
79 | - add_role( 'give_worker', __( 'Give Worker', 'give' ), array( |
|
79 | + add_role('give_worker', __('Give Worker', 'give'), array( |
|
80 | 80 | 'read' => true, |
81 | 81 | 'edit_posts' => false, |
82 | 82 | 'upload_files' => true, |
83 | 83 | 'delete_posts' => false |
84 | - ) ); |
|
84 | + )); |
|
85 | 85 | |
86 | 86 | } |
87 | 87 | |
@@ -96,38 +96,38 @@ discard block |
||
96 | 96 | public function add_caps() { |
97 | 97 | global $wp_roles; |
98 | 98 | |
99 | - if ( class_exists('WP_Roles') ) { |
|
100 | - if ( ! isset( $wp_roles ) ) { |
|
99 | + if (class_exists('WP_Roles')) { |
|
100 | + if ( ! isset($wp_roles)) { |
|
101 | 101 | $wp_roles = new WP_Roles(); |
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
105 | - if ( is_object( $wp_roles ) ) { |
|
106 | - $wp_roles->add_cap( 'give_manager', 'view_give_reports' ); |
|
107 | - $wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
108 | - $wp_roles->add_cap( 'give_manager', 'export_give_reports' ); |
|
109 | - $wp_roles->add_cap( 'give_manager', 'manage_give_settings' ); |
|
105 | + if (is_object($wp_roles)) { |
|
106 | + $wp_roles->add_cap('give_manager', 'view_give_reports'); |
|
107 | + $wp_roles->add_cap('give_manager', 'view_give_sensitive_data'); |
|
108 | + $wp_roles->add_cap('give_manager', 'export_give_reports'); |
|
109 | + $wp_roles->add_cap('give_manager', 'manage_give_settings'); |
|
110 | 110 | |
111 | - $wp_roles->add_cap( 'administrator', 'view_give_reports' ); |
|
112 | - $wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' ); |
|
113 | - $wp_roles->add_cap( 'administrator', 'export_give_reports' ); |
|
114 | - $wp_roles->add_cap( 'administrator', 'manage_give_settings' ); |
|
111 | + $wp_roles->add_cap('administrator', 'view_give_reports'); |
|
112 | + $wp_roles->add_cap('administrator', 'view_give_sensitive_data'); |
|
113 | + $wp_roles->add_cap('administrator', 'export_give_reports'); |
|
114 | + $wp_roles->add_cap('administrator', 'manage_give_settings'); |
|
115 | 115 | |
116 | 116 | // Add the main post type capabilities |
117 | 117 | $capabilities = $this->get_core_caps(); |
118 | - foreach ( $capabilities as $cap_group ) { |
|
119 | - foreach ( $cap_group as $cap ) { |
|
120 | - $wp_roles->add_cap( 'give_manager', $cap ); |
|
121 | - $wp_roles->add_cap( 'administrator', $cap ); |
|
122 | - $wp_roles->add_cap( 'give_worker', $cap ); |
|
118 | + foreach ($capabilities as $cap_group) { |
|
119 | + foreach ($cap_group as $cap) { |
|
120 | + $wp_roles->add_cap('give_manager', $cap); |
|
121 | + $wp_roles->add_cap('administrator', $cap); |
|
122 | + $wp_roles->add_cap('give_worker', $cap); |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_forms' ); |
|
127 | - $wp_roles->add_cap( 'give_accountant', 'read_private_forms' ); |
|
128 | - $wp_roles->add_cap( 'give_accountant', 'view_give_reports' ); |
|
129 | - $wp_roles->add_cap( 'give_accountant', 'export_give_reports' ); |
|
130 | - $wp_roles->add_cap( 'give_accountant', 'edit_give_payments' ); |
|
126 | + $wp_roles->add_cap('give_accountant', 'edit_give_forms'); |
|
127 | + $wp_roles->add_cap('give_accountant', 'read_private_forms'); |
|
128 | + $wp_roles->add_cap('give_accountant', 'view_give_reports'); |
|
129 | + $wp_roles->add_cap('give_accountant', 'export_give_reports'); |
|
130 | + $wp_roles->add_cap('give_accountant', 'edit_give_payments'); |
|
131 | 131 | |
132 | 132 | } |
133 | 133 | } |
@@ -142,10 +142,10 @@ discard block |
||
142 | 142 | public function get_core_caps() { |
143 | 143 | $capabilities = array(); |
144 | 144 | |
145 | - $capability_types = array( 'give_forms', 'give_campaigns', 'give_payments' ); |
|
145 | + $capability_types = array('give_forms', 'give_campaigns', 'give_payments'); |
|
146 | 146 | |
147 | - foreach ( $capability_types as $capability_type ) { |
|
148 | - $capabilities[ $capability_type ] = array( |
|
147 | + foreach ($capability_types as $capability_type) { |
|
148 | + $capabilities[$capability_type] = array( |
|
149 | 149 | // Post type |
150 | 150 | "edit_{$capability_type}", |
151 | 151 | "read_{$capability_type}", |
@@ -182,22 +182,22 @@ discard block |
||
182 | 182 | * @since 2.0 |
183 | 183 | * @return array $caps |
184 | 184 | */ |
185 | - public function meta_caps( $caps, $cap, $user_id, $args ) { |
|
185 | + public function meta_caps($caps, $cap, $user_id, $args) { |
|
186 | 186 | |
187 | - switch( $cap ) { |
|
187 | + switch ($cap) { |
|
188 | 188 | |
189 | 189 | case 'view_give_forms_stats' : |
190 | 190 | |
191 | - if( empty( $args[0] ) ) { |
|
191 | + if (empty($args[0])) { |
|
192 | 192 | break; |
193 | 193 | } |
194 | 194 | |
195 | - $form = get_post( $args[0] ); |
|
196 | - if ( empty( $form ) ) { |
|
195 | + $form = get_post($args[0]); |
|
196 | + if (empty($form)) { |
|
197 | 197 | break; |
198 | 198 | } |
199 | 199 | |
200 | - if( user_can( $user_id, 'view_give_reports' ) || $user_id == $form->post_author ) { |
|
200 | + if (user_can($user_id, 'view_give_reports') || $user_id == $form->post_author) { |
|
201 | 201 | $caps = array(); |
202 | 202 | } |
203 | 203 | |
@@ -219,41 +219,41 @@ discard block |
||
219 | 219 | |
220 | 220 | global $wp_roles; |
221 | 221 | |
222 | - if ( class_exists( 'WP_Roles' ) ) { |
|
223 | - if ( ! isset( $wp_roles ) ) { |
|
222 | + if (class_exists('WP_Roles')) { |
|
223 | + if ( ! isset($wp_roles)) { |
|
224 | 224 | $wp_roles = new WP_Roles(); |
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
228 | - if ( is_object( $wp_roles ) ) { |
|
228 | + if (is_object($wp_roles)) { |
|
229 | 229 | /** Give Manager Capabilities */ |
230 | - $wp_roles->remove_cap( 'give_manager', 'view_give_reports' ); |
|
231 | - $wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' ); |
|
232 | - $wp_roles->remove_cap( 'give_manager', 'export_give_reports' ); |
|
233 | - $wp_roles->remove_cap( 'give_manager', 'manage_give_settings' ); |
|
230 | + $wp_roles->remove_cap('give_manager', 'view_give_reports'); |
|
231 | + $wp_roles->remove_cap('give_manager', 'view_give_sensitive_data'); |
|
232 | + $wp_roles->remove_cap('give_manager', 'export_give_reports'); |
|
233 | + $wp_roles->remove_cap('give_manager', 'manage_give_settings'); |
|
234 | 234 | |
235 | 235 | /** Site Administrator Capabilities */ |
236 | - $wp_roles->remove_cap( 'administrator', 'view_give_reports' ); |
|
237 | - $wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' ); |
|
238 | - $wp_roles->remove_cap( 'administrator', 'export_give_reports' ); |
|
239 | - $wp_roles->remove_cap( 'administrator', 'manage_give_settings' ); |
|
236 | + $wp_roles->remove_cap('administrator', 'view_give_reports'); |
|
237 | + $wp_roles->remove_cap('administrator', 'view_give_sensitive_data'); |
|
238 | + $wp_roles->remove_cap('administrator', 'export_give_reports'); |
|
239 | + $wp_roles->remove_cap('administrator', 'manage_give_settings'); |
|
240 | 240 | |
241 | 241 | /** Remove the Main Post Type Capabilities */ |
242 | 242 | $capabilities = $this->get_core_caps(); |
243 | 243 | |
244 | - foreach ( $capabilities as $cap_group ) { |
|
245 | - foreach ( $cap_group as $cap ) { |
|
246 | - $wp_roles->remove_cap( 'give_manager', $cap ); |
|
247 | - $wp_roles->remove_cap( 'administrator', $cap ); |
|
248 | - $wp_roles->remove_cap( 'give_worker', $cap ); |
|
244 | + foreach ($capabilities as $cap_group) { |
|
245 | + foreach ($cap_group as $cap) { |
|
246 | + $wp_roles->remove_cap('give_manager', $cap); |
|
247 | + $wp_roles->remove_cap('administrator', $cap); |
|
248 | + $wp_roles->remove_cap('give_worker', $cap); |
|
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
252 | 252 | /** Shop Accountant Capabilities */ |
253 | - $wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' ); |
|
254 | - $wp_roles->remove_cap( 'give_accountant', 'read_private_forms' ); |
|
255 | - $wp_roles->remove_cap( 'give_accountant', 'view_give_reports' ); |
|
256 | - $wp_roles->remove_cap( 'give_accountant', 'export_give_reports' ); |
|
253 | + $wp_roles->remove_cap('give_accountant', 'edit_give_forms'); |
|
254 | + $wp_roles->remove_cap('give_accountant', 'read_private_forms'); |
|
255 | + $wp_roles->remove_cap('give_accountant', 'view_give_reports'); |
|
256 | + $wp_roles->remove_cap('give_accountant', 'export_give_reports'); |
|
257 | 257 | |
258 | 258 | } |
259 | 259 | } |
@@ -71,9 +71,9 @@ |
||
71 | 71 | ) ); |
72 | 72 | |
73 | 73 | add_role( 'give_accountant', __( 'Give Accountant', 'give' ), array( |
74 | - 'read' => true, |
|
75 | - 'edit_posts' => false, |
|
76 | - 'delete_posts' => false |
|
74 | + 'read' => true, |
|
75 | + 'edit_posts' => false, |
|
76 | + 'delete_posts' => false |
|
77 | 77 | ) ); |
78 | 78 | |
79 | 79 | add_role( 'give_worker', __( 'Give Worker', 'give' ), array( |