Make WordPress Core

Changeset 43777


Ignore:
Timestamp:
10/22/2018 02:05:23 AM (6 years ago)
Author:
pento
Message:

Block Editor: Add an is_block_editor() method to WP_Screen.

This method allows checking (or setting) whether the block editor is loading on the current screen.

See #45037.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/src/wp-admin/includes/class-wp-screen.php

    r43502 r43777  
    181181     */
    182182    private $_screen_settings;
     183
     184    /**
     185     * Whether the screen is using the block editor.
     186     *
     187     * @since 5.0.0
     188     * @var bool
     189     */
     190    public $is_block_editor = false;
    183191
    184192    /**
     
    398406
    399407        return ( $admin == $this->in_admin );
     408    }
     409
     410    /**
     411     * Sets or returns whether the block editor is loading on the current screen.
     412     *
     413     * @since 5.0.0
     414     *
     415     * @param bool $set Optional. Sets whether the block editor is loading on the current screen or not.
     416     * @return bool True if the block editor is being loaded, false otherwise.
     417     */
     418    public function is_block_editor( $set = null ) {
     419        if ( $set !== null ) {
     420            $this->is_block_editor = (bool) $set;
     421        }
     422
     423        return $this->is_block_editor;
    400424    }
    401425
Note: See TracChangeset for help on using the changeset viewer.