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 ( 7d5fa4...bb6361 )
by Brad
05:02 queued 02:31
created

FooGallery_FooBox_Support   A

Complexity

Total Complexity 13

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 13
lcom 0
cbo 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 21 3
A ensure_outdated_foobox_extensions_never_run() 0 13 3
A add_lightbox() 0 9 3
A album_stack_link_class_name() 0 3 1
A add_panning_fields() 0 14 1
A add_panning_attributes() 0 12 2
1
<?php
2
/**
3
 * Adds in better support for FooBox Free and PRO
4
 */
5
6
if ( !class_exists( 'FooGallery_FooBox_Support' ) ) {
7
8
	class FooGallery_FooBox_Support {
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
			//we need to make sure outdated versions of FooBox never run in the future
12
			$this->ensure_outdated_foobox_extensions_never_run();
13
14
			//add the FooBox lightbox option no matter if using Free or Pro
15
			add_filter( 'foogallery_gallery_template_field_lightboxes', array($this, 'add_lightbox') );
16
17
			if ( class_exists( 'fooboxV2' ) ) {
18
				//FooBox PRO specific functionality
19
20
				//only add FooBox PRO functionality after FooBox version 1.2.29
21
				if ( version_compare( FOOBOX_BASE_VERSION, '1.2.29', '>' ) ) {
22
					add_filter( 'foogallery_attachment_custom_fields', array($this, 'add_panning_fields' ) );
23
					add_filter( 'foogallery_attachment_html_link_attributes', array( $this, 'add_panning_attributes' ), 10, 3 );
24
				}
25
26
			} else {
27
				//FooBox Free specific functionality
28
				add_filter( 'foogallery_album_stack_link_class_name', array($this, 'album_stack_link_class_name'));
29
			}
30
		}
31
32
		function ensure_outdated_foobox_extensions_never_run() {
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...
33
			global $foogallery_extensions;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
34
35
			//backwards compatibility for older versions of the FooBox Free extension class
36
			if ( class_exists( 'FooGallery_FooBox_Free_Extension' ) ) {
37
				$foogallery_extensions['foobox-image-lightbox'] = $this;
38
			}
39
40
			//backwards compatibility for older versions of the FooBox PRO extension class
41
			if ( class_exists( 'FooGallery_FooBox_Extension' ) ) {
42
				$foogallery_extensions['foobox'] = $this;
43
			}
44
		}
45
46
		function add_lightbox($lightboxes) {
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...
47
			$option_text = __( 'FooBox', 'foogallery' );
48
			if ( !class_exists( 'FooBox' ) && !class_exists( 'fooboxV2' ) ) {
49
				$option_text .= __( ' (Not installed!)', 'foogallery' );
50
			}
51
52
			$lightboxes['foobox'] = $option_text;
53
			return $lightboxes;
54
		}
55
56
		function album_stack_link_class_name( $class_name ) {
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...
57
			return str_replace( 'foobox-free', 'foobox', $class_name );
58
		}
59
60
		function add_panning_fields( $fields ) {
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...
61
			$fields['foobox_panning'] = array(
62
				'label'       =>  __( 'Panning', 'foogallery' ),
63
				'input'       => 'radio',
64
				'helps'       => __( 'Enable mouse panning for this image in the lightbox.', 'foogallery' ),
65
				'exclusions'  => array( 'audio', 'video' ),
66
				'options'     => array(
67
					'' => __( 'Disabled', 'foogallery' ),
68
					'enabled' => __( 'Enabled', 'foogallery' )
69
				)
70
			);
71
72
			return $fields;
73
		}
74
75
		function add_panning_attributes( $attr, $args, $foogallery_attachment ) {
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...
76
77
			$foobox_panning = get_post_meta( $foogallery_attachment->ID, '_foobox_panning', true );
78
79
			if ( !empty( $foobox_panning ) ) {
80
				//add data-overflow="true" + data-proportion="false" attributes to the anchor link
81
				$attr['data-overflow'] = 'true';
82
				$attr['data-proportion'] = 'false';
83
			}
84
85
			return $attr;
86
		}
87
	}
88
}