コード例 #1
0
 public static function manual_send()
 {
     if (isset($_POST['manualtext'])) {
         $manual_text = $_POST['manualtext'];
         $manual_link = $_POST['manuallink'];
         $manual_text = stripslashes($manual_text);
         if ('' == $manual_text || '' == $manual_link) {
             $status = 'Your message or link can not be blank.';
         } else {
             $roost_settings = self::roost_settings();
             $app_key = $roost_settings['appKey'];
             $app_secret = $roost_settings['appSecret'];
             if (false === strpos($manual_link, 'http')) {
                 $manual_link = 'http://' . $manual_link;
             }
             $msg_status = Roost_API::send_notification($manual_text, $manual_link, null, $app_key, $app_secret, null);
             if (true === $msg_status['success']) {
                 $status = 'Message Sent.';
             } else {
                 $status = 'Message failed. Please make sure you have a valid URL.';
             }
         }
         $status = urlencode($status);
         wp_redirect(admin_url('admin.php?page=roost-web-push') . '&status=' . $status);
         exit;
     }
 }
コード例 #2
0
    public static function roost_bbp_notify_subscribers( $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author = 0 ) {
        $topic_id = bbp_get_topic_id( $topic_id );
        $forum_id = bbp_get_forum_id( $forum_id );

        if ( ! bbp_is_topic_published( $topic_id ) ) {
            return false;
        }

        $topic_title = bbp_get_topic_title( $topic_id );
        $topic_url = get_permalink( $topic_id );
        if ( isset( $_POST['bbp_reply_to'] ) ) {
            $reply_to_id = $_POST['bbp_reply_to'];
        }

        $roost_settings = ROOST::roost_settings();
        $app_key = $roost_settings['appKey'];
        $app_secret = $roost_settings['appSecret'];

        $message = 'New Post in ' . $topic_title;

        if ( ! empty( $reply_to_id ) ) {
            $reply_subscriptions = get_post_meta( $reply_to_id, '_roost_bbp_subscription', true );
        }

        $topic_subscriptions = get_post_meta( $topic_id, '_roost_bbp_subscription', true );
        $forum_subscriptions = get_post_meta( $forum_id, '_roost_bbp_subscription', true );

        if ( ! empty( $reply_subscriptions ) ) {
            $device_tokens = array();
            foreach( $reply_subscriptions as $token => $active ) {
                $device_tokens[] = $token;
            }
        }

        if ( ! empty( $topic_subscriptions ) ) {
            if ( empty( $device_tokens ) ) {
                $device_tokens = array();
            }
            foreach( $topic_subscriptions as $token => $active ) {
                $device_tokens[] = $token;
            }
        }

        if ( ! empty( $forum_subscriptions ) ) {
            if ( empty( $device_tokens ) ) {
                $device_tokens = array();
            }
            foreach( $forum_subscriptions as $token => $active ) {
                $device_tokens[] = $token;
            }
        }

        if ( empty( $device_tokens) ) {
            return;
        }
        Roost_API::send_notification( $message, $topic_url, null, $app_key, $app_secret, $device_tokens, null );
    }