Version Description
- New Gutemberg block
=
Download this release
Release Info
Developer | codepeople |
Plugin | Payment Form for PayPal Pro |
Version | 1.1.46 |
Comparing to | |
See all releases |
Code changes from version 1.1.45 to 1.1.46
- README.txt +5 -2
- cp_ppp.php +66 -1
- images/cp_form.gif +0 -0
- js/block.js +119 -0
README.txt
CHANGED
@@ -266,7 +266,10 @@ A: In all plugin versions you can turn off IP tracking to avoid saving that user
|
|
266 |
= 1.1.45 =
|
267 |
* Compatible with WordPress 5.0
|
268 |
|
|
|
|
|
|
|
269 |
== Upgrade Notice ==
|
270 |
|
271 |
-
= 1.1.
|
272 |
-
*
|
266 |
= 1.1.45 =
|
267 |
* Compatible with WordPress 5.0
|
268 |
|
269 |
+
= 1.1.46 =
|
270 |
+
* New Gutemberg block
|
271 |
+
|
272 |
== Upgrade Notice ==
|
273 |
|
274 |
+
= 1.1.46 =
|
275 |
+
* New Gutemberg block
|
cp_ppp.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Payment Form for PayPal Pro
|
4 |
Plugin URI: https://wordpress.dwbooster.com/forms/paypal-payment-pro-form
|
5 |
Description: Payment Form for PayPal Pro to accept credit cards directly into your website. Official PayPal Partner.
|
6 |
-
Version: 1.1.
|
7 |
Author: CodePeople
|
8 |
Author URI: https://wordpress.dwbooster.com/forms/payment-form-for-paypal-pro
|
9 |
License: GPL
|
@@ -130,6 +130,7 @@ if ( is_admin() ) {
|
|
130 |
add_action('media_buttons', 'set_cp_ppp_insert_button', 100);
|
131 |
add_action('admin_enqueue_scripts', 'set_cp_ppp_insert_adminScripts', 1);
|
132 |
add_action('admin_menu', 'cp_ppp_admin_menu');
|
|
|
133 |
|
134 |
$plugin = plugin_basename(__FILE__);
|
135 |
add_filter("plugin_action_links_".$plugin, 'cp_ppp_customAdjustmentsLink');
|
@@ -148,6 +149,21 @@ if ( is_admin() ) {
|
|
148 |
add_shortcode( 'CP_PPP_LIST', 'cp_ppp_filter_list' );
|
149 |
}
|
150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
// functions
|
153 |
//------------------------------------------
|
@@ -435,6 +451,55 @@ function cp_ppp_available_templates(){
|
|
435 |
return $CP_CFPP_global_templates;
|
436 |
}
|
437 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
438 |
function cp_ppp_filter_content($atts) {
|
439 |
global $wpdb;
|
440 |
extract( shortcode_atts( array(
|
3 |
Plugin Name: Payment Form for PayPal Pro
|
4 |
Plugin URI: https://wordpress.dwbooster.com/forms/paypal-payment-pro-form
|
5 |
Description: Payment Form for PayPal Pro to accept credit cards directly into your website. Official PayPal Partner.
|
6 |
+
Version: 1.1.46
|
7 |
Author: CodePeople
|
8 |
Author URI: https://wordpress.dwbooster.com/forms/payment-form-for-paypal-pro
|
9 |
License: GPL
|
130 |
add_action('media_buttons', 'set_cp_ppp_insert_button', 100);
|
131 |
add_action('admin_enqueue_scripts', 'set_cp_ppp_insert_adminScripts', 1);
|
132 |
add_action('admin_menu', 'cp_ppp_admin_menu');
|
133 |
+
add_action('enqueue_block_editor_assets', 'cp_ppp_gutenberg_block' );
|
134 |
|
135 |
$plugin = plugin_basename(__FILE__);
|
136 |
add_filter("plugin_action_links_".$plugin, 'cp_ppp_customAdjustmentsLink');
|
149 |
add_shortcode( 'CP_PPP_LIST', 'cp_ppp_filter_list' );
|
150 |
}
|
151 |
|
152 |
+
// register gutemberg block
|
153 |
+
if (function_exists('register_block_type'))
|
154 |
+
{
|
155 |
+
register_block_type('cpcfwpppro/form-rendering', array(
|
156 |
+
'attributes' => array(
|
157 |
+
'formId' => array(
|
158 |
+
'type' => 'string'
|
159 |
+
),
|
160 |
+
'instanceId' => array(
|
161 |
+
'type' => 'string'
|
162 |
+
),
|
163 |
+
),
|
164 |
+
'render_callback' => 'cp_ppp_render_form_admin'
|
165 |
+
));
|
166 |
+
}
|
167 |
|
168 |
// functions
|
169 |
//------------------------------------------
|
451 |
return $CP_CFPP_global_templates;
|
452 |
}
|
453 |
|
454 |
+
|
455 |
+
function cp_ppp_gutenberg_block() {
|
456 |
+
global $wpdb;
|
457 |
+
|
458 |
+
wp_enqueue_script( 'cpcfwpp_gutenberg_editor', plugins_url('/js/block.js', __FILE__));
|
459 |
+
|
460 |
+
wp_enqueue_style('cfwpppro-publicstyle', plugins_url('css/stylepublic.css', __FILE__));
|
461 |
+
|
462 |
+
wp_deregister_script('query-stringify');
|
463 |
+
wp_register_script('query-stringify', plugins_url('/js/jQuery.stringify.js', __FILE__));
|
464 |
+
|
465 |
+
wp_deregister_script('cp_ppp_validate_script');
|
466 |
+
wp_register_script('cp_ppp_validate_script', plugins_url('/js/jquery.validate.js', __FILE__));
|
467 |
+
|
468 |
+
wp_enqueue_script( 'cp_ppp_buikder_script',
|
469 |
+
get_site_url( get_current_blog_id() ).'?cp_ppp_resources=public',array("jquery","jquery-ui-core","jquery-ui-datepicker","jquery-ui-widget","jquery-ui-position","jquery-ui-tooltip","query-stringify","cp_ppp_validate_script"), false, true );
|
470 |
+
|
471 |
+
$forms = array();
|
472 |
+
$rows = $wpdb->get_results("SELECT id,form_name FROM ".$wpdb->prefix.CP_PPP_FORMS_TABLE." ORDER BY form_name");
|
473 |
+
foreach ($rows as $item)
|
474 |
+
$forms[] = array (
|
475 |
+
'value' => $item->id,
|
476 |
+
'label' => $item->form_name,
|
477 |
+
);
|
478 |
+
|
479 |
+
wp_localize_script( 'cpcfwpp_gutenberg_editor', 'cpcfwpppro_forms', array(
|
480 |
+
'forms' => $forms,
|
481 |
+
'siteUrl' => get_site_url()
|
482 |
+
) );
|
483 |
+
}
|
484 |
+
|
485 |
+
|
486 |
+
function cp_ppp_render_form_admin ($atts) {
|
487 |
+
$is_gutemberg_editor = defined( 'REST_REQUEST' ) && REST_REQUEST && ! empty( $_REQUEST['context'] ) && 'edit' === $_REQUEST['context'];
|
488 |
+
if (!$is_gutemberg_editor)
|
489 |
+
return cp_ppp_filter_content (array('id' => $atts["formId"]));
|
490 |
+
else if ($atts["formId"])
|
491 |
+
{
|
492 |
+
ob_start();
|
493 |
+
@include_once dirname( __FILE__ ) . '/cp_ppp_paypal_pro_int.inc.php';
|
494 |
+
$buffer = ob_get_contents();
|
495 |
+
ob_end_clean();
|
496 |
+
return '<input type="hidden" name="form_structure'.$atts["instanceId"].'" id="form_structure'.$atts["instanceId"].'" value="'.esc_attr(cp_ppp_get_option('form_structure', CP_PPP_DEFAULT_form_structure, $atts["formId"])).'" /><fieldset class="ahbgutenberg_editor" disabled><div id="fbuilder"><div id="fbuilder_'.$atts["instanceId"].'"><div id="formheader_'.$atts["instanceId"].'"></div><div id="fieldlist_'.$atts["instanceId"].'"></div></div></div>'.$buffer.'</fieldset>';
|
497 |
+
}
|
498 |
+
else
|
499 |
+
return '';
|
500 |
+
}
|
501 |
+
|
502 |
+
|
503 |
function cp_ppp_filter_content($atts) {
|
504 |
global $wpdb;
|
505 |
extract( shortcode_atts( array(
|
images/cp_form.gif
CHANGED
Binary file
|
js/block.js
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(function()
|
2 |
+
{
|
3 |
+
(function( blocks, element ) {
|
4 |
+
var el = wp.element.createElement,
|
5 |
+
source = blocks.source,
|
6 |
+
InspectorControls = wp.editor.InspectorControls,
|
7 |
+
category = {slug:'payment-form-for-paypal-prol', title : 'Payment Form for PayPal Pro'};
|
8 |
+
|
9 |
+
var _wp$components = wp.components,
|
10 |
+
SelectControl = _wp$components.SelectControl,
|
11 |
+
ServerSideRender = _wp$components.ServerSideRender;
|
12 |
+
|
13 |
+
/* Plugin Category */
|
14 |
+
blocks.getCategories().push({slug: 'cpcfwpppro', title: 'Payment Form for PayPal Pro'}) ;
|
15 |
+
|
16 |
+
|
17 |
+
/* ICONS */
|
18 |
+
const iconcpcfwpppro = el('img', { width: 20, height: 20, src: "data:image/gif;base64,R0lGODlhFAARAJEAAP8AJAAA////AAAAACwAAAAAFAARAAACOYyPqcLt3wycTwqFA7OU8g5lYgJ62nUwANCsLLqlwtrS8MTSOmDJ8/t79Ti2YIwC/EVOpQqzuRyJCgA7" } );
|
19 |
+
|
20 |
+
/* Form's shortcode */
|
21 |
+
blocks.registerBlockType( 'cpcfwpppro/form-rendering', {
|
22 |
+
title: 'Payment Form for PayPal Pro',
|
23 |
+
icon: iconcpcfwpppro,
|
24 |
+
category: 'cpcfwpppro',
|
25 |
+
supports: {
|
26 |
+
customClassName: false,
|
27 |
+
className: false
|
28 |
+
},
|
29 |
+
attributes: {
|
30 |
+
formId: {
|
31 |
+
type: 'string'
|
32 |
+
},
|
33 |
+
instanceId: {
|
34 |
+
type: 'string'
|
35 |
+
}
|
36 |
+
},
|
37 |
+
edit: function( { attributes, className, isSelected, setAttributes } ) {
|
38 |
+
const formOptions = cpcfwpppro_forms.forms;
|
39 |
+
if (!formOptions.length)
|
40 |
+
return el("div", null, 'Please create a payment form first.' );
|
41 |
+
var iId = attributes.instanceId;
|
42 |
+
if (!iId)
|
43 |
+
{
|
44 |
+
iId = formOptions[0].value+parseInt(Math.random()*100000);
|
45 |
+
setAttributes({instanceId: iId });
|
46 |
+
}
|
47 |
+
if (!attributes.formId)
|
48 |
+
setAttributes({formId: formOptions[0].value });
|
49 |
+
cpcfwpppro_renderForm(iId);
|
50 |
+
var focus = isSelected;
|
51 |
+
return [
|
52 |
+
!!focus && el(
|
53 |
+
InspectorControls,
|
54 |
+
{
|
55 |
+
key: 'cpcfwpppro_inspector'
|
56 |
+
},
|
57 |
+
[
|
58 |
+
el(
|
59 |
+
'span',
|
60 |
+
{
|
61 |
+
key: 'cpcfwpppro_inspector_help',
|
62 |
+
style:{fontStyle: 'italic'}
|
63 |
+
},
|
64 |
+
'If you need help: '
|
65 |
+
),
|
66 |
+
el(
|
67 |
+
'a',
|
68 |
+
{
|
69 |
+
key : 'cpcfwpppro_inspector_help_link',
|
70 |
+
href : 'https://cfpaypal.dwbooster.com/contact-us',
|
71 |
+
target : '_blank'
|
72 |
+
},
|
73 |
+
'CLICK HERE'
|
74 |
+
)
|
75 |
+
]
|
76 |
+
),
|
77 |
+
el(SelectControl, {
|
78 |
+
value: attributes.formId,
|
79 |
+
options: formOptions,
|
80 |
+
onChange: function(evt){
|
81 |
+
setAttributes({formId: evt});
|
82 |
+
iId = evt+parseInt(Math.random()*100000);
|
83 |
+
setAttributes({instanceId: iId });
|
84 |
+
cpcfwpppro_renderForm(iId);
|
85 |
+
},
|
86 |
+
}),
|
87 |
+
el(ServerSideRender, {
|
88 |
+
block: "cpcfwpppro/form-rendering",
|
89 |
+
attributes: attributes
|
90 |
+
})
|
91 |
+
];
|
92 |
+
},
|
93 |
+
|
94 |
+
save: function( props ) {
|
95 |
+
return null;
|
96 |
+
}
|
97 |
+
});
|
98 |
+
|
99 |
+
} )(
|
100 |
+
window.wp.blocks,
|
101 |
+
window.wp.element
|
102 |
+
);
|
103 |
+
}
|
104 |
+
);
|
105 |
+
function cpcfwpppro_renderForm(id) {
|
106 |
+
if ($("#form_structure"+id).length)
|
107 |
+
{
|
108 |
+
try
|
109 |
+
{
|
110 |
+
var cp_appbooking_fbuilder_myconfig = {"obj":"{\"pub\":true,\"identifier\":\"_"+id+"\",\"messages\": {}}"};
|
111 |
+
var f = $("#fbuilder_"+id).fbuilder($.parseJSON(cp_appbooking_fbuilder_myconfig.obj));
|
112 |
+
f.fBuild.loadData("form_structure"+id);
|
113 |
+
} catch (e) { setTimeout ('cpcfwpppro_renderForm('+id+')',250);}
|
114 |
+
}
|
115 |
+
else
|
116 |
+
{
|
117 |
+
setTimeout ('cpcfwpppro_renderForm('+id+')',50);
|
118 |
+
}
|
119 |
+
}
|