|
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 { |
|
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
function __construct() { |
|
|
|
|
|
|
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() { |
|
|
|
|
|
|
33
|
|
|
global $foogallery_extensions; |
|
|
|
|
|
|
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) { |
|
|
|
|
|
|
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 ) { |
|
|
|
|
|
|
57
|
|
|
return str_replace( 'foobox-free', 'foobox', $class_name ); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
function add_panning_fields( $fields ) { |
|
|
|
|
|
|
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 ) { |
|
|
|
|
|
|
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
|
|
|
} |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.