Completed
Pull Request — master (#1412)
by Ravinder
17:25
created
includes/admin/reporting/tools.php 1 patch
Spacing   +26 added lines, -26 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
 
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  */
23 23
 function give_tools_recount_stats_display() {
24 24
 
25
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
25
+	if ( ! current_user_can('manage_give_settings')) {
26 26
 		return;
27 27
 	}
28 28
 
@@ -31,27 +31,27 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @since 1.5
33 33
 	 */
34
-	do_action( 'give_tools_recount_stats_before' );
34
+	do_action('give_tools_recount_stats_before');
35 35
 	?>
36 36
 	<div id="poststuff">
37 37
 		<div class="postbox">
38 38
 
39
-			<h2 class="hndle ui-sortable-handle"><span><?php esc_html_e( 'Recount Stats', 'give' ); ?></span></h2>
39
+			<h2 class="hndle ui-sortable-handle"><span><?php esc_html_e('Recount Stats', 'give'); ?></span></h2>
40 40
 
41 41
 			<div class="inside recount-stats-controls">
42
-				<p><?php esc_html_e( 'Use these tools to recount stats, delete test transactions, or reset stats.', 'give' ); ?></p>
42
+				<p><?php esc_html_e('Use these tools to recount stats, delete test transactions, or reset stats.', 'give'); ?></p>
43 43
 				<form method="post" id="give-tools-recount-form" class="give-export-form">
44 44
 
45
-					<?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?>
45
+					<?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?>
46 46
 
47 47
 					<select name="give-export-class" id="recount-stats-type">
48
-						<option value="0" selected="selected" disabled="disabled"><?php esc_html_e( 'Please select an option', 'give' ); ?></option>
49
-						<option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e( 'Recalculate Total Donation Income Amount', 'give' ); ?></option>
50
-						<option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_e( 'Recalculate Income Amount and Donation Counts for a Form', 'give' ); ?></option>
51
-						<option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php esc_html_e( 'Recalculate Income Amount and Donation Counts for All Forms', 'give' ); ?></option>
52
-						<option data-type="recount-customer-stats" value="Give_Tools_Recount_Customer_Stats"><?php esc_html_e( 'Recalculate Donor Statistics', 'give' ); ?></option>
53
-						<option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e( 'Delete Test Transactions', 'give' ); ?></option>
54
-						<option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_e( 'Delete All Data', 'give' ); ?></option>
48
+						<option value="0" selected="selected" disabled="disabled"><?php esc_html_e('Please select an option', 'give'); ?></option>
49
+						<option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e('Recalculate Total Donation Income Amount', 'give'); ?></option>
50
+						<option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_e('Recalculate Income Amount and Donation Counts for a Form', 'give'); ?></option>
51
+						<option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php esc_html_e('Recalculate Income Amount and Donation Counts for All Forms', 'give'); ?></option>
52
+						<option data-type="recount-customer-stats" value="Give_Tools_Recount_Customer_Stats"><?php esc_html_e('Recalculate Donor Statistics', 'give'); ?></option>
53
+						<option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e('Delete Test Transactions', 'give'); ?></option>
54
+						<option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_e('Delete All Data', 'give'); ?></option>
55 55
 						<?php
56 56
 						/**
57 57
 						 * Fires in the recount stats selectbox.
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 						 *
61 61
 						 * @since 1.5
62 62
 						 */
63
-						do_action( 'give_recount_tool_options' );
63
+						do_action('give_recount_tool_options');
64 64
 						?>
65 65
 					</select>
66 66
 
@@ -68,22 +68,22 @@  discard block
 block discarded – undo
68 68
 						<?php
69 69
 						$args = array(
70 70
 							'name'   => 'form_id',
71
-							'number' => - 1,
71
+							'number' => -1,
72 72
 							'chosen' => true,
73 73
 						);
74
-						echo Give()->html->forms_dropdown( $args );
74
+						echo Give()->html->forms_dropdown($args);
75 75
 						?>
76 76
 					</span>
77 77
 
78
-					<input type="submit" id="recount-stats-submit" value="<?php esc_attr_e( 'Submit', 'give' ); ?>" class="button-secondary"/>
78
+					<input type="submit" id="recount-stats-submit" value="<?php esc_attr_e('Submit', 'give'); ?>" class="button-secondary"/>
79 79
 
80 80
 					<br/>
81 81
 
82 82
 					<span class="give-recount-stats-descriptions">
83
-						<span id="recount-stats"><?php esc_html_e( 'Recalculates the overall donation income amount.', 'give' ); ?></span>
84
-						<span id="recount-form"><?php esc_html_e( 'Recalculates the donation and income stats for a specific form.', 'give' ); ?></span>
85
-						<span id="recount-all"><?php esc_html_e( 'Recalculates the earnings and sales stats for all forms.', 'give' ); ?></span>
86
-						<span id="recount-customer-stats"><?php esc_html_e( 'Recalculates the lifetime value and donation counts for all donors.', 'give' ); ?></span>
83
+						<span id="recount-stats"><?php esc_html_e('Recalculates the overall donation income amount.', 'give'); ?></span>
84
+						<span id="recount-form"><?php esc_html_e('Recalculates the donation and income stats for a specific form.', 'give'); ?></span>
85
+						<span id="recount-all"><?php esc_html_e('Recalculates the earnings and sales stats for all forms.', 'give'); ?></span>
86
+						<span id="recount-customer-stats"><?php esc_html_e('Recalculates the lifetime value and donation counts for all donors.', 'give'); ?></span>
87 87
 						<?php
88 88
 						/**
89 89
 						 * Fires in the recount stats description area.
@@ -92,10 +92,10 @@  discard block
 block discarded – undo
92 92
 						 *
93 93
 						 * @since 1.5
94 94
 						 */
95
-						do_action( 'give_recount_tool_descriptions' );
95
+						do_action('give_recount_tool_descriptions');
96 96
 						?>
97
-						<span id="delete-test-transactions"><?php _e( '<strong>Deletes</strong> all TEST donations, donors, and related log entries.', 'give' ); ?></span>
98
-						<span id="reset-stats"><?php _e( '<strong>Deletes</strong> ALL donations, donors, and related log entries regardless of test or live mode.', 'give' ); ?></span>
97
+						<span id="delete-test-transactions"><?php _e('<strong>Deletes</strong> all TEST donations, donors, and related log entries.', 'give'); ?></span>
98
+						<span id="reset-stats"><?php _e('<strong>Deletes</strong> ALL donations, donors, and related log entries regardless of test or live mode.', 'give'); ?></span>
99 99
 					</span>
100 100
 
101 101
 					<span class="spinner"></span>
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 				 *
110 110
 				 * @since 1.5
111 111
 				 */
112
-				do_action( 'give_tools_recount_forms' );
112
+				do_action('give_tools_recount_forms');
113 113
 				?>
114 114
 			</div><!-- .inside -->
115 115
 		</div><!-- .postbox -->
@@ -120,5 +120,5 @@  discard block
 block discarded – undo
120 120
 	 *
121 121
 	 * @since 1.5
122 122
 	 */
123
-	do_action( 'give_tools_recount_stats_after' );
123
+	do_action('give_tools_recount_stats_after');
124 124
 }
125 125
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/views/html-admin-settings.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -2,13 +2,13 @@  discard block
 block discarded – undo
2 2
 /**
3 3
  * Admin View: Settings
4 4
  */
5
-if ( ! defined( 'ABSPATH' ) ) {
5
+if ( ! defined('ABSPATH')) {
6 6
 	exit;
7 7
 }
8 8
 
9 9
 
10 10
 // Bailout: Do not output anything if setting tab is not defined.
11
-if( ! empty( $tabs ) ) :
11
+if ( ! empty($tabs)) :
12 12
 	/**
13 13
 	 * Filter the form action.
14 14
 	 *
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @since 1.8
20 20
 	 */
21
-	$form_method    = apply_filters( self::$setting_filter_prefix . '_form_method_tab_' . $current_tab, 'post' );
21
+	$form_method = apply_filters(self::$setting_filter_prefix.'_form_method_tab_'.$current_tab, 'post');
22 22
 
23 23
 	/**
24 24
 	 * Filter the main form tab.
@@ -30,15 +30,15 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @since 1.8
32 32
 	 */
33
-	$form_open_tag  = apply_filters( self::$setting_filter_prefix . '_open_form', '<form method="' . $form_method  . '" id="give-mainform" action="" enctype="multipart/form-data">' );
34
-	$form_close_tag = apply_filters( self::$setting_filter_prefix . '_close_form', '</form>' );
33
+	$form_open_tag  = apply_filters(self::$setting_filter_prefix.'_open_form', '<form method="'.$form_method.'" id="give-mainform" action="" enctype="multipart/form-data">');
34
+	$form_close_tag = apply_filters(self::$setting_filter_prefix.'_close_form', '</form>');
35 35
 	?>
36
-	<div class="wrap give-settings-page <?php echo self::$setting_filter_prefix . '-setting-page'; ?>">
36
+	<div class="wrap give-settings-page <?php echo self::$setting_filter_prefix.'-setting-page'; ?>">
37 37
 		<?php echo $form_open_tag; ?>
38 38
 			<h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
39 39
 				<?php
40
-				foreach ( $tabs as $name => $label ) {
41
-					echo '<a href="' . admin_url( "edit.php?post_type=give_forms&page=" . self::$setting_filter_prefix . "&tab={$name}" ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
40
+				foreach ($tabs as $name => $label) {
41
+					echo '<a href="'.admin_url("edit.php?post_type=give_forms&page=".self::$setting_filter_prefix."&tab={$name}").'" class="nav-tab '.($current_tab == $name ? 'nav-tab-active' : '').'">'.$label.'</a>';
42 42
 				}
43 43
 
44 44
 				/**
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
 				 *
51 51
 				 * @since 1.8
52 52
 				 */
53
-				do_action( self::$setting_filter_prefix . '_tabs' );
53
+				do_action(self::$setting_filter_prefix.'_tabs');
54 54
 				?>
55 55
 			</h2>
56
-			<h1 class="screen-reader-text"><?php echo esc_html( $tabs[ $current_tab ] ); ?></h1>
56
+			<h1 class="screen-reader-text"><?php echo esc_html($tabs[$current_tab]); ?></h1>
57 57
 			<?php
58 58
 
59 59
 			/**
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 			 *
66 66
 			 * @since 1.8
67 67
 			 */
68
-			do_action( self::$setting_filter_prefix . "_sections_{$current_tab}_page" );
68
+			do_action(self::$setting_filter_prefix."_sections_{$current_tab}_page");
69 69
 
70 70
 			
71 71
 			// Show messages.
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
 			 *
82 82
 			 * @since 1.8
83 83
 			 */
84
-			do_action( self::$setting_filter_prefix . "_settings_{$current_tab}_page" );
84
+			do_action(self::$setting_filter_prefix."_settings_{$current_tab}_page");
85 85
 
86
-			if ( empty( $GLOBALS['give_hide_save_button'] ) ) : ?>
86
+			if (empty($GLOBALS['give_hide_save_button'])) : ?>
87 87
 				<div class="give-submit-wrap">
88
-					<?php wp_nonce_field( 'give-save-settings', '_give-save-settings' ); ?>
89
-					<input name="save" class="button-primary give-save-button" type="submit" value="<?php esc_attr_e( 'Save changes', 'give' ); ?>" />
88
+					<?php wp_nonce_field('give-save-settings', '_give-save-settings'); ?>
89
+					<input name="save" class="button-primary give-save-button" type="submit" value="<?php esc_attr_e('Save changes', 'give'); ?>" />
90 90
 				</div>
91 91
 			<?php endif; ?>
92 92
 		<?php echo $form_close_tag; ?>
Please login to merge, or discard this patch.
includes/admin/tools/class-settings-api.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit; // Exit if accessed directly
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Settings_API' ) ) :
16
+if ( ! class_exists('Give_Settings_API')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Settings_API.
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 		 */
44 44
 		public function __construct() {
45 45
 			$this->id    = 'api';
46
-			$this->label = esc_html__( 'API', 'give' );
46
+			$this->label = esc_html__('API', 'give');
47 47
 
48
-			add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 );
49
-			add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) );
48
+			add_filter('give-tools_tabs_array', array($this, 'add_settings_page'), 20);
49
+			add_action("give-tools_settings_{$this->id}_page", array($this, 'output'));
50 50
 		}
51 51
 
52 52
 		/**
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 		 * @param  array $pages Lst of pages.
57 57
 		 * @return array
58 58
 		 */
59
-		public function add_settings_page( $pages ) {
60
-			$pages[ $this->id ] = $this->label;
59
+		public function add_settings_page($pages) {
60
+			$pages[$this->id] = $this->label;
61 61
 
62 62
 			return $pages;
63 63
 		}
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 			$GLOBALS['give_hide_save_button'] = true;
74 74
 
75 75
 			// Get settings.
76
-			$settings = apply_filters( 'give_settings_system', array(
76
+			$settings = apply_filters('give_settings_system', array(
77 77
 				array(
78 78
 					'id'   => 'give_tools_api',
79 79
 					'type' => 'title',
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 				),
82 82
 				array(
83 83
 					'id'   => 'api',
84
-					'name' => esc_html__( 'API', 'give' ),
84
+					'name' => esc_html__('API', 'give'),
85 85
 					'type' => 'api',
86 86
 				),
87 87
 				array(
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			 * @since  1.8
98 98
 			 * @param  array $settings
99 99
 			 */
100
-			$settings = apply_filters( 'give_get_settings_' . $this->id, $settings );
100
+			$settings = apply_filters('give_get_settings_'.$this->id, $settings);
101 101
 
102 102
 			// Output.
103 103
 			return $settings;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 		public function output() {
113 113
 			$settings = $this->get_settings();
114 114
 
115
-			Give_Admin_Settings::output_fields( $settings, 'give_settings' );
115
+			Give_Admin_Settings::output_fields($settings, 'give_settings');
116 116
 		}
117 117
 	}
118 118
 
Please login to merge, or discard this patch.
includes/admin/tools/class-settings-data.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit; // Exit if accessed directly
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Settings_Data' ) ) :
16
+if ( ! class_exists('Give_Settings_Data')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Settings_Data.
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
 		 */
44 44
 		public function __construct() {
45 45
 			$this->id    = 'data';
46
-			$this->label = esc_html__( 'Data', 'give' );
46
+			$this->label = esc_html__('Data', 'give');
47 47
 
48
-			add_filter( 'give-tools_tabs_array', array( $this, 'add_settings_page' ), 20 );
49
-			add_action( "give-tools_settings_{$this->id}_page", array( $this, 'output' ) );
48
+			add_filter('give-tools_tabs_array', array($this, 'add_settings_page'), 20);
49
+			add_action("give-tools_settings_{$this->id}_page", array($this, 'output'));
50 50
 
51 51
 			// Do not use main form for this tab.
52
-			if( give_get_current_setting_tab() === $this->id ) {
53
-				add_action( "give-tools_open_form", '__return_empty_string' );
54
-				add_action( "give-tools_close_form", '__return_empty_string' );
52
+			if (give_get_current_setting_tab() === $this->id) {
53
+				add_action("give-tools_open_form", '__return_empty_string');
54
+				add_action("give-tools_close_form", '__return_empty_string');
55 55
 			}
56 56
 		}
57 57
 
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 		 * @param  array $pages Lst of pages.
63 63
 		 * @return array
64 64
 		 */
65
-		public function add_settings_page( $pages ) {
66
-			$pages[ $this->id ] = $this->label;
65
+		public function add_settings_page($pages) {
66
+			$pages[$this->id] = $this->label;
67 67
 
68 68
 			return $pages;
69 69
 		}
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 			$GLOBALS['give_hide_save_button'] = true;
80 80
 
81 81
 			// Get settings.
82
-			$settings = apply_filters( 'give_settings_system', array(
82
+			$settings = apply_filters('give_settings_system', array(
83 83
 				array(
84 84
 					'id'   => 'give_tools_tools',
85 85
 					'type' => 'title',
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 				),
88 88
 				array(
89 89
 					'id'   => 'api',
90
-					'name' => esc_html__( 'Tools', 'give' ),
90
+					'name' => esc_html__('Tools', 'give'),
91 91
 					'type' => 'data',
92 92
 				),
93 93
 				array(
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 			 * @since  1.8
104 104
 			 * @param  array $settings
105 105
 			 */
106
-			$settings = apply_filters( 'give_get_settings_' . $this->id, $settings );
106
+			$settings = apply_filters('give_get_settings_'.$this->id, $settings);
107 107
 
108 108
 			// Output.
109 109
 			return $settings;
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 		public function output() {
119 119
 			$settings = $this->get_settings();
120 120
 
121
-			Give_Admin_Settings::output_fields( $settings, 'give_settings' );
121
+			Give_Admin_Settings::output_fields($settings, 'give_settings');
122 122
 		}
123 123
 	}
124 124
 
Please login to merge, or discard this patch.
includes/filters.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,28 +26,28 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return void
28 28
  */
29
-function give_set_settings_with_disable_prefix( $settings, $option_name ) {
29
+function give_set_settings_with_disable_prefix($settings, $option_name) {
30 30
 	// Get old setting names.
31 31
 	$old_settings   = give_v18_renamed_core_settings();
32 32
 	$update_setting = false;
33 33
 
34
-	foreach ( $settings as $key => $value ) {
34
+	foreach ($settings as $key => $value) {
35 35
 
36 36
 		// Check 1. Check if new option is really updated or not.
37 37
 		// Check 2. Continue if key is not renamed.
38 38
 		if (
39
-			! isset( $_POST[ $key ] )
40
-			|| false === ( $old_setting_name = array_search( $key, $old_settings ) )
39
+			! isset($_POST[$key])
40
+			|| false === ($old_setting_name = array_search($key, $old_settings))
41 41
 		) {
42 42
 			continue;
43 43
 		}
44 44
 
45 45
 		// Set old setting.
46
-		$settings[ $old_setting_name ] = 'on';
46
+		$settings[$old_setting_name] = 'on';
47 47
 
48 48
 		// Do not need to set old setting if new setting is not set.
49
-		if ( give_is_setting_enabled( $value ) ) {
50
-			unset( $settings[ $old_setting_name ] );
49
+		if (give_is_setting_enabled($value)) {
50
+			unset($settings[$old_setting_name]);
51 51
 		}
52 52
 
53 53
 		// Tell bot to update setting.
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
 	}
56 56
 
57 57
 	// Update setting if any old setting set.
58
-	if ( $update_setting ) {
59
-		update_option( $option_name, $settings );
58
+	if ($update_setting) {
59
+		update_option($option_name, $settings);
60 60
 	}
61 61
 }
62 62
 
63
-add_filter( 'give_save_settings_give_settings', 'give_set_settings_with_disable_prefix', 10, 2 );
63
+add_filter('give_save_settings_give_settings', 'give_set_settings_with_disable_prefix', 10, 2);
Please login to merge, or discard this patch.
includes/class-give-logging.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
 	 *
38 38
 	 * Display admin bar when active
39 39
 	 *
40
-	 * @return bool
40
+	 * @return false|null
41 41
 	 */
42 42
 	public function give_admin_bar_menu() {
43 43
 		global $wp_admin_bar;
Please login to merge, or discard this patch.
Spacing   +68 added lines, -68 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
 
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public function __setup_hooks() {
45 45
 		// Create the log post type
46
-		add_action( 'init', array( $this, 'register_post_type' ), 1 );
46
+		add_action('init', array($this, 'register_post_type'), 1);
47 47
 
48 48
 		// Create types taxonomy and default types
49
-		add_action( 'init', array( $this, 'register_taxonomy' ), 1 );
49
+		add_action('init', array($this, 'register_taxonomy'), 1);
50 50
 
51
-		add_action( 'save_post_give_payment', array( $this, 'background_process_delete_cache') );
52
-		add_action( 'save_post_give_forms', array( $this, 'background_process_delete_cache') );
53
-		add_action( 'save_post_give_log', array( $this, 'background_process_delete_cache') );
54
-		add_action( 'give_delete_log_cache', array( $this, 'delete_cache') );
51
+		add_action('save_post_give_payment', array($this, 'background_process_delete_cache'));
52
+		add_action('save_post_give_forms', array($this, 'background_process_delete_cache'));
53
+		add_action('save_post_give_log', array($this, 'background_process_delete_cache'));
54
+		add_action('give_delete_log_cache', array($this, 'delete_cache'));
55 55
 	}
56 56
 
57 57
 	/**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	public function register_post_type() {
68 68
 		/* Logs post type */
69 69
 		$log_args = array(
70
-			'labels'              => array( 'name' => esc_html__( 'Logs', 'give' ) ),
70
+			'labels'              => array('name' => esc_html__('Logs', 'give')),
71 71
 			'public'              => false,
72 72
 			'exclude_from_search' => true,
73 73
 			'publicly_queryable'  => false,
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
 			'query_var'           => false,
76 76
 			'rewrite'             => false,
77 77
 			'capability_type'     => 'post',
78
-			'supports'            => array( 'title', 'editor' ),
78
+			'supports'            => array('title', 'editor'),
79 79
 			'can_export'          => true,
80 80
 		);
81 81
 
82
-		register_post_type( 'give_log', $log_args );
82
+		register_post_type('give_log', $log_args);
83 83
 	}
84 84
 
85 85
 	/**
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @return void
94 94
 	 */
95 95
 	public function register_taxonomy() {
96
-		register_taxonomy( 'give_log_type', 'give_log', array( 'public' => false ) );
96
+		register_taxonomy('give_log_type', 'give_log', array('public' => false));
97 97
 	}
98 98
 
99 99
 	/**
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 			'api_request',
114 114
 		);
115 115
 
116
-		return apply_filters( 'give_log_types', $terms );
116
+		return apply_filters('give_log_types', $terms);
117 117
 	}
118 118
 
119 119
 	/**
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 	 *
129 129
 	 * @return bool         Whether log type is valid.
130 130
 	 */
131
-	public function valid_type( $type ) {
132
-		return in_array( $type, $this->log_types() );
131
+	public function valid_type($type) {
132
+		return in_array($type, $this->log_types());
133 133
 	}
134 134
 
135 135
 	/**
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return int             Log ID.
150 150
 	 */
151
-	public function add( $title = '', $message = '', $parent = 0, $type = null ) {
151
+	public function add($title = '', $message = '', $parent = 0, $type = null) {
152 152
 		$log_data = array(
153 153
 			'post_title'   => $title,
154 154
 			'post_content' => $message,
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 			'log_type'     => $type,
157 157
 		);
158 158
 
159
-		return $this->insert_log( $log_data );
159
+		return $this->insert_log($log_data);
160 160
 	}
161 161
 
162 162
 	/**
@@ -173,12 +173,12 @@  discard block
 block discarded – undo
173 173
 	 *
174 174
 	 * @return array             An array of the connected logs.
175 175
 	 */
176
-	public function get_logs( $object_id = 0, $type = null, $paged = null ) {
177
-		return $this->get_connected_logs( array(
176
+	public function get_logs($object_id = 0, $type = null, $paged = null) {
177
+		return $this->get_connected_logs(array(
178 178
 			'post_parent' => $object_id,
179 179
 			'paged'       => $paged,
180 180
 			'log_type'    => $type,
181
-		) );
181
+		));
182 182
 	}
183 183
 
184 184
 	/**
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 *
193 193
 	 * @return int             The ID of the newly created log item.
194 194
 	 */
195
-	public function insert_log( $log_data = array(), $log_meta = array() ) {
195
+	public function insert_log($log_data = array(), $log_meta = array()) {
196 196
 		$defaults = array(
197 197
 			'post_type'    => 'give_log',
198 198
 			'post_status'  => 'publish',
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 			'log_type'     => false,
202 202
 		);
203 203
 
204
-		$args = wp_parse_args( $log_data, $defaults );
204
+		$args = wp_parse_args($log_data, $defaults);
205 205
 
206 206
 		/**
207 207
 		 * Fires before inserting log entry.
@@ -211,20 +211,20 @@  discard block
 block discarded – undo
211 211
 		 * @param array $log_data Log entry data.
212 212
 		 * @param array $log_meta Log entry meta.
213 213
 		 */
214
-		do_action( 'give_pre_insert_log', $log_data, $log_meta );
214
+		do_action('give_pre_insert_log', $log_data, $log_meta);
215 215
 
216 216
 		// Store the log entry
217
-		$log_id = wp_insert_post( $args );
217
+		$log_id = wp_insert_post($args);
218 218
 
219 219
 		// Set the log type, if any
220
-		if ( $log_data['log_type'] && $this->valid_type( $log_data['log_type'] ) ) {
221
-			wp_set_object_terms( $log_id, $log_data['log_type'], 'give_log_type', false );
220
+		if ($log_data['log_type'] && $this->valid_type($log_data['log_type'])) {
221
+			wp_set_object_terms($log_id, $log_data['log_type'], 'give_log_type', false);
222 222
 		}
223 223
 
224 224
 		// Set log meta, if any
225
-		if ( $log_id && ! empty( $log_meta ) ) {
226
-			foreach ( (array) $log_meta as $key => $meta ) {
227
-				update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
225
+		if ($log_id && ! empty($log_meta)) {
226
+			foreach ((array) $log_meta as $key => $meta) {
227
+				update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
228 228
 			}
229 229
 		}
230 230
 
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 		 * @param array $log_data Log entry data.
238 238
 		 * @param array $log_meta Log entry meta.
239 239
 		 */
240
-		do_action( 'give_post_insert_log', $log_id, $log_data, $log_meta );
240
+		do_action('give_post_insert_log', $log_id, $log_data, $log_meta);
241 241
 
242 242
 		return $log_id;
243 243
 	}
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 	 *
254 254
 	 * @return bool|null       True if successful, false otherwise.
255 255
 	 */
256
-	public function update_log( $log_data = array(), $log_meta = array() ) {
256
+	public function update_log($log_data = array(), $log_meta = array()) {
257 257
 
258 258
 		/**
259 259
 		 * Fires before updating log entry.
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 		 * @param array $log_data Log entry data.
264 264
 		 * @param array $log_meta Log entry meta.
265 265
 		 */
266
-		do_action( 'give_pre_update_log', $log_data, $log_meta );
266
+		do_action('give_pre_update_log', $log_data, $log_meta);
267 267
 
268 268
 		$defaults = array(
269 269
 			'post_type'   => 'give_log',
@@ -271,15 +271,15 @@  discard block
 block discarded – undo
271 271
 			'post_parent' => 0,
272 272
 		);
273 273
 
274
-		$args = wp_parse_args( $log_data, $defaults );
274
+		$args = wp_parse_args($log_data, $defaults);
275 275
 
276 276
 		// Store the log entry
277
-		$log_id = wp_update_post( $args );
277
+		$log_id = wp_update_post($args);
278 278
 
279
-		if ( $log_id && ! empty( $log_meta ) ) {
280
-			foreach ( (array) $log_meta as $key => $meta ) {
281
-				if ( ! empty( $meta ) ) {
282
-					update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
279
+		if ($log_id && ! empty($log_meta)) {
280
+			foreach ((array) $log_meta as $key => $meta) {
281
+				if ( ! empty($meta)) {
282
+					update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
283 283
 				}
284 284
 			}
285 285
 		}
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 		 * @param array $log_data Log entry data.
294 294
 		 * @param array $log_meta Log entry meta.
295 295
 		 */
296
-		do_action( 'give_post_update_log', $log_id, $log_data, $log_meta );
296
+		do_action('give_post_update_log', $log_id, $log_data, $log_meta);
297 297
 	}
298 298
 
299 299
 	/**
@@ -308,19 +308,19 @@  discard block
 block discarded – undo
308 308
 	 *
309 309
 	 * @return array|false Array if logs were found, false otherwise.
310 310
 	 */
311
-	public function get_connected_logs( $args = array() ) {
311
+	public function get_connected_logs($args = array()) {
312 312
 
313 313
 		$defaults = array(
314 314
 			'post_type'      => 'give_log',
315 315
 			'posts_per_page' => 20,
316 316
 			'post_status'    => 'publish',
317
-			'paged'          => get_query_var( 'paged' ),
317
+			'paged'          => get_query_var('paged'),
318 318
 			'log_type'       => false,
319 319
 		);
320 320
 
321
-		$query_args = wp_parse_args( $args, $defaults );
321
+		$query_args = wp_parse_args($args, $defaults);
322 322
 
323
-		if ( $query_args['log_type'] && $this->valid_type( $query_args['log_type'] ) ) {
323
+		if ($query_args['log_type'] && $this->valid_type($query_args['log_type'])) {
324 324
 			$query_args['tax_query'] = array(
325 325
 				array(
326 326
 					'taxonomy' => 'give_log_type',
@@ -330,9 +330,9 @@  discard block
 block discarded – undo
330 330
 			);
331 331
 		}
332 332
 
333
-		$logs = get_posts( $query_args );
333
+		$logs = get_posts($query_args);
334 334
 
335
-		if ( $logs ) {
335
+		if ($logs) {
336 336
 			return $logs;
337 337
 		}
338 338
 
@@ -355,17 +355,17 @@  discard block
 block discarded – undo
355 355
 	 *
356 356
 	 * @return int                Log count.
357 357
 	 */
358
-	public function get_log_count( $object_id = 0, $type = null, $meta_query = null, $date_query = null ) {
358
+	public function get_log_count($object_id = 0, $type = null, $meta_query = null, $date_query = null) {
359 359
 
360 360
 		$query_args = array(
361 361
 			'post_parent'    => $object_id,
362 362
 			'post_type'      => 'give_log',
363
-			'posts_per_page' => - 1,
363
+			'posts_per_page' => -1,
364 364
 			'post_status'    => 'publish',
365 365
 			'fields'         => 'ids',
366 366
 		);
367 367
 
368
-		if ( ! empty( $type ) && $this->valid_type( $type ) ) {
368
+		if ( ! empty($type) && $this->valid_type($type)) {
369 369
 			$query_args['tax_query'] = array(
370 370
 				array(
371 371
 					'taxonomy' => 'give_log_type',
@@ -375,25 +375,25 @@  discard block
 block discarded – undo
375 375
 			);
376 376
 		}
377 377
 
378
-		if ( ! empty( $meta_query ) ) {
378
+		if ( ! empty($meta_query)) {
379 379
 			$query_args['meta_query'] = $meta_query;
380 380
 		}
381 381
 
382
-		if ( ! empty( $date_query ) ) {
382
+		if ( ! empty($date_query)) {
383 383
 			$query_args['date_query'] = $date_query;
384 384
 		}
385 385
 
386 386
 
387 387
 		// Get cache key for current query.
388
-		$cache_key =  give_get_cache_key( 'get_log_count', $query_args );
388
+		$cache_key = give_get_cache_key('get_log_count', $query_args);
389 389
 
390 390
 		// check if cache already exist or not.
391
-		if( ! ( $logs_count = get_option( $cache_key ) ) ) {
392
-			$logs = new WP_Query( $query_args );
391
+		if ( ! ($logs_count = get_option($cache_key))) {
392
+			$logs = new WP_Query($query_args);
393 393
 			$logs_count = (int) $logs->post_count;
394 394
 
395 395
 			// Cache results.
396
-			add_option( $cache_key, $logs_count, '', 'no' );
396
+			add_option($cache_key, $logs_count, '', 'no');
397 397
 		}
398 398
 
399 399
 		return $logs_count;
@@ -413,16 +413,16 @@  discard block
 block discarded – undo
413 413
 	 *
414 414
 	 * @return void
415 415
 	 */
416
-	public function delete_logs( $object_id = 0, $type = null, $meta_query = null ) {
416
+	public function delete_logs($object_id = 0, $type = null, $meta_query = null) {
417 417
 		$query_args = array(
418 418
 			'post_parent'    => $object_id,
419 419
 			'post_type'      => 'give_log',
420
-			'posts_per_page' => - 1,
420
+			'posts_per_page' => -1,
421 421
 			'post_status'    => 'publish',
422 422
 			'fields'         => 'ids',
423 423
 		);
424 424
 
425
-		if ( ! empty( $type ) && $this->valid_type( $type ) ) {
425
+		if ( ! empty($type) && $this->valid_type($type)) {
426 426
 			$query_args['tax_query'] = array(
427 427
 				array(
428 428
 					'taxonomy' => 'give_log_type',
@@ -432,15 +432,15 @@  discard block
 block discarded – undo
432 432
 			);
433 433
 		}
434 434
 
435
-		if ( ! empty( $meta_query ) ) {
435
+		if ( ! empty($meta_query)) {
436 436
 			$query_args['meta_query'] = $meta_query;
437 437
 		}
438 438
 
439
-		$logs = get_posts( $query_args );
439
+		$logs = get_posts($query_args);
440 440
 
441
-		if ( $logs ) {
442
-			foreach ( $logs as $log ) {
443
-				wp_delete_post( $log, true );
441
+		if ($logs) {
442
+			foreach ($logs as $log) {
443
+				wp_delete_post($log, true);
444 444
 			}
445 445
 		}
446 446
 	}
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 	 *
454 454
 	 * @param int $post_id
455 455
 	 */
456
-	public function background_process_delete_cache( $post_id ) {
457
-		wp_schedule_single_event( time(), 'give_delete_log_cache' );
456
+	public function background_process_delete_cache($post_id) {
457
+		wp_schedule_single_event(time(), 'give_delete_log_cache');
458 458
 	}
459 459
 
460 460
 	/**
@@ -476,14 +476,14 @@  discard block
 block discarded – undo
476 476
 		);
477 477
 
478 478
 		// Bailout.
479
-		if( empty( $cache_option_names ) ) {
479
+		if (empty($cache_option_names)) {
480 480
 			return false;
481 481
 		}
482 482
 
483 483
 
484 484
 		// Delete log cache.
485
-		foreach ( $cache_option_names as $option_name ) {
486
-			delete_option( $option_name['option_name'] );
485
+		foreach ($cache_option_names as $option_name) {
486
+			delete_option($option_name['option_name']);
487 487
 		}
488 488
 	}
489 489
 }
@@ -506,10 +506,10 @@  discard block
 block discarded – undo
506 506
  *
507 507
  * @return int             ID of the new log entry.
508 508
  */
509
-function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) {
509
+function give_record_log($title = '', $message = '', $parent = 0, $type = null) {
510 510
 	/* @var Give_Logging $give_logs */
511 511
 	global $give_logs;
512
-	$log = $give_logs->add( $title, $message, $parent, $type );
512
+	$log = $give_logs->add($title, $message, $parent, $type);
513 513
 
514 514
 	return $log;
515 515
 }
Please login to merge, or discard this patch.
includes/class-give-cli-commands.php 1 patch
Spacing   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // Exit if accessed directly.
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if ( ! defined('ABSPATH')) {
11 11
 	exit;
12 12
 }
13 13
 
14 14
 // Add give command.
15
-WP_CLI::add_command( 'give', 'GIVE_CLI_COMMAND' );
15
+WP_CLI::add_command('give', 'GIVE_CLI_COMMAND');
16 16
 
17 17
 
18 18
 /**
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @subcommand    logo
70 70
 	 */
71
-	public function ascii( $args, $assoc_args ) {
72
-		WP_CLI::log( file_get_contents( GIVE_PLUGIN_DIR . 'assets/images/give-ascii-logo.txt' ) );
71
+	public function ascii($args, $assoc_args) {
72
+		WP_CLI::log(file_get_contents(GIVE_PLUGIN_DIR.'assets/images/give-ascii-logo.txt'));
73 73
 	}
74 74
 
75 75
 
@@ -94,54 +94,54 @@  discard block
 block discarded – undo
94 94
 	 *
95 95
 	 * @subcommand    details
96 96
 	 */
97
-	public function details( $args, $assoc_args ) {
97
+	public function details($args, $assoc_args) {
98 98
 
99 99
 		/**
100 100
 		 * Plugin Information
101 101
 		 */
102
-		WP_CLI::log( $this->color_message( __( 'Give Version: ', 'give' ) ) . GIVE_VERSION );
102
+		WP_CLI::log($this->color_message(__('Give Version: ', 'give')).GIVE_VERSION);
103 103
 
104 104
 		/**
105 105
 		 * General Information.
106 106
 		 */
107
-		WP_CLI::log( "\n####   " . $this->color_message( __( 'General information', 'give' ) ) . '   ####' );
107
+		WP_CLI::log("\n####   ".$this->color_message(__('General information', 'give')).'   ####');
108 108
 
109
-		$success_page = give_get_option( 'success_page' );
110
-		$failure_page = give_get_option( 'failure_page' );
111
-		$history_page = give_get_option( 'history_page' );
109
+		$success_page = give_get_option('success_page');
110
+		$failure_page = give_get_option('failure_page');
111
+		$history_page = give_get_option('history_page');
112 112
 
113
-		WP_CLI::log( $this->color_message( sprintf( __( 'Success Page: ', 'give' ) ) ) . ( $success_page ? "[{$success_page}] " . get_permalink( $success_page ) : __( 'Not Set', 'give' ) ) );
114
-		WP_CLI::log( $this->color_message( __( 'Failed Donation Page: ', 'give' ) ) . ( $failure_page ? "[{$failure_page}] " . get_permalink( $failure_page ) : __( 'Not Set', 'give' ) ) );
115
-		WP_CLI::log( $this->color_message( __( 'Donation History Page: ', 'give' ) ) . ( $history_page ? "[{$history_page}] " . get_permalink( $history_page ) : __( 'Not Set', 'give' ) ) );
116
-		WP_CLI::log( $this->color_message( __( 'Country: ', 'give' ) ) . give_get_country() );
113
+		WP_CLI::log($this->color_message(sprintf(__('Success Page: ', 'give'))).($success_page ? "[{$success_page}] ".get_permalink($success_page) : __('Not Set', 'give')));
114
+		WP_CLI::log($this->color_message(__('Failed Donation Page: ', 'give')).($failure_page ? "[{$failure_page}] ".get_permalink($failure_page) : __('Not Set', 'give')));
115
+		WP_CLI::log($this->color_message(__('Donation History Page: ', 'give')).($history_page ? "[{$history_page}] ".get_permalink($history_page) : __('Not Set', 'give')));
116
+		WP_CLI::log($this->color_message(__('Country: ', 'give')).give_get_country());
117 117
 
118 118
 		/**
119 119
 		 * Currency Information.
120 120
 		 */
121
-		$default_gateway = give_get_option( 'default_gateway' );
121
+		$default_gateway = give_get_option('default_gateway');
122 122
 
123
-		WP_CLI::log( "\n####   " . $this->color_message( __( 'Currency Information', 'give' ) ) . '   ####' );
123
+		WP_CLI::log("\n####   ".$this->color_message(__('Currency Information', 'give')).'   ####');
124 124
 
125
-		WP_CLI::log( $this->color_message( __( 'Currency: ', 'give' ), give_get_currency() ) );
126
-		WP_CLI::log( $this->color_message( __( 'Currency Position: ', 'give' ), give_get_currency_position() ) );
127
-		WP_CLI::log( $this->color_message( __( 'Thousand Separator: ', 'give' ), give_get_price_thousand_separator() ) );
128
-		WP_CLI::log( $this->color_message( __( 'Decimal Separator: ', 'give' ), give_get_price_decimal_separator() ) );
129
-		WP_CLI::log( $this->color_message( __( 'Number of Decimals: ', 'give' ), give_get_price_decimals() ) );
130
-		WP_CLI::log( $this->color_message( __( 'Test Mode: ', 'give' ), ( give_get_option( 'test_mode' ) ? __( 'Yes', 'give' ) : __( 'No', 'give' ) ) ) );
131
-		WP_CLI::log( $this->color_message( __( 'Default Gateway: ', 'give' ), ( $default_gateway ? $default_gateway : __( 'Not Set', 'give' ) ) ) );
125
+		WP_CLI::log($this->color_message(__('Currency: ', 'give'), give_get_currency()));
126
+		WP_CLI::log($this->color_message(__('Currency Position: ', 'give'), give_get_currency_position()));
127
+		WP_CLI::log($this->color_message(__('Thousand Separator: ', 'give'), give_get_price_thousand_separator()));
128
+		WP_CLI::log($this->color_message(__('Decimal Separator: ', 'give'), give_get_price_decimal_separator()));
129
+		WP_CLI::log($this->color_message(__('Number of Decimals: ', 'give'), give_get_price_decimals()));
130
+		WP_CLI::log($this->color_message(__('Test Mode: ', 'give'), (give_get_option('test_mode') ? __('Yes', 'give') : __('No', 'give'))));
131
+		WP_CLI::log($this->color_message(__('Default Gateway: ', 'give'), ($default_gateway ? $default_gateway : __('Not Set', 'give'))));
132 132
 
133 133
 		// Payment gateways Information.
134
-		$gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() );
135
-		WP_CLI::log( $this->color_message( __( 'Enabled Gateways: ', 'give' ) ) );
134
+		$gateways = give_get_ordered_payment_gateways(give_get_payment_gateways());
135
+		WP_CLI::log($this->color_message(__('Enabled Gateways: ', 'give')));
136 136
 
137
-		if ( ! empty( $gateways ) ) {
137
+		if ( ! empty($gateways)) {
138 138
 			self::$counter = 1;
139
-			foreach ( $gateways as $gateway ) {
140
-				WP_CLI::log( '  ' . $this->color_message( self::$counter, $gateway['admin_label'] ) );
141
-				self::$counter ++;
139
+			foreach ($gateways as $gateway) {
140
+				WP_CLI::log('  '.$this->color_message(self::$counter, $gateway['admin_label']));
141
+				self::$counter++;
142 142
 			}
143 143
 		} else {
144
-			WP_CLI::log( __( 'Not any payment gateways found', 'give' ) );
144
+			WP_CLI::log(__('Not any payment gateways found', 'give'));
145 145
 		}
146 146
 	}
147 147
 
@@ -173,15 +173,15 @@  discard block
 block discarded – undo
173 173
 	 *
174 174
 	 * @subcommand    forms
175 175
 	 */
176
-	public function forms( $args, $assoc_args ) {
176
+	public function forms($args, $assoc_args) {
177 177
 		global $wp_query;
178
-		$form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false;
179
-		$number  = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? absint( $assoc_args['number'] ) : 10;
178
+		$form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false;
179
+		$number  = isset($assoc_args) && array_key_exists('number', $assoc_args) ? absint($assoc_args['number']) : 10;
180 180
 		$start   = time();
181 181
 
182 182
 		// Cache previous number query var.
183 183
 		$is_set_number = $cache_per_page = false;
184
-		if ( isset( $wp_query->query_vars['number'] ) ) {
184
+		if (isset($wp_query->query_vars['number'])) {
185 185
 			$cache_per_page = $wp_query->query_vars['number'];
186 186
 			$is_set_number  = true;
187 187
 		}
@@ -190,22 +190,22 @@  discard block
 block discarded – undo
190 190
 		$wp_query->query_vars['number'] = $number;
191 191
 
192 192
 		// Get forms.
193
-		$forms = $form_id ? $this->api->get_forms( $form_id ) : $this->api->get_forms();
193
+		$forms = $form_id ? $this->api->get_forms($form_id) : $this->api->get_forms();
194 194
 
195 195
 		// Reset number query var.
196
-		if ( $is_set_number ) {
196
+		if ($is_set_number) {
197 197
 			$wp_query->query_vars['number'] = $cache_per_page;
198 198
 		}
199 199
 
200 200
 		// Bailout.
201
-		if ( array_key_exists( 'error', $forms ) ) {
201
+		if (array_key_exists('error', $forms)) {
202 202
 
203
-			WP_CLI::warning( $forms['error'] );
203
+			WP_CLI::warning($forms['error']);
204 204
 
205 205
 			return;
206
-		} elseif ( empty( $forms['forms'] ) ) {
206
+		} elseif (empty($forms['forms'])) {
207 207
 
208
-			WP_CLI::error( __( 'No forms found.', 'give' ) );
208
+			WP_CLI::error(__('No forms found.', 'give'));
209 209
 
210 210
 			return;
211 211
 		}
@@ -213,25 +213,25 @@  discard block
 block discarded – undo
213 213
 		// Param to check if form typeis already showed or not.
214 214
 		$is_show_form_type = false;
215 215
 
216
-		if ( 1 === count( $forms ) && $form_id ) {
216
+		if (1 === count($forms) && $form_id) {
217 217
 			// Show single form.
218
-			foreach ( $forms['forms'][0] as $key => $info ) {
219
-				switch ( $key ) {
218
+			foreach ($forms['forms'][0] as $key => $info) {
219
+				switch ($key) {
220 220
 					case 'stats':
221
-						$this->color_main_heading( ucfirst( $key ) );
221
+						$this->color_main_heading(ucfirst($key));
222 222
 
223
-						foreach ( $info as $heading => $data ) {
224
-							$this->color_sub_heading( ucfirst( $heading ) );
225
-							switch ( $heading ) {
223
+						foreach ($info as $heading => $data) {
224
+							$this->color_sub_heading(ucfirst($heading));
225
+							switch ($heading) {
226 226
 								default:
227
-									foreach ( $data as $subheading => $subdata ) {
227
+									foreach ($data as $subheading => $subdata) {
228 228
 
229
-										switch ( $subheading ) {
229
+										switch ($subheading) {
230 230
 											case 'earnings':
231
-												WP_CLI::log( $this->color_message( $subheading . ': ', give_currency_filter( $subdata ) ) );
231
+												WP_CLI::log($this->color_message($subheading.': ', give_currency_filter($subdata)));
232 232
 												break;
233 233
 											default:
234
-												WP_CLI::log( $this->color_message( $subheading . ': ', $subdata ) );
234
+												WP_CLI::log($this->color_message($subheading.': ', $subdata));
235 235
 										}
236 236
 									}
237 237
 							}
@@ -241,26 +241,26 @@  discard block
 block discarded – undo
241 241
 					case 'pricing':
242 242
 					case 'info':
243 243
 					default:
244
-						$this->color_main_heading( ucfirst( $key ) );
244
+						$this->color_main_heading(ucfirst($key));
245 245
 
246 246
 						// Show form type.
247
-						if ( ! $is_show_form_type ) {
248
-							$form              = new Give_Donate_Form( $form_id );
247
+						if ( ! $is_show_form_type) {
248
+							$form              = new Give_Donate_Form($form_id);
249 249
 							$is_show_form_type = true;
250 250
 
251
-							WP_CLI::log( $this->color_message( __( 'form type', 'give' ), $form->get_type() ) );
251
+							WP_CLI::log($this->color_message(__('form type', 'give'), $form->get_type()));
252 252
 						}
253 253
 
254
-						foreach ( $info as $heading => $data ) {
254
+						foreach ($info as $heading => $data) {
255 255
 
256
-							switch ( $heading ) {
256
+							switch ($heading) {
257 257
 								case 'id':
258
-									WP_CLI::log( $this->color_message( $heading, $data ) );
258
+									WP_CLI::log($this->color_message($heading, $data));
259 259
 									break;
260 260
 
261 261
 								default:
262
-									$data = empty( $data ) ? __( 'Not set', 'give' ) : $data;
263
-									WP_CLI::log( $this->color_message( $heading, $data ) );
262
+									$data = empty($data) ? __('Not set', 'give') : $data;
263
+									WP_CLI::log($this->color_message($heading, $data));
264 264
 							}
265 265
 						}
266 266
 				}
@@ -271,37 +271,37 @@  discard block
 block discarded – undo
271 271
 			$is_table_first_row_set = false;
272 272
 			$table_column_count     = 0;
273 273
 
274
-			WP_CLI::line( $this->color_message( sprintf( __( '%d donation forms found', 'give' ), count( $forms['forms'] ) ), '', false ) );
274
+			WP_CLI::line($this->color_message(sprintf(__('%d donation forms found', 'give'), count($forms['forms'])), '', false));
275 275
 
276
-			foreach ( $forms['forms'] as $index => $form_data ) {
276
+			foreach ($forms['forms'] as $index => $form_data) {
277 277
 
278 278
 				// Default table data.
279 279
 				$table_first_row = array();
280 280
 				$table_row       = array();
281 281
 
282
-				foreach ( $form_data['info'] as $key => $form ) {
282
+				foreach ($form_data['info'] as $key => $form) {
283 283
 
284 284
 					// Do not show thumbnail, content and link in table.
285
-					if ( in_array( $key, array( 'content', 'thumbnail', 'link' ), true ) ) {
285
+					if (in_array($key, array('content', 'thumbnail', 'link'), true)) {
286 286
 						continue;
287 287
 					}
288 288
 
289
-					if ( ! $is_table_first_row_set ) {
289
+					if ( ! $is_table_first_row_set) {
290 290
 						$table_first_row[] = $key;
291 291
 					}
292 292
 
293 293
 					$table_row[] = $form;
294 294
 
295
-					if ( 'status' === $key ) {
295
+					if ('status' === $key) {
296 296
 						// First array item will be an form id in our case.
297
-						$form = new Give_Donate_Form( absint( $table_row[0] ) );
297
+						$form = new Give_Donate_Form(absint($table_row[0]));
298 298
 
299 299
 						$table_row[] = $form->get_type();
300 300
 					}
301 301
 				}
302 302
 
303 303
 				// Set table first row.
304
-				if ( ! $is_table_first_row_set ) {
304
+				if ( ! $is_table_first_row_set) {
305 305
 
306 306
 					// Add extra column to table.
307 307
 					$table_first_row[] = 'type';
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 				$table_data[] = $table_row;
315 315
 			}
316 316
 
317
-			$this->display_table( $table_data );
317
+			$this->display_table($table_data);
318 318
 		}
319 319
 	}
320 320
 
@@ -366,37 +366,37 @@  discard block
 block discarded – undo
366 366
 	 *
367 367
 	 * @subcommand    donors
368 368
 	 */
369
-	public function donors( $args, $assoc_args ) {
369
+	public function donors($args, $assoc_args) {
370 370
 		global $wp_query;
371
-		$donor_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false;
372
-		$email    = isset( $assoc_args ) && array_key_exists( 'email', $assoc_args ) ? $assoc_args['email'] : false;
373
-		$name     = isset( $assoc_args ) && array_key_exists( 'name', $assoc_args ) ? $assoc_args['name'] : '';
374
-		$create   = isset( $assoc_args ) && array_key_exists( 'create', $assoc_args ) ? $assoc_args['create'] : false;
375
-		$number   = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10;
376
-		$form_id  = isset( $assoc_args ) && array_key_exists( 'form-id', $assoc_args ) ? $assoc_args['form-id'] : 0;
377
-		$format   = isset( $assoc_args ) && array_key_exists( 'format', $assoc_args ) ? $assoc_args['format'] : 'table';
371
+		$donor_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false;
372
+		$email    = isset($assoc_args) && array_key_exists('email', $assoc_args) ? $assoc_args['email'] : false;
373
+		$name     = isset($assoc_args) && array_key_exists('name', $assoc_args) ? $assoc_args['name'] : '';
374
+		$create   = isset($assoc_args) && array_key_exists('create', $assoc_args) ? $assoc_args['create'] : false;
375
+		$number   = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10;
376
+		$form_id  = isset($assoc_args) && array_key_exists('form-id', $assoc_args) ? $assoc_args['form-id'] : 0;
377
+		$format   = isset($assoc_args) && array_key_exists('format', $assoc_args) ? $assoc_args['format'] : 'table';
378 378
 		$start    = time();
379 379
 
380
-		if ( $create ) {
380
+		if ($create) {
381 381
 			$number = 1;
382 382
 
383
-			if ( isset( $assoc_args['email'] ) && ! is_email( $email ) ) {
384
-				WP_CLI::warning( 'Wrong email address provided.', 'give' );
383
+			if (isset($assoc_args['email']) && ! is_email($email)) {
384
+				WP_CLI::warning('Wrong email address provided.', 'give');
385 385
 
386 386
 				return;
387 387
 			}
388 388
 
389 389
 			// Create one or more donors.
390
-			if ( ! $email ) {
390
+			if ( ! $email) {
391 391
 				// If no email is specified, look to see if we are generating arbitrary donor accounts.
392
-				$number = is_numeric( $create ) ? absint( $create ) : 1;
392
+				$number = is_numeric($create) ? absint($create) : 1;
393 393
 			}
394 394
 
395
-			for ( $i = 0; $i < $number; $i ++ ) {
396
-				if ( ! $email ) {
395
+			for ($i = 0; $i < $number; $i++) {
396
+				if ( ! $email) {
397 397
 
398 398
 					// Generate fake email.
399
-					$email = 'customer-' . uniqid() . '@test.com';
399
+					$email = 'customer-'.uniqid().'@test.com';
400 400
 				}
401 401
 
402 402
 				$args = array(
@@ -404,19 +404,19 @@  discard block
 block discarded – undo
404 404
 					'name'  => $name,
405 405
 				);
406 406
 
407
-				$customer_id = Give()->customers->add( $args );
407
+				$customer_id = Give()->customers->add($args);
408 408
 
409
-				if ( $customer_id ) {
410
-					WP_CLI::line( $this->color_message( sprintf( __( 'Donor #%d created successfully', 'give' ), $customer_id ) ) );
409
+				if ($customer_id) {
410
+					WP_CLI::line($this->color_message(sprintf(__('Donor #%d created successfully', 'give'), $customer_id)));
411 411
 				} else {
412
-					WP_CLI::error( __( 'Failed to create donor', 'give' ) );
412
+					WP_CLI::error(__('Failed to create donor', 'give'));
413 413
 				}
414 414
 
415 415
 				// Reset email to false so it is generated on the next loop (if creating donors).
416 416
 				$email = false;
417 417
 			}
418 418
 
419
-			WP_CLI::line( $this->color_message( sprintf( __( '%1$d donors created in %2$d seconds', 'give' ), $number, time() - $start ) ) );
419
+			WP_CLI::line($this->color_message(sprintf(__('%1$d donors created in %2$d seconds', 'give'), $number, time() - $start)));
420 420
 
421 421
 		} else {
422 422
 			// Counter.
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 			 */
431 431
 			// Cache previous number query var.
432 432
 			$is_set_number = $cache_per_page = false;
433
-			if ( isset( $wp_query->query_vars['number'] ) ) {
433
+			if (isset($wp_query->query_vars['number'])) {
434 434
 				$cache_per_page = $wp_query->query_vars['number'];
435 435
 				$is_set_number  = true;
436 436
 			}
@@ -439,24 +439,24 @@  discard block
 block discarded – undo
439 439
 			$wp_query->query_vars['number'] = $number;
440 440
 
441 441
 			// Get donors.
442
-			if ( $form_id ) {
442
+			if ($form_id) {
443 443
 				// @TODO: Allow user to get a list of donors by donation status.
444
-				$donors = $this->get_donors_by_form_id( $form_id );
444
+				$donors = $this->get_donors_by_form_id($form_id);
445 445
 			} else {
446
-				$donors = $this->api->get_customers( $search );
446
+				$donors = $this->api->get_customers($search);
447 447
 			}
448 448
 
449 449
 			// Reset number query var.
450
-			if ( $is_set_number ) {
450
+			if ($is_set_number) {
451 451
 				$wp_query->query_vars['number'] = $cache_per_page;
452 452
 			}
453 453
 
454
-			if ( isset( $donors['error'] ) ) {
455
-				WP_CLI::error( $donors['error'] );
454
+			if (isset($donors['error'])) {
455
+				WP_CLI::error($donors['error']);
456 456
 			}
457 457
 
458
-			if ( empty( $donors ) ) {
459
-				WP_CLI::error( __( 'No donors found.', 'give' ) );
458
+			if (empty($donors)) {
459
+				WP_CLI::error(__('No donors found.', 'give'));
460 460
 
461 461
 				return;
462 462
 			}
@@ -464,24 +464,24 @@  discard block
 block discarded – undo
464 464
 			$table_data             = array();
465 465
 			$is_table_first_row_set = false;
466 466
 
467
-			foreach ( $donors['donors'] as $donor_data ) {
467
+			foreach ($donors['donors'] as $donor_data) {
468 468
 				// Set default table row data.
469
-				$table_first_row = array( __( 's_no', 'give' ) );
470
-				$table_row       = array( self::$counter );
469
+				$table_first_row = array(__('s_no', 'give'));
470
+				$table_row       = array(self::$counter);
471 471
 
472
-				foreach ( $donor_data as $key => $donor ) {
473
-					switch ( $key ) {
472
+				foreach ($donor_data as $key => $donor) {
473
+					switch ($key) {
474 474
 						case 'stats':
475
-							foreach ( $donor as $heading => $data ) {
475
+							foreach ($donor as $heading => $data) {
476 476
 
477 477
 								// Get first row.
478
-								if ( ! $is_table_first_row_set ) {
478
+								if ( ! $is_table_first_row_set) {
479 479
 									$table_first_row[] = $heading;
480 480
 								}
481 481
 
482
-								switch ( $heading ) {
482
+								switch ($heading) {
483 483
 									case 'total_spent':
484
-										$table_row[] = give_currency_filter( $data );
484
+										$table_row[] = give_currency_filter($data);
485 485
 										break;
486 486
 
487 487
 									default:
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
 
493 493
 						case 'info':
494 494
 						default:
495
-							foreach ( $donor as $heading => $data ) {
495
+							foreach ($donor as $heading => $data) {
496 496
 
497 497
 								// Get first row.
498
-								if ( ! $is_table_first_row_set ) {
498
+								if ( ! $is_table_first_row_set) {
499 499
 									$table_first_row[] = $heading;
500 500
 								}
501 501
 
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 				}
506 506
 
507 507
 				// Add first row data to table data.
508
-				if ( ! $is_table_first_row_set ) {
508
+				if ( ! $is_table_first_row_set) {
509 509
 					$table_data[]           = $table_first_row;
510 510
 					$is_table_first_row_set = true;
511 511
 				}
@@ -514,44 +514,44 @@  discard block
 block discarded – undo
514 514
 				$table_data[] = $table_row;
515 515
 
516 516
 				// Increase counter.
517
-				self::$counter ++;
517
+				self::$counter++;
518 518
 			}
519 519
 
520
-			switch ( $format ) {
520
+			switch ($format) {
521 521
 				case 'json':
522 522
 					$table_column_name = $table_data[0];
523
-					unset( $table_data[0] );
523
+					unset($table_data[0]);
524 524
 
525 525
 					$new_table_data = array();
526
-					foreach ( $table_data as $index => $data ) {
527
-						foreach ( $data as $key => $value ) {
528
-							$new_table_data[ $index ][ $table_column_name[ $key ] ] = $value;
526
+					foreach ($table_data as $index => $data) {
527
+						foreach ($data as $key => $value) {
528
+							$new_table_data[$index][$table_column_name[$key]] = $value;
529 529
 						}
530 530
 					}
531 531
 
532
-					WP_CLI::log( json_encode( $new_table_data ) );
532
+					WP_CLI::log(json_encode($new_table_data));
533 533
 					break;
534 534
 
535 535
 				case 'csv':
536
-					$file_path = trailingslashit( WP_CONTENT_DIR ) . 'uploads/give_donors_' . date( 'Y_m_d_s', current_time( 'timestamp' ) ) . '.csv';
537
-					$fp        = fopen( $file_path, 'w' );
536
+					$file_path = trailingslashit(WP_CONTENT_DIR).'uploads/give_donors_'.date('Y_m_d_s', current_time('timestamp')).'.csv';
537
+					$fp        = fopen($file_path, 'w');
538 538
 
539
-					if ( is_writable( $file_path ) ) {
540
-						foreach ( $table_data as $fields ) {
541
-							fputcsv( $fp, $fields );
539
+					if (is_writable($file_path)) {
540
+						foreach ($table_data as $fields) {
541
+							fputcsv($fp, $fields);
542 542
 						}
543 543
 
544
-						fclose( $fp );
544
+						fclose($fp);
545 545
 
546
-						WP_CLI::success( "Donors list csv created successfully: {$file_path}" );
546
+						WP_CLI::success("Donors list csv created successfully: {$file_path}");
547 547
 					} else {
548
-						WP_CLI::warning( "Unable to create donors list csv file: {$file_path} (May folder do not have write permission)" );
548
+						WP_CLI::warning("Unable to create donors list csv file: {$file_path} (May folder do not have write permission)");
549 549
 					}
550 550
 
551 551
 					break;
552 552
 
553 553
 				default:
554
-					$this->display_table( $table_data );
554
+					$this->display_table($table_data);
555 555
 			}
556 556
 		}
557 557
 	}
@@ -581,13 +581,13 @@  discard block
 block discarded – undo
581 581
 	 *
582 582
 	 * @subcommand    donations
583 583
 	 */
584
-	public function donations( $args, $assoc_args ) {
584
+	public function donations($args, $assoc_args) {
585 585
 		global $wp_query;
586
-		$number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10;
586
+		$number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10;
587 587
 
588 588
 		// Cache previous number query var.
589 589
 		$is_set_number = $cache_per_page = false;
590
-		if ( isset( $wp_query->query_vars['number'] ) ) {
590
+		if (isset($wp_query->query_vars['number'])) {
591 591
 			$cache_per_page = $wp_query->query_vars['number'];
592 592
 			$is_set_number  = true;
593 593
 		}
@@ -599,46 +599,46 @@  discard block
 block discarded – undo
599 599
 		$donations = $this->api->get_recent_donations();
600 600
 
601 601
 		// Reset number query var.
602
-		if ( $is_set_number ) {
602
+		if ($is_set_number) {
603 603
 			$wp_query->query_vars['number'] = $cache_per_page;
604 604
 		}
605 605
 
606
-		if ( empty( $donations ) ) {
607
-			WP_CLI::error( __( 'No donations found.', 'give' ) );
606
+		if (empty($donations)) {
607
+			WP_CLI::error(__('No donations found.', 'give'));
608 608
 
609 609
 			return;
610 610
 		}
611 611
 
612 612
 		self::$counter = 1;
613 613
 
614
-		foreach ( $donations['donations'] as $key => $donation ) {
615
-			$this->color_main_heading( sprintf( __( '%1$s. Donation #%2$s', 'give' ), self::$counter, $donation['ID'] ), 'Y' );
616
-			self::$counter ++;
614
+		foreach ($donations['donations'] as $key => $donation) {
615
+			$this->color_main_heading(sprintf(__('%1$s. Donation #%2$s', 'give'), self::$counter, $donation['ID']), 'Y');
616
+			self::$counter++;
617 617
 
618
-			foreach ( $donation as $column => $data ) {
618
+			foreach ($donation as $column => $data) {
619 619
 
620
-				if ( is_array( $data ) ) {
621
-					$this->color_sub_heading( $column );
622
-					foreach ( $data as $subcolumn => $subdata ) {
620
+				if (is_array($data)) {
621
+					$this->color_sub_heading($column);
622
+					foreach ($data as $subcolumn => $subdata) {
623 623
 
624 624
 						// Decode html codes.
625
-						switch ( $subcolumn ) {
625
+						switch ($subcolumn) {
626 626
 							case 'name':
627
-								$subdata = html_entity_decode( $subdata );
627
+								$subdata = html_entity_decode($subdata);
628 628
 								break;
629 629
 						}
630 630
 
631 631
 						// @TODO Check if multi dimension array information is importent to show or not. For example inside donation array we have array for fees data inside payment meta.
632
-						if ( is_array( $subdata ) ) {
632
+						if (is_array($subdata)) {
633 633
 							continue;
634 634
 						}
635 635
 
636
-						WP_CLI::log( $this->color_message( $subcolumn, $subdata ) );
636
+						WP_CLI::log($this->color_message($subcolumn, $subdata));
637 637
 					}
638 638
 					continue;
639 639
 				}
640 640
 
641
-				WP_CLI::log( $this->color_message( $column, $data ) );
641
+				WP_CLI::log($this->color_message($column, $data));
642 642
 			}
643 643
 		}
644 644
 	}
@@ -677,27 +677,27 @@  discard block
 block discarded – undo
677 677
 	 *
678 678
 	 * @return        void
679 679
 	 */
680
-	public function report( $args, $assoc_args ) {
680
+	public function report($args, $assoc_args) {
681 681
 		$stats      = new Give_Payment_Stats();
682
-		$date       = isset( $assoc_args ) && array_key_exists( 'date', $assoc_args ) ? $assoc_args['date'] : false;
683
-		$start_date = isset( $assoc_args ) && array_key_exists( 'start-date', $assoc_args ) ? $assoc_args['start-date'] : false;
684
-		$end_date   = isset( $assoc_args ) && array_key_exists( 'end-date', $assoc_args ) ? $assoc_args['end-date'] : false;
685
-		$form_id    = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? $assoc_args['id'] : 0;
682
+		$date       = isset($assoc_args) && array_key_exists('date', $assoc_args) ? $assoc_args['date'] : false;
683
+		$start_date = isset($assoc_args) && array_key_exists('start-date', $assoc_args) ? $assoc_args['start-date'] : false;
684
+		$end_date   = isset($assoc_args) && array_key_exists('end-date', $assoc_args) ? $assoc_args['end-date'] : false;
685
+		$form_id    = isset($assoc_args) && array_key_exists('id', $assoc_args) ? $assoc_args['id'] : 0;
686 686
 
687
-		if ( ! empty( $date ) ) {
687
+		if ( ! empty($date)) {
688 688
 			$start_date = $date;
689 689
 			$end_date   = false;
690
-		} elseif ( empty( $date ) && empty( $start_date ) ) {
690
+		} elseif (empty($date) && empty($start_date)) {
691 691
 			$start_date = 'this_month';
692 692
 			$end_date   = false;
693 693
 		}
694 694
 
695 695
 		// Get stats.
696
-		$earnings = $stats->get_earnings( $form_id, $start_date, $end_date );
697
-		$sales    = $stats->get_sales( $form_id, $start_date, $end_date );
696
+		$earnings = $stats->get_earnings($form_id, $start_date, $end_date);
697
+		$sales    = $stats->get_sales($form_id, $start_date, $end_date);
698 698
 
699
-		WP_CLI::line( $this->color_message( __( 'Earnings', 'give' ), give_currency_filter( $earnings ) ) );
700
-		WP_CLI::line( $this->color_message( __( 'Sales', 'give' ), $sales ) );
699
+		WP_CLI::line($this->color_message(__('Earnings', 'give'), give_currency_filter($earnings)));
700
+		WP_CLI::line($this->color_message(__('Sales', 'give'), $sales));
701 701
 	}
702 702
 
703 703
 
@@ -724,27 +724,27 @@  discard block
 block discarded – undo
724 724
 	 *
725 725
 	 * @subcommand    cache
726 726
 	 */
727
-	public function cache( $args, $assoc_args ) {
728
-		$action = isset( $assoc_args ) && array_key_exists( 'action', $assoc_args ) ? $assoc_args['action'] : false;
727
+	public function cache($args, $assoc_args) {
728
+		$action = isset($assoc_args) && array_key_exists('action', $assoc_args) ? $assoc_args['action'] : false;
729 729
 
730 730
 		// Bailout.
731
-		if ( ! $action || ! in_array( $action, array( 'delete' ), true ) ) {
732
-			WP_CLI::warning( __( 'Type wp give cache --action=delete to delete all stat transients', 'give' ) );
731
+		if ( ! $action || ! in_array($action, array('delete'), true)) {
732
+			WP_CLI::warning(__('Type wp give cache --action=delete to delete all stat transients', 'give'));
733 733
 
734 734
 			return;
735 735
 		}
736 736
 
737
-		switch ( $action ) {
737
+		switch ($action) {
738 738
 			case 'delete' :
739 739
 				// Reset counter.
740 740
 				self::$counter = 1;
741 741
 
742
-				if ( $this->delete_stats_transients() ) {
742
+				if ($this->delete_stats_transients()) {
743 743
 					// Report .eading.
744
-					WP_CLI::success( 'Give cache deleted.' );
744
+					WP_CLI::success('Give cache deleted.');
745 745
 				} else {
746 746
 					// Report .eading.
747
-					WP_CLI::warning( 'We did not find any Give plugin cache to delete :)' );
747
+					WP_CLI::warning('We did not find any Give plugin cache to delete :)');
748 748
 				}
749 749
 				break;
750 750
 		}
@@ -773,27 +773,27 @@  discard block
 block discarded – undo
773 773
 			ARRAY_A
774 774
 		);
775 775
 
776
-		if ( ! empty( $stat_option_names ) ) {
776
+		if ( ! empty($stat_option_names)) {
777 777
 
778
-			foreach ( $stat_option_names as $option_name ) {
778
+			foreach ($stat_option_names as $option_name) {
779 779
 				$error       = false;
780 780
 				$option_name = $option_name['option_name'];
781 781
 
782
-				switch ( true ) {
783
-					case ( false !== strpos( $option_name, 'transient' ) ):
784
-						$option_name = str_replace( '_transient_', '', $option_name );
785
-						$error       = delete_transient( $option_name );
782
+				switch (true) {
783
+					case (false !== strpos($option_name, 'transient')):
784
+						$option_name = str_replace('_transient_', '', $option_name);
785
+						$error       = delete_transient($option_name);
786 786
 						break;
787 787
 
788 788
 					default:
789
-						$error = delete_option( $option_name );
789
+						$error = delete_option($option_name);
790 790
 				}
791 791
 
792
-				if ( $error ) {
793
-					WP_CLI::log( $this->color_message( self::$counter, $option_name ) );
794
-					self::$counter ++;
792
+				if ($error) {
793
+					WP_CLI::log($this->color_message(self::$counter, $option_name));
794
+					self::$counter++;
795 795
 				} else {
796
-					WP_CLI::log( $this->color_message( __( 'Error while deleting this transient', 'give' ), $option_name ) );
796
+					WP_CLI::log($this->color_message(__('Error while deleting this transient', 'give'), $option_name));
797 797
 				}
798 798
 			}
799 799
 
@@ -814,13 +814,13 @@  discard block
 block discarded – undo
814 814
 	 *
815 815
 	 * @return    mixed
816 816
 	 */
817
-	private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) {
817
+	private function color_message($heading, $message = '', $colon = true, $color = 'g') {
818 818
 		// Add colon.
819
-		if ( $colon ) {
820
-			$heading = $heading . ': ';
819
+		if ($colon) {
820
+			$heading = $heading.': ';
821 821
 		}
822 822
 
823
-		return WP_CLI::colorize( "%{$color}" . $heading . '%n' ) . $message;
823
+		return WP_CLI::colorize("%{$color}".$heading.'%n').$message;
824 824
 	}
825 825
 
826 826
 
@@ -835,8 +835,8 @@  discard block
 block discarded – undo
835 835
 	 *
836 836
 	 * @return    void
837 837
 	 */
838
-	private function color_main_heading( $heading, $color = 'g' ) {
839
-		WP_CLI::log( "\n######   " . $this->color_message( $heading, '', false, $color ) . '   ######' );
838
+	private function color_main_heading($heading, $color = 'g') {
839
+		WP_CLI::log("\n######   ".$this->color_message($heading, '', false, $color).'   ######');
840 840
 	}
841 841
 
842 842
 	/**
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
 	 *
850 850
 	 * @return    void
851 851
 	 */
852
-	private function color_sub_heading( $subheading ) {
853
-		WP_CLI::log( "\n--->" . $subheading . '', '', false );
852
+	private function color_sub_heading($subheading) {
853
+		WP_CLI::log("\n--->".$subheading.'', '', false);
854 854
 	}
855 855
 
856 856
 
@@ -864,17 +864,17 @@  discard block
 block discarded – undo
864 864
 	 *
865 865
 	 * @return    void
866 866
 	 */
867
-	private function display_table( $data ) {
867
+	private function display_table($data) {
868 868
 		$table = new \cli\Table();
869 869
 
870 870
 		// Set table header.
871
-		$table->setHeaders( $data[0] );
871
+		$table->setHeaders($data[0]);
872 872
 
873 873
 		// Remove table header.
874
-		unset( $data[0] );
874
+		unset($data[0]);
875 875
 
876 876
 		// Set table data.
877
-		$table->setRows( $data );
877
+		$table->setRows($data);
878 878
 
879 879
 		// Display table.
880 880
 		$table->display();
@@ -891,14 +891,14 @@  discard block
 block discarded – undo
891 891
 	 * @return array
892 892
 	 */
893 893
 
894
-	private function get_donors_by_form_id( $form_id ) {
894
+	private function get_donors_by_form_id($form_id) {
895 895
 		$donors = array();
896 896
 
897 897
 		$donations = new Give_Payments_Query(
898 898
 			array(
899
-				'give_forms' => array( $form_id ),
900
-				'number'     => - 1,
901
-				'status'     => array( 'publish' ),
899
+				'give_forms' => array($form_id),
900
+				'number'     => -1,
901
+				'status'     => array('publish'),
902 902
 			)
903 903
 		);
904 904
 
@@ -906,16 +906,16 @@  discard block
 block discarded – undo
906 906
 		$skip_donors = array();
907 907
 
908 908
 		/* @var Give_Payment|object $donation Payment object. */
909
-		foreach ( $donations as $donation ) {
909
+		foreach ($donations as $donation) {
910 910
 
911
-			if ( in_array( $donation->customer_id, $skip_donors ) ) {
911
+			if (in_array($donation->customer_id, $skip_donors)) {
912 912
 				continue;
913 913
 			}
914 914
 
915
-			if ( ! empty( $donors ) ) {
916
-				$donors['donors'][] = current( current( $this->api->get_customers( (int) $donation->customer_id ) ) );
915
+			if ( ! empty($donors)) {
916
+				$donors['donors'][] = current(current($this->api->get_customers((int) $donation->customer_id)));
917 917
 			} else {
918
-				$donors = array_merge( $donors, $this->api->get_customers( (int) $donation->customer_id ) );
918
+				$donors = array_merge($donors, $this->api->get_customers((int) $donation->customer_id));
919 919
 			}
920 920
 
921 921
 			$skip_donors[] = $donation->customer_id;
Please login to merge, or discard this patch.
includes/emails/template.php 1 patch
Spacing   +104 added lines, -104 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,42 +56,42 @@  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( '{amount}', $price, $message );
83
-	$message = str_replace( '{price}', $price, $message );
84
-	$message = str_replace( '{donation}', esc_html__( 'Sample Donation Form Title', 'give' ), $message );
85
-	$message = str_replace( '{form_title}', esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ), $message );
86
-	$message = str_replace( '{receipt_id}', $receipt_id, $message );
87
-	$message = str_replace( '{payment_method}', $gateway, $message );
88
-	$message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message );
89
-	$message = str_replace( '{payment_id}', $payment_id, $message );
90
-	$message = str_replace( '{receipt_link}', $receipt_link, $message );
91
-	$message = str_replace( '{receipt_link_url}', $receipt_link_url, $message );
92
-	$message = str_replace( '{pdf_receipt}', '<a href="#">Download Receipt</a>', $message );
93
-
94
-	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('{amount}', $price, $message);
83
+	$message = str_replace('{price}', $price, $message);
84
+	$message = str_replace('{donation}', esc_html__('Sample Donation Form Title', 'give'), $message);
85
+	$message = str_replace('{form_title}', esc_html__('Sample Donation Form Title - Sample Donation Level', 'give'), $message);
86
+	$message = str_replace('{receipt_id}', $receipt_id, $message);
87
+	$message = str_replace('{payment_method}', $gateway, $message);
88
+	$message = str_replace('{sitename}', get_bloginfo('name'), $message);
89
+	$message = str_replace('{payment_id}', $payment_id, $message);
90
+	$message = str_replace('{receipt_link}', $receipt_link, $message);
91
+	$message = str_replace('{receipt_link_url}', $receipt_link_url, $message);
92
+	$message = str_replace('{pdf_receipt}', '<a href="#">Download Receipt</a>', $message);
93
+
94
+	return wpautop(apply_filters('give_email_preview_template_tags', $message));
95 95
 }
96 96
 
97 97
 /**
@@ -103,23 +103,23 @@  discard block
 block discarded – undo
103 103
  * @since  1.0
104 104
  * @return array|bool
105 105
  */
106
-function give_email_template_preview( $array ) {
106
+function give_email_template_preview($array) {
107 107
 
108
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
108
+	if ( ! current_user_can('manage_give_settings')) {
109 109
 		return false;
110 110
 	}
111 111
 	$custom_field = array(
112
-		'name' => esc_html__( 'Preview Email', 'give' ),
113
-		'desc' => esc_html__( 'Click the buttons to preview emails.', 'give' ),
112
+		'name' => esc_html__('Preview Email', 'give'),
113
+		'desc' => esc_html__('Click the buttons to preview emails.', 'give'),
114 114
 		'id'   => 'give_email_preview_buttons',
115 115
 		'type' => 'email_preview_buttons'
116 116
 	);
117 117
 
118
-	return give_settings_array_insert( $array, 'donation_subject', array( $custom_field ) );
118
+	return give_settings_array_insert($array, 'donation_subject', array($custom_field));
119 119
 
120 120
 }
121 121
 
122
-add_filter( 'give_settings_emails', 'give_email_template_preview' );
122
+add_filter('give_settings_emails', 'give_email_template_preview');
123 123
 
124 124
 /**
125 125
  * Output Email Template Preview Buttons.
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
 function give_email_preview_buttons_callback() {
132 132
 	ob_start();
133 133
 	?>
134
-	<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>
135
-	<a href="<?php echo wp_nonce_url( add_query_arg( array(
134
+	<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>
135
+	<a href="<?php echo wp_nonce_url(add_query_arg(array(
136 136
 		'give_action'  => 'send_test_email',
137 137
 		'give-message' => 'sent-test-email',
138 138
 		'tag'          => 'emails'
139
-	) ), '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>
139
+	)), '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>
140 140
 	<?php
141 141
 	echo ob_get_clean();
142 142
 }
@@ -149,46 +149,46 @@  discard block
 block discarded – undo
149 149
  */
150 150
 function give_display_email_template_preview() {
151 151
 
152
-	if ( empty( $_GET['give_action'] ) ) {
152
+	if (empty($_GET['give_action'])) {
153 153
 		return;
154 154
 	}
155 155
 
156
-	if ( 'preview_email' !== $_GET['give_action'] ) {
156
+	if ('preview_email' !== $_GET['give_action']) {
157 157
 		return;
158 158
 	}
159 159
 
160
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
160
+	if ( ! current_user_can('manage_give_settings')) {
161 161
 		return;
162 162
 	}
163 163
 
164 164
 
165
-	Give()->emails->heading = esc_html__( 'Donation Receipt', 'give' );
165
+	Give()->emails->heading = esc_html__('Donation Receipt', 'give');
166 166
 
167
-	$payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : '';
167
+	$payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : '';
168 168
 
169 169
 	echo give_get_preview_email_header();
170 170
 
171 171
 	//Are we previewing an actual payment?
172
-	if ( ! empty( $payment_id ) ) {
172
+	if ( ! empty($payment_id)) {
173 173
 
174
-		$content = give_get_email_body_content( $payment_id );
174
+		$content = give_get_email_body_content($payment_id);
175 175
 
176
-		$preview_content = give_do_email_tags( $content, $payment_id );
176
+		$preview_content = give_do_email_tags($content, $payment_id);
177 177
 
178 178
 	} else {
179 179
 
180 180
 		//No payment ID, use sample preview content
181
-		$preview_content = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) );
181
+		$preview_content = give_email_preview_template_tags(give_get_email_body_content(0, array()));
182 182
 	}
183 183
 
184 184
 
185
-	echo Give()->emails->build_email( $preview_content );
185
+	echo Give()->emails->build_email($preview_content);
186 186
 
187 187
 	exit;
188 188
 
189 189
 }
190 190
 
191
-add_action( 'init', 'give_display_email_template_preview' );
191
+add_action('init', 'give_display_email_template_preview');
192 192
 
193 193
 /**
194 194
  * Email Template Body.
@@ -200,18 +200,18 @@  discard block
 block discarded – undo
200 200
  *
201 201
  * @return string $email_body Body of the email
202 202
  */
203
-function give_get_email_body_content( $payment_id = 0, $payment_data = array() ) {
203
+function give_get_email_body_content($payment_id = 0, $payment_data = array()) {
204 204
 
205 205
 	$default_email_body = give_get_default_donation_receipt_email();
206 206
 
207
-	$email_content = give_get_option( 'donation_receipt' );
208
-	$email_content = isset( $email_content ) ? stripslashes( $email_content ) : $default_email_body;
207
+	$email_content = give_get_option('donation_receipt');
208
+	$email_content = isset($email_content) ? stripslashes($email_content) : $default_email_body;
209 209
 
210
-	$email_body = wpautop( $email_content );
210
+	$email_body = wpautop($email_content);
211 211
 
212
-	$email_body = apply_filters( 'give_donation_receipt_' . Give()->emails->get_template(), $email_body, $payment_id, $payment_data );
212
+	$email_body = apply_filters('give_donation_receipt_'.Give()->emails->get_template(), $email_body, $payment_id, $payment_data);
213 213
 
214
-	return apply_filters( 'give_donation_receipt', $email_body, $payment_id, $payment_data );
214
+	return apply_filters('give_donation_receipt', $email_body, $payment_id, $payment_data);
215 215
 }
216 216
 
217 217
 /**
@@ -224,36 +224,36 @@  discard block
 block discarded – undo
224 224
  *
225 225
  * @return string $email_body Body of the email
226 226
  */
227
-function give_get_donation_notification_body_content( $payment_id = 0, $payment_data = array() ) {
227
+function give_get_donation_notification_body_content($payment_id = 0, $payment_data = array()) {
228 228
 
229
-	$user_info = maybe_unserialize( $payment_data['user_info'] );
230
-	$email     = give_get_payment_user_email( $payment_id );
229
+	$user_info = maybe_unserialize($payment_data['user_info']);
230
+	$email     = give_get_payment_user_email($payment_id);
231 231
 
232
-	if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) {
233
-		$user_data = get_userdata( $user_info['id'] );
232
+	if (isset($user_info['id']) && $user_info['id'] > 0) {
233
+		$user_data = get_userdata($user_info['id']);
234 234
 		$name      = $user_data->display_name;
235
-	} elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) {
236
-		$name = $user_info['first_name'] . ' ' . $user_info['last_name'];
235
+	} elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) {
236
+		$name = $user_info['first_name'].' '.$user_info['last_name'];
237 237
 	} else {
238 238
 		$name = $email;
239 239
 	}
240 240
 
241
-	$gateway = give_get_gateway_admin_label( get_post_meta( $payment_id, '_give_payment_gateway', true ) );
241
+	$gateway = give_get_gateway_admin_label(get_post_meta($payment_id, '_give_payment_gateway', true));
242 242
 
243
-	$default_email_body = esc_html__( 'Hello', 'give' ) . "\n\n";
244
-	$default_email_body .= esc_html__( 'A donation has been made.', 'give' ) . "\n\n";
245
-	$default_email_body .= esc_html__( 'Donation:', 'give' ) . "\n\n";
246
-	$default_email_body .= esc_html__( 'Donor:', 'give' ) . ' ' . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n";
247
-	$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";
248
-	$default_email_body .= esc_html__( 'Payment Method:', 'give' ) . ' ' . $gateway . "\n\n";
249
-	$default_email_body .= esc_html__( 'Thank you', 'give' );
243
+	$default_email_body = esc_html__('Hello', 'give')."\n\n";
244
+	$default_email_body .= esc_html__('A donation has been made.', 'give')."\n\n";
245
+	$default_email_body .= esc_html__('Donation:', 'give')."\n\n";
246
+	$default_email_body .= esc_html__('Donor:', 'give').' '.html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n";
247
+	$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";
248
+	$default_email_body .= esc_html__('Payment Method:', 'give').' '.$gateway."\n\n";
249
+	$default_email_body .= esc_html__('Thank you', 'give');
250 250
 
251
-	$email = give_get_option( 'donation_notification' );
252
-	$email = isset( $email ) ? stripslashes( $email ) : $default_email_body;
251
+	$email = give_get_option('donation_notification');
252
+	$email = isset($email) ? stripslashes($email) : $default_email_body;
253 253
 
254
-	$email_body = give_do_email_tags( $email, $payment_id );
254
+	$email_body = give_do_email_tags($email, $payment_id);
255 255
 
256
-	return apply_filters( 'give_donation_notification', wpautop( $email_body ), $payment_id, $payment_data );
256
+	return apply_filters('give_donation_notification', wpautop($email_body), $payment_id, $payment_data);
257 257
 }
258 258
 
259 259
 /**
@@ -266,19 +266,19 @@  discard block
 block discarded – undo
266 266
  * @since  1.0
267 267
  */
268 268
 function give_render_receipt_in_browser() {
269
-	if ( ! isset( $_GET['payment_key'] ) ) {
270
-		wp_die( esc_html__( 'Missing donation payment key.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
269
+	if ( ! isset($_GET['payment_key'])) {
270
+		wp_die(esc_html__('Missing donation payment key.', 'give'), esc_html__('Error', 'give'), array('response' => 400));
271 271
 	}
272 272
 
273
-	$key = urlencode( $_GET['payment_key'] );
273
+	$key = urlencode($_GET['payment_key']);
274 274
 
275 275
 	ob_start();
276 276
 	//Disallows caching of the page
277
-	header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" );
278
-	header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1
279
-	header( "Cache-Control: post-check=0, pre-check=0", false );
280
-	header( "Pragma: no-cache" ); // HTTP/1.0
281
-	header( "Expires: Sat, 23 Oct 1977 05:00:00 PST" ); // Date in the past
277
+	header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
278
+	header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
279
+	header("Cache-Control: post-check=0, pre-check=0", false);
280
+	header("Pragma: no-cache"); // HTTP/1.0
281
+	header("Expires: Sat, 23 Oct 1977 05:00:00 PST"); // Date in the past
282 282
 	?>
283 283
 	<!DOCTYPE html>
284 284
 	<html lang="en">
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
 		 *
290 290
 		 * @since 1.0
291 291
 		 */
292
-		do_action( 'give_receipt_head' );
292
+		do_action('give_receipt_head');
293 293
 		?>
294 294
 	</head>
295
-	<body class="<?php echo apply_filters( 'give_receipt_page_body_class', 'give_receipt_page' ); ?>">
295
+	<body class="<?php echo apply_filters('give_receipt_page_body_class', 'give_receipt_page'); ?>">
296 296
 
297 297
 	<div id="give_receipt_wrapper">
298 298
 		<?php
@@ -301,16 +301,16 @@  discard block
 block discarded – undo
301 301
 		 *
302 302
 		 * @since 1.0
303 303
 		 */
304
-		do_action( 'give_render_receipt_in_browser_before' );
304
+		do_action('give_render_receipt_in_browser_before');
305 305
 
306
-		echo do_shortcode( '[give_receipt payment_key=' . $key . ']' );
306
+		echo do_shortcode('[give_receipt payment_key='.$key.']');
307 307
 
308 308
 		/**
309 309
 		 * Fires in the receipt template after the content.
310 310
 		 *
311 311
 		 * @since 1.0
312 312
 		 */
313
-		do_action( 'give_render_receipt_in_browser_after' );
313
+		do_action('give_render_receipt_in_browser_after');
314 314
 		?>
315 315
 	</div>
316 316
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	 *
321 321
 	 * @since 1.0
322 322
 	 */
323
-	do_action( 'give_receipt_footer' );
323
+	do_action('give_receipt_footer');
324 324
 	?>
325 325
 	</body>
326 326
 	</html>
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 	die();
330 330
 }
331 331
 
332
-add_action( 'give_view_receipt', 'give_render_receipt_in_browser' );
332
+add_action('give_view_receipt', 'give_render_receipt_in_browser');
333 333
 
334 334
 
335 335
 /**
@@ -344,29 +344,29 @@  discard block
 block discarded – undo
344 344
 
345 345
 	//Payment receipt switcher
346 346
 	$payment_count = give_count_payments()->publish;
347
-	$payment_id    = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : '';
347
+	$payment_id    = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : '';
348 348
 
349
-	if ( $payment_count <= 0 ) {
349
+	if ($payment_count <= 0) {
350 350
 		return false;
351 351
 	}
352 352
 
353 353
 	//Get payments.
354
-	$payments = new Give_Payments_Query( array(
354
+	$payments = new Give_Payments_Query(array(
355 355
 		'number' => 100
356
-	) );
356
+	));
357 357
 	$payments = $payments->get_payments();
358 358
 	$options  = array();
359 359
 
360 360
 	//Provide nice human readable options.
361
-	if ( $payments ) {
362
-		$options[0] = esc_html__( '- Select a donation -', 'give' );
363
-		foreach ( $payments as $payment ) {
361
+	if ($payments) {
362
+		$options[0] = esc_html__('- Select a donation -', 'give');
363
+		foreach ($payments as $payment) {
364 364
 
365
-			$options[ $payment->ID ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title );
365
+			$options[$payment->ID] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title);
366 366
 
367 367
 		}
368 368
 	} else {
369
-		$options[0] = esc_html__( 'No donations found.', 'give' );
369
+		$options[0] = esc_html__('No donations found.', 'give');
370 370
 	}
371 371
 
372 372
 	//Start constructing HTML output.
@@ -379,16 +379,16 @@  discard block
 block discarded – undo
379 379
 			        var selected_trans = transactions.options[transactions.selectedIndex];
380 380
 				        console.log(selected_trans);
381 381
 				        if (selected_trans){
382
-				            var url_string = "' . get_bloginfo( 'url' ) . '?give_action=preview_email&preview_id=" + selected_trans.value;
382
+				            var url_string = "' . get_bloginfo('url').'?give_action=preview_email&preview_id=" + selected_trans.value;
383 383
 				                window.location = url_string;
384 384
 				        }
385 385
 				    }
386 386
 			    </script>';
387 387
 
388
-	$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>';
388
+	$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>';
389 389
 
390 390
 	//The select field with 100 latest transactions
391
-	$transaction_header .= Give()->html->select( array(
391
+	$transaction_header .= Give()->html->select(array(
392 392
 		'name'             => 'preview_email_payment_id',
393 393
 		'selected'         => $payment_id,
394 394
 		'id'               => 'give_preview_email_payment_id',
@@ -398,12 +398,12 @@  discard block
 block discarded – undo
398 398
 		'select_atts'      => 'onchange="change_preview()">',
399 399
 		'show_option_all'  => false,
400 400
 		'show_option_none' => false
401
-	) );
401
+	));
402 402
 
403 403
 	//Closing tag
404 404
 	$transaction_header .= '</div>';
405 405
 
406
-	return apply_filters( 'give_preview_email_receipt_header', $transaction_header );
406
+	return apply_filters('give_preview_email_receipt_header', $transaction_header);
407 407
 
408 408
 }
409 409
 
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 function give_receipt_head_content() {
418 418
 
419 419
 	//Title.
420
-	$output = '<title>' . esc_html__( 'Donation Receipt', 'give' ) . '</title>';
420
+	$output = '<title>'.esc_html__('Donation Receipt', 'give').'</title>';
421 421
 
422 422
 	//Meta.
423 423
 	$output .= '<meta charset="utf-8"/>
@@ -431,10 +431,10 @@  discard block
 block discarded – undo
431 431
 		<meta name="robots" content="noindex, nofollow"/>';
432 432
 
433 433
 	//CSS
434
-	$output .= '<link rel="stylesheet" href="' . give_get_stylesheet_uri() . '?ver=' . GIVE_VERSION . '">';
434
+	$output .= '<link rel="stylesheet" href="'.give_get_stylesheet_uri().'?ver='.GIVE_VERSION.'">';
435 435
 
436
-	echo apply_filters( 'give_receipt_head_content', $output );
436
+	echo apply_filters('give_receipt_head_content', $output);
437 437
 
438 438
 }
439 439
 
440
-add_action( 'give_receipt_head', 'give_receipt_head_content' );
441 440
\ No newline at end of file
441
+add_action('give_receipt_head', 'give_receipt_head_content');
442 442
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-give-email-access.php 1 patch
Spacing   +62 added lines, -62 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
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	public function __construct() {
97 97
 
98 98
 		// get it started
99
-		add_action( 'init', array( $this, 'init' ) );
99
+		add_action('init', array($this, 'init'));
100 100
 	}
101 101
 
102 102
 	/**
@@ -111,30 +111,30 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	public function init() {
113 113
 
114
-		$is_enabled = give_get_option( 'email_access' );
114
+		$is_enabled = give_get_option('email_access');
115 115
 
116 116
 		//Non-logged in users only
117
-		if ( is_user_logged_in() || $is_enabled !== 'on' || is_admin() ) {
117
+		if (is_user_logged_in() || $is_enabled !== 'on' || is_admin()) {
118 118
 			return;
119 119
 		}
120 120
 
121 121
 		//Are db columns setup?
122
-		$is_setup = give_get_option( 'email_access_installed' );
123
-		if ( empty( $is_setup ) ) {
122
+		$is_setup = give_get_option('email_access_installed');
123
+		if (empty($is_setup)) {
124 124
 			$this->create_columns();
125 125
 		}
126 126
 
127 127
 		// Timeouts
128
-		$this->verify_throttle  = apply_filters( 'give_nl_verify_throttle', 300 );
129
-		$this->token_expiration = apply_filters( 'give_nl_token_expiration', 7200 );
128
+		$this->verify_throttle  = apply_filters('give_nl_verify_throttle', 300);
129
+		$this->token_expiration = apply_filters('give_nl_token_expiration', 7200);
130 130
 
131 131
 		// Setup login
132 132
 		$this->check_for_token();
133 133
 
134
-		if ( $this->token_exists ) {
135
-			add_filter( 'give_can_view_receipt', '__return_true' );
136
-			add_filter( 'give_user_pending_verification', '__return_false' );
137
-			add_filter( 'give_get_users_donations_args', array( $this, 'users_donations_args' ) );
134
+		if ($this->token_exists) {
135
+			add_filter('give_can_view_receipt', '__return_true');
136
+			add_filter('give_user_pending_verification', '__return_false');
137
+			add_filter('give_get_users_donations_args', array($this, 'users_donations_args'));
138 138
 		}
139 139
 	}
140 140
 
@@ -148,25 +148,25 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return bool
150 150
 	 */
151
-	public function can_send_email( $customer_id ) {
151
+	public function can_send_email($customer_id) {
152 152
 		/* @var WPDB $wpdb */
153 153
 		global $wpdb;
154 154
 
155 155
 		// Prevent multiple emails within X minutes
156
-		$throttle = date( 'Y-m-d H:i:s', time() - $this->verify_throttle );
156
+		$throttle = date('Y-m-d H:i:s', time() - $this->verify_throttle);
157 157
 
158 158
 		// Does a user row exist?
159 159
 		$exists = (int) $wpdb->get_var(
160
-			$wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id )
160
+			$wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id)
161 161
 		);
162 162
 
163
-		if ( 0 < $exists ) {
163
+		if (0 < $exists) {
164 164
 			$row_id = (int) $wpdb->get_var(
165
-				$wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle )
165
+				$wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle)
166 166
 			);
167 167
 
168
-			if ( $row_id < 1 ) {
169
-				give_set_error( 'give_email_access_attempts_exhausted', esc_html__( 'Please wait a few minutes before requesting a new email access link.', 'give' ) );
168
+			if ($row_id < 1) {
169
+				give_set_error('give_email_access_attempts_exhausted', esc_html__('Please wait a few minutes before requesting a new email access link.', 'give'));
170 170
 
171 171
 				return false;
172 172
 			}
@@ -186,34 +186,34 @@  discard block
 block discarded – undo
186 186
 	 *
187 187
 	 * @return void
188 188
 	 */
189
-	public function send_email( $customer_id, $email ) {
189
+	public function send_email($customer_id, $email) {
190 190
 
191
-		$verify_key = wp_generate_password( 20, false );
191
+		$verify_key = wp_generate_password(20, false);
192 192
 
193 193
 		// Generate a new verify key
194
-		$this->set_verify_key( $customer_id, $email, $verify_key );
194
+		$this->set_verify_key($customer_id, $email, $verify_key);
195 195
 
196 196
 		// Get the donation history page
197
-		$page_id = give_get_option( 'history_page' );
197
+		$page_id = give_get_option('history_page');
198 198
 
199
-		$access_url = add_query_arg( array(
199
+		$access_url = add_query_arg(array(
200 200
 			'give_nl' => $verify_key,
201
-		), get_permalink( $page_id ) );
201
+		), get_permalink($page_id));
202 202
 
203 203
 		//Nice subject and message
204
-		$subject = apply_filters( 'give_email_access_token_subject', sprintf( esc_html__( 'Your Access Link to %s', 'give' ), get_bloginfo( 'name' ) ) );
204
+		$subject = apply_filters('give_email_access_token_subject', sprintf(esc_html__('Your Access Link to %s', 'give'), get_bloginfo('name')));
205 205
 
206
-		$message = esc_html__( 'You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give' ) . "\n\n";
207
-		$message .= '<a href="' . esc_url( $access_url ) . '" target="_blank">' . esc_html__( 'Access My Donation Details &raquo;', 'give' ) . '</a>' . "\n\n";
206
+		$message = esc_html__('You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give')."\n\n";
207
+		$message .= '<a href="'.esc_url($access_url).'" target="_blank">'.esc_html__('Access My Donation Details &raquo;', 'give').'</a>'."\n\n";
208 208
 		$message .= "\n\n";
209
-		$message .= esc_html__( 'Sincerely,', 'give' ) . "\n";
210
-		$message .= get_bloginfo( 'name' ) . "\n";
209
+		$message .= esc_html__('Sincerely,', 'give')."\n";
210
+		$message .= get_bloginfo('name')."\n";
211 211
 
212
-		$message = apply_filters( 'give_email_access_token_message', $message );
212
+		$message = apply_filters('give_email_access_token_message', $message);
213 213
 
214 214
 		// Send the email
215
-		Give()->emails->__set( 'heading', apply_filters( 'give_email_access_token_heading', esc_html__( 'Your Access Link', 'give' ) ) );
216
-		Give()->emails->send( $email, $subject, $message );
215
+		Give()->emails->__set('heading', apply_filters('give_email_access_token_heading', esc_html__('Your Access Link', 'give')));
216
+		Give()->emails->send($email, $subject, $message);
217 217
 
218 218
 	}
219 219
 
@@ -227,24 +227,24 @@  discard block
 block discarded – undo
227 227
 	 */
228 228
 	public function check_for_token() {
229 229
 
230
-		$token = isset( $_GET['give_nl'] ) ? $_GET['give_nl'] : '';
230
+		$token = isset($_GET['give_nl']) ? $_GET['give_nl'] : '';
231 231
 
232 232
 		// Check for cookie
233
-		if ( empty( $token ) ) {
234
-			$token = isset( $_COOKIE['give_nl'] ) ? $_COOKIE['give_nl'] : '';
233
+		if (empty($token)) {
234
+			$token = isset($_COOKIE['give_nl']) ? $_COOKIE['give_nl'] : '';
235 235
 		}
236 236
 
237
-		if ( ! empty( $token ) ) {
238
-			if ( ! $this->is_valid_token( $token ) ) {
239
-				if ( ! $this->is_valid_verify_key( $token ) ) {
237
+		if ( ! empty($token)) {
238
+			if ( ! $this->is_valid_token($token)) {
239
+				if ( ! $this->is_valid_verify_key($token)) {
240 240
 					return;
241 241
 				}
242 242
 			}
243 243
 
244 244
 			$this->token_exists = true;
245 245
 			// Set cookie
246
-			$lifetime = current_time( 'timestamp' ) + Give()->session->set_expiration_time();
247
-			@setcookie( 'give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false );
246
+			$lifetime = current_time('timestamp') + Give()->session->set_expiration_time();
247
+			@setcookie('give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false);
248 248
 		}
249 249
 	}
250 250
 
@@ -258,18 +258,18 @@  discard block
 block discarded – undo
258 258
 	 *
259 259
 	 * @return bool
260 260
 	 */
261
-	public function is_valid_token( $token ) {
261
+	public function is_valid_token($token) {
262 262
 
263 263
 		global $wpdb;
264 264
 
265 265
 		// Make sure token isn't expired
266
-		$expires = date( 'Y-m-d H:i:s', time() - $this->token_expiration );
266
+		$expires = date('Y-m-d H:i:s', time() - $this->token_expiration);
267 267
 
268 268
 		$email = $wpdb->get_var(
269
-			$wpdb->prepare( "SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires )
269
+			$wpdb->prepare("SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires)
270 270
 		);
271 271
 
272
-		if ( ! empty( $email ) ) {
272
+		if ( ! empty($email)) {
273 273
 			$this->token_email = $email;
274 274
 			$this->token       = $token;
275 275
 
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 		}
278 278
 
279 279
 		//Set error only if email access form isn't being submitted
280
-		if ( ! isset( $_POST['give_email'] ) && ! isset( $_POST['_wpnonce'] ) ) {
281
-			give_set_error( 'give_email_token_expired', apply_filters( 'give_email_token_expired_message', esc_html__( 'Your access token has expired. Please request a new one below:', 'give' ) ) );
280
+		if ( ! isset($_POST['give_email']) && ! isset($_POST['_wpnonce'])) {
281
+			give_set_error('give_email_token_expired', apply_filters('give_email_token_expired_message', esc_html__('Your access token has expired. Please request a new one below:', 'give')));
282 282
 		}
283 283
 
284 284
 		return false;
@@ -297,25 +297,25 @@  discard block
 block discarded – undo
297 297
 	 *
298 298
 	 * @return void
299 299
 	 */
300
-	public function set_verify_key( $customer_id, $email, $verify_key ) {
300
+	public function set_verify_key($customer_id, $email, $verify_key) {
301 301
 		global $wpdb;
302 302
 
303
-		$now = date( 'Y-m-d H:i:s' );
303
+		$now = date('Y-m-d H:i:s');
304 304
 
305 305
 		// Insert or update?
306 306
 		$row_id = (int) $wpdb->get_var(
307
-			$wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id )
307
+			$wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id)
308 308
 		);
309 309
 
310 310
 		// Update
311
-		if ( ! empty( $row_id ) ) {
311
+		if ( ! empty($row_id)) {
312 312
 			$wpdb->query(
313
-				$wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id )
313
+				$wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id)
314 314
 			);
315 315
 		} // Insert
316 316
 		else {
317 317
 			$wpdb->query(
318
-				$wpdb->prepare( "INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now )
318
+				$wpdb->prepare("INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now)
319 319
 			);
320 320
 		}
321 321
 	}
@@ -330,21 +330,21 @@  discard block
 block discarded – undo
330 330
 	 *
331 331
 	 * @return bool
332 332
 	 */
333
-	public function is_valid_verify_key( $token ) {
333
+	public function is_valid_verify_key($token) {
334 334
 		/* @var WPDB $wpdb */
335 335
 		global $wpdb;
336 336
 
337 337
 		// See if the verify_key exists
338 338
 		$row = $wpdb->get_row(
339
-			$wpdb->prepare( "SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token )
339
+			$wpdb->prepare("SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token)
340 340
 		);
341 341
 
342
-		$now = date( 'Y-m-d H:i:s' );
342
+		$now = date('Y-m-d H:i:s');
343 343
 
344 344
 		// Set token
345
-		if ( ! empty( $row ) ) {
345
+		if ( ! empty($row)) {
346 346
 			$wpdb->query(
347
-				$wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id )
347
+				$wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id)
348 348
 			);
349 349
 
350 350
 			$this->token_email = $row->email;
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 	 *
369 369
 	 * @return mixed
370 370
 	 */
371
-	public function users_donations_args( $args ) {
371
+	public function users_donations_args($args) {
372 372
 		$args['user'] = $this->token_email;
373 373
 
374 374
 		return $args;
@@ -389,11 +389,11 @@  discard block
 block discarded – undo
389 389
 		global $wpdb;
390 390
 
391 391
 		//Create columns in customers table
392
-		$query = $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`" );
392
+		$query = $wpdb->query("ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`");
393 393
 
394 394
 		//Columns added properly
395
-		if ( $query ) {
396
-			give_update_option( 'email_access_installed', 1 );
395
+		if ($query) {
396
+			give_update_option('email_access_installed', 1);
397 397
 		}
398 398
 
399 399
 	}
Please login to merge, or discard this patch.