WordPress’teki Özellikleri Devre Dışı Bırakma

WordPress’te hazır gelen bazı özellikleri basit kodlarla devre dışı bırakabilirsiniz. Bu kodların tamamını tema klasörünüzdeki function.php dosyasının en altına yapıştırmanız yeterlidir. CSS ve JS dosyalarının Sonundaki Versiyonları Silme wp-embed Özelliği Devre Dışı Bırakma Gutenberg CSS …

WordPress’te hazır gelen bazı özellikleri basit kodlarla devre dışı bırakabilirsiniz.

Bu kodların tamamını tema klasörünüzdeki function.php dosyasının en altına yapıştırmanız yeterlidir.

CSS ve JS dosyalarının Sonundaki Versiyonları Silme

function remove_cssjs_ver( $src ) {
if( strpos( $src, '?ver=' ) )
	$src = remove_query_arg( 'ver', $src );
	return $src;
}
add_filter( 'style_loader_src', 'remove_cssjs_ver', 10, 2 );
add_filter( 'script_loader_src', 'remove_cssjs_ver', 10, 2 );

wp-embed Özelliği Devre Dışı Bırakma

function disable_embed(){
	wp_dequeue_script( 'wp-embed' );
}
add_action( 'wp_footer', 'disable_embed' );

Gutenberg CSS Dosyalarını Kaldırma

function smartwp_remove_wp_block_library_css(){
    wp_dequeue_style( 'wp-block-library' );
    wp_dequeue_style( 'wp-block-library-theme' );
    wp_dequeue_style( 'wc-block-style' );
} 
add_action( 'wp_enqueue_scripts', 'smartwp_remove_wp_block_library_css', 100 );

Pingback Özelliği Devre Dışı Bırakma

function disable_pingback( &$links ) {
	foreach ( $links as $l => $link )
	if ( 0 === strpos( $link, get_option( 'home' ) ) )
	unset($links[$l]);
}
add_action( 'pre_ping', 'disable_pingback' );

Heartbeat Özelliği Devre Dışı Bırakma

add_action( 'init', 'stop_heartbeat', 1 );
	function stop_heartbeat() {
	wp_deregister_script('heartbeat');
}

Dashicon CSS Dosyalarını Kaldırma

function wpdocs_dequeue_dashicon() {
        if (current_user_can( 'update_core' )) {
            return;
        }
        wp_deregister_style('dashicons');
}
add_action( 'wp_enqueue_scripts', 'wpdocs_dequeue_dashicon' );

WP REST API İsteklerini Devre Dışı Bırakın

add_filter( 'rest_authentication_errors', function( $result ) {
    if ( ! empty( $result ) ) {
        return $result;
    }
    if ( ! is_user_logged_in() ) {
        return new WP_Error( 'rest_not_logged_in', 'You are not currently logged in.', array( 'status' => 401 ) );
    }
    return $result;
});

REST API Kaldırma

remove_action('wp_head', 'rest_output_link_wp_head', 10);
remove_action('template_redirect', 'rest_output_link_header', 11, 0);

oEmbed Kaldırma

remove_action('wp_head', 'wp_oembed_add_discovery_links', 10);

RSD Link Kaldırma

remove_action( 'wp_head', 'rsd_link' );

Wordpress Emoji Özelliğini Kaldırma

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' );

Kısa Link Özelliğini Kaldırma

remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0);

WordPress Versiyonunu Gizleme

remove_action( 'wp_head', 'wp_generator' );

Wlwmanifest Link Kaldırma

remove_action( 'wp_head', 'wlwmanifest_link' );

Yoast SEO Search Etiketini Kaldırma

add_filter( 'disable_wpseo_json_ld_search', '__return_true' );

Yoast SEO Yorum Satırını Kaldırma

add_filter( 'wpseo_debug_markers', '__return_false' );

WordPress Pingback Kaldırma

function disable_pingback( &$links ) {
	foreach ( $links as $l => $link )
	if ( 0 === strpos( $link, get_option( 'home' ) ) )
	unset($links[$l]);
}
add_action( 'pre_ping', 'disable_pingback' );

Yönetim Paneli Kategorileri Gizleme

function alter_taxonomy_for_post() {
  unregister_taxonomy_for_object_type( 'category', 'post' );
}
add_action( 'init', 'alter_taxonomy_for_post' );

Yönetim Paneli Etiketleri Gizleme

add_action('init', function(){
    register_taxonomy('post_tag', []);
});

Dns-Prefetch Kaldırma

remove_action('wp_head', 'wp_resource_hints', 2);

Yorum Beslemesini (Feed) Kaldırma

remove_action( 'wp_head', 'feed_links', 2 ); 
add_action('wp_head', 'addBackPostFeed');
function addBackPostFeed() {
    echo '<link rel="alternate" type="application/rss+xml" title="RSS 2.0 Feed" href="'.get_bloginfo('rss2_url').'" />'; 
}