コード例 #1
0
ファイル: functions.php プロジェクト: hewu/blogwp
/**
 * Get views summary for any given post.
 *
 * @param int $post_id post to get views for
 * @return gdptPostViews|WP_Error views summary or error if post ID is invalid.
 */
function presstools_get_post_views($post_id = 0)
{
    if ($post_id == 0) {
        global $post;
        $post_id = $post->ID;
    }
    if ($post_id > 0) {
        $results = gd_count_views($post_id);
        $views = new gdptPostViews($post_id);
        if (is_object($results) && !is_null($results)) {
            $views->users_views = $results->usr_views;
            $views->visitors_views = $results->vst_views;
            $views->total_views = $results->tot_views;
            return $views;
        }
    } else {
        return new WP_Error("presstools_get_post_views", __("Given post ID is invalid.", "gd-press-tools"));
    }
}
コード例 #2
0
ファイル: gd-press-tools.php プロジェクト: hewu/blogwp
 function admin_columns_data($column, $id)
 {
     switch ($column) {
         case "gdpt_sticky":
             if (is_sticky($id)) {
                 echo __("Yes", "gd-press-tools");
             }
             break;
         case "gdpt_mediaid":
         case "gdpt_postid":
         case "gdpt_linksid":
             echo $id;
             break;
         case "gdpt_views":
             $data = gd_count_views($id);
             echo sprintf('<div class="gdpt_view_line">%s: <strong class="gdpt_view_value">%s</strong></div>%s: <strong class="gdpt_view_value">%s</strong><br />%s: <strong class="gdpt_view_value">%s</strong><br />', __("total", "gd-press-tools"), intval($data->tot_views), __("users", "gd-press-tools"), intval($data->usr_views), __("visitors", "gd-press-tools"), intval($data->vst_views));
             break;
         case "gdpt_options":
             $url = add_query_arg("pid", $id, $_SERVER['REQUEST_URI']);
             $counter = gd_count_revisions($id);
             echo sprintf('<a style="color: #00008b" href="%s" title="%s">%s</a><br />', add_query_arg("gda", "duplicate", $url), __("Duplicate", "gd-press-tools"), __("Duplicate", "gd-press-tools"));
             if ($counter > 0) {
                 echo sprintf('<a style="color: #cc0000" onclick="if (confirm(\'%s\')) { return true; } return false;" href="%s" title="%s">%s (%s)</a>', __("Are you sure that you want to delete revisions for this post?", "gd-press-tools"), add_query_arg("gda", "delrev", $url), __("Delete Revisions", "gd-press-tools"), __("Delete Revisions", "gd-press-tools"), $counter);
             }
             break;
     }
 }