forked from ideesculture/WP-CollectiveAccess
-
Notifications
You must be signed in to change notification settings - Fork 1
/
widget_browse_links.php
executable file
·70 lines (60 loc) · 2.76 KB
/
widget_browse_links.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
* Created by PhpStorm.
* User: gautier
* Date: 26/06/2014
* Time: 06:38
*/
require_once(plugin_dir_path( __FILE__ ) ."lib/cawrappercache/ItemServiceCache.php");
add_action( 'widgets_init', 'collectiveaccess_register_browse_links_widget' );
//register our widget
function collectiveaccess_register_browse_links_widget() {
register_widget( 'browse_links_widget' );
}
class browse_links_widget extends WP_Widget {
//process the new widget
function browse_links_widget() {
$description = __('Display browse collections links','collectiveaccess');
$widget_ops = array(
'classname' => 'browse_links_widget_class',
'description' => $description
);
$title = __('CollectiveAccess browse collections links',"collectiveaccess");
$this->WP_Widget( 'browse_links_widget', $title, $widget_ops );
}
//build the widget settings form
function form($instance) {
$title = __('Browse collections','collectiveaccess');
$defaults = array(
'title' => $title
);
// TODO : add checkboxes to select which collections parts are browsable
$instance = wp_parse_args( (array) $instance, $defaults );
$title = $instance['title'];
?>
<p><?php _e('Title:','collectiveaccess');?> <input class="widefat" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p>
<?php
}
//save the widget settings
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
return $instance;
}
//display the widget
function widget($args, $instance) {
extract($args);
$title = (!empty($instance['title']) ? $instance['title'] : __('Browse collections','collectiveaccess'));
echo $before_widget;
$widget_body = "<ul>";
$widget_body .= "<li><a href='".get_site_url()."/collections/objects/browse'>".__("Objects","collectiveaccess")."</a></li>";
$widget_body .= "<li><a href='".get_site_url()."/collections/entities/browse'>".__("Entities","collectiveaccess")."</a></li>";
$widget_body .= "<li><a href='".get_site_url()."/collections/occurrences/browse'>".__("Occurrences","collectiveaccess")."</a></li>";
$widget_body .= "<li><a href='".get_site_url()."/collections/places/browse'>".__("Places","collectiveaccess")."</a></li>";
$widget_body .= "<li><a href='".get_site_url()."/collections/collections/browse'>".__("Collections","collectiveaccess")."</a></li>";
$widget_body .= "</ul>";
if ( !empty( $title ) ) { echo $before_title . $title . $after_title; };
print $widget_body;
echo $after_widget;
}
}