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... ( cd983d...5984e4 )
by Brad
02:39
created

preview_arguments()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 2
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
if ( !class_exists( 'FooGallery_Default_Gallery_Template' ) ) {
4
5
	define('FOOGALLERY_DEFAULT_GALLERY_TEMPLATE_URL', plugin_dir_url( __FILE__ ));
6
7
	class FooGallery_Default_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
14
			//add extra fields to the templates
15
			add_filter( 'foogallery_override_gallery_template_fields-default', array( $this, 'add_common_thumbnail_fields' ), 10, 2 );
16
17
			add_action( 'foogallery_located_template-default', array( $this, 'enqueue_dependencies' ) );
18
19
			add_filter( 'foogallery_gallery_templates_files', array( $this, 'register_myself' ) );
20
21
			//build up any preview arguments
22
			add_filter( 'foogallery_preview_arguments-default', array( $this, 'preview_arguments' ), 10, 2 );
23
24
			//build up the thumb dimensions from some arguments
25
			add_filter( 'foogallery_calculate_thumbnail_dimensions-default', array( $this, 'build_thumbnail_dimensions_from_arguments' ), 10, 2 );
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'        => 'default',
48
				'name'        => __( 'Responsive Image Gallery', 'foogallery' ),
49
				'lazyload_support' => true,
50
				'fields'	  => array(
51
                    array(
52
                        'id'      => 'thumbnail_dimensions',
53
                        'title'   => __( 'Thumbnail Size', 'foogallery' ),
54
                        'desc'    => __( 'Choose the size of your thumbnails.', 'foogallery' ),
55
                        'section' => __( 'General', 'foogallery' ),
56
                        'type'    => 'thumb_size',
57
                        'default' => array(
58
                            'width' => get_option( 'thumbnail_size_w' ),
59
                            'height' => get_option( 'thumbnail_size_h' ),
60
                            'crop' => true,
61
                        ),
62
						'row_data'=> array(
63
							'data-foogallery-preview' => 'shortcode'
64
						)
65
                    ),
66
                    array(
67
                        'id'      => 'thumbnail_link',
68
                        'title'   => __( 'Link To', 'foogallery' ),
69
                        'section' => __( 'General', 'foogallery' ),
70
                        'default' => 'image',
71
                        'type'    => 'thumb_link',
72
                        'desc'	  => __( 'You can choose to link each thumbnail to the full size image, the image\'s attachment page, a custom URL, or you can choose to not link to anything.', 'foogallery' ),
73
                    ),
74
					array(
75
						'id'      => 'lightbox',
76
						'title'   => __( 'Lightbox', 'foogallery' ),
77
						'desc'    => __( 'Choose which lightbox you want to use. The lightbox will generally only work if you set the thumbnail link to "Full Size Image".', 'foogallery' ),
78
                        'section' => __( 'General', 'foogallery' ),
79
						'type'    => 'lightbox',
80
						'row_data'=> array(
81
							'data-foogallery-change-selector' => 'select'
82
						)
83
					),
84
					array(
85
						'id'      => 'lightbox_foobox_help',
86
						'title'   => __( 'FooBox Help', 'foogallery' ),
87
						'desc'    => __( 'The FooBox lightbox is a separate plugin.', 'foogallery' ),
88
						'section' => __( 'General', 'foogallery' ),
89
						'type'    => 'help',
90
						'row_data'=> array(
91
							'data-foogallery-hidden' => true,
92
							'data-foogallery-show-when-field' => 'lightbox',
93
							'data-foogallery-show-when-field-value' => 'foobox'
94
						)
95
					),
96
					array(
97
						'id'      => 'spacing',
98
						'title'   => __( 'Spacing', 'foogallery' ),
99
						'desc'    => __( 'The spacing or gap between thumbnails in the gallery.', 'foogallery' ),
100
                        'section' => __( 'General', 'foogallery' ),
101
						'type'    => 'select',
102
						'default' => 'fg-gutter-10',
103
						'choices' => array(
104
							'fg-gutter-0' => __( 'none', 'foogallery' ),
105
							'fg-gutter-5' => __( '5 pixels', 'foogallery' ),
106
							'fg-gutter-10' => __( '10 pixels', 'foogallery' ),
107
							'fg-gutter-15' => __( '15 pixels', 'foogallery' ),
108
							'fg-gutter-20' => __( '20 pixels', 'foogallery' ),
109
							'fg-gutter-25' => __( '25 pixels', 'foogallery' ),
110
						),
111
                        'row_data'=> array(
112
                            'data-foogallery-change-selector' => 'select',
113
							'data-foogallery-preview' => 'class'
114
                        )
115
					),
116
					array(
117
						'id'      => 'alignment',
118
						'title'   => __( 'Alignment', 'foogallery' ),
119
						'desc'    => __( 'The horizontal alignment of the thumbnails inside the gallery.', 'foogallery' ),
120
                        'section' => __( 'General', 'foogallery' ),
121
						'default' => 'fg-center',
122
						'type'    => 'radio',
123
						'spacer'  => '<span class="spacer"></span>',
124
						'choices' => array(
125
							'fg-left' => __( 'Left', 'foogallery' ),
126
							'fg-center' => __( 'Center', 'foogallery' ),
127
							'fg-right' => __( 'Right', 'foogallery' ),
128
						),
129
                        'row_data'=> array(
130
                            'data-foogallery-change-selector' => 'input:radio',
131
							'data-foogallery-preview' => 'class'
132
                        )
133
					)
134
				)
135
			);
136
137
			return $gallery_templates;
138
		}
139
140
		/**
141
		 * Add thumbnail fields to the gallery template
142
		 *
143
		 * @uses "foogallery_override_gallery_template_fields"
144
		 * @param $fields
145
		 * @param $template
146
		 *
147
		 * @return array
148
		 */
149
		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...
150
			return apply_filters( 'foogallery_gallery_template_common_thumbnail_fields', $fields );
151
		}
152
153
		/**
154
		 * Enqueue scripts that the default gallery template relies on
155
		 */
156
		function enqueue_dependencies( $gallery ) {
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...
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...
157
			//enqueue core files
158
			foogallery_enqueue_core_gallery_template_style();
159
			foogallery_enqueue_core_gallery_template_script();
160
		}
161
162
		/**
163
		 * Build up a arguments used in the preview of the gallery
164
		 * @param $args
165
		 * @param $post_data
166
		 *
167
		 * @return mixed
168
		 */
169
		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...
170
			$args['thumbnail_width'] = $post_data['foogallery_settings']['default_thumbnail_dimensions']['width'];
171
			$args['thumbnail_height'] = $post_data['foogallery_settings']['default_thumbnail_dimensions']['height'];
172
			$args['thumbnail_crop'] = isset( $post_data['foogallery_settings']['default_thumbnail_dimensions']['crop'] ) ? '1' : '0';
173
174
			return $args;
175
		}
176
177
		/**
178
		 * Builds thumb dimensions from arguments
179
		 *
180
		 * @param array $dimensions
181
		 * @param array $arguments
182
		 *
183
		 * @return mixed
184
		 */
185
		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...
186
			return array(
187
				'height' => intval( $arguments['thumbnail_height'] ),
188
				'width'  => intval( $arguments['thumbnail_width'] ),
189
				'crop'   => $arguments['thumbnail_crop'] === '1'
190
			);
191
		}
192
	}
193
}