-
Notifications
You must be signed in to change notification settings - Fork 1
/
gallery.php
42 lines (38 loc) · 1.44 KB
/
gallery.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
class cfs_gallery extends cfs_field
{
function __construct($parent = ""){
$this->name = 'gallery';
$this->label = __('Gallery', 'cfs');
$this->parent = $parent;
}
function html($field){
wp_register_script('cfs-gallery-js', plugins_url('gallery.js?time='.time(), __FILE__) , '', '', true);
wp_enqueue_script('cfs-gallery-js');
wp_register_style('cfs-gallery-css', plugins_url('gallery.css?time='.time(), __FILE__));
wp_enqueue_style('cfs-gallery-css');
?>
<script type="text/javascript">if(typeof(CFSGalLoadSort) == "function") CFSGalLoadSort();</script>
<div class="cfs-gallery-base">
<input type="hidden" name="<?=$field->input_name; ?>" class="<?=$field->input_class; ?>" value="<?=trim($field->value, ","); ?>" />
<div class="cfs-gallery">
<?php
foreach(explode(",",$field->value) as $img){
if($img != ""){
?>
<div class="base-img" data-id="<?=$img?>" style="background-image:url(<?=@array_shift(wp_get_attachment_image_src($img, "thumbnail"))?>);">
<a href="javascript:;" onclick="CFSGalremoveItemGallery(jQuery(this));">x</a>
</div>
<?php
}
}
?>
</div>
<input type="button" class="button-primary" value="<?=__('Add Images', 'cfs')?>" onclick="CFSusaGalleryWp(jQuery(this));" />
</div>
<?php
}
function format_value_for_api($value, $field = null){
return explode(",",$value);
}
}