Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full Site Editing: add a is_fse_active property to the Site object in the REST API #13196

Merged
merged 4 commits into from
Aug 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions json-endpoints/class.wpcom-json-api-get-site-endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class WPCOM_JSON_API_GET_Site_Endpoint extends WPCOM_JSON_API_Endpoint {
'meta' => '(object) Meta data',
'quota' => '(array) An array describing how much space a user has left for uploads',
'launch_status' => '(string) A string describing the launch status of a site',
'is_fse_active' => '(bool) If the site has Full Site Editing active or not.',
);

protected static $no_member_fields = array(
Expand All @@ -70,6 +71,7 @@ class WPCOM_JSON_API_GET_Site_Endpoint extends WPCOM_JSON_API_Endpoint {
'is_following',
'meta',
'launch_status',
'is_fse_active',
);

protected static $site_options_format = array(
Expand Down Expand Up @@ -373,6 +375,9 @@ protected function render_response_key( $key, &$response, $is_user_logged_in ) {
case 'launch_status' :
$response[ $key ] = $this->site->get_launch_status();
break;
case 'is_fse_active':
$response[ $key ] = $this->site->is_fse_active();
break;
}

do_action( 'post_render_site_response_key', $key );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class WPCOM_JSON_API_GET_Site_V1_2_Endpoint extends WPCOM_JSON_API_GET_Site_Endp
'meta' => '(object) Meta data',
'quota' => '(array) An array describing how much space a user has left for uploads',
'launch_status' => '(string) A string describing the launch status of a site',
'is_fse_active' => '(bool) If the site has Full Site Editing active or not.',
);


Expand Down
11 changes: 11 additions & 0 deletions sal/class.json-api-site-jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,17 @@ function current_user_can( $role ) {
return current_user_can( $role );
}

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 );
}
return false;
}

/**
* Post functions
*/
Expand Down