// =========================================================
// Notifications API
// =========================================================
add_action('rest_api_init', function () {
register_rest_route('flexmoviez/v1', '/notifications', array(
'methods' => 'GET',
'callback' => 'flexmoviez_api_get_notifications',
'permission_callback' => function () {
return is_user_logged_in();
},
));
});
function flexmoviez_api_get_notifications(WP_REST_Request $request) {
$user_id = get_current_user_id();
// اعلانهای خواندهشده کاربر
$read_notifications = get_user_meta(
$user_id,
'_read_notifications',
true
);
if (!is_array($read_notifications)) {
$read_notifications = array();
}
// تعداد مورد نیاز
$limit = absint($request->get_param('limit'));
if ($limit <= 0) {
$limit = 20;
}
if ($limit > 100) {
$limit = 100;
}
$notifications = flexmoviez_get_notifications($limit);
$items = array();
if ($notifications->have_posts()) {
while ($notifications->have_posts()) {
$notifications->the_post();
$notification_id = get_the_ID();
$link = get_post_meta(
$notification_id,
'_notification_link',
true
);
$type = get_post_meta(
$notification_id,
'_notification_type',
true
);
$content = get_the_content();
$content = wp_strip_all_tags($content);
$items[] = array(
'id' => $notification_id,
'title' => get_the_title(),
'content' => $content,
'link' => !empty($link)
? esc_url_raw($link)
: '',
'type' => !empty($type)
? $type
: 'general',
'is_read' => in_array(
$notification_id,
$read_notifications
),
'date' => get_the_date(
'c',
$notification_id
),
);
}
wp_reset_postdata();
}
return rest_ensure_response(array(
'success' => true,
'unread_count' =>
flexmoviez_get_unread_notifications_count(),
'notifications' => $items,
));
}
دانلود فیلم های بازیگر_30769 - صفحه 54 از 2020 - مشهد فیلم - مرجع دانلود فیلم و سریال کلاسیک و نایاب
بازیگر_30769
42418 فیلم و سریال
فیلمها و
سریالهای بازیگر_30769
خانه
فیلم
سریال
پنل کاربری