WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Google +1 Button - Advanced Plugin, Includes Redirection
[resolved] php code to insert into (10 posts)

  1. elementel
    Member
    Posted 2 years ago #

    I'd like to have even more control of where this code appears on my client's site. Shortcode is great but that would require my client to always put the shortcode in at the beginning of every post.

    What is the code I would use to insert this into the single.php file?

    In other words, is there something like a "if function exists" kind of code I can copy and paste in place? I have done this with a number of plugins like pixopoint menus etc.

    Any help at all would be greatly appreciated!

    http://wordpress.org/extend/plugins/wp-plus-one/

  2. Jacob Gillespie
    Member
    Plugin Author

    Posted 2 years ago #

    I actually don't have shortcode support added yet, so it's good you need the PHP version. :)

    The code you need is:

    <?php do_action( 'wp_plus_one_button', $url, $style, $css, $count, $redirect); ?>

    You don't need any if function exists stuff since this is a WordPress action. The $url param is self-explanatory. The rest are as follows:

    • $style - button style (standard / small / medium / tall)
    • $css - custom css
    • $count - show the +1 count (true/false)
    • $redirect - a url to redirect to if the user clicks the +1 button

    These docs are on the plugin settings page as well.

    Let me know if that answers your question.

    Thanks!

  3. elementel
    Member
    Posted 2 years ago #

    so just to be sure, so I understand the $style etc. Can you make an example of that code with the $count set to true so I can see what the syntax looks like?

    thanks so much!

  4. Jacob Gillespie
    Member
    Plugin Author

    Posted 2 years ago #

    For example

    <?php do_action( 'wp_plus_one_button', 'http://google.com', 'tall', 'padding:10px;border: 1px solid black;'); ?>

    $count by default is true
    $redirect by default is blank

  5. elementel
    Member
    Posted 2 years ago #

    Jacob, you're a gentleman and a scholar. Do you have a donate link? I believe in paying forward.

  6. elementel
    Member
    Posted 2 years ago #

    well hold the phone. I added your example to the single.php file and it's not appearing.

    link here

    I'm trying to force the +1 button to sit above the facebook like button because when people I know "like" the page, their avatars block the google +1 button if it's sitting below the facebook like.

    So I added your sample code just right after the date code and before the content code. Nothing appears.

  7. Jacob Gillespie
    Member
    Plugin Author

    Posted 2 years ago #

    Can you post the contents of the single.php file to pastebin.com?

    Thanks!

  8. elementel
    Member
    Posted 2 years ago #

  9. Jacob Gillespie
    Member
    Plugin Author

    Posted 2 years ago #

    That's really strange - it should be displaying...

    I'll do some more digging, and if you want to email temporary admin account information to me@jacobwg.com, I'd be happy to take a look. It looks like the theme you are using is a premium iThemes theme, so I am not able to easily test the theme code locally.

  10. Jacob Gillespie
    Member
    Plugin Author

    Posted 2 years ago #

    For those of you other than elementel reading this thread, we communicated via email and discovered that he was in fact running a different +1 button plugin and once we switched to this one, the PHP action code worked.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic