| Conditions | 1 |
| Paths | 1 |
| Total Lines | 113 |
| Code Lines | 92 |
| 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 |
||
| 65 | function add_template( $gallery_templates ) { |
||
| 66 | |||
| 67 | $gallery_templates[] = array( |
||
| 68 | 'slug' => 'image-viewer', |
||
| 69 | 'name' => __( 'Image Viewer', 'foogallery' ), |
||
| 70 | 'preview_support' => true, |
||
| 71 | 'common_fields_support' => true, |
||
| 72 | 'lazyload_support' => true, |
||
| 73 | 'mandatory_classes' => 'fg-image-viewer', |
||
| 74 | 'thumbnail_dimensions' => true, |
||
| 75 | 'fields' => array( |
||
| 76 | array( |
||
| 77 | 'id' => 'thumbnail-help', |
||
| 78 | 'title' => __( 'Thumbnail Help', 'foogallery' ), |
||
| 79 | 'desc' => __( 'It is recommended to crop your thumbnails, so that your gallery remains a constant size. If you do not crop, then the size of the gallery could potentially change for each thumbnail.', 'foogallery' ), |
||
| 80 | 'section' => __( 'General', 'foogallery' ), |
||
| 81 | 'type' => 'help' |
||
| 82 | ), |
||
| 83 | array( |
||
| 84 | 'id' => 'thumbnail_size', |
||
| 85 | 'title' => __( 'Thumb Size', 'foogallery' ), |
||
| 86 | 'section' => __( 'General', 'foogallery' ), |
||
| 87 | 'desc' => __( 'Choose the size of your thumbnails', 'foogallery' ), |
||
| 88 | 'type' => 'thumb_size', |
||
| 89 | 'default' => array( |
||
| 90 | 'width' => 640, |
||
| 91 | 'height' => 360, |
||
| 92 | 'crop' => true |
||
| 93 | ), |
||
| 94 | 'row_data'=> array( |
||
| 95 | 'data-foogallery-change-selector' => 'input', |
||
| 96 | 'data-foogallery-preview' => 'shortcode' |
||
| 97 | ) |
||
| 98 | ), |
||
| 99 | array( |
||
| 100 | 'id' => 'thumbnail_link', |
||
| 101 | 'title' => __( 'Thumb Link', 'foogallery' ), |
||
| 102 | 'section' => __( 'General', 'foogallery' ), |
||
| 103 | 'default' => 'image' , |
||
| 104 | 'type' => 'thumb_link', |
||
| 105 | 'desc' => __( 'You can choose to either link each thumbnail to the full size image or to the image\'s attachment page', 'foogallery') |
||
| 106 | ), |
||
| 107 | array( |
||
| 108 | 'id' => 'lightbox', |
||
| 109 | 'title' => __( 'Lightbox', 'foogallery' ), |
||
| 110 | 'section' => __( 'General', 'foogallery' ), |
||
| 111 | 'desc' => __( 'Choose which lightbox you want to use in the gallery', 'foogallery' ), |
||
| 112 | 'default' => 'none', |
||
| 113 | 'type' => 'lightbox' |
||
| 114 | ), |
||
| 115 | array( |
||
| 116 | 'id' => 'alignment', |
||
| 117 | 'title' => __( 'Alignment', 'foogallery' ), |
||
| 118 | 'section' => __( 'General', 'foogallery' ), |
||
| 119 | 'desc' => __( 'The horizontal alignment of the thumbnails inside the gallery', 'foogallery' ), |
||
| 120 | 'default' => 'fg-center', |
||
| 121 | 'type' => 'radio', |
||
| 122 | 'spacer' => '<span class="spacer"></span>', |
||
| 123 | 'choices' => array( |
||
| 124 | 'fg-left' => __( 'Left', 'foogallery' ), |
||
| 125 | 'fg-center' => __( 'Center', 'foogallery' ), |
||
| 126 | 'fg-right' => __( 'Right', 'foogallery' ), |
||
| 127 | ), |
||
| 128 | 'row_data'=> array( |
||
| 129 | 'data-foogallery-change-selector' => 'input:radio', |
||
| 130 | 'data-foogallery-preview' => 'class' |
||
| 131 | ) |
||
| 132 | ), |
||
| 133 | array( |
||
| 134 | 'id' => 'language-help', |
||
| 135 | 'title' => __( 'Language Help', 'foogallery' ), |
||
| 136 | 'desc' => __( 'This gallery template shows the below items of text. Change them to suit your preference or language.', 'foogallery' ), |
||
| 137 | 'section' => __( 'General', 'foogallery' ), |
||
| 138 | 'type' => 'help' |
||
| 139 | ), |
||
| 140 | array( |
||
| 141 | 'id' => 'text-prev', |
||
| 142 | 'title' => __( '"Prev" Text', 'foogallery' ), |
||
| 143 | 'section' => __( 'General', 'foogallery' ), |
||
| 144 | 'type' => 'text', |
||
| 145 | 'default' => __('Prev', 'foogallery'), |
||
| 146 | 'row_data'=> array( |
||
| 147 | 'data-foogallery-change-selector' => 'input', |
||
| 148 | 'data-foogallery-preview' => 'shortcode' |
||
| 149 | ) |
||
| 150 | ), |
||
| 151 | array( |
||
| 152 | 'id' => 'text-of', |
||
| 153 | 'title' => __( '"of" Text', 'foogallery' ), |
||
| 154 | 'section' => __( 'General', 'foogallery' ), |
||
| 155 | 'type' => 'text', |
||
| 156 | 'default' => __('of', 'foogallery'), |
||
| 157 | 'row_data'=> array( |
||
| 158 | 'data-foogallery-change-selector' => 'input', |
||
| 159 | 'data-foogallery-preview' => 'shortcode' |
||
| 160 | ) |
||
| 161 | ), |
||
| 162 | array( |
||
| 163 | 'id' => 'text-next', |
||
| 164 | 'title' => __( '"Next" Text', 'foogallery' ), |
||
| 165 | 'section' => __( 'General', 'foogallery' ), |
||
| 166 | 'type' => 'text', |
||
| 167 | 'default' => __('Next', 'foogallery'), |
||
| 168 | 'row_data'=> array( |
||
| 169 | 'data-foogallery-change-selector' => 'input', |
||
| 170 | 'data-foogallery-preview' => 'shortcode' |
||
| 171 | ) |
||
| 172 | ) |
||
| 173 | ) |
||
| 174 | ); |
||
| 175 | |||
| 176 | return $gallery_templates; |
||
| 177 | } |
||
| 178 | |||
| 280 | } |
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.