1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* User: bradvin |
5
|
|
|
* Date: 2017/04/19 |
6
|
|
|
* Time: 1:19 PM |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
if ( ! class_exists( 'FooGallery_Admin_Gallery_MetaBox_Settings' ) ) { |
11
|
|
|
|
12
|
|
|
class FooGallery_Admin_Gallery_MetaBox_Settings { |
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* FooGallery_Admin_Gallery_MetaBox_Settings constructor. |
16
|
|
|
*/ |
17
|
|
|
function __construct() { |
|
|
|
|
18
|
|
|
//enqueue assets for the new settings tabs |
19
|
|
|
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) ); |
20
|
|
|
|
21
|
|
|
//set default settings tab icons |
22
|
|
|
add_filter( 'foogallery_gallery_settings_metabox_section_icon', array( $this, 'add_section_icons') ); |
23
|
|
|
|
24
|
|
|
add_filter( 'foogallery_gallery_template_common_thumbnail_fields', array( $this, 'add_gallery_template_common_thumbnail_fields' ) ); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/*** |
28
|
|
|
* Enqueue the assets needed by the settings |
29
|
|
|
* @param $hook_suffix |
30
|
|
|
*/ |
31
|
|
|
function enqueue_assets( $hook_suffix ){ |
|
|
|
|
32
|
|
|
if( in_array( $hook_suffix, array( 'post.php', 'post-new.php' ) ) ) { |
33
|
|
|
$screen = get_current_screen(); |
34
|
|
|
|
35
|
|
|
if ( is_object( $screen ) && FOOGALLERY_CPT_GALLERY == $screen->post_type ){ |
36
|
|
|
|
37
|
|
|
// Register, enqueue scripts and styles here |
38
|
|
|
wp_enqueue_script( 'foogallery-admin-settings', FOOGALLERY_URL . '/js/foogallery.admin.min.js', FOOGALLERY_VERSION, 'jquery' ); |
39
|
|
|
|
40
|
|
|
wp_enqueue_style( 'foogallery-admin-settings', FOOGALLERY_URL . '/css/foogallery.admin.min.css', FOOGALLERY_VERSION ); |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Returns the Dashicon that can be used in the settings tabs |
47
|
|
|
* @param $section_slug |
48
|
|
|
* @return string |
49
|
|
|
*/ |
50
|
|
|
function add_section_icons( $section_slug ) { |
|
|
|
|
51
|
|
|
switch ( $section_slug ) { |
52
|
|
|
case 'general': |
53
|
|
|
return 'dashicons-admin-tools'; |
54
|
|
|
break; |
|
|
|
|
55
|
|
|
case 'advanced': |
56
|
|
|
return 'dashicons-admin-generic'; |
57
|
|
|
break; |
|
|
|
|
58
|
|
|
case 'look & feel': |
59
|
|
|
return 'dashicons-images-alt2'; |
60
|
|
|
break; |
|
|
|
|
61
|
|
|
case 'video': |
62
|
|
|
return 'dashicons-format-video'; |
63
|
|
|
} |
64
|
|
|
return 'dashicons-admin-tools'; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Add common thumbnail fields to a gallery template |
69
|
|
|
* |
70
|
|
|
* @return array |
71
|
|
|
*/ |
72
|
|
|
function add_gallery_template_common_thumbnail_fields( $fields ) { |
|
|
|
|
73
|
|
|
|
74
|
|
|
$border_style_choices = apply_filters( 'foogallery_gallery_template_common_thumbnail_fields_border_style_choices', array( |
75
|
|
|
'border-style-square-white' => array( 'label' => __( 'Square white border with shadow' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-square-white.png' ), |
76
|
|
|
'border-style-circle-white' => array( 'label' => __( 'Circular white border with shadow' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-circle-white.png' ), |
77
|
|
|
'border-style-square-black' => array( 'label' => __( 'Square Black' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-square-black.png' ), |
78
|
|
|
'border-style-circle-black' => array( 'label' => __( 'Circular Black' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-circle-black.png' ), |
79
|
|
|
'border-style-inset' => array( 'label' => __( 'Square Inset' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-square-inset.png' ), |
80
|
|
|
'border-style-rounded' => array( 'label' => __( 'Plain Rounded' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-plain-rounded.png' ), |
81
|
|
|
'' => array( 'label' => __( 'Plain' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/border-style-icon-none.png' ), |
82
|
|
|
) ); |
83
|
|
|
$fields[] = array( |
84
|
|
|
'id' => 'border-style', |
85
|
|
|
'title' => __( 'Border Style', 'foogallery' ), |
86
|
|
|
'desc' => __( 'The border style applied to each thumbnail', 'foogallery' ), |
87
|
|
|
'section' => __( 'Look & Feel', 'foogallery' ), |
88
|
|
|
'type' => 'icon', |
89
|
|
|
'default' => 'border-style-square-white', |
90
|
|
|
'choices' => $border_style_choices |
91
|
|
|
); |
92
|
|
|
|
93
|
|
|
$fields[] = array( |
94
|
|
|
'id' => 'hover-effect-help', |
95
|
|
|
'title' => __( 'Hover Effect Help', 'foogallery' ), |
96
|
|
|
'desc' => __( 'Captions can be enabled by choosing the "Caption" hover effect below.', 'foogallery' ), |
97
|
|
|
'section' => __( 'Look & Feel', 'foogallery' ), |
98
|
|
|
'type' => 'help' |
99
|
|
|
); |
100
|
|
|
|
101
|
|
|
$hover_effect_type_choices = apply_filters( 'foogallery_gallery_template_common_thumbnail_fields_hover_effect_type_choices', array( |
102
|
|
|
'' => __( 'Icon', 'foogallery' ), |
103
|
|
|
'hover-effect-tint' => __( 'Dark Tint', 'foogallery' ), |
104
|
|
|
'hover-effect-color' => __( 'Colorize', 'foogallery' ), |
105
|
|
|
'hover-effect-caption' => __( 'Caption', 'foogallery' ), |
106
|
|
|
'hover-effect-scale' => __( 'Scale', 'foogallery' ), |
107
|
|
|
'hover-effect-none' => __( 'None', 'foogallery' ) |
108
|
|
|
) ); |
109
|
|
|
$fields[] = array( |
110
|
|
|
'id' => 'hover-effect-type', |
111
|
|
|
'title' => __( 'Hover Effect', 'foogallery' ), |
112
|
|
|
'section' => __( 'Look & Feel', 'foogallery' ), |
113
|
|
|
'default' => '', |
114
|
|
|
'type' => 'radio', |
115
|
|
|
'choices' => $hover_effect_type_choices, |
116
|
|
|
'desc' => __( 'Choose what will happen when you hover over a thumbnail', 'foogallery' ), |
117
|
|
|
'row_data'=> array( |
118
|
|
|
'data-foogallery-value-selector' => 'input:checked' |
119
|
|
|
) |
120
|
|
|
); |
121
|
|
|
|
122
|
|
|
$hover_effect_choices = apply_filters( 'foogallery_gallery_template_common_thumbnail_fields_hover_effect_choices', array( |
123
|
|
|
'hover-effect-zoom' => array( 'label' => __( 'Zoom' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-zoom.png' ), |
124
|
|
|
'hover-effect-zoom2' => array( 'label' => __( 'Zoom 2' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-zoom2.png' ), |
125
|
|
|
'hover-effect-zoom3' => array( 'label' => __( 'Zoom 3' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-zoom3.png' ), |
126
|
|
|
'hover-effect-plus' => array( 'label' => __( 'Plus' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-plus.png' ), |
127
|
|
|
'hover-effect-circle-plus' => array( 'label' => __( 'Cirlce Plus' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-circle-plus.png' ), |
128
|
|
|
'hover-effect-eye' => array( 'label' => __( 'Eye' , 'foogallery' ), 'img' => FOOGALLERY_DEFAULT_TEMPLATES_EXTENSION_SHARED_URL . 'img/admin/hover-effect-icon-eye.png' ) |
129
|
|
|
) ); |
130
|
|
|
$fields[] = array( |
131
|
|
|
'id' => 'hover-effect', |
132
|
|
|
'title' => __( 'Hover Icon', 'foogallery' ), |
133
|
|
|
'desc' => __( 'Choose which icon is shown when you hover over a thumbnail', 'foogallery' ), |
134
|
|
|
'section' => __( 'Look & Feel', 'foogallery' ), |
135
|
|
|
'type' => 'icon', |
136
|
|
|
'default' => 'hover-effect-zoom', |
137
|
|
|
'choices' => $hover_effect_choices, |
138
|
|
|
'row_data'=> array( |
139
|
|
|
'data-foogallery-hidden' => true, |
140
|
|
|
'data-foogallery-show-when-field' => 'hover-effect-type', |
141
|
|
|
'data-foogallery-show-when-field-value' => '' |
142
|
|
|
) |
143
|
|
|
); |
144
|
|
|
|
145
|
|
|
$caption_hover_effect_choices = apply_filters( 'foogallery_gallery_template_common_thumbnail_fields_caption_hover_effect_choices', array( |
146
|
|
|
'hover-caption-simple' => __( 'Simple', 'foogallery' ), |
147
|
|
|
'hover-caption-full-drop' => __( 'Drop', 'foogallery' ), |
148
|
|
|
'hover-caption-full-fade' => __( 'Fade In', 'foogallery' ), |
149
|
|
|
'hover-caption-push' => __( 'Push', 'foogallery' ), |
150
|
|
|
'hover-caption-simple-always' => __( 'Always Visible', 'foogallery' ) |
151
|
|
|
) ); |
152
|
|
|
$fields[] = array( |
153
|
|
|
'id' => 'caption-hover-effect', |
154
|
|
|
'title' => __( 'Caption Type', 'foogallery' ), |
155
|
|
|
'desc' => __( 'Choose what the captions will look like and how they will work', 'foogallery' ), |
156
|
|
|
'section' => __( 'Look & Feel', 'foogallery' ), |
157
|
|
|
'default' => 'hover-caption-simple', |
158
|
|
|
'type' => 'radio', |
159
|
|
|
'choices' => $caption_hover_effect_choices, |
160
|
|
|
'row_data'=> array( |
161
|
|
|
'data-foogallery-hidden' => true, |
162
|
|
|
'data-foogallery-show-when-field' => 'hover-effect-type', |
163
|
|
|
'data-foogallery-show-when-field-value' => 'hover-effect-caption' |
164
|
|
|
) |
165
|
|
|
); |
166
|
|
|
|
167
|
|
|
$caption_content_choices = apply_filters( 'foogallery_gallery_template_common_thumbnail_fields_caption_content_choices', array( |
168
|
|
|
'title' => __( 'Title Only', 'foogallery' ), |
169
|
|
|
'desc' => __( 'Description Only', 'foogallery' ), |
170
|
|
|
'both' => __( 'Title and Description', 'foogallery' ) |
171
|
|
|
) ); |
172
|
|
|
$fields[] = array( |
173
|
|
|
'id' => 'caption-content', |
174
|
|
|
'title' => __( 'Caption Content', 'foogallery' ), |
175
|
|
|
'desc' => __( 'Choose what is used for your caption content', 'foogallery' ), |
176
|
|
|
'section' => __( 'Look & Feel', 'foogallery' ), |
177
|
|
|
'default' => 'title', |
178
|
|
|
'type' => 'radio', |
179
|
|
|
'choices' => $caption_content_choices, |
180
|
|
|
'row_data'=> array( |
181
|
|
|
'data-foogallery-hidden' => true, |
182
|
|
|
'data-foogallery-show-when-field' => 'hover-effect-type', |
183
|
|
|
'data-foogallery-show-when-field-value' => 'hover-effect-caption' |
184
|
|
|
) |
185
|
|
|
); |
186
|
|
|
|
187
|
|
|
return $fields; |
188
|
|
|
} |
189
|
|
|
} |
190
|
|
|
} |
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.