Passed
Push — master ( 8c5dc4...d786e3 )
by Brian
09:28
created
includes/class-bp-getpaid-component.php 2 patches
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -17,45 +17,45 @@  discard block
 block discarded – undo
17 17
  */
18 18
 class BP_GetPaid_Component extends BP_Component {
19 19
 
20
-	/**
21
-	 * Start the component setup process.
22
-	 *
23
-	 * @since 2.1.5
24
-	 */
25
-	public function __construct() {
26
-		parent::start(
27
-			'getpaid',
28
-			'GetPaid',
29
-			buddypress()->plugin_dir,
30
-			array(
31
-				'adminbar_myaccount_order' => 30,
32
-			)
33
-		);
34
-	}
20
+    /**
21
+     * Start the component setup process.
22
+     *
23
+     * @since 2.1.5
24
+     */
25
+    public function __construct() {
26
+        parent::start(
27
+            'getpaid',
28
+            'GetPaid',
29
+            buddypress()->plugin_dir,
30
+            array(
31
+                'adminbar_myaccount_order' => 30,
32
+            )
33
+        );
34
+    }
35 35
 
36 36
     /**
37
-	 * Set up component global variables.
38
-	 *
39
-	 * @since 2.1.5
40
-	 *
41
-	 *
42
-	 * @param array $args {
43
-	 *     All values are optional.
44
-	 *     @type string   $slug                  The component slug. Used to construct certain URLs, such as 'friends' in
45
-	 *                                           http://example.com/members/joe/friends/. Default: the value of $this->id.
46
-	 *     @type string   $root_slug             The component root slug. Note that this value is generally unused if the
47
-	 *                                           component has a root directory (the slug will be overridden by the
48
-	 *                                           post_name of the directory page). Default: the slug of the directory page
49
-	 *                                           if one is found, otherwise an empty string.
50
-	 *     @type bool     $has_directory         Set to true if the component requires an associated WordPress page.
51
-	 *     @type callable $notification_callback Optional. The callable function that formats the component's notifications.
52
-	 *     @type string   $search_term           Optional. The placeholder text in the component directory search box. Eg,
53
-	 *                                           'Search Groups...'.
54
-	 *     @type array    $global_tables         Optional. An array of database table names.
55
-	 *     @type array    $meta_tables           Optional. An array of metadata table names.
56
-	 * }
57
-	 */
58
-	public function setup_globals( $args = array() ) {
37
+     * Set up component global variables.
38
+     *
39
+     * @since 2.1.5
40
+     *
41
+     *
42
+     * @param array $args {
43
+     *     All values are optional.
44
+     *     @type string   $slug                  The component slug. Used to construct certain URLs, such as 'friends' in
45
+     *                                           http://example.com/members/joe/friends/. Default: the value of $this->id.
46
+     *     @type string   $root_slug             The component root slug. Note that this value is generally unused if the
47
+     *                                           component has a root directory (the slug will be overridden by the
48
+     *                                           post_name of the directory page). Default: the slug of the directory page
49
+     *                                           if one is found, otherwise an empty string.
50
+     *     @type bool     $has_directory         Set to true if the component requires an associated WordPress page.
51
+     *     @type callable $notification_callback Optional. The callable function that formats the component's notifications.
52
+     *     @type string   $search_term           Optional. The placeholder text in the component directory search box. Eg,
53
+     *                                           'Search Groups...'.
54
+     *     @type array    $global_tables         Optional. An array of database table names.
55
+     *     @type array    $meta_tables           Optional. An array of metadata table names.
56
+     * }
57
+     */
58
+    public function setup_globals( $args = array() ) {
59 59
         parent::setup_globals(
60 60
             array(
61 61
                 'id'            => 'getpaid',
@@ -64,21 +64,21 @@  discard block
 block discarded – undo
64 64
                 'has_directory' => false
65 65
             )
66 66
         );
67
-	}
68
-
69
-	/**
70
-	 * Set up component navigation.
71
-	 *
72
-	 * @since 2.1.5
73
-	 *
74
-	 * @see BP_Component::setup_nav() for a description of arguments.
75
-	 *
76
-	 * @param array $main_nav Optional. See BP_Component::setup_nav() for description.
77
-	 * @param array $sub_nav  Optional. See BP_Component::setup_nav() for description.
78
-	 */
79
-	public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
80
-
81
-		// Abort if the integration is inactive.
67
+    }
68
+
69
+    /**
70
+     * Set up component navigation.
71
+     *
72
+     * @since 2.1.5
73
+     *
74
+     * @see BP_Component::setup_nav() for a description of arguments.
75
+     *
76
+     * @param array $main_nav Optional. See BP_Component::setup_nav() for description.
77
+     * @param array $sub_nav  Optional. See BP_Component::setup_nav() for description.
78
+     */
79
+    public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
80
+
81
+        // Abort if the integration is inactive.
82 82
         if ( ! getpaid_is_buddypress_integration_active() || ! is_user_logged_in() ) {
83 83
             return;
84 84
         }
@@ -88,25 +88,25 @@  discard block
 block discarded – undo
88 88
             return;
89 89
         }
90 90
 
91
-		// Determine user to use.
92
-		$user_domain   = bp_loggedin_user_domain();
93
-		$slug          = 'getpaid';
94
-		$payments_link = trailingslashit( $user_domain . $slug );
95
-
96
-		// Add 'Payments' to the main navigation.
97
-		$main_nav = array(
98
-			'name'                => _x( 'Billing', 'BuddyPress profile payments screen nav', 'invoicing' ),
99
-			'slug'                => $slug,
100
-			'position'            => apply_filters( 'wpinv_bp_nav_position', wpinv_get_option( 'wpinv_menu_position', 91 ), $slug ),
101
-			'screen_function'     => array( $this, 'display_current_tab' ),
102
-			'default_subnav_slug' => apply_filters( 'getpaid_default_tab', 'gp-edit-address' ),
91
+        // Determine user to use.
92
+        $user_domain   = bp_loggedin_user_domain();
93
+        $slug          = 'getpaid';
94
+        $payments_link = trailingslashit( $user_domain . $slug );
95
+
96
+        // Add 'Payments' to the main navigation.
97
+        $main_nav = array(
98
+            'name'                => _x( 'Billing', 'BuddyPress profile payments screen nav', 'invoicing' ),
99
+            'slug'                => $slug,
100
+            'position'            => apply_filters( 'wpinv_bp_nav_position', wpinv_get_option( 'wpinv_menu_position', 91 ), $slug ),
101
+            'screen_function'     => array( $this, 'display_current_tab' ),
102
+            'default_subnav_slug' => apply_filters( 'getpaid_default_tab', 'gp-edit-address' ),
103 103
             'show_for_displayed_user' => false,
104
-			'item_css_id'         => $this->id,
105
-			'parent_url'          => $user_domain,
106
-			'parent_slug'         => buddypress()->slug,
107
-		);
104
+            'item_css_id'         => $this->id,
105
+            'parent_url'          => $user_domain,
106
+            'parent_slug'         => buddypress()->slug,
107
+        );
108 108
 
109
-		// Add the subnav items to the payments nav item if we are using a theme that supports this.
109
+        // Add the subnav items to the payments nav item if we are using a theme that supports this.
110 110
         foreach ( getpaid_get_user_content_tabs() as $_slug => $tab ) {
111 111
 
112 112
             $sub_nav[] = array(
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
                 'parent_slug'     => $slug,
117 117
                 'position' => 10,
118 118
                 'screen_function'        => function() use ( $tab ) {
119
-					$GLOBALS['getpaid_bp_current_tab'] = $tab;
120
-					$this->display_current_tab();
119
+                    $GLOBALS['getpaid_bp_current_tab'] = $tab;
120
+                    $this->display_current_tab();
121 121
                 },
122 122
                 'show_for_displayed_user' => false,
123 123
                 'item_css_id'             => "getpaid-bp-$_slug",
@@ -125,27 +125,27 @@  discard block
 block discarded – undo
125 125
 
126 126
         }
127 127
 
128
-		parent::setup_nav( $main_nav, $sub_nav );
129
-	}
130
-
131
-	/**
132
-	 * Set up the component entries in the WordPress Admin Bar.
133
-	 *
134
-	 * @since 2.1.5
135
-	 *
136
-	 * @see BP_Component::setup_nav() for a description of the $wp_admin_nav
137
-	 *      parameter array.
138
-	 *
139
-	 * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a
140
-	 *                            description.
141
-	 */
142
-	public function setup_admin_bar( $wp_admin_nav = array() ) {
143
-
144
-		// Menus for logged in user.
145
-		if ( is_user_logged_in() ) {
128
+        parent::setup_nav( $main_nav, $sub_nav );
129
+    }
146 130
 
147
-			// Setup the logged in user variables.
148
-			$payments_link = trailingslashit( bp_loggedin_user_domain() . 'getpaid/' );
131
+    /**
132
+     * Set up the component entries in the WordPress Admin Bar.
133
+     *
134
+     * @since 2.1.5
135
+     *
136
+     * @see BP_Component::setup_nav() for a description of the $wp_admin_nav
137
+     *      parameter array.
138
+     *
139
+     * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a
140
+     *                            description.
141
+     */
142
+    public function setup_admin_bar( $wp_admin_nav = array() ) {
143
+
144
+        // Menus for logged in user.
145
+        if ( is_user_logged_in() ) {
146
+
147
+            // Setup the logged in user variables.
148
+            $payments_link = trailingslashit( bp_loggedin_user_domain() . 'getpaid/' );
149 149
 
150 150
             // Add the "Payments" sub menu.
151 151
             $wp_admin_nav[] = array(
@@ -167,50 +167,50 @@  discard block
 block discarded – undo
167 167
 
168 168
             }
169 169
 
170
-		}
171
-
172
-		parent::setup_admin_bar( $wp_admin_nav );
173
-	}
170
+        }
174 171
 
175
-	/**
176
-	 * Retrieves the current tab.
177
-	 *
178
-	 * @since 2.1.5
179
-	 */
180
-	public function get_current_tab() {
181
-		global $getpaid_bp_current_tab;
172
+        parent::setup_admin_bar( $wp_admin_nav );
173
+    }
182 174
 
183
-		if ( empty( $getpaid_bp_current_tab ) ) {
184
-			return array(
185
-				'label'     => __( 'Invoices', 'invoicing' ),
186
-				'content'   => '[wpinv_history]',
187
-				'icon'      => 'fas fa-file-invoice',
188
-			);
189
-		}
175
+    /**
176
+     * Retrieves the current tab.
177
+     *
178
+     * @since 2.1.5
179
+     */
180
+    public function get_current_tab() {
181
+        global $getpaid_bp_current_tab;
182
+
183
+        if ( empty( $getpaid_bp_current_tab ) ) {
184
+            return array(
185
+                'label'     => __( 'Invoices', 'invoicing' ),
186
+                'content'   => '[wpinv_history]',
187
+                'icon'      => 'fas fa-file-invoice',
188
+            );
189
+        }
190 190
 
191
-		return $getpaid_bp_current_tab;
192
-	}
191
+        return $getpaid_bp_current_tab;
192
+    }
193 193
 
194
-	/**
195
-	 * Displays the current tab.
196
-	 *
197
-	 * @since 2.1.5
198
-	 */
199
-	public function display_current_tab() {
194
+    /**
195
+     * Displays the current tab.
196
+     *
197
+     * @since 2.1.5
198
+     */
199
+    public function display_current_tab() {
200 200
 
201
-		add_action( 'bp_template_content', array( $this, 'handle_display_current_tab' ) );
202
-		$template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' );
201
+        add_action( 'bp_template_content', array( $this, 'handle_display_current_tab' ) );
202
+        $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' );
203 203
 
204 204
         bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) );
205
-	}
206
-
207
-	/**
208
-	 * Handles the actual display of the current tab.
209
-	 *
210
-	 * @since 2.1.5
211
-	 */
212
-	public function handle_display_current_tab() {
213
-		echo getpaid_prepare_user_content_tab( $this->get_current_tab() );
214
-	}
205
+    }
206
+
207
+    /**
208
+     * Handles the actual display of the current tab.
209
+     *
210
+     * @since 2.1.5
211
+     */
212
+    public function handle_display_current_tab() {
213
+        echo getpaid_prepare_user_content_tab( $this->get_current_tab() );
214
+    }
215 215
 
216 216
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 // Exit if accessed directly.
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * Main GetPaid Class.
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 *     @type array    $meta_tables           Optional. An array of metadata table names.
56 56
 	 * }
57 57
 	 */
58
-	public function setup_globals( $args = array() ) {
58
+	public function setup_globals($args = array()) {
59 59
         parent::setup_globals(
60 60
             array(
61 61
                 'id'            => 'getpaid',
@@ -76,30 +76,30 @@  discard block
 block discarded – undo
76 76
 	 * @param array $main_nav Optional. See BP_Component::setup_nav() for description.
77 77
 	 * @param array $sub_nav  Optional. See BP_Component::setup_nav() for description.
78 78
 	 */
79
-	public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
79
+	public function setup_nav($main_nav = array(), $sub_nav = array()) {
80 80
 
81 81
 		// Abort if the integration is inactive.
82
-        if ( ! getpaid_is_buddypress_integration_active() || ! is_user_logged_in() ) {
82
+        if (!getpaid_is_buddypress_integration_active() || !is_user_logged_in()) {
83 83
             return;
84 84
         }
85 85
     
86 86
         // Or a user is not viewing their profile.
87
-        if ( bp_displayed_user_id() != bp_loggedin_user_id() ) {
87
+        if (bp_displayed_user_id() != bp_loggedin_user_id()) {
88 88
             return;
89 89
         }
90 90
 
91 91
 		// Determine user to use.
92 92
 		$user_domain   = bp_loggedin_user_domain();
93 93
 		$slug          = 'getpaid';
94
-		$payments_link = trailingslashit( $user_domain . $slug );
94
+		$payments_link = trailingslashit($user_domain . $slug);
95 95
 
96 96
 		// Add 'Payments' to the main navigation.
97 97
 		$main_nav = array(
98
-			'name'                => _x( 'Billing', 'BuddyPress profile payments screen nav', 'invoicing' ),
98
+			'name'                => _x('Billing', 'BuddyPress profile payments screen nav', 'invoicing'),
99 99
 			'slug'                => $slug,
100
-			'position'            => apply_filters( 'wpinv_bp_nav_position', wpinv_get_option( 'wpinv_menu_position', 91 ), $slug ),
101
-			'screen_function'     => array( $this, 'display_current_tab' ),
102
-			'default_subnav_slug' => apply_filters( 'getpaid_default_tab', 'gp-edit-address' ),
100
+			'position'            => apply_filters('wpinv_bp_nav_position', wpinv_get_option('wpinv_menu_position', 91), $slug),
101
+			'screen_function'     => array($this, 'display_current_tab'),
102
+			'default_subnav_slug' => apply_filters('getpaid_default_tab', 'gp-edit-address'),
103 103
             'show_for_displayed_user' => false,
104 104
 			'item_css_id'         => $this->id,
105 105
 			'parent_url'          => $user_domain,
@@ -107,15 +107,15 @@  discard block
 block discarded – undo
107 107
 		);
108 108
 
109 109
 		// Add the subnav items to the payments nav item if we are using a theme that supports this.
110
-        foreach ( getpaid_get_user_content_tabs() as $_slug => $tab ) {
110
+        foreach (getpaid_get_user_content_tabs() as $_slug => $tab) {
111 111
 
112 112
             $sub_nav[] = array(
113
-                'name'            => $tab[ 'label'],
113
+                'name'            => $tab['label'],
114 114
                 'slug'            => $_slug,
115 115
                 'parent_url'      => $payments_link,
116 116
                 'parent_slug'     => $slug,
117 117
                 'position' => 10,
118
-                'screen_function'        => function() use ( $tab ) {
118
+                'screen_function'        => function() use ($tab) {
119 119
 					$GLOBALS['getpaid_bp_current_tab'] = $tab;
120 120
 					$this->display_current_tab();
121 121
                 },
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
         }
127 127
 
128
-		parent::setup_nav( $main_nav, $sub_nav );
128
+		parent::setup_nav($main_nav, $sub_nav);
129 129
 	}
130 130
 
131 131
 	/**
@@ -139,29 +139,29 @@  discard block
 block discarded – undo
139 139
 	 * @param array $wp_admin_nav See BP_Component::setup_admin_bar() for a
140 140
 	 *                            description.
141 141
 	 */
142
-	public function setup_admin_bar( $wp_admin_nav = array() ) {
142
+	public function setup_admin_bar($wp_admin_nav = array()) {
143 143
 
144 144
 		// Menus for logged in user.
145
-		if ( is_user_logged_in() ) {
145
+		if (is_user_logged_in()) {
146 146
 
147 147
 			// Setup the logged in user variables.
148
-			$payments_link = trailingslashit( bp_loggedin_user_domain() . 'getpaid/' );
148
+			$payments_link = trailingslashit(bp_loggedin_user_domain() . 'getpaid/');
149 149
 
150 150
             // Add the "Payments" sub menu.
151 151
             $wp_admin_nav[] = array(
152 152
                 'parent' => buddypress()->my_account_menu_id,
153 153
                 'id'     => 'my-account-getpaid',
154
-                'title'  => _x( 'Billing', 'BuddyPress my account payments sub nav', 'invoicing' ),
155
-                'href'   => $payments_link . apply_filters( 'getpaid_default_tab', 'gp-edit-address' ),
154
+                'title'  => _x('Billing', 'BuddyPress my account payments sub nav', 'invoicing'),
155
+                'href'   => $payments_link . apply_filters('getpaid_default_tab', 'gp-edit-address'),
156 156
             );
157 157
 
158
-            foreach ( getpaid_get_user_content_tabs() as $slug => $tab ) {
158
+            foreach (getpaid_get_user_content_tabs() as $slug => $tab) {
159 159
 
160 160
                 $wp_admin_nav[] = array(
161 161
                     'parent'   => 'my-account-getpaid',
162 162
                     'id'       => 'my-account-getpaid' . $slug,
163
-                    'title'    => $tab[ 'label'],
164
-                    'href'     => trailingslashit( $payments_link . $slug ),
163
+                    'title'    => $tab['label'],
164
+                    'href'     => trailingslashit($payments_link . $slug),
165 165
                     'position' => 20
166 166
                 );
167 167
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 
170 170
 		}
171 171
 
172
-		parent::setup_admin_bar( $wp_admin_nav );
172
+		parent::setup_admin_bar($wp_admin_nav);
173 173
 	}
174 174
 
175 175
 	/**
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
 	public function get_current_tab() {
181 181
 		global $getpaid_bp_current_tab;
182 182
 
183
-		if ( empty( $getpaid_bp_current_tab ) ) {
183
+		if (empty($getpaid_bp_current_tab)) {
184 184
 			return array(
185
-				'label'     => __( 'Invoices', 'invoicing' ),
185
+				'label'     => __('Invoices', 'invoicing'),
186 186
 				'content'   => '[wpinv_history]',
187 187
 				'icon'      => 'fas fa-file-invoice',
188 188
 			);
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
 	 */
199 199
 	public function display_current_tab() {
200 200
 
201
-		add_action( 'bp_template_content', array( $this, 'handle_display_current_tab' ) );
202
-		$template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' );
201
+		add_action('bp_template_content', array($this, 'handle_display_current_tab'));
202
+		$template = apply_filters('bp_core_template_plugin', 'members/single/plugins');
203 203
 
204
-        bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) );
204
+        bp_core_load_template(apply_filters('wpinv_bp_core_template_plugin', $template));
205 205
 	}
206 206
 
207 207
 	/**
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 * @since 2.1.5
211 211
 	 */
212 212
 	public function handle_display_current_tab() {
213
-		echo getpaid_prepare_user_content_tab( $this->get_current_tab() );
213
+		echo getpaid_prepare_user_content_tab($this->get_current_tab());
214 214
 	}
215 215
 
216 216
 }
Please login to merge, or discard this patch.