• Resolved cmarshall

    (@cmarshall)


    In the old WP, I could run it on a local server quite easily, as the server URI was consistent. However, WP 2+ now has a couple of new options that scrag that.

    I need to be able to intercept the bloginfo(‘home’) and bloginfo(‘siteurl’) to spit out a modified URI (I use a Mac with Parallels for testing, and the URI becomes a local IP). This also prevents me from just wholesale copying the WP databases for my local work.

    Adding a filter for bloginfo doesn’t work, as WP just goes and executes the regular one afterwards anyway, which makes a real mess.

    Even better, is there a way for my theme to intercept get_bloginfo()?

Viewing 7 replies - 1 through 7 (of 7 total)
  • <?php bloginfo('stylesheet_directoy'); ?> doesn’t work?

    Thread Starter cmarshall

    (@cmarshall)

    I’m not sure I understand.

    I need to intercept it so that the “native” WP code uses my reassignments.

    I don’t want to do any hacking at all in the native code (I could quite easily do it by messing with the main function). I want to overload the main function, so that it returns localized versions of the URI, if I am running it on my laptop (localhost) or I’m accessing the laptop version from a Parallels VM (10.211.50.2).

    I know that get_bloginfo(‘home’) and/or get_bloginfo(‘siteurl’) are called from within the code, because I see my pages getting really screwed up in the Location Bar, and everything goes pear-shaped.

    Are you using the ‘bloginfo_url’ filter?

    Blog Information and Option Filters

    Thread Starter cmarshall

    (@cmarshall)

    That looks like what I need. Let me experiment…

    Thanks!

    Thread Starter cmarshall

    (@cmarshall)

    option_home and option_siteurl give me what I need, but the E3Calendar plugin is doing some whacky stuff that I’ll have to dissect…

    Thread Starter cmarshall

    (@cmarshall)

    Okay, that went pear-shaped. WP completely ignores this:

    <?php
    /*
    Plugin Name: localhosts
    Plugin URI: https://sasna.org/
    Description: Makes things local, for testing.
    Version: 1.0
    */
    function GetMainURI( $ret )
        {
        if ( preg_match ( '|10\.211\.55\.2|', $_SERVER['REQUEST_URI'] ) )
            {
            $ret = "https://10.211.55.2/.../public_html/main";
            }
        elseif ( preg_match ( '|127\.0\.0\.1|', $_SERVER['REQUEST_URI'] ) || preg_match ( '|localhost|', $_SERVER['REQUEST_URI'] ) )
            {
            $ret = "https://localhost/.../public_html/main";
            }
        return $ret;
        }
    
    add_filter ( 'option_home', 'GetMainURI' );
    add_filter ( 'option_siteurl', 'GetMainURI' );
    ?>

    The plugin is installed and activated (I redacted the interiors of the URIs).

    Obviously, “add_filter(‘option_xxx” isn’t working. Either I misread the docs, or I’m just thick. I can’t find examples of this particular capability no matter how hard I Google…

    Thread Starter cmarshall

    (@cmarshall)

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Intercepting the New “home” and “siteurl” bloginfo’ is closed to new replies.