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/thumb-dimensions ( 3a26b7...7f492d )
by Brad
02:20
created

get_thumbnail_dimensions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 2
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
if ( !class_exists( 'FooGallery_Masonry_Gallery_Template' ) ) {
4
5
	define('FOOGALLERY_MASONRY_GALLERY_TEMPLATE_URL', plugin_dir_url( __FILE__ ));
6
7
	class FooGallery_Masonry_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
			add_filter( 'foogallery_located_template-masonry', array( $this, 'enqueue_dependencies' ) );
15
16
			add_filter( 'foogallery_template_thumbnail_dimensions-masonry', array( $this, 'get_thumbnail_dimensions' ), 10, 2 );
17
		}
18
19
		/**
20
		 * Register myself so that all associated JS and CSS files can be found and automatically included
21
		 * @param $extensions
22
		 *
23
		 * @return array
24
		 */
25
		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...
26
			$extensions[] = __FILE__;
27
			return $extensions;
28
		}
29
30
		/**
31
		 * Add our gallery template to the list of templates available for every gallery
32
		 * @param $gallery_templates
33
		 *
34
		 * @return array
35
		 */
36
		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...
37
			$gallery_templates[] = array(
38
					'slug'        => 'masonry',
39
					'name'        => __( 'Masonry Image Gallery', 'foogallery' ),
40
					'admin_js'	  => FOOGALLERY_MASONRY_GALLERY_TEMPLATE_URL . 'js/admin-gallery-masonry.js',
41
					'fields'	  => array(
42
							array(
43
									'id'      => 'thumbnail_width',
44
									'title'   => __( 'Thumbnail Width', 'foogallery' ),
45
									'desc'    => __( 'Choose the width of your thumbnails. Thumbnails will be generated on the fly and cached once generated.', 'foogallery' ),
46
									'type'    => 'number',
47
									'class'   => 'small-text',
48
									'default' => 150,
49
									'step'    => '1',
50
									'min'     => '0',
51
							),
52
							array(
53
									'id'      => 'layout',
54
									'title'   => __( 'Masonry Layout', 'foogallery' ),
55
									'desc'    => __( 'Choose a fixed width thumb layout, or responsive columns.', 'foogallery' ),
56
									'type'    => 'radio',
57
									'choices' => array(
58
											'fixed'  => __( 'Fixed Width', 'foogallery' ),
59
											'2col'   => __( '2 Columns', 'foogallery' ),
60
											'3col'   => __( '3 Columns', 'foogallery' ),
61
											'4col'   => __( '4 Columns', 'foogallery' ),
62
											'5col'   => __( '5 Columns', 'foogallery' )
63
									),
64
									'spacer'  => '<span class="spacer"></span>',
65
									'default' => 'fixed'
66
							),
67
							array(
68
									'id'      => 'gutter_width',
69
									'title'   => __( 'Gutter Width', 'foogallery' ),
70
									'desc'    => __( 'The spacing between your thumbnails. Only applicable when using a fixed layout!', 'foogallery' ),
71
									'type'    => 'number',
72
									'class'   => 'small-text',
73
									'default' => 10,
74
									'step'    => '1',
75
									'min'     => '0',
76
							),
77
							array(
78
									'id'      => 'center_align',
79
									'title'   => __( 'Image Alignment', 'foogallery' ),
80
									'desc'    => __( 'You can choose to center align your images or leave them at the default. Only applicable when using a fixed layout!', 'foogallery' ),
81
									'type'    => 'radio',
82
									'choices' => array(
83
											'default'  => __( 'Left Alignment', 'foogallery' ),
84
											'center'   => __( 'Center Alignment', 'foogallery' )
85
									),
86
									'spacer'  => '<span class="spacer"></span>',
87
									'default' => 'default'
88
							),
89
							array(
90
									'id'      => 'gutter_percent',
91
									'title'   => __( 'Gutter Size', 'foogallery' ),
92
									'desc'    => __( 'Choose a gutter size when using responsive columns.', 'foogallery' ),
93
									'type'    => 'radio',
94
									'choices' => array(
95
											'no-gutter'   => __( 'No Gutter', 'foogallery' ),
96
											''  => __( 'Normal Size Gutter', 'foogallery' ),
97
											'large-gutter'   => __( 'Larger Gutter', 'foogallery' )
98
									),
99
									'spacer'  => '<span class="spacer"></span>',
100
									'default' => ''
101
							),
102
							array(
103
									'id'      => 'hover_zoom',
104
									'title'   => __( 'Hover Zoom', 'foogallery' ),
105
									'desc'    => __( 'The effect that is applied to images when you move your mouse over them.', 'foogallery' ),
106
									'type'    => 'radio',
107
									'choices' => array(
108
											'default'  => __( 'Zoom Slightly', 'foogallery' ),
109
											'none'   => __( 'No Zoom', 'foogallery' )
110
									),
111
									'spacer'  => '<span class="spacer"></span>',
112
									'default' => 'default'
113
							),
114
							array(
115
									'id'      => 'thumbnail_link',
116
									'title'   => __( 'Thumbnail Link', 'foogallery' ),
117
									'default' => 'image' ,
118
									'type'    => 'thumb_link',
119
									'spacer'  => '<span class="spacer"></span>',
120
									'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' ),
121
							),
122
							array(
123
									'id'      => 'lightbox',
124
									'title'   => __( 'Lightbox', 'foogallery' ),
125
									'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' ),
126
									'type'    => 'lightbox',
127
							),
128
					),
129
			);
130
131
132
			return $gallery_templates;
133
		}
134
135
		/**
136
		 * Enqueue scripts that the masonry gallery template relies on
137
		 */
138
		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...
139
			wp_enqueue_script( 'jquery' );
140
			wp_enqueue_script( 'masonry' );
141
			foogallery_enqueue_imagesloaded_script();
142
		}
143
144
		/**
145
		 * Get the thumb dimensions arguments saved for the gallery for this gallery template
146
		 *
147
		 * @param array $dimensions
148
		 * @param FooGallery $foogallery
149
		 *
150
		 * @return mixed
151
		 */
152
		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...
153
			$width = $foogallery->get_meta( 'masonry_thumbnail_width', false );
154
			return array(
155
				'height' => 0,
156
				'width'  => intval( $width ),
157
				'crop'   => false
158
			);
159
		}
160
	}
161
}