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 — master ( d4ff54...7bd111 )
by Brad
18:04
created

__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Class for adding advanced settings to all gallery templates
4
 * Date: 11/09/2018
5
 */
6
if ( ! class_exists( 'FooGallery_Pro_Advanced_Gallery_Settings' ) ) {
7
8
	class FooGallery_Pro_Advanced_Gallery_Settings {
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...
9
10
		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...
11
			//add fields to all templates
12
			add_filter( 'foogallery_override_gallery_template_fields', array( $this, 'add_advanced_fields' ), 10, 2 );
13
14
			//add data options
15
			add_filter( 'foogallery_build_container_data_options', array( $this, 'add_data_options' ), 10, 3 );
16
		}
17
18
		/**
19
		 * Add fields to the gallery template
20
		 *
21
		 * @param $fields
22
		 * @param $template
23
		 *
24
		 * @return array
25
		 */
26
		function add_advanced_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...
27
			$fields[] = array(
28
				'id'       => 'state',
29
				'title'    => __( 'State', 'foogallery' ),
30
				'desc'     => __( 'Allow the gallery to keep state for both paging and filtering. When enabled, changing the page or filter will alter the URL.', 'foogallery' ),
31
				'section'  => __( 'Advanced', 'foogallery' ),
32
				'type'     => 'radio',
33
				'default'  => 'no',
34
				'spacer'   => '<span class="spacer"></span>',
35
				'choices'  => array(
36
					'no'  => __( 'Disabled', 'foogallery' ),
37
					'yes'   => __( 'Enabled', 'foogallery' ),
38
				),
39
//				'row_data' => array(
0 ignored issues
show
Unused Code Comprehensibility introduced by
46% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
40
//					'data-foogallery-change-selector' => 'input:radio',
41
//					'data-foogallery-value-selector'  => 'input:checked',
42
//					'data-foogallery-preview'         => 'class'
43
//				)
44
			);
45
46
			$fields[] = array(
47
				'id'       => 'custom_settings',
48
				'title'    => __( 'Custom Settings', 'foogallery' ),
49
				'desc'     => __( 'Add any custom settings to the gallery which will be merged with existing settings.', 'foogallery' ),
50
				'section'  => __( 'Advanced', 'foogallery' ),
51
				'type'     => 'textarea',
52
				'default'  => '',
53
//				'row_data' => array(
0 ignored issues
show
Unused Code Comprehensibility introduced by
46% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
54
//					'data-foogallery-change-selector' => 'input:radio',
55
//					'data-foogallery-value-selector'  => 'input:checked',
56
//					'data-foogallery-preview'         => 'class'
57
//				)
58
			);
59
60
			return $fields;
61
		}
62
63
		/**
64
		 * Add the required data options
65
		 *
66
		 * @param $options
67
		 * @param $gallery    FooGallery
68
		 *
69
		 * @param $attributes array
70
		 *
71
		 * @return array
72
		 */
73
		function add_data_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...
74
			$enable_state = foogallery_gallery_template_setting( 'state', 'no' );
75
76
			if ( 'yes' === $enable_state ) {
77
				$options['state']['enabled'] = true;
78
			}
79
80
			$custom_settings = foogallery_gallery_template_setting( 'custom_settings', '' );
81
82
			if ( !empty( $custom_settings ) ) {
83
				$settings_array = @json_decode($custom_settings, true);
84
85
				if ( isset( $settings_array ) ) {
86
					$options = array_merge_recursive( $options, $settings_array );
87
				}
88
			}
89
90
			return $options;
91
		}
92
	}
93
}