function dwqa_get_latest_action_date($question = false, $before = '<span>', $after = '</span>') { if (!$question) { $question = get_the_ID(); } $message = ''; $latest_answer = dwqa_get_latest_answer($question); $post_id = $latest_answer ? $latest_answer->ID : $question; $author_id = get_post_field('post_author', $post_id); if ($author_id == 0 || dwqa_is_anonymous($post_id)) { $author_link = __('Anonymous', 'dwqa'); } else { $display_name = get_the_author_meta('display_name', $author_id); $author_link = sprintf('<span class="dwqa-author"><span class="dwqa-user-avatar">%4$s</span> <a href="%1$s" title="%2$s" rel="author">%3$s</a></span>', get_author_posts_url($author_id), esc_attr(sprintf(__('Posts by %s'), $display_name)), $display_name, get_avatar($author_id, 12)); } if ($latest_answer) { $date = dwqa_human_time_diff(strtotime($latest_answer->post_date), false, get_option('date_format')); return sprintf(__('%s answered <span class="dwqa-date">%s</span>', 'dwqa'), $author_link, $date); } return sprintf(__('%s asked <span class="dwqa-date">%s</span>', 'dwqa'), $author_link, get_the_date()); }
the_permalink(); ?> "><?php the_title(); ?> </a></header> <div class="dwqa-question-meta"> <?php dwqa_question_print_status(); ?> <?php global $post; $user_id = get_post_field('post_author', get_the_ID()) ? get_post_field('post_author', get_the_ID()) : false; $time = human_time_diff(get_post_time('U')); $text = __('asked', 'dwqa'); $latest_answer = dwqa_get_latest_answer(); if ($latest_answer) { $time = human_time_diff(strtotime($latest_answer->post_date)); $text = __('answered', 'dwqa'); } ?> <?php printf(__('<span><a href="%s">%s%s</a> %s %s ago</span>', 'dwqa'), dwqa_get_author_link($user_id), get_avatar($user_id, 48), dwqa_get_author(), $text, $time); ?> <?php echo get_the_term_list(get_the_ID(), 'dwqa-question_category', '<span class="dwqa-question-category">' . __(' • ', 'dwqa'), ', ', '</span>'); ?> </div> <div class="dwqa-question-stats"> <span class="dwqa-views-count"> <?php
function dwqa_have_new_reply($question_id = false) { //if latest answer is not administrator if (!$question_id) { $question_id = get_the_ID(); } $latest_answer = dwqa_get_latest_answer($question_id); if ($latest_answer) { if (dwqa_is_staff_answer($latest_answer)) { //answered return 'staff-answered'; } else { //Is open return strtotime($latest_answer->post_date); } } return false; }
function dwqa_get_latest_action_date($question = false, $before = '<span>', $after = '</span>') { if (!$question) { $question = get_the_ID(); } global $post, $dwqa_general_settings; $message = ''; $question_list_link = isset($dwqa_general_settings['pages']['archive-question']) ? get_permalink($dwqa_general_settings['pages']['archive-question']) : false; $latest_answer = dwqa_get_latest_answer($question); $last_activity_date = $latest_answer ? $latest_answer->post_date : get_post_field('post_date', $question); $post_id = $latest_answer ? $latest_answer->ID : $question; $author_id = $post->post_author; if ($author_id == 0 || dwqa_is_anonymous($post_id)) { $anonymous_name = get_post_meta($post_id, '_dwqa_anonymous_name', true); $author_email = get_post_meta($post_id, '_dwqa_anonymous_email', true); if ($anonymous_name) { $display_name = $anonymous_name . ' '; } else { $display_name = __('Anonymous', 'dwqa') . ' '; } } else { $display_name = get_the_author_meta('display_name', $author_id); $author_url = $question_list_link ? add_query_arg(array('user-question' => get_the_author_meta('user_login', $author_id)), $question_list_link) : the_author_posts_link($author_id); $author_email = get_the_author_meta('user_email', $author_id); } $author_avatar = wp_cache_get('avatar_of_' . $author_id, 'dwqa'); if (false === $author_avatar) { $author_avatar = get_avatar($author_email, 48); wp_cache_set('avatar_of_' . $author_email, $author_avatar, 'dwqa', 60 * 60 * 24 * 7); } $author_display = dwqa_is_anonymous() ? $display_name : sprintf('<a href="%1$s" title="%2$s" rel="author">%3$s</a>', $author_url, esc_attr(sprintf(__('Posts by %s'), $display_name)), $display_name); $author_link = sprintf('<span class="dwqa-author"><span class="dwqa-user-avatar">%2$s</span>%1$s</span>', $author_display, $author_avatar); if ($last_activity_date && $post->last_activity_type == 'answer') { $date = human_time_diff(strtotime($last_activity_date), current_time('timestamp')); return sprintf(__('%s answered <span class="dwqa-date">%s</span> ago', 'dwqa'), $author_link, $date); } if ('dwqa-answer' == get_post_type($question)) { return sprintf(__('%s answered <span class="dwqa-date">%s</span> ago', 'dwqa'), $author_link, human_time_diff(get_the_time('U'), current_time('timestamp'))); } return sprintf(__('%s asked <span class="dwqa-date">%s</span> ago', 'dwqa'), $author_link, human_time_diff(get_the_time('U'), current_time('timestamp'))); }
function dwqa_get_latest_action_date($question = false, $before = '<span>', $after = '</span>') { if (!$question) { $question = get_the_ID(); } global $post; $message = ''; $latest_answer = dwqa_get_latest_answer($question); $last_activity_date = $latest_answer ? $latest_answer->post_date : get_post_field('post_date', $question); $post_id = $latest_answer ? $latest_answer->ID : $question; $author_id = $post->post_author; if ($author_id == 0 || dwqa_is_anonymous($post_id)) { $anonymous_name = get_post_meta($post_id, '_dwqa_anonymous_name', true); if ($anonymous_name) { $author_link = $anonymous_name . ' '; } else { $author_link = __('Anonymous', 'dwqa') . ' '; } } else { $display_name = get_the_author_meta('display_name', $author_id); $author_url = get_author_posts_url($author_id); $author_avatar = wp_cache_get('avatar_of_' . $author_id, 'dwqa'); if (false === $author_avatar) { $author_avatar = get_avatar($author_id, 12); wp_cache_set('avatar_of_' . $author_id, $author_avatar, 'dwqa', 60 * 60 * 24 * 7); } $author_link = sprintf('<span class="dwqa-author">%3$s</span>', $author_url, esc_attr(sprintf(__('Posts by %s'), $display_name)), $display_name, $author_avatar); } if ($last_activity_date && $post->last_activity_type == 'answer') { $date = dwqa_human_time_diff(strtotime($last_activity_date), false, get_option('date_format')); return sprintf(__('%s respondida <span class="dwqa-date">%s</span>', 'dwqa'), $author_link, $date); } return sprintf(__('%s perguntou <span class="dwqa-date">%s</span>', 'dwqa'), $author_link, get_the_date()); }