echo "</br>" . $category->cat_name;
                } else {
                    echo $category->cat_name;
                }
            }
        }
        ?>
</td>
				<td class="frontier-list-posts" id="frontier-list-posts-cmt"><?php 
        echo $post->comment_count;
        ?>
</td>
				<td class="frontier-list-posts" id="frontier-list-posts-action">
					<?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);
        ?>
					&nbsp;
				</td>
			</tr>
		<?php 
    }
    ?>
	</tbody>
</table>
<?php 
    $pagination = paginate_links(array('base' => add_query_arg('pagenum', '%#%'), 'format' => '', 'prev_text' => __('&laquo;', 'frontier-post'), 'next_text' => __('&raquo;', 'frontier-post'), 'total' => $user_posts->max_num_pages, 'current' => $pagenum, 'add_args' => false));
    if ($pagination) {
        echo $pagination;
    }
Ejemplo n.º 2
0
function frontier_post_display_links($fp_post, $fp_show_icons = true, $tmp_plink = "default", $tmp_class = '')
{
    if ($tmp_plink == "default") {
        $tmp_plink = get_permalink(fp_get_option('fps_page_id'));
    }
    $tmp_out = '';
    $tmp_out .= frontier_post_edit_link($fp_post, $fp_show_icons, $tmp_plink, $tmp_class);
    $tmp_out .= frontier_post_approve_link($fp_post, $fp_show_icons, $tmp_plink, $tmp_class);
    $tmp_out .= frontier_post_delete_link($fp_post, $fp_show_icons, $tmp_plink, $tmp_class);
    $tmp_out .= frontier_post_preview_link($fp_post, $fp_show_icons, $tmp_plink, $tmp_class);
    return $tmp_out;
}
Ejemplo n.º 3
0
    /** @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 '&nbsp;&nbsp;';
                        }
                        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 . "&nbsp;&nbsp;";
                        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 ":&nbsp" . "</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 . '&nbsp;' . __("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>";
        }
    }
Ejemplo n.º 4
0
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     if (is_user_logged_in() && current_user_can("edit_others_posts")) {
         $instance = array_merge($this->defaults, $instance);
         $frontier_page_link = get_permalink(fp_get_option('fps_page_id'));
         // from version 3.4.6 caching will be available, and as such changed to handle in one array.
         $fp_cache_name = FRONTIER_MY_APPROVALS_W_PREFIX . $this->number;
         $fp_cache_time = $instance['fp_cache_time'];
         $fp_cache_test = "Cache active";
         global $wpdb;
         //error_log(print_r($instance), true);
         if ($fp_cache_time <= 0 || false === ($fp_wdata = get_transient($fp_cache_name))) {
             $fp_wdata = array();
             if (isset($instance['show_draft']) && $instance['show_draft'] == true) {
                 $fp_wdata['draft_cnt'] = $wpdb->get_var("SELECT count(id) AS draft_cnt FROM {$wpdb->posts} WHERE post_status = 'draft'");
                 $fp_wdata['draft_txt'] = $fp_wdata['draft_cnt'] . ' ' . __('draft posts', 'frontier-post');
                 $fp_wdata['show_draft'] = true;
             } else {
                 $fp_wdata['show_draft'] = false;
             }
             if (isset($instance['show_pending']) && $instance['show_pending'] == true) {
                 $fp_wdata['pending_cnt'] = $wpdb->get_var("SELECT count(id) AS pending_cnt FROM {$wpdb->posts} WHERE post_status = 'pending'");
                 $fp_wdata['pending_txt'] = $fp_wdata['pending_cnt'] . ' ' . __('posts to be approved', 'frontier-post');
                 $fp_wdata['show_pending'] = true;
             } else {
                 $fp_wdata['show_pending'] = false;
             }
             if (isset($instance['show_comments']) && $instance['show_comments'] == true) {
                 $fp_wdata['cmt_pending_cnt'] = $wpdb->get_var("SELECT count(comment_ID) AS cmt_pending_cnt FROM {$wpdb->comments} WHERE comment_approved = 0");
                 $fp_wdata['cmt_pending_txt'] = $fp_wdata['cmt_pending_cnt'] . ' ' . __('comments to be approved', 'frontier-post');
                 $fp_wdata['show_comments'] = true;
             } else {
                 $fp_wdata['show_comments'] = false;
             }
             if (isset($instance['show_comment_spam']) && $instance['show_comment_spam'] == true) {
                 $fp_wdata['cmt_spam_cnt'] = $wpdb->get_var("SELECT count(comment_ID) AS cmt_pending_cnt FROM {$wpdb->comments} WHERE comment_approved = 'spam'");
                 $fp_wdata['cmt_spam_txt'] = $fp_wdata['cmt_spam_cnt'] . ' ' . __('spam comments', 'frontier-post');
                 $fp_wdata['show_comment_spam'] = true;
             } else {
                 $fp_wdata['show_comment_spam'] = false;
             }
             if (intval($instance['pending_count']) > 0) {
                 //$tmp_sql 					= "";
                 $tmp_sql = "SELECT ID AS post_id, post_title AS post_title FROM {$wpdb->posts} WHERE post_status = 'pending' ORDER BY post_date DESC LIMIT " . intval($instance['pending_count']) . " ";
                 $fp_wdata['pending_list'] = $wpdb->get_results($tmp_sql);
                 $fp_wdata['pending_count'] = intval($instance['pending_count']);
             } else {
                 $fp_wdata['pending_count'] = 0;
             }
             if (intval($instance['draft_count']) > 0) {
                 //$tmp_sql 					= "";
                 $tmp_sql = "SELECT ID AS post_id, post_title AS post_title FROM {$wpdb->posts} WHERE post_status = 'draft' ORDER BY post_date DESC LIMIT " . intval($instance['draft_count']) . " ";
                 $fp_wdata['draft_list'] = $wpdb->get_results($tmp_sql);
                 $fp_wdata['draft_count'] = intval($instance['draft_count']);
             } else {
                 $fp_wdata['draft_count'] = 0;
             }
             $fp_wdata['postdateformat'] = $instance['postdateformat'];
             $fp_wdata['show_author'] = fp_bool($instance['show_author']);
             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 '<div  class="frontier-my-post-widget">';
         echo '<ul>';
         if ($fp_wdata['show_pending']) {
             if (fp_get_option_int('fps_pending_page_id', 0) > 0) {
                 $tmp_pending_link = get_permalink(fp_get_option('fps_pending_page_id'));
             } else {
                 $tmp_pending_link = site_url('/wp-admin/edit.php?post_status=pending&post_type=post');
             }
             if (fp_get_option_int('fps_draft_page_id', 0) > 0) {
                 $tmp_draft_link = get_permalink(fp_get_option('fps_draft_page_id'));
             } else {
                 $tmp_draft_link = site_url('/wp-admin/edit.php?post_status=draft&post_type=post');
             }
             echo '<li>';
             echo '<a href="' . $tmp_pending_link . '">' . $fp_wdata['pending_txt'] . '</a>';
             echo '</li>';
         }
         if (array_key_exists('pending_count', $fp_wdata) && $fp_wdata['pending_count'] > 0) {
             if (!$fp_wdata['show_pending']) {
                 echo '<li>' . __("Pending posts", "frontier-post") . '</li>';
             }
             echo '<ul class="frontier-my-approvals-pending">';
             foreach ($fp_wdata['pending_list'] as $q_post) {
                 $tmp_post = get_post($q_post->post_id);
                 echo '<li class="frontier-my-approvals-pending">';
                 if ($fp_wdata['postdateformat'] != 'nodate') {
                     echo '<div id="frontier-my-approvals-date-pending">' . mysql2date($instance['postdateformat'], $tmp_post->post_date) . '&nbsp;&nbsp;</div>';
                 }
                 echo $q_post->post_title;
                 if ($fp_wdata['show_author']) {
                     echo '<div id="frontier-my-approvals-author">' . '  (' . get_the_author_meta('nicename', $tmp_post->post_author) . ')</div>';
                 }
                 echo ' ' . frontier_post_edit_link($tmp_post, true, $frontier_page_link, 'fp-my-approvals-post-edit-link');
                 echo ' ' . frontier_post_delete_link($tmp_post, true, $frontier_page_link, 'fp-my-approvals-post-delete-link');
                 echo '</li>';
             }
             echo '</ul>';
         }
         if ($fp_wdata['show_draft']) {
             echo '<li>';
             echo '<a href="' . $tmp_draft_link . '">' . $fp_wdata['draft_txt'] . '</a>';
             echo '</li>';
         }
         if (array_key_exists('draft_count', $fp_wdata) && $fp_wdata['draft_count'] > 0) {
             if (!$fp_wdata['show_draft']) {
                 echo '<li>' . __("Draft posts", "frontier-post") . '</li>';
             }
             echo '<ul class="frontier-my-approvals-draft">';
             foreach ($fp_wdata['draft_list'] as $q_post) {
                 $tmp_post = get_post($q_post->post_id);
                 echo '<li class="frontier-my-approvals-draft">';
                 if ($fp_wdata['postdateformat'] != 'nodate') {
                     echo '<div id="frontier-my-approvals-date-draft">' . mysql2date($instance['postdateformat'], $tmp_post->post_date) . '&nbsp;&nbsp;</div>';
                 }
                 echo $q_post->post_title;
                 if ($fp_wdata['show_author']) {
                     echo '<div id="frontier-my-approvals-author">' . '  (' . get_the_author_meta('nicename', $tmp_post->post_author) . ')</div>';
                 }
                 echo ' ' . frontier_post_edit_link($tmp_post, true, $frontier_page_link, 'fp-my-approvals-post-edit-link');
                 echo ' ' . frontier_post_delete_link($tmp_post, true, $frontier_page_link, 'fp-my-approvals-post-delete-link');
                 echo '</li>';
             }
             echo '</ul>';
         }
         if ($fp_wdata['show_comments']) {
             echo '<li>';
             echo '<a href="' . site_url('/wp-admin/edit-comments.php?comment_status=moderated') . '">' . $fp_wdata['cmt_pending_txt'] . '</a>';
             echo '</li>';
         }
         if ($fp_wdata['show_comment_spam']) {
             echo '<li>';
             echo '<a href="' . site_url('/wp-admin/edit-comments.php?comment_status=spam') . '">' . $fp_wdata['cmt_spam_txt'] . '</a>';
             echo '</li>';
         }
         echo '</ul>';
         echo '</div>';
         //echo "<pre>".print_r($fp_wdata, true)."</pre><br>";
         echo $args['after_widget'];
     }
 }