mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-05-02 12:02:25 +08:00
20 lines
761 B
Text
20 lines
761 B
Text
function jeherve_control_publicize_for_categories( $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;
|
|
}
|
|
|
|
// Get list of categories for our post.
|
|
$categories = get_the_category( $post->ID );
|
|
|
|
if ( is_array( $categories ) && ! empty( $categories ) ) {
|
|
foreach( $categories as $category ) {
|
|
if ( 'do-not-publicize' === $category->slug ) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
return $should_publicize;
|
|
}
|
|
add_filter( 'publicize_should_publicize_published_post', 'jeherve_control_publicize_for_categories', 10, 2 );
|