Conditions | 1 |
Paths | 1 |
Total Lines | 80 |
Code Lines | 66 |
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 |
||
53 | function add_template( $gallery_templates ) { |
||
54 | $gallery_templates[] = array( |
||
55 | 'slug' => 'polaroid_new', |
||
56 | 'name' => __( 'Polaroid', 'foogallery' ), |
||
57 | 'preview_support' => true, |
||
58 | 'common_fields_support' => true, |
||
59 | 'lazyload_support' => true, |
||
60 | 'paging_support' => true, |
||
61 | 'mandatory_classes' => 'fg-simple_portfolio fg-preset fg-polaroid', |
||
62 | 'fields' => array( |
||
63 | array( |
||
64 | 'id' => 'thumbnail_dimensions', |
||
65 | 'title' => __( 'Thumbnail Size', 'foogallery' ), |
||
66 | 'desc' => __( 'Choose the size of your thumbnails.', 'foogallery' ), |
||
67 | 'section' => __( 'General', 'foogallery' ), |
||
68 | 'type' => 'thumb_size', |
||
69 | 'default' => array( |
||
70 | 'width' => 250, |
||
71 | 'height' => 200, |
||
72 | 'crop' => true, |
||
73 | ), |
||
74 | 'row_data'=> array( |
||
75 | 'data-foogallery-change-selector' => 'input', |
||
76 | 'data-foogallery-preview' => 'shortcode' |
||
77 | ) |
||
78 | ), |
||
79 | array( |
||
80 | 'id' => 'thumbnail_link', |
||
81 | 'title' => __( 'Thumbnail Link', 'foogallery' ), |
||
82 | 'section' => __( 'General', 'foogallery' ), |
||
83 | 'default' => 'image', |
||
84 | 'type' => 'thumb_link', |
||
85 | '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' ) |
||
86 | ), |
||
87 | array( |
||
88 | 'id' => 'lightbox', |
||
89 | 'title' => __( 'Lightbox', 'foogallery' ), |
||
90 | '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' ), |
||
91 | 'section' => __( 'General', 'foogallery' ), |
||
92 | 'type' => 'lightbox', |
||
93 | ), |
||
94 | array( |
||
95 | 'id' => 'gutter', |
||
96 | 'title' => __( 'Gutter', 'foogallery' ), |
||
97 | 'desc' => __( 'The spacing between each thumbnail in the gallery.', 'foogallery' ), |
||
98 | 'section' => __( 'General', 'foogallery' ), |
||
99 | 'type' => 'number', |
||
100 | 'class' => 'small-text', |
||
101 | 'default' => 40, |
||
102 | 'step' => '1', |
||
103 | 'min' => '0', |
||
104 | 'row_data'=> array( |
||
105 | 'data-foogallery-change-selector' => 'input', |
||
106 | 'data-foogallery-value-selector' => 'input', |
||
107 | 'data-foogallery-preview' => 'data', |
||
108 | ) |
||
109 | ), |
||
110 | array( |
||
111 | 'id' => 'caption_position', |
||
112 | 'title' => __('Caption Position', 'foogallery'), |
||
113 | 'desc' => __('Where the captions are displayed in relation to the thumbnail.', 'foogallery'), |
||
114 | 'section' => __( 'Captions', 'foogallery' ), |
||
115 | 'default' => '', |
||
116 | 'type' => 'radio', |
||
117 | 'spacer' => '<span class="spacer"></span>', |
||
118 | 'choices' => array( |
||
119 | '' => __( 'Below', 'foogallery' ), |
||
120 | 'fg-captions-top' => __( 'Above', 'foogallery' ) |
||
121 | ), |
||
122 | 'row_data'=> array( |
||
123 | 'data-foogallery-change-selector' => 'input:radio', |
||
124 | 'data-foogallery-value-selector' => 'input:checked', |
||
125 | 'data-foogallery-preview' => 'class' |
||
126 | ) |
||
127 | ), |
||
128 | ), |
||
129 | ); |
||
130 | |||
131 | return $gallery_templates; |
||
132 | } |
||
133 | |||
249 | } |
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.