Skip to content

Instantly share code, notes, and snippets.

@darrenmeehan
Created August 5, 2012 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darrenmeehan/3266387 to your computer and use it in GitHub Desktop.
Save darrenmeehan/3266387 to your computer and use it in GitHub Desktop.
This is a simple WordPress shortcode to add a Paypal button
<?php
/*
Plugin Name: PayPal Shortcode by Darren
Plugin URI: https://gist.github.com/3266387
Description: This is a simple shortcode to add a Paypal button, just use [paypal] as the shortcode.
Version: 0.1
Author:
Author URI:
License:
License URI:
*/
function dm_paypal_function () {
$productid = get_the_title();
$price = get_post_custom_values('item_price');
echo print_wp_cart_button_for_product("$productid", "$price[0]");
}
add_shortcode('paypal', 'dm_paypal_function');
Copy link

ghost commented Aug 5, 2012

it can be:

echo print_wp_cart_button_for_product($productid, $price[0]);

or

echo print_wp_cart_button_for_product("{$productid}", "{$price[0]}");

to better.

@darrenmeehan
Copy link
Author

Hi, Just wondering what difference the quotes will make with this. Thanks.

Copy link

ghost commented Aug 5, 2012

Double quotes are using for VariableStrings. Like: "Hello $MyNameVariable." also they are slower than Single quotes.

Single quotes are using for SimpleStrings. Like: 'Hello YPY'. also they are faster than Double quotes.

And using { and } to variables, just increase code readability and better it. "Hello {$Micro}soft" <--- !

@darrenmeehan
Copy link
Author

Thanks for the help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment