forked from imath/altctrl-public-group
-
Notifications
You must be signed in to change notification settings - Fork 0
/
altctrl-public-group.php
executable file
·111 lines (98 loc) · 2.99 KB
/
altctrl-public-group.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
<?php
/**
* Experiment to provide an alternative control to group admins on their public groups.
*
*
* @author imath
* @license GPL-2.0+
* @link http://imathi.eu
*
* @buddypress-plugin
* Plugin Name: Alternative Public Group Control
* Plugin URI: http://imathi.eu/2014/06/15/altctrl-public-group/
* Description: Experimental BuddyPress plugin to provide an alternative control to group admins on their public groups.
* Version: 1.0.0-beta
* Author: imath
* Author URI: http://imathi.eu
* Text Domain: altctrl-public-group
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Domain Path: /languages/
* GitHub Plugin URI: https://github.com/imath/altctrl-public-group
*/
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* The Alternative Public Group control Loader class
*
* @since 1.0.0
*/
class Alt_Public_Group_Ctrl_Loader {
/**
* Let's start
*/
public static function start() {
$bp = buddypress();
if ( empty( $bp->altctrl ) ) {
$bp->altctrl = new self;
}
return $bp->altctrl;
}
/**
* Constructor
*/
public function __construct() {
$this->setup_globals();
$this->includes();
$this->setup_actions();
}
/**
* Set the includes and templates dirs
*/
private function setup_globals() {
$this->version = '1.0.0-beta';
$this->domain = 'altctrl-public-group';
$this->includes_dir = trailingslashit( plugin_dir_path( __FILE__ ) . 'includes' );
$this->templates_dir = trailingslashit( plugin_dir_path( __FILE__ ) . 'templates' );
$this->lang_dir = trailingslashit( plugin_dir_path( __FILE__ ) . 'languages' );
$this->css_url = trailingslashit( plugin_dir_url ( __FILE__ ) . 'css' );
}
/**
* Include the needed file
*
* @since 1.0.0
*/
private function includes() {
if ( ! bp_is_active( 'groups' ) ) {
return;
}
require( $this->includes_dir . 'alt-public-group-ctrl.php' );
}
/**
* Hook to bp_init to load translation
*
* @since 1.0.0
*/
private function setup_actions() {
add_action( 'bp_init', array( $this, 'load_textdomain' ), 5 );
}
/**
* Load the translation files
*
* @since 1.0.0
*/
public function load_textdomain() {
// Traditional WordPress plugin locale filter
$locale = apply_filters( 'plugin_locale', get_locale(), $this->domain );
$mofile = sprintf( '%1$s-%2$s.mo', $this->domain, $locale );
// Setup paths to current locale file
$mofile_local = $this->lang_dir . $mofile;
$mofile_global = WP_LANG_DIR . '/altctrl-public-group/' . $mofile;
// Look in global /wp-content/languages/altctrl-public-group folder
load_textdomain( $this->domain, $mofile_global );
// Look in local /wp-content/plugins/altctrl-public-group/languages/ folder
load_textdomain( $this->domain, $mofile_local );
// Look in global /wp-content/languages/plugins/
load_plugin_textdomain( $this->domain );
}
}
add_action( 'bp_include', array( 'Alt_Public_Group_Ctrl_Loader', 'start' ) );