-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbp-block-users.php
140 lines (123 loc) · 3.88 KB
/
bp-block-users.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
/**
* Plugin Name: BP Block Users
* Plugin URI: https://github.com/thebrandonallen/bp-block-users
* Description: Allows BuddyPress administrators to block users indefinitely, or for a specified period of time.
* Author: Brandon Allen
* Author URI: https://github.com/thebrandonallen
* Text Domain: bp-block-users
* Domain Path: /languages
* Version: 1.0.2
*
* Copyright (C) 2015-2018 Brandon Allen (https://github.com/thebrandonallen)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* @package BP_Block_Users
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
/**
* Only load the plugin code if BuddyPress is activated.
*
* @since 1.0.0
*/
function bpbu_init() {
// Only supported in BP 2.5.0+.
if ( version_compare( bp_get_version(), '2.5.0', '>=' ) ) {
require plugin_dir_path( __FILE__ ) . 'classes/class-bpbu-component.php';
add_action( 'bp_loaded', 'bpbu_setup_component' );
} else {
add_action( 'admin_notices', 'bpbu_display_older_bp_notice' );
}
}
add_action( 'bp_include', 'bpbu_init' );
/**
* Display the notice that BuddyPress is too old.
*
* Provided as a PHP 7.2 compatability step to replace `create_function`.
* Since PHP 5.3 is not the minimum version yet, we need an actual function.
*
* @since 1.1.0
*
* @return void
*/
function bpbu_display_older_bp_notice() {
$older_version_notice = __( 'Hey! BP Block Users requires BuddyPress 2.5.0 or higher.', 'bp-block-users' );
echo '<div class=\"error\"><p>"' . esc_html( $older_version_notice ) . '"</p></div>';
}
/**
* Load the translation file for current language. Checks the BP Block Users
* languages folder first, then inside the default WP language plugins folder.
*
* Note that custom translation files inside the BP Block Users plugin folder
* will be removed on BP Block Users updates. If you're creating custom
* translation files, please use the global language folder, located at
* wp-content/languages/plugins.
*
* @since 1.0.0
* @since 1.1.0 Only check the default WP languages directory.
*/
function bpbu_load_textdomain() {
load_plugin_textdomain( 'bp-block-users' );
}
add_action( 'plugins_loaded', 'bpbu_load_textdomain' );
/**
* Loads the Block Users component into the $bp global.
*
* @since 1.0.0
*/
function bpbu_setup_component() {
buddypress()->block_users = new BPBU_Component( __FILE__ );
/**
* Fires after the BP Block Users component is loaded.
*
* @since 1.0.0
*/
do_action( 'bpbu_loaded' );
}
/**
* The BP Block Users activation hook.
*
* @since 1.0.0
*/
function bpbu_activation() {
/**
* Fires on plugin activation.
*
* @since 1.0.0
*/
do_action( 'bpbu_activation' );
}
register_activation_hook( __FILE__, 'bpbu_activation' );
/**
* The BP Block Users deactivation hook.
*
* @since 1.0.0
*/
function bpbu_deactivation() {
/**
* Fires on plugin deactivation.
*
* @since 1.0.0
*/
do_action( 'bpbu_deactivation' );
}
register_deactivation_hook( __FILE__, 'bpbu_deactivation' );
/* Constants ******************************************************************/
// `MONTH_IN_SECONDS` wasn't introduced until WP 4.4, so we add it here.
if ( ! defined( 'MONTH_IN_SECONDS' ) ) {
define( 'MONTH_IN_SECONDS', ( 30 * DAY_IN_SECONDS ) );
}