Conditions | 1 |
Paths | 1 |
Total Lines | 92 |
Code Lines | 75 |
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 |
||
44 | function add_template( $gallery_templates ) { |
||
45 | $gallery_templates[] = array( |
||
46 | 'slug' => 'thumbnail', |
||
47 | 'name' => __( 'Single Thumbnail Gallery', 'foogallery' ), |
||
48 | 'preview_support' => true, |
||
49 | 'common_fields_support' => true, |
||
50 | 'lazyload_support' => true, |
||
51 | 'mandatory_classes' => 'fg-thumbnail', |
||
52 | 'thumbnail_dimensions' => true, |
||
53 | 'fields' => array( |
||
54 | array( |
||
55 | 'id' => 'help', |
||
56 | 'type' => 'html', |
||
57 | 'section' => __( 'General', 'foogallery' ), |
||
58 | 'help' => true, |
||
59 | 'desc' => __( 'This gallery template only shows a single thumbnail, but the true power shines through when the thumbnail is clicked, because then the lightbox takes over and the user can view all the images in the gallery.', 'foogallery' ), |
||
60 | ), |
||
61 | array( |
||
62 | 'id' => 'thumbnail_dimensions', |
||
63 | 'title' => __( 'Size', 'foogallery' ), |
||
64 | 'desc' => __( 'Choose the size of your thumbnail.', 'foogallery' ), |
||
65 | 'section' => __( 'General', 'foogallery' ), |
||
66 | 'type' => 'thumb_size_no_crop', |
||
67 | 'default' => array( |
||
68 | 'width' => 250, |
||
69 | 'height' => 200 |
||
70 | ), |
||
71 | 'row_data'=> array( |
||
72 | 'data-foogallery-change-selector' => 'input', |
||
73 | 'data-foogallery-preview' => 'shortcode' |
||
74 | ) |
||
75 | ), |
||
76 | array( |
||
77 | 'id' => 'position', |
||
78 | 'title' => __( 'Position', 'foogallery' ), |
||
79 | 'desc' => __( 'The position of the thumbnail related to the content around it.', 'foogallery' ), |
||
80 | 'section' => __( 'General', 'foogallery' ), |
||
81 | 'default' => 'position-block', |
||
82 | 'type' => 'select', |
||
83 | 'choices' => array( |
||
84 | 'fg-center' => __( 'Full Width (block)', 'foogallery' ), |
||
85 | 'fg-left' => __( 'Float Left', 'foogallery' ), |
||
86 | 'fg-right' => __( 'Float Right', 'foogallery' ), |
||
87 | ), |
||
88 | 'row_data'=> array( |
||
89 | 'data-foogallery-change-selector' => 'select', |
||
90 | 'data-foogallery-preview' => 'class' |
||
91 | ) |
||
92 | ), |
||
93 | array( |
||
94 | 'id' => 'link_custom_url', |
||
95 | 'title' => __( 'Link To Custom URL', 'foogallery' ), |
||
96 | 'section' => __( 'General', 'foogallery' ), |
||
97 | 'default' => '', |
||
98 | 'type' => 'checkbox', |
||
99 | 'desc' => __( 'You can link your thumbnails to Custom URL\'s (if they are set on your attachments). Fallback will be to the full size image.', 'foogallery' ) |
||
100 | ), |
||
101 | array( |
||
102 | 'id' => 'lightbox', |
||
103 | 'title' => __( 'Lightbox', 'foogallery' ), |
||
104 | 'section' => __( 'General', 'foogallery' ), |
||
105 | 'desc' => __( 'Choose which lightbox you want to use.', 'foogallery' ), |
||
106 | 'type' => 'lightbox', |
||
107 | 'default' => 'none', |
||
108 | ), |
||
109 | array( |
||
110 | 'id' => 'caption_title', |
||
111 | 'title' => __('Override Title', 'foogallery'), |
||
112 | 'section' => __( 'Captions', 'foogallery' ), |
||
113 | 'desc' => __('Leave blank if you do not want a caption title.', 'foogallery'), |
||
114 | 'type' => 'text', |
||
115 | 'row_data'=> array( |
||
116 | 'data-foogallery-change-selector' => 'input', |
||
117 | 'data-foogallery-preview' => 'shortcode' |
||
118 | ) |
||
119 | ), |
||
120 | array( |
||
121 | 'id' => 'caption_description', |
||
122 | 'title' => __('Override Description', 'foogallery'), |
||
123 | 'section' => __( 'Captions', 'foogallery' ), |
||
124 | 'desc' => __('Leave blank if you do not want a caption description.', 'foogallery'), |
||
125 | 'type' => 'textarea', |
||
126 | 'row_data'=> array( |
||
127 | 'data-foogallery-change-selector' => 'textarea', |
||
128 | 'data-foogallery-preview' => 'shortcode' |
||
129 | ) |
||
130 | ) |
||
131 | ) |
||
132 | ); |
||
133 | |||
134 | return $gallery_templates; |
||
135 | } |
||
136 | |||
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.