├── .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
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='';
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 |
--------------------------------------------------------------------------------