1 ) { $str = array_pop( $pieces ); } else { break; } } while ( $str ); return $chars; } /** * Disables wpautop behavior in classic editor when post contains blocks, to * prevent removep from invalidating paragraph blocks. * * @param array $settings Original editor settings. * @param string $editor_id ID for the editor instance. * @return array Filtered settings. */ function gutenberg_disable_editor_settings_wpautop( $settings, $editor_id ) { $post = get_post(); if ( 'content' === $editor_id && is_object( $post ) && has_blocks( $post ) ) { $settings['wpautop'] = false; } return $settings; } add_filter( 'wp_editor_settings', 'gutenberg_disable_editor_settings_wpautop', 10, 2 ); /** * Add rest nonce to the heartbeat response. * * @param array $response Original heartbeat response. * @return array New heartbeat response. */ function gutenberg_add_rest_nonce_to_heartbeat_response_headers( $response ) { $response['rest-nonce'] = wp_create_nonce( 'wp_rest' ); return $response; } add_filter( 'wp_refresh_nonces', 'gutenberg_add_rest_nonce_to_heartbeat_response_headers' ); /** * As a substitute for the default content `wpautop` filter, applies autop * behavior only for posts where content does not contain blocks. * * @param string $content Post content. * @return string Paragraph-converted text if non-block content. */ function gutenberg_wpautop( $content ) { if ( has_blocks( $content ) ) { return $content; } return wpautop( $content ); } remove_filter( 'the_content', 'wpautop' ); add_filter( 'the_content', 'gutenberg_wpautop', 8 ); /** * Check if we need to load the block warning in the Classic Editor. * * @since 3.4.0 */ function gutenberg_check_if_classic_needs_warning_about_blocks() { global $pagenow; if ( ! in_array( $pagenow, array( 'post.php', 'post-new.php' ), true ) || ! isset( $_REQUEST['classic-editor'] ) ) { return; } $post = get_post(); if ( ! $post ) { return; } if ( ! has_blocks( $post ) && ! isset( $_REQUEST['cloudflare-error'] ) ) { return; } // Enqueue the JS we're going to need in the dialog. wp_enqueue_script( 'wp-a11y' ); wp_enqueue_script( 'wp-sanitize' ); if ( isset( $_REQUEST['cloudflare-error'] ) ) { add_action( 'admin_footer', 'gutenberg_warn_classic_about_cloudflare' ); } else { add_action( 'admin_footer', 'gutenberg_warn_classic_about_blocks' ); } } add_action( 'admin_enqueue_scripts', 'gutenberg_check_if_classic_needs_warning_about_blocks' ); /** * Adds a warning to the Classic Editor when trying to edit a post containing blocks. * * @since 3.4.0 */ function gutenberg_warn_classic_about_blocks() { $post = get_post(); $gutenberg_edit_link = get_edit_post_link( $post->ID, 'raw' ); $classic_edit_link = $gutenberg_edit_link; $classic_edit_link = add_query_arg( array( 'classic-editor' => '', 'hide-block-warning' => '', ), $classic_edit_link ); $revisions_link = ''; if ( wp_revisions_enabled( $post ) ) { $revisions = wp_get_post_revisions( $post ); // If there's only one revision, that won't help. if ( count( $revisions ) > 1 ) { reset( $revisions ); // Reset pointer for key(). $revisions_link = get_edit_post_link( key( $revisions ) ); } } ?>

browse previous revisions and restore a version of the post before it was edited in Gutenberg.', 'gutenberg' ), esc_url( $revisions_link ) ); ?>

  • change the REST API URL, to avoid triggering the WAF rules. Please be aware that this may cause issues with other plugins that use the REST API, and removes any other protection Cloudflare may be offering for the REST API.', 'gutenberg' ), 'https://github.com/WordPress/gutenberg/issues/2704#issuecomment-410582252' ); ?>

follow this issue for updates. We hope to have this issue rectified soon!', 'gutenberg' ), 'https://github.com/WordPress/gutenberg/issues/2704' ); ?>