function frontier_quickpost($fpost_sc_parms = array()) { if (fp_get_option_bool('fps_use_quickpost') && frontier_can_add($fpost_sc_parms['frontier_add_post_type'])) { // Show/Hide Quickpost ?> <script type="text/javascript"> jQuery(document).ready(function($) { $("#fp-quickpost-show").click(function () { /*alert('show');*/ $("#frontier-post-quickpost").show(); $("#fp-quickpost-show").hide(); $("#fp-quickpost-hide").show(); $(".frontier-quickpost-hide").hide(); $(".frontier-quickpost-show").show(); $("#fp_show_quickpost").val("true"); } ); $("#fp-quickpost-hide").click(function () { /*alert('hide');*/ $("#frontier-post-quickpost").hide(); $("#fp-quickpost-show").show(); $("#fp-quickpost-hide").hide(); $(".frontier-quickpost-hide").show(); $(".frontier-quickpost-show").hide(); $("#fp_show_quickpost").val("false"); } ); } ); </script> <?php if (strlen(trim($fpost_sc_parms['frontier_add_link_text'])) > 0) { $tmp_add_text = $fpost_sc_parms['frontier_add_link_text']; } else { $tmp_add_text = __("Create New", "frontier-post") . " " . fp_get_posttype_label_singular($fpost_sc_parms['frontier_add_post_type']); } echo '<button class="button frontier-post-quickpost-button frontier-quickpost-hide" type="button" name="fp-quickpost-show" id="fp-quickpost-show" value="show">' . $tmp_add_text . '</button>'; echo '<button class="button frontier-post-quickpost-button frontier-quickpost-show" type="button" name="fp-quickpost-hide" id="fp-quickpost-hide" value="hide">' . __("Hide", "frontier-post") . " " . $tmp_add_text . '</button>'; echo '<fieldset id="frontier-post-quickpost" class="frontier-quickpost-show">'; frontier_post_add_edit($fpost_sc_parms, true); echo '</fieldset>'; } // fps_use_quickpost }
?> </button> <?php } if (fp_get_option_bool("fps_submit_cancel")) { ?> <input type="reset" value="<?php _e("Cancel", "frontier-post"); ?> " name="cancel" id="frontier-post-cancel" onclick="location.href='<?php the_permalink(); ?> '"> <?php } /* if ( fp_get_option_bool("fps_submit_delete") && $thispost->post_status !== "publish" && current_user_can("frontier_post_can_delete") && !$tmp_task_new ) { echo " ".frontier_post_delete_link($thispost, false, $frontier_permalink, 'frontier-post-form-delete' ); } */ echo '<p class="frontier-post-form-posttype"> (' . __("Post type", "frontier-post") . ": " . fp_get_posttype_label_singular($thispost->post_type) . ') </p>'; ?> </fieldset> </td></tr></table> </form> </div> <!-- ending div --> <?php // end form file
//Display before text from shortcode if (strlen($frontier_list_text_before) > 1) { echo '<div id="frontier_list_text_before">' . $frontier_list_text_before . '</div>'; } //Display message frontier_post_output_msg(); $fp_cat_list = implode(",", $frontier_cat_id); /* echo "post_type: ".$frontier_add_post_type."<br>"; echo "Label: ".fp_get_posttype_label_singular($frontier_add_post_type); */ if (frontier_can_add() && !fp_get_option_bool("fps_hide_add_on_list")) { if (strlen(trim($frontier_add_link_text)) > 0) { $tmp_add_text = $frontier_add_link_text; } else { $tmp_add_text = __("Create New", "frontier-post") . " " . fp_get_posttype_label_singular($frontier_add_post_type); } ?> <table class="frontier-menu" > <tr class="frontier-menu"> <th class="frontier-menu" > </th> <th class="frontier-menu" ><a id="frontier-post-add-new-link" href='<?php echo frontier_post_add_link($tmp_p_id); ?> '><?php echo $tmp_add_text; ?> </a></th> <th class="frontier-menu" > </th> </tr> </table>
$tmp_status_list = get_post_statuses(); $tmp_info_separator = " | "; //Display before text from shortcode if (strlen($frontier_list_text_before) > 1) { echo '<div id="frontier_list_text_before">' . $frontier_list_text_before . '</div>'; } // Dummy translation of ago for human readable time $crap = __("atrĂ¡s", "frontier-post"); // alterado //Display message frontier_post_output_msg(); if (frontier_can_add() && !fp_get_option_bool("fps_hide_add_on_list")) { if (strlen(trim($frontier_add_link_text)) > 0) { $tmp_add_text = $frontier_add_link_text; } else { $tmp_add_text = __("+ Adicionar ", "frontier-post") . " " . fp_get_posttype_label_singular($frontier_add_post_type); } ?> <fieldset class="frontier-new-menu"> <a id="frontier-post-add-new-link" class="frontier_add_link" href='http://restrito.ccst.inpe.br/meus-posts/?task=new'><?php echo $tmp_add_text; ?> </a> </fieldset> <?php } // if can_add if ($user_posts->found_posts > 0) {
function frontier_prepare_delete_post($frontier_post_shortcode_parms = array()) { extract($frontier_post_shortcode_parms); $frontier_permalink = get_permalink(); $concat = get_option("permalink_structure") ? "?" : "&"; //$post_task = isset($_GET['task']) ? $_GET['task'] : "notaskset"; //$post_action = isset($_REQUEST['action']) ? $_REQUEST['action'] : "Unknown"; if (isset($_POST['task'])) { $post_task = $_POST['task']; } else { if (isset($_GET['task'])) { $post_task = $_GET['task']; } else { $post_task = "notaskset"; } } if (isset($_POST['user_post_submit']) && $_POST['user_post_submit'] == "delete") { $post_task = "delete"; } $post_action = isset($_POST['action']) ? $_POST['action'] : "Unknown"; if ($post_task == "delete") { if ($_REQUEST['postid']) { $thispost = get_post($_REQUEST['postid']); $post_author = $thispost->post_author; //double check current user is equal to author (in case directly with param) if (frontier_can_delete($thispost) == true) { echo '<div id="frontier-post-alert">' . __("Delete", "frontier-post") . ': ' . fp_get_posttype_label_singular($thispost->post_type); $tmp_delete_txt = fp_get_option('fps_custom_delete_txt', ''); if (strlen($tmp_delete_txt) > 0) { echo '<br><br><p class="frontier-post-confirm-delete-text">' . $tmp_delete_txt . '</p>'; } echo '</div>'; echo '<br><br>'; ?> <div id="frontier-post-delete-post" class="frontier_post_delete_form"> <table> <form action="<?php echo $frontier_permalink; ?> " method="post" name="frontier_delete_post" id="frontier_delete_post" enctype="multipart/form-data" > <input type="hidden" name="action" value="wpfrtp_delete_post"> <input type="hidden" name="task" value="delete"> <input type="hidden" name="postid" id="postid" value="<?php if (isset($thispost->ID)) { echo $thispost->ID; } ?> "> <?php wp_nonce_field('frontier_delete_post', 'frontier_delete_post_' . $thispost->ID); ?> <tr> </tr><tr> <td><center> <button class="button frontier-post-form-delete" type="submit" name="submit_delete" id="submit_delete" value="deletego"><?php _e("Delete", "frontier-post"); ?> </button> <input type="reset" value=<?php _e("Cancel", "frontier-post"); ?> name="cancel" id="cancel" onclick="location.href='<?php the_permalink(); ?> '"> </center> </td></tr> </form> </table> <hr> <?php echo "<table>"; echo "<tr>"; echo "<td><h1>" . $thispost->post_title . "</h1></td>"; echo "</tr><tr><td>"; /* $content = $thispost->post_content; //$content = apply_filters( 'the_content', $content); $content = str_replace( ']]>', ']]>', $content ); */ $content = fp_view_post($thispost); echo $content; echo "</td>"; // echo $thispost->post_content; echo "</tr></table>"; ?> </div> <?php } } } }
function frontier_prepare_approve_post($frontier_post_shortcode_parms = array()) { extract($frontier_post_shortcode_parms); $frontier_permalink = get_permalink(); $concat = get_option("permalink_structure") ? "?" : "&"; if (isset($_POST['task'])) { $post_task = $_POST['task']; } else { if (isset($_GET['task'])) { $post_task = $_GET['task']; } else { $post_task = "notaskset"; } } $post_action = isset($_POST['action']) ? $_POST['action'] : "Unknown"; if ($post_task == "approve") { if ($_REQUEST['postid']) { $thispost = get_post($_REQUEST['postid']); $post_author = $thispost->post_author; if ($thispost->post_status === "pending" && current_user_can("edit_others_posts")) { echo '<div id="frontier-post-alert">' . __("Approve", "frontier-post") . ': ' . fp_get_posttype_label_singular($thispost->post_type) . '</div>'; echo '<br><br>'; ?> <div class="frontier_post_approve_form"> <table> <form action="<?php echo $frontier_permalink; ?> " method="post" name="frontier_approve_post" id="frontier_approve_post" enctype="multipart/form-data" > <input type="hidden" name="action" value="wpfrtp_approve_post"> <input type="hidden" name="task" value="approve"> <input type="hidden" name="postid" id="postid" value="<?php if (isset($thispost->ID)) { echo $thispost->ID; } ?> "> <?php wp_nonce_field('frontier_approve_post', 'frontier_approve_post_' . $thispost->ID); ?> <tr> </tr><tr> <td><center> <button class="button" type="submit" name="submit_approve" id="submit_approve" value="approvego"><?php _e("Approve", "frontier-post"); ?> </button> <input type="reset" value=<?php _e("Cancel", "frontier-post"); ?> name="cancel" id="cancel" onclick="location.href='<?php the_permalink(); ?> '"> </center> </td></tr> </form> </table> <hr> <?php echo "<table>"; echo "<tr>"; echo "<td><h1>" . $thispost->post_title . "</h1></td>"; echo "</tr><tr><td>"; /* $tmp_content = apply_filters( 'the_content', $thispost->post_content ); $tmp_content = str_replace( ']]>', ']]>', $tmp_content ); */ $tmp_content = fp_view_post($thispost); echo $tmp_content; /* $content = $thispost->post_content; //$content = apply_filters( 'the_content', $content); $content = str_replace( ']]>', ']]>', $content ); echo $content; */ echo "</td>"; // echo $thispost->post_content; echo "</tr></table>"; ?> </div> <?php } } } }
/** @see WP_Widget::widget */ function widget($args, $instance) { if (is_user_logged_in()) { // check access level if (array_key_exists('fp_access_level', $instance) && !current_user_can($instance['fp_access_level'])) { return; } 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 && frontier_can_add($instance['post_type'])) { 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 id"frontier-post-widget-add-link" href="' . frontier_post_add_link() . $tmp_post_type_parm . '">' . __("Create New", "frontier-post") . " " . fp_get_posttype_label_singular($instance['post_type']) . '</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 id="frontier-post-widget-post-count" 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>"; } }