'; } /** * Is this user banned from posting/liking/replying? */ function beep_user_is_banned($user_id) { if (!$user_id) { return false; } return get_user_meta($user_id, 'beep_banned', true) === '1'; } /** * Render the composer textarea (for logged-in, non-banned users). */ function beep_render_composer() { $user = wp_get_current_user(); $avatar = get_avatar($user->ID, 48, '', $user->display_name, ['class' => 'beep-avatar']); ob_start(); ?>
post_author); $avatar = get_avatar($author ? $author->ID : 0, 48, '', '', ['class' => 'beep-avatar']); $name = $author ? esc_html($author->display_name) : 'Unknown'; $handle = $author ? '@' . esc_html($author->user_login) : ''; $ts = strtotime($post->post_date_gmt . ' UTC'); $time = beep_relative_time($ts); $time_iso = gmdate('c', $ts); $time_full = mysql2date('F j, Y g:i a', $post->post_date); $content = beep_format_content($post->post_content); $like_count = Beep_Likes::get_count($post->ID, 'post'); $reply_count = Beep_Replies::reply_count($post->ID); $user_liked = Beep_Likes::user_has_liked($post->ID, 'post'); $can_delete = current_user_can('delete_post', $post->ID); $can_interact = is_user_logged_in() && !beep_user_is_banned(get_current_user_id()); $beep_images = Beep_Media::get_images($post->ID); $beep_video = Beep_Media::get_video_url($post->ID); $beep_voice = Beep_Media::get_voice_url($post->ID); ob_start(); ?>
·
ID); ?>
ID); ?>
ID); ?>
ID, 'beep_gif_url', true); ?>
GIF
ID); if ($poll) : ?>
%
votes Final results · Ends
ID, 0); ?>
ID); echo beep_render_replies_tree($all, 0, 0, $post->ID, $can_interact); ?>
comment_parent !== (int) $parent_id) { continue; } $out .= beep_render_reply($c, $comments, $depth, $post_id, $can_interact); } return $out; } /** * Render a single reply, plus its nested children. */ function beep_render_reply($comment, $all_comments = [], $depth = 0, $post_id = 0, $can_interact = false) { if (!$comment) { return ''; } $author_id = (int) $comment->user_id; $avatar = $author_id ? get_avatar($author_id, 36, '', '', ['class' => 'beep-avatar beep-avatar-sm']) : get_avatar($comment->comment_author_email, 36, '', '', ['class' => 'beep-avatar beep-avatar-sm']); $author = $author_id ? get_userdata($author_id) : null; $name = $author ? esc_html($author->display_name) : esc_html($comment->comment_author); $handle = $author ? '@' . esc_html($author->user_login) : ''; $ts = strtotime($comment->comment_date_gmt . ' UTC'); $time = beep_relative_time($ts); $time_iso = gmdate('c', $ts); $content = beep_format_content($comment->comment_content); $can_delete = current_user_can('moderate_comments'); $like_count = Beep_Likes::get_count($comment->comment_ID, 'reply'); $user_liked = Beep_Likes::user_has_liked($comment->comment_ID, 'reply'); $depth_class = 'beep-depth-' . min((int) $depth, 2); ob_start(); ?>
·
comment_ID); ?>
comment_ID, $depth + 1, $post_id, $can_interact); if ($children) { echo '
' . $children . '
'; } ?>
#' . esc_html($m[2]) . ''; }, $text); // @mentions $text = preg_replace_callback('/(^|\s)@([a-zA-Z0-9_]+)/', function ($m) { $user = get_user_by('login', $m[2]); if ($user) { return $m[1] . '@' . esc_html($m[2]) . ''; } return $m[1] . '@' . esc_html($m[2]) . ''; }, $text); // URLs $text = preg_replace_callback('#(https?://[^\s<]+)#i', function ($m) { $url = esc_url($m[1]); $display = parse_url($url, PHP_URL_HOST); if (!$display) { $display = $url; } return '' . esc_html($display) . ''; }, $text); // Line breaks $text = nl2br($text); return $text; } function beep_relative_time($timestamp) { $now = time(); $diff = $now - $timestamp; if ($diff < 0) { $diff = 0; } if ($diff < 60) { return $diff . 's'; } if ($diff < 3600) { return floor($diff / 60) . 'm'; } if ($diff < 86400) { return floor($diff / 3600) . 'h'; } if ($diff < 604800) { return floor($diff / 86400) . 'd'; } return gmdate('M j', $timestamp); } function beep_icon($name) { $icons = [ 'reply' => '', 'heart' => '', 'heart_filled' => '', 'share' => '', ]; return isset($icons[$name]) ? $icons[$name] : ''; } /** * Render the thread/conversation modal (sits outside individual posts). */ function beep_render_thread_modal() { return ''; } /** * Render the GIF picker modal. */ function beep_render_gif_modal() { return ''; }