Created
August 5, 2012 18:01
-
-
Save darrenmeehan/3266387 to your computer and use it in GitHub Desktop.
This is a simple WordPress shortcode to add a Paypal button
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'); |
Hi, Just wondering what difference the quotes will make with this. Thanks.
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" <--- !
Thanks for the help :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.