Skip to content

Conversation

@avonville
Copy link
Contributor

weSerialize function was not extending to the frontend scripts.

To test:

enable SCRIPT_DEBUG in wp_config and submit a form.

Scripts will be minified upon the release of the next version.

Copy link
Contributor

@bwmarkle bwmarkle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to my comment, what are the testing instructions? IE how can I see the broken state

Comment on lines 13 to 25
$.fn.extend({
/**
* Custom jQuery serialize wrapper.
*
* When WordPress 5.6 increased the jQuery version to 3.5.1, the serialize function changed. Instead of
* sending spaces as "+", they are sent as "%20". This wrapper is for backwards compatibility.
*
* @since ###
*/
weSerialize: function() {
return $( this ).serialize().replaceAll( '%20', '+' );
},
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way we can not duplicate this function? Is this the 3rd copy? 1 on the backend, 2 on the frontend?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To test the broken state: make sure the master branch on your testing environment is up to date.
Create or use a form with a Name and Text field.
And try to submit the form. The form will not submit and F12 will show the weSerialize is not a function error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bwmarkle Updated the function to be on the frontend and back end just once based on what scripts are being enqueue'd

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To confirm, weSerialize is only defined in one place?

IE the frontend-form.js script is loaded in the admin as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One will be on the frontend and one on the backend for this release.

Comment on lines 3635 to 3645
// /**
// * Custom jQuery serialize wrapper.
// *
// * When WordPress 5.6 increased the jQuery version to 3.5.1, the serialize function changed. Instead of
// * sending spaces as "+", they are sent as "%20". This wrapper is for backwards compatibility.
// *
// * @since ###
// */
// weSerialize: function() {
// return $( this ).serialize().replaceAll( '%20', '+' );
// },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove this?

Copy link
Contributor Author

@avonville avonville May 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bwmarkle Uncommented, this will need to stay since the weforms.js is used for weform.min.js so we will need it for this release, but will be automatically when we create the one script for the front and backend.

Comment on lines 13 to 25
$.fn.extend({
/**
* Custom jQuery serialize wrapper.
*
* When WordPress 5.6 increased the jQuery version to 3.5.1, the serialize function changed. Instead of
* sending spaces as "+", they are sent as "%20". This wrapper is for backwards compatibility.
*
* @since ###
*/
weSerialize: function() {
return $( this ).serialize().replaceAll( '%20', '+' );
},
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To confirm, weSerialize is only defined in one place?

IE the frontend-form.js script is loaded in the admin as well?

@avonville avonville mentioned this pull request May 24, 2021
Comment on lines 13774 to 13775
// Adding custom jQuery serialize wrapper to the frontend and backend for WeForms 1.6.7.
// GitHub ticket created to make one script applied to frontend/backend.
Copy link
Contributor

@bwmarkle bwmarkle May 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of an additional comment block above, how about this:

               /**
		* Custom jQuery serialize wrapper.
		*
		* When WordPress 5.6 increased the jQuery version to 3.5.1, the serialize function changed. Instead of
		* sending spaces as "+", they are sent as "%20". This wrapper is for backwards compatibility.
		* 
		* @todo This function is duplicated in both the frontend and backend. Need to have the code live in
		* just one location.
		*
		* @since ###
		*/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed blocks and added to the block with the @todo tag.

@avonville
Copy link
Contributor Author

@bwmarkle all comments have been addressed. On the frontend the script lives in frontend-form.js and on the backend I created a new file jquery-extensions.js that is used for the backed. jquery-extensions.js is concatenated into vendor.js. and frontend-form.js is concatenated in weforms.js. This happens in the build process. For the next release in May, jquery-extensions.js can be used for both the front and backend.

@bwmarkle bwmarkle merged commit eb7509d into master May 25, 2021
@bwmarkle bwmarkle deleted the issue-88 branch May 25, 2021 12:09
@avonville avonville added this to the 1.6.7 milestone May 25, 2021
avonville added a commit that referenced this pull request Feb 22, 2022
avonville added a commit that referenced this pull request Feb 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants