forked from Log1x/plugin-meta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin.php
290 lines (262 loc) · 8.12 KB
/
plugin.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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
<?php
/**
* Plugin Name: Plugin Meta
* Plugin URI: https://github.com/log1x/plugin-meta
* Description: A simple meta package for my commonly used WordPress plugins
* Version: 1.2.4
* Author: Brandon Nifong
* Author URI: https://github.com/log1x
* Licence: MIT
*/
add_action('plugins_loaded', new class
{
/**
* Invoke the plugin.
*
* @return void
*/
public function __invoke()
{
/**
* Disable unnecessary ACF Extended modules.
*
* @return boolean
*/
foreach([
'acf/settings/acfe/modules/dynamic_post_types',
'acf/settings/acfe/modules/dynamic_taxonomies',
'acf/settings/acfe/modules/dynamic_forms',
'acf/settings/acfe/modules/dynamic_options_pages',
'acf/settings/acfe/modules/dynamic_block_types',
'acf/settings/acfe/modules/author',
'acf/settings/acfe/modules/categories',
'acf/settings/acfe/modules/taxonomies',
'acf/settings/acfe/modules/options',
'acf/settings/acfe/modules/single_meta',
] as $hook) {
add_filter($hook, '__return_false');
};
/**
* Enable good ACF Extended modules.
*
* @return bool
*/
foreach([
'acf/settings/acfe/modules/ui',
'acf/settings/acfe/modules/multilang',
] as $hook) {
add_filter($hook, '__return_true');
};
/**
* Remove the EditorsKit and CoBlocks getting started screens.
*
* @return bool
*/
foreach(['blockopts_welcome_cap', 'coblocks_getting_started_screen_capability'] as $filter) {
add_filter($hook, '__return_false');
}
/**
* Remove the UpdraftPlus admin bar item.
*
* @return void
*/
add_filter('init', function () {
if (defined('UPDRAFTPLUS_ADMINBAR_DISABLE')) {
return;
}
define('UPDRAFTPLUS_ADMINBAR_DISABLE', true);
});
/**
* Fix the role capability for Better Search Replace.
*
* @return string
*/
add_filter('bsr_capability', function () {
return 'manage_options';
});
/**
* Remove metaboxes created by Related Posts for WordPress.
*
* @return void
*/
add_filter('do_meta_boxes', function () {
remove_meta_box('rp4wp_metabox_related_posts', get_post_types(), 'normal');
remove_meta_box('rp4wp_metabox_exclude_post', get_post_types(), 'side');
});
/**
* Disable unwanted default functionality of Related Posts for WordPress.
*
* @return void
*/
add_filter('rp4wp_append_content', '__return_false');
add_filter('rp4wp_disable_css', '__return_true');
/**
* Remove metaboxes created by Pretty Links.
*
* @return void
*/
add_filter('wp_dashboard_setup', function () {
remove_meta_box('prli_dashboard_widget', 'dashboard', 'normal');
remove_meta_box('prli_dashboard_widget', 'dashboard', 'side');
});
/**
* Change the WordPress login header to the blog name
*
* @return string
*/
add_filter('login_headertext', function () {
return get_bloginfo('name');
});
/**
* Change the WordPress login header URL to the home URL
*
* @return string
*/
add_filter('login_headerurl', function () {
return get_home_url();
});
/**
* Process shortcodes inside of titles, descriptions, and open graph data.
*
* @return string
*/
foreach([
'the_title',
'get_the_title',
'wpseo_title',
'wpseo_metadesc',
'wpseo_opengraph_title',
'wpseo_opengraph_desc',
'wpseo_opengraph_site_name',
'wpseo_twitter_title',
'wpseo_twitter_description'
] as $hook) {
add_filter($hook, 'do_shortcode');
}
/**
* Process shortcodes inside of WordPress SEO's schema.
*
* @param string[] $data
* @return string[]
*/
foreach(['wpseo_schema_webpage', 'wpseo_schema_article'] as $hook) {
add_filter($hook, function ($data) {
return array_map(function ($item) {
return is_string($item) ? do_shortcode($item) : $item;
}, $data);
});
}
/**
* Hide version on WordPress SEO's HTML output.
*
* @return bool
*/
add_filter('wpseo_hide_version', '__return_true');
/**
* Remove the WP Rocket option metabox.
*
* @return void
*/
add_filter('admin_init', function () {
remove_filter('add_meta_boxes', 'rocket_cache_options_meta_boxes');
});
/**
* Remove Find My Blocks' reusable blocks admin menu hook.
*
* @return void
*/
remove_filter('admin_menu', 'find_my_blocks_add_reusable_to_admin_menu');
/**
* Disable the widget block editor.
*
* @return bool
*/
add_filter('gutenberg_use_widgets_block_editor', '__return_false');
/**
* Deregister useless plugin widgets.
*
* @return void
*/
add_filter('widgets_init', function () {
foreach([
'Su_Widget',
'RP4WP_Related_Posts_Widget'
] as $widget) {
unregister_widget($widget);
}
});
/**
* Remove failed login logging from Simple History.
*
* @param bool $logged
* @param string $slug
* @param string $key
* @param int $level
* @param string $context
* @return bool
*/
add_filter('simple_history/simple_logger/log_message_key', function ($logged, $slug, $key, $level, $context) {
if ($this->contains($slug, 'SimpleUserLogger') && $this->contains($key, ['user_login_failed', 'user_unknown_login_failed'])) {
return false;
}
return $logged;
}, 10, 5);
/**
* Remove the post actions created by Page Generator Pro.
*
* @param array $actions
* @return array
*/
foreach([
'post_row_actions',
'page_row_actions',
] as $hook) {
add_filter($hook, function ($actions) {
if (! empty($actions['page_generator_pro_import'])) {
unset($actions['page_generator_pro_import']);
}
return $actions;
}, 100);
}
/**
* Disable RankMath's whitelabeling.
*
* @return bool
*/
foreach([
'rank_math/whitelabel',
'rank_math/link/remove_class',
'rank_math/sitemap/remove_credit',
'rank_math/frontend/remove_credit_notice',
] as $hook) {
add_filter($hook, '__return_true');
}
/**
* Register the defined Google Maps API key with ACF.
*
* @return void
*/
add_filter('acf/init', function () {
if (! defined('GOOGLE_MAPS_API_KEY') || ! function_exists('acf_update_setting')) {
return;
}
acf_update_setting('google_api_key', GOOGLE_MAPS_API_KEY);
});
}
/**
* Determine if a given string contains a given substring.
*
* @param string $haystack
* @param string|string[] $needles
* @return bool
*/
public function contains($haystack, $needles)
{
foreach ((array) $needles as $needle) {
if ($needle !== '' && mb_strpos($haystack, $needle) !== false) {
return true;
}
}
return false;
}
});