Passed
Push — master ( 7c0663...7b931b )
by Brian
05:42
created
includes/reports/class-getpaid-reports.php 2 patches
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -12,49 +12,49 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Reports {
14 14
 
15
-	/**
16
-	 * Class constructor.
17
-	 *
18
-	 */
19
-	public function __construct() {
20
-		add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
-		add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
-		add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
-		add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
-		add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
25
-
26
-	}
27
-
28
-	/**
29
-	 * Registers the reports page.
30
-	 *
31
-	 */
32
-	public function register_reports_page() {
33
-
34
-		add_submenu_page(
15
+    /**
16
+     * Class constructor.
17
+     *
18
+     */
19
+    public function __construct() {
20
+        add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
+        add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
+        add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
+        add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
+        add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
25
+
26
+    }
27
+
28
+    /**
29
+     * Registers the reports page.
30
+     *
31
+     */
32
+    public function register_reports_page() {
33
+
34
+        add_submenu_page(
35 35
             'wpinv',
36 36
             __( 'Reports', 'invoicing' ),
37 37
             __( 'Reports', 'invoicing' ),
38 38
             wpinv_get_capability(),
39 39
             'wpinv-reports',
40 40
             array( $this, 'display_reports_page' )
41
-		);
41
+        );
42 42
 
43
-	}
43
+    }
44 44
 
45
-	/**
46
-	 * Displays the reports page.
47
-	 *
48
-	 */
49
-	public function display_reports_page() {
45
+    /**
46
+     * Displays the reports page.
47
+     *
48
+     */
49
+    public function display_reports_page() {
50 50
 
51
-		// Prepare variables.
52
-		$tabs        = $this->get_tabs();
53
-		$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
-		$current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
51
+        // Prepare variables.
52
+        $tabs        = $this->get_tabs();
53
+        $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
+        $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
55 55
 
56
-		// Display the current tab.
57
-		?>
56
+        // Display the current tab.
57
+        ?>
58 58
 
59 59
         <div class="wrap">
60 60
 
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
 			<nav class="nav-tab-wrapper">
64 64
 
65 65
 				<?php
66
-					foreach( $tabs as $key => $label ) {
66
+                    foreach( $tabs as $key => $label ) {
67 67
 
68
-						$key   = sanitize_text_field( $key );
69
-						$label = sanitize_text_field( $label );
70
-						$class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71
-						$url   = esc_url(
72
-							add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
73
-						);
68
+                        $key   = sanitize_text_field( $key );
69
+                        $label = sanitize_text_field( $label );
70
+                        $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71
+                        $url   = esc_url(
72
+                            add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
73
+                        );
74 74
 
75
-						echo "\n\t\t\t<a href='$url' class='$class'>$label</a>";
75
+                        echo "\n\t\t\t<a href='$url' class='$class'>$label</a>";
76 76
 
77
-					}
78
-				?>
77
+                    }
78
+                ?>
79 79
 
80 80
 			</nav>
81 81
 
@@ -86,82 +86,82 @@  discard block
 block discarded – undo
86 86
         </div>
87 87
 		<?php
88 88
 
89
-			// Wordfence loads an unsupported version of chart js on our page.
90
-			wp_deregister_style( 'chart-js' );
91
-			wp_deregister_script( 'chart-js' );
92
-			wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true );
89
+            // Wordfence loads an unsupported version of chart js on our page.
90
+            wp_deregister_style( 'chart-js' );
91
+            wp_deregister_script( 'chart-js' );
92
+            wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true );
93 93
 
94
-	}
94
+    }
95 95
 
96
-	/**
97
-	 * Retrieves reports page tabs.
98
-	 *
99
-	 * @return array
100
-	 */
101
-	public function get_tabs() {
96
+    /**
97
+     * Retrieves reports page tabs.
98
+     *
99
+     * @return array
100
+     */
101
+    public function get_tabs() {
102 102
 
103
-		$tabs = array(
104
-			'reports' => __( 'Reports', 'invoicing' ),
105
-			'export'  => __( 'Export', 'invoicing' ),
106
-		);
103
+        $tabs = array(
104
+            'reports' => __( 'Reports', 'invoicing' ),
105
+            'export'  => __( 'Export', 'invoicing' ),
106
+        );
107 107
 
108
-		return apply_filters( 'getpaid_report_tabs', $tabs );
109
-	}
108
+        return apply_filters( 'getpaid_report_tabs', $tabs );
109
+    }
110 110
 
111
-	/**
112
-	 * Displays the reports tab.
113
-	 *
114
-	 */
115
-	public function display_reports_tab() {
111
+    /**
112
+     * Displays the reports tab.
113
+     *
114
+     */
115
+    public function display_reports_tab() {
116 116
 
117
-		$reports = new GetPaid_Reports_Report();
118
-		$reports->display();
117
+        $reports = new GetPaid_Reports_Report();
118
+        $reports->display();
119 119
 
120
-	}
120
+    }
121 121
 
122
-	/**
123
-	 * Displays the exports tab.
124
-	 *
125
-	 */
126
-	public function display_exports_tab() {
122
+    /**
123
+     * Displays the exports tab.
124
+     *
125
+     */
126
+    public function display_exports_tab() {
127 127
 
128
-		$exports = new GetPaid_Reports_Export();
129
-		$exports->display();
128
+        $exports = new GetPaid_Reports_Export();
129
+        $exports->display();
130 130
 
131
-	}
131
+    }
132 132
 
133
-	/**
134
-	 * Donwnloads a graph.
135
-	 *
136
-	 * @param array $args
137
-	 */
138
-	public function download_graph( $args ) {
133
+    /**
134
+     * Donwnloads a graph.
135
+     *
136
+     * @param array $args
137
+     */
138
+    public function download_graph( $args ) {
139 139
 
140
-		if ( ! empty( $args['graph'] ) ) {
141
-			$downloader = new GetPaid_Graph_Downloader();
142
-			$downloader->download( $args['graph'] );
143
-		}
140
+        if ( ! empty( $args['graph'] ) ) {
141
+            $downloader = new GetPaid_Graph_Downloader();
142
+            $downloader->download( $args['graph'] );
143
+        }
144 144
 
145
-	}
145
+    }
146 146
 
147
-	/**
148
-	 * Exports invoices.
149
-	 *
150
-	 * @param array $args
151
-	 */
152
-	public function export_invoices( $args ) {
147
+    /**
148
+     * Exports invoices.
149
+     *
150
+     * @param array $args
151
+     */
152
+    public function export_invoices( $args ) {
153 153
 
154
-		if ( ! empty( $args['post_type'] ) ) {
154
+        if ( ! empty( $args['post_type'] ) ) {
155 155
 
156
-			if ( 'subscriptions' === $args['post_type'] ) {
157
-				$downloader = new GetPaid_Subscription_Exporter();
158
-			} else {
159
-				$downloader = new GetPaid_Invoice_Exporter();
160
-			}
156
+            if ( 'subscriptions' === $args['post_type'] ) {
157
+                $downloader = new GetPaid_Subscription_Exporter();
158
+            } else {
159
+                $downloader = new GetPaid_Invoice_Exporter();
160
+            }
161 161
 
162
-			$downloader->export( $args['post_type'], $args );
163
-		}
162
+            $downloader->export( $args['post_type'], $args );
163
+        }
164 164
 
165
-	}
165
+    }
166 166
 
167 167
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Reports Class.
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 */
19 19
 	public function __construct() {
20
-		add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
-		add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
-		add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
-		add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
-		add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
20
+		add_action('admin_menu', array($this, 'register_reports_page'), 20);
21
+		add_action('wpinv_reports_tab_reports', array($this, 'display_reports_tab'));
22
+		add_action('wpinv_reports_tab_export', array($this, 'display_exports_tab'));
23
+		add_action('getpaid_authenticated_admin_action_download_graph', array($this, 'download_graph'));
24
+		add_action('getpaid_authenticated_admin_action_export_invoices', array($this, 'export_invoices'));
25 25
 
26 26
 	}
27 27
 
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 
34 34
 		add_submenu_page(
35 35
             'wpinv',
36
-            __( 'Reports', 'invoicing' ),
37
-            __( 'Reports', 'invoicing' ),
36
+            __('Reports', 'invoicing'),
37
+            __('Reports', 'invoicing'),
38 38
             wpinv_get_capability(),
39 39
             'wpinv-reports',
40
-            array( $this, 'display_reports_page' )
40
+            array($this, 'display_reports_page')
41 41
 		);
42 42
 
43 43
 	}
@@ -50,26 +50,26 @@  discard block
 block discarded – undo
50 50
 
51 51
 		// Prepare variables.
52 52
 		$tabs        = $this->get_tabs();
53
-		$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
-		$current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
53
+		$current_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'reports';
54
+		$current_tab = array_key_exists($current_tab, $tabs) ? $current_tab : 'reports';
55 55
 
56 56
 		// Display the current tab.
57 57
 		?>
58 58
 
59 59
         <div class="wrap">
60 60
 
61
-			<h1><?php echo sanitize_text_field( $tabs[ $current_tab ] ); ?></h1>
61
+			<h1><?php echo sanitize_text_field($tabs[$current_tab]); ?></h1>
62 62
 
63 63
 			<nav class="nav-tab-wrapper">
64 64
 
65 65
 				<?php
66
-					foreach( $tabs as $key => $label ) {
66
+					foreach ($tabs as $key => $label) {
67 67
 
68
-						$key   = sanitize_text_field( $key );
69
-						$label = sanitize_text_field( $label );
68
+						$key   = sanitize_text_field($key);
69
+						$label = sanitize_text_field($label);
70 70
 						$class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71 71
 						$url   = esc_url(
72
-							add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
72
+							add_query_arg('tab', $key, admin_url('admin.php?page=wpinv-reports'))
73 73
 						);
74 74
 
75 75
 						echo "\n\t\t\t<a href='$url' class='$class'>$label</a>";
@@ -79,17 +79,17 @@  discard block
 block discarded – undo
79 79
 
80 80
 			</nav>
81 81
 
82
-			<div class="bsui <?php echo esc_attr( $current_tab ); ?>">
83
-				<?php do_action( "wpinv_reports_tab_{$current_tab}" ); ?>
82
+			<div class="bsui <?php echo esc_attr($current_tab); ?>">
83
+				<?php do_action("wpinv_reports_tab_{$current_tab}"); ?>
84 84
 			</div>
85 85
 
86 86
         </div>
87 87
 		<?php
88 88
 
89 89
 			// Wordfence loads an unsupported version of chart js on our page.
90
-			wp_deregister_style( 'chart-js' );
91
-			wp_deregister_script( 'chart-js' );
92
-			wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true );
90
+			wp_deregister_style('chart-js');
91
+			wp_deregister_script('chart-js');
92
+			wp_enqueue_script('chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array('jquery'), '3.7.1', true);
93 93
 
94 94
 	}
95 95
 
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	public function get_tabs() {
102 102
 
103 103
 		$tabs = array(
104
-			'reports' => __( 'Reports', 'invoicing' ),
105
-			'export'  => __( 'Export', 'invoicing' ),
104
+			'reports' => __('Reports', 'invoicing'),
105
+			'export'  => __('Export', 'invoicing'),
106 106
 		);
107 107
 
108
-		return apply_filters( 'getpaid_report_tabs', $tabs );
108
+		return apply_filters('getpaid_report_tabs', $tabs);
109 109
 	}
110 110
 
111 111
 	/**
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @param array $args
137 137
 	 */
138
-	public function download_graph( $args ) {
138
+	public function download_graph($args) {
139 139
 
140
-		if ( ! empty( $args['graph'] ) ) {
140
+		if (!empty($args['graph'])) {
141 141
 			$downloader = new GetPaid_Graph_Downloader();
142
-			$downloader->download( $args['graph'] );
142
+			$downloader->download($args['graph']);
143 143
 		}
144 144
 
145 145
 	}
@@ -149,17 +149,17 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @param array $args
151 151
 	 */
152
-	public function export_invoices( $args ) {
152
+	public function export_invoices($args) {
153 153
 
154
-		if ( ! empty( $args['post_type'] ) ) {
154
+		if (!empty($args['post_type'])) {
155 155
 
156
-			if ( 'subscriptions' === $args['post_type'] ) {
156
+			if ('subscriptions' === $args['post_type']) {
157 157
 				$downloader = new GetPaid_Subscription_Exporter();
158 158
 			} else {
159 159
 				$downloader = new GetPaid_Invoice_Exporter();
160 160
 			}
161 161
 
162
-			$downloader->export( $args['post_type'], $args );
162
+			$downloader->export($args['post_type'], $args);
163 163
 		}
164 164
 
165 165
 	}
Please login to merge, or discard this patch.