| Conditions | 1 |
| Paths | 1 |
| Total Lines | 94 |
| Code Lines | 76 |
| 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 |
||
| 45 | function add_template( $gallery_templates ) { |
||
| 46 | $gallery_templates[] = array( |
||
| 47 | 'slug' => 'default', |
||
| 48 | 'name' => __( 'Responsive Image Gallery', 'foogallery' ), |
||
| 49 | 'lazyload_support' => true, |
||
| 50 | 'fields' => array( |
||
| 51 | array( |
||
| 52 | 'id' => 'thumbnail_dimensions', |
||
| 53 | 'title' => __( 'Thumbnail Size', 'foogallery' ), |
||
| 54 | 'desc' => __( 'Choose the size of your thumbnails.', 'foogallery' ), |
||
| 55 | 'section' => __( 'General', 'foogallery' ), |
||
| 56 | 'type' => 'thumb_size', |
||
| 57 | 'default' => array( |
||
| 58 | 'width' => get_option( 'thumbnail_size_w' ), |
||
| 59 | 'height' => get_option( 'thumbnail_size_h' ), |
||
| 60 | 'crop' => true, |
||
| 61 | ), |
||
| 62 | 'row_data'=> array( |
||
| 63 | 'data-foogallery-preview' => 'shortcode' |
||
| 64 | ) |
||
| 65 | ), |
||
| 66 | array( |
||
| 67 | 'id' => 'thumbnail_link', |
||
| 68 | 'title' => __( 'Link To', 'foogallery' ), |
||
| 69 | 'section' => __( 'General', 'foogallery' ), |
||
| 70 | 'default' => 'image', |
||
| 71 | 'type' => 'thumb_link', |
||
| 72 | 'desc' => __( 'You can choose to link each thumbnail to the full size image, the image\'s attachment page, a custom URL, or you can choose to not link to anything.', 'foogallery' ), |
||
| 73 | ), |
||
| 74 | array( |
||
| 75 | 'id' => 'lightbox', |
||
| 76 | 'title' => __( 'Lightbox', 'foogallery' ), |
||
| 77 | 'desc' => __( 'Choose which lightbox you want to use. The lightbox will generally only work if you set the thumbnail link to "Full Size Image".', 'foogallery' ), |
||
| 78 | 'section' => __( 'General', 'foogallery' ), |
||
| 79 | 'type' => 'lightbox', |
||
| 80 | 'row_data'=> array( |
||
| 81 | 'data-foogallery-change-selector' => 'select' |
||
| 82 | ) |
||
| 83 | ), |
||
| 84 | array( |
||
| 85 | 'id' => 'lightbox_foobox_help', |
||
| 86 | 'title' => __( 'FooBox Help', 'foogallery' ), |
||
| 87 | 'desc' => __( 'The FooBox lightbox is a separate plugin.', 'foogallery' ), |
||
| 88 | 'section' => __( 'General', 'foogallery' ), |
||
| 89 | 'type' => 'help', |
||
| 90 | 'row_data'=> array( |
||
| 91 | 'data-foogallery-hidden' => true, |
||
| 92 | 'data-foogallery-show-when-field' => 'lightbox', |
||
| 93 | 'data-foogallery-show-when-field-value' => 'foobox' |
||
| 94 | ) |
||
| 95 | ), |
||
| 96 | array( |
||
| 97 | 'id' => 'spacing', |
||
| 98 | 'title' => __( 'Spacing', 'foogallery' ), |
||
| 99 | 'desc' => __( 'The spacing or gap between thumbnails in the gallery.', 'foogallery' ), |
||
| 100 | 'section' => __( 'General', 'foogallery' ), |
||
| 101 | 'type' => 'select', |
||
| 102 | 'default' => 'fg-gutter-10', |
||
| 103 | 'choices' => array( |
||
| 104 | 'fg-gutter-0' => __( 'none', 'foogallery' ), |
||
| 105 | 'fg-gutter-5' => __( '5 pixels', 'foogallery' ), |
||
| 106 | 'fg-gutter-10' => __( '10 pixels', 'foogallery' ), |
||
| 107 | 'fg-gutter-15' => __( '15 pixels', 'foogallery' ), |
||
| 108 | 'fg-gutter-20' => __( '20 pixels', 'foogallery' ), |
||
| 109 | 'fg-gutter-25' => __( '25 pixels', 'foogallery' ), |
||
| 110 | ), |
||
| 111 | 'row_data'=> array( |
||
| 112 | 'data-foogallery-change-selector' => 'select', |
||
| 113 | 'data-foogallery-preview' => 'class' |
||
| 114 | ) |
||
| 115 | ), |
||
| 116 | array( |
||
| 117 | 'id' => 'alignment', |
||
| 118 | 'title' => __( 'Alignment', 'foogallery' ), |
||
| 119 | 'desc' => __( 'The horizontal alignment of the thumbnails inside the gallery.', 'foogallery' ), |
||
| 120 | 'section' => __( 'General', 'foogallery' ), |
||
| 121 | 'default' => 'fg-center', |
||
| 122 | 'type' => 'radio', |
||
| 123 | 'spacer' => '<span class="spacer"></span>', |
||
| 124 | 'choices' => array( |
||
| 125 | 'fg-left' => __( 'Left', 'foogallery' ), |
||
| 126 | 'fg-center' => __( 'Center', 'foogallery' ), |
||
| 127 | 'fg-right' => __( 'Right', 'foogallery' ), |
||
| 128 | ), |
||
| 129 | 'row_data'=> array( |
||
| 130 | 'data-foogallery-change-selector' => 'input:radio', |
||
| 131 | 'data-foogallery-preview' => 'class' |
||
| 132 | ) |
||
| 133 | ) |
||
| 134 | ) |
||
| 135 | ); |
||
| 136 | |||
| 137 | return $gallery_templates; |
||
| 138 | } |
||
| 139 | |||
| 193 | } |
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.