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

Fix: Only send publicize action for post types that support it. #5381

Merged
merged 1 commit into from Oct 20, 2016
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/publicize/publicize-jetpack.php
Expand Up @@ -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 ) ) {
/**
Expand Down
14 changes: 14 additions & 0 deletions tests/php/modules/publicize/test_class.publicize.php
Expand Up @@ -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 ) {
Expand Down