PHP
<?php
function fastpage_enqueue_styles() {
wp_enqueue_style(
'fastpage',
get_stylesheet_uri()
);
}
add_action( 'wp_enqueue_scripts', 'fastpage_enqueue_styles' );
add_action('wp_enqueue_scripts', function () {
wp_enqueue_script(
'fastpage-scripts',
get_template_directory_uri() . '/assets/js/scripts.js',
[],
wp_get_theme()->get('Version'),
true
);
});
// -----------------------------------------------------------------------------------------------
// BLOCK EDITOR ANPASSUNGEN
// -----------------------------------------------------------------------------------------------
// Alle Core-Patterns entfernen
add_action('init', function() {
remove_theme_support('core-block-patterns');
$patterns = [
'core/query-standard-posts',
'core/query-medium-posts',
'core/query-small-posts',
'core/query-grid-posts',
'core/query-large-title-posts',
'core/query-offset-posts',
];
array_walk($patterns, 'unregister_block_pattern');
}, 15);
// Core Pattern Kategorien entfernen
add_action('init', function() {
$categories = [
'featured', 'about', 'audio', 'banner', 'buttons',
'call-to-action', 'columns', 'contact', 'footer',
'gallery', 'header', 'media', 'portfolio', 'posts',
'query', 'services', 'team', 'testimonials', 'text', 'videos',
];
array_walk($categories, 'unregister_block_pattern_category');
});
// Eigene Pattern Kategorien erstellen
add_action('init', function() {
$categories = [
'hero' => 'Hero',
'vorteile' => 'Vorteile',
'cta' => 'CTA',
'kontakt' => 'Kontakt',
];
foreach ($categories as $slug => $label) {
register_block_pattern_category($slug, ['label' => $label]);
}
});
// OpenVerse Inserter deaktiviren
add_filter('block_editor_settings_all', function($settings) {
$settings['enableOpenverseMediaCategory'] = false;
return $settings;
});
// Block-Verzeichnis deaktivieren
remove_action('enqueue_block_editor_assets', 'wp_enqueue_editor_block_directory_assets');
// Den Willkommens-Guide beim Laden des Editors automatisch schließen
add_filter('default_hidden_meta_boxes', function($hidden) {
$hidden[] = 'editor-welcome-guide';
return $hidden;
});
// -----------------------------------------------------------------------------------------------
// BACKEND ANPASSUNGEN
// -----------------------------------------------------------------------------------------------
// Update Benachrichtigung für Nicht Administratoren verbergen
add_action('admin_notices', function() {
if (!current_user_can('update_core')) {
remove_action('admin_notices', 'update_nag', 3);
}
});
// Zusatz-Inhalte bei Core-Upgrades installieren
add_filter('install_default_theme', '__return_false');
// Revisionen beschränken
add_filter('wp_revisions_to_keep', fn($num) => 5);
// Papierkorb wöchentlich leeren
add_filter('empty_trash_days', fn() => 7);
// Anwendungspasswörter nur für Administratoren
add_filter('wp_is_application_passwords_available_for_user', function($available, $user) {
return user_can($user, 'manage_options');
}, 10, 2);
// Admin Mail Check alle 6 Monate deaktivieren
add_filter('admin_email_check_interval', '__return_false');
// XML-RPC API-Endpunkt deaktivieren
add_filter('xmlrpc_enabled', '__return_false');
// Adminleiste säubern
add_action('wp_before_admin_bar_render', function() {
global $wp_admin_bar;
$wp_admin_bar->remove_node('wp-logo');
$wp_admin_bar->remove_node('comments');
$wp_admin_bar->remove_node('rank-math');
});
// Footer-Text im Admin-Bereich entfernen
add_filter('admin_footer_text', '__return_empty_string');
// -----------------------------------------------------------------------------------------------
// FRONTEND HEADER ANPASSUNGEN
// -----------------------------------------------------------------------------------------------
// Entfernt CSS Variablen aus :root, wenn Settings in theme.json auf false gesetzt wurden
add_filter( 'wp_theme_json_data_theme', function ( \WP_Theme_JSON_Data $theme_json ): \WP_Theme_JSON_Data {
$data = $theme_json->get_data();
$color = &$data['settings']['color'];
if ( $color['defaultDuotone'] === false ) {
$color['duotone']['default'] = array();
}
if ( $color['defaultGradients'] === false ) {
$color['gradients']['default'] = array();
}
if ( $color['defaultPalette'] === false ) {
$color['palette']['default'] = array();
}
$dimensions = &$data['settings']['dimensions'];
if ( $dimensions['defaultAspectRatios'] === false ) {
$dimensions['aspectRatios']['default'] = array();
}
$shadow = &$data['settings']['shadow'];
if ( $shadow['defaultPresets'] === false ) {
$shadow['presets']['default'] = array();
}
$spacing = &$data['settings']['spacing'];
if ( $spacing['defaultSpacingSizes'] === false ) {
$spacing['spacingSizes']['default'] = array();
}
$typography = &$data['settings']['typography'];
if ( $typography['defaultFontSizes'] === false ) {
$typography['fontSizes']['default'] = array();
}
$theme_json->update_with( $data );
return $theme_json;
} );
// REST-API Discovery Link entfernen
remove_action('wp_head', 'rest_output_link_wp_head');
remove_action('template_redirect', 'rest_output_link_header', 11);
// Skip Link CSS entfernen - ACHTUNG, setze das selbst in style.css
add_action('wp_enqueue_scripts', function() {
wp_dequeue_style('wp-block-template-skip-link');
}, 20);
// Entfernt WP img autosizes inline css
// CSS verhindert Layout Shifts bei native core Lazy Loading
add_action('wp_enqueue_scripts', function() {
wp_dequeue_style('wp-img-auto-sizes-contain');
}, 20);
// WordPress Generator meta entfernen
remove_action('wp_head', 'wp_generator');
// WLW Manifest entfernen
remove_action('wp_head', 'wlwmanifest_link');
// RSD-Link entfernen
remove_action('wp_head', 'rsd_link');
// Kurzlink entfernen
remove_action('wp_head', 'wp_shortlink_wp_head');
// Feed-Generator entfernen
add_filter('the_generator', '__return_empty_string');
// DNS-Prefetch entfernen
remove_action('wp_head', 'wp_resource_hints', 2);
// jQuery Migrate entfernen
add_action('wp_default_scripts', function($scripts) {
if (!is_admin()) {
$scripts->remove('jquery');
$scripts->add('jquery', false, ['jquery-core'], '1');
}
});
// Emojis entfernen
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_filter('the_content_feed', 'wp_staticize_emoji');
remove_filter('comment_text_rss', 'wp_staticize_emoji');
remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
add_filter('tiny_mce_plugins', fn($plugins) => array_diff($plugins, ['wpemoji']));
add_filter('wp_resource_hints', fn($urls, $relation_type) =>
$relation_type === 'dns-prefetch' ? array_filter($urls, fn($url) => !str_contains($url, 'fonts.googleapis.com')) : $urls
, 10, 2);
// Versionsparameter von Stil- und Skript-Links entfernen
add_filter('style_loader_src', fn($src) => remove_query_arg('ver', $src));
add_filter('script_loader_src', fn($src) => remove_query_arg('ver', $src));
// Kommentare komplett deaktivieren
add_action('admin_init', function () {
// Kommentarseite umleiten
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_safe_redirect(admin_url());
exit;
}
// Kommentar-Metabox im Dashboard entfernen
remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');
// Kommentare und Trackbacks für alle Post-Types deaktivieren
foreach (get_post_types() as $post_type) {
if (post_type_supports($post_type, 'comments')) {
remove_post_type_support($post_type, 'comments');
remove_post_type_support($post_type, 'trackbacks');
}
}
});
// Kommentare und Pings im Frontend schliessen
add_filter('comments_open', '__return_false', 20, 2);
add_filter('pings_open', '__return_false', 20, 2);
// Bestehende Kommentare ausblenden
add_filter('comments_array', '__return_empty_array', 10, 2);
// Kommentarseite aus dem Admin-Menü entfernen
add_action('admin_menu', function () {
remove_menu_page('edit-comments.php');
});
// Kommentar-Link aus der Admin-Leiste entfernen
add_action('init', function () {
if (is_admin_bar_showing()) {
remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
}
});
// Standard Favicon entfernen - selbst eines setzen geht
add_filter('get_site_icon_url', '__return_empty_string');
// Heartbeat Intervall auf zwei Minuten anpassen
add_filter('heartbeat_settings', function($settings) {
$settings['interval'] = 120;
return $settings;
});
// PLUGIN RNKMATH SETTINGS
// Whitelabel: Hinweise aus <head> und Admin-Footer entfernen
add_filter('rank_math/whitelabel', '__return_true');
// Sitemap-Erwähnung entfernen
add_filter('rank_math/sitemap/remove_credit', '__return_true');
// Link-Klasse im Frontend entfernen
add_filter('rank_math/link/remove_class', '__return_true');
// Rank Math CSS in Frontend deaktivieren
add_action('wp_enqueue_scripts', function() {
wp_dequeue_style('rank-math-css');
}, 20);