Changeset 472131
- Timestamp:
- 12/07/2011 07:12:38 PM (14 years ago)
- Location:
- easy-paypal-custom-fields
- Files:
-
- 4 edited
-
tags/1.3/easy-paypal-custom-fields.php (modified) (1 diff)
-
trunk/css/paypal.css (modified) (2 diffs)
-
trunk/easy-paypal-custom-fields.php (modified) (35 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
easy-paypal-custom-fields/tags/1.3/easy-paypal-custom-fields.php
r438923 r472131 42 42 'url' => '' 43 43 ); 44 update_option( 'rps_myplugin_options', $button ); 44 if( !get_option('rps_myplugin_options') ) { 45 update_option( 'rps_myplugin_options', $button ); 46 } 45 47 46 48 // Delete all the crap I made when people delete the plugin -
easy-paypal-custom-fields/trunk/css/paypal.css
r465303 r472131 70 70 line-height: 13px !important; 71 71 font: 12px !important "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", "Bitstream Vera Sans", "Liberation Sans", Verdana, "Verdana Ref", sans-serif; 72 font-weight: bold; 72 73 -webkit-border-radius: 12px !important; 73 74 -moz-border-radius: 12px !important; 74 75 border-radius: 12px !important; 75 -webkit-transition: none;76 -moz-transition: none;77 -o-transition: none;78 transition: none;79 -webkit-background-clip: padding-box;80 76 } 81 77 … … 150 146 cursor: default; 151 147 margin-top: 1px; 152 /* padding: 0.5em 0.9em; */153 148 border-color: #000; 154 149 color: #fff; -
easy-paypal-custom-fields/trunk/easy-paypal-custom-fields.php
r465329 r472131 4 4 Plugin URI: http://richardsweeney.com/blog/easy-paypal-custom-fields/ 5 5 Description: This plugin uses custom fields to make creating a PayPal button super-easy. There is no complicated shortcut syntax to remember. 6 Version: 2.0. 16 Version: 2.0.2 7 7 Author: Richard Sweeney 8 8 Author URI: http://richardsweeney.com/ … … 42 42 private $currency_array = array( 43 43 'Australian Dollar' => 'AUD', 44 'Brazilian Real' => 'BRL',45 44 'Canadian Dollar' => 'CAD', 46 45 'Czech Koruna' => 'CZK', 47 46 'Danish Krone' => 'DKK', 48 47 'Euro' => 'EUR', 49 'Hong Kong Dollar' => 'HKD',50 48 'Hungarian Forint' => 'HUF', 51 'Israeli New Sheqel' => 'ILS',52 49 'Japanese Yen' => 'JPY', 53 'Malaysian Ringgit' => 'MYR',54 'Mexican Peso' => 'MXN',55 50 'Norwegian Krone' => 'NOK', 56 51 'New Zealand Dollar' => 'NZD', 57 'Philippine Peso' => 'PHP',58 52 'Polish Zloty' => 'PLN', 59 53 'Pound Sterling' => 'GBP', … … 61 55 'Swedish Krona' => 'SEK', 62 56 'Swiss Franc' => 'CHF', 63 'Taiwan New Dollar' => 'TWD',64 'Thai Baht' => 'THB',65 'Turkish Lira' => 'TRY',66 57 'U.S. Dollar' => 'USD' 67 58 ); … … 83 74 ); 84 75 85 // used for checking against individual post meta - see loopy_meta()76 // used for checking against individual post meta - see get_the_post_meta() 86 77 private $some_meta = array( 87 78 'amount', … … 89 80 'item_no', 90 81 'textfield_checkbox', 91 'textfield_title' 82 'textfield_title', 83 'quantity_checkbox', 84 'require_address' 92 85 //'drop_down_title' 93 86 ); 94 87 95 // Default values - used for checking against individual post meta - see loopy_meta()88 // Default values - used for checking against individual post meta - see get_the_post_meta() 96 89 private $default_meta = array( 97 90 'user_email', … … 105 98 // These variables are declared later 106 99 public $opts; // default options, declared in __construct() 107 public $my_post_meta; // indivdual, additional post meta, declared in loopy_meta()100 public $my_post_meta; // indivdual, additional post meta, declared in get_the_post_meta() 108 101 public $paypal_button; // the button, declared in create_button() 109 102 … … 115 108 116 109 // Define current version 117 define( 'PAYPAL_VERSION', '2.0. 1' );110 define( 'PAYPAL_VERSION', '2.0.2' ); 118 111 119 112 // Activation Hook 120 register_activation_hook( __FILE__, array( &$this, ' plugin_activate' ) );113 register_activation_hook( __FILE__, array( &$this, 'activate_my_plugin' ) ); 121 114 122 115 // Add stylesheet to the admin pages & the front end 123 116 add_action( 'admin_print_styles-post.php', array( &$this, 'add_css' ) ); 124 117 add_action( 'admin_print_styles-post-new.php', array( &$this, 'add_css' ) ); 125 add_action( ' template_redirect', array( &$this, 'add_css' ) );118 add_action( 'wp_print_styles', array( &$this, 'add_css' ) ); 126 119 127 120 // Add my JS to WP Admin … … 129 122 130 123 // Create options page & menu item 131 add_action( 'admin_menu', array( &$this, 'add_ page' ) );124 add_action( 'admin_menu', array( &$this, 'add_my_options_page' ) ); 132 125 133 126 // Register and define the settings 134 add_action( 'admin_init', array( &$this, ' admin_init' ) );127 add_action( 'admin_init', array( &$this, 'create_settings_sections' ) ); 135 128 136 129 // Create paypal meta box 137 add_action( 'add_meta_boxes', array( &$this, ' eppcf_meta_box' ) );130 add_action( 'add_meta_boxes', array( &$this, 'register_meta_box' ) ); 138 131 139 132 // Save post meta … … 154 147 * When the plugin is activated, add the default options 155 148 */ 156 public function plugin_activate() {149 public function activate_my_plugin() { 157 150 158 151 // On plugin activation register the following options … … 170 163 171 164 // Uninstaller function callback 172 register_uninstall_hook( __FILE__, array( &$this, ' plugin_uninstaller' ) );173 174 } 175 176 177 /**165 register_uninstall_hook( __FILE__, array( &$this, 'uninstall_my_plugin' ) ); 166 167 } 168 169 170 /** 178 171 * Uninstall function 179 172 */ 180 public function plugin_uninstaller() {173 public function uninstall_my_plugin() { 181 174 182 175 // Get any custom post types … … 216 209 217 210 218 /**211 /** 219 212 * Add custom CSS 220 213 */ 221 214 public function add_css() { 222 wp_enqueue_style( 'eppcf_css', plugin_dir_url(__FILE__) . 'css/paypal.css' );223 } 224 225 /**215 wp_enqueue_style( 'eppcf_css', plugin_dir_url(__FILE__) . 'css/paypal.css' ); 216 } 217 218 /** 226 219 * Add custom JavaScript 227 220 */ … … 240 233 */ 241 234 242 public function loopy_meta( $meta_array ){ 235 public function get_the_post_meta( $meta_array ){ 236 243 237 $post_meta_array = array(); 244 $post_meta_array['show'] = ( isset( $meta_array['show'] ) && !empty( $meta_array['show'] ) ) ? $meta_array['show'] : 'no'; 245 $post_meta_array['name'] = ( isset( $meta_array['name'] ) && !empty( $meta_array['name'] ) ) ? $meta_array['name'] : ''; 238 $post_meta_array['show'] = ( !empty( $meta_array['show'] ) ) ? $meta_array['show'] : 'no'; 239 $post_meta_array['name'] = ( !empty( $meta_array['name'] ) ) ? $meta_array['name'] : ''; 240 246 241 foreach( $this->some_meta as $meta ){ 247 242 $post_meta_array[$meta] = ( isset ( $meta_array[$meta] ) ) ? $meta_array[$meta] : ''; 248 243 } 244 249 245 foreach( $this->default_meta as $default ){ 250 246 $post_meta_array[$default] = ( isset( $meta_array[$default] ) && !empty( $meta_array[$default] ) ) ? $meta_array[$default] : $this->opts[$default]; 251 247 } 248 249 252 250 // Backwards compatibility 253 251 // My old, stupid names for stuff => because I'm a dork. … … 272 270 */ 273 271 274 public function add_ page() {272 public function add_my_options_page() { 275 273 $ops = add_options_page( 276 274 'Easy PayPal Custom Fields', … … 278 276 'manage_options', 279 277 'easy-paypal-custom-fields', 280 array( &$this, ' options_page' ) // callback function to draw the options page278 array( &$this, 'echo_options_page' ) // callback function to draw the options page 281 279 ); 282 280 // Add plugin CSS to this page … … 290 288 */ 291 289 292 public function options_page() {290 public function echo_options_page() { 293 291 294 292 // Shorthand as there are some many checks to be made against button_type & theme … … 354 352 355 353 356 public function admin_init(){354 public function create_settings_sections(){ 357 355 358 356 register_setting( 359 357 'rps_eppcf_options', 360 358 'rps_eppcf_options', 361 array( $this, 'validate_options' )359 array( &$this, 'validate_options' ) 362 360 ); 363 361 … … 365 363 'rps_eppcf_main', 366 364 'Enter your default settings here', 367 array( $this, 'settings_section_header' ),365 array( &$this, 'echo_settings_section_header' ), 368 366 'rps_eppcf_settings_page' 369 367 ); … … 373 371 'id' => 'settings-input', //HTML ID tag for the section 374 372 'text' => 'PayPal username', // Text to output for the section 375 'function' => array( $this, 'settings_input' ) // Callback function (to echo the form field)373 'function' => array( &$this, 'echo_settings_input' ) // Callback function (to echo the form field) 376 374 ), 377 375 array( 378 376 'id' => 'settings-curreny', 379 377 'text' => 'Default currency', 380 'function' => array( $this, 'settings_currency' )378 'function' => array( &$this, 'echo_settings_currency' ) 381 379 ), 382 380 array( 383 381 'id' => 'settings-button-type', 384 382 'text' => 'Select a button type', 385 'function' => array( $this, 'settings_button_type' )383 'function' => array( &$this, 'echo_settings_button_type' ) 386 384 ), 387 385 array( 388 386 'id' => 'settings-button-text', 389 387 'text' => 'Custom button text (optional)', 390 'function' => array( $this, 'settings_button_text' )388 'function' => array( &$this, 'echo_settings_button_text' ) 391 389 ), 392 390 array( 393 391 'id' => 'settings-url', 394 392 'text' => 'Return URL (optional)', 395 'function' => array( $this, 'settings_url' )393 'function' => array( &$this, 'echo_settings_url' ) 396 394 ), 397 395 array( 398 396 'id' => 'settings-post-type', 399 397 'text' => 'Select on which post type to display the Button', 400 'function' => array( $this, 'settings_post_type' )398 'function' => array( &$this, 'echo_settings_post_type' ) 401 399 ), 402 400 array( 403 401 'id' => 'settings-theme', 404 402 'text' => 'Select a theme for the button', 405 'function' => array( $this, 'settings_theme' )403 'function' => array( &$this, 'echo_settings_theme' ) 406 404 ) 407 405 ); … … 430 428 * Draw settings page functions follow: 431 429 */ 432 public function settings_section_header() {430 public function echo_settings_section_header() { 433 431 // echo '<p><strong>Plugin Settings:</strong></p>'; 434 432 } 435 433 436 434 437 public function settings_input() { ?>435 public function echo_settings_input() { ?> 438 436 <input placeholder="email@address.com" id="user-email" name="rps_eppcf_options[user_email]" type="text" value="<?php echo $this->opts['user_email']; ?>" /> 439 437 <?php } 440 438 441 439 442 public function settings_currency() { ?>440 public function echo_settings_currency() { ?> 443 441 <select id="currency" name="rps_eppcf_options[currency]"> 444 442 <?php foreach( $this->currency_array as $key => $value ) : ?> … … 449 447 450 448 451 public function settings_button_type() { ?>449 public function echo_settings_button_type() { ?> 452 450 <p> 453 451 <select id="button-type" name="rps_eppcf_options[button_type]"> … … 462 460 463 461 464 public function settings_button_text() { ?>462 public function echo_settings_button_text() { ?> 465 463 <input placeholder="eg. 'Buy CD'" id="button-text" name="rps_eppcf_options[button_text]" type="text" value="<?php echo $this->opts['button_text']; ?>" /> 466 464 <?php } 467 465 468 466 469 public function settings_url() { ?>467 public function echo_settings_url() { ?> 470 468 <input placeholder="The URL to return to after checkout" type="text" id="url" name="rps_eppcf_options[url]" value="<?php echo $this->opts['url']; ?>" /> 471 469 <?php } 472 470 473 471 474 public function settings_post_type() {472 public function echo_settings_post_type() { 475 473 476 474 // Get any custom post types … … 520 518 521 519 522 public function settings_theme() { ?>520 public function echo_settings_theme() { ?> 523 521 <p> 524 522 <select id="theme" name="rps_eppcf_options[theme]"> … … 606 604 */ 607 605 608 public function eppcf_meta_box() {606 public function register_meta_box() { 609 607 610 608 // Loop through the selected post types & create the meta box on the selected pages … … 614 612 'rps_paypal_meta', 615 613 'Add Paypal Button', 616 array( &$this, 'e ppcf_meta_box_callback' ),614 array( &$this, 'echo_meta_box' ), 617 615 $post_type, 618 616 'normal', … … 628 626 * Callback function to draw the meta box on post / page / custom post type 629 627 */ 630 public function e ppcf_meta_box_callback( $post ) {628 public function echo_meta_box( $post ) { 631 629 632 630 // Get the current post meta & default settings 633 631 $rps_meta_array = get_post_meta( $post->ID, '_rps_eppcf_array', true ); 634 $this-> loopy_meta( $rps_meta_array );632 $this->get_the_post_meta( $rps_meta_array ); 635 633 ?> 636 634 … … 667 665 668 666 <p> 667 <span>Require customers' address</span> 668 <label> 669 <input type="checkbox" id="require_address" name="require_address" value="true" <?php checked( $this->my_post_meta['require_address'], true ); ?> /> 670 Yes 671 </label> 672 </p> 673 674 <p> 675 <span>Allow customer to select quantity</span> 676 <label> 677 <input type="checkbox" id="quantity_checkbox" name="quantity_checkbox" value="true" <?php checked( $this->my_post_meta['quantity_checkbox'], true ); ?> /> 678 Yes 679 </label> 680 </p> 681 682 <p> 669 683 <span>Add a custom textfield</span> 670 684 <label> 671 685 <input type="checkbox" id="textfield_checkbox" name="textfield_checkbox" value="true" <?php checked( $this->my_post_meta['textfield_checkbox'], true ); ?> /> 672 Yes please686 Yes 673 687 </label> 674 688 </p> … … 794 808 } else { 795 809 $eppcf_array['name'] = ''; 796 } 797 798 if( isset( $_POST['textfield_checkbox'] ) && $_POST['textfield_checkbox'] == 'true' ){ 799 $eppcf_array['textfield_checkbox'] = true; 800 } else { 801 $eppcf_array['textfield_checkbox'] = false; 810 } 811 812 $checkboxVals = array( 'require_address', 'textfield_checkbox', 'quantity_checkbox' ); 813 814 foreach( $checkboxVals as $checkboxVal ){ 815 if( isset( $_POST[ $checkboxVal ] ) && $_POST[ $checkboxVal ] == 'true' ){ 816 $eppcf_array[ $checkboxVal ] = true; 817 } else { 818 $eppcf_array[ $checkboxVal ] = false; 819 } 802 820 } 803 821 … … 869 887 // Get post meta 870 888 $rps_meta_array = get_post_meta( $post->ID, '_rps_eppcf_array', true ); 871 $this-> loopy_meta( $rps_meta_array );889 $this->get_the_post_meta( $rps_meta_array ); 872 890 873 891 // Shorthand … … 881 899 KISS 882 900 */ 883 $tf_i = 0;901 // $tf_i = 0; 884 902 885 903 // If there are 2 additional textfields, they must have different IDs … … 933 951 } 934 952 935 if( $theme == 'use PayPal image - large' ) { 936 if( $button_type == 'Buy Now' ) { 937 $args = array(); 938 } else if ( $button_type == 'Donations' ) { 939 $args = array( 'src' => 'btn_buynow_LG.gif' ); 940 } 941 } else if( $theme == 'use PayPal image - small' ){ 942 if( $button_type == 'Buy Now' ) { 943 $args = array( 'src' => 'btn_buynow_SM.gif' ); 944 } else if( $button_type == 'Donations' ) { 945 $args = array( 'src' => 'btn_donate_SM.gif' ); 946 } 947 } else if( $theme == 'light theme' ) { 948 $args = array( 'type' => 'custom_theme', 'button_text' => $button_text ); 949 } else if( $theme == 'dark theme' ) { 950 $args = array( 'type' => 'custom_theme', 'id' => 'rps-paypal-button-dark', 'button_text' => $button_text ); 951 } else if( $theme == 'blue theme' ) { 952 $args = array( 'type' => 'custom_theme', 'id' => 'rps-paypal-button-blue', 'button_text' => $button_text ); 953 } else if( $theme == 'red theme' ) { 954 $args = array( 'type' => 'custom_theme', 'id' => 'rps-paypal-button-red', 'button_text' => $button_text ); 953 switch( $theme ){ 954 case 'use PayPal image - large' : 955 if( $button_type == 'Buy Now' ) { 956 $args = array(); 957 } else if ( $button_type == 'Donations' ) { 958 $args = array( 'src' => 'btn_buynow_LG.gif' ); 959 } 960 break; 961 case 'use PayPal image - small' : 962 if( $button_type == 'Buy Now' ) { 963 $args = array( 'src' => 'btn_buynow_SM.gif' ); 964 } else if( $button_type == 'Donations' ) { 965 $args = array( 'src' => 'btn_donate_SM.gif' ); 966 } 967 break; 968 case 'light theme' : 969 $args = array( 'type' => 'custom_theme', 'button_text' => $button_text ); 970 break; 971 case 'dark theme' : 972 $args = array( 'type' => 'custom_theme', 'id' => 'rps-paypal-button-dark', 'button_text' => $button_text ); 973 break; 974 case 'blue theme' : 975 $args = array( 'type' => 'custom_theme', 'id' => 'rps-paypal-button-blue', 'button_text' => $button_text ); 976 break; 977 case 'red theme' : 978 $args = array( 'type' => 'custom_theme', 'id' => 'rps-paypal-button-red', 'button_text' => $button_text ); 979 break; 955 980 } 956 981 957 982 $button .= $this->type_of_button( $args ); 958 983 959 960 984 // Username (email address) 961 985 $button .= '<input type="hidden" name="business" value="' . antispambot( $this->my_post_meta['user_email'] ) .'" />'; … … 974 998 $button .= ' 975 999 <input type="hidden" name="amount" value="' . $this->my_post_meta['amount'] . '" /> 976 <input type="hidden" name="currency_code" value="' . $this->my_post_meta['currency'] . '" /> 977 <input type="hidden" name="shipping" value="' . $this->my_post_meta['postage'] . '" /> 978 <input type="hidden" name="rm" value="2" /> 979 '; 1000 <input type="hidden" name="currency_code" value="' . $this->my_post_meta['currency'] . '" />'; 1001 1002 if( $button_type == 'Buy Now' ) { 1003 $button .= '<input type="hidden" name="shipping" value="' . $this->my_post_meta['postage'] . '" />'; 1004 } 1005 1006 $needAddress = ( $this->my_post_meta['require_address'] == true ) ? 2 : 1; 1007 1008 $button .= '<input type="hidden" name="no_shipping" value="' . $needAddress - '"> 1009 <input type="hidden" name="rm" value="2" />'; 1010 1011 if( $button_type == 'Buy Now' && $this->my_post_meta['quantity_checkbox'] == true ) { 1012 $button .= '<input type="hidden" name="undefined_quantity" value="1">'; 1013 } 980 1014 981 1015 // Return url … … 992 1026 } 993 1027 994 /** 1028 1029 1030 /** 995 1031 * Where the button should appear 996 1032 * 997 1033 * @param string the post content 998 1034 */ 999 1000 1035 public function display_button( $content ) { 1001 1036 … … 1003 1038 // Get the current post meta 1004 1039 $rps_meta_array = get_post_meta( $post->ID, '_rps_eppcf_array', true ); 1005 $show = ( isset( $rps_meta_array['show'] ) && !empty( $rps_meta_array['show'] )) ? $rps_meta_array['show'] : 'no';1040 $show = ( isset( $rps_meta_array['show'] ) ) ? $rps_meta_array['show'] : 'no'; 1006 1041 // Create the button 1007 1042 $this->create_button(); … … 1024 1059 1025 1060 } 1026 1027 1028 /** 1061 1062 1063 1064 /** 1029 1065 * Create button shortcode 1030 1066 */ 1031 1032 1067 function create_shortcode() { 1033 1068 $this->create_button(); … … 1045 1080 * having to prefix all my functions makes it all super worth it. 1046 1081 */ 1047 $rps_eppcf = new RPS_eppcf(); 1048 1082 $rps_eppcf = new RPS_eppcf(); 1049 1083 1050 1084 ?> -
easy-paypal-custom-fields/trunk/readme.txt
r465331 r472131 6 6 Requires at least: 3.0 7 7 Tested up to: 3.2.1 8 Stable tag: 2.0 8 Stable tag: 2.0.2 9 9 10 10 An easy-to-use plugin to add a PayPal 'donate' or 'buy now' button to your site. … … 74 74 = 2.0 = 75 75 76 * Completely rebuilt and optimized the (using OOP).76 * Completely rebuilt and optimized the plugin (using OOP). 77 77 * Added the option to add a custom textfield (displayed above the button). 78 78 * Added support for opera CSS3 gradients for custom button themes. … … 82 82 83 83 * Fixed backwards compatibility issues and a few wee bugs. 84 85 = 2.0.2 = 86 87 * Added the option to choose if the customer can alter the number of items to purchase. 88 * Added the option to make collection of the customers' address mandatory. 89 * Optimized code readability. 90 * Amended list of supported currency codes.
Note: See TracChangeset
for help on using the changeset viewer.