Skip to content

Commit

Permalink
Update is_fse_active to account for a8c_disable_full_site_editing fil…
Browse files Browse the repository at this point in the history
…ter (#13392)

* Update is_fse_active to account for a8c_disable_full_site_editing filter

* Fix method check and add dockblock comment

* Fix typo

* Update docblock to allow parser to create Codex page for filter


Co-authored-by: Glen Davies <glen.davies@a8c.com>
Co-authored-by: Jeremy Herve <jeremy@jeremy.hu>
  • Loading branch information
3 people committed Sep 3, 2019
1 parent f35498e commit 308b9c4
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions sal/class.json-api-site-jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,39 @@ function current_user_can( $role ) {
return current_user_can( $role );
}

/**
* Check if full site editing should be considered as currently active. Full site editing
* requires the FSE plugin to be installed and activated, as well the current
* theme to be FSE compatible. The plugin can also be explicitly disabled via the
* a8c_disable_full_site_editing filter.
*
* @since 7.7.0
*
* @return bool true if full site editing is currently active.
*/
function is_fse_active() {
$fse_enabled = Jetpack::is_plugin_active( 'full-site-editing/full-site-editing-plugin.php' );
$has_method = method_exists( '\A8C\FSE\Full_Site_Editing', 'is_supported_theme' );
if ( $fse_enabled && $has_method ) {
$fse = \A8C\FSE\Full_Site_Editing::get_instance();
$slug = get_option( 'stylesheet' );
return $fse->is_supported_theme( $slug );
if ( ! Jetpack::is_plugin_active( 'full-site-editing/full-site-editing-plugin.php' ) ) {
return false;
}
if (
/**
* Allow disabling Full Site Editing, even when the FSE plugin is active.
*
* @module json-api
*
* @since 7.7.0
*
* @param bool $disable_fse Disable Full Site Editing. Defaults to false.
*/
apply_filters( 'a8c_disable_full_site_editing', false )
) {
return false;
}
$has_is_supported_theme_method = method_exists( '\A8C\FSE\Full_Site_Editing', 'is_supported_theme' );
$has_normalize_theme_slug = method_exists( '\A8C\FSE\Full_Site_Editing', 'normalize_theme_slug' );
if ( $has_is_supported_theme_method && $has_normalize_theme_slug ) {
$slug = \A8C\FSE\Full_Site_Editing::get_instance()->normalize_theme_slug( get_option( 'stylesheet' ) );
return \A8C\FSE\Full_Site_Editing::get_instance()->is_supported_theme( $slug );
}
return false;
}
Expand Down

0 comments on commit 308b9c4

Please sign in to comment.