├── .gitignore ├── js ├── .DS_Store └── input.js ├── images └── .DS_Store ├── screenshot-1.jpg ├── screenshot-2.jpg ├── screenshot-3.jpg ├── screenshot-4.jpg ├── css └── input.css ├── README.md ├── readme.txt ├── acf-paypal.php ├── paypal_item-v5.php ├── paypal_item-v3.php └── paypal_item-v4.php /.gitignore: -------------------------------------------------------------------------------- 1 | /.DS_Store 2 | -------------------------------------------------------------------------------- /js/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikerodriguez/acf-paypal-field/HEAD/js/.DS_Store -------------------------------------------------------------------------------- /images/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikerodriguez/acf-paypal-field/HEAD/images/.DS_Store -------------------------------------------------------------------------------- /screenshot-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikerodriguez/acf-paypal-field/HEAD/screenshot-1.jpg -------------------------------------------------------------------------------- /screenshot-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikerodriguez/acf-paypal-field/HEAD/screenshot-2.jpg -------------------------------------------------------------------------------- /screenshot-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikerodriguez/acf-paypal-field/HEAD/screenshot-3.jpg -------------------------------------------------------------------------------- /screenshot-4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikerodriguez/acf-paypal-field/HEAD/screenshot-4.jpg -------------------------------------------------------------------------------- /css/input.css: -------------------------------------------------------------------------------- 1 | .pp-item-inputs { 2 | margin-bottom: 20px; 3 | } 4 | .pp-item-inputs input, .pp-item-inputs textarea{ 5 | box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.1) inset; 6 | } -------------------------------------------------------------------------------- /js/input.js: -------------------------------------------------------------------------------- 1 | (function($){ 2 | 3 | 4 | /* 5 | * acf/setup_fields 6 | * 7 | * This event is triggered when ACF adds any new elements to the DOM. 8 | * 9 | * @type function 10 | * @since 1.0.0 11 | * @date 01/01/12 12 | * 13 | * @param event e: an event object. This can be ignored 14 | * @param Element postbox: An element which contains the new HTML 15 | * 16 | * @return N/A 17 | */ 18 | 19 | $(document).live('acf/setup_fields', function(e, postbox){ 20 | 21 | $(postbox).find('.my-field-class').each(function(){ 22 | 23 | // initiate JS on my field! 24 | // $(this).add_awesome_stuff(); 25 | 26 | }); 27 | 28 | }); 29 | 30 | })(jQuery); 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ACF { PayPal Field 2 | 3 | 4 | ### Overview 5 | 6 | The PayPal Item Field is a simple, yet useful field that can help you integrate PayPal forms onto your WP site with the use of ACF. It's a faster way of adding PayPal Items to your site without having to login to your PayPal Account and create it yourself. Using the native ACF function the_field(), you can display a simple form that includes Item Name, Item Description, Price, and you can enable/disable user Quantity input. 7 | 8 | The PayPal Item field currently supports 343 countries and 18 different currencies. 9 | 10 | ### Compatibility 11 | 12 | This add-on will work with: 13 | 14 | * version 4 and up 15 | * version 3 and below 16 | 17 | 18 | ### Installation 19 | 20 | This add-on can be treated as both a WP plugin and a theme include. 21 | 22 | **Install as Plugin** 23 | 24 | 1. Copy the 'acf-paypal-field' folder into your plugins folder 25 | 2. Activate the plugin via the Plugins admin page 26 | 27 | **Include within theme** 28 | 29 | 1. Copy the 'acf-paypal-field' folder into your theme folder (can use sub folders). You can place the folder anywhere inside the 'wp-content' directory 30 | 2. Edit your functions.php file and add the code below (Make sure the path is correct to include the acf-paypal.php file) 31 | 32 | ```php 33 | include_once('acf-paypal-field/acf-paypal.php'); 34 | ``` 35 | 36 | ### More Information 37 | 38 | Please read the readme.txt file for more information 39 | 40 | https://github.com/mikerodriguez/acf-paypal-field/blob/master/readme.txt 41 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | === Advanced Custom Fields: PayPal Field === 2 | Contributors: Mike Rodriguez 3 | Tags: custom, field, custom field, advanced, admin, paypal, item, edit 4 | Requires at least: 3.4 5 | Tested up to: 3.3.1 6 | Stable tag: trunk 7 | License: GPLv2 or later 8 | License URI: http://www.gnu.org/licenses/gpl-2.0.html 9 | 10 | 11 | == Description == 12 | 13 | The PayPal Item Field is a simple, yet useful field that can help you integrate PayPal forms onto your WP site with the use of ACF. It's a faster way of adding PayPal Items to your site without having to login to your PayPal Account and create it yourself. Using the native ACF function the_field(), you can display a simple form that includes Item Name, Item Description, Price, and you can enable/disable user Quantity input. 14 | 15 | The PayPal Item field currently supports 343 countries and 18 different currencies. 16 | 17 | 18 | = Compatibility = 19 | 20 | This add-on will work with: 21 | 22 | * version 4 and up 23 | * version 3 and bellow 24 | 25 | 26 | == Installation == 27 | 28 | This add-on can be treated as both a WP plugin and a theme include. 29 | 30 | = Plugin = 31 | 1. Copy the 'acf-paypal-field' folder into your plugins folder 32 | 2. Activate the plugin via the Plugins admin page 33 | 34 | = Include = 35 | 1. Copy the 'acf-paypal-field' folder into your theme folder (can use sub folders). You can place the folder anywhere inside the 'wp-content' directory 36 | 2. Edit your functions.php file and add the code below (Make sure the path is correct to include the acf-paypal.php file) 37 | 38 | ` 39 | include_once('acf-paypal-field/acf-paypal.php'); 40 | ` 41 | 42 | == Changelog == 43 | 44 | 45 | = 2.0.0 = 46 | * Bug Fixes 47 | * ACF V4 Compatibility, Updated CSS 48 | * Updated CSS 49 | 50 | = 1.0.0 = 51 | * Initial Release. 52 | -------------------------------------------------------------------------------- /acf-paypal.php: -------------------------------------------------------------------------------- 1 | 86 | -------------------------------------------------------------------------------- /paypal_item-v5.php: -------------------------------------------------------------------------------- 1 | name = 'paypal_item'; 29 | 30 | 31 | /* 32 | * label (string) Multiple words, can include spaces, visible when selecting a field type 33 | */ 34 | 35 | $this->label = __('PayPal Item', 'acf-paypal_item'); 36 | 37 | 38 | /* 39 | * category (string) basic | content | choice | relational | jquery | layout | CUSTOM GROUP NAME 40 | */ 41 | 42 | $this->category = 'content'; 43 | 44 | 45 | /* 46 | * defaults (array) Array of default settings which are merged into the field object. These are used later in settings 47 | */ 48 | 49 | $this->defaults = array( 50 | 'font_size' => 14, 51 | ); 52 | 53 | 54 | /* 55 | * l10n (array) Array of strings that are used in JavaScript. This allows JS strings to be translated in PHP and loaded via: 56 | * var message = acf._e('paypal_item', 'error'); 57 | */ 58 | 59 | $this->l10n = array( 60 | 'error' => __('Error! Please enter a higher value', 'acf-paypal_item'), 61 | ); 62 | 63 | 64 | // do not delete! 65 | parent::__construct(); 66 | 67 | // settings 68 | $this->settings = array( 69 | 'path' => apply_filters('acf/helpers/get_path', __FILE__), 70 | 'dir' => apply_filters('acf/helpers/get_dir', __FILE__), 71 | 'version' => '1.1.0' 72 | ); 73 | 74 | } 75 | 76 | 77 | /* 78 | * render_field_settings() 79 | * 80 | * Create extra settings for your field. These are visible when editing a field 81 | * 82 | * @type action 83 | * @since 3.6 84 | * @date 23/01/13 85 | * 86 | * @param $field (array) the $field being edited 87 | * @return n/a 88 | */ 89 | 90 | function render_field_settings( $field ) { 91 | 92 | /* 93 | * acf_render_field_setting 94 | * 95 | * This function will create a setting for your field. Simply pass the $field parameter and an array of field settings. 96 | * The array of settings does not require a `value` or `prefix`; These settings are found from the $field array. 97 | * 98 | * More than one setting can be added by copy/paste the above code. 99 | * Please note that you must also have a matching $defaults value for the field name (font_size) 100 | */ 101 | 102 | 103 | acf_render_field_setting( $field, array( 104 | 'label' => __('Paypal Email','acf-paypal_item'), 105 | 'instructions' => __('Enter your PayPal email address.','acf-paypal_item'), 106 | 'type' => 'text', 107 | 'name' => 'paypal_email', 108 | )); 109 | 110 | acf_render_field_setting( $field, array( 111 | 'label' => __('Button Label','acf-paypal_item'), 112 | 'instructions' => __('Customize the label of your button. Default: Pay Now

Note: Use the CSS class (.item-field_button) to customize look of your button.','acf-paypal_item'), 113 | 'type' => 'text', 114 | 'name' => 'button_label', 115 | )); 116 | 117 | acf_render_field_setting( $field, array( 118 | 'label' => __('Enable Quantity','acf-paypal_item'), 119 | 'instructions' => __('Allows user to change quantity on the front-end.','acf-paypal_item'), 120 | 'type' => 'radio', 121 | 'name' => 'enable_quantity', 122 | 'layout' => 'horizontal', 123 | 'choices' => array( 124 | '1' => 'Yes', 125 | '0' => 'No', 126 | ), 127 | )); 128 | 129 | 130 | acf_render_field_setting( $field, array( 131 | 'label' => __('Currency','acf-paypal_item'), 132 | 'instructions' => __('ESelect Currency.','acf-paypal_item'), 133 | 'type' => 'select', 134 | 'name' => 'currency', 135 | 'choices' => array( 136 | 'USD' => 'USD - United States Dollars', 137 | 'AUD' => 'AUD - Australian Dollars', 138 | 'CAD' => 'CAD - Canadian Dollars', 139 | 'CHF' => 'CHF - Swiss Franc', 140 | 'CZK' => 'CZK - Czech Koruna', 141 | 'DKK' => 'DKK - Danish Krone', 142 | 'EUR' => 'EUR - Euros', 143 | 'GBP' => 'GBP - Pounds Sterling', 144 | 'HDK' => 'HDK - Hong Kong Dollar', 145 | 'HUF' => 'HUF - Hungarian Forint', 146 | 'ILS' => 'ILS - Israeli Shekel', 147 | 'JPY' => 'JPY - Japanese Yen', 148 | 'MXN' => 'MXN - Mexican Peso', 149 | 'NOK' => 'NOK - Norwegian Krone', 150 | 'NZD' => 'NZD - New Zealand Dollar', 151 | 'PLN' => 'PLN - Polish Zloty', 152 | 'SEK' => 'SEK - Swedish Krona', 153 | 'SGD' => 'SGD - Singapore Dollar', 154 | 'USD' => 'USD - United States Dollars' 155 | ), 156 | )); 157 | 158 | acf_render_field_setting( $field, array( 159 | 'label' => __('Country','acf-paypal_item'), 160 | 'instructions' => __('Select Country Default: (US) - United States.','acf-paypal_item'), 161 | 'type' => 'select', 162 | 'name' => 'country', 163 | 'choices' => array( 164 | "US" => "United States ", 165 | "AX" => "Åland Islands", 166 | "AL" => "Albania ", 167 | "DZ" => "Algeria ", 168 | "AS" => "American Samoa", 169 | "AD" => "Andorra", 170 | "AO" => "Angola ", 171 | "AI" => "Anguilla ", 172 | "AQ" => "Antarctica ", 173 | "AG" => "Antigua and Barbuda ", 174 | "AR" => "Argentina", 175 | "AU" => "Australia ", 176 | "AT" => "Austria ", 177 | "AZ" => "Azerbaijan", 178 | "BS" => "Bahamas ", 179 | "BH" => "Bahrain ", 180 | "BD" => "Bangladesh ", 181 | "BB" => "Barbados ", 182 | "BY" => "Belarus", 183 | "BE" => "Belgium ", 184 | "BZ" => "Belize ", 185 | "BJ" => "Benin ", 186 | "BM" => "Bermuda ", 187 | "BT" => "Bhutan", 188 | "BO" => "Bolivia ", 189 | "BA" => "Bosnia and Herzegovina ", 190 | "BW" => "Botswana ", 191 | "BV" => "Bouvet Island ", 192 | "BR" => "Brazil", 193 | "IO" => "British Indian Ocean Territory ", 194 | "BN" => "Brunei Darussalam ", 195 | "BG" => "Bulgaria ", 196 | "BF" => "Burkina Faso ", 197 | "BI" => "Burundi", 198 | "KH" => "Cambodia ", 199 | "CM" => "Cameroon ", 200 | "CA" => "Canada ", 201 | "CV" => "Cape Verde ", 202 | "KY" => "Cayman Islands ", 203 | "CF" => "Central African Republic ", 204 | "TD" => "Chad ", 205 | "CL" => "Chile ", 206 | "CN" => "China ", 207 | "CX" => "Christmas Island", 208 | "CC" => "Cocos (Keeling) Islands ", 209 | "CO" => "Colombia ", 210 | "KM" => "Comoros ", 211 | "CG" => "Congo ", 212 | "CD" => "Congo, the Democratic Republic of the", 213 | "CK" => "Cook Islands ", 214 | "CR" => "Costa Rica ", 215 | "CI" => "Côte D'Ivoire", 216 | "HR" => "Croatia ", 217 | "CU" => "Cuba ", 218 | "CY" => "Cyprus ", 219 | "CZ" => "Czech Republic ", 220 | "DK" => "Denmark", 221 | "DJ" => "Djibouti ", 222 | "DM" => "Dominica ", 223 | "DO" => "Dominican Republic ", 224 | "EC" => "Ecuador ", 225 | "EG" => "Egypt", 226 | "SV" => "El Salvador ", 227 | "GQ" => "Equatorial Guinea ", 228 | "ER" => "Eritrea ", 229 | "EE" => "Estonia ", 230 | "ET" => "Ethiopia ", 231 | "FK" => "Falkland Islands (Malvinas) ", 232 | "FO" => "Faroe Islands ", 233 | "FJ" => "Fiji ", 234 | "FI" => "Finland ", 235 | "FR" => "France", 236 | "GF" => "French Guiana ", 237 | "PF" => "French Polynesia ", 238 | "TF" => "French Southern Territories ", 239 | "GA" => "Gabon ", 240 | "GM" => "Gambia ", 241 | "GE" => "Georgia ", 242 | "DE" => "Germany ", 243 | "GH" => "Ghana ", 244 | "GI" => "Gibraltar ", 245 | "GR" => "Greece", 246 | "GL" => "Greenland ", 247 | "GD" => "Grenada ", 248 | "GP" => "Guadeloupe ", 249 | "GU" => "Guam ", 250 | "GT" => "Guatemala", 251 | "GG" => "Guernsey ", 252 | "GN" => "Guinea ", 253 | "GW" => "Guinea-Bissau ", 254 | "GY" => "Guyana ", 255 | "HT" => "Haiti", 256 | "HM" => "Heard Island and Mcdonald Islands ", 257 | "VA" => "Holy See (Vatican City State) ", 258 | "HN" => "Honduras ", 259 | "HK" => "Hong Kong ", 260 | "HU" => "Hungary", 261 | "IS" => "Iceland ", 262 | "IN" => "India ", 263 | "ID" => "Indonesia ", 264 | "IR" => "Iran, Islamic Republic of ", 265 | "IQ" => "Iraq ", 266 | "IE" => "Ireland ", 267 | "IM" => "Isle of Man ", 268 | "IL" => "Israel ", 269 | "IT" => "Italy ", 270 | "JM" => "Jamaica", 271 | "JP" => "Japan ", 272 | "JE" => "Jersey ", 273 | "JO" => "Jordan ", 274 | "KZ" => "Kazakhstan ", 275 | "KE" => "KENYA", 276 | "KI" => "Kiribati ", 277 | "KP" => "Korea, Democratic People's Republic of ", 278 | "KR" => "Korea, Republic of ", 279 | "KW" => "Kuwait ", 280 | "KG" => "Kyrgyzstan", 281 | "LA" => "Lao People's Democratic Republic ", 282 | "LV" => "Latvia ", 283 | "LB" => "Lebanon ", 284 | "LS" => "Lesotho ", 285 | "LR" => "Liberia", 286 | "LY" => "Libyan Arab Jamahiriya ", 287 | "LI" => "Liechtenstein ", 288 | "LT" => "Lithuania ", 289 | "LU" => "Luxembourg ", 290 | "MO" => "Macao", 291 | "MK" => "Macedonia, the Former Yugoslav Republic of ", 292 | "MG" => "Madagascar ", 293 | "MW" => "Malawi ", 294 | "MY" => "Malaysia ", 295 | "MV" => "Maldives", 296 | "ML" => "Mali ", 297 | "MT" => "Malta ", 298 | "MH" => "Marshall Islands ", 299 | "MQ" => "Martinique ", 300 | "MR" => "Mauritania", 301 | "MU" => "Mauritius ", 302 | "YT" => "Mayotte ", 303 | "MX" => "Mexico ", 304 | "FM" => "Micronesia, Federated States of ", 305 | "MD" => "Moldova, Republic of", 306 | "MC" => "Monaco ", 307 | "MN" => "Mongolia ", 308 | "ME" => "Montenegro ", 309 | "MS" => "Montserrat ", 310 | "MA" => "Morocco", 311 | "MZ" => "Mozambique ", 312 | "MM" => "Myanmar ", 313 | "NA" => "Namibia ", 314 | "NR" => "Nauru ", 315 | "NP" => "Nepal", 316 | "NL" => "Netherlands ", 317 | "AN" => "Netherlands Antilles ", 318 | "NC" => "New Caledonia ", 319 | "NZ" => "New Zealand ", 320 | "NI" => "Nicaragua", 321 | "NE" => "Niger ", 322 | "NG" => "Nigeria ", 323 | "NU" => "Niue ", 324 | "NF" => "Norfolk Island ", 325 | "MP" => "Northern Mariana Islands", 326 | "NO" => "Norway ", 327 | "OM" => "Oman ", 328 | "PK" => "Pakistan ", 329 | "PW" => "Palau ", 330 | "PS" => "Palestinian Territory, Occupied", 331 | "PA" => "Panama ", 332 | "PG" => "Papua New Guinea ", 333 | "PY" => "Paraguay ", 334 | "PE" => "Peru ", 335 | "PH" => "Philippines", 336 | "PN" => "Pitcairn ", 337 | "PL" => "Poland ", 338 | "PT" => "Portugal ", 339 | "PR" => "Puerto Rico ", 340 | "QA" => "Qatar", 341 | "RE" => "Réunion ", 342 | "RO" => "Romania ", 343 | "RU" => "Russian Federation ", 344 | "RW" => "Rwanda ", 345 | "SH" => "Saint Helena", 346 | "KN" => "Saint Kitts and Nevis ", 347 | "LC" => "Saint Lucia ", 348 | "PM" => "Saint Pierre and Miquelon ", 349 | "VC" => "Saint Vincent and the Grenadines ", 350 | "WS" => "Samoa", 351 | "SM" => "San Marino ", 352 | "ST" => "Sao Tome and Principe ", 353 | "SA" => "Saudi Arabia ", 354 | "SN" => "Senegal ", 355 | "RS" => "Serbia", 356 | "SC" => "Seychelles ", 357 | "SL" => "Sierra Leone ", 358 | "SG" => "Singapore ", 359 | "SK" => "Slovakia ", 360 | "SI" => "Slovenia", 361 | "SB" => "Solomon Islands ", 362 | "SO" => "Somalia ", 363 | "ZA" => "South Africa ", 364 | "GS" => "South Georgia and the South Sandwich Islands", 365 | "ES" => "Spain", 366 | "LK" => "Sri Lanka ", 367 | "SD" => "Sudan", 368 | "SR" => "Suriname ", 369 | "SJ" => "Svalbard and Jan Mayen ", 370 | "SZ" => "Swaziland", 371 | "SE" => "Sweden", 372 | "CH" => "Switzerland", 373 | "SY" => "Syrian Arab Republic ", 374 | "TW" => "Taiwan, Province of China ", 375 | "TJ" => "Tajikistan", 376 | "TZ" => "Tanzania, United Republic of ", 377 | "TH" => "Thailand ", 378 | "TL" => "Timor-Leste ", 379 | "TG" => "Togo ", 380 | "TK" => "Tokelau", 381 | "TO" => "Tonga ", 382 | "TT" => "Trinidad and Tobago ", 383 | "TN" => "Tunisia ", 384 | "TR" => "Turkey ", 385 | "TM" => "Turkmenistan", 386 | "TC" => "Turks and Caicos Islands ", 387 | "TV" => "Tuvalu ", 388 | "UG" => "Uganda ", 389 | "UA" => "Ukraine ", 390 | "AE" => "United Arab Emirates", 391 | "GB" => "United Kingdom ", 392 | "US" => "United States ", 393 | "UM" => "United States Minor Outlying Islands ", 394 | "UY" => "Uruguay ", 395 | "UZ" => "Uzbekistan", 396 | "VU" => "Vanuatu ", 397 | "VA" => "Vatican City State ", 398 | "VE" => "Venezuela ", 399 | "VN" => "Viet Nam ", 400 | "VG" => "Virgin Islands, British ", 401 | "VI" => "Virgin Islands, U.S. ", 402 | "WF" => "Wallis and Futuna", 403 | "EH" => "Western Sahara ", 404 | "YE" => "Yemen", 405 | "CD" => "Zaire", 406 | "ZM" => "Zambia", 407 | "ZW" => "Zimbabwe", 408 | ), 409 | )); 410 | 411 | 412 | 413 | 414 | 415 | 416 | } 417 | 418 | 419 | 420 | /* 421 | * render_field() 422 | * 423 | * Create the HTML interface for your field 424 | * 425 | * @param $field (array) the $field being rendered 426 | * 427 | * @type action 428 | * @since 3.6 429 | * @date 23/01/13 430 | * 431 | * @param $field (array) the $field being edited 432 | * @return n/a 433 | */ 434 | 435 | function render_field( $field ) { 436 | 437 | 438 | /* 439 | * Review the data of $field. 440 | * This will show what data is available 441 | */ 442 | 443 | 444 | 445 | echo '
Item Name:
'; 446 | 447 | echo '
Item Description:
'; 448 | 449 | echo '
Price:
'; 450 | 451 | 452 | } 453 | 454 | 455 | /* 456 | * input_admin_enqueue_scripts() 457 | * 458 | * This action is called in the admin_enqueue_scripts action on the edit screen where your field is created. 459 | * Use this action to add CSS + JavaScript to assist your render_field() action. 460 | * 461 | * @type action (admin_enqueue_scripts) 462 | * @since 3.6 463 | * @date 23/01/13 464 | * 465 | * @param n/a 466 | * @return n/a 467 | */ 468 | 469 | 470 | 471 | function input_admin_enqueue_scripts() { 472 | 473 | $dir = plugin_dir_url( __FILE__ ); 474 | 475 | 476 | // register & include JS 477 | wp_register_script( 'acf-input-paypal_item', "{$dir}js/input.js" ); 478 | wp_enqueue_script('acf-input-paypal_item'); 479 | 480 | 481 | // register & include CSS 482 | wp_register_style( 'acf-input-paypal_item', "{$dir}css/input.css" ); 483 | wp_enqueue_style('acf-input-paypal_item'); 484 | 485 | 486 | } 487 | 488 | 489 | 490 | 491 | /* 492 | * input_admin_head() 493 | * 494 | * This action is called in the admin_head action on the edit screen where your field is created. 495 | * Use this action to add CSS and JavaScript to assist your render_field() action. 496 | * 497 | * @type action (admin_head) 498 | * @since 3.6 499 | * @date 23/01/13 500 | * 501 | * @param n/a 502 | * @return n/a 503 | */ 504 | 505 | /* 506 | 507 | function input_admin_head() { 508 | 509 | 510 | 511 | } 512 | 513 | */ 514 | 515 | 516 | /* 517 | * input_form_data() 518 | * 519 | * This function is called once on the 'input' page between the head and footer 520 | * There are 2 situations where ACF did not load during the 'acf/input_admin_enqueue_scripts' and 521 | * 'acf/input_admin_head' actions because ACF did not know it was going to be used. These situations are 522 | * seen on comments / user edit forms on the front end. This function will always be called, and includes 523 | * $args that related to the current screen such as $args['post_id'] 524 | * 525 | * @type function 526 | * @date 6/03/2014 527 | * @since 5.0.0 528 | * 529 | * @param $args (array) 530 | * @return n/a 531 | */ 532 | 533 | /* 534 | 535 | function input_form_data( $args ) { 536 | 537 | 538 | 539 | } 540 | 541 | */ 542 | 543 | 544 | /* 545 | * input_admin_footer() 546 | * 547 | * This action is called in the admin_footer action on the edit screen where your field is created. 548 | * Use this action to add CSS and JavaScript to assist your render_field() action. 549 | * 550 | * @type action (admin_footer) 551 | * @since 3.6 552 | * @date 23/01/13 553 | * 554 | * @param n/a 555 | * @return n/a 556 | */ 557 | 558 | /* 559 | 560 | function input_admin_footer() { 561 | 562 | 563 | 564 | } 565 | 566 | */ 567 | 568 | 569 | /* 570 | * field_group_admin_enqueue_scripts() 571 | * 572 | * This action is called in the admin_enqueue_scripts action on the edit screen where your field is edited. 573 | * Use this action to add CSS + JavaScript to assist your render_field_options() action. 574 | * 575 | * @type action (admin_enqueue_scripts) 576 | * @since 3.6 577 | * @date 23/01/13 578 | * 579 | * @param n/a 580 | * @return n/a 581 | */ 582 | 583 | /* 584 | 585 | function field_group_admin_enqueue_scripts() { 586 | 587 | } 588 | 589 | */ 590 | 591 | 592 | /* 593 | * field_group_admin_head() 594 | * 595 | * This action is called in the admin_head action on the edit screen where your field is edited. 596 | * Use this action to add CSS and JavaScript to assist your render_field_options() action. 597 | * 598 | * @type action (admin_head) 599 | * @since 3.6 600 | * @date 23/01/13 601 | * 602 | * @param n/a 603 | * @return n/a 604 | */ 605 | 606 | /* 607 | 608 | function field_group_admin_head() { 609 | 610 | } 611 | 612 | */ 613 | 614 | 615 | /* 616 | * load_value() 617 | * 618 | * This filter is applied to the $value after it is loaded from the db 619 | * 620 | * @type filter 621 | * @since 3.6 622 | * @date 23/01/13 623 | * 624 | * @param $value (mixed) the value found in the database 625 | * @param $post_id (mixed) the $post_id from which the value was loaded 626 | * @param $field (array) the field array holding all the field options 627 | * @return $value 628 | */ 629 | 630 | 631 | 632 | function load_value( $value, $post_id, $field ) { 633 | 634 | return $value; 635 | 636 | } 637 | 638 | 639 | 640 | 641 | /* 642 | * update_value() 643 | * 644 | * This filter is applied to the $value before it is saved in the db 645 | * 646 | * @type filter 647 | * @since 3.6 648 | * @date 23/01/13 649 | * 650 | * @param $value (mixed) the value found in the database 651 | * @param $post_id (mixed) the $post_id from which the value was loaded 652 | * @param $field (array) the field array holding all the field options 653 | * @return $value 654 | */ 655 | 656 | 657 | 658 | function update_value( $value, $post_id, $field ) { 659 | 660 | // making sure value is a number / converting number with two decimal places at all times. 661 | $value['price'] = floatval($value['price']); 662 | $value['price'] = number_format($value['price'], 2, '.', ''); 663 | 664 | return $value; 665 | 666 | } 667 | 668 | 669 | 670 | 671 | /* 672 | * format_value() 673 | * 674 | * This filter is appied to the $value after it is loaded from the db and before it is returned to the template 675 | * 676 | * @type filter 677 | * @since 3.6 678 | * @date 23/01/13 679 | * 680 | * @param $value (mixed) the value which was loaded from the database 681 | * @param $post_id (mixed) the $post_id from which the value was loaded 682 | * @param $field (array) the field array holding all the field options 683 | * 684 | * @return $value (mixed) the modified value 685 | */ 686 | 687 | 688 | 689 | function format_value( $value, $post_id, $field ) { 690 | 691 | // bail early if no value 692 | if( empty($value) ) { 693 | 694 | return $value; 695 | 696 | } 697 | 698 | $field = array_merge($this->defaults, $field); 699 | $enable_qty = isset($field['enable_quantity']) ? $field['enable_quantity'] : '1'; 700 | $button_label = ( isset($field['button_label']) && $field['button_label'] != "" ) ? $field['button_label'] : __("Pay Now",'acf'); 701 | 702 | $output='
'; 703 | $output.='
'.$value['item_name'].'
'; 704 | $output.='
'.nl2br($value['item_description']).'
'; 705 | 706 | $output.='
Price: '. $value['price'] .' '.$field['currency'].'
'; 707 | 708 | $output.=' 709 | 710 | 711 | 712 | 713 | 714 | 715 | '; 716 | 717 | if($enable_qty == 1){ 718 | 719 | $output.='
Qty:
'; 720 | } 721 | 722 | $output.=' 723 | 724 |
'; 725 | 726 | return $output; 727 | 728 | } 729 | 730 | 731 | 732 | 733 | /* 734 | * validate_value() 735 | * 736 | * This filter is used to perform validation on the value prior to saving. 737 | * All values are validated regardless of the field's required setting. This allows you to validate and return 738 | * messages to the user if the value is not correct 739 | * 740 | * @type filter 741 | * @date 11/02/2014 742 | * @since 5.0.0 743 | * 744 | * @param $valid (boolean) validation status based on the value and the field's required setting 745 | * @param $value (mixed) the $_POST value 746 | * @param $field (array) the field array holding all the field options 747 | * @param $input (string) the corresponding input name for $_POST value 748 | * @return $valid 749 | */ 750 | 751 | /* 752 | 753 | function validate_value( $valid, $value, $field, $input ){ 754 | 755 | // Basic usage 756 | if( $value < $field['custom_minimum_setting'] ) 757 | { 758 | $valid = false; 759 | } 760 | 761 | 762 | // Advanced usage 763 | if( $value < $field['custom_minimum_setting'] ) 764 | { 765 | $valid = __('The value is too little!','acf-paypal_item'), 766 | } 767 | 768 | 769 | // return 770 | return $valid; 771 | 772 | } 773 | 774 | */ 775 | 776 | 777 | /* 778 | * delete_value() 779 | * 780 | * This action is fired after a value has been deleted from the db. 781 | * Please note that saving a blank value is treated as an update, not a delete 782 | * 783 | * @type action 784 | * @date 6/03/2014 785 | * @since 5.0.0 786 | * 787 | * @param $post_id (mixed) the $post_id from which the value was deleted 788 | * @param $key (string) the $meta_key which the value was deleted 789 | * @return n/a 790 | */ 791 | 792 | /* 793 | 794 | function delete_value( $post_id, $key ) { 795 | 796 | 797 | 798 | } 799 | 800 | */ 801 | 802 | 803 | 804 | /* 805 | * load_field() 806 | * 807 | * This filter is applied to the $field after it is loaded from the database 808 | * 809 | * @type filter 810 | * @date 23/01/2013 811 | * @since 3.6.0 812 | * 813 | * @param $field (array) the field array holding all the field options 814 | * @return $field 815 | */ 816 | 817 | 818 | 819 | function load_field( $field ) { 820 | 821 | 822 | return $field; 823 | 824 | } 825 | 826 | 827 | 828 | 829 | /* 830 | * update_field() 831 | * 832 | * This filter is applied to the $field before it is saved to the database 833 | * 834 | * @type filter 835 | * @date 23/01/2013 836 | * @since 3.6.0 837 | * 838 | * @param $field (array) the field array holding all the field options 839 | * @return $field 840 | */ 841 | 842 | /* 843 | 844 | function update_field( $field ) { 845 | 846 | return $field; 847 | 848 | } 849 | 850 | */ 851 | 852 | 853 | /* 854 | * delete_field() 855 | * 856 | * This action is fired after a field is deleted from the database 857 | * 858 | * @type action 859 | * @date 11/02/2014 860 | * @since 5.0.0 861 | * 862 | * @param $field (array) the field array holding all the field options 863 | * @return n/a 864 | */ 865 | 866 | /* 867 | 868 | function delete_field( $field ) { 869 | 870 | 871 | 872 | } 873 | 874 | */ 875 | 876 | 877 | } 878 | 879 | 880 | // create field 881 | new acf_field_paypal_item(); 882 | 883 | ?> 884 | -------------------------------------------------------------------------------- /paypal_item-v3.php: -------------------------------------------------------------------------------- 1 | name = 'paypalitem_field'; // variable name (no spaces / special characters / etc) 24 | $this->title = __("PayPal Item",'acf'); // field label (Displayed in edit screens) 25 | 26 | } 27 | 28 | 29 | /*-------------------------------------------------------------------------------------- 30 | * 31 | * create_options 32 | * - this function is called from core/field_meta_box.php to create extra options 33 | * for your field 34 | * 35 | * @params 36 | * - $key (int) - the $_POST obejct key required to save the options to the field 37 | * - $field (array) - the field object 38 | * 39 | * @author Elliot Condon 40 | * @since 2.2.0 41 | * 42 | *-------------------------------------------------------------------------------------*/ 43 | 44 | function create_options($key, $field) 45 | { 46 | // default variables 47 | $field['paypal_email'] = isset($field['paypal_email']) ? $field['paypal_email'] : ''; 48 | $button_label = ( isset($field['button_label']) && $field['button_label'] != "" ) ? $field['button_label'] : __("Pay Now",'acf'); 49 | $field['enable_quantity'] = isset($field['enable_quantity']) ? $field['enable_quantity'] : '1'; 50 | $field['currency'] = isset($field['currency']) ? $field['currency'] : 'USD'; 51 | $field['country'] = isset($field['currency']) ? $field['currency'] : 'US'; 52 | 53 | ?> 54 | 55 | 56 | 57 | 58 | 59 |

60 | 61 | 62 | parent->create_field(array( 64 | 'type' => 'text', 65 | 'name' => 'fields['.$key.'][paypal_email]', 66 | 'value' => $field['paypal_email'], 67 | )); 68 | ?> 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 |

Default: Pay Now

Note: Use the CSS class (.item-field_button) to customize look of your button.",'acf'); ?>

78 | 79 | 80 | parent->create_field(array( 82 | 'type' => 'text', 83 | 'name' => 'fields['.$key.'][button_label]', 84 | 'value' => $field['button_label'], 85 | )); 86 | ?> 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 |

Allows user to change quantity on the front-end.

97 | 98 | 99 | parent->create_field(array( 100 | 'type' => 'radio', 101 | 'name' => 'fields[' . $key . '][enable_quantity]', 102 | 'value' => $field['enable_quantity'], 103 | 'choices' => array( 104 | '1' => 'Yes', 105 | '0' => 'No', 106 | ), 107 | 'layout' => 'horizontal', 108 | )); 109 | ?> 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 |

Select Country Default: (US) - United States

119 | 120 | 121 | parent->create_field(array( 122 | 'type' => 'select', 123 | 'name' => 'fields[' . $key . '][country]', 124 | 'value' => $field['country'], 125 | 'choices' => array( 126 | "US" => "United States ", 127 | "AX" => "Åland Islands", 128 | "AL" => "Albania ", 129 | "DZ" => "Algeria ", 130 | "AS" => "American Samoa", 131 | "AD" => "Andorra", 132 | "AO" => "Angola ", 133 | "AI" => "Anguilla ", 134 | "AQ" => "Antarctica ", 135 | "AG" => "Antigua and Barbuda ", 136 | "AR" => "Argentina", 137 | "AU" => "Australia ", 138 | "AT" => "Austria ", 139 | "AZ" => "Azerbaijan", 140 | "BS" => "Bahamas ", 141 | "BH" => "Bahrain ", 142 | "BD" => "Bangladesh ", 143 | "BB" => "Barbados ", 144 | "BY" => "Belarus", 145 | "BE" => "Belgium ", 146 | "BZ" => "Belize ", 147 | "BJ" => "Benin ", 148 | "BM" => "Bermuda ", 149 | "BT" => "Bhutan", 150 | "BO" => "Bolivia ", 151 | "BA" => "Bosnia and Herzegovina ", 152 | "BW" => "Botswana ", 153 | "BV" => "Bouvet Island ", 154 | "BR" => "Brazil", 155 | "IO" => "British Indian Ocean Territory ", 156 | "BN" => "Brunei Darussalam ", 157 | "BG" => "Bulgaria ", 158 | "BF" => "Burkina Faso ", 159 | "BI" => "Burundi", 160 | "KH" => "Cambodia ", 161 | "CM" => "Cameroon ", 162 | "CA" => "Canada ", 163 | "CV" => "Cape Verde ", 164 | "KY" => "Cayman Islands ", 165 | "CF" => "Central African Republic ", 166 | "TD" => "Chad ", 167 | "CL" => "Chile ", 168 | "CN" => "China ", 169 | "CX" => "Christmas Island", 170 | "CC" => "Cocos (Keeling) Islands ", 171 | "CO" => "Colombia ", 172 | "KM" => "Comoros ", 173 | "CG" => "Congo ", 174 | "CD" => "Congo, the Democratic Republic of the", 175 | "CK" => "Cook Islands ", 176 | "CR" => "Costa Rica ", 177 | "CI" => "Côte D'Ivoire", 178 | "HR" => "Croatia ", 179 | "CU" => "Cuba ", 180 | "CY" => "Cyprus ", 181 | "CZ" => "Czech Republic ", 182 | "DK" => "Denmark", 183 | "DJ" => "Djibouti ", 184 | "DM" => "Dominica ", 185 | "DO" => "Dominican Republic ", 186 | "EC" => "Ecuador ", 187 | "EG" => "Egypt", 188 | "SV" => "El Salvador ", 189 | "GQ" => "Equatorial Guinea ", 190 | "ER" => "Eritrea ", 191 | "EE" => "Estonia ", 192 | "ET" => "Ethiopia ", 193 | "FK" => "Falkland Islands (Malvinas) ", 194 | "FO" => "Faroe Islands ", 195 | "FJ" => "Fiji ", 196 | "FI" => "Finland ", 197 | "FR" => "France", 198 | "GF" => "French Guiana ", 199 | "PF" => "French Polynesia ", 200 | "TF" => "French Southern Territories ", 201 | "GA" => "Gabon ", 202 | "GM" => "Gambia ", 203 | "GE" => "Georgia ", 204 | "DE" => "Germany ", 205 | "GH" => "Ghana ", 206 | "GI" => "Gibraltar ", 207 | "GR" => "Greece", 208 | "GL" => "Greenland ", 209 | "GD" => "Grenada ", 210 | "GP" => "Guadeloupe ", 211 | "GU" => "Guam ", 212 | "GT" => "Guatemala", 213 | "GG" => "Guernsey ", 214 | "GN" => "Guinea ", 215 | "GW" => "Guinea-Bissau ", 216 | "GY" => "Guyana ", 217 | "HT" => "Haiti", 218 | "HM" => "Heard Island and Mcdonald Islands ", 219 | "VA" => "Holy See (Vatican City State) ", 220 | "HN" => "Honduras ", 221 | "HK" => "Hong Kong ", 222 | "HU" => "Hungary", 223 | "IS" => "Iceland ", 224 | "IN" => "India ", 225 | "ID" => "Indonesia ", 226 | "IR" => "Iran, Islamic Republic of ", 227 | "IQ" => "Iraq ", 228 | "IE" => "Ireland ", 229 | "IM" => "Isle of Man ", 230 | "IL" => "Israel ", 231 | "IT" => "Italy ", 232 | "JM" => "Jamaica", 233 | "JP" => "Japan ", 234 | "JE" => "Jersey ", 235 | "JO" => "Jordan ", 236 | "KZ" => "Kazakhstan ", 237 | "KE" => "KENYA", 238 | "KI" => "Kiribati ", 239 | "KP" => "Korea, Democratic People's Republic of ", 240 | "KR" => "Korea, Republic of ", 241 | "KW" => "Kuwait ", 242 | "KG" => "Kyrgyzstan", 243 | "LA" => "Lao People's Democratic Republic ", 244 | "LV" => "Latvia ", 245 | "LB" => "Lebanon ", 246 | "LS" => "Lesotho ", 247 | "LR" => "Liberia", 248 | "LY" => "Libyan Arab Jamahiriya ", 249 | "LI" => "Liechtenstein ", 250 | "LT" => "Lithuania ", 251 | "LU" => "Luxembourg ", 252 | "MO" => "Macao", 253 | "MK" => "Macedonia, the Former Yugoslav Republic of ", 254 | "MG" => "Madagascar ", 255 | "MW" => "Malawi ", 256 | "MY" => "Malaysia ", 257 | "MV" => "Maldives", 258 | "ML" => "Mali ", 259 | "MT" => "Malta ", 260 | "MH" => "Marshall Islands ", 261 | "MQ" => "Martinique ", 262 | "MR" => "Mauritania", 263 | "MU" => "Mauritius ", 264 | "YT" => "Mayotte ", 265 | "MX" => "Mexico ", 266 | "FM" => "Micronesia, Federated States of ", 267 | "MD" => "Moldova, Republic of", 268 | "MC" => "Monaco ", 269 | "MN" => "Mongolia ", 270 | "ME" => "Montenegro ", 271 | "MS" => "Montserrat ", 272 | "MA" => "Morocco", 273 | "MZ" => "Mozambique ", 274 | "MM" => "Myanmar ", 275 | "NA" => "Namibia ", 276 | "NR" => "Nauru ", 277 | "NP" => "Nepal", 278 | "NL" => "Netherlands ", 279 | "AN" => "Netherlands Antilles ", 280 | "NC" => "New Caledonia ", 281 | "NZ" => "New Zealand ", 282 | "NI" => "Nicaragua", 283 | "NE" => "Niger ", 284 | "NG" => "Nigeria ", 285 | "NU" => "Niue ", 286 | "NF" => "Norfolk Island ", 287 | "MP" => "Northern Mariana Islands", 288 | "NO" => "Norway ", 289 | "OM" => "Oman ", 290 | "PK" => "Pakistan ", 291 | "PW" => "Palau ", 292 | "PS" => "Palestinian Territory, Occupied", 293 | "PA" => "Panama ", 294 | "PG" => "Papua New Guinea ", 295 | "PY" => "Paraguay ", 296 | "PE" => "Peru ", 297 | "PH" => "Philippines", 298 | "PN" => "Pitcairn ", 299 | "PL" => "Poland ", 300 | "PT" => "Portugal ", 301 | "PR" => "Puerto Rico ", 302 | "QA" => "Qatar", 303 | "RE" => "Réunion ", 304 | "RO" => "Romania ", 305 | "RU" => "Russian Federation ", 306 | "RW" => "Rwanda ", 307 | "SH" => "Saint Helena", 308 | "KN" => "Saint Kitts and Nevis ", 309 | "LC" => "Saint Lucia ", 310 | "PM" => "Saint Pierre and Miquelon ", 311 | "VC" => "Saint Vincent and the Grenadines ", 312 | "WS" => "Samoa", 313 | "SM" => "San Marino ", 314 | "ST" => "Sao Tome and Principe ", 315 | "SA" => "Saudi Arabia ", 316 | "SN" => "Senegal ", 317 | "RS" => "Serbia", 318 | "SC" => "Seychelles ", 319 | "SL" => "Sierra Leone ", 320 | "SG" => "Singapore ", 321 | "SK" => "Slovakia ", 322 | "SI" => "Slovenia", 323 | "SB" => "Solomon Islands ", 324 | "SO" => "Somalia ", 325 | "ZA" => "South Africa ", 326 | "GS" => "South Georgia and the South Sandwich Islands", 327 | "ES" => "Spain", 328 | "LK" => "Sri Lanka ", 329 | "SD" => "Sudan", 330 | "SR" => "Suriname ", 331 | "SJ" => "Svalbard and Jan Mayen ", 332 | "SZ" => "Swaziland", 333 | "SE" => "Sweden", 334 | "CH" => "Switzerland", 335 | "SY" => "Syrian Arab Republic ", 336 | "TW" => "Taiwan, Province of China ", 337 | "TJ" => "Tajikistan", 338 | "TZ" => "Tanzania, United Republic of ", 339 | "TH" => "Thailand ", 340 | "TL" => "Timor-Leste ", 341 | "TG" => "Togo ", 342 | "TK" => "Tokelau", 343 | "TO" => "Tonga ", 344 | "TT" => "Trinidad and Tobago ", 345 | "TN" => "Tunisia ", 346 | "TR" => "Turkey ", 347 | "TM" => "Turkmenistan", 348 | "TC" => "Turks and Caicos Islands ", 349 | "TV" => "Tuvalu ", 350 | "UG" => "Uganda ", 351 | "UA" => "Ukraine ", 352 | "AE" => "United Arab Emirates", 353 | "GB" => "United Kingdom ", 354 | "US" => "United States ", 355 | "UM" => "United States Minor Outlying Islands ", 356 | "UY" => "Uruguay ", 357 | "UZ" => "Uzbekistan", 358 | "VU" => "Vanuatu ", 359 | "VA" => "Vatican City State ", 360 | "VE" => "Venezuela ", 361 | "VN" => "Viet Nam ", 362 | "VG" => "Virgin Islands, British ", 363 | "VI" => "Virgin Islands, U.S. ", 364 | "WF" => "Wallis and Futuna", 365 | "EH" => "Western Sahara ", 366 | "YE" => "Yemen", 367 | "CD" => "Zaire", 368 | "ZM" => "Zambia", 369 | "ZW" => "Zimbabwe", 370 | ) 371 | )); 372 | ?> 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 |

Select Currency

382 | 383 | 384 | parent->create_field(array( 385 | 'type' => 'select', 386 | 'name' => 'fields[' . $key . '][currency]', 387 | 'value' => $field['currency'], 388 | 'choices' => array( 389 | 'USD' => 'USD - United States Dollars', 390 | 'AUD' => 'AUD - Australian Dollars', 391 | 'CAD' => 'CAD - Canadian Dollars', 392 | 'CHF' => 'CHF - Swiss Franc', 393 | 'CZK' => 'CZK - Czech Koruna', 394 | 'DKK' => 'DKK - Danish Krone', 395 | 'EUR' => 'EUR - Euros', 396 | 'GBP' => 'GBP - Pounds Sterling', 397 | 'HDK' => 'HDK - Hong Kong Dollar', 398 | 'HUF' => 'HUF - Hungarian Forint', 399 | 'ILS' => 'ILS - Israeli Shekel', 400 | 'JPY' => 'JPY - Japanese Yen', 401 | 'MXN' => 'MXN - Mexican Peso', 402 | 'NOK' => 'NOK - Norwegian Krone', 403 | 'NZD' => 'NZD - New Zealand Dollar', 404 | 'PLN' => 'PLN - Polish Zloty', 405 | 'SEK' => 'SEK - Swedish Krona', 406 | 'SGD' => 'SGD - Singapore Dollar', 407 | 'USD' => 'USD - United States Dollars' 408 | ) 409 | )); 410 | ?> 411 | 412 | 413 | 414 | Item Name:
'; 433 | 434 | echo '
Item Description:
'; 435 | 436 | echo '
Price:
'; 437 | 438 | } 439 | 440 | 441 | /*-------------------------------------------------------------------------------------- 442 | * 443 | * admin_head 444 | * - this function is called in the admin_head of the edit screen where your field 445 | * is created. Use this function to create css and javascript to assist your 446 | * create_field() function. 447 | * 448 | * @author Elliot Condon 449 | * @since 2.2.0 450 | * 451 | *-------------------------------------------------------------------------------------*/ 452 | 453 | function admin_head() 454 | { 455 | ?> 456 | 461 | get_value($post_id, $field); 541 | 542 | // default variables 543 | $enable_qty = isset($field['enable_quantity']) ? $field['enable_quantity'] : '1'; 544 | $button_label = ( isset($field['button_label']) && $field['button_label'] != "" ) ? $field['button_label'] : __("Pay Now",'acf'); 545 | 546 | ?> 547 | 548 |
549 | 550 | 551 |
552 | 553 |
554 |
Price:
555 | 556 | 557 | 558 | 559 | 560 |
Qty:
561 | 562 | 563 |
564 | -------------------------------------------------------------------------------- /paypal_item-v4.php: -------------------------------------------------------------------------------- 1 | name = 'paypal_item'; 23 | $this->label = __('PayPal Item'); 24 | $this->category = __("Content",'acf'); // Basic, Content, Choice, etc 25 | $this->defaults = array( 26 | // add default here to merge into your field. 27 | // This makes life easy when creating the field options as you don't need to use any if( isset('') ) logic. eg: 28 | //'preview_size' => 'thumbnail' 29 | ); 30 | 31 | 32 | // do not delete! 33 | parent::__construct(); 34 | 35 | 36 | // settings 37 | $this->settings = array( 38 | 'path' => apply_filters('acf/helpers/get_path', __FILE__), 39 | 'dir' => apply_filters('acf/helpers/get_dir', __FILE__), 40 | 'version' => '1.1.0' 41 | ); 42 | 43 | } 44 | 45 | 46 | /* 47 | * create_options() 48 | * 49 | * Create extra options for your field. This is rendered when editing a field. 50 | * The value of $field['name'] can be used (like bellow) to save extra data to the $field 51 | * 52 | * @type action 53 | * @since 3.6 54 | * @date 23/01/13 55 | * 56 | * @param $field - an array holding all the field's data 57 | */ 58 | 59 | function create_options( $field ) 60 | { 61 | // defaults? 62 | $field = array_merge($this->defaults, $field); 63 | $field['paypal_email'] = isset($field['paypal_email']) ? $field['paypal_email'] : ''; 64 | $button_label = ( isset($field['button_label']) && $field['button_label'] != "" ) ? $field['button_label'] : __("Pay Now",'acf'); 65 | $field['enable_quantity'] = isset($field['enable_quantity']) ? $field['enable_quantity'] : '1'; 66 | $field['currency'] = isset($field['currency']) ? $field['currency'] : 'USD'; 67 | $field['country'] = isset($field['currency']) ? $field['currency'] : 'US'; 68 | $field['button_label'] = ( isset($field['button_label']) && $field['button_label'] != "" ) ? $field['button_label'] : __("Pay Now",'acf'); 69 | 70 | // key is needed in the field names to correctly save the data 71 | $key = $field['name']; 72 | 73 | 74 | // Create Field Options HTML 75 | ?> 76 | 77 | 78 | 79 | 80 |

81 | 82 | 83 | 'text', 86 | 'name' => 'fields[' .$key.'][paypal_email]', 87 | 'value' => $field['paypal_email'], 88 | )); 89 | ?> 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 |

Default: Pay Now

Note: Use the CSS class (.item-field_button) to customize look of your button.",'acf'); ?>

99 | 100 | 101 | 'text', 104 | 'name' => 'fields[' .$key.'][button_label]', 105 | 'value' => $field['button_label'], 106 | )); 107 | ?> 108 | 109 | 110 | 111 | 112 | 113 | 114 |

115 | 116 | 117 | 'radio', 120 | 'name' => 'fields[' . $key . '][enable_quantity]', 121 | 'value' => $field['enable_quantity'], 122 | 'layout' => 'horizontal', 123 | 'choices' => array( 124 | '1' => 'Yes', 125 | '0' => 'No', 126 | ), 127 | )); 128 | ?> 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 |

143 | 144 | 145 | 'select', 148 | 'name' => 'fields[' . $key . '][currency]', 149 | 'value' => $field['currency'], 150 | 'choices' => array( 151 | 'USD' => 'USD - United States Dollars', 152 | 'AUD' => 'AUD - Australian Dollars', 153 | 'CAD' => 'CAD - Canadian Dollars', 154 | 'CHF' => 'CHF - Swiss Franc', 155 | 'CZK' => 'CZK - Czech Koruna', 156 | 'DKK' => 'DKK - Danish Krone', 157 | 'EUR' => 'EUR - Euros', 158 | 'GBP' => 'GBP - Pounds Sterling', 159 | 'HDK' => 'HDK - Hong Kong Dollar', 160 | 'HUF' => 'HUF - Hungarian Forint', 161 | 'ILS' => 'ILS - Israeli Shekel', 162 | 'JPY' => 'JPY - Japanese Yen', 163 | 'MXN' => 'MXN - Mexican Peso', 164 | 'NOK' => 'NOK - Norwegian Krone', 165 | 'NZD' => 'NZD - New Zealand Dollar', 166 | 'PLN' => 'PLN - Polish Zloty', 167 | 'SEK' => 'SEK - Swedish Krona', 168 | 'SGD' => 'SGD - Singapore Dollar', 169 | 'USD' => 'USD - United States Dollars' 170 | ) 171 | )); 172 | ?> 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 |

Default: (US) - United States ",'acf'); ?>

188 | 189 | 190 | 'select', 193 | 'name' => 'fields[' . $key . '][country]', 194 | 'value' => $field['country'], 195 | 'choices' => array( 196 | "US" => "United States ", 197 | "AX" => "Åland Islands", 198 | "AL" => "Albania ", 199 | "DZ" => "Algeria ", 200 | "AS" => "American Samoa", 201 | "AD" => "Andorra", 202 | "AO" => "Angola ", 203 | "AI" => "Anguilla ", 204 | "AQ" => "Antarctica ", 205 | "AG" => "Antigua and Barbuda ", 206 | "AR" => "Argentina", 207 | "AU" => "Australia ", 208 | "AT" => "Austria ", 209 | "AZ" => "Azerbaijan", 210 | "BS" => "Bahamas ", 211 | "BH" => "Bahrain ", 212 | "BD" => "Bangladesh ", 213 | "BB" => "Barbados ", 214 | "BY" => "Belarus", 215 | "BE" => "Belgium ", 216 | "BZ" => "Belize ", 217 | "BJ" => "Benin ", 218 | "BM" => "Bermuda ", 219 | "BT" => "Bhutan", 220 | "BO" => "Bolivia ", 221 | "BA" => "Bosnia and Herzegovina ", 222 | "BW" => "Botswana ", 223 | "BV" => "Bouvet Island ", 224 | "BR" => "Brazil", 225 | "IO" => "British Indian Ocean Territory ", 226 | "BN" => "Brunei Darussalam ", 227 | "BG" => "Bulgaria ", 228 | "BF" => "Burkina Faso ", 229 | "BI" => "Burundi", 230 | "KH" => "Cambodia ", 231 | "CM" => "Cameroon ", 232 | "CA" => "Canada ", 233 | "CV" => "Cape Verde ", 234 | "KY" => "Cayman Islands ", 235 | "CF" => "Central African Republic ", 236 | "TD" => "Chad ", 237 | "CL" => "Chile ", 238 | "CN" => "China ", 239 | "CX" => "Christmas Island", 240 | "CC" => "Cocos (Keeling) Islands ", 241 | "CO" => "Colombia ", 242 | "KM" => "Comoros ", 243 | "CG" => "Congo ", 244 | "CD" => "Congo, the Democratic Republic of the", 245 | "CK" => "Cook Islands ", 246 | "CR" => "Costa Rica ", 247 | "CI" => "Côte D'Ivoire", 248 | "HR" => "Croatia ", 249 | "CU" => "Cuba ", 250 | "CY" => "Cyprus ", 251 | "CZ" => "Czech Republic ", 252 | "DK" => "Denmark", 253 | "DJ" => "Djibouti ", 254 | "DM" => "Dominica ", 255 | "DO" => "Dominican Republic ", 256 | "EC" => "Ecuador ", 257 | "EG" => "Egypt", 258 | "SV" => "El Salvador ", 259 | "GQ" => "Equatorial Guinea ", 260 | "ER" => "Eritrea ", 261 | "EE" => "Estonia ", 262 | "ET" => "Ethiopia ", 263 | "FK" => "Falkland Islands (Malvinas) ", 264 | "FO" => "Faroe Islands ", 265 | "FJ" => "Fiji ", 266 | "FI" => "Finland ", 267 | "FR" => "France", 268 | "GF" => "French Guiana ", 269 | "PF" => "French Polynesia ", 270 | "TF" => "French Southern Territories ", 271 | "GA" => "Gabon ", 272 | "GM" => "Gambia ", 273 | "GE" => "Georgia ", 274 | "DE" => "Germany ", 275 | "GH" => "Ghana ", 276 | "GI" => "Gibraltar ", 277 | "GR" => "Greece", 278 | "GL" => "Greenland ", 279 | "GD" => "Grenada ", 280 | "GP" => "Guadeloupe ", 281 | "GU" => "Guam ", 282 | "GT" => "Guatemala", 283 | "GG" => "Guernsey ", 284 | "GN" => "Guinea ", 285 | "GW" => "Guinea-Bissau ", 286 | "GY" => "Guyana ", 287 | "HT" => "Haiti", 288 | "HM" => "Heard Island and Mcdonald Islands ", 289 | "VA" => "Holy See (Vatican City State) ", 290 | "HN" => "Honduras ", 291 | "HK" => "Hong Kong ", 292 | "HU" => "Hungary", 293 | "IS" => "Iceland ", 294 | "IN" => "India ", 295 | "ID" => "Indonesia ", 296 | "IR" => "Iran, Islamic Republic of ", 297 | "IQ" => "Iraq ", 298 | "IE" => "Ireland ", 299 | "IM" => "Isle of Man ", 300 | "IL" => "Israel ", 301 | "IT" => "Italy ", 302 | "JM" => "Jamaica", 303 | "JP" => "Japan ", 304 | "JE" => "Jersey ", 305 | "JO" => "Jordan ", 306 | "KZ" => "Kazakhstan ", 307 | "KE" => "KENYA", 308 | "KI" => "Kiribati ", 309 | "KP" => "Korea, Democratic People's Republic of ", 310 | "KR" => "Korea, Republic of ", 311 | "KW" => "Kuwait ", 312 | "KG" => "Kyrgyzstan", 313 | "LA" => "Lao People's Democratic Republic ", 314 | "LV" => "Latvia ", 315 | "LB" => "Lebanon ", 316 | "LS" => "Lesotho ", 317 | "LR" => "Liberia", 318 | "LY" => "Libyan Arab Jamahiriya ", 319 | "LI" => "Liechtenstein ", 320 | "LT" => "Lithuania ", 321 | "LU" => "Luxembourg ", 322 | "MO" => "Macao", 323 | "MK" => "Macedonia, the Former Yugoslav Republic of ", 324 | "MG" => "Madagascar ", 325 | "MW" => "Malawi ", 326 | "MY" => "Malaysia ", 327 | "MV" => "Maldives", 328 | "ML" => "Mali ", 329 | "MT" => "Malta ", 330 | "MH" => "Marshall Islands ", 331 | "MQ" => "Martinique ", 332 | "MR" => "Mauritania", 333 | "MU" => "Mauritius ", 334 | "YT" => "Mayotte ", 335 | "MX" => "Mexico ", 336 | "FM" => "Micronesia, Federated States of ", 337 | "MD" => "Moldova, Republic of", 338 | "MC" => "Monaco ", 339 | "MN" => "Mongolia ", 340 | "ME" => "Montenegro ", 341 | "MS" => "Montserrat ", 342 | "MA" => "Morocco", 343 | "MZ" => "Mozambique ", 344 | "MM" => "Myanmar ", 345 | "NA" => "Namibia ", 346 | "NR" => "Nauru ", 347 | "NP" => "Nepal", 348 | "NL" => "Netherlands ", 349 | "AN" => "Netherlands Antilles ", 350 | "NC" => "New Caledonia ", 351 | "NZ" => "New Zealand ", 352 | "NI" => "Nicaragua", 353 | "NE" => "Niger ", 354 | "NG" => "Nigeria ", 355 | "NU" => "Niue ", 356 | "NF" => "Norfolk Island ", 357 | "MP" => "Northern Mariana Islands", 358 | "NO" => "Norway ", 359 | "OM" => "Oman ", 360 | "PK" => "Pakistan ", 361 | "PW" => "Palau ", 362 | "PS" => "Palestinian Territory, Occupied", 363 | "PA" => "Panama ", 364 | "PG" => "Papua New Guinea ", 365 | "PY" => "Paraguay ", 366 | "PE" => "Peru ", 367 | "PH" => "Philippines", 368 | "PN" => "Pitcairn ", 369 | "PL" => "Poland ", 370 | "PT" => "Portugal ", 371 | "PR" => "Puerto Rico ", 372 | "QA" => "Qatar", 373 | "RE" => "Réunion ", 374 | "RO" => "Romania ", 375 | "RU" => "Russian Federation ", 376 | "RW" => "Rwanda ", 377 | "SH" => "Saint Helena", 378 | "KN" => "Saint Kitts and Nevis ", 379 | "LC" => "Saint Lucia ", 380 | "PM" => "Saint Pierre and Miquelon ", 381 | "VC" => "Saint Vincent and the Grenadines ", 382 | "WS" => "Samoa", 383 | "SM" => "San Marino ", 384 | "ST" => "Sao Tome and Principe ", 385 | "SA" => "Saudi Arabia ", 386 | "SN" => "Senegal ", 387 | "RS" => "Serbia", 388 | "SC" => "Seychelles ", 389 | "SL" => "Sierra Leone ", 390 | "SG" => "Singapore ", 391 | "SK" => "Slovakia ", 392 | "SI" => "Slovenia", 393 | "SB" => "Solomon Islands ", 394 | "SO" => "Somalia ", 395 | "ZA" => "South Africa ", 396 | "GS" => "South Georgia and the South Sandwich Islands", 397 | "ES" => "Spain", 398 | "LK" => "Sri Lanka ", 399 | "SD" => "Sudan", 400 | "SR" => "Suriname ", 401 | "SJ" => "Svalbard and Jan Mayen ", 402 | "SZ" => "Swaziland", 403 | "SE" => "Sweden", 404 | "CH" => "Switzerland", 405 | "SY" => "Syrian Arab Republic ", 406 | "TW" => "Taiwan, Province of China ", 407 | "TJ" => "Tajikistan", 408 | "TZ" => "Tanzania, United Republic of ", 409 | "TH" => "Thailand ", 410 | "TL" => "Timor-Leste ", 411 | "TG" => "Togo ", 412 | "TK" => "Tokelau", 413 | "TO" => "Tonga ", 414 | "TT" => "Trinidad and Tobago ", 415 | "TN" => "Tunisia ", 416 | "TR" => "Turkey ", 417 | "TM" => "Turkmenistan", 418 | "TC" => "Turks and Caicos Islands ", 419 | "TV" => "Tuvalu ", 420 | "UG" => "Uganda ", 421 | "UA" => "Ukraine ", 422 | "AE" => "United Arab Emirates", 423 | "GB" => "United Kingdom ", 424 | "US" => "United States ", 425 | "UM" => "United States Minor Outlying Islands ", 426 | "UY" => "Uruguay ", 427 | "UZ" => "Uzbekistan", 428 | "VU" => "Vanuatu ", 429 | "VA" => "Vatican City State ", 430 | "VE" => "Venezuela ", 431 | "VN" => "Viet Nam ", 432 | "VG" => "Virgin Islands, British ", 433 | "VI" => "Virgin Islands, U.S. ", 434 | "WF" => "Wallis and Futuna", 435 | "EH" => "Western Sahara ", 436 | "YE" => "Yemen", 437 | "CD" => "Zaire", 438 | "ZM" => "Zambia", 439 | "ZW" => "Zimbabwe", 440 | ) 441 | )); 442 | ?> 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | defaults, $field); 476 | */ 477 | 478 | // perhaps use $field['preview_size'] to alter the markup? 479 | 480 | 481 | // create Field HTML 482 | 483 | 484 | echo '
Item Name:
'; 485 | 486 | echo '
Item Description:
'; 487 | 488 | echo '
Price:
'; 489 | 490 | ?> 491 | 492 | settings['dir'] . 'js/input.js', array('acf-input'), $this->settings['version'] ); 515 | wp_register_style( 'acf-input-paypal_item', $this->settings['dir'] . 'css/input.css', array('acf-input'), $this->settings['version'] ); 516 | 517 | 518 | // scripts 519 | wp_enqueue_script(array( 520 | 'acf-input-paypal_item', 521 | )); 522 | 523 | // styles 524 | wp_enqueue_style(array( 525 | 'acf-input-paypal_item', 526 | )); 527 | 528 | 529 | } 530 | 531 | 532 | /* 533 | * input_admin_head() 534 | * 535 | * This action is called in the admin_head action on the edit screen where your field is created. 536 | * Use this action to add css and javascript to assist your create_field() action. 537 | * 538 | * @info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_head 539 | * @type action 540 | * @since 3.6 541 | * @date 23/01/13 542 | */ 543 | 544 | function input_admin_head() 545 | { 546 | // Note: This function can be removed if not used 547 | } 548 | 549 | 550 | /* 551 | * field_group_admin_enqueue_scripts() 552 | * 553 | * This action is called in the admin_enqueue_scripts action on the edit screen where your field is edited. 554 | * Use this action to add css + javascript to assist your create_field_options() action. 555 | * 556 | * $info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts 557 | * @type action 558 | * @since 3.6 559 | * @date 23/01/13 560 | */ 561 | 562 | function field_group_admin_enqueue_scripts() 563 | { 564 | // Note: This function can be removed if not used 565 | } 566 | 567 | 568 | /* 569 | * field_group_admin_head() 570 | * 571 | * This action is called in the admin_head action on the edit screen where your field is edited. 572 | * Use this action to add css and javascript to assist your create_field_options() action. 573 | * 574 | * @info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_head 575 | * @type action 576 | * @since 3.6 577 | * @date 23/01/13 578 | */ 579 | 580 | function field_group_admin_head() 581 | { 582 | // Note: This function can be removed if not used 583 | } 584 | 585 | 586 | /* 587 | * load_value() 588 | * 589 | * This filter is appied to the $value after it is loaded from the db 590 | * 591 | * @type filter 592 | * @since 3.6 593 | * @date 23/01/13 594 | * 595 | * @param $value - the value found in the database 596 | * @param $post_id - the $post_id from which the value was loaded from 597 | * @param $field - the field array holding all the field options 598 | * 599 | * @return $value - the value to be saved in te database 600 | */ 601 | 602 | function load_value( $value, $post_id, $field ) 603 | { 604 | // Note: This function can be removed if not used 605 | return $value; 606 | } 607 | 608 | 609 | /* 610 | * update_value() 611 | * 612 | * This filter is appied to the $value before it is updated in the db 613 | * 614 | * @type filter 615 | * @since 3.6 616 | * @date 23/01/13 617 | * 618 | * @param $value - the value which will be saved in the database 619 | * @param $field - the field array holding all the field options 620 | * @param $post_id - the $post_id of which the value will be saved 621 | * 622 | * @return $value - the modified value 623 | */ 624 | 625 | function update_value( $value, $field, $post_id ) 626 | { 627 | // Note: This function can be removed if not used 628 | 629 | // making sure value is a number / converting number with two decimal places at all times. 630 | $value['price'] = floatval($value['price']); 631 | $value['price'] = number_format($value['price'], 2, '.', ''); 632 | 633 | return $value; 634 | } 635 | 636 | 637 | /* 638 | * format_value() 639 | * 640 | * This filter is appied to the $value after it is loaded from the db and before it is passed to the create_field action 641 | * 642 | * @type filter 643 | * @since 3.6 644 | * @date 23/01/13 645 | * 646 | * @param $value - the value which was loaded from the database 647 | * @param $post_id - the $post_id from which the value was loaded 648 | * @param $field - the field array holding all the field options 649 | * 650 | * @return $value - the modified value 651 | */ 652 | 653 | function format_value( $value, $post_id, $field ) 654 | { 655 | // defaults? 656 | /* 657 | $field = array_merge($this->defaults, $field); 658 | */ 659 | 660 | // perhaps use $field['preview_size'] to alter the $value? 661 | 662 | 663 | // Note: This function can be removed if not used 664 | return $value; 665 | } 666 | 667 | 668 | /* 669 | * format_value_for_api() 670 | * 671 | * This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field 672 | * 673 | * @type filter 674 | * @since 3.6 675 | * @date 23/01/13 676 | * 677 | * @param $value - the value which was loaded from the database 678 | * @param $post_id - the $post_id from which the value was loaded 679 | * @param $field - the field array holding all the field options 680 | * 681 | * @return $value - the modified value 682 | */ 683 | 684 | function format_value_for_api( $value, $post_id, $field ) 685 | { 686 | // defaults? 687 | 688 | $field = array_merge($this->defaults, $field); 689 | $enable_qty = isset($field['enable_quantity']) ? $field['enable_quantity'] : '1'; 690 | $button_label = ( isset($field['button_label']) && $field['button_label'] != "" ) ? $field['button_label'] : __("Pay Now",'acf'); 691 | 692 | $output='
693 | 694 | 695 |
'.$value['item_name'].'
696 | 697 |
'.nl2br($value['item_description']).'
698 |
Price: '.$value['price'].' '.$field['currency'].'
699 | 700 | 701 | 702 | 703 | '; 704 | 705 | if($enable_qty == 1){ 706 | 707 | $output.='
Qty:
'; 708 | } 709 | 710 | $output.=' 711 | 712 |
'; 713 | 714 | return $output; 715 | 716 | // Note: This function can be removed if not used 717 | 718 | } 719 | 720 | 721 | /* 722 | * load_field() 723 | * 724 | * This filter is appied to the $field after it is loaded from the database 725 | * 726 | * @type filter 727 | * @since 3.6 728 | * @date 23/01/13 729 | * 730 | * @param $field - the field array holding all the field options 731 | * 732 | * @return $field - the field array holding all the field options 733 | */ 734 | 735 | function load_field( $field ) 736 | { 737 | // Note: This function can be removed if not used 738 | return $field; 739 | } 740 | 741 | 742 | /* 743 | * update_field() 744 | * 745 | * This filter is appied to the $field before it is saved to the database 746 | * 747 | * @type filter 748 | * @since 3.6 749 | * @date 23/01/13 750 | * 751 | * @param $field - the field array holding all the field options 752 | * @param $post_id - the field group ID (post_type = acf) 753 | * 754 | * @return $field - the modified field 755 | */ 756 | 757 | function update_field( $field, $post_id ) 758 | { 759 | // Note: This function can be removed if not used 760 | return $field; 761 | } 762 | 763 | 764 | } 765 | 766 | 767 | // create field 768 | new acf_field_paypal_item(); 769 | 770 | ?> 771 | --------------------------------------------------------------------------------