Thread Starter
cindy c
(@cindy_conlinyahoocom)
I figured out that the conflict was Give is loading scripts on all pages, not just the ones with their donation forms. I tried de-enqueuing those and removed ‘defer’ from the Gravity Form scripts, but still there’s no credit card fields. Working on it – will update here in case anyone is following.
Hello @cindy_conlinyahoocom ,
Glad you reached out, happy to help – you’re on the right track!
You’ve come across an issue we discovered wherein Square is acting weird when two plugins are using their API
Here is the bug report:
https://givewp.featureos.app/p/square-credit-card-fields-don-t-show-when-multiple-forms-or-apps-are-using-the-same-square-api-access.
While I do not have an ETA to share if/when this will be corrected.
On a simplified perspective, this is happening because Square’s apps can only connect to one app at a time. I was able to work around this by using this code snippet:
add_action('wp_enqueue_scripts', 'remove_give_on_form_pages', 100);
function remove_give_on_form_pages()
{
// Remove Give on form pages
// only act on the specific page
if (!is_page(5706)) {
wp_dequeue_script('give');
wp_dequeue_script('give_recurring_script');
wp_dequeue_script('give-fee-recovery');
wp_dequeue_script('give-campaign-options');
wp_dequeue_script('give-square-payment-form');
wp_dequeue_script('give-square-frontend');
wp_dequeue_script('givewp-form-entity');
wp_dequeue_script('givewp-campaign-entity');
wp_dequeue_script('givewp-donation-entity');
wp_dequeue_script('givewp-donor-entity');
wp_dequeue_script('givewp-campaign-entity');
wp_dequeue_script('givewp-subscription-entity');
wp_dequeue_script('give-donation-summary-script-frontend');
}
}
We recommend adding PHP code snippets to your website via a code snippet plugin. We use this one https://ww.wp.xz.cn/plugins/code-snippets/, however, there are many available that can work.
Please note that this code snippet is provided as an example of how you can extend GiveWP with code. It’s up to you to implement and customize to your liking. We cannot provide support for custom code on your website, only the code that we create and distribute.
Let us know once you implemented and tested the above 👍🏻
Thread Starter
cindy c
(@cindy_conlinyahoocom)
Hi, and thanks so much for your reply. Doesn’t this line mean if it’s NOT this page?
Do I need a return; in there so that if it’s not that page, it won’t dequeue the scripts?
if (!is_page(5706))
Also – on your ticket, you say:
“The same was true on the GiveWP donation form. When the Gravity Forms Square add-on was active and displaying, the Square fields do not display at all in the payment gateway section of a V3 donation form, it was blank with these js errors:”
However, my GiveWP donation forms continued to work fine, the credit card fields showed on all the forms.
-
This reply was modified 3 days, 6 hours ago by
cindy c.
Thread Starter
cindy c
(@cindy_conlinyahoocom)
I tried your script as is (just changed the page ID) and it did not change anything with either the Gravity Form or any of the Give forms.
Hello @cindy_conlinyahoocom ,
My apologies! I sent the wrong script. I was able to locate my test site for this code snippet. The script below works. On my test site, the Gravity Forms page has a post id = 1351.
function give_mysite_deregister_script() {
$deregister = false;
//Deregister for a specific page.
if ( is_page( 1351 ) ) {
$deregister = true;
}
// Check if the conditions are met to register.
if ( $deregister ) {
remove_all_givewp_styles_scripts();
}
}
add_action( 'wp_print_scripts', 'give_mysite_deregister_script', 100 );
add_action( 'wp_enqueue_scripts', 'give_mysite_deregister_script', 100 );
function remove_all_givewp_styles_scripts() {
global $wp_scripts;
global $wp_styles;
foreach( $wp_scripts->queue as $handle ) {
if (strpos($wp_scripts->registered[$handle]->handle, 'give') !== false) {
wp_dequeue_script( $handle );
}
}
foreach( $wp_styles->queue as $handle ) {
if (strpos($wp_styles->registered[$handle]->handle, 'give') !== false) {
wp_dequeue_style( $handle );
}
}
}
I’m linking the two pages below for reference.
GiveWP – Square donation form page:
https://square-gsc.instawp.xyz/donations/givewp-donation-form/
Gravity Forms – Square payment page:
https://square-gsc.instawp.xyz/gravity-forms-square-donation/
Let me know how things go!
Thread Starter
cindy c
(@cindy_conlinyahoocom)
I had used your script but took out the ‘!’, swapped for my page id, and it wasn’t working. Then I also dequeued the ‘givewp-entities-public’ script, and that all worked.
Please review my code below (taken from yours) and advise if I should change it out for your new script above if below is not correct. It did work but your new one has additional elements:
/* Give's workaround */
add_action('wp_enqueue_scripts', 'remove_give_on_form_pages', 100);
function remove_give_on_form_pages() {
// Remove Give on form pages
// only act on the specific page
if (is_page(7454)) {
wp_dequeue_script('give');
wp_dequeue_script('give_recurring_script');
wp_dequeue_script('give-fee-recovery');
wp_dequeue_script('give-campaign-options');
wp_dequeue_script('give-square-payment-form');
wp_dequeue_script('give-square-frontend');
wp_dequeue_script('givewp-form-entity');
wp_dequeue_script('givewp-campaign-entity');
wp_dequeue_script('givewp-donation-entity');
wp_dequeue_script('givewp-donor-entity');
wp_dequeue_script('givewp-campaign-entity');
wp_dequeue_script('givewp-subscription-entity');
wp_dequeue_script('give-donation-summary-script-frontend');
wp_dequeue_script('givewp-entities-public'); /* cc added */
}
}
/* End Give's workaround */
-
This reply was modified 3 days, 3 hours ago by
cindy c.
Hello again,
There are certainly many ways to craft a dequeuing script, so I would say if that is working for you, don’t change it 🙂
I’ll go ahead and mark this topic as resolved now. Have a great weekend!