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.

Issues (1881)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

masonry/class-masonry-gallery-template.php (19 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
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 the data options needed for masonry
22
			add_filter( 'foogallery_build_container_data_options-masonry', array( $this, 'add_masonry_options' ), 10, 3 );
23
24
			//build up any preview arguments
25
			add_filter( 'foogallery_preview_arguments-masonry', array( $this, 'preview_arguments' ), 10, 2 );
26
27
			//build up the thumb dimensions from some arguments
28
			add_filter( 'foogallery_calculate_thumbnail_dimensions-masonry', array( $this, 'build_thumbnail_dimensions_from_arguments' ), 10, 2 );
29
30
            //build up the arguments needed for rendering this template
31
            add_filter( 'foogallery_gallery_template_arguments-masonry', array( $this, 'build_gallery_template_arguments' ) );
32
33
            //add extra fields to the templates
34
            add_filter( 'foogallery_override_gallery_template_fields-masonry', array( $this, 'add_masonry_fields' ), 10, 2 );
35
36
			//remove the captions if the captions are below thumbs
37
			add_filter( 'foogallery_build_attachment_html_caption', array( $this, 'remove_captions' ), 10, 3 );
38
        }
39
40
		/**
41
		 * Register myself so that all associated JS and CSS files can be found and automatically included
42
		 * @param $extensions
43
		 *
44
		 * @return array
45
		 */
46
		function register_myself( $extensions ) {
0 ignored issues
show
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...
47
			$extensions[] = __FILE__;
48
			return $extensions;
49
		}
50
51
		/**
52
		 * Add our gallery template to the list of templates available for every gallery
53
		 * @param $gallery_templates
54
		 *
55
		 * @return array
56
		 */
57
		function add_template( $gallery_templates ) {
0 ignored issues
show
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...
58
			$gallery_templates[] = array(
59
                'slug'        => 'masonry',
60
                'name'        => __( 'Masonry Image Gallery', 'foogallery' ),
61
				'preview_support' => true,
62
				'common_fields_support' => true,
63
                'lazyload_support' => true,
64
				'paging_support' => true,
65
				'mandatory_classes' => 'fg-masonry',
66
				'thumbnail_dimensions' => true,
67
				'filtering_support' => true,
68
                'fields'	  => array(
69
                    array(
70
                        'id'      => 'thumbnail_width',
71
                        'title'   => __( 'Thumb Width', 'foogallery' ),
72
                        'desc'    => __( 'Choose the width of your thumbnails. Thumbnails will be generated on the fly and cached once generated', 'foogallery' ),
73
                        'section' => __( 'General', 'foogallery' ),
74
                        'type'    => 'number',
75
                        'class'   => 'small-text',
76
                        'default' => 150,
77
                        'step'    => '1',
78
                        'min'     => '0',
79
						'row_data'=> array(
80
							'data-foogallery-change-selector' => 'input',
81
							'data-foogallery-preview' => 'shortcode'
82
						)
83
                    ),
84
                    array(
85
                        'id'      => 'layout',
86
                        'title'   => __( 'Masonry Layout', 'foogallery' ),
87
                        'desc'    => __( 'Choose a fixed width thumb layout, or responsive columns.', 'foogallery' ),
88
                        'section' => __( 'General', 'foogallery' ),
89
                        'type'    => 'radio',
90
                        'choices' => array(
91
                            'fixed'  => __( 'Fixed Width', 'foogallery' ),
92
                            'col2'   => __( '2 Columns', 'foogallery' ),
93
                            'col3'   => __( '3 Columns', 'foogallery' ),
94
                            'col4'   => __( '4 Columns', 'foogallery' ),
95
                            'col5'   => __( '5 Columns', 'foogallery' )
96
                        ),
97
                        'default' => 'fixed',
98
                        'row_data'=> array(
99
                            'data-foogallery-change-selector' => 'input:radio',
100
                            'data-foogallery-value-selector' => 'input:checked',
101
							'data-foogallery-preview' => 'shortcode'
102
                        )
103
                    ),
104
                    array(
105
                        'id'      => 'gutter_width',
106
                        'title'   => __( 'Gutter Width', 'foogallery' ),
107
                        'desc'    => __( 'The spacing between your thumbnails. Only applicable when using a fixed layout!', 'foogallery' ),
108
                        'section' => __( 'General', 'foogallery' ),
109
                        'type'    => 'number',
110
                        'class'   => 'small-text',
111
                        'default' => 10,
112
                        'step'    => '1',
113
                        'min'     => '0',
114
                        'row_data'=> array(
115
                            'data-foogallery-hidden' => true,
116
							'data-foogallery-change-selector' => 'input',
117
							'data-foogallery-value-selector' => 'input',
118
                            'data-foogallery-show-when-field' => 'layout',
119
                            'data-foogallery-show-when-field-value' => 'fixed',
120
							'data-foogallery-preview' => 'shortcode',
121
                        )
122
                    ),
123
                    array(
124
                        'id'      => 'gutter_percent',
125
                        'title'   => __( 'Gutter Size', 'foogallery' ),
126
                        'desc'    => __( 'Choose a gutter size when using responsive columns.', 'foogallery' ),
127
                        'section' => __( 'General', 'foogallery' ),
128
                        'type'    => 'radio',
129
                        'choices' => array(
130
                            'fg-gutter-none'   => __( 'No Gutter', 'foogallery' ),
131
                            ''  => __( 'Normal Size Gutter', 'foogallery' ),
132
                            'fg-gutter-large'   => __( 'Larger Gutter', 'foogallery' )
133
                        ),
134
                        'default' => '',
135
                        'row_data'=> array(
136
                            'data-foogallery-hidden' => true,
137
							'data-foogallery-change-selector' => 'input:radio',
138
							'data-foogallery-value-selector' => 'input:checked',
139
                            'data-foogallery-show-when-field' => 'layout',
140
                            'data-foogallery-show-when-field-operator' => '!==',
141
                            'data-foogallery-show-when-field-value' => 'fixed',
142
							'data-foogallery-preview' => 'class'
143
                        )
144
                    ),
145
                    array(
146
                        'id'      => 'alignment',
147
                        'title'   => __( 'Alignment', 'foogallery' ),
148
                        'desc'    => __( 'You can choose to center align your images or leave them at the default (left). Only applicable when using a fixed layout!', 'foogallery' ),
149
						'section' => __( 'General', 'foogallery' ),
150
						'type'    => 'radio',
151
						'spacer'  => '<span class="spacer"></span>',
152
                        'choices' => array(
153
                            ''  => __( 'Left', 'foogallery' ),
154
                            'fg-center'   => __( 'Center', 'foogallery' )
155
                        ),
156
                        'default' => 'fg-center',
157
						'row_data'=> array(
158
							'data-foogallery-hidden' => true,
159
							'data-foogallery-show-when-field' => 'layout',
160
							'data-foogallery-show-when-field-value' => 'fixed',
161
							'data-foogallery-change-selector' => 'input:radio',
162
							'data-foogallery-preview' => 'class'
163
						)
164
                    ),
165
                    array(
166
                        'id'      => 'thumbnail_link',
167
                        'title'   => __( 'Thumb Link', 'foogallery' ),
168
                        'default' => 'image' ,
169
                        'type'    => 'thumb_link',
170
                        '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' ),
171
                    ),
172
                    array(
173
                        'id'      => 'lightbox',
174
                        'title'   => __( 'Lightbox', 'foogallery' ),
175
                        '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' ),
176
                        'type'    => 'lightbox',
177
                        'default' => 'none',
178
                    ),
179
                ),
180
			);
181
182
183
			return $gallery_templates;
184
		}
185
186
		/**
187
		 * Enqueue scripts that the masonry gallery template relies on
188
		 */
189
		function enqueue_preview_dependencies() {
0 ignored issues
show
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...
190
			wp_enqueue_script( 'masonry' );
191
		}
192
193
		/**
194
		 * Enqueue scripts that the masonry gallery template relies on
195
		 */
196
		function enqueue_dependencies() {
0 ignored issues
show
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...
197
			wp_enqueue_script( 'masonry' );
198
199
			//enqueue core files
200
			foogallery_enqueue_core_gallery_template_style();
201
			foogallery_enqueue_core_gallery_template_script();
202
		}
203
204
		/**
205
		 * Get the thumb dimensions arguments saved for the gallery for this gallery template
206
		 *
207
		 * @param array $dimensions
208
		 * @param FooGallery $foogallery
209
		 *
210
		 * @return mixed
211
		 */
212
		function get_thumbnail_dimensions( $dimensions, $foogallery ) {
0 ignored issues
show
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...
213
			$width = $foogallery->get_meta( 'masonry_thumbnail_width', false );
214
			return array(
215
				'height' => 0,
216
				'width'  => intval( $width ),
217
				'crop'   => false
218
			);
219
		}
220
221
		/**
222
		 * Add the required masonry options if needed
223
		 *
224
		 * @param $options
225
		 * @param $gallery    FooGallery
226
		 *
227
		 * @param $attributes array
228
		 *
229
		 * @return array
230
		 */
231
		function add_masonry_options($options, $gallery, $attributes) {
0 ignored issues
show
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...
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...
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...
232
			$layout = foogallery_gallery_template_setting( 'layout', 'fixed' );
233
			$options['template']['layout'] = $layout;
234
			if ( 'fixed' === $layout ) {
235
				$width = foogallery_gallery_template_setting( 'thumbnail_width', '150' );
236
				$gutter_width = foogallery_gallery_template_setting( 'gutter_width', '10' );
237
				$options['template']['columnWidth'] = intval($width);
238
				$options['template']['gutter'] = intval($gutter_width);
239
			}
240
			return $options;
241
		}
242
243
		/**
244
		 * Build up a arguments used in the preview of the gallery
245
		 * @param $args
246
		 * @param $post_data
247
		 *
248
		 * @return mixed
249
		 */
250
		function preview_arguments( $args, $post_data ) {
0 ignored issues
show
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...
251
			$args['thumbnail_width'] = $post_data[FOOGALLERY_META_SETTINGS]['masonry_thumbnail_width'];
252
			$args['layout'] = $post_data[FOOGALLERY_META_SETTINGS]['masonry_layout'];
253
			$args['gutter_width'] = $post_data[FOOGALLERY_META_SETTINGS]['masonry_gutter_width'];
254
			return $args;
255
		}
256
257
		/**
258
		 * Builds thumb dimensions from arguments
259
		 *
260
		 * @param array $dimensions
261
		 * @param array $arguments
262
		 *
263
		 * @return mixed
264
		 */
265
		function build_thumbnail_dimensions_from_arguments( $dimensions, $arguments ) {
0 ignored issues
show
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...
266
            if ( array_key_exists( 'thumbnail_width', $arguments) ) {
267
                return array(
268
                    'height' => 0,
269
                    'width' => intval($arguments['thumbnail_width']),
270
                    'crop' => false
271
                );
272
            }
273
            return null;
274
		}
275
276
        /**
277
         * Build up the arguments needed for rendering this gallery template
278
         *
279
         * @param $args
280
         * @return array
281
         */
282
        function build_gallery_template_arguments( $args ) {
0 ignored issues
show
The parameter $args 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...
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...
283
            $args = array(
284
                'width' => foogallery_gallery_template_setting( 'thumbnail_width', '150' ),
285
                'link' => foogallery_gallery_template_setting( 'thumbnail_link', 'image' ),
286
                'crop' => false
287
            );
288
289
            return $args;
290
        }
291
292
        /**
293
         * Add masonry-specific fields to the gallery template
294
         *
295
         * @uses "foogallery_override_gallery_template_fields"
296
         * @param $fields
297
         * @param $template
298
         *
299
         * @return array
300
         */
301
        function add_masonry_fields( $fields, $template ) {
0 ignored issues
show
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...
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...
302
            //update specific fields
303
            foreach ($fields as &$field) {
304
                if ( 'hover_effect_caption_visibility' === $field['id'] ) {
305
                    $field['choices']['fg-captions-bottom'] = __( 'Below Thumbnail', 'foogallery' );
306
                }
307
            }
308
309
            return $fields;
310
        }
311
312
        function remove_captions( $captions, $foogallery_attachment, $args ) {
0 ignored issues
show
The parameter $foogallery_attachment 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...
The parameter $args 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...
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...
313
			global $current_foogallery_template;
314
315
        	//check if masonry
316
			if ( 'masonry' === $current_foogallery_template ) {
317
318
				$hover_effect_caption_visibility = foogallery_gallery_template_setting( 'hover_effect_caption_visibility', 'fg-caption-hover' );
319
320
				//check if captions are set to show below the thumbs
321
				if ( 'fg-captions-bottom' === $hover_effect_caption_visibility ) {
322
					//if we have no captions then do not output captions at all
323
					if ( !array_key_exists( 'title', $captions ) && !array_key_exists( 'desc', $captions ) ) {
324
						$captions = false;
325
					}
326
				}
327
			}
328
329
        	return $captions;
330
		}
331
	}
332
}