diff --git a/blocks/components/chosen-select/index.js b/blocks/components/chosen-select/index.js
deleted file mode 100644
index d025f70353..0000000000
--- a/blocks/components/chosen-select/index.js
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * WordPress dependencies
- */
-import { Component } from '@wordpress/element';
-import { BaseControl } from '@wordpress/components';
-import jquery from "jquery";
-
-/**
- * Render ChosenSelect Control
-*/
-class ChosenSelect extends Component {
- constructor( props ) {
- super( props );
-
- this.saveSetting = this.saveSetting.bind( this );
- this.saveState = this.saveState.bind( this );
- }
-
- saveSetting( name, value ) {
- this.props.setAttributes( {
- [ name ]: value,
- } );
- }
-
- saveState( name, value ) {
- this.setState( {
- [ name ]: value,
- } );
- }
-
- componentDidMount() {
- const { value } = this.props;
-
- this.$el = jquery( this.el );
- this.$el.val( value );
-
- this.$input = this.$el.chosen( {
- width: '100%',
- } ).data( 'chosen' );
-
- this.handleChange = this.handleChange.bind( this );
-
- this.$el.on( 'change', this.handleChange );
- }
-
- componentWillUnmount() {
- this.$el.off( 'change', this.handleChange );
- this.$el.chosen( 'destroy' );
- }
-
- handleChange( e ) {
- this.props.onChange( e.target.value );
- }
-
- componentDidUpdate() {
- const $searchField = jquery( '.chosen-base-control' ).closest( '.chosen-container' ).find( '.chosen-search-input' );
- this.$input.search_field.autocomplete( {
- source: function( request, response ) {
- const data = {
- action: 'give_block_donation_form_search_results',
- search: request.term,
- };
- const chosenBlock = jquery( '.give-block-chosen-select' );
-
- jquery.post( ajaxurl, data, ( responseData ) => {
- chosenBlock.empty();
- responseData = JSON.parse( responseData );
-
- if ( responseData.length > 0 ) {
- response( jquery.map( responseData, function( item ) {
- chosenBlock.append( `` );
- } ) );
-
- chosenBlock.trigger( 'chosen:updated' );
- $searchField.val( request.term );
- }
- } );
- },
- } );
- }
-
- render() {
- return (
-
-
-
- );
- }
-}
-
-export default ChosenSelect;
diff --git a/blocks/components/select-form/index.js b/blocks/components/select-form/index.js
deleted file mode 100644
index 94557b4776..0000000000
--- a/blocks/components/select-form/index.js
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * WordPress dependencies
- */
-import { __ } from '@wordpress/i18n'
-import {withSelect} from '@wordpress/data';
-import { Placeholder, Spinner } from '@wordpress/components';
-
-/**
- * Internal dependencies
- */
-import './index.scss';
-import GiveBlankSlate from '../blank-slate';
-import NoForms from '../no-form';
-import ChosenSelect from '../chosen-select';
-import { getFormOptions } from '../../utils';
-
-const SelectForm = ( { forms, setAttributes } ) => {
- const setFormIdTo = id => {
- setAttributes( { id: Number( id ) } );
- };
-
- // Render Component UI
- let componentUI;
-
- if ( ! forms ) {
- componentUI = ;
- } else if ( forms && forms.length === 0 ) {
- componentUI = ;
- } else {
- componentUI = (
-
-
-
- );
- }
-
- return componentUI;
-};
-
-/**
- * Export with forms data
- */
-export default withSelect( ( select ) => {
- return {
- forms: select( 'core' ).getEntityRecords( 'postType', 'give_forms', { per_page: 30 } ),
- };
-} )( SelectForm );
diff --git a/blocks/components/select-form/index.scss b/blocks/components/select-form/index.scss
deleted file mode 100644
index ac312db265..0000000000
--- a/blocks/components/select-form/index.scss
+++ /dev/null
@@ -1,8 +0,0 @@
-[data-type='give/donation-form'] {
- .components-base-control__field {
- max-width: 400px;
- margin: 0 auto;
-
- text-align: left;
- }
-}
diff --git a/blocks/donation-form/class-give-donation-form-block.php b/blocks/donation-form/class-give-donation-form-block.php
index 3b4e17adaa..77d5e23079 100644
--- a/blocks/donation-form/class-give-donation-form-block.php
+++ b/blocks/donation-form/class-give-donation-form-block.php
@@ -2,16 +2,16 @@
/**
* Give Donation Form Block Class
*
- * @package Give
+ * @since 2.0.2
* @subpackage Classes/Blocks
* @copyright Copyright (c) 2018, GiveWP
* @license https://opensource.org/licenses/gpl-license GNU Public License
- * @since 2.0.2
+ * @package Give
*/
// Exit if accessed directly.
-if ( ! defined( 'ABSPATH' ) ) {
- exit;
+if (!defined('ABSPATH')) {
+ exit;
}
/**
@@ -21,200 +21,211 @@
*
* @since 2.0.2
*/
-class Give_Donation_Form_Block {
- /**
- * Instance.
- *
- * @since
- * @access private
- * @var Give_Donation_Form_Block
- */
- private static $instance;
-
- /**
- * Singleton pattern.
- *
- * @since
- * @access private
- */
- private function __construct() {
- }
-
-
- /**
- * Get instance.
- *
- * @since
- * @access public
- * @return Give_Donation_Form_Block
- */
- public static function get_instance() {
- if ( null === static::$instance ) {
- self::$instance = new static();
-
- self::$instance->init();
- }
-
- return self::$instance;
- }
-
- /**
- * Class Constructor
- *
- * Set up the Give Donation Grid Block class.
- *
- * @since 2.0.2
- * @access private
- */
- private function init() {
- add_action( 'init', array( $this, 'register_block' ), 999 );
- add_action( 'wp_ajax_give_block_donation_form_search_results', array( $this, 'block_donation_form_search_results' ) );
- add_filter( 'rest_prepare_give_forms', array( $this, 'addExtraDataToResponse' ), 10, 2 );
- }
-
- /**
- * Add extra data to response.
- *
- * @since 2.7.0
- * @param WP_REST_Response $response
- * @param WP_Post $form
- *
- * @return WP_REST_Response
- */
- public function addExtraDataToResponse( $response, $form ) {
- // Return extra data only if query in edit context.
- if ( empty( $_REQUEST['context'] ) || $_REQUEST['context'] !== 'edit' ) {
- return $response;
- }
-
- $data = $response->get_data();
- $data['formTemplate'] = Give()->form_meta->get_meta( $form->ID, '_give_form_template', true );
- $response->set_data( $data );
-
- return $response;
- }
-
- /**
- * Register block
- *
- * @since 2.1
- * @access public
- *
- * @access public
- */
- public function register_block() {
- // Bailout.
- if ( ! function_exists( 'register_block_type' ) ) {
- return;
- }
-
- // Register block.
- register_block_type(
- 'give/donation-form',
- array(
- 'render_callback' => array( $this, 'render_donation_form' ),
- 'attributes' => array(
- 'id' => array(
- 'type' => 'number',
- ),
- 'prevId' => array(
- 'type' => 'number',
- ),
- 'displayStyle' => array(
- 'type' => 'string',
- 'default' => 'onpage',
- ),
- 'continueButtonTitle' => array(
- 'type' => 'string',
- 'default' => '',
- ),
- 'showTitle' => array(
- 'type' => 'boolean',
- 'default' => true,
- ),
- 'showGoal' => array(
- 'type' => 'boolean',
- 'default' => true,
- ),
- 'contentDisplay' => array(
- 'type' => 'boolean',
- 'default' => true,
- ),
- 'showContent' => array(
- 'type' => 'string',
- 'default' => 'above',
- ),
- ),
- )
- );
- }
-
- /**
- * Block render callback
- *
- * @param array $attributes Block parameters.
- *
- * @access public
- * @return string;
- */
- public function render_donation_form( $attributes ) {
- // Bailout.
- if ( empty( $attributes['id'] ) ) {
- return '';
- }
-
- $parameters = array();
-
- $parameters['id'] = absint( $attributes['id'] );
- $parameters['show_title'] = $attributes['showTitle'];
- $parameters['show_goal'] = $attributes['showGoal'];
- $parameters['show_content'] = ! empty( $attributes['contentDisplay'] ) ? $attributes['showContent'] : 'none';
- $parameters['display_style'] = $attributes['displayStyle'];
- $parameters['continue_button_title'] = trim( $attributes['continueButtonTitle'] );
+class Give_Donation_Form_Block
+{
+ /**
+ * Instance.
+ *
+ * @since
+ * @access private
+ * @var Give_Donation_Form_Block
+ */
+ private static $instance;
+
+ /**
+ * Singleton pattern.
+ *
+ * @since
+ * @access private
+ */
+ private function __construct()
+ {
+ }
+
+
+ /**
+ * Get instance.
+ *
+ * @since
+ * @access public
+ * @return Give_Donation_Form_Block
+ */
+ public static function get_instance()
+ {
+ if (null === static::$instance) {
+ self::$instance = new static();
+
+ self::$instance->init();
+ }
+
+ return self::$instance;
+ }
+
+ /**
+ * Class Constructor
+ *
+ * Set up the Give Donation Grid Block class.
+ *
+ * @since 2.0.2
+ * @access private
+ */
+ private function init()
+ {
+ add_action('init', array($this, 'register_block'), 999);
+ add_action('wp_ajax_give_block_donation_form_search_results', array($this, 'block_donation_form_search_results')
+ );
+ add_filter('rest_prepare_give_forms', array($this, 'addExtraDataToResponse'), 10, 2);
+ }
+
+ /**
+ * Add extra data to response.
+ *
+ * @since 2.7.0
+ * @param WP_REST_Response $response
+ * @param WP_Post $form
+ *
+ * @return WP_REST_Response
+ */
+ public function addExtraDataToResponse($response, $form)
+ {
+ // Return extra data only if query in edit context.
+ if (empty($_REQUEST['context']) || $_REQUEST['context'] !== 'edit') {
+ return $response;
+ }
+
+ $data = $response->get_data();
+ $data['formTemplate'] = Give()->form_meta->get_meta($form->ID, '_give_form_template', true);
+ $data['isLegacyForm'] = !Give()->form_meta->get_meta($form->ID, 'formBuilderSettings', true);
+ $response->set_data($data);
+
+ return $response;
+ }
+
+ /**
+ * Register block
+ *
+ * @since 2.1
+ * @access public
+ *
+ * @access public
+ */
+ public function register_block()
+ {
+ // Bailout.
+ if (!function_exists('register_block_type')) {
+ return;
+ }
+
+ // Register block.
+ register_block_type(
+ 'give/donation-form',
+ array(
+ 'render_callback' => array($this, 'render_donation_form'),
+ 'attributes' => array(
+ 'id' => array(
+ 'type' => 'number',
+ ),
+ 'prevId' => array(
+ 'type' => 'number',
+ ),
+ 'displayStyle' => array(
+ 'type' => 'string',
+ 'default' => 'onpage',
+ ),
+ 'continueButtonTitle' => array(
+ 'type' => 'string',
+ 'default' => __('Donate now', 'give')
+ ),
+ 'showTitle' => array(
+ 'type' => 'boolean',
+ 'default' => true,
+ ),
+ 'showGoal' => array(
+ 'type' => 'boolean',
+ 'default' => true,
+ ),
+ 'contentDisplay' => array(
+ 'type' => 'boolean',
+ 'default' => true,
+ ),
+ 'showContent' => array(
+ 'type' => 'string',
+ 'default' => 'above',
+ ),
+ 'blockId' => array(
+ 'type' => 'string',
+ ),
+ ),
+ )
+ );
+ }
+
+ /**
+ * Block render callback
+ *
+ * @param array $attributes Block parameters.
+ *
+ * @access public
+ * @return string;
+ */
+ public function render_donation_form($attributes)
+ {
+ // Bailout.
+ if (empty($attributes['id'])) {
+ return '';
+ }
+ $parameters = array();
+
+ $parameters['id'] = absint($attributes['id']);
+ $parameters['show_title'] = $attributes['showTitle'];
+ $parameters['show_goal'] = $attributes['showGoal'];
+ $parameters['show_content'] = !empty($attributes['contentDisplay']) ? $attributes['showContent'] : 'none';
+ $parameters['display_style'] = $attributes['displayStyle'];
+ $parameters['continue_button_title'] = trim($attributes['continueButtonTitle']);
_give_redirect_form_id($parameters['id']);
- return give_form_shortcode( $parameters );
- }
-
- /**
- * This function is used to fetch donation forms based on the chosen search in the donation form block.
- *
- * @since 2.5.3
- * @access public
- *
- * @return void
- */
- public function block_donation_form_search_results() {
-
- // Define variables.
- $result = array();
- $post_data = give_clean( $_POST );
- $search_keyword = ! empty( $post_data['search'] ) ? $post_data['search'] : '';
-
- // Setup the arguments to fetch the donation forms.
- $forms_query = new Give_Forms_Query(
- array(
- 's' => $search_keyword,
- 'number' => 30,
- 'post_status' => 'publish',
- )
- );
-
- // Fetch the donation forms.
- $forms = $forms_query->get_forms();
-
- // Loop through each donation form.
- foreach ( $forms as $form ) {
- $result[] = array(
- 'id' => $form->ID,
- 'name' => $form->post_title,
- );
- }
-
- echo wp_json_encode( $result );
- give_die();
- }
+ return give_form_shortcode($parameters);
+ }
+
+ /**
+ * This function is used to fetch donation forms based on the chosen search in the donation form block.
+ *
+ * @since 2.5.3
+ * @access public
+ *
+ * @return void
+ */
+ public function block_donation_form_search_results()
+ {
+ // Define variables.
+ $result = array();
+ $post_data = give_clean($_POST);
+ $search_keyword = !empty($post_data['search']) ? $post_data['search'] : '';
+
+ // Setup the arguments to fetch the donation forms.
+ $forms_query = new Give_Forms_Query(
+ array(
+ 's' => $search_keyword,
+ 'number' => 30,
+ 'post_status' => 'publish',
+ )
+ );
+
+ // Fetch the donation forms.
+ $forms = $forms_query->get_forms();
+
+ // Loop through each donation form.
+ foreach ($forms as $form) {
+ $result[] = array(
+ 'id' => $form->ID,
+ 'name' => $form->post_title,
+ );
+ }
+
+ echo wp_json_encode($result);
+ give_die();
+ }
}
Give_Donation_Form_Block::get_instance();
diff --git a/blocks/donation-form/data/attributes.js b/blocks/donation-form/data/attributes.js
index 6dca987b09..d4fd5bd8b2 100644
--- a/blocks/donation-form/data/attributes.js
+++ b/blocks/donation-form/data/attributes.js
@@ -1,38 +1,41 @@
/**
* Block Attributes
-*/
+ */
const blockAttributes = {
- id: {
- type: 'number',
- default: 0,
- },
- prevId: {
- type: 'number',
- },
- displayStyle: {
- type: 'string',
- default: 'onpage',
- },
- continueButtonTitle: {
- type: 'string',
- default: '',
- },
- showTitle: {
- type: 'boolean',
- default: true,
- },
- showGoal: {
- type: 'boolean',
- default: true,
- },
- contentDisplay: {
- type: 'boolean',
- default: true,
- },
- showContent: {
- type: 'string',
- default: 'above',
- },
+ id: {
+ type: 'number',
+ default: 0,
+ },
+ prevId: {
+ type: 'number',
+ },
+ displayStyle: {
+ type: 'string',
+ default: 'onpage',
+ },
+ continueButtonTitle: {
+ type: 'string',
+ default: 'Donate now',
+ },
+ showTitle: {
+ type: 'boolean',
+ default: true,
+ },
+ showGoal: {
+ type: 'boolean',
+ default: true,
+ },
+ contentDisplay: {
+ type: 'boolean',
+ default: true,
+ },
+ showContent: {
+ type: 'string',
+ default: 'above',
+ },
+ blockId: {
+ type: 'string',
+ },
};
export default blockAttributes;
diff --git a/blocks/donation-form/data/options.js b/blocks/donation-form/data/options.js
deleted file mode 100644
index b7951d4002..0000000000
--- a/blocks/donation-form/data/options.js
+++ /dev/null
@@ -1,26 +0,0 @@
-/* globals Give */
-/**
- * WordPress dependencies
-*/
-import { __ } from '@wordpress/i18n'
-
-/**
- * Options data for various form selects
- */
-const giveFormOptions = {};
-
-// Form Display Styles
-giveFormOptions.displayStyles = [
- { value: 'onpage', label: __( 'Full Form', 'give' ) },
- { value: 'modal', label: __( 'Modal', 'give' ) },
- { value: 'reveal', label: __( 'Reveal', 'give' ) },
- { value: 'button', label: __( 'One Button Launch', 'give' ) },
-];
-
-// Form content Position
-giveFormOptions.contentPosition = [
- { value: 'above', label: __( 'Above', 'give' ) },
- { value: 'below', label: __( 'Below', 'give' ) },
-];
-
-export default giveFormOptions;
diff --git a/blocks/donation-form/edit/block.js b/blocks/donation-form/edit/block.js
deleted file mode 100644
index 2833eab5c3..0000000000
--- a/blocks/donation-form/edit/block.js
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * WordPress dependencies
- */
-import ServerSideRender from '@wordpress/server-side-render';
-
-/**
- * Internal dependencies
- */
-import './block.scss';
-import SelectForm from '../../components/select-form';
-import Inspector from './inspector';
-
-/**
- * Render Block UI For Editor
- */
-
-const GiveForm = ( props ) => {
- const { attributes, isSelected, className } = props;
- const { id } = attributes;
-
- // Render block UI
- let blockUI;
-
- if ( ! id ) {
- blockUI = ;
- } else {
- blockUI = (
-
-
-
-
- );
- }
-
- return blockUI;
-};
-
-export default GiveForm;
diff --git a/blocks/donation-form/edit/block.scss b/blocks/donation-form/edit/block.scss
deleted file mode 100644
index 98e857e293..0000000000
--- a/blocks/donation-form/edit/block.scss
+++ /dev/null
@@ -1,18 +0,0 @@
-.wp-block-give-donation-form {
- position: relative;
-
- form[id*='give-form'] #give-gateway-radio-list > li input[type='radio'] {
- display: inline-block;
- }
-
- iframe {
- pointer-events: none;
- width: 100% !important;
- }
-}
-
-.give-change-donation-form-btn {
- svg {
- margin-top: 3px;
- }
-}
diff --git a/blocks/donation-form/edit/inspector.js b/blocks/donation-form/edit/inspector.js
deleted file mode 100644
index 43b51f8dc9..0000000000
--- a/blocks/donation-form/edit/inspector.js
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- * WordPress dependencies
- */
-import { __ } from '@wordpress/i18n'
-import { InspectorControls } from '@wordpress/block-editor';
-import { Dashicon, Button, PanelBody, SelectControl, ToggleControl, TextControl } from '@wordpress/components';
-import { Component } from '@wordpress/element';
-import {withSelect} from '@wordpress/data';
-
-/**
- * Internal dependencies
- */
-import giveFormOptions from '../data/options';
-import { isLegacyForm } from '../../utils';
-
-/**
- * Render Inspector Controls
-*/
-class Inspector extends Component {
- constructor( props ) {
- super( props );
-
- this.state = {
- continueButtonTitle: this.props.attributes.continueButtonTitle,
- };
-
- this.saveSetting = this.saveSetting.bind( this );
- this.saveState = this.saveState.bind( this );
- }
-
- saveSetting( name, value ) {
- this.props.setAttributes( {
- [ name ]: value,
- } );
- }
-
- saveState( name, value ) {
- this.setState( {
- [ name ]: value,
- } );
- }
-
- render() {
- const { forms } = this.props;
-
- const {
- id,
- displayStyle,
- showTitle,
- showGoal,
- showContent,
- contentDisplay,
- } = this.props.attributes;
-
- return (
-
-
-
-
- {
- isLegacyForm( forms, id ) && (
-
-
- this.saveSetting( 'displayStyle', value ) } />
- {
- 'reveal' === displayStyle && (
- this.saveState( 'continueButtonTitle', value ) }
- onBlur={ ( event ) => this.saveSetting( 'continueButtonTitle', event.target.value ) } />
- )
- }
-
-
- this.saveSetting( 'showTitle', value ) } />
- this.saveSetting( 'showGoal', value ) } />
- this.saveSetting( 'contentDisplay', value ) } />
- {
- contentDisplay && (
- this.saveSetting( 'showContent', value ) } />
- )
- }
-
-
- ) }
-
- );
- }
-}
-
-/**
- * Export with forms data
- */
-export default withSelect( ( select ) => {
- return {
- forms: select( 'core' ).getEntityRecords( 'postType', 'give_forms', { per_page: 30 } ),
- };
-} )( Inspector );
diff --git a/blocks/donation-form/index.js b/blocks/donation-form/index.js
index a3387c4640..c35de1d6ec 100644
--- a/blocks/donation-form/index.js
+++ b/blocks/donation-form/index.js
@@ -7,10 +7,9 @@ import {registerBlockType} from '@wordpress/blocks';
/**
* Internal dependencies
*/
-import './style.scss';
import GiveIcon from '@givewp/components/GiveIcon';
import blockAttributes from './data/attributes';
-import GiveForm from './edit/block';
+import Edit from '../../src/DonationForms/Blocks/DonationFormBlock/resources/editor/Edit';
/**
* Register Block
@@ -29,7 +28,7 @@ export default registerBlockType('give/donation-form', {
html: false,
},
attributes: blockAttributes,
- edit: GiveForm,
+ edit: Edit,
save: () => {
// Server side rendering via shortcode
diff --git a/blocks/donation-form/style.scss b/blocks/donation-form/style.scss
deleted file mode 100644
index 63f780b939..0000000000
--- a/blocks/donation-form/style.scss
+++ /dev/null
@@ -1,16 +0,0 @@
-.gutenberg__editor .give-blank-slate__image {
- max-width: 96px;
-}
-
-.give-chosen-base-control {
- a.chosen-single {
- box-shadow: none !important;
- }
-
- ul.chosen-results {
- margin: 0 !important;
- text-align: left !important;
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell,
- 'Helvetica Neue', sans-serif;
- }
-}
diff --git a/blocks/utils/index.js b/blocks/utils/index.js
deleted file mode 100644
index 78921baa6a..0000000000
--- a/blocks/utils/index.js
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * WordPress dependencies
- */
-import {__} from '@wordpress/i18n';
-
-/**
- * getSiteUrl from API root
- * @returns {string} siteurl
- */
-export function getSiteUrl() {
- return wpApiSettings.root.replace('/wp-json/', '');
-}
-
-/**
- * Convert forms object in option
- *
- * @since 2.7.0
- *
- * @param {object} forms
- *
- * @return {[]}
- */
-export function getFormOptions(forms) {
- let formOptions = [];
-
- if (forms) {
- formOptions = forms.map(({id, title: {rendered: title}}) => {
- return {
- value: id,
- label: title === '' ? `${id} : ${__('No form title', 'give')}` : title,
- };
- });
- }
-
- // Add Default option
- formOptions.unshift({value: '0', label: __('-- Select Form --', 'give')});
-
- return formOptions;
-}
-
-/**
- * Returns whether or not the given form uses the legacy form template.
- *
- * Note: if selected form has legacy form template or empty (old forms) then it will return true otherwise false.
- *
- * @since 2.30.0 Filter v3 forms out of the form list.
- * @since 2.7.0
- *
- * @param {object} forms
- * @param {number} SelectedFormId
- *
- * @return {boolean}
- */
-export function isLegacyForm(forms, SelectedFormId) {
- if (forms) {
- const data = forms.find((form) => parseInt(form.id) === parseInt(SelectedFormId));
-
- return (
- data && data.excerpt.rendered !== '[]
\n' && (!data.formTemplate || data.formTemplate === 'legacy')
- );
- }
-
- return false;
-}
diff --git a/includes/forms/functions.php b/includes/forms/functions.php
index 4380ea3b6b..1a3a584348 100644
--- a/includes/forms/functions.php
+++ b/includes/forms/functions.php
@@ -1587,8 +1587,8 @@ function give_get_default_form_shortcode_args() {
'show_goal' => true,
'show_content' => '',
'float_labels' => '',
- 'display_style' => '',
- 'continue_button_title' => '',
+ 'display_style' => 'fullForm',
+ 'continue_button_title' => __('Donate now', 'give'),
// This attribute belong to form template functionality.
// You can use this attribute to set modal open button background color.
diff --git a/src/DonationForms/Blocks/DonationFormBlock/Controllers/BlockRenderController.php b/src/DonationForms/Blocks/DonationFormBlock/Controllers/BlockRenderController.php
index a5f9c8a9ed..88533b767d 100644
--- a/src/DonationForms/Blocks/DonationFormBlock/Controllers/BlockRenderController.php
+++ b/src/DonationForms/Blocks/DonationFormBlock/Controllers/BlockRenderController.php
@@ -13,6 +13,7 @@
class BlockRenderController
{
/**
+ * @unreleased include form url for new tab format.
* @since 3.0.0
*
* @return string|null
@@ -26,7 +27,7 @@ public function render(array $attributes)
$blockAttributes = BlockAttributes::fromArray($attributes);
- if ( ! $blockAttributes->formId) {
+ if (!$blockAttributes->formId) {
return null;
}
@@ -39,11 +40,13 @@ public function render(array $attributes)
$viewUrl = $this->getViewUrl($donationForm, $embedId);
+ $formUrl = add_query_arg(['p' => $blockAttributes->formId], site_url('?post_type=give_forms'));
+
/**
* Note: iframe-resizer uses querySelectorAll so using a data attribute makes the most sense to target.
* It will also generate a dynamic ID - so when we have multiple embeds on a page there will be no conflict.
*/
- return "";
+ return "";
}
/**
diff --git a/src/DonationForms/Blocks/DonationFormBlock/block.json b/src/DonationForms/Blocks/DonationFormBlock/block.json
index 754a139b84..93de63075b 100644
--- a/src/DonationForms/Blocks/DonationFormBlock/block.json
+++ b/src/DonationForms/Blocks/DonationFormBlock/block.json
@@ -1,33 +1,25 @@
{
- "$schema": "https://json.schemastore.org/block.json",
- "apiVersion": 2,
- "name": "givewp/donation-form",
- "version": "1.0.0",
- "title": "Donation Form",
- "category": "give",
- "icon": "superhero",
- "description": "The GiveWP Donation Form block inserts an existing donation form into the page.",
- "supports": {
- "html": false,
- "inserter": false
+ "$schema": "https://json.schemastore.org/block.json",
+ "apiVersion": 2,
+ "name": "givewp/donation-form",
+ "version": "1.0.0",
+ "title": "Donation Form",
+ "category": "give",
+ "icon": "superhero",
+ "description": "The GiveWP Donation Form block inserts an existing donation form into the page.",
+ "supports": {
+ "html": false,
+ "inserter": false
+ },
+ "attributes": {
+ "formId": {
+ "type": "string"
},
- "attributes": {
- "formId": {
- "type": "string"
- },
- "blockId": {
- "type": "string"
- },
- "formFormat": {
- "type": "string",
- "default": "full"
- },
- "openFormButton": {
- "type": "string",
- "default": "Donate now"
- }
- },
- "textdomain": "give",
- "editorStyle": "file:../../../../build/donationFormBlock.css",
- "editorScript": "file:../../../../build/donationFormBlock.js"
+ "blockId": {
+ "type": "string"
+ }
+ },
+ "textdomain": "give",
+ "editorStyle": "file:../../../../build/donationFormBlock.css",
+ "editorScript": "file:../../../../build/donationFormBlock.js"
}
diff --git a/src/DonationForms/Blocks/DonationFormBlock/resources/app/Components/ModalForm.tsx b/src/DonationForms/Blocks/DonationFormBlock/resources/app/Components/ModalForm.tsx
index a644615538..29f6a125ac 100644
--- a/src/DonationForms/Blocks/DonationFormBlock/resources/app/Components/ModalForm.tsx
+++ b/src/DonationForms/Blocks/DonationFormBlock/resources/app/Components/ModalForm.tsx
@@ -1,11 +1,20 @@
import {useEffect, useRef, useState} from '@wordpress/element';
-import {createPortal} from 'react-dom';
import IframeResizer from 'iframe-resizer-react';
+import {createPortal} from 'react-dom';
+
+import '../../editor/styles/index.scss';
+
+type ModalFormProps = {
+ dataSrc: string;
+ embedId: string;
+ openFormButton: string;
+};
/**
+ * @unreleased include types. update BEM classnames.
* @since 3.0.0
*/
-export default function ModalForm({dataSrc, embedId, openFormButton}) {
+export default function ModalForm({dataSrc, embedId, openFormButton}: ModalFormProps) {
const [isOpen, setIsOpen] = useState(false);
const modalRef = useRef(null);
@@ -15,37 +24,42 @@ export default function ModalForm({dataSrc, embedId, openFormButton}) {
useEffect(() => {
const {current: el} = modalRef;
- if (isOpen) el.showModal();
+ if (isOpen) {
+ el.showModal();
+ }
}, [isOpen]);
return (
- <>
-