This repository has been archived by the owner on Feb 27, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buddyboss-extended-addon.php
150 lines (126 loc) · 3.61 KB
/
buddyboss-extended-addon.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
141
142
143
144
145
146
147
148
149
150
<?php
/**
* Plugin Name: BuddyBoss Extended Add-on
* Plugin URI: https://github.com/jcatama/buddyboss-extended-addon
* Description: 🚀 All-in-one enhancement plugin that improves WordPress & BuddyBoss integration.
* Author: John Albert Catama
* Author URI: https://github.com/jcatama
* Version: 1.2.2
* Text Domain: buddyboss-extended-addon
* Domain Path: /languages/
* License: GPL2
*
* @package BuddyBossExtendedAddon
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
if ( ! defined( 'BBEA_VERSION' ) ) {
define( 'BBEA_VERSION', 'v1.2.2' );
}
if ( ! defined( 'BBEA_PLUGIN_DIR' ) ) {
define( 'BBEA_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
}
// WP Activation hook.
register_activation_hook( __FILE__, 'on_bbea_activation' );
/**
* Check for BuddyBoss dependency.
*
* @return void
*/
function on_bbea_activation() {
if ( ! is_plugin_active( 'buddyboss-platform/bp-loader.php' ) && is_admin() ) {
wp_die(
sprintf(
/* translators: %s: plugin home url */
__(
'Sorry, but this plugin requires BuddyBoss Platform Plugin to be installed and active.<br><a href="%1$s">« Return to Plugins</a>',
'buddyboss-extended-addon'
),
admin_url( 'plugins.php' )
)
);
deactivate_plugins( plugin_basename( __FILE__ ) );
}
}
// Plugin action link hook.
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'bbea_plugin_page_settings_link' );
/**
* Add setting page link.
*
* @param array $links wp links.
*
* @return string, url link
*/
function bbea_plugin_page_settings_link( $links ) {
$links[] = sprintf(
/* translators: %s: plugin setting page url, %s: settings */
__(
'<a href="%1$s">%2$s</a>',
'buddyboss-extended-addon'
),
admin_url( 'options-general.php?page=bbea' ),
'Settings'
);
return $links;
}
// Hook scripts and styles.
add_action( 'wp_enqueue_scripts', 'bbea_scripts_styles', 9999 );
/**
* Enqueues scripts and styles.
*
* @return void
*/
function bbea_scripts_styles() {
/**
* Scripts and Styles loaded by the parent theme can be unloaded if needed
* using wp_deregister_script or wp_deregister_style.
*
* See the WordPress Codex for more information about those functions:
* http://codex.wordpress.org/Function_Reference/wp_deregister_script
* http://codex.wordpress.org/Function_Reference/wp_deregister_style
*/
wp_enqueue_style( 'bbea-css', plugins_url( 'assets/css/index.css', __FILE__ ), [], BBEA_VERSION );
wp_localize_script( 'jquery', 'bbea', [ 'ajaxurl' => admin_url( 'admin-ajax.php' ) ] );
}
// Check if bbea_option_all_unsubscribe is enabled.
if ( 1 === absint( get_option( 'bbea_option_all_unsubscribe' ) ) ) :
// BuddyPress registration hooks.
add_action( 'bbp_register_theme_packages', 'bbea_register_plugin_template' );
/**
* Register BBPress overrides.
*
* @return void
*/
function bbea_register_plugin_template() {
/**
* This function registers a new template stack location.
*
* @param string $location_callback
* @param int $priority
*
* @return void
*/
bbp_register_template_stack( 'bbea_get_template_path', 12 );
}
/**
* Return custom bbpress overrides.
*
* @return string
*/
function bbea_get_template_path() {
return BBEA_PLUGIN_DIR . 'includes/templates/bbpress/';
}
endif;
// Plugin hook.
add_action( 'plugins_loaded', 'bbea_init' );
/**
* Register plugin hook.
*
* @return void
*/
function bbea_init() {
// Load local translations.
load_plugin_textdomain( 'buddyboss-extended-addon', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
// Include classes.
require_once BBEA_PLUGIN_DIR . 'includes/classes/class-index.php';
}