Completed
Pull Request — master (#1201)
by Ravinder
23:20
created
includes/admin/shortcodes/shortcode-give-receipt.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
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
 
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
 	 */
25 25
 	public function __construct() {
26 26
 
27
-		$this->shortcode['title'] = esc_html__( 'Donation Receipt', 'give' );
28
-		$this->shortcode['label'] = esc_html__( 'Donation Receipt', 'give' );
27
+		$this->shortcode['title'] = esc_html__('Donation Receipt', 'give');
28
+		$this->shortcode['label'] = esc_html__('Donation Receipt', 'give');
29 29
 
30
-		parent::__construct( 'give_receipt' );
30
+		parent::__construct('give_receipt');
31 31
 	}
32 32
 
33 33
 	/**
@@ -40,60 +40,60 @@  discard block
 block discarded – undo
40 40
 		return array(
41 41
 			array(
42 42
 				'type' => 'container',
43
-				'html' => sprintf( '<p class="strong">%s</p>', esc_html__( 'Optional settings', 'give' ) ),
43
+				'html' => sprintf('<p class="strong">%s</p>', esc_html__('Optional settings', 'give')),
44 44
 			),
45 45
 			array(
46 46
 				'type'    => 'listbox',
47 47
 				'name'    => 'price',
48
-				'label'   => esc_html__( 'Show Donation Amount:', 'give' ),
48
+				'label'   => esc_html__('Show Donation Amount:', 'give'),
49 49
 				'options' => array(
50
-					'true'  => esc_html__( 'Show', 'give' ),
51
-					'false' => esc_html__( 'Hide', 'give' ),
50
+					'true'  => esc_html__('Show', 'give'),
51
+					'false' => esc_html__('Hide', 'give'),
52 52
 				),
53 53
 			),
54 54
 			array(
55 55
 				'type'    => 'listbox',
56 56
 				'name'    => 'donor',
57
-				'label'   => esc_html__( 'Show Donor Name:', 'give' ),
57
+				'label'   => esc_html__('Show Donor Name:', 'give'),
58 58
 				'options' => array(
59
-					'true'  => esc_html__( 'Show', 'give' ),
60
-					'false' => esc_html__( 'Hide', 'give' ),
59
+					'true'  => esc_html__('Show', 'give'),
60
+					'false' => esc_html__('Hide', 'give'),
61 61
 				),
62 62
 			),
63 63
 			array(
64 64
 				'type'    => 'listbox',
65 65
 				'name'    => 'date',
66
-				'label'   => esc_html__( 'Show Date:', 'give' ),
66
+				'label'   => esc_html__('Show Date:', 'give'),
67 67
 				'options' => array(
68
-					'true'  => esc_html__( 'Show', 'give' ),
69
-					'false' => esc_html__( 'Hide', 'give' ),
68
+					'true'  => esc_html__('Show', 'give'),
69
+					'false' => esc_html__('Hide', 'give'),
70 70
 				),
71 71
 			),
72 72
 			array(
73 73
 				'type'    => 'listbox',
74 74
 				'name'    => 'payment_key',
75
-				'label'   => esc_html__( 'Show Payment Key:', 'give' ),
75
+				'label'   => esc_html__('Show Payment Key:', 'give'),
76 76
 				'options' => array(
77
-					'true'  => esc_html__( 'Show', 'give' ),
78
-					'false' => esc_html__( 'Hide', 'give' ),
77
+					'true'  => esc_html__('Show', 'give'),
78
+					'false' => esc_html__('Hide', 'give'),
79 79
 				),
80 80
 			),
81 81
 			array(
82 82
 				'type'    => 'listbox',
83 83
 				'name'    => 'payment_method',
84
-				'label'   => esc_html__( 'Show Payment Method:', 'give' ),
84
+				'label'   => esc_html__('Show Payment Method:', 'give'),
85 85
 				'options' => array(
86
-					'true'  => esc_html__( 'Show', 'give' ),
87
-					'false' => esc_html__( 'Hide', 'give' ),
86
+					'true'  => esc_html__('Show', 'give'),
87
+					'false' => esc_html__('Hide', 'give'),
88 88
 				),
89 89
 			),
90 90
 			array(
91 91
 				'type'    => 'listbox',
92 92
 				'name'    => 'payment_id',
93
-				'label'   => esc_html__( 'Show Payment ID:', 'give' ),
93
+				'label'   => esc_html__('Show Payment ID:', 'give'),
94 94
 				'options' => array(
95
-					'true'  => esc_html__( 'Show', 'give' ),
96
-					'false' => esc_html__( 'Hide', 'give' ),
95
+					'true'  => esc_html__('Show', 'give'),
96
+					'false' => esc_html__('Hide', 'give'),
97 97
 				),
98 98
 			),
99 99
 		);
Please login to merge, or discard this patch.
includes/admin/shortcodes/shortcode-give-goal.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 // Exit if accessed directly
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
 	 */
24 24
 	public function __construct() {
25 25
 
26
-		$this->shortcode['title'] = esc_html__( 'Donation Form Goal', 'give' );
27
-		$this->shortcode['label'] = esc_html__( 'Donation Form Goal', 'give' );
26
+		$this->shortcode['title'] = esc_html__('Donation Form Goal', 'give');
27
+		$this->shortcode['label'] = esc_html__('Donation Form Goal', 'give');
28 28
 
29
-		parent::__construct( 'give_goal' );
29
+		parent::__construct('give_goal');
30 30
 	}
31 31
 
32 32
 	/**
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 
39 39
 		$create_form_link = sprintf(
40 40
 		/* translators: %s: create new form URL */
41
-			__( '<a href="%s">Create</a> a new Donation Form.', 'give' ),
42
-			admin_url( 'post-new.php?post_type=give_forms' )
41
+			__('<a href="%s">Create</a> a new Donation Form.', 'give'),
42
+			admin_url('post-new.php?post_type=give_forms')
43 43
 		);
44 44
 
45 45
 		return array(
@@ -49,35 +49,35 @@  discard block
 block discarded – undo
49 49
 					'post_type' => 'give_forms',
50 50
 				),
51 51
 				'name'        => 'id',
52
-				'tooltip'     => esc_attr__( 'Select a Donation Form', 'give' ),
53
-				'placeholder' => esc_attr__( '- Select a Form -', 'give' ),
52
+				'tooltip'     => esc_attr__('Select a Donation Form', 'give'),
53
+				'placeholder' => esc_attr__('- Select a Form -', 'give'),
54 54
 				'required'    => array(
55
-					'alert' => esc_html__( 'You must first select a Form!', 'give' ),
56
-					'error' => sprintf( '<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__( 'No forms found.', 'give' ), $create_form_link ),
55
+					'alert' => esc_html__('You must first select a Form!', 'give'),
56
+					'error' => sprintf('<p class="strong">%s</p><p class="no-margin">%s</p>', esc_html__('No forms found.', 'give'), $create_form_link),
57 57
 				),
58 58
 			),
59 59
 			array(
60 60
 				'type' => 'container',
61
-				'html' => sprintf( '<p class="strong margin-top">%s</p>', esc_html__( 'Optional settings', 'give' ) ),
61
+				'html' => sprintf('<p class="strong margin-top">%s</p>', esc_html__('Optional settings', 'give')),
62 62
 			),
63 63
 			array(
64 64
 				'type'    => 'listbox',
65 65
 				'name'    => 'show_text',
66
-				'label'   => esc_attr__( 'Show Text:', 'give' ),
67
-				'tooltip' => esc_attr__( 'This text displays the amount of income raised compared to the goal.', 'give' ),
66
+				'label'   => esc_attr__('Show Text:', 'give'),
67
+				'tooltip' => esc_attr__('This text displays the amount of income raised compared to the goal.', 'give'),
68 68
 				'options' => array(
69
-					'true'  => esc_html__( 'Show', 'give' ),
70
-					'false' => esc_html__( 'Hide', 'give' ),
69
+					'true'  => esc_html__('Show', 'give'),
70
+					'false' => esc_html__('Hide', 'give'),
71 71
 				),
72 72
 			),
73 73
 			array(
74 74
 				'type'    => 'listbox',
75 75
 				'name'    => 'show_bar',
76
-				'label'   => esc_attr__( 'Show Progress Bar:', 'give' ),
77
-				'tooltip' => esc_attr__( 'Do you want to display the goal\'s progress bar?', 'give' ),
76
+				'label'   => esc_attr__('Show Progress Bar:', 'give'),
77
+				'tooltip' => esc_attr__('Do you want to display the goal\'s progress bar?', 'give'),
78 78
 				'options' => array(
79
-					'true'  => esc_html__( 'Show', 'give' ),
80
-					'false' => esc_html__( 'Hide', 'give' ),
79
+					'true'  => esc_html__('Show', 'give'),
80
+					'false' => esc_html__('Hide', 'give'),
81 81
 				),
82 82
 			),
83 83
 		);
Please login to merge, or discard this patch.
includes/admin/shortcodes/shortcode-give-profile-editor.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	public function __construct() {
23 23
 
24
-		$this->shortcode['label'] = esc_html__( 'Profile Editor', 'give' );
24
+		$this->shortcode['label'] = esc_html__('Profile Editor', 'give');
25 25
 
26
-		parent::__construct( 'give_profile_editor' );
26
+		parent::__construct('give_profile_editor');
27 27
 	}
28 28
 }
29 29
 
Please login to merge, or discard this patch.
includes/admin/add-ons.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
 	ob_start(); ?>
27 27
 	<div class="wrap" id="give-add-ons">
28 28
 		<h1><?php echo get_admin_page_title(); ?>
29
-			&nbsp;&mdash;&nbsp;<a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" target="_blank"><?php esc_html_e( 'View All Add-ons', 'give' ); ?>
29
+			&nbsp;&mdash;&nbsp;<a href="https://givewp.com/addons/" class="button-primary give-view-addons-all" target="_blank"><?php esc_html_e('View All Add-ons', 'give'); ?>
30 30
 				<span class="dashicons dashicons-external"></span></a>
31 31
 		</h1>
32 32
 
33
-		<p><?php esc_html_e( 'The following Add-ons extend the functionality of Give.', 'give' ); ?></p>
33
+		<p><?php esc_html_e('The following Add-ons extend the functionality of Give.', 'give'); ?></p>
34 34
 		<?php echo give_add_ons_get_feed(); ?>
35 35
 	</div>
36 36
 	<?php
@@ -48,18 +48,18 @@  discard block
 block discarded – undo
48 48
 function give_add_ons_get_feed() {
49 49
 
50 50
 	$addons_debug = false; //set to true to debug
51
-	$cache        = get_transient( 'give_add_ons_feed' );
51
+	$cache        = get_transient('give_add_ons_feed');
52 52
 
53
-	if ( $cache === false || $addons_debug === true && WP_DEBUG === true ) {
54
-		$feed = wp_remote_get( 'https://givewp.com/downloads/feed/', array( 'sslverify' => false ) );
53
+	if ($cache === false || $addons_debug === true && WP_DEBUG === true) {
54
+		$feed = wp_remote_get('https://givewp.com/downloads/feed/', array('sslverify' => false));
55 55
 
56
-		if ( ! is_wp_error( $feed ) ) {
57
-			if ( isset( $feed['body'] ) && strlen( $feed['body'] ) > 0 ) {
58
-				$cache = wp_remote_retrieve_body( $feed );
59
-				set_transient( 'give_add_ons_feed', $cache, 3600 );
56
+		if ( ! is_wp_error($feed)) {
57
+			if (isset($feed['body']) && strlen($feed['body']) > 0) {
58
+				$cache = wp_remote_retrieve_body($feed);
59
+				set_transient('give_add_ons_feed', $cache, 3600);
60 60
 			}
61 61
 		} else {
62
-			$cache = '<div class="error"><p>' . esc_html__( 'There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give' ) . '</div>';
62
+			$cache = '<div class="error"><p>'.esc_html__('There was an error retrieving the Give Add-ons list from the server. Please try again later.', 'give').'</div>';
63 63
 		}
64 64
 	}
65 65
 
Please login to merge, or discard this patch.
includes/admin/forms/dashboard-columns.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
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
 
@@ -27,34 +27,34 @@  discard block
 block discarded – undo
27 27
  * @return array $form_columns Updated array of forms columns
28 28
  *  Post Type List Table
29 29
  */
30
-function give_form_columns( $give_form_columns ) {
30
+function give_form_columns($give_form_columns) {
31 31
 
32 32
 	//Standard columns
33 33
 	$give_form_columns = array(
34 34
 		'cb'            => '<input type="checkbox"/>',
35
-		'title'         => esc_html__( 'Name', 'give' ),
36
-		'form_category' => esc_html__( 'Categories', 'give' ),
37
-		'form_tag'      => esc_html__( 'Tags', 'give' ),
38
-		'price'         => esc_html__( 'Price', 'give' ),
39
-		'goal'          => esc_html__( 'Goal', 'give' ),
40
-		'donations'     => esc_html__( 'Donations', 'give' ),
41
-		'earnings'      => esc_html__( 'Income', 'give' ),
42
-		'shortcode'     => esc_html__( 'Shortcode', 'give' ),
43
-		'date'          => esc_html__( 'Date', 'give' )
35
+		'title'         => esc_html__('Name', 'give'),
36
+		'form_category' => esc_html__('Categories', 'give'),
37
+		'form_tag'      => esc_html__('Tags', 'give'),
38
+		'price'         => esc_html__('Price', 'give'),
39
+		'goal'          => esc_html__('Goal', 'give'),
40
+		'donations'     => esc_html__('Donations', 'give'),
41
+		'earnings'      => esc_html__('Income', 'give'),
42
+		'shortcode'     => esc_html__('Shortcode', 'give'),
43
+		'date'          => esc_html__('Date', 'give')
44 44
 	);
45 45
 
46 46
 	//Does the user want categories / tags?
47
-	if ( give_get_option( 'enable_categories' ) !== 'on' ) {
48
-		unset( $give_form_columns['form_category'] );
47
+	if (give_get_option('enable_categories') !== 'on') {
48
+		unset($give_form_columns['form_category']);
49 49
 	}
50
-	if ( give_get_option( 'enable_tags' ) !== 'on' ) {
51
-		unset( $give_form_columns['form_tag'] );
50
+	if (give_get_option('enable_tags') !== 'on') {
51
+		unset($give_form_columns['form_tag']);
52 52
 	}
53 53
 
54
-	return apply_filters( 'give_forms_columns', $give_form_columns );
54
+	return apply_filters('give_forms_columns', $give_form_columns);
55 55
 }
56 56
 
57
-add_filter( 'manage_edit-give_forms_columns', 'give_form_columns' );
57
+add_filter('manage_edit-give_forms_columns', 'give_form_columns');
58 58
 
59 59
 /**
60 60
  * Render Give Form Columns
@@ -66,60 +66,60 @@  discard block
 block discarded – undo
66 66
  *
67 67
  * @return void
68 68
  */
69
-function give_render_form_columns( $column_name, $post_id ) {
70
-	if ( get_post_type( $post_id ) == 'give_forms' ) {
69
+function give_render_form_columns($column_name, $post_id) {
70
+	if (get_post_type($post_id) == 'give_forms') {
71 71
 		
72
-		switch ( $column_name ) {
72
+		switch ($column_name) {
73 73
 			case 'form_category':
74
-				echo get_the_term_list( $post_id, 'give_forms_category', '', ', ', '' );
74
+				echo get_the_term_list($post_id, 'give_forms_category', '', ', ', '');
75 75
 				break;
76 76
 			case 'form_tag':
77
-				echo get_the_term_list( $post_id, 'give_forms_tag', '', ', ', '' );
77
+				echo get_the_term_list($post_id, 'give_forms_tag', '', ', ', '');
78 78
 				break;
79 79
 			case 'price':
80
-				if ( give_has_variable_prices( $post_id ) ) {
81
-					echo give_price_range( $post_id );
80
+				if (give_has_variable_prices($post_id)) {
81
+					echo give_price_range($post_id);
82 82
 				} else {
83
-					echo give_price( $post_id, false );
84
-					echo '<input type="hidden" class="formprice-' . $post_id . '" value="' . give_get_form_price( $post_id ) . '" />';
83
+					echo give_price($post_id, false);
84
+					echo '<input type="hidden" class="formprice-'.$post_id.'" value="'.give_get_form_price($post_id).'" />';
85 85
 				}
86 86
 				break;
87 87
 			case 'goal':
88
-				$goal_option = get_post_meta( $post_id, '_give_goal_option', true );
89
-				if ( ! empty( $goal_option ) && $goal_option === 'yes' ) {
90
-					echo give_goal( $post_id, false );
88
+				$goal_option = get_post_meta($post_id, '_give_goal_option', true);
89
+				if ( ! empty($goal_option) && $goal_option === 'yes') {
90
+					echo give_goal($post_id, false);
91 91
 				} else {
92
-					esc_html_e( 'No Goal Set', 'give' );
92
+					esc_html_e('No Goal Set', 'give');
93 93
 				}
94 94
 
95
-				echo '<input type="hidden" class="formgoal-' . $post_id . '" value="' . give_get_form_goal( $post_id ) . '" />';
95
+				echo '<input type="hidden" class="formgoal-'.$post_id.'" value="'.give_get_form_goal($post_id).'" />';
96 96
 				break;
97 97
 			case 'donations':
98
-				if ( current_user_can( 'view_give_form_stats', $post_id ) ) {
99
-					echo '<a href="' . esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=logs&view=sales&form=' . $post_id ) ) . '">';
100
-					echo give_get_form_sales_stats( $post_id );
98
+				if (current_user_can('view_give_form_stats', $post_id)) {
99
+					echo '<a href="'.esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&tab=logs&view=sales&form='.$post_id)).'">';
100
+					echo give_get_form_sales_stats($post_id);
101 101
 					echo '</a>';
102 102
 				} else {
103 103
 					echo '-';
104 104
 				}
105 105
 				break;
106 106
 			case 'earnings':
107
-				if ( current_user_can( 'view_give_form_stats', $post_id ) ) {
108
-					echo '<a href="' . esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&view=forms&form-id=' . $post_id ) ) . '">';
109
-					echo give_currency_filter( give_format_amount( give_get_form_earnings_stats( $post_id ) ) );
107
+				if (current_user_can('view_give_form_stats', $post_id)) {
108
+					echo '<a href="'.esc_url(admin_url('edit.php?post_type=give_forms&page=give-reports&view=forms&form-id='.$post_id)).'">';
109
+					echo give_currency_filter(give_format_amount(give_get_form_earnings_stats($post_id)));
110 110
 					echo '</a>';
111 111
 				} else {
112 112
 					echo '-';
113 113
 				}
114 114
 				break;
115 115
 			case 'shortcode':
116
-				echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id=&#34;' . absint( $post_id ) . '&#34;]">';
116
+				echo '<input onclick="this.setSelectionRange(0, this.value.length)" type="text" class="shortcode-input" readonly="" value="[give_form id=&#34;'.absint($post_id).'&#34;]">';
117 117
 				break;
118 118
 		}
119 119
 	}
120 120
 }
121 121
 
122
-add_action( 'manage_posts_custom_column', 'give_render_form_columns', 10, 2 );
122
+add_action('manage_posts_custom_column', 'give_render_form_columns', 10, 2);
123 123
 
124 124
 /**
125 125
  * Registers the sortable columns in the list table
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
  *
131 131
  * @return array $columns Array of sortable columns
132 132
  */
133
-function give_sortable_form_columns( $columns ) {
133
+function give_sortable_form_columns($columns) {
134 134
 	$columns['price']    = 'price';
135 135
 	$columns['sales']    = 'sales';
136 136
 	$columns['earnings'] = 'earnings';
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	return $columns;
140 140
 }
141 141
 
142
-add_filter( 'manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns' );
142
+add_filter('manage_edit-give_forms_sortable_columns', 'give_sortable_form_columns');
143 143
 
144 144
 /**
145 145
  * Sorts Columns in the Forms List Table
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
  *
151 151
  * @return array $vars Array of all the sort variables
152 152
  */
153
-function give_sort_forms( $vars ) {
153
+function give_sort_forms($vars) {
154 154
 	// Check if we're viewing the "give_forms" post type
155
-	if ( isset( $vars['post_type'] ) && 'give_forms' == $vars['post_type'] ) {
155
+	if (isset($vars['post_type']) && 'give_forms' == $vars['post_type']) {
156 156
 		// Check if 'orderby' is set to "sales"
157
-		if ( isset( $vars['orderby'] ) && 'sales' == $vars['orderby'] ) {
157
+		if (isset($vars['orderby']) && 'sales' == $vars['orderby']) {
158 158
 			$vars = array_merge(
159 159
 				$vars,
160 160
 				array(
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 		}
166 166
 
167 167
 		// Check if "orderby" is set to "earnings"
168
-		if ( isset( $vars['orderby'] ) && 'earnings' == $vars['orderby'] ) {
168
+		if (isset($vars['orderby']) && 'earnings' == $vars['orderby']) {
169 169
 			$vars = array_merge(
170 170
 				$vars,
171 171
 				array(
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		}
177 177
 
178 178
 		// Check if "orderby" is set to "price"
179
-		if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) {
179
+		if (isset($vars['orderby']) && 'price' == $vars['orderby']) {
180 180
 			$vars = array_merge(
181 181
 				$vars,
182 182
 				array(
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 		}
188 188
 
189 189
 		// Check if "orderby" is set to "goal"
190
-		if ( isset( $vars['orderby'] ) && 'goal' == $vars['orderby'] ) {
190
+		if (isset($vars['orderby']) && 'goal' == $vars['orderby']) {
191 191
 			$vars = array_merge(
192 192
 				$vars,
193 193
 				array(
@@ -210,16 +210,16 @@  discard block
 block discarded – undo
210 210
  *
211 211
  * @return array       Array of all sort variables
212 212
  */
213
-function give_filter_forms( $vars ) {
214
-	if ( isset( $vars['post_type'] ) && 'give_forms' == $vars['post_type'] ) {
213
+function give_filter_forms($vars) {
214
+	if (isset($vars['post_type']) && 'give_forms' == $vars['post_type']) {
215 215
 
216 216
 		// If an author ID was passed, use it
217
-		if ( isset( $_REQUEST['author'] ) && ! current_user_can( 'view_give_reports' ) ) {
217
+		if (isset($_REQUEST['author']) && ! current_user_can('view_give_reports')) {
218 218
 
219 219
 			$author_id = $_REQUEST['author'];
220
-			if ( (int) $author_id !== get_current_user_id() ) {
220
+			if ((int) $author_id !== get_current_user_id()) {
221 221
 				// Tried to view the products of another person, sorry
222
-				wp_die( esc_html__( 'You do not have permission to view this data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
222
+				wp_die(esc_html__('You do not have permission to view this data.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
223 223
 			}
224 224
 			$vars = array_merge(
225 225
 				$vars,
@@ -244,11 +244,11 @@  discard block
 block discarded – undo
244 244
  * @return void
245 245
  */
246 246
 function give_forms_load() {
247
-	add_filter( 'request', 'give_sort_forms' );
248
-	add_filter( 'request', 'give_filter_forms' );
247
+	add_filter('request', 'give_sort_forms');
248
+	add_filter('request', 'give_filter_forms');
249 249
 }
250 250
 
251
-add_action( 'load-edit.php', 'give_forms_load', 9999 );
251
+add_action('load-edit.php', 'give_forms_load', 9999);
252 252
 
253 253
 /**
254 254
  * Remove Forms Month Filter
@@ -262,17 +262,17 @@  discard block
 block discarded – undo
262 262
  * @global      $typenow The post type we are viewing
263 263
  * @return array Empty array disables the dropdown
264 264
  */
265
-function give_remove_month_filter( $dates ) {
265
+function give_remove_month_filter($dates) {
266 266
 	global $typenow;
267 267
 
268
-	if ( $typenow == 'give_forms' ) {
268
+	if ($typenow == 'give_forms') {
269 269
 		$dates = array();
270 270
 	}
271 271
 
272 272
 	return $dates;
273 273
 }
274 274
 
275
-add_filter( 'months_dropdown_results', 'give_remove_month_filter', 99 );
275
+add_filter('months_dropdown_results', 'give_remove_month_filter', 99);
276 276
 
277 277
 /**
278 278
  * Adds price field to Quick Edit options
@@ -284,16 +284,16 @@  discard block
 block discarded – undo
284 284
  *
285 285
  * @return void
286 286
  */
287
-function give_price_field_quick_edit( $column_name, $post_type ) {
288
-	if ( $column_name != 'price' || $post_type != 'give_forms' ) {
287
+function give_price_field_quick_edit($column_name, $post_type) {
288
+	if ($column_name != 'price' || $post_type != 'give_forms') {
289 289
 		return;
290 290
 	}
291 291
 	?>
292 292
 	<fieldset class="inline-edit-col-left">
293 293
 		<div id="give-give-data" class="inline-edit-col">
294
-			<h4><?php esc_html_e( 'Form Configuration', 'give' ); ?></h4>
294
+			<h4><?php esc_html_e('Form Configuration', 'give'); ?></h4>
295 295
 			<label for="give_regprice">
296
-				<span class="title"><?php esc_html_e( 'Price', 'give' ); ?></span>
296
+				<span class="title"><?php esc_html_e('Price', 'give'); ?></span>
297 297
 				<span class="input-text-wrap">
298 298
 					<input type="text" name="give_regprice" id="give_regprice" class="text regprice" />
299 299
 				</span>
@@ -304,8 +304,8 @@  discard block
 block discarded – undo
304 304
 	<?php
305 305
 }
306 306
 
307
-add_action( 'quick_edit_custom_box', 'give_price_field_quick_edit', 10, 2 );
308
-add_action( 'bulk_edit_custom_box', 'give_price_field_quick_edit', 10, 2 );
307
+add_action('quick_edit_custom_box', 'give_price_field_quick_edit', 10, 2);
308
+add_action('bulk_edit_custom_box', 'give_price_field_quick_edit', 10, 2);
309 309
 
310 310
 /**
311 311
  * Updates price when saving post
@@ -316,23 +316,23 @@  discard block
 block discarded – undo
316 316
  *
317 317
  * @return void
318 318
  */
319
-function give_price_save_quick_edit( $post_id ) {
320
-	if ( ! isset( $_POST['post_type'] ) || 'give_forms' !== $_POST['post_type'] ) {
319
+function give_price_save_quick_edit($post_id) {
320
+	if ( ! isset($_POST['post_type']) || 'give_forms' !== $_POST['post_type']) {
321 321
 		return;
322 322
 	}
323
-	if ( ! current_user_can( 'edit_post', $post_id ) ) {
323
+	if ( ! current_user_can('edit_post', $post_id)) {
324 324
 		return $post_id;
325 325
 	}
326
-	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
326
+	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
327 327
 		return $post_id;
328 328
 	}
329 329
 
330
-	if ( isset( $_REQUEST['_give_regprice'] ) ) {
331
-		update_post_meta( $post_id, '_give_set_price', strip_tags( stripslashes( $_REQUEST['_give_regprice'] ) ) );
330
+	if (isset($_REQUEST['_give_regprice'])) {
331
+		update_post_meta($post_id, '_give_set_price', strip_tags(stripslashes($_REQUEST['_give_regprice'])));
332 332
 	}
333 333
 }
334 334
 
335
-add_action( 'save_post', 'give_price_save_quick_edit' );
335
+add_action('save_post', 'give_price_save_quick_edit');
336 336
 
337 337
 /**
338 338
  * Process bulk edit actions via AJAX
@@ -342,18 +342,18 @@  discard block
 block discarded – undo
342 342
  */
343 343
 function give_save_bulk_edit() {
344 344
 
345
-	$post_ids = ( isset( $_POST['post_ids'] ) && ! empty( $_POST['post_ids'] ) ) ? $_POST['post_ids'] : array();
345
+	$post_ids = (isset($_POST['post_ids']) && ! empty($_POST['post_ids'])) ? $_POST['post_ids'] : array();
346 346
 
347
-	if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
348
-		$price = isset( $_POST['price'] ) ? strip_tags( stripslashes( $_POST['price'] ) ) : 0;
349
-		foreach ( $post_ids as $post_id ) {
347
+	if ( ! empty($post_ids) && is_array($post_ids)) {
348
+		$price = isset($_POST['price']) ? strip_tags(stripslashes($_POST['price'])) : 0;
349
+		foreach ($post_ids as $post_id) {
350 350
 
351
-			if ( ! current_user_can( 'edit_post', $post_id ) ) {
351
+			if ( ! current_user_can('edit_post', $post_id)) {
352 352
 				continue;
353 353
 			}
354 354
 
355
-			if ( ! empty( $price ) ) {
356
-				update_post_meta( $post_id, '_give_set_price', give_sanitize_amount( $price ) );
355
+			if ( ! empty($price)) {
356
+				update_post_meta($post_id, '_give_set_price', give_sanitize_amount($price));
357 357
 			}
358 358
 		}
359 359
 	}
@@ -361,4 +361,4 @@  discard block
 block discarded – undo
361 361
 	die();
362 362
 }
363 363
 
364
-add_action( 'wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit' );
364
+add_action('wp_ajax_give_save_bulk_edit', 'give_save_bulk_edit');
Please login to merge, or discard this patch.
includes/admin/plugins.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,19 +23,19 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return array An array of updated action links.
25 25
  */
26
-function give_plugin_action_links( $actions ) {
26
+function give_plugin_action_links($actions) {
27 27
 	$new_actions = array(
28 28
 		'settings' => sprintf(
29 29
 			'<a href="%1$s">%2$s</a>',
30
-			admin_url( 'edit.php?post_type=give_forms&page=give-settings' ),
31
-			esc_html__( 'Settings', 'give' )
30
+			admin_url('edit.php?post_type=give_forms&page=give-settings'),
31
+			esc_html__('Settings', 'give')
32 32
 		),
33 33
 	);
34 34
 
35
-	return array_merge( $new_actions, $actions );
35
+	return array_merge($new_actions, $actions);
36 36
 }
37 37
 
38
-add_filter( 'plugin_action_links_' . GIVE_PLUGIN_BASENAME, 'give_plugin_action_links' );
38
+add_filter('plugin_action_links_'.GIVE_PLUGIN_BASENAME, 'give_plugin_action_links');
39 39
 
40 40
 
41 41
 /**
@@ -48,35 +48,35 @@  discard block
 block discarded – undo
48 48
  *
49 49
  * @return array
50 50
  */
51
-function give_plugin_row_meta( $plugin_meta, $plugin_file ) {
52
-	if ( $plugin_file != GIVE_PLUGIN_BASENAME ) {
51
+function give_plugin_row_meta($plugin_meta, $plugin_file) {
52
+	if ($plugin_file != GIVE_PLUGIN_BASENAME) {
53 53
 		return $plugin_meta;
54 54
 	}
55 55
 
56 56
 	$new_meta_links = array(
57 57
 		sprintf(
58 58
 			'<a href="%1$s" target="_blank">%2$s</a>',
59
-			esc_url( add_query_arg( array(
59
+			esc_url(add_query_arg(array(
60 60
 					'utm_source'   => 'plugins-page',
61 61
 					'utm_medium'   => 'plugin-row',
62 62
 					'utm_campaign' => 'admin',
63
-				), 'https://givewp.com/documentation/' )
63
+				), 'https://givewp.com/documentation/')
64 64
 			),
65
-			esc_html__( 'Documentation', 'give' )
65
+			esc_html__('Documentation', 'give')
66 66
 		),
67 67
 		sprintf(
68 68
 			'<a href="%1$s" target="_blank">%2$s</a>',
69
-			esc_url( add_query_arg( array(
69
+			esc_url(add_query_arg(array(
70 70
 					'utm_source'   => 'plugins-page',
71 71
 					'utm_medium'   => 'plugin-row',
72 72
 					'utm_campaign' => 'admin',
73
-				), 'https://givewp.com/addons/' )
73
+				), 'https://givewp.com/addons/')
74 74
 			),
75
-			esc_html__( 'Add-ons', 'give' )
75
+			esc_html__('Add-ons', 'give')
76 76
 		),
77 77
 	);
78 78
 
79
-	return array_merge( $plugin_meta, $new_meta_links );
79
+	return array_merge($plugin_meta, $new_meta_links);
80 80
 }
81 81
 
82
-add_filter( 'plugin_row_meta', 'give_plugin_row_meta', 10, 2 );
82
+add_filter('plugin_row_meta', 'give_plugin_row_meta', 10, 2);
Please login to merge, or discard this patch.
includes/install.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,15 +23,15 @@  discard block
 block discarded – undo
23 23
  * @global $wpdb
24 24
  * @return void
25 25
  */
26
-function give_install( $network_wide = false ) {
26
+function give_install($network_wide = false) {
27 27
 
28 28
 	global $wpdb;
29 29
 
30
-	if ( is_multisite() && $network_wide ) {
30
+	if (is_multisite() && $network_wide) {
31 31
 
32
-		foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) {
32
+		foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) {
33 33
 
34
-			switch_to_blog( $blog_id );
34
+			switch_to_blog($blog_id);
35 35
 			give_run_install();
36 36
 			restore_current_blog();
37 37
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 
46 46
 }
47 47
 
48
-register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' );
48
+register_activation_hook(GIVE_PLUGIN_FILE, 'give_install');
49 49
 
50 50
 /**
51 51
  * Run the Give Install process.
@@ -61,24 +61,24 @@  discard block
 block discarded – undo
61 61
 	give_setup_post_types();
62 62
 
63 63
 	// Clear the permalinks.
64
-	flush_rewrite_rules( false );
64
+	flush_rewrite_rules(false);
65 65
 
66 66
 	// Add Upgraded From Option.
67
-	$current_version = get_option( 'give_version' );
68
-	if ( $current_version ) {
69
-		update_option( 'give_version_upgraded_from', $current_version );
67
+	$current_version = get_option('give_version');
68
+	if ($current_version) {
69
+		update_option('give_version_upgraded_from', $current_version);
70 70
 	}
71 71
 
72 72
 	// Setup some default options.
73 73
 	$options = array();
74 74
 
75 75
 	// Checks if the Success Page option exists AND that the page exists.
76
-	if ( ! get_post( give_get_option( 'success_page' ) ) ) {
76
+	if ( ! get_post(give_get_option('success_page'))) {
77 77
 
78 78
 		// Donation Confirmation (Success) Page
79 79
 		$success = wp_insert_post(
80 80
 			array(
81
-				'post_title'     => esc_html__( 'Donation Confirmation', 'give' ),
81
+				'post_title'     => esc_html__('Donation Confirmation', 'give'),
82 82
 				'post_content'   => '[give_receipt]',
83 83
 				'post_status'    => 'publish',
84 84
 				'post_author'    => 1,
@@ -92,13 +92,13 @@  discard block
 block discarded – undo
92 92
 	}
93 93
 
94 94
 	// Checks if the Failure Page option exists AND that the page exists.
95
-	if ( ! get_post( give_get_option( 'failure_page' ) ) ) {
95
+	if ( ! get_post(give_get_option('failure_page'))) {
96 96
 
97 97
 		// Failed Donation Page
98 98
 		$failed = wp_insert_post(
99 99
 			array(
100
-				'post_title'     => esc_html__( 'Donation Failed', 'give' ),
101
-				'post_content'   => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ),
100
+				'post_title'     => esc_html__('Donation Failed', 'give'),
101
+				'post_content'   => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'),
102 102
 				'post_status'    => 'publish',
103 103
 				'post_author'    => 1,
104 104
 				'post_type'      => 'page',
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
 	}
111 111
 
112 112
 	// Checks if the History Page option exists AND that the page exists.
113
-	if ( ! get_post( give_get_option( 'history_page' ) ) ) {
113
+	if ( ! get_post(give_get_option('history_page'))) {
114 114
 		// Donation History Page
115 115
 		$history = wp_insert_post(
116 116
 			array(
117
-				'post_title'     => esc_html__( 'Donation History', 'give' ),
117
+				'post_title'     => esc_html__('Donation History', 'give'),
118 118
 				'post_content'   => '[donation_history]',
119 119
 				'post_status'    => 'publish',
120 120
 				'post_author'    => 1,
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	}
128 128
 
129 129
 	//Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency.
130
-	if ( empty( $current_version ) ) {
130
+	if (empty($current_version)) {
131 131
 		$options['base_country']       = 'US';
132 132
 		$options['test_mode']          = 1;
133 133
 		$options['currency']           = 'USD';
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
 	}
152 152
 
153 153
 	// Populate the default values.
154
-	update_option( 'give_settings', array_merge( $give_options, $options ) );
155
-	update_option( 'give_version', GIVE_VERSION );
154
+	update_option('give_settings', array_merge($give_options, $options));
155
+	update_option('give_version', GIVE_VERSION);
156 156
 
157 157
 	// Create Give roles.
158 158
 	$roles = new Give_Roles();
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	$roles->add_caps();
161 161
 
162 162
 	$api = new Give_API();
163
-	update_option( 'give_default_api_version', 'v' . $api->get_version() );
163
+	update_option('give_default_api_version', 'v'.$api->get_version());
164 164
 
165 165
 	// Create the customers databases.
166 166
 	@Give()->customers->create_table();
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
 	Give()->session->use_php_sessions();
171 171
 
172 172
 	// Add a temporary option to note that Give pages have been created.
173
-	set_transient( '_give_installed', $options, 30 );
173
+	set_transient('_give_installed', $options, 30);
174 174
 
175
-	if ( ! $current_version ) {
175
+	if ( ! $current_version) {
176 176
 
177
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
177
+		require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
178 178
 
179 179
 		// When new upgrade routines are added, mark them as complete on fresh install.
180 180
 		$upgrade_routines = array(
@@ -183,22 +183,22 @@  discard block
 block discarded – undo
183 183
 			'upgrade_give_offline_status'
184 184
 		);
185 185
 
186
-		foreach ( $upgrade_routines as $upgrade ) {
187
-			give_set_upgrade_complete( $upgrade );
186
+		foreach ($upgrade_routines as $upgrade) {
187
+			give_set_upgrade_complete($upgrade);
188 188
 		}
189 189
 	}
190 190
 
191 191
 	// Bail if activating from network, or bulk.
192
-	if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
192
+	if (is_network_admin() || isset($_GET['activate-multi'])) {
193 193
 		return;
194 194
 	}
195 195
 
196 196
 	// Add the transient to redirect.
197
-	set_transient( '_give_activation_redirect', true, 30 );
197
+	set_transient('_give_activation_redirect', true, 30);
198 198
 
199 199
 }
200 200
 
201
-register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' );
201
+register_activation_hook(GIVE_PLUGIN_FILE, 'give_install');
202 202
 
203 203
 /**
204 204
  * Network Activated New Site Setup.
@@ -214,11 +214,11 @@  discard block
 block discarded – undo
214 214
  * @param  int    $site_id The Site ID.
215 215
  * @param  array  $meta Blog Meta.
216 216
  */
217
-function on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
217
+function on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) {
218 218
 
219
-	if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) {
219
+	if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) {
220 220
 
221
-		switch_to_blog( $blog_id );
221
+		switch_to_blog($blog_id);
222 222
 		give_install();
223 223
 		restore_current_blog();
224 224
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 
227 227
 }
228 228
 
229
-add_action( 'wpmu_new_blog', 'on_create_blog', 10, 6 );
229
+add_action('wpmu_new_blog', 'on_create_blog', 10, 6);
230 230
 
231 231
 
232 232
 /**
@@ -239,13 +239,13 @@  discard block
 block discarded – undo
239 239
  *
240 240
  * @return array          The tables to drop.
241 241
  */
242
-function give_wpmu_drop_tables( $tables, $blog_id ) {
242
+function give_wpmu_drop_tables($tables, $blog_id) {
243 243
 
244
-	switch_to_blog( $blog_id );
244
+	switch_to_blog($blog_id);
245 245
 	$customers_db     = new Give_DB_Customers();
246 246
 	$customer_meta_db = new Give_DB_Customer_Meta();
247 247
 
248
-	if ( $customers_db->installed() ) {
248
+	if ($customers_db->installed()) {
249 249
 		$tables[] = $customers_db->table_name;
250 250
 		$tables[] = $customer_meta_db->table_name;
251 251
 	}
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 
256 256
 }
257 257
 
258
-add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 );
258
+add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2);
259 259
 
260 260
 /**
261 261
  * Post-installation
@@ -267,16 +267,16 @@  discard block
 block discarded – undo
267 267
  */
268 268
 function give_after_install() {
269 269
 
270
-	if ( ! is_admin() ) {
270
+	if ( ! is_admin()) {
271 271
 		return;
272 272
 	}
273 273
 
274
-	$give_options     = get_transient( '_give_installed' );
275
-	$give_table_check = get_option( '_give_table_check', false );
274
+	$give_options     = get_transient('_give_installed');
275
+	$give_table_check = get_option('_give_table_check', false);
276 276
 
277
-	if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) {
277
+	if (false === $give_table_check || current_time('timestamp') > $give_table_check) {
278 278
 
279
-		if ( ! @Give()->customer_meta->installed() ) {
279
+		if ( ! @Give()->customer_meta->installed()) {
280 280
 
281 281
 			// Create the customer meta database
282 282
 			// (this ensures it creates it on multisite instances where it is network activated).
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 
285 285
 		}
286 286
 
287
-		if ( ! @Give()->customers->installed() ) {
287
+		if ( ! @Give()->customers->installed()) {
288 288
 			// Create the customers database
289 289
 			// (this ensures it creates it on multisite instances where it is network activated).
290 290
 			@Give()->customers->create_table();
@@ -296,22 +296,22 @@  discard block
 block discarded – undo
296 296
 			 *
297 297
 			 * @param array $give_options Give plugin options.
298 298
 			 */
299
-			do_action( 'give_after_install', $give_options );
299
+			do_action('give_after_install', $give_options);
300 300
 		}
301 301
 
302
-		update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) );
302
+		update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS));
303 303
 
304 304
 	}
305 305
 
306 306
 	// Delete the transient
307
-	if ( false !== $give_options ) {
308
-		delete_transient( '_give_installed' );
307
+	if (false !== $give_options) {
308
+		delete_transient('_give_installed');
309 309
 	}
310 310
 
311 311
 
312 312
 }
313 313
 
314
-add_action( 'admin_init', 'give_after_install' );
314
+add_action('admin_init', 'give_after_install');
315 315
 
316 316
 
317 317
 /**
@@ -326,11 +326,11 @@  discard block
 block discarded – undo
326 326
 
327 327
 	global $wp_roles;
328 328
 
329
-	if ( ! is_object( $wp_roles ) ) {
329
+	if ( ! is_object($wp_roles)) {
330 330
 		return;
331 331
 	}
332 332
 
333
-	if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) {
333
+	if ( ! array_key_exists('give_manager', $wp_roles->roles)) {
334 334
 
335 335
 		// Create Give plugin roles
336 336
 		$roles = new Give_Roles();
@@ -341,4 +341,4 @@  discard block
 block discarded – undo
341 341
 
342 342
 }
343 343
 
344
-add_action( 'admin_init', 'give_install_roles_on_network' );
345 344
\ No newline at end of file
345
+add_action('admin_init', 'give_install_roles_on_network');
346 346
\ No newline at end of file
Please login to merge, or discard this patch.
includes/emails/template.php 1 patch
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
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
 
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
  *
42 42
  * @return string $message Fully formatted message
43 43
  */
44
-function give_email_template_tags( $message, $payment_data, $payment_id, $admin_notice = false ) {
45
-	return give_do_email_tags( $message, $payment_id );
44
+function give_email_template_tags($message, $payment_data, $payment_id, $admin_notice = false) {
45
+	return give_do_email_tags($message, $payment_id);
46 46
 }
47 47
 
48 48
 /**
@@ -56,40 +56,40 @@  discard block
 block discarded – undo
56 56
  *
57 57
  * @return string $message Fully formatted message
58 58
  */
59
-function give_email_preview_template_tags( $message ) {
59
+function give_email_preview_template_tags($message) {
60 60
 
61
-	$price = give_currency_filter( give_format_amount( 10.50 ) );
61
+	$price = give_currency_filter(give_format_amount(10.50));
62 62
 
63 63
 	$gateway = 'PayPal';
64 64
 
65
-	$receipt_id = strtolower( md5( uniqid() ) );
65
+	$receipt_id = strtolower(md5(uniqid()));
66 66
 
67
-	$payment_id = rand( 1, 100 );
67
+	$payment_id = rand(1, 100);
68 68
 
69
-	$receipt_link_url = esc_url( add_query_arg( array( 'payment_key' => $receipt_id, 'give_action' => 'view_receipt' ), home_url() ) );
69
+	$receipt_link_url = esc_url(add_query_arg(array('payment_key' => $receipt_id, 'give_action' => 'view_receipt'), home_url()));
70 70
 	$receipt_link = sprintf(
71 71
 		'<a href="%1$s">%2$s</a>',
72 72
 		$receipt_link_url,
73
-		esc_html__( 'View the receipt in your browser &raquo;', 'give' )
73
+		esc_html__('View the receipt in your browser &raquo;', 'give')
74 74
 	);
75 75
 
76 76
 	$user = wp_get_current_user();
77 77
 
78
-	$message = str_replace( '{name}', $user->display_name, $message );
79
-	$message = str_replace( '{fullname}', $user->display_name, $message );
80
-	$message = str_replace( '{username}', $user->user_login, $message );
81
-	$message = str_replace( '{date}', date( give_date_format(), current_time( 'timestamp' ) ), $message );
82
-	$message = str_replace( '{price}', $price, $message );
83
-	$message = str_replace( '{donation}', esc_html__( 'Sample Donation Form Title', 'give' ), $message );
84
-	$message = str_replace( '{receipt_id}', $receipt_id, $message );
85
-	$message = str_replace( '{payment_method}', $gateway, $message );
86
-	$message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message );
87
-	$message = str_replace( '{payment_id}', $payment_id, $message );
88
-	$message = str_replace( '{receipt_link}', $receipt_link, $message );
89
-	$message = str_replace( '{receipt_link_url}', $receipt_link_url, $message );
90
-	$message = str_replace( '{pdf_receipt}', '<a href="#">Download Receipt</a>', $message );
91
-
92
-	return wpautop( apply_filters( 'give_email_preview_template_tags', $message ) );
78
+	$message = str_replace('{name}', $user->display_name, $message);
79
+	$message = str_replace('{fullname}', $user->display_name, $message);
80
+	$message = str_replace('{username}', $user->user_login, $message);
81
+	$message = str_replace('{date}', date(give_date_format(), current_time('timestamp')), $message);
82
+	$message = str_replace('{price}', $price, $message);
83
+	$message = str_replace('{donation}', esc_html__('Sample Donation Form Title', 'give'), $message);
84
+	$message = str_replace('{receipt_id}', $receipt_id, $message);
85
+	$message = str_replace('{payment_method}', $gateway, $message);
86
+	$message = str_replace('{sitename}', get_bloginfo('name'), $message);
87
+	$message = str_replace('{payment_id}', $payment_id, $message);
88
+	$message = str_replace('{receipt_link}', $receipt_link, $message);
89
+	$message = str_replace('{receipt_link_url}', $receipt_link_url, $message);
90
+	$message = str_replace('{pdf_receipt}', '<a href="#">Download Receipt</a>', $message);
91
+
92
+	return wpautop(apply_filters('give_email_preview_template_tags', $message));
93 93
 }
94 94
 
95 95
 /**
@@ -101,23 +101,23 @@  discard block
 block discarded – undo
101 101
  * @since  1.0
102 102
  * @return array|bool
103 103
  */
104
-function give_email_template_preview( $array ) {
104
+function give_email_template_preview($array) {
105 105
 
106
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
106
+	if ( ! current_user_can('manage_give_settings')) {
107 107
 		return false;
108 108
 	}
109 109
 	$custom_field = array(
110
-		'name' => esc_html__( 'Preview Email', 'give' ),
111
-		'desc' => esc_html__( 'Click the buttons to preview emails.', 'give' ),
110
+		'name' => esc_html__('Preview Email', 'give'),
111
+		'desc' => esc_html__('Click the buttons to preview emails.', 'give'),
112 112
 		'id'   => 'give_email_preview_buttons',
113 113
 		'type' => 'email_preview_buttons'
114 114
 	);
115 115
 
116
-	return give_settings_array_insert( $array, 'donation_subject', array( $custom_field ) );
116
+	return give_settings_array_insert($array, 'donation_subject', array($custom_field));
117 117
 
118 118
 }
119 119
 
120
-add_filter( 'give_settings_emails', 'give_email_template_preview' );
120
+add_filter('give_settings_emails', 'give_email_template_preview');
121 121
 
122 122
 /**
123 123
  * Output Email Template Preview Buttons.
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
 function give_email_preview_buttons_callback() {
130 130
 	ob_start();
131 131
 	?>
132
-	<a href="<?php echo esc_url( add_query_arg( array( 'give_action' => 'preview_email' ), home_url() ) ); ?>" class="button-secondary" target="_blank"><?php esc_html_e( 'Preview Donation Receipt', 'give' ); ?></a>
133
-	<a href="<?php echo wp_nonce_url( add_query_arg( array(
132
+	<a href="<?php echo esc_url(add_query_arg(array('give_action' => 'preview_email'), home_url())); ?>" class="button-secondary" target="_blank"><?php esc_html_e('Preview Donation Receipt', 'give'); ?></a>
133
+	<a href="<?php echo wp_nonce_url(add_query_arg(array(
134 134
 		'give_action'  => 'send_test_email',
135 135
 		'give-message' => 'sent-test-email',
136 136
 		'tag'          => 'emails'
137
-	) ), 'give-test-email' ); ?>" aria-label="<?php esc_attr_e( 'Send demo donation receipt to the emails listed below.', 'give' ); ?>" class="button-secondary"><?php esc_html_e( 'Send Test Email', 'give' ); ?></a>
137
+	)), 'give-test-email'); ?>" aria-label="<?php esc_attr_e('Send demo donation receipt to the emails listed below.', 'give'); ?>" class="button-secondary"><?php esc_html_e('Send Test Email', 'give'); ?></a>
138 138
 	<?php
139 139
 	echo ob_get_clean();
140 140
 }
@@ -147,46 +147,46 @@  discard block
 block discarded – undo
147 147
  */
148 148
 function give_display_email_template_preview() {
149 149
 
150
-	if ( empty( $_GET['give_action'] ) ) {
150
+	if (empty($_GET['give_action'])) {
151 151
 		return;
152 152
 	}
153 153
 
154
-	if ( 'preview_email' !== $_GET['give_action'] ) {
154
+	if ('preview_email' !== $_GET['give_action']) {
155 155
 		return;
156 156
 	}
157 157
 
158
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
158
+	if ( ! current_user_can('manage_give_settings')) {
159 159
 		return;
160 160
 	}
161 161
 
162 162
 
163
-	Give()->emails->heading = esc_html__( 'Donation Receipt', 'give' );
163
+	Give()->emails->heading = esc_html__('Donation Receipt', 'give');
164 164
 
165
-	$payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : '';
165
+	$payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : '';
166 166
 
167 167
 	echo give_get_preview_email_header();
168 168
 
169 169
 	//Are we previewing an actual payment?
170
-	if ( ! empty( $payment_id ) ) {
170
+	if ( ! empty($payment_id)) {
171 171
 
172
-		$content = give_get_email_body_content( $payment_id );
172
+		$content = give_get_email_body_content($payment_id);
173 173
 
174
-		$preview_content = give_do_email_tags( $content, $payment_id );
174
+		$preview_content = give_do_email_tags($content, $payment_id);
175 175
 
176 176
 	} else {
177 177
 
178 178
 		//No payment ID, use sample preview content
179
-		$preview_content = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) );
179
+		$preview_content = give_email_preview_template_tags(give_get_email_body_content(0, array()));
180 180
 	}
181 181
 
182 182
 
183
-	echo Give()->emails->build_email( $preview_content );
183
+	echo Give()->emails->build_email($preview_content);
184 184
 
185 185
 	exit;
186 186
 
187 187
 }
188 188
 
189
-add_action( 'init', 'give_display_email_template_preview' );
189
+add_action('init', 'give_display_email_template_preview');
190 190
 
191 191
 /**
192 192
  * Email Template Body.
@@ -198,18 +198,18 @@  discard block
 block discarded – undo
198 198
  *
199 199
  * @return string $email_body Body of the email
200 200
  */
201
-function give_get_email_body_content( $payment_id = 0, $payment_data = array() ) {
201
+function give_get_email_body_content($payment_id = 0, $payment_data = array()) {
202 202
 
203 203
 	$default_email_body = give_get_default_donation_receipt_email();
204 204
 
205
-	$email_content = give_get_option( 'donation_receipt' );
206
-	$email_content = isset( $email_content ) ? stripslashes( $email_content ) : $default_email_body;
205
+	$email_content = give_get_option('donation_receipt');
206
+	$email_content = isset($email_content) ? stripslashes($email_content) : $default_email_body;
207 207
 
208
-	$email_body = wpautop( $email_content );
208
+	$email_body = wpautop($email_content);
209 209
 
210
-	$email_body = apply_filters( "give_donation_receipt_{Give()->emails->get_template()}", $email_body, $payment_id, $payment_data );
210
+	$email_body = apply_filters("give_donation_receipt_{Give()->emails->get_template()}", $email_body, $payment_id, $payment_data);
211 211
 
212
-	return apply_filters( 'give_donation_receipt', $email_body, $payment_id, $payment_data );
212
+	return apply_filters('give_donation_receipt', $email_body, $payment_id, $payment_data);
213 213
 }
214 214
 
215 215
 /**
@@ -222,36 +222,36 @@  discard block
 block discarded – undo
222 222
  *
223 223
  * @return string $email_body Body of the email
224 224
  */
225
-function give_get_donation_notification_body_content( $payment_id = 0, $payment_data = array() ) {
225
+function give_get_donation_notification_body_content($payment_id = 0, $payment_data = array()) {
226 226
 
227
-	$user_info = maybe_unserialize( $payment_data['user_info'] );
228
-	$email     = give_get_payment_user_email( $payment_id );
227
+	$user_info = maybe_unserialize($payment_data['user_info']);
228
+	$email     = give_get_payment_user_email($payment_id);
229 229
 
230
-	if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) {
231
-		$user_data = get_userdata( $user_info['id'] );
230
+	if (isset($user_info['id']) && $user_info['id'] > 0) {
231
+		$user_data = get_userdata($user_info['id']);
232 232
 		$name      = $user_data->display_name;
233
-	} elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) {
234
-		$name = $user_info['first_name'] . ' ' . $user_info['last_name'];
233
+	} elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) {
234
+		$name = $user_info['first_name'].' '.$user_info['last_name'];
235 235
 	} else {
236 236
 		$name = $email;
237 237
 	}
238 238
 
239
-	$gateway = give_get_gateway_admin_label( get_post_meta( $payment_id, '_give_payment_gateway', true ) );
239
+	$gateway = give_get_gateway_admin_label(get_post_meta($payment_id, '_give_payment_gateway', true));
240 240
 
241
-	$default_email_body = esc_html__( 'Hello', 'give' ) . "\n\n";
242
-	$default_email_body .= esc_html__( 'A donation has been made.', 'give' ) . "\n\n";
243
-	$default_email_body .= esc_html__( 'Forms sold:', 'give' ) . "\n\n";
244
-	$default_email_body .= esc_html__( 'Donor:', 'give' ) . ' ' . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n";
245
-	$default_email_body .= esc_html__( 'Amount:', 'give' ) . ' ' . html_entity_decode( give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ), ENT_COMPAT, 'UTF-8' ) . "\n";
246
-	$default_email_body .= esc_html__( 'Payment Method:', 'give' ) . ' ' . $gateway . "\n\n";
247
-	$default_email_body .= esc_html__( 'Thank you', 'give' );
241
+	$default_email_body = esc_html__('Hello', 'give')."\n\n";
242
+	$default_email_body .= esc_html__('A donation has been made.', 'give')."\n\n";
243
+	$default_email_body .= esc_html__('Forms sold:', 'give')."\n\n";
244
+	$default_email_body .= esc_html__('Donor:', 'give').' '.html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n";
245
+	$default_email_body .= esc_html__('Amount:', 'give').' '.html_entity_decode(give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))), ENT_COMPAT, 'UTF-8')."\n";
246
+	$default_email_body .= esc_html__('Payment Method:', 'give').' '.$gateway."\n\n";
247
+	$default_email_body .= esc_html__('Thank you', 'give');
248 248
 
249
-	$email = give_get_option( 'donation_notification' );
250
-	$email = isset( $email ) ? stripslashes( $email ) : $default_email_body;
249
+	$email = give_get_option('donation_notification');
250
+	$email = isset($email) ? stripslashes($email) : $default_email_body;
251 251
 
252
-	$email_body = give_do_email_tags( $email, $payment_id );
252
+	$email_body = give_do_email_tags($email, $payment_id);
253 253
 
254
-	return apply_filters( 'give_donation_notification', wpautop( $email_body ), $payment_id, $payment_data );
254
+	return apply_filters('give_donation_notification', wpautop($email_body), $payment_id, $payment_data);
255 255
 }
256 256
 
257 257
 /**
@@ -264,19 +264,19 @@  discard block
 block discarded – undo
264 264
  * @since  1.0
265 265
  */
266 266
 function give_render_receipt_in_browser() {
267
-	if ( ! isset( $_GET['payment_key'] ) ) {
268
-		wp_die( esc_html__( 'Missing donation payment key.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
267
+	if ( ! isset($_GET['payment_key'])) {
268
+		wp_die(esc_html__('Missing donation payment key.', 'give'), esc_html__('Error', 'give'), array('response' => 400));
269 269
 	}
270 270
 
271
-	$key = urlencode( $_GET['payment_key'] );
271
+	$key = urlencode($_GET['payment_key']);
272 272
 
273 273
 	ob_start();
274 274
 	//Disallows caching of the page
275
-	header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" );
276
-	header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1
277
-	header( "Cache-Control: post-check=0, pre-check=0", false );
278
-	header( "Pragma: no-cache" ); // HTTP/1.0
279
-	header( "Expires: Sat, 23 Oct 1977 05:00:00 PST" ); // Date in the past
275
+	header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
276
+	header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
277
+	header("Cache-Control: post-check=0, pre-check=0", false);
278
+	header("Pragma: no-cache"); // HTTP/1.0
279
+	header("Expires: Sat, 23 Oct 1977 05:00:00 PST"); // Date in the past
280 280
 	?>
281 281
 	<!DOCTYPE html>
282 282
 	<html lang="en">
@@ -287,10 +287,10 @@  discard block
 block discarded – undo
287 287
 		 *
288 288
 		 * @since 1.0
289 289
 		 */
290
-		do_action( 'give_receipt_head' );
290
+		do_action('give_receipt_head');
291 291
 		?>
292 292
 	</head>
293
-	<body class="<?php echo apply_filters( 'give_receipt_page_body_class', 'give_receipt_page' ); ?>">
293
+	<body class="<?php echo apply_filters('give_receipt_page_body_class', 'give_receipt_page'); ?>">
294 294
 
295 295
 	<div id="give_receipt_wrapper">
296 296
 		<?php
@@ -299,16 +299,16 @@  discard block
 block discarded – undo
299 299
 		 *
300 300
 		 * @since 1.0
301 301
 		 */
302
-		do_action( 'give_render_receipt_in_browser_before' );
302
+		do_action('give_render_receipt_in_browser_before');
303 303
 
304
-		echo do_shortcode( '[give_receipt payment_key=' . $key . ']' );
304
+		echo do_shortcode('[give_receipt payment_key='.$key.']');
305 305
 
306 306
 		/**
307 307
 		 * Fires in the receipt template after the content.
308 308
 		 *
309 309
 		 * @since 1.0
310 310
 		 */
311
-		do_action( 'give_render_receipt_in_browser_after' );
311
+		do_action('give_render_receipt_in_browser_after');
312 312
 		?>
313 313
 	</div>
314 314
 
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 	 *
319 319
 	 * @since 1.0
320 320
 	 */
321
-	do_action( 'give_receipt_footer' );
321
+	do_action('give_receipt_footer');
322 322
 	?>
323 323
 	</body>
324 324
 	</html>
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 	die();
328 328
 }
329 329
 
330
-add_action( 'give_view_receipt', 'give_render_receipt_in_browser' );
330
+add_action('give_view_receipt', 'give_render_receipt_in_browser');
331 331
 
332 332
 
333 333
 /**
@@ -342,29 +342,29 @@  discard block
 block discarded – undo
342 342
 
343 343
 	//Payment receipt switcher
344 344
 	$payment_count = give_count_payments()->publish;
345
-	$payment_id    = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : '';
345
+	$payment_id    = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : '';
346 346
 
347
-	if ( $payment_count <= 0 ) {
347
+	if ($payment_count <= 0) {
348 348
 		return false;
349 349
 	}
350 350
 
351 351
 	//Get payments.
352
-	$payments = new Give_Payments_Query( array(
352
+	$payments = new Give_Payments_Query(array(
353 353
 		'number' => 100
354
-	) );
354
+	));
355 355
 	$payments = $payments->get_payments();
356 356
 	$options  = array();
357 357
 
358 358
 	//Provide nice human readable options.
359
-	if ( $payments ) {
360
-		$options[0] = esc_html__( '- Select a donation -', 'give' );
361
-		foreach ( $payments as $payment ) {
359
+	if ($payments) {
360
+		$options[0] = esc_html__('- Select a donation -', 'give');
361
+		foreach ($payments as $payment) {
362 362
 
363
-			$options[ $payment->ID ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title );
363
+			$options[$payment->ID] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title);
364 364
 
365 365
 		}
366 366
 	} else {
367
-		$options[0] = esc_html__( 'No donations found.', 'give' );
367
+		$options[0] = esc_html__('No donations found.', 'give');
368 368
 	}
369 369
 
370 370
 	//Start constructing HTML output.
@@ -377,16 +377,16 @@  discard block
 block discarded – undo
377 377
 			        var selected_trans = transactions.options[transactions.selectedIndex];
378 378
 				        console.log(selected_trans);
379 379
 				        if (selected_trans){
380
-				            var url_string = "' . get_bloginfo( 'url' ) . '?give_action=preview_email&preview_id=" + selected_trans.value;
380
+				            var url_string = "' . get_bloginfo('url').'?give_action=preview_email&preview_id=" + selected_trans.value;
381 381
 				                window.location = url_string;
382 382
 				        }
383 383
 				    }
384 384
 			    </script>';
385 385
 
386
-	$transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">' . esc_html__( 'Preview email with a donation:', 'give' ) . '</label>';
386
+	$transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">'.esc_html__('Preview email with a donation:', 'give').'</label>';
387 387
 
388 388
 	//The select field with 100 latest transactions
389
-	$transaction_header .= Give()->html->select( array(
389
+	$transaction_header .= Give()->html->select(array(
390 390
 		'name'             => 'preview_email_payment_id',
391 391
 		'selected'         => $payment_id,
392 392
 		'id'               => 'give_preview_email_payment_id',
@@ -396,12 +396,12 @@  discard block
 block discarded – undo
396 396
 		'select_atts'      => 'onchange="change_preview()">',
397 397
 		'show_option_all'  => false,
398 398
 		'show_option_none' => false
399
-	) );
399
+	));
400 400
 
401 401
 	//Closing tag
402 402
 	$transaction_header .= '</div>';
403 403
 
404
-	return apply_filters( 'give_preview_email_receipt_header', $transaction_header );
404
+	return apply_filters('give_preview_email_receipt_header', $transaction_header);
405 405
 
406 406
 }
407 407
 
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 function give_receipt_head_content() {
416 416
 
417 417
 	//Title.
418
-	$output = '<title>' . esc_html__( 'Donation Receipt', 'give' ) . '</title>';
418
+	$output = '<title>'.esc_html__('Donation Receipt', 'give').'</title>';
419 419
 
420 420
 	//Meta.
421 421
 	$output .= '<meta charset="utf-8"/>
@@ -429,10 +429,10 @@  discard block
 block discarded – undo
429 429
 		<meta name="robots" content="noindex, nofollow"/>';
430 430
 
431 431
 	//CSS
432
-	$output .= '<link rel="stylesheet" href="' . give_get_stylesheet_uri() . '?ver=' . GIVE_VERSION . '">';
432
+	$output .= '<link rel="stylesheet" href="'.give_get_stylesheet_uri().'?ver='.GIVE_VERSION.'">';
433 433
 
434
-	echo apply_filters( 'give_receipt_head_content', $output );
434
+	echo apply_filters('give_receipt_head_content', $output);
435 435
 
436 436
 }
437 437
 
438
-add_action( 'give_receipt_head', 'give_receipt_head_content' );
439 438
\ No newline at end of file
439
+add_action('give_receipt_head', 'give_receipt_head_content');
440 440
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-give-db-customers.php 1 patch
Spacing   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
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
 
@@ -35,11 +35,11 @@  discard block
 block discarded – undo
35 35
 		/* @var WPDB $wpdb */
36 36
 		global $wpdb;
37 37
 
38
-		$this->table_name  = $wpdb->prefix . 'give_customers';
38
+		$this->table_name  = $wpdb->prefix.'give_customers';
39 39
 		$this->primary_key = 'id';
40 40
 		$this->version     = '1.0';
41 41
 		
42
-		add_action( 'profile_update', array( $this, 'update_customer_email_on_user_update' ), 10, 2 );
42
+		add_action('profile_update', array($this, 'update_customer_email_on_user_update'), 10, 2);
43 43
 
44 44
 	}
45 45
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 			'purchase_value' => 0.00,
83 83
 			'purchase_count' => 0,
84 84
 			'notes'          => '',
85
-			'date_created'   => date( 'Y-m-d H:i:s' ),
85
+			'date_created'   => date('Y-m-d H:i:s'),
86 86
 		);
87 87
 	}
88 88
 
@@ -96,40 +96,40 @@  discard block
 block discarded – undo
96 96
 	 *
97 97
 	 * @return int|bool
98 98
 	 */
99
-	public function add( $data = array() ) {
99
+	public function add($data = array()) {
100 100
 
101 101
 		$defaults = array(
102 102
 			'payment_ids' => ''
103 103
 		);
104 104
 
105
-		$args = wp_parse_args( $data, $defaults );
105
+		$args = wp_parse_args($data, $defaults);
106 106
 
107
-		if ( empty( $args['email'] ) ) {
107
+		if (empty($args['email'])) {
108 108
 			return false;
109 109
 		}
110 110
 
111
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
112
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
111
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
112
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
113 113
 		}
114 114
 
115
-		$customer = $this->get_customer_by( 'email', $args['email'] );
115
+		$customer = $this->get_customer_by('email', $args['email']);
116 116
 
117
-		if ( $customer ) {
117
+		if ($customer) {
118 118
 			// update an existing customer
119 119
 
120 120
 			// Update the payment IDs attached to the customer
121
-			if ( ! empty( $args['payment_ids'] ) ) {
121
+			if ( ! empty($args['payment_ids'])) {
122 122
 
123
-				if ( empty( $customer->payment_ids ) ) {
123
+				if (empty($customer->payment_ids)) {
124 124
 
125 125
 					$customer->payment_ids = $args['payment_ids'];
126 126
 
127 127
 				} else {
128 128
 
129
-					$existing_ids          = array_map( 'absint', explode( ',', $customer->payment_ids ) );
130
-					$payment_ids           = array_map( 'absint', explode( ',', $args['payment_ids'] ) );
131
-					$payment_ids           = array_merge( $payment_ids, $existing_ids );
132
-					$customer->payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
129
+					$existing_ids          = array_map('absint', explode(',', $customer->payment_ids));
130
+					$payment_ids           = array_map('absint', explode(',', $args['payment_ids']));
131
+					$payment_ids           = array_merge($payment_ids, $existing_ids);
132
+					$customer->payment_ids = implode(',', array_unique(array_values($payment_ids)));
133 133
 
134 134
 				}
135 135
 
@@ -137,13 +137,13 @@  discard block
 block discarded – undo
137 137
 
138 138
 			}
139 139
 
140
-			$this->update( $customer->id, $args );
140
+			$this->update($customer->id, $args);
141 141
 
142 142
 			return $customer->id;
143 143
 
144 144
 		} else {
145 145
 
146
-			return $this->insert( $args, 'customer' );
146
+			return $this->insert($args, 'customer');
147 147
 
148 148
 		}
149 149
 
@@ -162,20 +162,20 @@  discard block
 block discarded – undo
162 162
 	 *
163 163
 	 * @return bool|int
164 164
 	 */
165
-	public function delete( $_id_or_email = false ) {
165
+	public function delete($_id_or_email = false) {
166 166
 
167
-		if ( empty( $_id_or_email ) ) {
167
+		if (empty($_id_or_email)) {
168 168
 			return false;
169 169
 		}
170 170
 
171
-		$column   = is_email( $_id_or_email ) ? 'email' : 'id';
172
-		$customer = $this->get_customer_by( $column, $_id_or_email );
171
+		$column   = is_email($_id_or_email) ? 'email' : 'id';
172
+		$customer = $this->get_customer_by($column, $_id_or_email);
173 173
 
174
-		if ( $customer->id > 0 ) {
174
+		if ($customer->id > 0) {
175 175
 
176 176
 			global $wpdb;
177 177
 
178
-			return $wpdb->delete( $this->table_name, array( 'id' => $customer->id ), array( '%d' ) );
178
+			return $wpdb->delete($this->table_name, array('id' => $customer->id), array('%d'));
179 179
 
180 180
 		} else {
181 181
 			return false;
@@ -194,14 +194,14 @@  discard block
 block discarded – undo
194 194
 	 *
195 195
 	 * @return bool          True is exists, false otherwise.
196 196
 	 */
197
-	public function exists( $value = '', $field = 'email' ) {
197
+	public function exists($value = '', $field = 'email') {
198 198
 		
199 199
 		$columns = $this->get_columns();
200
-		if ( ! array_key_exists( $field, $columns ) ) {
200
+		if ( ! array_key_exists($field, $columns)) {
201 201
 			return false;
202 202
 		}
203 203
 
204
-		return (bool) $this->get_column_by( 'id', $field, $value );
204
+		return (bool) $this->get_column_by('id', $field, $value);
205 205
 
206 206
 	}
207 207
 
@@ -216,16 +216,16 @@  discard block
 block discarded – undo
216 216
 	 *
217 217
 	 * @return bool
218 218
 	 */
219
-	public function attach_payment( $customer_id = 0, $payment_id = 0 ) {
219
+	public function attach_payment($customer_id = 0, $payment_id = 0) {
220 220
 
221
-		$customer = new Give_Customer( $customer_id );
221
+		$customer = new Give_Customer($customer_id);
222 222
 
223
-		if ( empty( $customer->id ) ) {
223
+		if (empty($customer->id)) {
224 224
 			return false;
225 225
 		}
226 226
 
227 227
 		// Attach the payment, but don't increment stats, as this function previously did not
228
-		return $customer->attach_payment( $payment_id, false );
228
+		return $customer->attach_payment($payment_id, false);
229 229
 
230 230
 	}
231 231
 
@@ -240,16 +240,16 @@  discard block
 block discarded – undo
240 240
 	 *
241 241
 	 * @return bool
242 242
 	 */
243
-	public function remove_payment( $customer_id = 0, $payment_id = 0 ) {
243
+	public function remove_payment($customer_id = 0, $payment_id = 0) {
244 244
 
245
-		$customer = new Give_Customer( $customer_id );
245
+		$customer = new Give_Customer($customer_id);
246 246
 
247
-		if ( ! $customer ) {
247
+		if ( ! $customer) {
248 248
 			return false;
249 249
 		}
250 250
 
251 251
 		// Remove the payment, but don't decrease stats, as this function previously did not
252
-		return $customer->remove_payment( $payment_id, false );
252
+		return $customer->remove_payment($payment_id, false);
253 253
 
254 254
 	}
255 255
 
@@ -263,18 +263,18 @@  discard block
 block discarded – undo
263 263
 	 *
264 264
 	 * @return bool
265 265
 	 */
266
-	public function increment_stats( $customer_id = 0, $amount = 0.00 ) {
266
+	public function increment_stats($customer_id = 0, $amount = 0.00) {
267 267
 
268
-		$customer = new Give_Customer( $customer_id );
268
+		$customer = new Give_Customer($customer_id);
269 269
 
270
-		if ( empty( $customer->id ) ) {
270
+		if (empty($customer->id)) {
271 271
 			return false;
272 272
 		}
273 273
 
274 274
 		$increased_count = $customer->increase_purchase_count();
275
-		$increased_value = $customer->increase_value( $amount );
275
+		$increased_value = $customer->increase_value($amount);
276 276
 
277
-		return ( $increased_count && $increased_value ) ? true : false;
277
+		return ($increased_count && $increased_value) ? true : false;
278 278
 
279 279
 	}
280 280
 
@@ -289,18 +289,18 @@  discard block
 block discarded – undo
289 289
 	 *
290 290
 	 * @return bool
291 291
 	 */
292
-	public function decrement_stats( $customer_id = 0, $amount = 0.00 ) {
292
+	public function decrement_stats($customer_id = 0, $amount = 0.00) {
293 293
 
294
-		$customer = new Give_Customer( $customer_id );
294
+		$customer = new Give_Customer($customer_id);
295 295
 
296
-		if ( ! $customer ) {
296
+		if ( ! $customer) {
297 297
 			return false;
298 298
 		}
299 299
 
300 300
 		$decreased_count = $customer->decrease_purchase_count();
301
-		$decreased_value = $customer->decrease_value( $amount );
301
+		$decreased_value = $customer->decrease_value($amount);
302 302
 
303
-		return ( $decreased_count && $decreased_value ) ? true : false;
303
+		return ($decreased_count && $decreased_value) ? true : false;
304 304
 
305 305
 	}
306 306
 
@@ -315,31 +315,31 @@  discard block
 block discarded – undo
315 315
 	 *
316 316
 	 * @return bool
317 317
 	 */
318
-	public function update_customer_email_on_user_update( $user_id = 0, $old_user_data ) {
318
+	public function update_customer_email_on_user_update($user_id = 0, $old_user_data) {
319 319
 
320
-		$customer = new Give_Customer( $user_id, true );
320
+		$customer = new Give_Customer($user_id, true);
321 321
 
322
-		if( ! $customer ) {
322
+		if ( ! $customer) {
323 323
 			return false;
324 324
 		}
325 325
 
326
-		$user = get_userdata( $user_id );
326
+		$user = get_userdata($user_id);
327 327
 
328
-		if( ! empty( $user ) && $user->user_email !== $customer->email ) {
328
+		if ( ! empty($user) && $user->user_email !== $customer->email) {
329 329
 
330
-			if( ! $this->get_customer_by( 'email', $user->user_email ) ) {
330
+			if ( ! $this->get_customer_by('email', $user->user_email)) {
331 331
 
332
-				$success = $this->update( $customer->id, array( 'email' => $user->user_email ) );
332
+				$success = $this->update($customer->id, array('email' => $user->user_email));
333 333
 
334
-				if( $success ) {
334
+				if ($success) {
335 335
 					// Update some payment meta if we need to
336
-					$payments_array = explode( ',', $customer->payment_ids );
336
+					$payments_array = explode(',', $customer->payment_ids);
337 337
 
338
-					if( ! empty( $payments_array ) ) {
338
+					if ( ! empty($payments_array)) {
339 339
 
340
-						foreach ( $payments_array as $payment_id ) {
340
+						foreach ($payments_array as $payment_id) {
341 341
 
342
-							give_update_payment_meta( $payment_id, 'email', $user->user_email );
342
+							give_update_payment_meta($payment_id, 'email', $user->user_email);
343 343
 
344 344
 						}
345 345
 
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 					 * @param  WP_User       $user     WordPress User object.
354 354
 					 * @param  Give_Customer $customer Give customer object.
355 355
 					 */
356
-					do_action( 'give_update_customer_email_on_user_update', $user, $customer );
356
+					do_action('give_update_customer_email_on_user_update', $user, $customer);
357 357
 
358 358
 				}
359 359
 
@@ -374,46 +374,46 @@  discard block
 block discarded – undo
374 374
 	 *
375 375
 	 * @return mixed         Upon success, an object of the customer. Upon failure, NULL
376 376
 	 */
377
-	public function get_customer_by( $field = 'id', $value = 0 ) {
377
+	public function get_customer_by($field = 'id', $value = 0) {
378 378
 		/* @var WPDB $wpdb */
379 379
 		global $wpdb;
380 380
 
381
-		if ( empty( $field ) || empty( $value ) ) {
381
+		if (empty($field) || empty($value)) {
382 382
 			return null;
383 383
 		}
384 384
 
385
-		if ( 'id' == $field || 'user_id' == $field ) {
385
+		if ('id' == $field || 'user_id' == $field) {
386 386
 			// Make sure the value is numeric to avoid casting objects, for example,
387 387
 			// to int 1.
388
-			if ( ! is_numeric( $value ) ) {
388
+			if ( ! is_numeric($value)) {
389 389
 				return false;
390 390
 			}
391 391
 
392
-			$value = intval( $value );
392
+			$value = intval($value);
393 393
 
394
-			if ( $value < 1 ) {
394
+			if ($value < 1) {
395 395
 				return false;
396 396
 			}
397 397
 
398
-		} elseif ( 'email' === $field ) {
398
+		} elseif ('email' === $field) {
399 399
 
400
-			if ( ! is_email( $value ) ) {
400
+			if ( ! is_email($value)) {
401 401
 				return false;
402 402
 			}
403 403
 
404
-			$value = trim( $value );
404
+			$value = trim($value);
405 405
 		}
406 406
 
407
-		if ( ! $value ) {
407
+		if ( ! $value) {
408 408
 			return false;
409 409
 		}
410 410
 
411
-		switch ( $field ) {
411
+		switch ($field) {
412 412
 			case 'id':
413 413
 				$db_field = 'id';
414 414
 				break;
415 415
 			case 'email':
416
-				$value    = sanitize_text_field( $value );
416
+				$value    = sanitize_text_field($value);
417 417
 				$db_field = 'email';
418 418
 				break;
419 419
 			case 'user_id':
@@ -423,15 +423,15 @@  discard block
 block discarded – undo
423 423
 				return false;
424 424
 		}
425 425
 
426
-		if ( ! $customer = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value ) ) ) {
426
+		if ( ! $customer = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value))) {
427 427
 
428 428
 			// Look for customer from an additional email
429
-			if( 'email' === $field ) {
429
+			if ('email' === $field) {
430 430
 				$meta_table  = Give()->customer_meta->table_name;
431
-				$customer_id = $wpdb->get_var( $wpdb->prepare( "SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $value ) );
431
+				$customer_id = $wpdb->get_var($wpdb->prepare("SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $value));
432 432
 
433
-				if( ! empty( $customer_id ) ) {
434
-					return $this->get( $customer_id );
433
+				if ( ! empty($customer_id)) {
434
+					return $this->get($customer_id);
435 435
  				}
436 436
  			}
437 437
 
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
      *
452 452
      * @return array|object|null Customers array or object. Null if not found.
453 453
 	 */
454
-	public function get_customers( $args = array() ) {
454
+	public function get_customers($args = array()) {
455 455
         /* @var WPDB $wpdb */
456 456
 		global $wpdb;
457 457
 
@@ -463,21 +463,21 @@  discard block
 block discarded – undo
463 463
 			'order'   => 'DESC'
464 464
 		);
465 465
 
466
-		$args = wp_parse_args( $args, $defaults );
466
+		$args = wp_parse_args($args, $defaults);
467 467
 
468
-		if ( $args['number'] < 1 ) {
468
+		if ($args['number'] < 1) {
469 469
 			$args['number'] = 999999999999;
470 470
 		}
471 471
 
472 472
 		$where = ' WHERE 1=1 ';
473 473
 
474 474
 		// specific customers
475
-		if ( ! empty( $args['id'] ) ) {
475
+		if ( ! empty($args['id'])) {
476 476
 
477
-			if ( is_array( $args['id'] ) ) {
478
-				$ids = implode( ',', array_map( 'intval', $args['id'] ) );
477
+			if (is_array($args['id'])) {
478
+				$ids = implode(',', array_map('intval', $args['id']));
479 479
 			} else {
480
-				$ids = intval( $args['id'] );
480
+				$ids = intval($args['id']);
481 481
 			}
482 482
 
483 483
 			$where .= " AND `id` IN( {$ids} ) ";
@@ -485,12 +485,12 @@  discard block
 block discarded – undo
485 485
 		}
486 486
 
487 487
 		// customers for specific user accounts
488
-		if ( ! empty( $args['user_id'] ) ) {
488
+		if ( ! empty($args['user_id'])) {
489 489
 
490
-			if ( is_array( $args['user_id'] ) ) {
491
-				$user_ids = implode( ',', array_map( 'intval', $args['user_id'] ) );
490
+			if (is_array($args['user_id'])) {
491
+				$user_ids = implode(',', array_map('intval', $args['user_id']));
492 492
 			} else {
493
-				$user_ids = intval( $args['user_id'] );
493
+				$user_ids = intval($args['user_id']);
494 494
 			}
495 495
 
496 496
 			$where .= " AND `user_id` IN( {$user_ids} ) ";
@@ -498,41 +498,41 @@  discard block
 block discarded – undo
498 498
 		}
499 499
 
500 500
 		//specific customers by email
501
-		if( ! empty( $args['email'] ) ) {
501
+		if ( ! empty($args['email'])) {
502 502
 
503
-			if( is_array( $args['email'] ) ) {
503
+			if (is_array($args['email'])) {
504 504
 
505
-				$emails_count       = count( $args['email'] );
506
-				$emails_placeholder = array_fill( 0, $emails_count, '%s' );
507
-				$emails             = implode( ', ', $emails_placeholder );
505
+				$emails_count       = count($args['email']);
506
+				$emails_placeholder = array_fill(0, $emails_count, '%s');
507
+				$emails             = implode(', ', $emails_placeholder);
508 508
 
509
-				$where .= $wpdb->prepare( " AND `email` IN( $emails ) ", $args['email'] );
509
+				$where .= $wpdb->prepare(" AND `email` IN( $emails ) ", $args['email']);
510 510
 			} else {
511
-				$where .= $wpdb->prepare( " AND `email` = %s ", $args['email'] );
511
+				$where .= $wpdb->prepare(" AND `email` = %s ", $args['email']);
512 512
 			}
513 513
 		}
514 514
 
515 515
 		// specific customers by name
516
-		if( ! empty( $args['name'] ) ) {
517
-			$where .= $wpdb->prepare( " AND `name` LIKE '%%%%" . '%s' . "%%%%' ", $args['name'] );
516
+		if ( ! empty($args['name'])) {
517
+			$where .= $wpdb->prepare(" AND `name` LIKE '%%%%".'%s'."%%%%' ", $args['name']);
518 518
 		}
519 519
 
520 520
 		// Customers created for a specific date or in a date range
521
-		if ( ! empty( $args['date'] ) ) {
521
+		if ( ! empty($args['date'])) {
522 522
 
523
-			if ( is_array( $args['date'] ) ) {
523
+			if (is_array($args['date'])) {
524 524
 
525
-				if ( ! empty( $args['date']['start'] ) ) {
525
+				if ( ! empty($args['date']['start'])) {
526 526
 
527
-					$start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) );
527
+					$start = date('Y-m-d H:i:s', strtotime($args['date']['start']));
528 528
 
529 529
 					$where .= " AND `date_created` >= '{$start}'";
530 530
 
531 531
 				}
532 532
 
533
-				if ( ! empty( $args['date']['end'] ) ) {
533
+				if ( ! empty($args['date']['end'])) {
534 534
 
535
-					$end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) );
535
+					$end = date('Y-m-d H:i:s', strtotime($args['date']['end']));
536 536
 
537 537
 					$where .= " AND `date_created` <= '{$end}'";
538 538
 
@@ -540,31 +540,31 @@  discard block
 block discarded – undo
540 540
 
541 541
 			} else {
542 542
 
543
-				$year  = date( 'Y', strtotime( $args['date'] ) );
544
-				$month = date( 'm', strtotime( $args['date'] ) );
545
-				$day   = date( 'd', strtotime( $args['date'] ) );
543
+				$year  = date('Y', strtotime($args['date']));
544
+				$month = date('m', strtotime($args['date']));
545
+				$day   = date('d', strtotime($args['date']));
546 546
 
547 547
 				$where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )";
548 548
 			}
549 549
 
550 550
 		}
551 551
 
552
-		$args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'id' : $args['orderby'];
552
+		$args['orderby'] = ! array_key_exists($args['orderby'], $this->get_columns()) ? 'id' : $args['orderby'];
553 553
 
554
-		if ( 'purchase_value' == $args['orderby'] ) {
554
+		if ('purchase_value' == $args['orderby']) {
555 555
 			$args['orderby'] = 'purchase_value+0';
556 556
 		}
557 557
 
558
-		$cache_key = md5( 'give_customers_' . serialize( $args ) );
558
+		$cache_key = md5('give_customers_'.serialize($args));
559 559
 
560
-		$customers = wp_cache_get( $cache_key, 'customers' );
560
+		$customers = wp_cache_get($cache_key, 'customers');
561 561
 
562
-		$args['orderby'] = esc_sql( $args['orderby'] );
563
-		$args['order']   = esc_sql( $args['order'] );
562
+		$args['orderby'] = esc_sql($args['orderby']);
563
+		$args['order']   = esc_sql($args['order']);
564 564
 
565
-		if ( $customers === false ) {
566
-			$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'] ) ) );
567
-			wp_cache_set( $cache_key, $customers, 'customers', 3600 );
565
+		if ($customers === false) {
566
+			$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'])));
567
+			wp_cache_set($cache_key, $customers, 'customers', 3600);
568 568
 		}
569 569
 
570 570
 		return $customers;
@@ -582,26 +582,26 @@  discard block
 block discarded – undo
582 582
      *
583 583
      * @return int         Total number of customers.
584 584
 	 */
585
-	public function count( $args = array() ) {
585
+	public function count($args = array()) {
586 586
         /* @var WPDB $wpdb */
587 587
 		global $wpdb;
588 588
 
589 589
 		$where = ' WHERE 1=1 ';
590 590
 
591
-		if ( ! empty( $args['date'] ) ) {
591
+		if ( ! empty($args['date'])) {
592 592
 
593
-			if ( is_array( $args['date'] ) ) {
593
+			if (is_array($args['date'])) {
594 594
 
595
-				$start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) );
596
-				$end   = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) );
595
+				$start = date('Y-m-d H:i:s', strtotime($args['date']['start']));
596
+				$end   = date('Y-m-d H:i:s', strtotime($args['date']['end']));
597 597
 
598 598
 				$where .= " AND `date_created` >= '{$start}' AND `date_created` <= '{$end}'";
599 599
 
600 600
 			} else {
601 601
 
602
-				$year  = date( 'Y', strtotime( $args['date'] ) );
603
-				$month = date( 'm', strtotime( $args['date'] ) );
604
-				$day   = date( 'd', strtotime( $args['date'] ) );
602
+				$year  = date('Y', strtotime($args['date']));
603
+				$month = date('m', strtotime($args['date']));
604
+				$day   = date('d', strtotime($args['date']));
605 605
 
606 606
 				$where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )";
607 607
 			}
@@ -609,16 +609,16 @@  discard block
 block discarded – undo
609 609
 		}
610 610
 
611 611
 
612
-		$cache_key = md5( 'give_customers_count' . serialize( $args ) );
612
+		$cache_key = md5('give_customers_count'.serialize($args));
613 613
 
614
-		$count = wp_cache_get( $cache_key, 'customers' );
614
+		$count = wp_cache_get($cache_key, 'customers');
615 615
 
616
-		if ( $count === false ) {
617
-			$count = $wpdb->get_var( "SELECT COUNT($this->primary_key) FROM " . $this->table_name . "{$where};" );
618
-			wp_cache_set( $cache_key, $count, 'customers', 3600 );
616
+		if ($count === false) {
617
+			$count = $wpdb->get_var("SELECT COUNT($this->primary_key) FROM ".$this->table_name."{$where};");
618
+			wp_cache_set($cache_key, $count, 'customers', 3600);
619 619
 		}
620 620
 
621
-		return absint( $count );
621
+		return absint($count);
622 622
 
623 623
 	}
624 624
 
@@ -632,9 +632,9 @@  discard block
 block discarded – undo
632 632
 	 */
633 633
 	public function create_table() {
634 634
 
635
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
635
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
636 636
 
637
-		$sql = "CREATE TABLE " . $this->table_name . " (
637
+		$sql = "CREATE TABLE ".$this->table_name." (
638 638
 		id bigint(20) NOT NULL AUTO_INCREMENT,
639 639
 		user_id bigint(20) NOT NULL,
640 640
 		email varchar(50) NOT NULL,
@@ -649,9 +649,9 @@  discard block
 block discarded – undo
649 649
 		KEY user (user_id)
650 650
 		) CHARACTER SET utf8 COLLATE utf8_general_ci;";
651 651
 
652
-		dbDelta( $sql );
652
+		dbDelta($sql);
653 653
 
654
-		update_option( $this->table_name . '_db_version', $this->version );
654
+		update_option($this->table_name.'_db_version', $this->version);
655 655
 	}
656 656
 	
657 657
 	/**
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
 	 * @return bool Returns if the customers table was installed and upgrade routine run.
664 664
 	 */
665 665
 	public function installed() {
666
-		return $this->table_exists( $this->table_name );
666
+		return $this->table_exists($this->table_name);
667 667
 	}
668 668
 
669 669
 }
Please login to merge, or discard this patch.