<commit_before><?php

add_filter('sanitize_file_name', 'remove_accents');

remove_action('do_feed_rdf', 'do_feed_rdf' , 10, 1);
remove_action('do_feed_rss', 'do_feed_rss' , 10, 1);
remove_action('do_feed_rss2', 'do_feed_rss2', 10, 1);
remove_action('do_feed_atom', 'do_feed_atom', 10, 1);
remove_action('template_redirect', 'redirect_canonical');<commit_msg>Disable Rest API and XMLRPC<commit_after><?php

add_filter('sanitize_file_name', 'remove_accents');

remove_action('do_feed_rdf', 'do_feed_rdf' , 10, 1);
remove_action('do_feed_rss', 'do_feed_rss' , 10, 1);
remove_action('do_feed_rss2', 'do_feed_rss2', 10, 1);
remove_action('do_feed_atom', 'do_feed_atom', 10, 1);
remove_action('template_redirect', 'redirect_canonical');

// Disable REST API

remove_action('init', 'rest_api_init');
remove_action('parse_request', 'rest_api_loaded');

remove_action( 'xmlrpc_rsd_apis', 'rest_output_rsd');
remove_action( 'wp_head', 'rest_output_link_wp_head');
remove_action( 'template_redirect', 'rest_output_link_header', 11);
remove_action( 'auth_cookie_malformed', 'rest_cookie_collect_status');
remove_action( 'auth_cookie_expired', 'rest_cookie_collect_status');
remove_action( 'auth_cookie_bad_username', 'rest_cookie_collect_status');
remove_action( 'auth_cookie_bad_hash', 'rest_cookie_collect_status');
remove_action( 'auth_cookie_valid', 'rest_cookie_collect_status');

add_filter('rest_enabled', '__return_false');
add_filter('rest_jsonp_enabled', '__return_false');

// Disable WMLRPC

function secure_API( $access ) {
  if( ! is_user_logged_in() ) {
    return new WP_Error( 'rest_cannot_access', __( 'Accès réservé aux personnes authentifiées', 'disable-json-api' ), array( 'status' => rest_authorization_required_code() ) );
  }

  return $access;
}
add_filter('rest_authentication_errors', 'secure_API');
{'fraction_non_alphanumeric': 0.14829106945975745, 'fraction_numerical': 0.016538037486218304, 'mean_word_length': 11.1, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6578803', 'n_tokens_mistral': 677, 'n_tokens_neox': 651, 'n_words': 105}