-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
indieweb.php
executable file
·199 lines (173 loc) · 5.42 KB
/
indieweb.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<?php
/*
* Plugin Name: IndieWeb
* Plugin URI: https://github.com/indieweb/wordpress-indieweb
* Description: Interested in connecting your WordPress site to the IndieWeb?
* Author: IndieWebCamp WordPress Outreach Club
* Author URI: https://indieweb.org/WordPress_Outreach_Club
* Version: 4.0.5
* License: MIT
* License URI: http://opensource.org/licenses/MIT
* Text Domain: indieweb
* Domain Path: /languages
*/
// initialize plugin
add_action( 'plugins_loaded', array( 'IndieWeb_Plugin', 'init' ) );
defined( 'INDIEWEB_ADD_HCARD_SUPPORT' ) || define( 'INDIEWEB_ADD_HCARD_SUPPORT', true );
defined( 'INDIEWEB_ADD_RELME_SUPPORT' ) || define( 'INDIEWEB_ADD_RELME_SUPPORT', true );
define( 'CNKT_INSTALLER_PATH', plugins_url( '/', __FILE__ ) );
/**
* IndieWeb Plugin Class
*
* @author Matthias Pfefferle
*/
class IndieWeb_Plugin {
public static $version;
/**
* Initialize the plugin, registering WordPress hooks.
*/
public static function init() {
self::$version = get_file_data( __FILE__, array( 'Version' => 'Version' ) )['Version'];
// enable translation
self::enable_translation();
require_once __DIR__ . '/includes/class-plugin-installer.php';
if ( INDIEWEB_ADD_HCARD_SUPPORT ) {
// Require H-Card Enhancements to User Profile
require_once __DIR__ . '/includes/class-relme-domain-icon-map.php';
require_once __DIR__ . '/includes/class-hcard-user.php';
require_once __DIR__ . '/includes/class-hcard-author-widget.php';
}
if ( INDIEWEB_ADD_RELME_SUPPORT ) {
// Require Rel Me Widget Class
require_once __DIR__ . '/includes/class-relme-widget.php';
}
add_action( 'wp_enqueue_scripts', array( 'IndieWeb_Plugin', 'enqueue_style' ) );
add_action( 'admin_enqueue_scripts', array( 'IndieWeb_Plugin', 'enqueue_admin_style' ) );
// Add General Settings Page
require_once __DIR__ . '/includes/class-general-settings.php';
// Add third party integrations
require_once __DIR__ . '/includes/class-integrations.php';
// add menu
add_action( 'admin_menu', array( 'IndieWeb_Plugin', 'add_menu_item' ), 9 );
// Privacy Declaration
add_action( 'admin_init', array( 'Indieweb_Plugin', 'privacy_declaration' ) );
// we're up and running
do_action( 'indieweb_loaded' );
}
/**
* Load translation files.
*
* A good reference on how to implement translation in WordPress:
* http://ottopress.com/2012/internationalization-youre-probably-doing-it-wrong/
*/
public static function enable_translation() {
// for plugins
load_plugin_textdomain(
'indieweb',
false,
dirname( plugin_basename( __FILE__ ) ) . '/languages/' // path
);
}
public static function enqueue_style() {
if ( '1' === get_option( 'iw_relme_bw' ) ) {
wp_enqueue_style( 'indieweb', plugins_url( 'static/css/indieweb-bw.css', __FILE__ ), array(), self::$version );
} else {
wp_enqueue_style( 'indieweb', plugins_url( 'static/css/indieweb.css', __FILE__ ), array(), self::$version );
}
}
public static function enqueue_admin_style() {
wp_enqueue_style( 'indieweb-admin', plugins_url( 'static/css/indieweb-admin.css', __FILE__ ), array(), self::$version );
}
/**
* Add Top Level Menu Item
*/
public static function add_menu_item() {
$options_page = add_menu_page(
'IndieWeb',
'IndieWeb',
'manage_options',
'indieweb',
array( 'IndieWeb_Plugin', 'getting_started' ),
plugins_url( 'static/img/indieweb.svg', __FILE__ )
);
add_submenu_page(
'indieweb',
__( 'Extensions', 'indieweb' ), // page title
__( 'Extensions', 'indieweb' ), // menu title
'manage_options', // access capability
'indieweb-installer',
array( 'IndieWeb_Plugin', 'plugin_installer' )
);
self::change_menu_title();
}
/**
* Changes the menu title
*/
public static function change_menu_title() {
global $submenu;
if ( isset( $submenu['indieweb'] ) && current_user_can( 'manage_options' ) ) {
// phpcs:ignore
$submenu['indieweb'][0][0] = __( 'Getting Started', 'indieweb' );
}
}
/**
* Callback from `add_plugins_page()` that shows the "Getting Started" page.
*/
public static function getting_started() {
require_once __DIR__ . '/includes/getting-started.php';
}
public static function plugin_installer() {
echo '<h1>' . esc_html__( 'IndieWeb Plugin Installer', 'indieweb' ) . '</h1>';
echo '<p>' . esc_html__( 'The below plugins are recommended to enable additional IndieWeb functionality.', 'indieweb' ) . '</p>';
if ( class_exists( 'IndieWeb_Plugin_Installer' ) ) {
IndieWeb_Plugin_Installer::init( self::register_plugins() );
}
}
/**
* Register the required plugins.
*
*
*/
public static function register_plugins() {
$plugin_array = array(
array(
'slug' => 'webmention',
),
array(
'slug' => 'micropub',
),
array(
'slug' => 'indieweb-post-kinds',
),
array(
'slug' => 'syndication-links',
),
array(
'slug' => 'indieauth',
),
array(
'slug' => 'simple-location',
),
array(
'slug' => 'pubsubhubbub',
),
array(
'slug' => 'indieblocks',
),
);
return $plugin_array;
}
public static function privacy_declaration() {
if ( function_exists( 'wp_add_privacy_policy_content' ) ) {
$content = __(
'Users can optionally add additional information to their profile. As this is part of your user profile you have control of this information and can remove
it at your discretion.',
'indieweb'
);
wp_add_privacy_policy_content(
'Indieweb',
wp_kses_post( wpautop( $content, false ) )
);
}
}
}