Jetpack Publicize only certain categories

Unfortunately, Jetpack Publicize module don’t have the option to choose which category of posts you want to publicize automatically. Here is the quick hack to publicize module file in order to publish future posts only from chosen category.

add_filter('wpas_submit_post?', 'vipx_wpas_submit_post', 10, 4);
function vipx_wpas_submit_post($ret, $post_id, $name, $connection) {
 $categories = get_the_terms($post_id, 'category');
 if (is_array($categories)) {
 $categories = wp_list_pluck($categories, 'slug');
 }
 if (empty($categories)) {
 return;
 }
 if (in_array('SLUG-OF-YOUR-CATEGORY', $categories)) {
 $ret = false;
 }
 return $ret;
}

Simply add this code after

class Publicize extends Publicize_Base {
function __construct() {
parent::__construct();

by editing wp-content/plugins/jetpack/modules/publicize/publicize-jetpack.php file

28-03-2016-11-44-14

You can put several categories followed by slug from which you want to push posts to social networks.

Additionally you can publicize your posts to twitter with adding automatically hashtags from tags by installing Publicize With Hashtags plugin