예제 #1
0
function ap_get_the_total_unread_notification($user_id = false, $echo = false)
{
    $count = ap_get_total_unread_notification();
    $count = $count >= 10 ? __('9+', 'ap') : $count;
    $count = $count != 0 ? '<span class="counter" data-view="notification_count">' . $count . '</span>' : '';
    if ($echo) {
        echo $count;
    }
    return $count;
}
예제 #2
0
 public function markread_notification()
 {
     $id = (int) $_POST['id'];
     if (isset($_POST['id']) && !wp_verify_nonce($_POST['__nonce'], 'ap_markread_notification_' . $id) && !is_user_logged_in()) {
         ap_send_json(ap_ajax_responce('something_wrong'));
         return;
     } elseif (!wp_verify_nonce($_POST['__nonce'], 'ap_markread_notification_' . get_current_user_id()) && !is_user_logged_in()) {
         ap_send_json(ap_ajax_responce('something_wrong'));
         return;
     }
     if (isset($_POST['id'])) {
         $notification = ap_get_notification_by_id($id);
         if ($notification && ($notification['apmeta_actionid'] == get_current_user_id() || is_super_admin())) {
             $row = ap_update_meta(array('apmeta_type' => 'notification'), array('apmeta_id' => $notification['apmeta_id']));
             if ($row !== false) {
                 ap_send_json(ap_ajax_responce(array('message' => 'mark_read_notification', 'action' => 'mark_read_notification', 'container' => '.ap-notification-' . $notification['apmeta_id'], 'view' => array('notification_count' => ap_get_total_unread_notification()))));
             }
         }
     } else {
         $row = ap_notification_mark_all_read(get_current_user_id());
         if ($row !== false) {
             ap_send_json(ap_ajax_responce(array('message' => 'mark_read_notification', 'action' => 'mark_all_read', 'container' => '#ap-notification-dropdown', 'view' => array('notification_count' => '0'))));
         }
     }
     //if process reached here then there must be something wrong
     ap_send_json(ap_ajax_responce('something_wrong'));
 }
예제 #3
0
파일: ajax.php 프로젝트: alaershov/anspress
 /**
  * Handle ajax callback for mark all notification as read
  */
 public function set_notifications_as_read()
 {
     $ids = sanitize_text_field($_POST['ids']);
     $ids = explode(',', $ids);
     if (count($ids) == 0) {
         wp_die();
     }
     if (!ap_verify_default_nonce() && !is_user_logged_in()) {
         wp_die();
     }
     foreach ($ids as $id) {
         $id = (int) $id;
         if (0 != $id) {
             ap_notification_mark_as_read($id, get_current_user_id());
         }
     }
     $this->send(array('container' => '#ap-notification-dropdown', 'view' => array('notification_count' => ap_get_total_unread_notification())));
     wp_die();
 }
예제 #4
0
 /**
  * Handle ajax callback for mark all notification as read
  */
 public function markread_notification()
 {
     $id = (int) $_POST['id'];
     if (isset($_POST['id']) && !ap_verify_nonce('ap_markread_notification_' . $id) && !is_user_logged_in()) {
         $this->something_wrong();
     } elseif (!ap_verify_nonce('ap_markread_notification_' . get_current_user_id()) && !is_user_logged_in()) {
         $this->something_wrong();
     }
     if (isset($_POST['id'])) {
         $notification = ap_get_notification_by_id($id);
         if ($notification && (get_current_user_id() == $notification['apmeta_actionid'] || is_super_admin())) {
             $row = ap_update_meta(array('apmeta_type' => 'notification'), array('apmeta_id' => $notification['apmeta_id']));
             if (false !== $row) {
                 $this->send(array('message' => 'mark_read_notification', 'action' => 'mark_read_notification', 'container' => '.ap-notification-' . $notification['apmeta_id'], 'view' => array('notification_count' => ap_get_total_unread_notification())));
             }
         }
     } else {
         $row = ap_notification_mark_all_read(get_current_user_id());
         if (false !== $row) {
             $this->send(array('message' => 'mark_read_notification', 'action' => 'mark_all_read', 'container' => '#ap-notification-dropdown', 'view' => array('notification_count' => '0')));
         }
     }
     $this->something_wrong();
 }