|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
if ( !class_exists( 'FooGallery_Justified_Gallery_Template' ) ) { |
|
4
|
|
|
|
|
5
|
|
|
define('FOOGALLERY_JUSTIFIED_GALLERY_TEMPLATE_URL', plugin_dir_url( __FILE__ )); |
|
6
|
|
|
|
|
7
|
|
|
class FooGallery_Justified_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
|
|
|
} |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Register myself so that all associated JS and CSS files can be found and automatically included |
|
18
|
|
|
* @param $extensions |
|
19
|
|
|
* |
|
20
|
|
|
* @return array |
|
21
|
|
|
*/ |
|
22
|
|
|
function register_myself( $extensions ) { |
|
|
|
|
|
|
23
|
|
|
$extensions[] = __FILE__; |
|
24
|
|
|
return $extensions; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Add our gallery template to the list of templates available for every gallery |
|
29
|
|
|
* @param $gallery_templates |
|
30
|
|
|
* |
|
31
|
|
|
* @return array |
|
32
|
|
|
*/ |
|
33
|
|
|
function add_template( $gallery_templates ) { |
|
|
|
|
|
|
34
|
|
|
$gallery_templates[] = array( |
|
35
|
|
|
'slug' => 'justified', |
|
36
|
|
|
'name' => __( 'Justified Gallery', 'foogallery' ), |
|
37
|
|
|
'fields' => array( |
|
38
|
|
|
array( |
|
39
|
|
|
'id' => 'help', |
|
40
|
|
|
'title' => __( 'Tip', 'foogallery' ), |
|
41
|
|
|
'type' => 'html', |
|
42
|
|
|
'help' => true, |
|
43
|
|
|
'desc' => __( 'The Justified Gallery template uses the popular <a href="http://miromannino.com/projects/justified-gallery/" target="_blank">Justified Gallery jQuery Plugin</a> under the hood. You can specify thumbnail captions by setting the alt text for your attachments.', 'foogallery' ), |
|
44
|
|
|
), |
|
45
|
|
|
array( |
|
46
|
|
|
'id' => 'thumb_height', |
|
47
|
|
|
'title' => __( 'Thumb Height', 'foogallery' ), |
|
48
|
|
|
'desc' => __( 'Choose the height of your thumbnails. Thumbnails will be generated on the fly and cached once generated.', 'foogallery' ), |
|
49
|
|
|
'type' => 'number', |
|
50
|
|
|
'class' => 'small-text', |
|
51
|
|
|
'default' => 250, |
|
52
|
|
|
'step' => '10', |
|
53
|
|
|
'min' => '0', |
|
54
|
|
|
), |
|
55
|
|
|
array( |
|
56
|
|
|
'id' => 'row_height', |
|
57
|
|
|
'title' => __( 'Row Height', 'foogallery' ), |
|
58
|
|
|
'desc' => __( 'The preferred height of your gallery rows. This can be different from the thumbnail height.', 'foogallery' ), |
|
59
|
|
|
'type' => 'number', |
|
60
|
|
|
'class' => 'small-text', |
|
61
|
|
|
'default' => 150, |
|
62
|
|
|
'step' => '10', |
|
63
|
|
|
'min' => '0', |
|
64
|
|
|
), |
|
65
|
|
|
array( |
|
66
|
|
|
'id' => 'max_row_height', |
|
67
|
|
|
'title' => __( 'Max Row Height', 'foogallery' ), |
|
68
|
|
|
'desc' => __( 'A number (e.g 200) which specifies the maximum row height in pixels. A negative value for no limits. Alternatively, use a percentage (e.g. 200% which means that the row height cannot exceed 2 * rowHeight)', 'foogallery' ), |
|
69
|
|
|
'type' => 'text', |
|
70
|
|
|
'class' => 'small-text', |
|
71
|
|
|
'default' => '200%' |
|
72
|
|
|
), |
|
73
|
|
|
array( |
|
74
|
|
|
'id' => 'margins', |
|
75
|
|
|
'title' => __( 'Margins', 'foogallery' ), |
|
76
|
|
|
'desc' => __( 'The spacing between your thumbnails.', 'foogallery' ), |
|
77
|
|
|
'type' => 'number', |
|
78
|
|
|
'class' => 'small-text', |
|
79
|
|
|
'default' => 1, |
|
80
|
|
|
'step' => '1', |
|
81
|
|
|
'min' => '0', |
|
82
|
|
|
), |
|
83
|
|
|
array( |
|
84
|
|
|
'id' => 'captions', |
|
85
|
|
|
'title' => __( 'Show Captions', 'foogallery' ), |
|
86
|
|
|
'desc' => __( 'Show a caption when hovering over your thumbnails. (Set captions by adding either a title or alt text to an attachment)', 'foogallery' ), |
|
87
|
|
|
'type' => 'checkbox', |
|
88
|
|
|
'default' => 'on', |
|
89
|
|
|
), |
|
90
|
|
|
array( |
|
91
|
|
|
'id' => 'caption_source', |
|
92
|
|
|
'title' => __( 'Caption Source', 'foogallery' ), |
|
93
|
|
|
'desc' => __( 'Pull captions from either the attachment Title, Caption or Alt Text.', 'foogallery' ), |
|
94
|
|
|
'type' => 'radio', |
|
95
|
|
|
'default' => 'title', |
|
96
|
|
|
'spacer' => '<span class="spacer"></span>', |
|
97
|
|
|
'choices' => array( |
|
98
|
|
|
'title' => __( 'Attachment Title', 'foogallery' ), |
|
99
|
|
|
'caption' => __( 'Attachment Caption', 'foogallery' ), |
|
100
|
|
|
'alt' => __( 'Attachment Alt Text', 'foogallery' ) |
|
101
|
|
|
) |
|
102
|
|
|
), |
|
103
|
|
|
array( |
|
104
|
|
|
'id' => 'thumbnail_link', |
|
105
|
|
|
'title' => __( 'Thumbnail Link', 'foogallery' ), |
|
106
|
|
|
'default' => 'image' , |
|
107
|
|
|
'type' => 'thumb_link', |
|
108
|
|
|
'spacer' => '<span class="spacer"></span>', |
|
109
|
|
|
'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' ), |
|
110
|
|
|
), |
|
111
|
|
|
array( |
|
112
|
|
|
'id' => 'lightbox', |
|
113
|
|
|
'title' => __( 'Lightbox', 'foogallery' ), |
|
114
|
|
|
'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' ), |
|
115
|
|
|
'type' => 'lightbox', |
|
116
|
|
|
), |
|
117
|
|
|
), |
|
118
|
|
|
); |
|
119
|
|
|
|
|
120
|
|
|
return $gallery_templates; |
|
121
|
|
|
} |
|
122
|
|
|
} |
|
123
|
|
|
} |
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.