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 — feature/gallery-template-clien... ( 39a5ef...85d10e )
by Brad
02:34
created

FooGallery_Thumbnail_Gallery_Template   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 186
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 186
rs 10
c 0
b 0
f 0
wmc 7
lcom 0
cbo 1

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 1
A register_myself() 0 4 1
B add_template() 0 92 1
A enqueue_dependencies() 0 5 1
A preview_arguments() 0 6 1
A build_thumbnail_dimensions_from_arguments() 0 7 1
A get_thumbnail_dimensions() 0 8 1
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
			add_filter( 'foogallery_located_template-thumbnail', array( $this, 'enqueue_dependencies' ) );
16
17
			//build up any preview arguments
18
			add_filter( 'foogallery_preview_arguments-thumbnail', array( $this, 'preview_arguments' ), 10, 2 );
19
20
			//build up the thumb dimensions from some arguments
21
			add_filter( 'foogallery_calculate_thumbnail_dimensions-thumbnail', array( $this, 'build_thumbnail_dimensions_from_arguments' ), 10, 2 );
22
23
			//build up the thumb dimensions on save
24
			add_filter( 'foogallery_template_thumbnail_dimensions-thumbnail', array( $this, 'get_thumbnail_dimensions' ), 10, 2 );
25
		}
26
27
		/**
28
		 * Register myself so that all associated JS and CSS files can be found and automatically included
29
		 * @param $extensions
30
		 *
31
		 * @return array
32
		 */
33
		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...
34
			$extensions[] = __FILE__;
35
			return $extensions;
36
		}
37
38
		/**
39
		 * Add our gallery template to the list of templates available for every gallery
40
		 * @param $gallery_templates
41
		 *
42
		 * @return array
43
		 */
44
		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...
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
137
		/**
138
		 * Enqueue scripts that the masonry gallery template relies on
139
		 */
140
		function enqueue_dependencies() {
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...
141
			//enqueue core files
142
			foogallery_enqueue_core_gallery_template_style();
143
			foogallery_enqueue_core_gallery_template_script();
144
		}
145
146
		/**
147
		 * Build up a arguments used in the preview of the gallery
148
		 * @param $args
149
		 * @param $post_data
150
		 *
151
		 * @return mixed
152
		 */
153
		function preview_arguments( $args, $post_data ) {
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...
154
			$args['thumbnail_dimensions'] = $post_data[FOOGALLERY_META_SETTINGS]['thumbnail_thumbnail_dimensions'];
155
			$args['caption_title'] = $post_data[FOOGALLERY_META_SETTINGS]['thumbnail_caption_title'];
156
			$args['caption_description'] = $post_data[FOOGALLERY_META_SETTINGS]['thumbnail_caption_description'];
157
			return $args;
158
		}
159
160
		/**
161
		 * Builds thumb dimensions from arguments
162
		 *
163
		 * @param array $dimensions
164
		 * @param array $arguments
165
		 *
166
		 * @return mixed
167
		 */
168
		function build_thumbnail_dimensions_from_arguments( $dimensions, $arguments ) {
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...
169
			return array(
170
				'height' => intval( $arguments['thumbnail_dimensions']['height'] ),
171
				'width'  => intval( $arguments['thumbnail_dimensions']['width'] ),
172
				'crop'   => '1'
173
			);
174
		}
175
176
		/**
177
		 * Get the thumb dimensions arguments saved for the gallery for this gallery template
178
		 *
179
		 * @param array $dimensions
180
		 * @param FooGallery $foogallery
181
		 *
182
		 * @return mixed
183
		 */
184
		function get_thumbnail_dimensions( $dimensions, $foogallery ) {
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...
185
			$dimensions = $foogallery->get_meta( 'thumbnail_thumbnail_dimensions', array(
186
				'width' => get_option( 'thumbnail_size_w' ),
187
				'height' => get_option( 'thumbnail_size_h' )
188
			) );
189
			$dimensions['crop'] = true;
190
			return $dimensions;
191
		}
192
	}
193
}