Wordpress 5.4 inserting <p> tags into Javascript code on Buddypress activity feed

1 answer

After upgrading to Wordpress 5.4, we've found that it's inserting rogue <p> tags into Javascript code that was previously working on our Buddypress activity feed.

The code is included with a call to bp_get_template_part:

bp_get_template_part( 'activity/submit-tabs' ); 

Here's an example of the code from the Web inspector, showing these roque <p> tags:

<p><script>      jQuery(function($) {          var input = $('#our-activity-action-input');          var privacy = $('#our-activity-action-privacy');          var type = $('#our-activity-action-type');          var button = $('#our-activity-action-button');</p>  <p>        type.change(function() {              var typeValue = type.val();              var placeholder = '';</p>  <p>            if (typeValue == 'news') {                  placeholder = 'Enter the URL of a news article you’d like to rate or fact-check.';              }</p>  <p>            input.attr('placeholder', placeholder);          });</p>  <p>        button.click(function() {              var inputValue = input.val().trim();</p>  <p>            if (!inputValue) {                  input.val('').focus();                  return false;              }</p>  <p>            var submitAction = function() {                  var typeValue = type.val();</p>  <p>                var action;                  var actionInput;                  var actionSubmit;</p>  <p>                if (typeValue == 'news') {                      action = $('.our-activity-actions .action-news');                      actionInput = action.find('#af_ournews_url_input');                      actionSubmit = action.find('#af_ournews_url_submit');                  } else if (typeValue == 'claim') {                      action = $('.our-activity-actions .action-claim');                      actionInput = action.find('#af_ournews_url_input_quote');                      actionSubmit = action.find('#af_ournews_url_submit_quote');                  } else if (typeValue == 'status') {                      action = $('.our-activity-actions .action-status');                      actionInput = action.find('#whats-new');                      actionSubmit = action.find('#aw-whats-new-submit');                  }</p>  <p>                actionInput.val(inputValue);</p>  <p>                actionSubmit.trigger('click');</p>  <p>                if (typeValue == 'status') {                      input.val('');</p>  <p>                                    }              };</p>  <p>            var privacyValue = privacy.val();</p>  <p>            var ajaxUrl = 'https://our.news/wp-admin/admin-ajax.php';</p>  <p>            var data = {                  action: 'ours_set_temp_privacy',                  privacy: privacyValue              };</p>  <p>            button.attr('disabled', true);</p>  <p>            $.post( ajaxUrl, data, function(response) {                  submitAction();</p>  <p>                button.attr('disabled', false);              });</p>  <p>        });      });

We tried the usual solutions like adding this to our child theme's functions.php:

remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' ); 

We went even further and tried guessing at a few Buddypress filters, but no success:

remove_filter( 'bp_get_template_part', 'wpautop'); remove_filter( 'bp_before_has_activities_parse_args', 'wpautop'); remove_filter( 'bp_after_has_activities_parse_args', 'wpautop'); 

Any advice or suggestions how to stop this from happening?

All answers to this question, which has the identifier 61219588

The best answer:

Alright we found a hacky workaround that works but there must be a better way:

add_filter ('the_content','our_remove_autop',0); function our_remove_autop($content) {     $request_uri = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );     $is_activity = strpos($request_uri, 'activity/',0);     if ($is_activity)     {             remove_filter('the_content','wpautop');     }     return $content; } 

Last questions

how do i remove the switch on my home screen?
how to edit the JS date and time to update atuomatically?
How to utilize data stored in a multidimensional array
Powermockito not mocking URL constructor in URI.toURL() method
Android Bluetooth LE Scanner only scans when phone's Location is turned on in some devices
docker wordpress container can't connect to mysql container
How can I declare a number in java that is more than 64-bits? [duplicate]
Optaplanner solutionClass entityCollectionProperty should never return null error when simple JSON object passed to controller
Anylogic, get the time a pedestrain is in a queue
How do I fix this syntax issue with my .flex file?
Optimizing query in PHP
How to find the highest number of a column and print two columns of that row in R?
Ideas on “Error: Type com.google.firebase.iid.zzav is referenced as an interface from com.google.firebase.messaging.zzd”?
JCIFS SmbFile.exists() and SmbFile.isDirectory() return false when it exists and I can listFiles()
PHP total order
Laravel booking system design
neural net - undefined column selected
How to indicate y axis does not start from 0 in ggplot?
Fragments in backStack
Spinner how to change the data