|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
if ( !class_exists( 'FooGallery_Simple_Portfolio_Gallery_Template' ) ) { |
|
4
|
|
|
|
|
5
|
|
|
define('FOOGALLERY_SIMPLE_PORTFOLIO_GALLERY_TEMPLATE_URL', plugin_dir_url( __FILE__ )); |
|
6
|
|
|
|
|
7
|
|
|
class FooGallery_Simple_Portfolio_Gallery_Template { |
|
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Wire up everything we need to run the extension |
|
10
|
|
|
*/ |
|
11
|
|
|
function __construct() { |
|
|
|
|
|
|
12
|
|
|
add_filter( 'foogallery_gallery_templates', array( $this, 'add_template' ) ); |
|
13
|
|
|
add_filter( 'foogallery_gallery_templates_files', array( $this, 'register_myself' ) ); |
|
14
|
|
|
add_filter( 'foogallery_attachment_html_image_attributes', array( $this, 'strip_size' ), 99, 3 ); |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Register myself so that all associated JS and CSS files can be found and automatically included |
|
19
|
|
|
* @param $extensions |
|
20
|
|
|
* |
|
21
|
|
|
* @return array |
|
22
|
|
|
*/ |
|
23
|
|
|
function register_myself( $extensions ) { |
|
|
|
|
|
|
24
|
|
|
$extensions[] = __FILE__; |
|
25
|
|
|
return $extensions; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Add our gallery template to the list of templates available for every gallery |
|
30
|
|
|
* @param $gallery_templates |
|
31
|
|
|
* |
|
32
|
|
|
* @return array |
|
33
|
|
|
*/ |
|
34
|
|
|
function add_template( $gallery_templates ) { |
|
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
$gallery_templates[] = array( |
|
37
|
|
|
'slug' => 'simple_portfolio', |
|
38
|
|
|
'name' => __( 'Simple Portfolio', 'foogallery' ), |
|
39
|
|
|
'fields' => array( |
|
40
|
|
|
array( |
|
41
|
|
|
'id' => 'help', |
|
42
|
|
|
'title' => __( 'Tip', 'foogallery' ), |
|
43
|
|
|
'type' => 'html', |
|
44
|
|
|
'help' => true, |
|
45
|
|
|
'desc' => __( 'The Simple Portfolio template works best when you have <strong>captions and descriptions</strong> set for every attachment in the gallery.<br />To change captions and descriptions, simply hover over the thumbnail above and click the "i" icon.', 'foogallery' ), |
|
46
|
|
|
), |
|
47
|
|
|
array( |
|
48
|
|
|
'id' => 'thumbnail_dimensions', |
|
49
|
|
|
'title' => __( 'Thumbnail Size', 'foogallery' ), |
|
50
|
|
|
'desc' => __( 'Choose the size of your thumbnails.', 'foogallery' ), |
|
51
|
|
|
'type' => 'thumb_size', |
|
52
|
|
|
'default' => array( |
|
53
|
|
|
'width' => 250, |
|
54
|
|
|
'height' => 200, |
|
55
|
|
|
'crop' => true, |
|
56
|
|
|
), |
|
57
|
|
|
), |
|
58
|
|
|
array( |
|
59
|
|
|
'id' => 'thumbnail_link', |
|
60
|
|
|
'title' => __( 'Thumbnail Link', 'foogallery' ), |
|
61
|
|
|
'default' => 'image', |
|
62
|
|
|
'type' => 'thumb_link', |
|
63
|
|
|
'spacer' => '<span class="spacer"></span>', |
|
64
|
|
|
'desc' => __( 'You can choose to link each thumbnail to the full size image, or to the image\'s attachment page, or you can choose to not link to anything.', 'foogallery' ) |
|
65
|
|
|
), |
|
66
|
|
|
array( |
|
67
|
|
|
'id' => 'lightbox', |
|
68
|
|
|
'title' => __( 'Lightbox', 'foogallery' ), |
|
69
|
|
|
'desc' => __( 'Choose which lightbox you want to display images with. The lightbox will only work if you set the thumbnail link to "Full Size Image".', 'foogallery' ), |
|
70
|
|
|
'type' => 'lightbox', |
|
71
|
|
|
), |
|
72
|
|
|
array( |
|
73
|
|
|
'id' => 'gutter', |
|
74
|
|
|
'title' => __( 'Gutter', 'foogallery' ), |
|
75
|
|
|
'desc' => __( 'The spacing between each thumbnail in the gallery.', 'foogallery' ), |
|
76
|
|
|
'type' => 'number', |
|
77
|
|
|
'class' => 'small-text', |
|
78
|
|
|
'default' => 40, |
|
79
|
|
|
'step' => '1', |
|
80
|
|
|
'min' => '0', |
|
81
|
|
|
), |
|
82
|
|
|
array( |
|
83
|
|
|
'id' => 'caption_position', |
|
84
|
|
|
'title' => __('Caption Position', 'foogallery'), |
|
85
|
|
|
'desc' => __('Where the captions are displayed in relation to the thumbnail.', 'foogallery'), |
|
86
|
|
|
'section' => __( 'Caption Settings', 'foogallery' ), |
|
87
|
|
|
'default' => '', |
|
88
|
|
|
'type' => 'radio', |
|
89
|
|
|
'spacer' => '<span class="spacer"></span>', |
|
90
|
|
|
'choices' => array( |
|
91
|
|
|
'' => __( 'Below', 'foogallery' ), |
|
92
|
|
|
'bf-captions-above' => __( 'Above', 'foogallery' ) |
|
93
|
|
|
) |
|
94
|
|
|
), |
|
95
|
|
|
array( |
|
96
|
|
|
'id' => 'caption_bg_color', |
|
97
|
|
|
'title' => __( 'Caption Background Color', 'foogallery' ), |
|
98
|
|
|
'section' => __( 'Caption Settings', 'foogallery' ), |
|
99
|
|
|
'type' => 'colorpicker', |
|
100
|
|
|
'default' => '#fff', |
|
101
|
|
|
'opacity' => true |
|
102
|
|
|
), |
|
103
|
|
|
array( |
|
104
|
|
|
'id' => 'caption_text_color', |
|
105
|
|
|
'title' => __( 'Caption Text Color', 'foogallery' ), |
|
106
|
|
|
'section' => __( 'Caption Settings', 'foogallery' ), |
|
107
|
|
|
'type' => 'colorpicker', |
|
108
|
|
|
'default' => '#333', |
|
109
|
|
|
'opacity' => true |
|
110
|
|
|
) |
|
111
|
|
|
), |
|
112
|
|
|
); |
|
113
|
|
|
|
|
114
|
|
|
return $gallery_templates; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* Simple portfolio relies on there being no width or height attributes on the IMG element so strip them out here. |
|
119
|
|
|
* |
|
120
|
|
|
* @param $attr |
|
121
|
|
|
* @param $args |
|
122
|
|
|
* @param $attachment |
|
123
|
|
|
* |
|
124
|
|
|
* @return mixed |
|
125
|
|
|
*/ |
|
126
|
|
|
function strip_size($attr, $args, $attachment){ |
|
|
|
|
|
|
127
|
|
|
global $current_foogallery_template; |
|
|
|
|
|
|
128
|
|
|
|
|
129
|
|
|
if ( 'simple_portfolio' === $current_foogallery_template ) { |
|
130
|
|
|
if ( isset($attr['width']) ){ |
|
131
|
|
|
unset($attr['width']); |
|
132
|
|
|
} |
|
133
|
|
|
if ( isset($attr['height']) ){ |
|
134
|
|
|
unset($attr['height']); |
|
135
|
|
|
} |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
return $attr; |
|
139
|
|
|
} |
|
140
|
|
|
} |
|
141
|
|
|
} |
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.