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 |
||
46 | function foogallery_get_gallery_template_common_thumbnail_fields($gallery_template) { |
||
47 | |||
48 | $template = $gallery_template['slug']; |
||
49 | |||
50 | $border_style_choices = apply_filters( "foogallery_gallery_template_common_thumbnail_fields_border_style_choices-{$template}", array( |
||
51 | 'border-style-square-white' => array( 'label' => __( 'Square white border with shadow' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-square-white.png' ), |
||
52 | 'border-style-circle-white' => array( 'label' => __( 'Circular white border with shadow' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-circle-white.png' ), |
||
53 | 'border-style-square-black' => array( 'label' => __( 'Square Black' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-square-black.png' ), |
||
54 | 'border-style-circle-black' => array( 'label' => __( 'Circular Black' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-circle-black.png' ), |
||
55 | 'border-style-inset' => array( 'label' => __( 'Square Inset' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-square-inset.png' ), |
||
56 | 'border-style-rounded' => array( 'label' => __( 'Plain Rounded' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-plain-rounded.png' ), |
||
57 | '' => array( 'label' => __( 'Plain' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-none.png' ), |
||
58 | ) ); |
||
59 | $fields[] = array( |
||
60 | 'id' => 'border-style', |
||
61 | 'title' => __( 'Border Style', 'foogallery' ), |
||
62 | 'desc' => __( 'The border style for each thumbnail in the gallery.', 'foogallery' ), |
||
63 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
64 | 'type' => 'icon', |
||
65 | 'default' => 'border-style-square-white', |
||
66 | 'choices' => $border_style_choices |
||
67 | ); |
||
68 | |||
69 | $hover_effect_type_choices = apply_filters( "foogallery_gallery_template_common_thumbnail_fields_hover_effect_type_choices-{$template}", array( |
||
70 | '' => __( 'Icon', 'foogallery' ), |
||
71 | 'hover-effect-tint' => __( 'Dark Tint', 'foogallery' ), |
||
72 | 'hover-effect-color' => __( 'Colorize', 'foogallery' ), |
||
73 | 'hover-effect-caption' => __( 'Caption', 'foogallery' ), |
||
74 | 'hover-effect-scale' => __( 'Scale', 'foogallery' ), |
||
75 | 'hover-effect-none' => __( 'None', 'foogallery' ) |
||
76 | ) ); |
||
77 | $fields[] = array( |
||
78 | 'id' => 'hover-effect-type', |
||
79 | 'title' => __( 'Hover Effect Type', 'foogallery' ), |
||
80 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
81 | 'default' => '', |
||
82 | 'type' => 'radio', |
||
83 | 'choices' => $hover_effect_type_choices, |
||
84 | 'spacer' => '<span class="spacer"></span>', |
||
85 | 'desc' => __( 'The type of hover effect the thumbnails will use.', 'foogallery' ), |
||
86 | ); |
||
87 | |||
88 | $hover_effect_choices = apply_filters( "foogallery_gallery_template_common_thumbnail_fields_hover_effect_choices-{$template}", array( |
||
89 | 'hover-effect-zoom' => array( 'label' => __( 'Zoom' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-zoom.png' ), |
||
90 | 'hover-effect-zoom2' => array( 'label' => __( 'Zoom 2' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-zoom2.png' ), |
||
91 | 'hover-effect-zoom3' => array( 'label' => __( 'Zoom 3' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-zoom3.png' ), |
||
92 | 'hover-effect-plus' => array( 'label' => __( 'Plus' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-plus.png' ), |
||
93 | 'hover-effect-circle-plus' => array( 'label' => __( 'Cirlce Plus' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-circle-plus.png' ), |
||
94 | 'hover-effect-eye' => array( 'label' => __( 'Eye' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-eye.png' ) |
||
95 | ) ); |
||
96 | $fields[] = array( |
||
97 | 'id' => 'hover-effect', |
||
98 | 'title' => __( 'Icon Hover Effect', 'foogallery' ), |
||
99 | 'desc' => __( 'When the hover effect type of Icon is chosen, you can choose which icon is shown when you hover over each thumbnail.', 'foogallery' ), |
||
100 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
101 | 'type' => 'icon', |
||
102 | 'default' => 'hover-effect-zoom', |
||
103 | 'choices' => $hover_effect_choices |
||
104 | ); |
||
105 | |||
106 | $caption_hover_effect_choices = apply_filters( "foogallery_gallery_template_common_thumbnail_fields_caption_hover_effect_choices-{$template}", array( |
||
107 | 'hover-caption-simple' => __( 'Simple', 'foogallery' ), |
||
108 | 'hover-caption-full-drop' => __( 'Drop', 'foogallery' ), |
||
109 | 'hover-caption-full-fade' => __( 'Fade In', 'foogallery' ), |
||
110 | 'hover-caption-push' => __( 'Push', 'foogallery' ), |
||
111 | 'hover-caption-simple-always' => __( 'Always Visible', 'foogallery' ) |
||
112 | ) ); |
||
113 | $fields[] = array( |
||
114 | 'id' => 'caption-hover-effect', |
||
115 | 'title' => __( 'Caption Effect', 'foogallery' ), |
||
116 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
117 | 'default' => 'hover-caption-simple', |
||
118 | 'type' => 'radio', |
||
119 | 'choices' => $caption_hover_effect_choices, |
||
120 | 'spacer' => '<span class="spacer"></span>' |
||
121 | ); |
||
122 | |||
123 | $caption_content_choices = apply_filters( "foogallery_gallery_template_common_thumbnail_fields_caption_content_choices-{$template}", array( |
||
124 | 'title' => __( 'Title Only', 'foogallery' ), |
||
125 | 'desc' => __( 'Description Only', 'foogallery' ), |
||
126 | 'both' => __( 'Title and Description', 'foogallery' ) |
||
127 | ) ); |
||
128 | $fields[] = array( |
||
129 | 'id' => 'caption-content', |
||
130 | 'title' => __( 'Caption Content', 'foogallery' ), |
||
131 | 'section' => __( 'Thumbnail Settings', 'foogallery' ), |
||
132 | 'default' => 'title', |
||
133 | 'type' => 'radio', |
||
134 | 'choices' => $caption_content_choices, |
||
135 | 'spacer' => '<span class="spacer"></span>' |
||
136 | ); |
||
137 | |||
138 | return $fields; |
||
139 | } |
Instead of relying on
global
state, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state