WordPress – Praktisches für die functions.php

…um nicht immer danach suchen zu müssen:

// Deaktiviert die E-Mail-Benachrichtigung nach automatischen Plugin-Updates.
add_filter( 'auto_plugin_update_send_email', '__return_false' );
 
// Deaktiviert die E-Mail-Benachrichtigung nach automatischen Theme-Updates.
add_filter( 'auto_theme_update_send_email', '__return_false' );

// Login-Logo ersetzen
add_filter( 'login_headerurl', function() {
    return site_url();
} );
    
add_filter('login_headertitle', function() {
    return get_bloginfo( 'name' );
} );


// Adds webp filetype to allowed mimes
add_filter( 'upload_mimes', 'wpse_mime_types_webp' );
function wpse_mime_types_webp( $mimes ) {
    $mimes['webp'] = 'image/webp';
  return $mimes;
}

//SECURITY ZEUGS Start

function remove_version() {
  return '';}
add_filter('the_generator', 'remove_version');

remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'rsd_link');
add_filter('xmlrpc_enabled', '__return_false');
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, 0);
header('X-Content-Type-Options: nosniff');
header('X-Frame-Options: SAMEORIGIN');
header('X-XSS-Protection: 1; mode=block');
header('Strict-Transport-Security: max-age=31536000;');
header('Referrer-Policy: same-origin');
//SECURITY ZEUGS Ende

// SEITEN VON DER WORDPRESS-SUCHE AUSSCHLIESSEN 
function js_search_filter( $query ) {
  if ( $query->is_search ) { 
      $query->set('post__not_in', array(XXXXX) ); //XXXXX = ID  
    }
  return $query;
}
add_action( 'pre_get_posts', 'js_search_filter' );