<?php } else { echo $post->post_title; } ?> </td> <?php if ($frontier_list_all_posts != "true" || current_user_can('edit_private_posts')) { echo '<td class="frontier-list-posts" id="" >' . (isset($tmp_status_list[$post->post_status]) ? $tmp_status_list[$post->post_status] : $post->post_status); } // check if moderation comments if ($post->post_status == "draft" || $post->post_status == "pending") { $tmp_flag = get_post_meta($post->ID, 'FRONTIER_POST_MODERATION_FLAG', true); if (isset($tmp_flag) && $tmp_flag == "true") { echo " " . frontier_get_icon('moderation'); } } echo '</td>'; ?> <?php // If post for all users is viewed, show author instead of category if ($frontier_list_all_posts == "true" || $frontier_list_pending_posts == "true") { echo '<td class="frontier-list-posts" id="frontier-list-posts-author">'; echo get_the_author_meta('display_name', $post->author); } else { echo '<td class="frontier-list-posts" id="frontier-list-posts-category">'; // List categories $categories = get_the_category($post->ID); $cnt = 0; foreach ($categories as $category) {
/** @see WP_Widget::widget */ function widget($args, $instance) { if (is_user_logged_in()) { global $current_user, $wpdb, $r; $instance = array_merge($this->defaults, $instance); $frontier_page_link = get_permalink(fp_get_option('fps_page_id')); $author = (int) $current_user->ID; $rec_limit = (int) (isset($instance['limit']) ? $instance['limit'] : 10); $excerpt_length = (int) (isset($instance['excerpt_length']) ? $instance['excerpt_length'] : 20); if (isset($instance['postdateformat']) && $instance['postdateformat'] != 'nodate') { $show_date = true; } else { $show_date = false; } if (isset($instance['cmtdateformat']) && $instance['cmtdateformat'] != 'nodate') { $show_comment_date = true; } else { $show_comment_date = false; } if (isset($instance['showcomments']) && $instance['showcomments'] != 'posts') { $show_comments = true; } else { $show_comments = false; } // Get comment icon from theme, first check local file path, if exists set tu url of icon $comment_icon = frontier_get_icon('comment'); // from version 3.4.6 caching will be available, and as such changed to handle in one array. // cache name must contain author id as results are specific to authors $fp_cache_name = FRONTIER_MY_POSTS_W_PREFIX . $this->number . "-U-" . $author; $fp_cache_time = $instance['fp_cache_time']; $fp_cache_test = "Cache active"; //echo "Cache name: ".$fp_cache_name."<br>"; $post_status_list = $instance['post_status_list']; // manage posts status if (!is_array($post_status_list)) { $post_status_list = array($post_status_list); } if (fp_bool($instance['show_pending_posts']) && !in_array('pending', $post_status_list)) { $post_status_list[] = 'pending'; } if (fp_bool($instance['show_draft_posts']) && !in_array('draft', $post_status_list)) { $post_status_list[] = 'draft'; } //echo "<pre>".print_r($post_status_list, true)."</pre><br>"; if ($fp_cache_time <= 0 || false === ($fp_wdata = get_transient($fp_cache_name))) { $fp_wdata = array(); $fp_wdata['tmp_post_cnt'] = $wpdb->get_var("SELECT count(ID) AS tmp_post_cnt FROM {$wpdb->posts} WHERE post_author = " . $author . " AND post_status = 'publish' AND post_type = 'post'"); // Build sql statement if ($show_comments) { $tmp_sql = " SELECT "; $tmp_sql .= " {$wpdb->posts}.ID \t\t\t\t\tAS post_id, "; $tmp_sql .= " {$wpdb->posts}.post_title \t\t\tAS post_title, "; $tmp_sql .= " {$wpdb->posts}.post_date \t\t\tAS post_date, "; $tmp_sql .= " {$wpdb->comments}.comment_ID \t\tAS comment_id, "; $tmp_sql .= " {$wpdb->comments}.comment_author \tAS comment_author, "; $tmp_sql .= " {$wpdb->comments}.comment_date \t\tAS comment_date, "; $tmp_sql .= " {$wpdb->comments}.comment_approved\tAS comment_approved, "; $tmp_sql .= " {$wpdb->comments}.comment_content \tAS comment_content "; $tmp_sql .= " FROM {$wpdb->posts} "; $tmp_sql .= " left OUTER JOIN {$wpdb->comments} ON {$wpdb->posts}.ID = {$wpdb->comments}.comment_post_ID "; $tmp_sql .= " WHERE {$wpdb->posts}.post_status IN ('" . implode("','", $post_status_list) . "') "; $tmp_sql .= " AND {$wpdb->posts}.post_type \t= '" . $instance['post_type'] . "'"; $tmp_sql .= " AND {$wpdb->posts}.post_author \t= " . $author . ""; $tmp_sql .= " ORDER BY {$wpdb->posts}.post_date DESC, {$wpdb->comments}.comment_date_gmt DESC"; $tmp_sql .= " LIMIT " . $rec_limit * 5 . ";"; } else { $tmp_sql = " SELECT {$wpdb->posts}.ID \tAS post_id, "; $tmp_sql .= " {$wpdb->posts}.post_title \tAS post_title, "; $tmp_sql .= " {$wpdb->posts}.post_date \tAS post_date "; $tmp_sql .= " FROM {$wpdb->posts} "; $tmp_sql .= " WHERE {$wpdb->posts}.post_author = " . $author . " "; $tmp_sql .= " AND {$wpdb->posts}.post_status IN ('" . implode("','", $post_status_list) . "') "; $tmp_sql .= " AND {$wpdb->posts}.post_type = '" . $instance['post_type'] . "' "; $tmp_sql .= " ORDER BY {$wpdb->posts}.post_date DESC "; $tmp_sql .= " LIMIT " . $rec_limit * 5 . ";"; // needs to multiply to account for non approved comments //echo "<pre>".print_r($tmp_sql, true)."</pre><br>"; } $fp_wdata['presult'] = $wpdb->get_results($tmp_sql); if ($fp_cache_time <= 0) { $fp_cache_test = "Caching disabled"; } else { $fp_cache_test = "Cache refreshed"; set_transient($fp_cache_name, $fp_wdata, $fp_cache_time); } } // end caching echo $args['before_widget']; if (!empty($instance['title'])) { echo $args['before_title']; echo $instance['title']; echo $args['after_title']; } //echo $args['before_widget']; //if ( $args['title'] ) echo $args['before_title'] . $args['title'] . $args['after_title']; //$title = apply_filters('widget_title', empty($instance['title']) ? __('My posts') : $instance['title'], $instance, $this->id_base); ?> <div class="frontier-my-post-widget"> <ul class="frontier-my-post-widget-list"> <?php $last_post = 0; $post_cnt = 0; if ($fp_wdata['presult']) { foreach ($fp_wdata['presult'] as $q_post) { $tmp_link = "xx"; if ($last_post != $q_post->post_id) { // $q_post is not a WP_post object $tmp_post = get_post($q_post->post_id); if ($post_cnt > 0) { echo "</li>"; } echo '<li class="frontier-my-post-widget-list">'; if ($instance['show_edit_link'] == 'before') { echo frontier_post_edit_link($tmp_post, true, $frontier_page_link, 'fp-widget-post-edit-link') . ' '; } if ($instance['show_delete_link'] == 'before') { echo frontier_post_delete_link($tmp_post, true, $frontier_page_link, 'fp-widget-post-delete-link') . ' '; } $post_cnt++; if ($show_date) { echo mysql2date($instance['postdateformat'], $q_post->post_date); echo ' '; } if ($tmp_post->post_status == "publish") { echo '<a class="frontier-my-post-widget-link frontier-my-post-widget-status-publish" href="' . get_permalink($q_post->post_id) . '">' . $q_post->post_title . '</a>'; } else { echo '<div id="frontier-my-post-widget-status-' . $tmp_post->post_status . '">' . $q_post->post_title . '</div>'; } if ($instance['show_edit_link'] == 'after') { echo ' ' . frontier_post_edit_link($tmp_post, true, $frontier_page_link, 'fp-widget-post-edit-link'); } if ($instance['show_delete_link'] == 'after') { echo frontier_post_delete_link($tmp_post, true, $frontier_page_link, 'fp-widget-post-delete-link') . ' '; } } $last_post = $q_post->post_id; if ($show_comments && !empty($q_post->comment_id) && $q_post->comment_approved == 1) { echo "</br>" . $comment_icon . " "; if ($show_comment_date) { echo mysql2date($instance['cmtdateformat'], $q_post->comment_date) . " - "; } echo $q_post->comment_author; if ($instance['showcomments'] == 'excerpts') { $tmp_comment = substr($q_post->comment_content, 0, $excerpt_length); if (strlen($q_post->comment_content) > strlen($tmp_comment)) { $tmp_comment = $tmp_comment . "..."; } echo ": " . "</br><i>" . $tmp_comment . "</i>"; } } if ($post_cnt >= $rec_limit) { break; } } } else { echo "<li>" . $instance['no_posts_text'] . "</li>"; } ?> </li> </ul> <?php if (isset($instance['show_add_post']) && $instance['show_add_post'] == 1 && current_user_can('frontier_post_can_add')) { if ($instance['post_type'] !== "post") { $tmp_post_type_parm = "&frontier_add_post_type=" . $instance['post_type']; } else { $tmp_post_type_parm = ""; } echo '<p><center><a href="' . frontier_post_add_link() . $tmp_post_type_parm . '">' . __("Create New Post", "frontier-post") . '</a></center></p>'; } // Count authors posts - get_permalink(fp_get_option('fps_page_id')) if (isset($instance['show_post_count']) && $instance['show_post_count'] == 1) { //$tmp_post_cnt = $wpdb->get_var("SELECT count(ID) AS tmp_post_cnt FROM $wpdb->posts WHERE post_author = ".$author." AND post_status = 'publish' AND post_type = 'post'" ); $tmp_post_cnt = $fp_wdata['tmp_post_cnt']; echo '<p><center><a href="' . get_permalink(fp_get_option('fps_page_id')) . '">' . __("You have published: ", "frontier-post") . $tmp_post_cnt . ' ' . __("posts", "frontier-post") . '</a></center></p>'; } ?> </div> <?php //echo "<pre>".print_r($instance)."<pre>"; echo $args['after_widget']; } else { // echo "<p>".__("You need to login to see your posts", "frontier-post")."</p>"; } }
?> <div class="frontier-new-list" id="frontier-post-new-list-info"> <?php echo frontier_post_edit_link($post, $fp_show_icons, $frontier_permalink); echo frontier_post_delete_link($post, $fp_show_icons, $frontier_permalink); echo frontier_post_preview_link($post, $fp_show_icons, $frontier_permalink); echo __("Status", "frontier-post") . ': ' . (isset($tmp_status_list[$post->post_status]) ? $tmp_status_list[$post->post_status] : $post->post_status); echo $tmp_info_separator; echo __("Autor", "frontier-post") . ': '; the_author(); echo $tmp_info_separator; printf(_x('%s atrĂ¡s', '%s = human-readable time difference', 'frontier-post'), human_time_diff(get_the_time('U'), current_time('timestamp'))); echo $tmp_info_separator; echo frontier_get_icon('comments2') . ' ' . intval($post->comment_count); echo $tmp_info_separator; echo __("Categorias", "frontier-post") . ': '; the_category(' '); echo $tmp_info_separator; echo __("Tags", "frontier-post") . ': '; the_tags(' '); /* echo '<br>'; echo fp_get_tax_values($post->ID); */ ?> </div> </div>
function frontier_post_preview_link($fp_post, $fp_show_icons = true, $tmp_plink, $tmp_class = '') { $fp_return = ''; $concat = get_option("permalink_structure") ? "?" : "&"; if ($fp_show_icons) { $fp_return = '<a class="frontier-post-list-icon ' . $tmp_class . '" id="frontier-post-list-icon-preview" href="' . site_url() . '/?p=' . $fp_post->ID . '&preview=true">' . frontier_get_icon('view', $tmp_class) . '</a>'; } else { $fp_return = '<a class="frontier-post-list-text ' . $tmp_class . '" id="frontier-post-list-text-preview" href="' . site_url() . '/?p=' . $fp_post->ID . '&preview=true">' . __("Preview", "frontier-post") . ' </a>'; } return $fp_return; }
echo " (" . $post->post_date . ")"; } echo $tmp_info_separator; echo __("Author", "frontier-post") . ': '; the_author(); // Show word count echo $tmp_info_separator; echo __("Words", "frontier-post") . ": " . str_word_count(strip_tags($post->post_content)); // show publish date echo $tmp_info_separator; if ($post->post_status === 'publish') { printf(_x('%s ago', '%s = human-readable time difference', 'frontier-post'), human_time_diff(get_the_time('U'), current_time('timestamp'))); echo $tmp_info_separator; } $postlink = esc_url(get_permalink()) . "#comments"; echo '<a class="frontier-post-comment-link" id="frontier-query-comment-link" href="' . $postlink . '">' . frontier_get_icon('comments2') . ' ' . intval($post->comment_count) . '</a>'; /* echo frontier_get_icon('comments2').' '.intval($post->comment_count); echo $tmp_info_separator; echo __("Categories", "frontier-post").': '; the_category(', '); echo $tmp_info_separator; echo __("Tags", "frontier-post").': '; the_tags(', '); */ // get taxonomy information echo fp_get_tax_values($post->ID, $tmp_info_separator); ?>
/** @see WP_Widget::widget */ function widget($args, $instance) { if (is_user_logged_in()) { global $current_user, $wpdb, $r; $instance = array_merge($this->defaults, $instance); $author = (int) $current_user->ID; $rec_limit = (int) (isset($instance['limit']) ? $instance['limit'] : 10); $excerpt_length = (int) (isset($instance['excerpt_length']) ? $instance['excerpt_length'] : 20); if (isset($instance['postdateformat']) && $instance['postdateformat'] != 'nodate') { $show_date = true; } else { $show_date = false; } if (isset($instance['cmtdateformat']) && $instance['cmtdateformat'] != 'nodate') { $show_comment_date = true; } else { $show_comment_date = false; } if (isset($instance['showcomments']) && $instance['showcomments'] != 'posts') { $show_comments = true; } else { $show_comments = false; } // Get comment icon from theme, first check local file path, if exists set tu url of icon $comment_icon = frontier_get_icon('comment'); // from version 3.4.6 caching will be available, and as such changed to handle in one array. // cache name must contain author id as results are specific to authors $fp_cache_name = $args['widget_id'] . "_fpuser_" . $author; $fp_cache_time = $instance['fp_cache_time']; $fp_cache_test = "Cache active"; if ($fp_cache_time <= 0 || false === ($fp_wdata = get_transient($fp_cache_name))) { $fp_wdata = array(); $fp_wdata['tmp_post_cnt'] = $wpdb->get_var("SELECT count(ID) AS tmp_post_cnt FROM {$wpdb->posts} WHERE post_author = " . $author . " AND post_status = 'publish' AND post_type = 'post'"); // Build sql statement if ($show_comments) { $tmp_sql = " SELECT \n\t\t\t\t\t\t\t {$wpdb->posts}.ID \t\t\t\t\tAS post_id, \n\t\t\t\t\t\t\t {$wpdb->posts}.post_title \t\t\tAS post_title, \n\t\t\t\t\t\t\t {$wpdb->posts}.post_date \t\t\tAS post_date, \n\t\t\t\t\t\t\t {$wpdb->comments}.comment_ID \t\tAS comment_id, \n\t\t\t\t\t\t\t {$wpdb->comments}.comment_author \tAS comment_author,\n\t\t\t\t\t\t\t {$wpdb->comments}.comment_date \t\tAS comment_date,\n\t\t\t\t\t\t\t {$wpdb->comments}.comment_approved\tAS comment_approved,\n\t\t\t\t\t\t\t {$wpdb->comments}.comment_content \tAS comment_content \n\t\t\t\t\t\t\t\t FROM {$wpdb->posts} \n\t\t\t\t\t\t\t\t left OUTER JOIN {$wpdb->comments} ON \n\t\t\t\t\t\t\t\t\t {$wpdb->posts}.ID = {$wpdb->comments}.comment_post_ID \n\t\t\t\t\t\t\t\t WHERE {$wpdb->posts}.post_status = 'publish' \n\t\t\t\t\t\t\t\t AND {$wpdb->posts}.post_type \t= 'post' \n\t\t\t\t\t\t\t\t AND {$wpdb->posts}.post_author \t= " . $author . "\n\t\t\t\t\t\t\t\t ORDER BY {$wpdb->posts}.post_date DESC, {$wpdb->comments}.comment_date_gmt DESC \n\t\t\t\t\t\t\t\t LIMIT " . $rec_limit * 5; } else { $tmp_sql = " SELECT {$wpdb->posts}.ID \tAS post_id, \n\t\t\t\t\t\t\t {$wpdb->posts}.post_title \tAS post_title, \n\t\t\t\t\t\t\t {$wpdb->posts}.post_date \tAS post_date \n\t\t\t\t\t\t\t FROM {$wpdb->posts} \n\t\t\t\t\t\t\t WHERE {$wpdb->posts}.post_author = " . $author . " AND {$wpdb->posts}.post_status = 'publish' AND {$wpdb->posts}.post_type = 'post' \n\t\t\t\t\t\t\t ORDER BY {$wpdb->posts}.post_date DESC \n\t\t\t\t\t\t\t LIMIT " . $rec_limit * 5; // needs to multiply to account for non approved comments } $fp_wdata['presult'] = $wpdb->get_results($tmp_sql); if ($fp_cache_time <= 0) { $fp_cache_test = "Caching disabled"; } else { $fp_cache_test = "Cache refreshed"; set_transient($fp_cache_name, $fp_wdata, $fp_cache_time); } } // end caching echo $args['before_widget']; if (!empty($instance['title'])) { echo $args['before_title']; echo $instance['title']; echo $args['after_title']; } //echo $args['before_widget']; //if ( $args['title'] ) echo $args['before_title'] . $args['title'] . $args['after_title']; //$title = apply_filters('widget_title', empty($instance['title']) ? __('My posts') : $instance['title'], $instance, $this->id_base); ?> <div class="frontier-my-post-widget"> <ul> <?php $last_post = 0; $post_cnt = 0; if ($fp_wdata['presult']) { foreach ($fp_wdata['presult'] as $post) { $tmp_link = "xx"; if ($last_post != $post->post_id) { if ($post_cnt > 0) { echo "</li>"; } echo "<li>"; $post_cnt++; if ($show_date) { echo mysql2date($instance['postdateformat'], $post->post_date); echo ' '; } ?> <a href="<?php echo post_permalink($post->post_id); ?> "><?php echo $post->post_title; ?> </a> <?php } $last_post = $post->post_id; if ($show_comments && !empty($post->comment_id) && $post->comment_approved == 1) { echo "</br>" . $comment_icon . " "; if ($show_comment_date) { echo mysql2date($instance['cmtdateformat'], $post->comment_date) . " - "; } echo $post->comment_author; if ($instance['showcomments'] == 'excerpts') { $tmp_comment = substr($post->comment_content, 0, $excerpt_length); if (strlen($post->comment_content) > strlen($tmp_comment)) { $tmp_comment = $tmp_comment . "..."; } echo ": " . "</br><i>" . $tmp_comment . "</i>"; } } if ($post_cnt >= $rec_limit) { break; } } } else { echo "<li>" . $instance['no_posts_text'] . "</li>"; } ?> </li> </ul> <?php if (isset($instance['show_add_post']) && $instance['show_add_post'] == 1 && current_user_can('frontier_post_can_add')) { echo '<p><center><a href="' . frontier_post_add_link() . '">' . __("Create New Post", "frontier-post") . '</a></center></p>'; } // Count authors posts - get_permalink(fp_get_option('fps_page_id')) if (isset($instance['show_post_count']) && $instance['show_post_count'] == 1) { //$tmp_post_cnt = $wpdb->get_var("SELECT count(ID) AS tmp_post_cnt FROM $wpdb->posts WHERE post_author = ".$author." AND post_status = 'publish' AND post_type = 'post'" ); $tmp_post_cnt = $fp_wdata['tmp_post_cnt']; echo '<p><center><a href="' . get_permalink(fp_get_option('fps_page_id')) . '">' . __("You have published: ", "frontier-post") . $tmp_post_cnt . ' ' . __("posts", "frontier-post") . '</a></center></p>'; } ?> </div> <?php echo $args['after_widget']; } else { // echo "<p>".__("You need to login to see your posts", "frontier-post")."</p>"; } }