RCCWP_CustomWritePanel::GetCountPostNotWritePanel PHP Method

GetCountPostNotWritePanel() public static method

public static GetCountPostNotWritePanel ( $type )
    public static function GetCountPostNotWritePanel($type)
    {
        global $wpdb;
        $user = wp_get_current_user();
        $sql = $wpdb->prepare("SELECT COUNT(DISTINCT(p.ID)) AS num_posts, p.post_status FROM {$wpdb->posts} p WHERE p.post_type = %s AND 0 = (SELECT COUNT(*) FROM {$wpdb->postmeta} pm  WHERE p.id = pm.post_id AND meta_key = %s ) GROUP BY p.post_status", array($type, "_mf_write_panel_id"));
        $count = $wpdb->get_results($sql, ARRAY_A);
        $stats = array('publish' => 0, 'private' => 0, 'draft' => 0, 'pending' => 0, 'future' => 0, 'trash' => 0);
        foreach ((array) $count as $row_num => $row) {
            $stats[$row['post_status']] = $row['num_posts'];
        }
        $stats['auto-draft'] = 0;
        $stats = (object) $stats;
        return $stats;
    }

Usage Example

コード例 #1
0
function change_number_not_write_panel_manage($where)
{
    global $parent_file;
    if (isset($_SESSION['change_number_not_write_panel_manage'])) {
        return $where;
    }
    $types = array('edit.php', 'edit-pages.php', 'edit.php?post_type=page');
    if (!in_array($parent_file, $types)) {
        return $where;
    }
    if (isset($_GET['custom-write-panel-id'])) {
        return $where;
    }
    if (!RCCWP_Options::Get('hide-non-standart-content')) {
        return $where;
    }
    $type = 'post';
    if (is_wp30()) {
        if ($parent_file == 'edit.php?post_type=page') {
            $type = 'page';
        }
    } else {
        if ($parent_file == 'edit-pages.php') {
            $type = 'page';
        }
    }
    $num_posts_mf = RCCWP_CustomWritePanel::GetCountPostNotWritePanel($type);
    printf("\n    <script type=\"text/javascript\">\n    //<![CDATA[\n      jQuery().ready(function() {\n        change_number_manage_not_write_panel('(%s)','(%s)','(%s)','(%s)','(%s)','(%s)','(%s)');\n      });\n    //]]>\n    </script>", array_sum((array) $num_posts_mf) - $num_posts_mf->trash, $num_posts_mf->publish, $num_posts_mf->pending, $num_posts_mf->draft, $num_posts_mf->private, $num_posts_mf->trash, $num_posts_mf->future);
    $_SESSION['change_number_not_write_panel_manage'] = "1";
    return $where;
}