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... ( 39a5ef...85d10e )
by Brad
02:34
created

FooGallery_Pro_Hover_Presets   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 80
rs 10
c 0
b 0
f 0
wmc 11
lcom 0
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A add_pro_hover_presets() 0 14 1
A show_preset_fields() 0 11 4
B remove_preset_choices_for_simple_portfolio() 0 15 5
1
<?php
2
/**
3
 * FooGallery Pro Hover Presets Class
4
 */
5
if ( ! class_exists( 'FooGallery_Pro_Hover_Presets' ) ) {
6
7
	class FooGallery_Pro_Hover_Presets {
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
		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...
10
			add_filter( 'foogallery_gallery_template_common_thumbnail_fields_hover_effect_preset_choices', array( $this, 'add_pro_hover_presets' ) );
11
12
			//make sure we can see the presets
13
			add_filter( 'foogallery_override_gallery_template_fields', array( $this, 'show_preset_fields' ), 99, 2 );
14
15
             //remove preset choices from simple portfolio
16
            add_filter( 'foogallery_override_gallery_template_fields-simple_portfolio', array( $this, 'remove_preset_choices_for_simple_portfolio' ), 10, 2 );
17
        }
18
19
		/**
20
		 * Adds the presets that are available in the PRO version
21
		 *
22
		 * @param $choices
23
		 *
24
		 * @return mixed
25
		 */
26
		function add_pro_hover_presets( $choices ) {
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...
27
			$choices['fg-preset fg-sadie'  ]= __( 'Sadie',   'foogallery' );
28
			$choices['fg-preset fg-layla'  ]= __( 'Layla',   'foogallery' );
29
			$choices['fg-preset fg-oscar'  ]= __( 'Oscar',   'foogallery' );
30
			$choices['fg-preset fg-sarah'  ]= __( 'Sarah',   'foogallery' );
31
			$choices['fg-preset fg-goliath']= __( 'Goliath', 'foogallery' );
32
			$choices['fg-preset fg-jazz'   ]= __( 'Jazz',    'foogallery' );
33
			$choices['fg-preset fg-lily'   ]= __( 'Lily',    'foogallery' );
34
			$choices['fg-preset fg-ming'   ]= __( 'Ming',    'foogallery' );
35
			$choices['fg-preset fg-selena' ]= __( 'Selena',  'foogallery' );
36
			$choices['fg-preset fg-steve'  ]= __( 'Steve',   'foogallery' );
37
			$choices['fg-preset fg-zoe'    ]= __( 'Zoe',     'foogallery' );
38
			return $choices;
39
		}
40
41
		/**
42
		 * Removed the preset choices from the simple portfolio template
43
		 *
44
		 * @uses "foogallery_override_gallery_template_fields"
45
		 * @param $fields
46
		 * @param $template
47
		 *
48
		 * @return array
49
		 */
50
		function show_preset_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...
51
			foreach ($fields as &$field) {
52
				if ( 'hover_effect_help' === $field['id'] ||
53
					'hover_effect_preset' === $field['id'] ) {
54
55
					unset( $field['row_data']['data-foogallery-hidden'] );
56
				}
57
			}
58
59
			return $fields;
60
		}
61
62
        /**
63
         * Removed the preset choices from the simple portfolio template
64
         *
65
         * @uses "foogallery_override_gallery_template_fields"
66
         * @param $fields
67
         * @param $template
68
         *
69
         * @return array
70
         */
71
        function remove_preset_choices_for_simple_portfolio( $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...
72
            foreach ($fields as &$field) {
73
                if ( 'hover_effect_preset' === $field['id'] ) {
74
                    $new_choices = $field['choices'];
75
                    foreach ($field['choices'] as $choice => $choice_name) {
76
                        if ( strpos( $choice, 'fg-preset') !== false ) {
77
                            unset( $new_choices[$choice] );
78
                        }
79
                    }
80
                    $field['choices'] = $new_choices;
81
                }
82
            }
83
84
            return $fields;
85
        }
86
	}
87
}