Example #1
0
 /**
  * Jetpack_Subscriptions::comment_subscribe_init()
  *
  * When a user checks the comment subscribe box and submits a comment, subscribe them to the comment thread.
  */
 function comment_subscribe_submit($comment_id, $approved)
 {
     if ('spam' === $approved) {
         return;
     }
     // Set cookies for this post/comment
     $this->set_cookies(isset($_REQUEST['subscribe_comments']), isset($_REQUEST['subscribe_blog']));
     if (!isset($_REQUEST['subscribe_comments']) && !isset($_REQUEST['subscribe_blog'])) {
         return;
     }
     $comment = get_comment($comment_id);
     $post_ids = array();
     if (isset($_REQUEST['subscribe_comments'])) {
         $post_ids[] = $comment->comment_post_ID;
     }
     if (isset($_REQUEST['subscribe_blog'])) {
         $post_ids[] = 0;
     }
     Jetpack_Subscriptions::subscribe($comment->comment_author_email, $post_ids, true, array('source' => 'comment-form', 'widget-in-use' => is_active_widget(false, false, 'blog_subscription', true) ? 'yes' : 'no', 'comment_status' => $approved, 'server_data' => $_SERVER));
 }
Example #2
0
 /**
  * Check Jetpack Subscription
  * @since 1.0.5
  * @version 1.0
  */
 protected function check_jetpack_subscription($email = NULL, $post_ids = NULL)
 {
     if ($email === NULL) {
         return 'missing';
     }
     if (!class_exists('Jetpack') && defined('JETPACK__PLUGIN_DIR')) {
         require_once JETPACK__PLUGIN_DIR . 'jetpack.php';
     }
     if (!class_exists('Jetpack_Subscriptions') && defined('JETPACK__PLUGIN_DIR')) {
         require_once JETPACK__PLUGIN_DIR . 'modules/subscriptions.php';
     }
     if ($post_ids === NULL) {
         $subscribe = Jetpack_Subscriptions::subscribe($email, 0, false);
     } else {
         $subscribe = Jetpack_Subscriptions::subscribe($email, $post_ids, false);
     }
     if (is_wp_error($subscribe)) {
         $error = $subscribe->get_error_code();
     } else {
         $error = false;
         foreach ($subscribe as $response) {
             if (is_wp_error($response)) {
                 $error = $response->get_error_code();
                 break;
             }
         }
     }
     if ($error) {
         switch ($error) {
             case 'invalid_email':
                 $return = 'invalid';
                 break;
             case 'active':
                 $return = 'active';
                 break;
             case 'pending':
                 $return = 'pending';
                 break;
             default:
                 $return = '';
                 break;
         }
     } else {
         if (is_array($subscribe) && $subscribe[0] === true) {
             $error = true;
         }
         $return = 'pending';
     }
     if ($error) {
         return $return;
     }
     return 'new';
 }
 public function test_sync_jetpack_published_post_should_set_dont_send_to_subscribers_flag()
 {
     Jetpack_Options::update_option('active_modules', array('subscriptions'));
     require_once JETPACK__PLUGIN_DIR . '/modules/subscriptions.php';
     Jetpack_Subscriptions::init();
     wp_update_post(array('ID' => $this->post->ID, 'post_status' => 'draft'));
     update_post_meta($this->post->ID, '_jetpack_dont_email_post_to_subs', 1);
     wp_publish_post($this->post->ID);
     $this->sender->do_sync();
     $post_flags = $this->server_event_storage->get_most_recent_event('jetpack_published_post')->args[1];
     $this->assertEquals($post_flags['_jetpack_dont_email_post_to_subs'], 1);
 }
Example #4
0
 /**
  * Jetpack_Subscriptions::comment_subscribe_init()
  *
  * When a user checks the comment subscribe box and submits a comment, subscribe them to the comment thread.
  */
 function comment_subscribe_submit($comment_id, $approved)
 {
     if ('spam' === $approved) {
         return;
     }
     // Set cookies for this post/comment
     $this->set_cookies(isset($_REQUEST['subscribe_comments']), isset($_REQUEST['subscribe_blog']));
     if (!isset($_REQUEST['subscribe_comments']) && !isset($_REQUEST['subscribe_blog'])) {
         return;
     }
     $comment = get_comment($comment_id);
     $post_ids = array();
     if (isset($_REQUEST['subscribe_comments'])) {
         $post_ids[] = $comment->comment_post_ID;
     }
     if (isset($_REQUEST['subscribe_blog'])) {
         $post_ids[] = 0;
     }
     Jetpack_Subscriptions::subscribe($comment->comment_author_email, $post_ids);
 }
 static function setupBeforeClass()
 {
     Jetpack_Subscriptions::init();
 }