• In before anyone “in before”‘s, I know I can hook the individual actions within wp_head and prefix them, I’m more checking if there was a way to do it by default to _anything_ placed in wp_head’s action queue.

    Ok so the issue is that I’m pedantic when it comes to code formatting. My code is structured as it should be, but when I examine the code (yes yes, nobody looks there, but as I said.. I care :D), wp_head dumps all the action outputs like this:

    <head profile="https://gmpg.org/xfn/11">
    		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    		<title>TITLE</title>
    		<link rel="stylesheet" href="THEME_CSS" type="text/css" media="screen" />
    		<link rel="alternate" type="application/rss+xml" title="TITLE RSS Feed" href="URL_FEED" />
    		<link rel="pingback" href="URL_XMLRPC" />
    <link rel="index" title="TITLE" href="URL" />
    <meta name="generator" content="Wordpress 3.0" />
    <script type="text/javascript" src="CUSTOM_ACTION_JS"></script>
    	</head>

    Ignore the uppercase words, they are nothing more than me blanking out the domain etc with something useful.

    So the main question is, is it possible to prefix all actions within wp_head with (in my case) double tab, without having to do each line individually?

    As I said before, got no issue filtering each action individually, just checking if there was an easier way that I’ve been unable to see.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Kysol

    (@kysol)

    Actually figured it out…

    add_filter( 'index_rel_link',				'wp_filter_add_tabs' );
    	add_filter( 'parent_post_rel_link',		'wp_filter_add_tabs' );
    	add_filter( 'start_post_rel_link',		'wp_filter_add_tabs' );
    	add_filter( 'previous_post_rel_link',	'wp_filter_add_tabs' );
    	add_filter( 'next_post_rel_link',		'wp_filter_add_tabs' );
    	add_filter( 'the_generator',				'wp_filter_add_tabs' );
    
    	add_filter( 'the_generator',				'wp_filter_the_generator' );
    
    	remove_action( 'wp_head', 'rsd_link' );
    	remove_action( 'wp_head', 'wlwmanifest_link' );
    
    	function wp_filter_the_generator( $data )
    	{
    		return preg_replace( '/WordPress ([0-9.]+)/', 'WordPress', $data );
    	}
    
    	function wp_filter_add_tabs( $data )
    	{
    		return "\t\t" . $data;
    	}

    Only issue I’m getting now is the inability to hook rel_canonical :/

    So funny, I thought I was the only one searching for tab-indenting auto-generated wp_head and sure enough, you’ve tried to do it!

    Have you found an easier way since? This is yet more actions on actions happening (pre-processing=slow) before I get my content out!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘formatting output of wp_head’ is closed to new replies.