2

I´d like to override $title = get_bloginfo(); with --> $title = get_bloginfo('siteurl');

Some code from the plugin "Really simple Facebook Twitter share buttons":

function really_simple_share ($content, $filter, $link='', $title='', $author='') {
    static $last_execution = '';

    ...

    $custom_field_disable = get_post_custom_values('really_simple_share_disable');
    if ($custom_field_disable[0]=='yes' and $filter!='shortcode') {
        return $content;
    }

    //GET ARRAY OF STORED VALUES
    global $really_simple_share_option;
    $option = $really_simple_share_option;

    ...

    $first_shown = false; // NO PADDING FOR THE FIRST BUTTON

    // IF LINK AND TITLE ARE NOT SET, USE DEFAULT FUNCTIONS
    if ($link=='' and $title=='') {
        $link = ($option['use_shortlink']) ? wp_get_shortlink() : get_permalink();

        $title = get_bloginfo(); // OVERRIDE

        $author = get_the_author_meta('nickname');
    }

Can I do this in my functions.php because I´ll updating this plugin without changing this lines after every update.

Thanks

3
  • May I ask why you want the title to be the site URL? Commented Jul 10, 2012 at 13:04
  • @TheDeadMedic: I´ll use this custom title as description in a pinterest post. Commented Jul 10, 2012 at 13:37
  • 1
    Just checked out the full plugin source - can't see a reliable filter/action to depend on. I suggest you contact the author & encourage them to add plugin-specific hooks. Commented Jul 10, 2012 at 13:41

1 Answer 1

2

It is possible to filter the get_bloginfo(), but you'll have to find a way to fine tune the conditional, because the override is global...

add_filter( 'pre_option_blogname', 'wpse_58030_override_blogname' );

function wpse_58030_override_blogname( $bool )
{
    // If not page with ID == 28, do nothing
    if( !is_page( 28 )  ) 
        return false;
        
    // Change the 'blogname'
    return "Not The Blog Name";
}

enter image description here

Observation

get_bloginfo() is the same as get_bloginfo('blogname').

If the desired filter was siteurl, the filter would be pre_option_siteurl.

5
  • This works great. THANKS. I´d like to override: '$title = get_the_title();' with '$title = get_bloginfo('siteurl');' Does it work, too? Commented Jul 11, 2012 at 10:31
  • That depends on how the function really_simple_share is being called... Commented Jul 11, 2012 at 10:38
  • Thanks. I share the whole PHP-Script: dropbox.com/s/j4912qn8yhpxkmn/… // LINE 219 Commented Jul 11, 2012 at 11:07
  • Damn, that's an awesome filter I was never aware of. Thanks, @brasofilo! +1 Commented Oct 8, 2012 at 1:47
  • @JohannesPille : Hook Hunters is the name of the movie :) Commented Oct 18, 2012 at 4:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.