Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

while there are plenty of social sharing / email a friend type of plugins i am looking for one that will let me place it on only 1 page and most importantly allow me to specify which URL (not necessarily the URL of the page the form/buttons are on) I would like to recommend.

to explain: the site i am working on is selling an online course. when purchased, the thank you page will have an option to tell your friends about the course. so i don't want to share this "thank you page" i would like the user to share the home/sales page.

is there a plugin that does this or do i have to roll my own? and if the latter, where should i start?

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

I would recommend rolling your own. Use the sharethis api or addthis. Then you can use get_permalink(); for the url parameter.

function wpu_share() {
        $url = get_permalink();
        $title = get_the_title();
        $add_this = 'st_url="'.esc_url( $url ).'"'; ?>

    <span class='st_facebook_large' <?php echo $add_this; ?> displayText='Facebook'></span>
    <span class='st_twitter_large' <?php echo $add_this; ?>  displayText='Tweet'></span>
    <span class='st_linkedin_large' <?php echo $add_this; ?> displayText='LinkedIn'></span>
    <span class='st_email_large' <?php echo $add_this; ?> displayText='Email'></span>
    <?php }

 add_action('wp_footer', 'wpu_share_js' );
 function wpu_share_js() { ?>
        <script type="text/javascript">var switchTo5x = true;</script>
        <script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
       <script type="text/javascript">stLight.options({publisher:"ur-xxxxxxxxxxxx"}); </script>
<? }

Update

You will need to pass a variable to the thank you page that references the post id of the course they signed up for then you can use this to get the right url.

$url = get_permalink( $post_id );  

// You will need to pass the post id to the thank you page using a query string or another method.

To use a query string append ?id=$post->ID to the end of the redirect to the thank you page. Then on the thank you page:

if (isset( $_GET['id'] ) $post_id = (int) $_GET['id'];

For security make sure you use esc_url() where ever you are using the $url variable.

share|improve this answer
    
i don't actually want to use get_permalink()... that's what all the plugins already do. but you are right, i don't think there's anyway around adding my own. thanks! –  helgatheviking Jun 26 '12 at 15:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.