Conditions | 1 |
Paths | 1 |
Total Lines | 116 |
Code Lines | 87 |
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 |
||
53 | public function get_settings() { |
||
54 | $settings = apply_filters( 'woocommerce_email_settings', array( |
||
55 | |||
56 | array( 'title' => __( 'Email Notifications', 'woocommerce' ), 'desc' => __( 'Email notifications sent from WooCommerce are listed below. Click on an email to configure it.', 'woocommerce' ), 'type' => 'title', 'id' => 'email_notification_settings' ), |
||
57 | |||
58 | array( 'type' => 'email_notification' ), |
||
59 | |||
60 | array( 'type' => 'sectionend', 'id' => 'email_notification_settings' ), |
||
61 | |||
62 | array( 'type' => 'sectionend', 'id' => 'email_recipient_options' ), |
||
63 | |||
64 | array( 'title' => __( 'Email Sender Options', 'woocommerce' ), 'type' => 'title', 'desc' => '', 'id' => 'email_options' ), |
||
65 | |||
66 | array( |
||
67 | 'title' => __( '"From" Name', 'woocommerce' ), |
||
68 | 'desc' => __( 'How the sender\'s name appears in outgoing WooCommerce emails.', 'woocommerce' ), |
||
69 | 'id' => 'woocommerce_email_from_name', |
||
70 | 'type' => 'text', |
||
71 | 'css' => 'min-width:300px;', |
||
72 | 'default' => esc_attr( get_bloginfo( 'name', 'display' ) ), |
||
73 | 'autoload' => false, |
||
74 | 'desc_tip' => true |
||
75 | ), |
||
76 | |||
77 | array( |
||
78 | 'title' => __( '"From" Address', 'woocommerce' ), |
||
79 | 'desc' => __( 'How the sender\'s email appears in outgoing WooCommerce emails.', 'woocommerce' ), |
||
80 | 'id' => 'woocommerce_email_from_address', |
||
81 | 'type' => 'email', |
||
82 | 'custom_attributes' => array( |
||
83 | 'multiple' => 'multiple' |
||
84 | ), |
||
85 | 'css' => 'min-width:300px;', |
||
86 | 'default' => get_option( 'admin_email' ), |
||
87 | 'autoload' => false, |
||
88 | 'desc_tip' => true |
||
89 | ), |
||
90 | |||
91 | array( 'type' => 'sectionend', 'id' => 'email_options' ), |
||
92 | |||
93 | array( 'title' => __( 'Email Template', 'woocommerce' ), 'type' => 'title', 'desc' => sprintf(__( 'This section lets you customize the WooCommerce emails. <a href="%s" target="_blank">Click here to preview your email template</a>.', 'woocommerce' ), wp_nonce_url( admin_url( '?preview_woocommerce_mail=true' ), 'preview-mail' ) ), 'id' => 'email_template_options' ), |
||
94 | |||
95 | array( |
||
96 | 'title' => __( 'Header Image', 'woocommerce' ), |
||
97 | 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'woocommerce' ), |
||
98 | 'id' => 'woocommerce_email_header_image', |
||
99 | 'type' => 'text', |
||
100 | 'css' => 'min-width:300px;', |
||
101 | 'placeholder' => __( 'N/A', 'woocommerce' ), |
||
102 | 'default' => '', |
||
103 | 'autoload' => false, |
||
104 | 'desc_tip' => true |
||
105 | ), |
||
106 | |||
107 | array( |
||
108 | 'title' => __( 'Footer Text', 'woocommerce' ), |
||
109 | 'desc' => __( 'The text to appear in the footer of WooCommerce emails.', 'woocommerce' ), |
||
110 | 'id' => 'woocommerce_email_footer_text', |
||
111 | 'css' => 'width:300px; height: 75px;', |
||
112 | 'placeholder' => __( 'N/A', 'woocommerce' ), |
||
113 | 'type' => 'textarea', |
||
114 | 'default' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by WooCommerce', 'woocommerce' ), |
||
115 | 'autoload' => false, |
||
116 | 'desc_tip' => true |
||
117 | ), |
||
118 | |||
119 | array( |
||
120 | 'title' => __( 'Base Colour', 'woocommerce' ), |
||
121 | 'desc' => __( 'The base colour for WooCommerce email templates. Default <code>#557da1</code>.', 'woocommerce' ), |
||
122 | 'id' => 'woocommerce_email_base_color', |
||
123 | 'type' => 'color', |
||
124 | 'css' => 'width:6em;', |
||
125 | 'default' => '#557da1', |
||
126 | 'autoload' => false, |
||
127 | 'desc_tip' => true |
||
128 | ), |
||
129 | |||
130 | array( |
||
131 | 'title' => __( 'Background Colour', 'woocommerce' ), |
||
132 | 'desc' => __( 'The background colour for WooCommerce email templates. Default <code>#f5f5f5</code>.', 'woocommerce' ), |
||
133 | 'id' => 'woocommerce_email_background_color', |
||
134 | 'type' => 'color', |
||
135 | 'css' => 'width:6em;', |
||
136 | 'default' => '#f5f5f5', |
||
137 | 'autoload' => false, |
||
138 | 'desc_tip' => true |
||
139 | ), |
||
140 | |||
141 | array( |
||
142 | 'title' => __( 'Body Background Colour', 'woocommerce' ), |
||
143 | 'desc' => __( 'The main body background colour. Default <code>#fdfdfd</code>.', 'woocommerce' ), |
||
144 | 'id' => 'woocommerce_email_body_background_color', |
||
145 | 'type' => 'color', |
||
146 | 'css' => 'width:6em;', |
||
147 | 'default' => '#fdfdfd', |
||
148 | 'autoload' => false, |
||
149 | 'desc_tip' => true |
||
150 | ), |
||
151 | |||
152 | array( |
||
153 | 'title' => __( 'Body Text Colour', 'woocommerce' ), |
||
154 | 'desc' => __( 'The main body text colour. Default <code>#505050</code>.', 'woocommerce' ), |
||
155 | 'id' => 'woocommerce_email_text_color', |
||
156 | 'type' => 'color', |
||
157 | 'css' => 'width:6em;', |
||
158 | 'default' => '#505050', |
||
159 | 'autoload' => false, |
||
160 | 'desc_tip' => true |
||
161 | ), |
||
162 | |||
163 | array( 'type' => 'sectionend', 'id' => 'email_notification_settings' ), |
||
164 | |||
165 | ) ); |
||
166 | |||
167 | return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings ); |
||
168 | } |
||
169 | |||
306 |
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.