Call to undefined function wp_should_load_separate_core_block_assets() wordpress

865 Views Asked by At

I'm a newbie in WordPress, have one issue in my implementation as below, P.S. Error occurs only on the server(cloudways), not in the local environment, and even on the server, it occurs after certain hours not continuously.

PHP Fatal error:  Uncaught Error: Call to undefined function wp_should_load_separate_core_block_assets() in `wp-includes/blocks.php`

I'm not getting exactly what's causing it, I have a rough idea of it that it must be of changing plugins.php or themes/functions.php.

WordPress version: 5.7.2 (Which I can't update to latest, right now)

I've added the following code in my theme's functions.php:

add_action('wp_head','wp_gravity_file_upload_preview');
function wp_gravity_file_upload_preview() {
    //if it is get_started form
    if ( is_page('13') ) {
        ?>
        <script type="text/javascript">
            jQuery(document).ready(function($) {
                gform.addFilter('gform_file_upload_markup', function (html, file, up, strings, imagesUrl) {
                    var formId = up.settings.multipart_params.form_id,
                       fieldId = up.settings.multipart_params.field_id;
                    html = "<img class='gform_delete' src='/wp-content/themes/brick-batten/assets/images/get-started/check-circle.jpg' " +
                           " alt='' title='Delete this file'> " +
                           "<strong>"+file.name+"</strong>&nbsp;&nbsp;" +
                           "<a href='javascript:;' onclick='gformDeleteUploadedFile(" + formId + "," + fieldId + ", this);' onkeypress='gformDeleteUploadedFile(" + formId + "," + fieldId + ", this);'><u style='color: #a5091e'>remove</u></a>"
                    return html;
                });
            });
        </script>
    <?php }
}

add_filter( 'gform_file_upload_markup', 'change_upload_markup_on_multipage_form', 1, 49 );
function change_upload_markup_on_multipage_form( $file_upload_markup, $file_info, $form_id, $field_id ) {
    if ( is_page('13') ) {
        return "<img class='gform_delete' src='/wp-content/themes/brick-batten/assets/images/get-started/check-circle.jpg' alt='' title='Delete this file'> 
               <strong>". esc_html($file_info['uploaded_filename']) ."</strong>&nbsp;&nbsp; 
               <a href='javascript:;' onclick='gformDeleteUploadedFile({$form_id}, {$field_id }, this);'><u style='color: #a5091e'>remove</u></a>";
    }
    return "";
}

add_filter( 'gform_next_button_1', function ($button, $form){
    $dom = new DOMDocument();
    $dom->loadHTML( $button );
    $input = $dom->getElementsByTagName( 'button' )->item(0);
    $onclick = $input->getAttribute( 'onclick' );
    $onclick = "preventSubmitForm();" . $onclick;
    $input->setAttribute( 'onclick', $onclick );
    return $dom->saveHtml( $input );
} , 10, 2);

Maybe it's related to the gravity-forms plugin? Please suggest me what's wrong in given code, any help would be appreciated. Thank you in advance!

1

There are 1 best solutions below

0
On

WordPress version: 5.7.2

there's your issue. Probably one of your plugins is calling this function which was introduced in 5.8 see the documentation

either search through your plugins code or disable one by one to find the offending one. or something on your server is calling this function - contact your server admin to find out what.