Making WordPress.org

Changeset 7476


Ignore:
Timestamp:
07/19/2018 03:04:13 AM (7 years ago)
Author:
coreymckrill
Message:

WordCamp Gutenberg Tweaks: Add hotfix for wpApiSettings bug

Starting in Gutenberg 3.1, the 'wp-api-request' script gets de-registered
and re-registered with a Gutenberg-specific version. Unfortunately, the
script doesn't also get re-localized with the wpApiSettings variable that's
needed for wp-api.js, unless the current screen contains an editor instance.

The bug was reported here:
https://github.com/WordPress/gutenberg/issues/7488

And it should be fixed once the changes in this pull request get released:
https://github.com/WordPress/gutenberg/pull/7566

In the meantime, this hotfix should ensure that wpApiSettings is available
regardless of the presence of an editor instance.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/gutenberg-tweaks.php

    r7459 r7476  
    3232        add_action( 'admin_print_scripts-edit.php', __NAMESPACE__ . '\add_classic_param_to_add_new_button', 11    );
    3333        add_action( 'admin_print_scripts',          __NAMESPACE__ . '\add_classic_param_to_admin_menus',     1    );
     34
     35        // @todo Hotfix for Gutenberg 3.1-3.2 breaking wpApiSettings. This will hopefully be unnecessary with 3.3.
     36        // See https://github.com/WordPress/gutenberg/issues/7488
     37        // See https://github.com/WordPress/gutenberg/pull/7566
     38        if ( ! wp_script_is( 'wp-api-fetch', 'registered' ) ) {
     39            add_action( 'wp_enqueue_scripts', 'gutenberg_extend_wp_api_backbone_client' );
     40            add_action( 'admin_enqueue_scripts', 'gutenberg_extend_wp_api_backbone_client' );
     41        }
    3442    }
    3543}
Note: See TracChangeset for help on using the changeset viewer.