WC_Settings_Accounts::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
dl 9
loc 9
rs 9.6666
c 0
b 0
f 0
eloc 6
nc 1
nop 0
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 View Code Duplication
	public function __construct() {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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.', 'woocommerce' ), 'id' => 'account_endpoint_options' ),
111
112
			array(
113
				'title'    => __( 'Orders', 'woocommerce' ),
114
				'desc'     => __( 'Endpoint for the My Account &rarr; Orders page', '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'     => __( 'Endpoint for the My Account &rarr; View Order page', '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'     => __( 'Endpoint for the My Account &rarr; Downloads page', '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'     => __( 'Endpoint for the My Account &rarr; Edit Account page', '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'     => __( 'Endpoint for the My Account &rarr; Addresses page', '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'     => __( 'Endpoint for the My Account &rarr; Payment Methods page', 'woocommerce' ),
160
				'id'       => 'woocommerce_myaccount_payment_methods_endpoint',
161
				'type'     => 'text',
162
				'default'  => 'payment-methods',
163
				'desc_tip' => true,
164
			),
165
166
			array(
167
				'title'    => __( 'Lost Password', 'woocommerce' ),
168
				'desc'     => __( 'Endpoint for the My Account &rarr; Lost Password page', '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