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 { |
|
|
|
|
8
|
|
|
|
9
|
|
|
function __construct() { |
|
|
|
|
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 ) { |
|
|
|
|
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 ) { |
|
|
|
|
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 ) { |
|
|
|
|
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
|
|
|
} |
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.