function publish_post_to_discourse($new_status, $old_status, $post)
{
$publish_to_discourse = get_post_meta($post->ID, 'publish_to_discourse', true);
$publish_post_category = get_post_meta($post->ID, 'publish_post_category', true);
if ((self::publish_active() || !empty($publish_to_discourse)) && $new_status == 'publish' && self::is_valid_sync_post_type($post->ID)) {
// This seems a little redundant after `save_postdata` but when using the Press This
// widget it updates the field as it should.
if (isset($_POST['publish_post_category'])) {
#delete_post_meta( $post->ID, 'publish_post_category');
add_post_meta($post->ID, 'publish_post_category', $_POST['publish_post_category'], true);
}
add_post_meta($post->ID, 'publish_to_discourse', '1', true);
self::sync_to_discourse($post->ID, $post->post_title, $post->post_content);
}
}