-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbp-event-organiser-groups.php
143 lines (93 loc) · 3.6 KB
/
bp-event-organiser-groups.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php /*
================================================================================
BP Group Organiser Group Extension
================================================================================
AUTHOR: Christian Wach <[email protected]>
--------------------------------------------------------------------------------
NOTES
=====
This class extends BP_Group_Extension to create the screens our plugin requires.
See: http://codex.buddypress.org/developer/plugin-development/group-extension-api/
--------------------------------------------------------------------------------
*/
// prevent problems during upgrade or when Groups are disabled
if ( !class_exists( 'BP_Group_Extension' ) ) { return; }
/*
================================================================================
Class Name
================================================================================
*/
class BP_Event_Organiser_Group_Extension extends BP_Group_Extension {
/*
============================================================================
Properties
============================================================================
*/
/*
// 'public' will show our extension to non-group members
// 'private' means only members of the group can view our extension
public $visibility = 'public';
// if our extension does not need a navigation item, set this to false
public $enable_nav_item = true;
// if our extension does not need an edit screen, set this to false
public $enable_edit_item = true;
// if our extension does not need an admin metabox, set this to false
public $enable_admin_item = true;
// the context of our admin metabox. See add_meta_box()
public $admin_metabox_context = 'core';
// the priority of our admin metabox. See add_meta_box()
public $admin_metabox_priority = 'normal';
*/
// no need for a creation step
public $enable_create_step = false;
// if our extension does not need an edit screen, set this to false
public $enable_edit_item = false;
// if our extension does not need an admin metabox, set this to false
public $enable_admin_item = false;
/**
* @description: initialises this object
* @return nothing
*/
function __construct() {
// init vars with filters applied
$name = apply_filters( 'bpeo_extension_title', __( 'Group Events', 'bp-event-organizer' ) );
$slug = apply_filters( 'bpeo_extension_slug', 'events' );
$pos = apply_filters( 'bpeo_extension_pos', 31 );
// test for BP 1.8+
// could also use 'bp_esc_sql_order' (the other core addition)
if ( function_exists( 'bp_core_get_upload_dir' ) ) {
// init array
$args = array(
'name' => $name,
'slug' => $slug,
'nav_item_position' => $pos,
'enable_create_step' => false,
);
// init
parent::init( $args );
} else {
// name our tab
$this->name = $name;
$this->slug = $slug;
// set position in navigation
$this->nav_item_position = $pos;
// disable create step
$this->enable_create_step = false;
}
}
/**
* @description display our content when the nav item is selected
*/
function display() {
// show header
echo '<h3>'.apply_filters( 'bpeo_extension_title', __( 'Group Events', 'bp-event-organizer' ) ).'</h3>';
// delete the transient cache
delete_transient( 'eo_full_calendar_public' );
// show events calendar, filtered by meta value in eo->intercept_calendar()
echo eo_get_event_fullcalendar( array(
'headerright' => 'prev,next today,month,agendaWeek',
) );
}
} // class ends
// register our class
bp_register_group_extension( 'BP_Event_Organiser_Group_Extension' );