Skip to content

Commit 8b539b3

Browse files
committed
Compatibilité WordPress 5.0 et PHP 7.2
1 parent 24760ad commit 8b539b3

7 files changed

+40
-47
lines changed

disable-feed-comments.php

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
defined('ABSPATH') or die();
3+
4+
/*
5+
MU Plugin: disable-feed-comments
6+
Description: Disable feed comments - RSS, Atom...
7+
Author: Yann Kozon
8+
Author URI: https://www.yannkozon.com
9+
*/
10+
11+
function mu_disable_feed_comments() {
12+
wp_redirect( esc_url( home_url( '/' ) ), 301 );
13+
die();
14+
}
15+
add_action( 'do_feed_rss2_comments', 'mu_disable_feed_comments' );
16+
add_action( 'do_feed_atom_comments', 'mu_disable_feed_comments' );

disable-feed.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,4 @@ function mu_disable_feed() {
1616
add_action( 'do_feed_rdf', 'mu_disable_feed' );
1717
add_action( 'do_feed_rss', 'mu_disable_feed' );
1818
add_action( 'do_feed_rss2', 'mu_disable_feed' );
19-
add_action( 'do_feed_atom', 'mu_disable_feed' );
20-
add_action( 'do_feed_rss2_comments', 'mu_disable_feed' );
21-
add_action( 'do_feed_atom_comments', 'mu_disable_feed' );
19+
add_action( 'do_feed_atom', 'mu_disable_feed' );

disable-rest-api.php

+16-14
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,23 @@
88
Author URI: https://www.yannkozon.com
99
*/
1010

11-
function mu_disable_rest_api( ) {
12-
remove_action( 'init', 'rest_api_init' );
13-
remove_action( 'parse_request', 'rest_api_loaded' );
11+
function mu_disable_rest_api() {
12+
if( ! is_user_logged_in() ) {
13+
remove_action( 'init', 'rest_api_init' );
14+
remove_action( 'parse_request', 'rest_api_loaded' );
1415

15-
remove_action( 'xmlrpc_rsd_apis', 'rest_output_rsd' );
16-
remove_action( 'wp_head', 'rest_output_link_wp_head' );
17-
remove_action( 'template_redirect', 'rest_output_link_header', 11 );
18-
remove_action( 'auth_cookie_malformed', 'rest_cookie_collect_status' );
19-
remove_action( 'auth_cookie_expired', 'rest_cookie_collect_status' );
20-
remove_action( 'auth_cookie_bad_username', 'rest_cookie_collect_status' );
21-
remove_action( 'auth_cookie_bad_hash', 'rest_cookie_collect_status' );
22-
remove_action( 'auth_cookie_valid', 'rest_cookie_collect_status' );
16+
remove_action( 'xmlrpc_rsd_apis', 'rest_output_rsd' );
17+
remove_action( 'wp_head', 'rest_output_link_wp_head' );
18+
remove_action( 'template_redirect', 'rest_output_link_header', 11 );
19+
remove_action( 'auth_cookie_malformed', 'rest_cookie_collect_status' );
20+
remove_action( 'auth_cookie_expired', 'rest_cookie_collect_status' );
21+
remove_action( 'auth_cookie_bad_username', 'rest_cookie_collect_status' );
22+
remove_action( 'auth_cookie_bad_hash', 'rest_cookie_collect_status' );
23+
remove_action( 'auth_cookie_valid', 'rest_cookie_collect_status' );
2324

24-
add_filter( 'rest_enabled', '__return_false' );
25-
add_filter( 'rest_jsonp_enabled', '__return_false' );
25+
add_filter( 'rest_enabled', '__return_false' );
26+
add_filter( 'rest_jsonp_enabled', '__return_false' );
27+
}
2628
}
2729

28-
mu_disable_rest_api();
30+
add_action( 'init', 'mu_disable_rest_api' );

remove-login-error.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
Author URI: https://www.yannkozon.com
99
*/
1010

11-
add_filter( 'login_errors', create_function( '$a', "return null;" ) );
11+
add_filter( 'login_errors', '__return_null' );

remove-recaptcha-frontend-itsec.php

-17
This file was deleted.

remove-wp-embed.php

+5-7
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@
88
Author URI: https://www.yannkozon.com
99
*/
1010

11-
remove_action( 'wp_head', 'rest_output_link_wp_head' );
12-
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
13-
remove_action( 'template_redirect', 'rest_output_link_header', 11, 0 );
14-
1511
function mu_remove_wp_embed() {
16-
wp_deregister_script( 'wp-embed.min.js' );
17-
wp_deregister_script( 'wp-embed' );
18-
wp_deregister_script( 'embed' );
12+
if( ! is_admin() ) {
13+
wp_deregister_script( 'wp-embed.min.js' );
14+
wp_deregister_script( 'wp-embed' );
15+
wp_deregister_script( 'embed' );
16+
}
1917
}
2018
add_action( 'init', 'mu_remove_wp_embed', 9999 );

remove-wp-version.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,4 @@
99
*/
1010

1111
remove_action( 'wp_head', 'wp_generator' );
12-
13-
function mu_remove_wp_version() {
14-
return '';
15-
}
16-
add_filter( 'the_generator', 'mu_remove_wp_version' );
12+
add_filter( 'the_generator', '__return_empty_string' );

0 commit comments

Comments
 (0)