| Conditions | 4 |
| Paths | 2 |
| Total Lines | 217 |
| 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 | function add_paging_fields( $fields, $template ) { |
||
| 41 | if ( $template && array_key_exists( 'paging_support', $template ) && true === $template['paging_support'] ) { |
||
| 42 | $fields[] = array( |
||
| 43 | 'id' => 'paging_type', |
||
| 44 | 'title' => __( 'Paging Type', 'foogallery' ), |
||
| 45 | 'desc' => __( 'Add paging to a large gallery.', 'foogallery' ), |
||
| 46 | 'section' => __( 'Paging', 'foogallery' ), |
||
| 47 | 'spacer' => '<span class="spacer"></span>', |
||
| 48 | 'type' => 'radio', |
||
| 49 | 'default' => '', |
||
| 50 | 'choices' => apply_filters( 'foogallery_gallery_template_paging_type_choices', array( |
||
| 51 | '' => __( 'None', 'foogallery' ), |
||
| 52 | 'dots' => __( 'Dots', 'foogallery' ) |
||
| 53 | ) ), |
||
| 54 | 'row_data'=> array( |
||
| 55 | 'data-foogallery-change-selector' => 'input', |
||
| 56 | 'data-foogallery-preview' => 'shortcode', |
||
| 57 | 'data-foogallery-value-selector' => 'input:checked', |
||
| 58 | ) |
||
| 59 | ); |
||
| 60 | |||
| 61 | $fields[] = array( |
||
| 62 | 'id' => 'paging_size', |
||
| 63 | 'title' => __( 'Page Size', 'foogallery' ), |
||
| 64 | 'desc' => __( 'The size of your pages.', 'foogallery' ), |
||
| 65 | 'section' => __( 'Paging', 'foogallery' ), |
||
| 66 | 'type' => 'number', |
||
| 67 | 'class' => 'small-text', |
||
| 68 | 'default' => 20, |
||
| 69 | 'step' => '1', |
||
| 70 | 'min' => '0', |
||
| 71 | 'row_data'=> array( |
||
| 72 | 'data-foogallery-change-selector' => 'input', |
||
| 73 | 'data-foogallery-preview' => 'shortcode', |
||
| 74 | 'data-foogallery-hidden' => true, |
||
| 75 | 'data-foogallery-show-when-field' => 'paging_type', |
||
| 76 | 'data-foogallery-show-when-field-operator' => '!==', |
||
| 77 | 'data-foogallery-show-when-field-value' => '', |
||
| 78 | ) |
||
| 79 | ); |
||
| 80 | |||
| 81 | $fields[] = array( |
||
| 82 | 'id' => 'paging_position', |
||
| 83 | 'title' => __( 'Position', 'foogallery' ), |
||
| 84 | 'desc' => __( 'The position of the paging for either dots or pagination.', 'foogallery' ), |
||
| 85 | 'section' => __( 'Paging', 'foogallery' ), |
||
| 86 | 'spacer' => '<span class="spacer"></span>', |
||
| 87 | 'type' => 'radio', |
||
| 88 | 'default' => 'both', |
||
| 89 | 'choices' => apply_filters( 'foogallery_gallery_template_paging_position_choices', array( |
||
| 90 | '' => __( 'None', 'foogallery' ), |
||
| 91 | 'top' => __( 'Top', 'foogallery' ), |
||
| 92 | 'bottom' => __( 'Bottom', 'foogallery' ), |
||
| 93 | 'both' => __( 'Both', 'foogallery' ) |
||
| 94 | ) ), |
||
| 95 | 'row_data'=> array( |
||
| 96 | 'data-foogallery-hidden' => true, |
||
| 97 | 'data-foogallery-show-when-field-operator' => 'regex', |
||
| 98 | 'data-foogallery-show-when-field' => 'paging_type', |
||
| 99 | 'data-foogallery-show-when-field-value' => 'dots|pagination', |
||
| 100 | 'data-foogallery-change-selector' => 'input', |
||
| 101 | 'data-foogallery-preview' => 'shortcode' |
||
| 102 | ) |
||
| 103 | ); |
||
| 104 | |||
| 105 | $fields[] = array( |
||
| 106 | 'id' => 'paging_theme', |
||
| 107 | 'title' => __( 'Theme', 'foogallery' ), |
||
| 108 | 'desc' => __( 'The theme used for paging.', 'foogallery' ), |
||
| 109 | 'section' => __( 'Paging', 'foogallery' ), |
||
| 110 | 'spacer' => '<span class="spacer"></span>', |
||
| 111 | 'type' => 'radio', |
||
| 112 | 'default' => 'fg-light', |
||
| 113 | 'choices' => apply_filters( 'foogallery_gallery_template_paging_theme_choices', array( |
||
| 114 | 'fg-light' => __( 'Light', 'foogallery' ), |
||
| 115 | 'fg-dark' => __( 'Dark', 'foogallery' ), |
||
| 116 | ) ), |
||
| 117 | 'row_data'=> array( |
||
| 118 | 'data-foogallery-change-selector' => 'input', |
||
| 119 | 'data-foogallery-preview' => 'shortcode', |
||
| 120 | 'data-foogallery-hidden' => true, |
||
| 121 | 'data-foogallery-show-when-field' => 'paging_type', |
||
| 122 | 'data-foogallery-show-when-field-operator' => '!==', |
||
| 123 | 'data-foogallery-show-when-field-value' => '', |
||
| 124 | ) |
||
| 125 | ); |
||
| 126 | |||
| 127 | $fields[] = array( |
||
| 128 | 'id' => 'paging_scroll', |
||
| 129 | 'title' => __( 'Scroll To Top', 'foogallery' ), |
||
| 130 | 'desc' => __( 'Whether or not it should scroll to the top of the gallery when paging is changed.', 'foogallery' ), |
||
| 131 | 'section' => __( 'Paging', 'foogallery' ), |
||
| 132 | 'type' => 'radio', |
||
| 133 | 'spacer' => '<span class="spacer"></span>', |
||
| 134 | 'default' => 'true', |
||
| 135 | 'choices' => array( |
||
| 136 | 'true' => __( 'Yes', 'foogallery' ), |
||
| 137 | 'false' => __( 'No', 'foogallery' ), |
||
| 138 | ), |
||
| 139 | 'row_data'=> array( |
||
| 140 | 'data-foogallery-hidden' => true, |
||
| 141 | 'data-foogallery-show-when-field-operator' => 'regex', |
||
| 142 | 'data-foogallery-show-when-field' => 'paging_type', |
||
| 143 | 'data-foogallery-show-when-field-value' => 'dots|pagination', |
||
| 144 | 'data-foogallery-change-selector' => 'input', |
||
| 145 | 'data-foogallery-preview' => 'shortcode' |
||
| 146 | ) |
||
| 147 | ); |
||
| 148 | |||
| 149 | $fields[] = array( |
||
| 150 | 'id' => 'paging_limit', |
||
| 151 | 'title' => __( 'Paging Limit', 'foogallery' ), |
||
| 152 | 'desc' => __( 'The maximum number of page links to display for the gallery.', 'foogallery' ), |
||
| 153 | 'section' => __( 'Paging', 'foogallery' ), |
||
| 154 | 'type' => 'number', |
||
| 155 | 'class' => 'small-text', |
||
| 156 | 'default' => 5, |
||
| 157 | 'step' => '1', |
||
| 158 | 'min' => '0', |
||
| 159 | 'row_data'=> array( |
||
| 160 | 'data-foogallery-hidden' => true, |
||
| 161 | 'data-foogallery-show-when-field' => 'paging_type', |
||
| 162 | 'data-foogallery-show-when-field-value' => 'pagination', |
||
| 163 | 'data-foogallery-change-selector' => 'input', |
||
| 164 | 'data-foogallery-preview' => 'shortcode' |
||
| 165 | ) |
||
| 166 | ); |
||
| 167 | |||
| 168 | $fields[] = array( |
||
| 169 | 'id' => 'paging_showFirstLast', |
||
| 170 | 'title' => __( 'First & Last Buttons', 'foogallery' ), |
||
| 171 | 'desc' => __( 'Whether or not to show the first & last buttons for pagination.', 'foogallery' ), |
||
| 172 | 'section' => __( 'Paging', 'foogallery' ), |
||
| 173 | 'type' => 'radio', |
||
| 174 | 'spacer' => '<span class="spacer"></span>', |
||
| 175 | 'default' => 'true', |
||
| 176 | 'choices' => array( |
||
| 177 | 'true' => __( 'Show', 'foogallery' ), |
||
| 178 | 'false' => __( 'Hide', 'foogallery' ), |
||
| 179 | ), |
||
| 180 | 'row_data'=> array( |
||
| 181 | 'data-foogallery-hidden' => true, |
||
| 182 | 'data-foogallery-show-when-field' => 'paging_type', |
||
| 183 | 'data-foogallery-show-when-field-value' => 'pagination', |
||
| 184 | 'data-foogallery-change-selector' => 'input', |
||
| 185 | 'data-foogallery-preview' => 'shortcode' |
||
| 186 | ) |
||
| 187 | ); |
||
| 188 | |||
| 189 | $fields[] = array( |
||
| 190 | 'id' => 'paging_showPrevNext', |
||
| 191 | 'title' => __( 'Prev & Next Buttons', 'foogallery' ), |
||
| 192 | 'desc' => __( 'Whether or not to show the previous & next buttons for pagination.', 'foogallery' ), |
||
| 193 | 'section' => __( 'Paging', 'foogallery' ), |
||
| 194 | 'type' => 'radio', |
||
| 195 | 'spacer' => '<span class="spacer"></span>', |
||
| 196 | 'default' => 'true', |
||
| 197 | 'choices' => array( |
||
| 198 | 'true' => __( 'Show', 'foogallery' ), |
||
| 199 | 'false' => __( 'Hide', 'foogallery' ), |
||
| 200 | ), |
||
| 201 | 'row_data'=> array( |
||
| 202 | 'data-foogallery-hidden' => true, |
||
| 203 | 'data-foogallery-show-when-field' => 'paging_type', |
||
| 204 | 'data-foogallery-show-when-field-value' => 'pagination', |
||
| 205 | 'data-foogallery-change-selector' => 'input', |
||
| 206 | 'data-foogallery-preview' => 'shortcode' |
||
| 207 | ) |
||
| 208 | ); |
||
| 209 | |||
| 210 | $fields[] = array( |
||
| 211 | 'id' => 'paging_showPrevNextMore', |
||
| 212 | 'title' => __( 'More Buttons', 'foogallery' ), |
||
| 213 | 'desc' => __( 'Whether or not to show the previous & next more buttons for pagination.', 'foogallery' ), |
||
| 214 | 'section' => __( 'Paging', 'foogallery' ), |
||
| 215 | 'type' => 'radio', |
||
| 216 | 'spacer' => '<span class="spacer"></span>', |
||
| 217 | 'default' => 'true', |
||
| 218 | 'choices' => array( |
||
| 219 | 'true' => __( 'Show', 'foogallery' ), |
||
| 220 | 'false' => __( 'Hide', 'foogallery' ), |
||
| 221 | ), |
||
| 222 | 'row_data'=> array( |
||
| 223 | 'data-foogallery-hidden' => true, |
||
| 224 | 'data-foogallery-show-when-field' => 'paging_type', |
||
| 225 | 'data-foogallery-show-when-field-value' => 'pagination', |
||
| 226 | 'data-foogallery-change-selector' => 'input', |
||
| 227 | 'data-foogallery-preview' => 'shortcode' |
||
| 228 | ) |
||
| 229 | ); |
||
| 230 | |||
| 231 | $fields[] = array( |
||
| 232 | 'id' => 'paging_output', |
||
| 233 | 'title' => __( 'Paging Output', 'foogallery' ), |
||
| 234 | 'desc' => __( 'How the paging items are output. We recommend that very large galleries output as JSON.', 'foogallery' ), |
||
| 235 | 'section' => __( 'Paging', 'foogallery' ), |
||
| 236 | 'spacer' => '<span class="spacer"></span>', |
||
| 237 | 'type' => 'radio', |
||
| 238 | 'default' => 'html', |
||
| 239 | 'choices' => apply_filters( 'foogallery_gallery_template_paging_output_choices', array( |
||
| 240 | '' => __( 'JSON', 'foogallery' ), |
||
| 241 | 'html' => __( 'HTML', 'foogallery' ) |
||
| 242 | ) ), |
||
| 243 | 'row_data'=> array( |
||
| 244 | 'data-foogallery-change-selector' => 'input', |
||
| 245 | 'data-foogallery-preview' => 'shortcode', |
||
| 246 | 'data-foogallery-value-selector' => 'input:checked', |
||
| 247 | 'data-foogallery-hidden' => true, |
||
| 248 | 'data-foogallery-show-when-field' => 'paging_type', |
||
| 249 | 'data-foogallery-show-when-field-operator' => '!==', |
||
| 250 | 'data-foogallery-show-when-field-value' => '', |
||
| 251 | ) |
||
| 252 | ); |
||
| 253 | } |
||
| 254 | |||
| 255 | return $fields; |
||
| 256 | } |
||
| 257 | |||
| 433 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.