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... ( a56405...b693b9 )
by Brad
02:39
created

enqueue_preview_dependencies()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
rs 10
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
15
			add_action( 'foogallery_enqueue_preview_dependencies', array( $this, 'enqueue_preview_dependencies' ) );
16
17
			add_filter( 'foogallery_located_template-masonry', array( $this, 'enqueue_dependencies' ) );
18
19
			add_filter( 'foogallery_template_thumbnail_dimensions-masonry', array( $this, 'get_thumbnail_dimensions' ), 10, 2 );
20
21
			//add extra fields to the templates
22
			add_filter( 'foogallery_override_gallery_template_fields-masonry', array( $this, 'add_common_thumbnail_fields' ), 10, 2 );
23
24
			//add the data options needed for masonry
25
			add_filter( 'foogallery_build_container_data_options', array( $this, 'add_masonry_options' ), 10, 3 );
26
		}
27
28
		/**
29
		 * Register myself so that all associated JS and CSS files can be found and automatically included
30
		 * @param $extensions
31
		 *
32
		 * @return array
33
		 */
34
		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...
35
			$extensions[] = __FILE__;
36
			return $extensions;
37
		}
38
39
		/**
40
		 * Add our gallery template to the list of templates available for every gallery
41
		 * @param $gallery_templates
42
		 *
43
		 * @return array
44
		 */
45
		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...
46
			$gallery_templates[] = array(
47
                'slug'        => 'masonry',
48
                'name'        => __( 'Masonry Image Gallery', 'foogallery' ),
49
                'lazyload_support' => true,
50
                'fields'	  => array(
51
                    array(
52
                        'id'      => 'thumbnail_width',
53
                        'title'   => __( 'Thumb Width', 'foogallery' ),
54
                        'desc'    => __( 'Choose the width of your thumbnails. Thumbnails will be generated on the fly and cached once generated', 'foogallery' ),
55
                        'section' => __( 'General', 'foogallery' ),
56
                        'type'    => 'number',
57
                        'class'   => 'small-text',
58
                        'default' => 150,
59
                        'step'    => '1',
60
                        'min'     => '0',
61
                    ),
62
                    array(
63
                        'id'      => 'layout',
64
                        'title'   => __( 'Masonry Layout', 'foogallery' ),
65
                        'desc'    => __( 'Choose a fixed width thumb layout, or responsive columns.', 'foogallery' ),
66
                        'section' => __( 'General', 'foogallery' ),
67
                        'type'    => 'radio',
68
                        'choices' => array(
69
                            'fixed'  => __( 'Fixed Width', 'foogallery' ),
70
                            'col2'   => __( '2 Columns', 'foogallery' ),
71
                            'col3'   => __( '3 Columns', 'foogallery' ),
72
                            'col4'   => __( '4 Columns', 'foogallery' ),
73
                            'col5'   => __( '5 Columns', 'foogallery' )
74
                        ),
75
                        'default' => 'fixed',
76
                        'row_data'=> array(
77
                            'data-foogallery-change-selector' => 'input:radio',
78
                            'data-foogallery-value-selector' => 'input:checked',
79
							'data-foogallery-preview' => 'data'
80
                        )
81
                    ),
82
                    array(
83
                        'id'      => 'gutter_width',
84
                        'title'   => __( 'Gutter Width', 'foogallery' ),
85
                        'desc'    => __( 'The spacing between your thumbnails. Only applicable when using a fixed layout!', 'foogallery' ),
86
                        'section' => __( 'General', 'foogallery' ),
87
                        'type'    => 'number',
88
                        'class'   => 'small-text',
89
                        'default' => 10,
90
                        'step'    => '1',
91
                        'min'     => '0',
92
                        'row_data'=> array(
93
                            'data-foogallery-hidden' => true,
94
							'data-foogallery-change-selector' => 'input',
95
							'data-foogallery-value-selector' => 'input',
96
                            'data-foogallery-show-when-field' => 'layout',
97
                            'data-foogallery-show-when-field-value' => 'fixed',
98
							'data-foogallery-preview' => 'data',
99
							'data-foogallery-preview-value-path' => 'template.gutter'
100
                        )
101
                    ),
102
                    array(
103
                        'id'      => 'gutter_percent',
104
                        'title'   => __( 'Gutter Size', 'foogallery' ),
105
                        'desc'    => __( 'Choose a gutter size when using responsive columns.', 'foogallery' ),
106
                        'section' => __( 'General', 'foogallery' ),
107
                        'type'    => 'radio',
108
                        'choices' => array(
109
                            'fg-gutter-none'   => __( 'No Gutter', 'foogallery' ),
110
                            ''  => __( 'Normal Size Gutter', 'foogallery' ),
111
                            'fg-gutter-large'   => __( 'Larger Gutter', 'foogallery' )
112
                        ),
113
                        'default' => '',
114
                        'row_data'=> array(
115
                            'data-foogallery-hidden' => true,
116
							'data-foogallery-change-selector' => 'input:radio',
117
							'data-foogallery-value-selector' => 'input:checked',
118
                            'data-foogallery-show-when-field' => 'layout',
119
                            'data-foogallery-show-when-field-operator' => '!==',
120
                            'data-foogallery-show-when-field-value' => 'fixed',
121
							'data-foogallery-preview' => 'class'
122
                        )
123
                    ),
124
                    array(
125
                        'id'      => 'alignment',
126
                        'title'   => __( 'Alignment', 'foogallery' ),
127
                        'desc'    => __( 'You can choose to center align your images or leave them at the default (left). Only applicable when using a fixed layout!', 'foogallery' ),
128
						'section' => __( 'General', 'foogallery' ),
129
						'type'    => 'radio',
130
						'spacer'  => '<span class="spacer"></span>',
131
                        'choices' => array(
132
                            ''  => __( 'Left', 'foogallery' ),
133
                            'fg-center'   => __( 'Center', 'foogallery' )
134
                        ),
135
                        'default' => 'default',
136
						'row_data'=> array(
137
							'data-foogallery-hidden' => true,
138
							'data-foogallery-show-when-field' => 'layout',
139
							'data-foogallery-show-when-field-value' => 'fixed',
140
							'data-foogallery-change-selector' => 'input:radio',
141
							'data-foogallery-preview' => 'class'
142
						)
143
                    ),
144
                    array(
145
                        'id'      => 'thumbnail_link',
146
                        'title'   => __( 'Thumb Link', 'foogallery' ),
147
                        'default' => 'image' ,
148
                        'type'    => 'thumb_link',
149
                        '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' ),
150
                    ),
151
                    array(
152
                        'id'      => 'lightbox',
153
                        'title'   => __( 'Lightbox', 'foogallery' ),
154
                        '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' ),
155
                        'type'    => 'lightbox',
156
                    ),
157
                ),
158
			);
159
160
161
			return $gallery_templates;
162
		}
163
164
		/**
165
		 * Enqueue scripts that the masonry gallery template relies on
166
		 */
167
		function enqueue_preview_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...
168
			wp_enqueue_script( 'masonry' );
169
		}
170
171
		/**
172
		 * Enqueue scripts that the masonry gallery template relies on
173
		 */
174
		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...
175
			wp_enqueue_script( 'masonry' );
176
177
			//enqueue core files
178
			foogallery_enqueue_core_gallery_template_style();
179
			foogallery_enqueue_core_gallery_template_script();
180
		}
181
182
		/**
183
		 * Get the thumb dimensions arguments saved for the gallery for this gallery template
184
		 *
185
		 * @param array $dimensions
186
		 * @param FooGallery $foogallery
187
		 *
188
		 * @return mixed
189
		 */
190
		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...
191
			$width = $foogallery->get_meta( 'masonry_thumbnail_width', false );
192
			return array(
193
				'height' => 0,
194
				'width'  => intval( $width ),
195
				'crop'   => false
196
			);
197
		}
198
199
		/**
200
		 * Add thumbnail fields to the gallery template
201
		 *
202
		 * @uses "foogallery_override_gallery_template_fields"
203
		 * @param $fields
204
		 * @param $template
205
		 *
206
		 * @return array
207
		 */
208
		function add_common_thumbnail_fields( $fields, $template ) {
0 ignored issues
show
Unused Code introduced by
The parameter $template is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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...
209
			return apply_filters( 'foogallery_gallery_template_common_thumbnail_fields', $fields );
210
		}
211
212
213
		/**
214
		 * Add the required masonry options if needed
215
		 *
216
		 * @param $options
217
		 * @param $gallery    FooGallery
218
		 *
219
		 * @param $attributes array
220
		 *
221
		 * @return array
222
		 */
223
		function add_masonry_options($options, $gallery, $attributes) {
0 ignored issues
show
Unused Code introduced by
The parameter $gallery is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $attributes is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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...
224
			$layout = foogallery_gallery_template_setting( 'layout', 'fixed' );
225
			$options['template']['layout'] = $layout;
226
			if ( 'fixed' === $layout ) {
227
				$width = foogallery_gallery_template_setting( 'thumbnail_width', '150' );
228
				$gutter_width = foogallery_gallery_template_setting( 'gutter_width', '10' );
229
				$options['template']['columnWidth'] = intval($width);
230
				$options['template']['gutter'] = intval($gutter_width);
231
			}
232
			return $options;
233
		}
234
	}
235
}