-
Notifications
You must be signed in to change notification settings - Fork 33
/
bp-activity-subscription.php
103 lines (89 loc) · 3.05 KB
/
bp-activity-subscription.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
<?php
/*
Plugin Name: BuddyPress Group Email Subscription
Plugin URI: http://wordpress.org/extend/plugins/buddypress-group-email-subscription/
Description: Allows group members to receive email notifications for group activity and forum posts instantly or as daily digest or weekly summary.
Author: Deryk Wenaus, boonebgorges, r-a-y
Revision Date: November 1, 2023
Version: 4.2.1
Text Domain: buddypress-group-email-subscription
Domain Path: /languages
*/
/**
* GES revision date.
*
* @since 3.7.0
*
* @var string Date string of last revision.
*/
define( 'GES_REVISION_DATE', '2023-11-01 19:00 UTC' );
require __DIR__ . '/vendor/autoload.php';
HardG\BuddyPress120URLPolyfills\Loader::init();
/**
* Main loader for the plugin.
*
* @since 2.9.0
*/
function ass_loader() {
if ( ! defined( 'BPGES_DEBUG_LOG_PATH' ) ) {
$dir = wp_upload_dir( null, false );
define( 'BPGES_DEBUG_LOG_PATH', trailingslashit( $dir['basedir'] ) . 'bpges-debug.log' );
}
$error = '';
// Old BP.
if ( version_compare( BP_VERSION, '2.1', '<' ) ) {
$error = __( 'BP Group Email Subscription v4.2.0 requires BuddyPress 2.1 or higher.', 'buddypress-group-email-subscription' );
} elseif ( ! bp_is_active( 'groups' ) || ! bp_is_active( 'activity' ) ) {
$admin_url = bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), 'admin.php' ) );
$error = sprintf( __( 'BuddyPress Group Email Subscription requires the BP Groups and Activity components. Please <a href="%s">activate them</a> to use this plugin.', 'buddypress-group-email-subscription' ), esc_url( $admin_url ) );
}
if ( $error ) {
if ( current_user_can( 'bp_moderate' ) ) {
$error_cb = function() use ( $error ) {
echo '<div class="error"><p>' . $error . '</p></div>';
};
add_action( 'admin_notices', $error_cb );
add_action( 'network_admin_notices', $error_cb );
}
return;
}
require_once( dirname( __FILE__ ) . '/bp-activity-subscription-main.php' );
}
add_action( 'bp_include', 'ass_loader' );
/**
* Textdomain loader.
*
* @since 2.5.3
*/
function activitysub_textdomain() {
load_plugin_textdomain( 'buddypress-group-email-subscription', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
add_action( 'plugins_loaded', 'activitysub_textdomain' );
/**
* Activation hook.
*
* @since 2.5.3
* @since 3.7.0 Renamed function to handle things other than digests.
*/
function activitysub_setup_defaults() {
// Digests.
require_once( dirname( __FILE__ ) . '/bp-activity-subscription-digest.php' );
ass_set_daily_digest_time( '05', '00' );
ass_set_weekly_digest_time( '4' );
// Run updater on activation.
ass_loader();
require_once( dirname( __FILE__ ) . '/admin.php' );
require_once( dirname( __FILE__ ) . '/updater.php' );
new GES_Updater( true );
}
register_activation_hook( __FILE__, 'activitysub_setup_defaults' );
/**
* Digest deactivation hook.
*
* @since 2.5.3
*/
function activitysub_unset_digests() {
wp_clear_scheduled_hook( 'ass_digest_event' );
wp_clear_scheduled_hook( 'ass_digest_event_weekly' );
}
register_deactivation_hook( __FILE__, 'activitysub_unset_digests' );