| Conditions | 1 |
| Paths | 1 |
| Total Lines | 98 |
| Code Lines | 81 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 34 | function add_template( $gallery_templates ) { |
||
| 35 | $gallery_templates[] = array( |
||
| 36 | 'slug' => 'masonry', |
||
| 37 | 'name' => __( 'Masonry Image Gallery', 'foogallery' ), |
||
| 38 | 'admin_js' => FOOGALLERY_MASONRY_GALLERY_TEMPLATE_URL . 'js/admin-gallery-masonry.js', |
||
| 39 | 'fields' => array( |
||
| 40 | array( |
||
| 41 | 'id' => 'thumbnail_width', |
||
| 42 | 'title' => __( 'Thumbnail Width', 'foogallery' ), |
||
| 43 | 'desc' => __( 'Choose the width of your thumbnails. Thumbnails will be generated on the fly and cached once generated.', 'foogallery' ), |
||
| 44 | 'type' => 'number', |
||
| 45 | 'class' => 'small-text', |
||
| 46 | 'default' => 150, |
||
| 47 | 'step' => '1', |
||
| 48 | 'min' => '0', |
||
| 49 | ), |
||
| 50 | array( |
||
| 51 | 'id' => 'layout', |
||
| 52 | 'title' => __( 'Masonry Layout', 'foogallery' ), |
||
| 53 | 'desc' => __( 'Choose a fixed width thumb layout, or responsive columns.', 'foogallery' ), |
||
| 54 | 'type' => 'radio', |
||
| 55 | 'choices' => array( |
||
| 56 | 'fixed' => __( 'Fixed Width', 'foogallery' ), |
||
| 57 | '2col' => __( '2 Columns', 'foogallery' ), |
||
| 58 | '3col' => __( '3 Columns', 'foogallery' ), |
||
| 59 | '4col' => __( '4 Columns', 'foogallery' ), |
||
| 60 | '5col' => __( '5 Columns', 'foogallery' ) |
||
| 61 | ), |
||
| 62 | 'spacer' => '<span class="spacer"></span>', |
||
| 63 | 'default' => 'fixed' |
||
| 64 | ), |
||
| 65 | array( |
||
| 66 | 'id' => 'gutter_width', |
||
| 67 | 'title' => __( 'Gutter Width', 'foogallery' ), |
||
| 68 | 'desc' => __( 'The spacing between your thumbnails. Only applicable when using a fixed layout!', 'foogallery' ), |
||
| 69 | 'type' => 'number', |
||
| 70 | 'class' => 'small-text', |
||
| 71 | 'default' => 10, |
||
| 72 | 'step' => '1', |
||
| 73 | 'min' => '0', |
||
| 74 | ), |
||
| 75 | array( |
||
| 76 | 'id' => 'center_align', |
||
| 77 | 'title' => __( 'Image Alignment', 'foogallery' ), |
||
| 78 | 'desc' => __( 'You can choose to center align your images or leave them at the default. Only applicable when using a fixed layout!', 'foogallery' ), |
||
| 79 | 'type' => 'radio', |
||
| 80 | 'choices' => array( |
||
| 81 | 'default' => __( 'Left Alignment', 'foogallery' ), |
||
| 82 | 'center' => __( 'Center Alignment', 'foogallery' ) |
||
| 83 | ), |
||
| 84 | 'spacer' => '<span class="spacer"></span>', |
||
| 85 | 'default' => 'default' |
||
| 86 | ), |
||
| 87 | array( |
||
| 88 | 'id' => 'gutter_percent', |
||
| 89 | 'title' => __( 'Gutter Size', 'foogallery' ), |
||
| 90 | 'desc' => __( 'Choose a gutter size when using responsive columns.', 'foogallery' ), |
||
| 91 | 'type' => 'radio', |
||
| 92 | 'choices' => array( |
||
| 93 | 'no-gutter' => __( 'No Gutter', 'foogallery' ), |
||
| 94 | '' => __( 'Normal Size Gutter', 'foogallery' ), |
||
| 95 | 'large-gutter' => __( 'Larger Gutter', 'foogallery' ) |
||
| 96 | ), |
||
| 97 | 'spacer' => '<span class="spacer"></span>', |
||
| 98 | 'default' => '' |
||
| 99 | ), |
||
| 100 | array( |
||
| 101 | 'id' => 'hover_zoom', |
||
| 102 | 'title' => __( 'Hover Zoom', 'foogallery' ), |
||
| 103 | 'desc' => __( 'The effect that is applied to images when you move your mouse over them.', 'foogallery' ), |
||
| 104 | 'type' => 'radio', |
||
| 105 | 'choices' => array( |
||
| 106 | 'default' => __( 'Zoom Slightly', 'foogallery' ), |
||
| 107 | 'none' => __( 'No Zoom', 'foogallery' ) |
||
| 108 | ), |
||
| 109 | 'spacer' => '<span class="spacer"></span>', |
||
| 110 | 'default' => 'default' |
||
| 111 | ), |
||
| 112 | array( |
||
| 113 | 'id' => 'thumbnail_link', |
||
| 114 | 'title' => __( 'Thumbnail Link', 'foogallery' ), |
||
| 115 | 'default' => 'image' , |
||
| 116 | 'type' => 'thumb_link', |
||
| 117 | 'spacer' => '<span class="spacer"></span>', |
||
| 118 | 'desc' => __( 'You can choose to link each thumbnail to the full size image, or to the image\'s attachment page, or you can choose to not link to anything.', 'foogallery' ), |
||
| 119 | ), |
||
| 120 | array( |
||
| 121 | 'id' => 'lightbox', |
||
| 122 | 'title' => __( 'Lightbox', 'foogallery' ), |
||
| 123 | 'desc' => __( 'Choose which lightbox you want to display images with. The lightbox will only work if you set the thumbnail link to "Full Size Image".', 'foogallery' ), |
||
| 124 | 'type' => 'lightbox', |
||
| 125 | ), |
||
| 126 | ), |
||
| 127 | ); |
||
| 128 | |||
| 129 | |||
| 130 | return $gallery_templates; |
||
| 131 | } |
||
| 132 | |||
| 142 | } |
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.