sc0ttkclark / wordpress-fields-api

The 2024 Fields API proposal for WordPress Core
https://make.wordpress.org/core/tag/fields-api/
361 stars 42 forks source link

Override customizer and user edit screen instead of requiring patch outright #18

Closed sc0ttkclark closed 9 years ago

sc0ttkclark commented 9 years ago

Add hooks to auto-override customizer classes and user-edit.php for testing purposes.

Customizer manager class override:

remove_action( 'plugins_loaded', '_wp_customize_include' );
add_action( 'plugins_loaded', '_wp_fields_api_customize_include' );

User profile edit override:

add_action( 'load-user-edit.php', '_wp_fields_api_load_user_edit' );
sc0ttkclark commented 9 years ago

is_customize_preview() in wp-includes/theme.php will always return false because the class is no longer an instanceof WP_Customize_Manager:

/**
 * Whether the site is being previewed in the Customizer.
 *
 * @since 4.0.0
 *
 * @global WP_Customize_Manager $wp_customize Customizer instance.
 *
 * @return bool True if the site is being previewed in the Customizer, false otherwise.
 */
function is_customize_preview() {
    global $wp_customize;

    return ( $wp_customize instanceof WP_Customize_Manager ) && $wp_customize->is_preview();
}

Core will need a way for us to override this.

sc0ttkclark commented 9 years ago

Actually the above should be fine, our implementation uses WP_Customize_Manager and assumes the core class never gets loaded.

sc0ttkclark commented 9 years ago

Implemented in latest commits