-
Notifications
You must be signed in to change notification settings - Fork 0
/
bp-links-component.php
100 lines (83 loc) · 2.53 KB
/
bp-links-component.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
<?php
if ( !defined( 'ABSPATH' ) ) {
exit;
}
class BP_Links_Component extends BP_Component {
function __construct()
{
parent::start(
'links',
_x( 'User Links', 'Link screen page <title>', 'buddypress-links' ),
BP_LINKS_PLUGIN_DIR
);
$this->includes();
bp_links_init_settings();
buddypress()->active_components[$this->id] = '1';
}
function includes( $args = array() )
{
require ( BP_LINKS_PLUGIN_DIR . '/bp-links-core.php' );
require ( BP_LINKS_PLUGIN_DIR . '/bp-links-embed.php' );
require ( BP_LINKS_PLUGIN_DIR . '/bp-links-classes.php' );
require ( BP_LINKS_PLUGIN_DIR . '/bp-links-ajax.php' );
require ( BP_LINKS_PLUGIN_DIR . '/bp-links-templatetags.php' );
require ( BP_LINKS_PLUGIN_DIR . '/bp-links-widgets.php' );
require ( BP_LINKS_PLUGIN_DIR . '/bp-links-filters.php' );
require ( BP_LINKS_PLUGIN_DIR . '/bp-links-dtheme.php' );
do_action( 'bp_links_includes' );
}
function setup_globals( $args = array() )
{
$bp = buddypress();
$global_tables = array(
'table_name' => $bp->table_prefix . 'bp_links',
'table_name_categories' => $bp->table_prefix . 'bp_links_categories',
'table_name_votes' => $bp->table_prefix . 'bp_links_votes',
'table_name_linkmeta' => $bp->table_prefix . 'bp_links_linkmeta',
);
// Set up the $globals array to be passed along to parent::setup_globals()
$globals = array(
'slug' => BP_LINKS_SLUG,
'root_slug' => isset( $bp->pages->{$this->id}->slug ) ? $bp->pages->{$this->id}->slug : BP_LINKS_SLUG,
'has_directory' => true, // Set to false if not required
'notification_callback' => 'bp_links_format_notifications',
'search_string' => __( 'Search Links...', 'buddypress-links' ),
'global_tables' => $global_tables
);
// Let BP_Component::setup_globals() do its work.
parent::setup_globals( $globals );
$this->forbidden_names =
apply_filters( 'bp_links_forbidden_names',
array(
// internal
'add',
'admin',
'all',
'create',
'delete',
'feed',
'links',
'my-links',
'submit',
// order by filter
'active',
'high-votes',
'most-votes',
'newest',
'popular',
// category url slug
BP_LINKS_CAT_URL_SLUG
)
);
}
function setup_nav( $main_nav = array(), $sub_nav = array() )
{
// nothing special yet
parent::setup_nav( $main_nav, $sub_nav );
}
}
function bp_links_setup_component()
{
buddypress()->links = new BP_Links_Component();
}
add_action( 'bp_loaded', 'bp_links_setup_component' );