Completed
Pull Request — master (#11534)
by Nicola
09:40
created

WC_Settings_Accounts::get_settings()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 150
Code Lines 112

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 150
rs 8.2857
cc 1
eloc 112
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * WooCommerce Account Settings
4
 *
5
 * @author      WooThemes
6
 * @category    Admin
7
 * @package     WooCommerce/Admin
8
 * @version     2.1.0
9
 */
10
11
if ( ! defined( 'ABSPATH' ) ) {
12
	exit; // Exit if accessed directly
13
}
14
15
if ( ! class_exists( 'WC_Settings_Accounts' ) ) :
16
17
/**
18
 * WC_Settings_Accounts.
19
 */
20
class WC_Settings_Accounts extends WC_Settings_Page {
21
22
	/**
23
	 * Constructor.
24
	 */
25
	public function __construct() {
26
27
		$this->id    = 'account';
28
		$this->label = __( 'Accounts', 'woocommerce' );
29
30
		add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
31
		add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
32
		add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );
33
	}
34
35
	/**
36
	 * Get settings array.
37
	 *
38
	 * @return array
39
	 */
40
	public function get_settings() {
41
		$settings = apply_filters( 'woocommerce_' . $this->id . '_settings', array(
42
43
			array( 'title' => __( 'Account Pages', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'These pages need to be set so that WooCommerce knows where to send users to access account related functionality.', 'woocommerce' ), 'id' => 'account_page_options' ),
44
45
			array(
46
				'title'    => __( 'My Account Page', 'woocommerce' ),
47
				'desc'     => __( 'Page contents:', 'woocommerce' ) . ' [' . apply_filters( 'woocommerce_my_account_shortcode_tag', 'woocommerce_my_account' ) . ']',
48
				'id'       => 'woocommerce_myaccount_page_id',
49
				'type'     => 'single_select_page',
50
				'default'  => '',
51
				'class'    => 'wc-enhanced-select',
52
				'css'      => 'min-width:300px;',
53
				'desc_tip' => true,
54
			),
55
56
			array( 'type' => 'sectionend', 'id' => 'account_page_options' ),
57
58
			array(	'title' => '', 'type' => 'title', 'id' => 'account_registration_options' ),
59
60
			array(
61
				'title'         => __( 'Enable Registration', 'woocommerce' ),
62
				'desc'          => __( 'Enable registration on the "Checkout" page', 'woocommerce' ),
63
				'id'            => 'woocommerce_enable_signup_and_login_from_checkout',
64
				'default'       => 'yes',
65
				'type'          => 'checkbox',
66
				'checkboxgroup' => 'start',
67
				'autoload'      => false
68
			),
69
70
			array(
71
				'desc'          => __( 'Enable registration on the "My Account" page', 'woocommerce' ),
72
				'id'            => 'woocommerce_enable_myaccount_registration',
73
				'default'       => 'no',
74
				'type'          => 'checkbox',
75
				'checkboxgroup' => 'end',
76
				'autoload'      => false
77
			),
78
79
			array(
80
				'title'         => __( 'Login', 'woocommerce' ),
81
				'desc'          => __( 'Display returning customer login reminder on the "Checkout" page', 'woocommerce' ),
82
				'id'            => 'woocommerce_enable_checkout_login_reminder',
83
				'default'       => 'yes',
84
				'type'          => 'checkbox',
85
				'checkboxgroup' => 'start',
86
				'autoload'      => false
87
			),
88
89
			array(
90
				'title'         => __( 'Account Creation', 'woocommerce' ),
91
				'desc'          => __( 'Automatically generate username from customer email', 'woocommerce' ),
92
				'id'            => 'woocommerce_registration_generate_username',
93
				'default'       => 'yes',
94
				'type'          => 'checkbox',
95
				'checkboxgroup' => 'start',
96
				'autoload'      => false
97
			),
98
99
			array(
100
				'desc'          => __( 'Automatically generate customer password', 'woocommerce' ),
101
				'id'            => 'woocommerce_registration_generate_password',
102
				'default'       => 'no',
103
				'type'          => 'checkbox',
104
				'checkboxgroup' => 'end',
105
				'autoload'      => false
106
			),
107
108
			array( 'type' => 'sectionend', 'id' => 'account_registration_options' ),
109
110
			array( 'title' => __( 'My Account Endpoints', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'Endpoints are appended to your page URLs to handle specific actions on the accounts pages. They should be unique and can be left blank to disable the endpoint.', 'woocommerce' ), 'id' => 'account_endpoint_options' ),
111
112
			array(
113
				'title'    => __( 'Orders', 'woocommerce' ),
114
				'desc'     => sprintf( __( 'Endpoint for the My Account &rarr; %s page', 'woocommerce' ), __( 'Orders', 'woocommerce' ) ),
115
				'id'       => 'woocommerce_myaccount_orders_endpoint',
116
				'type'     => 'text',
117
				'default'  => 'orders',
118
				'desc_tip' => true,
119
			),
120
121
			array(
122
				'title'    => __( 'View Order', 'woocommerce' ),
123
				'desc'     => sprintf( __( 'Endpoint for the My Account &rarr; %s page', 'woocommerce' ), __( 'View Order', 'woocommerce' ) ),
124
				'id'       => 'woocommerce_myaccount_view_order_endpoint',
125
				'type'     => 'text',
126
				'default'  => 'view-order',
127
				'desc_tip' => true,
128
			),
129
130
			array(
131
				'title'    => __( 'Downloads', 'woocommerce' ),
132
				'desc'     => sprintf( __( 'Endpoint for the My Account &rarr; %s page', 'woocommerce' ), __( 'Downloads', 'woocommerce' ) ),
133
				'id'       => 'woocommerce_myaccount_downloads_endpoint',
134
				'type'     => 'text',
135
				'default'  => 'downloads',
136
				'desc_tip' => true,
137
			),
138
139
			array(
140
				'title'    => __( 'Edit Account', 'woocommerce' ),
141
				'desc'     => sprintf( __( 'Endpoint for the My Account &rarr; %s page', 'woocommerce' ), __( 'Edit Account', 'woocommerce' ) ),
142
				'id'       => 'woocommerce_myaccount_edit_account_endpoint',
143
				'type'     => 'text',
144
				'default'  => 'edit-account',
145
				'desc_tip' => true,
146
			),
147
148
			array(
149
				'title'    => __( 'Addresses', 'woocommerce' ),
150
				'desc'     => sprintf( __( 'Endpoint for the My Account &rarr; %s page', 'woocommerce' ), __( 'Addresses', 'woocommerce' ) ),
151
				'id'       => 'woocommerce_myaccount_edit_address_endpoint',
152
				'type'     => 'text',
153
				'default'  => 'edit-address',
154
				'desc_tip' => true,
155
			),
156
157
			array(
158
				'title'    => __( 'Payment Methods', 'woocommerce' ),
159
				'desc'     => sprintf( __( 'Endpoint for the My Account &rarr; %s page', 'woocommerce' ), __( 'Payment Methods', 'woocommerce' ),
160
				'id'       => 'woocommerce_myaccount_payment_methods_endpoint',
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_DOUBLE_ARROW, expecting ',' or ')'
Loading history...
161
				'type'     => 'text',
162
				'default'  => 'payment-methods',
163
				'desc_tip' => true,
164
			),
165
166
			array(
167
				'title'    => __( 'Lost Password', 'woocommerce' ),
168
				'desc'     => sprintf( __( 'Endpoint for the My Account &rarr; %s page', 'woocommerce' ), __( 'Lost Password', 'woocommerce' ) ),
169
				'id'       => 'woocommerce_myaccount_lost_password_endpoint',
170
				'type'     => 'text',
171
				'default'  => 'lost-password',
172
				'desc_tip' => true,
173
			),
174
175
			array(
176
				'title' => __( 'Logout', 'woocommerce' ),
177
				'desc'     => __( 'Endpoint for the triggering logout. You can add this to your menus via a custom link: yoursite.com/?customer-logout=true', 'woocommerce' ),
178
				'id'       => 'woocommerce_logout_endpoint',
179
				'type'     => 'text',
180
				'default'  => 'customer-logout',
181
				'desc_tip' => true,
182
			),
183
184
			array( 'type' => 'sectionend', 'id' => 'account_endpoint_options' ),
185
186
		) );
187
188
		return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings );
189
	}
190
}
191
192
endif;
193
194
return new WC_Settings_Accounts();
195