GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( fa35e8...bb810f )
by Brad
02:38
created

add_template()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 106
Code Lines 89

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 106
rs 8.2857
cc 1
eloc 89
nc 1
nop 1

How to fix   Long Method   

Long Method

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:

1
<?php
2
3
if ( !class_exists( 'FooGallery_Thumbnail_Gallery_Template' ) ) {
4
5
	define('FOOGALLERY_THUMBNAIL_GALLERY_TEMPLATE_URL', plugin_dir_url( __FILE__ ));
6
7
	class FooGallery_Thumbnail_Gallery_Template {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
8
		/**
9
		 * Wire up everything we need to run the extension
10
		 */
11
		function __construct() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
12
			add_filter( 'foogallery_gallery_templates', array( $this, 'add_template' ) );
13
			add_filter( 'foogallery_gallery_templates_files', array( $this, 'register_myself' ) );
14
		}
15
16
		/**
17
		 * Register myself so that all associated JS and CSS files can be found and automatically included
18
		 * @param $extensions
19
		 *
20
		 * @return array
21
		 */
22
		function register_myself( $extensions ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
23
			$extensions[] = __FILE__;
24
			return $extensions;
25
		}
26
27
		/**
28
		 * Add our gallery template to the list of templates available for every gallery
29
		 * @param $gallery_templates
30
		 *
31
		 * @return array
32
		 */
33
		function add_template( $gallery_templates ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
34
			$gallery_templates[] = array(
35
					'slug'        => 'thumbnail',
36
					'name'        => __( 'Single Thumbnail Gallery', 'foogallery' ),
37
					'preview_css' => FOOGALLERY_THUMBNAIL_GALLERY_TEMPLATE_URL . 'css/gallery-thumbnail.css',
38
					'admin_js'	  => FOOGALLERY_THUMBNAIL_GALLERY_TEMPLATE_URL . 'js/admin-gallery-thumbnail.js',
39
					'fields'	  => array(
40
							array(
41
									'id'	  => 'help',
42
									'type'	  => 'html',
43
									'help'	  => true,
44
									'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' ),
45
							),
46
							array(
47
									'id'      => 'thumbnail_dimensions',
48
									'title'   => __( 'Size', 'foogallery' ),
49
									'desc'    => __( 'Choose the size of your thumbnail.', 'foogallery' ),
50
									'section' => __( 'Thumbnail Settings', 'foogallery' ),
51
									'type'    => 'thumb_size',
52
									'default' => array(
53
											'width' => 250,
54
											'height' => 200,
55
											'crop' => true,
56
									),
57
							),
58
							array(
59
									'id'      => 'position',
60
									'title'   => __( 'Position', 'foogallery' ),
61
									'desc'    => __( 'The position of the thumbnail related to the content around it.', 'foogallery' ),
62
									'section' => __( 'Thumbnail Settings', 'foogallery' ),
63
									'default' => 'position-block',
64
									'type'    => 'select',
65
									'choices' => array(
66
											'position-block' => __( 'Full Width (block)', 'foogallery' ),
67
											'position-float-left' => __( 'Float Left', 'foogallery' ),
68
											'position-float-right' => __( 'Float Right', 'foogallery' ),
69
									)
70
							),
71
							array(
72
									'id'      => 'link_custom_url',
73
									'title'   => __( 'Link To Custom URL', 'foogallery' ),
74
									'section' => __( 'Thumbnail Settings', 'foogallery' ),
75
									'default' => '',
76
									'type'    => 'checkbox',
77
									'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' )
78
							),
79
							array(
80
									'id'      => 'caption_style',
81
									'title'   => __( 'Caption Style', 'foogallery' ),
82
									'section' => __( 'Caption Settings', 'foogallery' ),
83
									'desc'    => __( 'Choose which caption style you want to use.', 'foogallery' ),
84
									'type'    => 'select',
85
									'default' => 'simple',
86
									'choices' => array(
87
											'caption-simple' => __( 'Simple' , 'foogallery' ),
88
											'caption-slideup' => __( 'Slide Up' , 'foogallery' ),
89
											'caption-fall' => __( 'Fall Down' , 'foogallery' ),
90
											'caption-fade' => __( 'Fade' , 'foogallery' ),
91
											'caption-push' => __( 'Push From Left' , 'foogallery' ),
92
											'caption-scale' => __( 'Scale' , 'foogallery' ),
93
											'caption-none' => __( 'None' , 'foogallery' )
94
									),
95
							),
96
							array(
97
									'id'      => 'caption_bgcolor',
98
									'title'   => __('Caption Background Color', 'foogallery'),
99
									'section' => __( 'Caption Settings', 'foogallery' ),
100
									'desc'    => __('The color of the caption background.', 'foogallery'),
101
									'type'    => 'colorpicker',
102
									'default' => 'rgba(0, 0, 0, 0.8)',
103
									'opacity' => true
104
							),
105
							array(
106
									'id'      => 'caption_color',
107
									'title'   => __('Caption Text Color', 'foogallery'),
108
									'section' => __( 'Caption Settings', 'foogallery' ),
109
									'desc'    => __('The color of the caption text.', 'foogallery'),
110
									'type'    => 'colorpicker',
111
									'default' => 'rgb(255, 255, 255)'
112
							),
113
							array(
114
									'id'      => 'caption_title',
115
									'title'   => __('Caption Title', 'foogallery'),
116
									'section' => __( 'Caption Settings', 'foogallery' ),
117
									'desc'    => __('Leave blank if you do not want a caption title.', 'foogallery'),
118
									'type'    => 'text'
119
							),
120
							array(
121
									'id'      => 'caption_description',
122
									'title'   => __('Caption Description', 'foogallery'),
123
									'section' => __( 'Caption Settings', 'foogallery' ),
124
									'desc'    => __('Leave blank if you do not want a caption description.', 'foogallery'),
125
									'type'    => 'textarea'
126
							),
127
							array(
128
									'id'      => 'lightbox',
129
									'title'   => __( 'Lightbox', 'foogallery' ),
130
									'section' => __( 'Gallery Settings', 'foogallery' ),
131
									'desc'    => __( 'Choose which lightbox you want to use.', 'foogallery' ),
132
									'type'    => 'lightbox',
133
							)
134
					)
135
			);
136
137
			return $gallery_templates;
138
		}
139
	}
140
}