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

Social: Prevent the editor extension loading for unsupported post types #24545

Merged
merged 2 commits into from
May 30, 2022
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
4 changes: 4 additions & 0 deletions projects/plugins/social/changelog/fix-social-site-editor
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Site Editor: Prevent the editor extension loading for unsupported post types
16 changes: 15 additions & 1 deletion projects/plugins/social/src/class-jetpack-social.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,25 @@ public function initial_state() {
);
}

/**
* Checks to see if the current post supports Publicize
*
* @return boolean True if Publicize is supported
*/
public function is_supported_post() {
$post_type = get_post_type();
return ! empty( $post_type ) && post_type_supports( $post_type, 'publicize' );
}

/**
* Enqueue block editor scripts and styles.
*/
public function enqueue_block_editor_scripts() {
if ( ! ( new Modules() )->is_active( self::JETPACK_PUBLICIZE_MODULE_SLUG ) || class_exists( 'Jetpack' ) ) {
if (
! ( new Modules() )->is_active( self::JETPACK_PUBLICIZE_MODULE_SLUG ) ||
spsiddarthan marked this conversation as resolved.
Show resolved Hide resolved
class_exists( 'Jetpack' ) ||
! $this->is_supported_post()
) {
return;
}

Expand Down