diff --git a/projects/plugins/social/changelog/fix-social-site-editor b/projects/plugins/social/changelog/fix-social-site-editor new file mode 100644 index 0000000000000..7429b921e551b --- /dev/null +++ b/projects/plugins/social/changelog/fix-social-site-editor @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Site Editor: Prevent the editor extension loading for unsupported post types diff --git a/projects/plugins/social/src/class-jetpack-social.php b/projects/plugins/social/src/class-jetpack-social.php index 0ee91ff225218..e653834751b26 100644 --- a/projects/plugins/social/src/class-jetpack-social.php +++ b/projects/plugins/social/src/class-jetpack-social.php @@ -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 ) || + class_exists( 'Jetpack' ) || + ! $this->is_supported_post() + ) { return; }