forked from jeherve/vk-sharing-jetpack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
msteams-sharing-jetpack.php
58 lines (50 loc) · 1.64 KB
/
msteams-sharing-jetpack.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
<?php
/*
* Plugin Name: Microsoft Teams Sharing for Jetpack
* Plugin URI: https://dev.commons.hwdsb.on.ca
* Description: Add a Microsoft Teams button to the Jetpack Sharing module
* Author: mrjarbenne
* Version: 1.0
* Author URI: https://mrjarbenne.ca
* License: GPL2+
* Text Domain: mstjp
*/
class MSTeams_Button {
private static $instance;
static function get_instance() {
if ( ! self::$instance )
self::$instance = new MSTeams_Button;
return self::$instance;
}
private function __construct() {
// Check if Jetpack and the sharing module is active
if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'sharedaddy' ) ) {
add_action( 'plugins_loaded', array( $this, 'setup' ) );
} else {
add_action( 'admin_notices', array( $this, 'install_jetpack' ) );
}
}
public function setup() {
add_filter( 'sharing_services', array( $this, 'inject_service' ) );
}
// Add the Microsoft Teams Button to the list of services in Sharedaddy
public function inject_service ( $services ) {
include_once 'class.teams-sharing-jetpack.php';
if ( class_exists( 'Share_MSTeams' ) ) {
$services['msteams'] = 'Share_MSTeams';
}
return $services;
}
// Prompt to install Jetpack
public function install_jetpack() {
echo '<div class="error"><p>';
printf(__( 'To use the Microsoft Teams Sharing plugin, you\'ll need to install and activate <a href="%1$s">Jetpack</a> first, and <a href="%2$s">activate the Sharing module</a>.'),
'plugin-install.php?tab=search&s=jetpack&plugin-search-input=Search+Plugins',
'admin.php?page=jetpack_modules',
'mstjp'
);
echo '</p></div>';
}
}
// And boom.
MSTeams_Button::get_instance();