| Conditions | 1 |
| Paths | 1 |
| Total Lines | 151 |
| Code Lines | 94 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 72 | function wpsc_default_customizer_settings( $settings ) { |
||
| 73 | |||
| 74 | $settings['wpsc_crop_thumbnails'] = array( |
||
| 75 | 'control' => array( |
||
| 76 | 'type' => 'checkbox', |
||
| 77 | 'priority' => 10, |
||
| 78 | 'section' => 'wpsc_thumbnails', |
||
| 79 | 'label' => __( 'Crop Thumbnails' ), |
||
| 80 | 'default' => false, |
||
| 81 | 'description' => __( 'Crop images to the specified dimensions using center positions.' ), |
||
| 82 | ), |
||
| 83 | 'setting' => array( |
||
| 84 | 'type' => 'option', |
||
| 85 | 'capability' => 'manage_options', |
||
| 86 | 'default' => false, |
||
| 87 | 'sanitize_callback' => 'esc_attr', |
||
| 88 | ) |
||
| 89 | ); |
||
| 90 | |||
| 91 | // TODO: We need to create a custom control here for thumbnails...which means some modifications will be necessary. |
||
| 92 | |||
| 93 | /* |
||
| 94 | add_image_size( |
||
| 95 | 'wpsc_product_single_thumbnail', |
||
| 96 | get_option( 'single_view_image_width' ), |
||
| 97 | get_option( 'single_view_image_height' ), |
||
| 98 | $crop |
||
| 99 | ); |
||
| 100 | |||
| 101 | add_image_size( |
||
| 102 | 'wpsc_product_archive_thumbnail', |
||
| 103 | get_option( 'product_image_width' ), |
||
| 104 | get_option( 'product_image_height' ), |
||
| 105 | $crop |
||
| 106 | ); |
||
| 107 | |||
| 108 | add_image_size( |
||
| 109 | 'wpsc_product_taxonomy_thumbnail', |
||
| 110 | get_option( 'category_image_width' ), |
||
| 111 | get_option( 'category_image_height' ), |
||
| 112 | $crop |
||
| 113 | ); |
||
| 114 | */ |
||
| 115 | |||
| 116 | $settings['wpsc_products_per_row'] = array( |
||
| 117 | 'control' => array( |
||
| 118 | 'type' => 'number', |
||
| 119 | 'priority' => 20, |
||
| 120 | 'section' => 'wpsc_general', |
||
| 121 | 'label' => __( 'Products Per Page' ), |
||
| 122 | 'default' => get_option( 'posts_per_page' ), |
||
| 123 | 'description' => __( 'Set the maximum number of products per page.', 'wp-e-commerce' ), |
||
| 124 | ), |
||
| 125 | 'setting' => array( |
||
| 126 | 'type' => 'option', |
||
| 127 | 'capability' => 'manage_options', |
||
| 128 | 'default' => 'auto', |
||
| 129 | 'sanitize_callback' => 'is_numeric', |
||
| 130 | ), |
||
| 131 | 'partial' => array( |
||
| 132 | 'selector' => '#wpsc-products', |
||
| 133 | 'render_callback' => function() { |
||
| 134 | wpsc_get_template_part( 'loop', 'products' ); |
||
| 135 | } |
||
| 136 | ) |
||
| 137 | ); |
||
| 138 | |||
| 139 | $settings['wpsc_fancy_notifications'] = array( |
||
| 140 | 'control' => array( |
||
| 141 | 'type' => 'checkbox', |
||
| 142 | 'priority' => 10, |
||
| 143 | 'section' => 'wpsc_general', |
||
| 144 | 'label' => __( 'Add to Cart Notifications' ), |
||
| 145 | 'default' => false, |
||
| 146 | 'description' => __( 'Enable Add to Cart notifications. When adding an item to your cart, this will create a popup notification for users.' ), |
||
| 147 | ), |
||
| 148 | 'setting' => array( |
||
| 149 | 'type' => 'option', |
||
| 150 | 'capability' => 'manage_options', |
||
| 151 | 'default' => false, |
||
| 152 | 'sanitize_callback' => 'esc_attr', |
||
| 153 | ), |
||
| 154 | 'partial' => array( |
||
| 155 | 'selector' => '#wpsc-products', |
||
| 156 | 'render_callback' => function() { |
||
| 157 | wpsc_get_template_part( 'loop', 'products' ); |
||
| 158 | } |
||
| 159 | ) |
||
| 160 | ); |
||
| 161 | |||
| 162 | $settings['wpsc_layout'] = array( |
||
| 163 | 'control' => array( |
||
| 164 | 'type' => 'select', |
||
| 165 | 'priority' => 10, |
||
| 166 | 'section' => 'wpsc_layout', |
||
| 167 | 'label' => __( 'Layout' ), |
||
| 168 | 'default' => 'grid', |
||
| 169 | 'description' => __( 'Change the layout of your store.' ), |
||
| 170 | 'choices' => apply_filters( 'wpsc_layouts', array( |
||
| 171 | 'grid' => __( 'Grid', 'wp-e-commerce' ), |
||
| 172 | 'list' => __( 'List', 'wp-e-commerce' ) |
||
| 173 | ) ) |
||
| 174 | ), |
||
| 175 | 'setting' => array( |
||
| 176 | 'type' => 'option', |
||
| 177 | 'capability' => 'manage_options', |
||
| 178 | 'default' => 'grid', |
||
| 179 | 'sanitize_callback' => 'sanitize_text_field', |
||
| 180 | ), |
||
| 181 | 'partial' => array( |
||
| 182 | 'selector' => '#wpsc-products', |
||
| 183 | 'render_callback' => function() { |
||
| 184 | wpsc_get_template_part( 'loop', 'products' ); |
||
| 185 | } |
||
| 186 | ) |
||
| 187 | ); |
||
| 188 | |||
| 189 | $settings['wpsc_products_per_row'] = array( |
||
| 190 | 'control' => array( |
||
| 191 | 'type' => 'select', |
||
| 192 | 'priority' => 12, |
||
| 193 | 'section' => 'wpsc_layout', |
||
| 194 | 'label' => __( 'Products Per Row' ), |
||
| 195 | 'default' => 'auto', |
||
| 196 | 'description' => __( 'Set the maximum number of products per row. Defaults to showing as many as will fit, up to six products per row', 'wp-e-commerce' ), |
||
| 197 | 'choices' => apply_filters( 'wpsc_products_per_row_options', array( |
||
| 198 | 'auto' => __( 'Automatic', 'wp-e-commerce' ), |
||
| 199 | '1' => __( '1', 'wp-e-commerce' ), |
||
| 200 | '2' => __( '2', 'wp-e-commerce' ), |
||
| 201 | '3' => __( '3', 'wp-e-commerce' ), |
||
| 202 | '4' => __( '4', 'wp-e-commerce' ), |
||
| 203 | '5' => __( '5', 'wp-e-commerce' ), |
||
| 204 | '6' => __( '6', 'wp-e-commerce' ), |
||
| 205 | ) ) |
||
| 206 | ), |
||
| 207 | 'setting' => array( |
||
| 208 | 'type' => 'option', |
||
| 209 | 'capability' => 'manage_options', |
||
| 210 | 'default' => 'auto', |
||
| 211 | 'sanitize_callback' => 'is_numeric', |
||
| 212 | ), |
||
| 213 | 'partial' => array( |
||
| 214 | 'selector' => '#wpsc-products', |
||
| 215 | 'render_callback' => function() { |
||
| 216 | wpsc_get_template_part( 'loop', 'products' ); |
||
| 217 | } |
||
| 218 | ) |
||
| 219 | ); |
||
| 220 | |||
| 221 | return $settings; |
||
| 222 | } |
||
| 223 | |||
| 238 |