Conditions | 1 |
Paths | 1 |
Total Lines | 150 |
Code Lines | 112 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
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 → 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 → 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 → 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 → 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 → 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 → 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 → 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 | } |
||
195 |
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.