function modify_column($column, $post_id) { switch ($column) { case 'user': $video = get_post($post_id); print get_avatar($video->post_author, 64); break; case 'likes': print mars_get_like_count($post_id); break; case 'views': print mars_get_count_viewed(); break; case 'layout': $layout = get_post_meta($post_id, 'layout', true) ? get_post_meta($post_id, 'layout', true) : 'small'; print $layout; break; } }
function mars_add_viewed() { if (!isset($_SESSION)) { session_start(); } global $post; if (is_single()) { if (isset($_SESSION['count_viewed'])) { if (in_array($post->ID, $_SESSION['count_viewed'])) { return; } } $current_viewed = mars_get_count_viewed(); update_post_meta($post->ID, 'count_viewed', $current_viewed + 1); $_SESSION['count_viewed'][] = $post->ID; } }