jetpack icon indicating copy to clipboard operation
jetpack copied to clipboard

Sharing: publicize_should_publicize_published_post filter ignored via API/XML-RPC

Open clreed87 opened this issue 8 years ago • 4 comments

Steps to reproduce the issue

  1. Create filter to exclude category
  2. Publish post in that category via WordPress app

What I expected

Expected post to be omitted from publicize

What happened instead

Filter returned true and post was published

clreed87 avatar Jan 16 '18 01:01 clreed87

Could you give us more details about this?

  • What is the URL of the post that got publicized?
  • What is the code snippet you use on your site to exclude categories?
  • What WordPress app did you use to post? A mobile app? A desktop app? Could you specify the version as well?

Thank you!

jeherve avatar Jan 16 '18 10:01 jeherve

Sure! Here are some more details:

Here is the filter I’m using in a site specific plugin:

// Do not trigger Jetpack Publicize if the post uses the 'status' post format.
add_filter( 'publicize_should_publicize_published_post', 'minimum_control_publicize', 10, 2 );
function minimum_control_publicize( $should_publicize, $post ) {
	// Return early if we don't have a post yet (it hasn't been saved as a draft)
	if ( !$post ) {
		return $should_publicize;
	}
	
	// Return false is the format is 'status'
	if ( has_post_format( 'status' ) ) {
		return false;
	}
	return $should_publicize;
}

This post was published using the Workflow for iOS app and set as a status post format and still triggered publicize:

http://www.chrisreedtech.com/960-2/

I’ve tried the following apps:

  1. WordPress for iOS (v. 9.0.1)
  2. Workflow for iOS
  3. Micro.Blog iOS and Desktop apps

Let me know if there’s any other details I can provide.

clreed87 avatar Jan 16 '18 14:01 clreed87

I'm not sure that snippet is going to work. Since you are not in the loop, when using has_post_format you would need to specify a post ID, like so:

if ( has_post_format( 'status', $post->ID ) ) { (reference)

Let me know how it goes.

jeherve avatar Jan 16 '18 20:01 jeherve

Thanks worked! Thanks--it was confusing because without the post ID it was still working via the post editor. Sorry for the false alarm and I really appreciate the help.

clreed87 avatar Jan 17 '18 05:01 clreed87