Example #1
0
 function __construct()
 {
     global $publicize_ui;
     $this->in_jetpack = class_exists('Jetpack') && method_exists('Jetpack', 'enable_module_configurable') ? true : false;
     if ($this->in_jetpack && method_exists('Jetpack', 'module_configuration_load')) {
         Jetpack::enable_module_configurable(__FILE__);
         Jetpack::module_configuration_load(__FILE__, array($this, 'jetpack_configuration_load'));
         Jetpack_Sync::sync_posts(__FILE__);
     }
     require_once dirname(__FILE__) . '/publicize/publicize.php';
     if ($this->in_jetpack) {
         require_once dirname(__FILE__) . '/publicize/publicize-jetpack.php';
     } else {
         require_once dirname(dirname(__FILE__)) . '/mu-plugins/keyring/keyring.php';
         require_once dirname(__FILE__) . '/publicize/publicize-wpcom.php';
     }
     require_once dirname(__FILE__) . '/publicize/ui.php';
     $publicize_ui = new Publicize_UI();
     $publicize_ui->in_jetpack = $this->in_jetpack;
     // Jetpack specific checks / hooks
     if ($this->in_jetpack) {
         add_action('jetpack_activate_module_publicize', array($this, 'module_state_toggle'));
         add_action('jetpack_deactivate_module_publicize', array($this, 'module_state_toggle'));
         // if sharedaddy isn't active, the sharing menu hasn't been added yet
         $active = Jetpack::get_active_modules();
         if (in_array('publicize', $active) && !in_array('sharedaddy', $active)) {
             add_action('admin_menu', array(&$publicize_ui, 'sharing_menu'));
         }
     }
 }
function stats_load()
{
    global $wp_roles;
    Jetpack::enable_module_configurable(__FILE__);
    Jetpack::module_configuration_load(__FILE__, 'stats_configuration_load');
    Jetpack::module_configuration_head(__FILE__, 'stats_configuration_head');
    Jetpack::module_configuration_screen(__FILE__, 'stats_configuration_screen');
    // Tell HQ about changed posts
    $post_stati = get_post_stati(array('public' => true));
    // All public post stati
    $post_stati[] = 'private';
    // Content from private stati will be redacted
    Jetpack_Sync::sync_posts(__FILE__, array('post_types' => get_post_types(array('public' => true)), 'post_stati' => $post_stati));
    // Generate the tracking code after wp() has queried for posts.
    add_action('template_redirect', 'stats_template_redirect', 1);
    add_action('wp_head', 'stats_admin_bar_head', 100);
    add_action('wp_head', 'stats_hide_smile_css');
    add_action('jetpack_admin_menu', 'stats_admin_menu');
    // Map stats caps
    add_filter('map_meta_cap', 'stats_map_meta_caps', 10, 4);
    if (isset($_GET['oldwidget'])) {
        // Old one.
        add_action('wp_dashboard_setup', 'stats_register_dashboard_widget');
    } else {
        add_action('admin_init', 'stats_merged_widget_admin_init');
    }
    add_filter('jetpack_xmlrpc_methods', 'stats_xmlrpc_methods');
    add_filter('pre_option_db_version', 'stats_ignore_db_version');
}
 function action_init()
 {
     //syncing must wait until after init so
     //post types that support comments
     $filt_post_types = array();
     $all_post_types = get_post_types();
     foreach ($all_post_types as $post_type) {
         if (post_type_supports($post_type, 'comments')) {
             $filt_post_types[] = $post_type;
         }
     }
     Jetpack_Sync::sync_posts(__FILE__, array('post_types' => $filt_post_types, 'post_stati' => array('publish')));
     Jetpack_Sync::sync_comments(__FILE__, array('post_types' => $filt_post_types, 'post_stati' => array('publish'), 'comment_stati' => array('approve', 'approved', '1', 'hold', 'unapproved', 'unapprove', '0', 'spam', 'trash')));
     if (defined('DOING_AJAX') && DOING_AJAX) {
         return;
     }
     if (!has_filter('show_admin_bar', '__return_true') && !is_user_logged_in()) {
         return;
     }
     if (!self::current_browser_is_supported()) {
         return;
     }
     add_action('admin_bar_menu', array(&$this, 'admin_bar_menu'), 120);
     add_action('wp_head', array(&$this, 'styles_and_scripts'), 120);
     add_action('admin_head', array(&$this, 'styles_and_scripts'));
 }
 function sync_posts_init()
 {
     $post_types = array('post', 'page');
     $all_post_types = get_post_types();
     foreach ($all_post_types as $post_type) {
         // sync Custom Post Types that support publicize
         if (post_type_supports($post_type, 'publicize')) {
             $post_types[] = $post_type;
         }
     }
     Jetpack_Sync::sync_posts(__FILE__, array('post_types' => $post_types));
 }
 /**
  * This action triggers if the module is in an active state, load related posts and options.
  *
  * @uses Jetpack_RelatedPosts::init, is_admin, Jetpack::enable_module_configurable, Jetpack::module_configuration_load, Jetpack_Sync::sync_posts
  * @return null
  */
 public function action_on_load()
 {
     require_once 'related-posts/jetpack-related-posts.php';
     Jetpack_RelatedPosts::init();
     if (is_admin()) {
         // Enable "Configure" button on module card
         Jetpack::enable_module_configurable(__FILE__);
         Jetpack::module_configuration_load(__FILE__, array($this, 'module_configuration_load'));
         // Sync new posts
         Jetpack_Sync::sync_posts(__FILE__);
     }
 }
Example #6
0
 function Jetpack_Notifications()
 {
     $this->jetpack = Jetpack::init();
     add_action('init', array(&$this, 'action_init'));
     //post types that support comments
     $filt_post_types = array();
     foreach (get_post_types() as $post_type) {
         if (post_type_supports($post_type, 'comments')) {
             $filt_post_types[] = $post_type;
         }
     }
     Jetpack_Sync::sync_posts(__FILE__, array('post_types' => $filt_post_types, 'post_stati' => array('publish')));
     Jetpack_Sync::sync_comments(__FILE__, array('post_types' => $filt_post_types, 'post_stati' => array('publish'), 'comment_stati' => array('approve', 'approved', '1', 'hold', 'unapproved', 'unapprove', '0', 'spam', 'trash')));
 }
Example #7
0
 function admin_init()
 {
     add_filter('manage_posts_columns', array($this, 'add_like_count_column'));
     add_filter('manage_pages_columns', array($this, 'add_like_count_column'));
     add_action('manage_posts_custom_column', array($this, 'likes_edit_column'), 10, 2);
     add_action('manage_pages_custom_column', array($this, 'likes_edit_column'), 10, 2);
     add_action('admin_print_styles-edit.php', array($this, 'load_admin_css'));
     add_action("admin_print_scripts-edit.php", array($this, 'enqueue_admin_scripts'));
     if ($this->in_jetpack) {
         $post_stati = get_post_stati(array('public' => true));
         // All public post stati
         $post_stati[] = 'private';
         // Content from private stati will be redacted
         Jetpack_Sync::sync_posts(__FILE__, array('post_types' => get_post_types(array('public' => true)), 'post_stati' => $post_stati));
     }
 }
Example #8
0
<?php

/**
 * Module Name: Subscriptions
 * Module Description: Allow users to subscribe to your posts and comments and receive notifications via email.
 * Sort Order: 9
 * First Introduced: 1.2
 * Requires Connection: Yes
 * Auto Activate: Yes
 * Module Tags: Social
 */
add_action('jetpack_modules_loaded', 'jetpack_subscriptions_load');
Jetpack_Sync::sync_options(__FILE__, 'home', 'blogname', 'siteurl', 'page_on_front', 'permalink_structure', 'category_base', 'rss_use_excerpt', 'subscription_options', 'stb_enabled', 'stc_enabled', 'tag_base');
Jetpack_Sync::sync_posts(__FILE__);
Jetpack_Sync::sync_comments(__FILE__);
function jetpack_subscriptions_load()
{
    Jetpack::enable_module_configurable(__FILE__);
    Jetpack::module_configuration_load(__FILE__, 'jetpack_subscriptions_configuration_load');
}
function jetpack_subscriptions_configuration_load()
{
    wp_safe_redirect(admin_url('options-discussion.php#jetpack-subscriptions-settings'));
    exit;
}
class Jetpack_Subscriptions
{
    var $jetpack = false;
    public static $hash;
    /**
     * Singleton
 * Requires Connection: Yes
 * Auto Activate: No
 * Module Tags: Centralized Management, Recommended
 * Feature: Recommended, Jumpstart
 */
add_action('jetpack_activate_module_manage', array(Jetpack::init(), 'toggle_module_on_wpcom'));
add_action('jetpack_deactivate_module_manage', array(Jetpack::init(), 'toggle_module_on_wpcom'));
add_action('customize_register', 'add_wpcom_to_allowed_redirect_hosts');
// Add wordpress.com to the safe redirect whitelist if the Manage module is enabled
// so the customizer can `return` to wordpress.com if invoked from there.
function add_wpcom_to_allowed_redirect_hosts($domains)
{
    if (Jetpack::is_module_active('manage')) {
        add_filter('allowed_redirect_hosts', 'allow_wpcom_domain');
    }
}
// Return $domains, with 'wordpress.com' appended.
function allow_wpcom_domain($domains)
{
    if (empty($domains)) {
        $domains = array();
    }
    $domains[] = 'wordpress.com';
    return array_unique($domains);
}
// Re add sync for non public posts when the optin is selected in Calypso.
// This will only work if you have manage enabled as well.
if (Jetpack_Options::get_option('sync_non_public_post_stati')) {
    $sync_options = array('post_types' => get_post_types(array('public' => true)), 'post_stati' => get_post_stati());
    Jetpack_Sync::sync_posts(__FILE__, $sync_options);
}
Example #10
0
 function admin_init()
 {
     add_filter('manage_posts_columns', array($this, 'add_like_count_column'));
     add_filter('manage_pages_columns', array($this, 'add_like_count_column'));
     add_action('manage_posts_custom_column', array($this, 'likes_edit_column'), 10, 2);
     add_action('manage_pages_custom_column', array($this, 'likes_edit_column'), 10, 2);
     add_action('admin_print_styles-edit.php', array($this, 'load_admin_css'));
     add_action("admin_print_scripts-edit.php", array($this, 'enqueue_admin_scripts'));
     if ($this->in_jetpack) {
         Jetpack_Sync::sync_posts(__FILE__);
     }
 }