diff --git a/modules/publicize/publicize-jetpack.php b/modules/publicize/publicize-jetpack.php index ab37143368b07..410b40af95da5 100644 --- a/modules/publicize/publicize-jetpack.php +++ b/modules/publicize/publicize-jetpack.php @@ -425,7 +425,7 @@ function test_connection( $service_name, $connection ) { */ function save_publicized( $post_ID, $post, $update ) { // Only do this when a post transitions to being published - if ( get_post_meta( $post->ID, $this->PENDING ) ) { + if ( get_post_meta( $post->ID, $this->PENDING ) && $this->post_type_is_publicizeable( $post->post_type ) ) { $connected_services = Jetpack_Options::get_option( 'publicize_connections' ); if ( ! empty( $connected_services ) ) { /** diff --git a/tests/php/modules/publicize/test_class.publicize.php b/tests/php/modules/publicize/test_class.publicize.php index 63c45e5b10b82..f1d5f074d9b7f 100644 --- a/tests/php/modules/publicize/test_class.publicize.php +++ b/tests/php/modules/publicize/test_class.publicize.php @@ -56,6 +56,20 @@ public function test_filter_can_prevent_publicize() { $this->assertPublicized( false, $this->post ); } + + public function test_publicize_does_not_fire_on_post_types_that_do_not_support_it() { + $args = array( + 'public' => true, + 'label' => 'unregister post type' + ); + register_post_type( 'foo', $args ); + $this->post->post_type = 'foo'; + $this->post->post_status = 'publish'; + + wp_insert_post( $this->post->to_array() ); + + $this->assertPublicized( false, $this->post ); + } function assertPublicized( $should_have_publicized, $post ) { if ( $should_have_publicized ) {