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

override_settings()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 3
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
if ( !class_exists( 'FooGallery_Image_Viewer_Gallery_Template' ) ) {
4
5
	define('FOOGALLERY_IMAGE_VIEWER_GALLERY_TEMPLATE_URL', plugin_dir_url( __FILE__ ));
6
7
	class FooGallery_Image_Viewer_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-image-viewer', array( $this, 'add_common_thumbnail_fields' ), 10, 2 );
16
17
			add_action( 'foogallery_located_template-image-viewer', array( $this, 'enqueue_dependencies' ) );
18
19
			add_filter( 'foogallery_gallery_templates_files', array( $this, 'register_myself' ) );
20
21
			add_filter( 'foogallery_template_thumbnail_dimensions-image-viewer', array( $this, 'get_thumbnail_dimensions' ), 10, 2 );
22
23
			//override specific settings when saving the gallery
24
			add_filter( 'foogallery_save_gallery_settings-image-viewer', array( $this, 'override_settings'), 10, 3 );
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
46
			$gallery_templates[] = array(
47
				'slug'        => 'image-viewer',
48
				'name'        => __( 'Image Viewer', 'foogallery' ),
49
				'lazyload_support' => true,
50
				'fields'	  => array(
51
                    array(
52
                        'id'      => 'thumbnail_size',
53
                        'title'   => __( 'Thumb Size', 'foogallery' ),
54
                        'section' => __( 'General', 'foogallery' ),
55
                        'desc'    => __( 'Choose the size of your thumbnails', 'foogallery' ),
56
                        'type'    => 'thumb_size',
57
                        'default' => array(
58
                            'width' => 640,
59
                            'height' => 360,
60
                            'crop' => true
61
                        )
62
                    ),
63
                    array(
64
                        'id'      => 'thumbnail_link',
65
                        'title'   => __( 'Thumb Link', 'foogallery' ),
66
                        'section' => __( 'General', 'foogallery' ),
67
                        'default' => 'image' ,
68
                        'type'    => 'thumb_link',
69
                        'desc'	  => __( 'You can choose to either link each thumbnail to the full size image or to the image\'s attachment page', 'foogallery')
70
                    ),
71
                    array(
72
                        'id'      => 'lightbox',
73
                        'title'   => __( 'Lightbox', 'foogallery' ),
74
                        'section' => __( 'General', 'foogallery' ),
75
                        'desc'    => __( 'Choose which lightbox you want to use in the gallery', 'foogallery' ),
76
                        'type'    => 'lightbox'
77
                    ),
78
                    array(
79
                        'id'      => 'alignment',
80
                        'title'   => __( 'Alignment', 'foogallery' ),
81
						'section' => __( 'General', 'foogallery' ),
82
                        'desc'    => __( 'The horizontal alignment of the thumbnails inside the gallery', 'foogallery' ),
83
                        'default' => 'fg-center',
84
						'type'    => 'radio',
85
						'spacer'  => '<span class="spacer"></span>',
86
                        'choices' => array(
87
                            'fg-left' => __( 'Left', 'foogallery' ),
88
                            'fg-center' => __( 'Center', 'foogallery' ),
89
                            'fg-right' => __( 'Right', 'foogallery' ),
90
                        ),
91
						'row_data'=> array(
92
							'data-foogallery-change-selector' => 'input:radio',
93
							'data-foogallery-preview' => 'class'
94
						)
95
                    ),
96
                    array(
97
                        'id'      => 'language-help',
98
                        'title'   => __( 'Language Help', 'foogallery' ),
99
                        'desc'    => __( 'This gallery template shows the below items of text. Change them to suit your preference or language.', 'foogallery' ),
100
						'section' => __( 'General', 'foogallery' ),
101
                        'type'    => 'help'
102
                    ),
103
					array(
104
						'id'      => 'text-prev',
105
						'title'   => __( '"Prev" Text', 'foogallery' ),
106
						'section' => __( 'General', 'foogallery' ),
107
						'type'    => 'text',
108
						'default' =>  __('Prev', 'foogallery')
109
					),
110
					array(
111
						'id'      => 'text-of',
112
						'title'   => __( '"of" Text', 'foogallery' ),
113
						'section' => __( 'General', 'foogallery' ),
114
						'type'    => 'text',
115
						'default' =>  __('of', 'foogallery')
116
					),
117
					array(
118
						'id'      => 'text-next',
119
						'title'   => __( '"Next" Text', 'foogallery' ),
120
						'section' => __( 'General', 'foogallery' ),
121
						'type'    => 'text',
122
						'default' =>  __('Next', 'foogallery')
123
					)
124
				)
125
			);
126
127
			return $gallery_templates;
128
		}
129
130
		/**
131
		 * Add thumbnail fields to the gallery template
132
		 *
133
		 * @uses "foogallery_override_gallery_template_fields"
134
		 * @param $fields
135
		 * @param $template
136
		 *
137
		 * @return array
138
		 */
139
		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...
140
			$updated_fields = apply_filters( 'foogallery_gallery_template_common_thumbnail_fields', $fields );
141
142
			//update specific fields
143
			foreach ($updated_fields as &$field) {
144
				if ( 'rounded_corners' === $field['id'] ) {
145
					$field['choices'] = array(
146
						''  => __( 'None', 'foogallery' ),
147
						'fg-round-small'  => __( 'Small', 'foogallery' ),
148
						'fg-round-medium'  => __( 'Medium', 'foogallery' ),
149
						'fg-round-large'  => __( 'Large', 'foogallery' ),
150
					);
151
				}
152
			}
153
154
			return $updated_fields;
155
		}
156
157
		/**
158
		 * Enqueue scripts that the default gallery template relies on
159
		 */
160
		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...
161
			//enqueue core files
162
			foogallery_enqueue_core_gallery_template_style();
163
			foogallery_enqueue_core_gallery_template_script();
164
		}
165
166
		/**
167
		 * Get the thumb dimensions arguments saved for the gallery for this gallery template
168
		 *
169
		 * @param array $dimensions
170
		 * @param FooGallery $foogallery
171
		 *
172
		 * @return mixed
173
		 */
174
		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...
175
			$dimensions = $foogallery->get_meta( 'image-viewer_thumbnail_size', false );
176
			return $dimensions;
177
		}
178
179
		/**
180
		 * Override specific settings so that the gallery template will always work
181
		 *
182
		 * @param $settings
183
		 * @param $post_id
184
		 * @param $form_data
185
		 *
186
		 * @return mixed
187
		 */
188
		function override_settings($settings, $post_id, $form_data) {
0 ignored issues
show
Unused Code introduced by
The parameter $post_id 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 $form_data 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...
189
			if ( 'fg-round-full' === $settings['image-viewer_rounded_corners'] ) {
190
				$settings['image-viewer_rounded_corners'] = 'fg-round-large';
191
			}
192
193
			return $settings;
194
		}
195
	}
196
}