public function status_menu($post_stati)
 {
     global $parent_file, $submenu, $submenu_file;
     $num_posts = wp_count_posts('page', 'readable');
     $num_total = array_sum((array) $num_posts);
     $link = $submenu_file = 'edit-pages.php';
     $submenu[$parent_file] = array(array(__('Add New Page'), 'edit_pages', 'page-new.php'), array(sprintf(__('All (%s)', 'ktai_style'), $num_total), 'edit_pages', $link));
     $post_status_label = __('Pages');
     $avail_post_stati = get_available_post_statuses('page');
     foreach ($post_stati as $status => $label) {
         if (!in_array($status, $avail_post_stati)) {
             continue;
         }
         if (empty($num_posts->{$status})) {
             continue;
         }
         $link = add_query_arg('post_status', $status, $link);
         $submenu[$parent_file][] = array(sprintf(__ngettext($label[2][0], $label[2][1], $num_posts->{$status}, 'ktai_style'), number_format_i18n($num_posts->{$status})), 'edit_pages', $link);
         if (str_replace('all', '', $status) == $_GET['post_status']) {
             $submenu_file = $link;
             $post_status_label = $label[1];
             $num_total = $num_posts->{$status};
         }
     }
     return array($post_status_label, $num_total);
 }
 private function wp_edit_posts_query($post_type = null, $q = false)
 {
     if (false === $q) {
         $q = $_GET;
     }
     $q['m'] = isset($q['m']) ? (int) $q['m'] : 0;
     $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0;
     $post_stati = get_post_stati();
     if (empty($post_type)) {
         if (isset($q['post_type']) && in_array($q['post_type'], get_post_types())) {
             $post_type = $q['post_type'];
         } else {
             $post_type = 'post';
         }
     }
     $avail_post_stati = get_available_post_statuses($post_type);
     if (isset($q['post_status']) && in_array($q['post_status'], $post_stati)) {
         $post_status = $q['post_status'];
         $perm = 'readable';
     }
     if (isset($q['orderby'])) {
         $orderby = $q['orderby'];
     } elseif (isset($q['post_status']) && in_array($q['post_status'], array('pending', 'draft'))) {
         $orderby = 'modified';
     }
     if (isset($q['order'])) {
         $order = $q['order'];
     } elseif (isset($q['post_status']) && 'pending' == $q['post_status']) {
         $order = 'ASC';
     }
     $per_page = 'tm_per_page';
     $posts_per_page = (int) get_user_option($per_page);
     if (empty($posts_per_page) || $posts_per_page < 1) {
         $posts_per_page = 20;
     }
     $posts_per_page = apply_filters($per_page, $posts_per_page);
     $query = compact('post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page');
     // Hierarchical types require special args.
     if (is_post_type_hierarchical($post_type) && !isset($orderby)) {
         $query['orderby'] = 'menu_order title';
         $query['order'] = 'asc';
         $query['posts_per_page'] = -1;
         $query['posts_per_archive_page'] = -1;
     }
     // WPML (add meta data to query)
     TM_EPO_WPML()->apply_query_filter();
     wp($query);
     TM_EPO_WPML()->remove_query_filter();
     return $avail_post_stati;
 }
 function prepare_items()
 {
     global $post_type_object, $avail_post_stati, $wp_query, $per_page, $mode;
     $query_args = array('post_type' => $this->post_type);
     $query_args['post_parent'] = $this->post_parent ? $this->post_parent : 0;
     $query_args['m'] = isset($_GET['m']) ? (int) $_GET['m'] : 0;
     $query_args['cat'] = isset($_GET['cat']) ? (int) $_GET['cat'] : 0;
     $wp_query = new WP_Query(apply_filters('cpm_table_query', $query_args));
     //$avail_post_stati = wp_edit_posts_query( $query_args );
     $avail_post_stati = get_available_post_statuses($this->post_type);
     $this->hierarchical_display = $post_type_object->hierarchical && 'menu_order title' == $wp_query->query['orderby'];
     $total_items = $this->hierarchical_display ? $wp_query->post_count : $wp_query->found_posts;
     $post_type = $post_type_object->name;
     $per_page = $this->get_items_per_page('edit_' . $post_type . '_per_page');
     $per_page = apply_filters('edit_posts_per_page', $per_page, $post_type);
     if ($this->hierarchical_display) {
         $total_pages = ceil($total_items / $per_page);
     } else {
         $total_pages = $wp_query->max_num_pages;
     }
     $mode = empty($_REQUEST['mode']) ? 'list' : $_REQUEST['mode'];
     $this->is_trash = isset($_REQUEST['post_status']) && $_REQUEST['post_status'] == 'trash';
     $this->set_pagination_args(array('total_items' => $total_items, 'total_pages' => $total_pages, 'per_page' => $per_page));
 }
Example #4
0
echo $this->get_field_id('post_status');
?>
">
				<?php 
_e('Post Status', 'rpwe');
?>
			</label>
			<select class="widefat" id="<?php 
echo $this->get_field_id('post_status');
?>
" name="<?php 
echo $this->get_field_name('post_status');
?>
" style="width:100%;">
				<?php 
foreach (get_available_post_statuses() as $status_value => $status_label) {
    ?>
					<option value="<?php 
    echo esc_attr($status_label);
    ?>
" <?php 
    selected($instance['post_status'], $status_label);
    ?>
><?php 
    echo esc_html(ucfirst($status_label));
    ?>
</option>
				<?php 
}
?>
			</select>
Example #5
0
/**
 * Run the wp query to fetch the posts for listing on the edit posts page
 *
 * @since 2.5.0
 *
 * @param array|bool $q Array of query variables to use to build the query or false to use $_GET superglobal.
 * @return array
 */
function wp_edit_posts_query($q = false)
{
    if (false === $q) {
        $q = $_GET;
    }
    $q['m'] = isset($q['m']) ? (int) $q['m'] : 0;
    $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0;
    $post_stati = get_post_stati();
    if (isset($q['post_type']) && in_array($q['post_type'], get_post_types())) {
        $post_type = $q['post_type'];
    } else {
        $post_type = 'post';
    }
    $avail_post_stati = get_available_post_statuses($post_type);
    if (isset($q['post_status']) && in_array($q['post_status'], $post_stati)) {
        $post_status = $q['post_status'];
        $perm = 'readable';
    }
    if (isset($q['orderby'])) {
        $orderby = $q['orderby'];
    } elseif (isset($q['post_status']) && in_array($q['post_status'], array('pending', 'draft'))) {
        $orderby = 'modified';
    }
    if (isset($q['order'])) {
        $order = $q['order'];
    } elseif (isset($q['post_status']) && 'pending' == $q['post_status']) {
        $order = 'ASC';
    }
    $per_page = "edit_{$post_type}_per_page";
    $posts_per_page = (int) get_user_option($per_page);
    if (empty($posts_per_page) || $posts_per_page < 1) {
        $posts_per_page = 20;
    }
    /**
     * Filters the number of items per page to show for a specific 'per_page' type.
     *
     * The dynamic portion of the hook name, `$post_type`, refers to the post type.
     *
     * Some examples of filter hooks generated here include: 'edit_attachment_per_page',
     * 'edit_post_per_page', 'edit_page_per_page', etc.
     *
     * @since 3.0.0
     *
     * @param int $posts_per_page Number of posts to display per page for the given post
     *                            type. Default 20.
     */
    $posts_per_page = apply_filters("edit_{$post_type}_per_page", $posts_per_page);
    /**
     * Filters the number of posts displayed per page when specifically listing "posts".
     *
     * @since 2.8.0
     *
     * @param int    $posts_per_page Number of posts to be displayed. Default 20.
     * @param string $post_type      The post type.
     */
    $posts_per_page = apply_filters('edit_posts_per_page', $posts_per_page, $post_type);
    $query = compact('post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page');
    // Hierarchical types require special args.
    if (is_post_type_hierarchical($post_type) && !isset($orderby)) {
        $query['orderby'] = 'menu_order title';
        $query['order'] = 'asc';
        $query['posts_per_page'] = -1;
        $query['posts_per_archive_page'] = -1;
        $query['fields'] = 'id=>parent';
    }
    if (!empty($q['show_sticky'])) {
        $query['post__in'] = (array) get_option('sticky_posts');
    }
    wp($query);
    return $avail_post_stati;
}
</a> | <a href="<?php 
    echo get_edit_post_link($_GET['posted']);
    ?>
"><?php 
    _e('Edit page');
    ?>
</a></p></div>
<?php 
    $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
}
?>

<form id="posts-filter" action="" method="get">
<ul class="subsubsub">
<?php 
$avail_post_stati = get_available_post_statuses('page');
if (empty($locked_post_status)) {
    $status_links = array();
    $num_posts = wp_count_posts('page', 'readable');
    $total_posts = array_sum((array) $num_posts);
    $class = empty($_GET['post_status']) ? ' class="current"' : '';
    $status_links[] = "<li><a href='edit-pages.php'{$class}>" . sprintf(__ngettext('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts), number_format_i18n($total_posts)) . '</a>';
    foreach ($post_stati as $status => $label) {
        $class = '';
        if (!in_array($status, $avail_post_stati)) {
            continue;
        }
        if (isset($_GET['post_status']) && $status == $_GET['post_status']) {
            $class = ' class="current"';
        }
        $status_links[] = "<li><a href='edit-pages.php?post_status={$status}'{$class}>" . sprintf(_nc($label[2][0], $label[2][1], $num_posts->{$status}), number_format_i18n($num_posts->{$status})) . '</a>';
Example #7
0
/**
 * Run the wp query to fetch the posts for listing on the edit posts page
 *
 * @since 2.5.0
 *
 * @param array|bool $q Array of query variables to use to build the query or false to use $_GET superglobal.
 * @return array
 */
function wp_edit_posts_query($q = false)
{
    if (false === $q) {
        $q = $_GET;
    }
    $q['m'] = isset($q['m']) ? (int) $q['m'] : 0;
    $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0;
    $post_stati = get_post_stati();
    if (isset($q['post_type']) && in_array($q['post_type'], get_post_types())) {
        $post_type = $q['post_type'];
    } else {
        $post_type = 'post';
    }
    $avail_post_stati = get_available_post_statuses($post_type);
    if (isset($q['post_status']) && in_array($q['post_status'], $post_stati)) {
        $post_status = $q['post_status'];
        $perm = 'readable';
    }
    if (isset($q['orderby'])) {
        $orderby = $q['orderby'];
    } elseif (isset($q['post_status']) && in_array($q['post_status'], array('pending', 'draft'))) {
        $orderby = 'modified';
    }
    if (isset($q['order'])) {
        $order = $q['order'];
    } elseif (isset($q['post_status']) && 'pending' == $q['post_status']) {
        $order = 'ASC';
    }
    $per_page = 'edit_' . $post_type . '_per_page';
    $posts_per_page = (int) get_user_option($per_page);
    if (empty($posts_per_page) || $posts_per_page < 1) {
        $posts_per_page = 20;
    }
    $posts_per_page = apply_filters($per_page, $posts_per_page);
    $posts_per_page = apply_filters('edit_posts_per_page', $posts_per_page, $post_type);
    $query = compact('post_type', 'post_status', 'perm', 'order', 'orderby', 'posts_per_page');
    // Hierarchical types require special args.
    if (is_post_type_hierarchical($post_type) && !isset($orderby)) {
        $query['orderby'] = 'menu_order title';
        $query['order'] = 'asc';
        $query['posts_per_page'] = -1;
        $query['posts_per_archive_page'] = -1;
    }
    if (!empty($q['show_sticky'])) {
        $query['post__in'] = (array) get_option('sticky_posts');
    }
    wp($query);
    return $avail_post_stati;
}
 public function get_views()
 {
     global $locked_post_status;
     $parent = get_post($this->product_id);
     $avail_post_stati = get_available_post_statuses('wpsc-product');
     $post_type_object = get_post_type_object('wpsc-product');
     $post_type = $post_type_object->name;
     $url_base = add_query_arg(array('action' => 'wpsc_product_variations_table', 'product_id' => $_REQUEST['product_id'], '_wpnonce' => wp_create_nonce('wpsc_product_variations_table')), admin_url('admin-ajax.php'));
     if (!empty($locked_post_status)) {
         return array();
     }
     $status_links = array();
     $num_posts = $this->count_variations();
     $class = '';
     $current_user_id = get_current_user_id();
     if (isset($num_posts->inherit)) {
         $key = $parent->post_status;
         if (!isset($num_posts->{$key})) {
             $num_posts->{$key} = 0;
         }
         $num_posts->{$key} += $num_posts->inherit;
         unset($num_posts->inherit);
     }
     $total_posts = array_sum((array) $num_posts);
     // Subtract post types that are not included in the admin all list.
     foreach (get_post_stati(array('show_in_admin_all_list' => false)) as $state) {
         if (isset($num_posts->{$state})) {
             $total_posts -= $num_posts->{$state};
         }
     }
     $class = empty($class) && empty($_REQUEST['post_status']) && empty($_REQUEST['show_sticky']) ? ' class="current"' : '';
     $status_links['all'] = "<a href='{$url_base}'{$class}>" . sprintf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts'), number_format_i18n($total_posts)) . '</a>';
     foreach (get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status) {
         $class = '';
         $status_name = $status->name;
         if ($status_name == 'publish') {
             continue;
         }
         if (!in_array($status_name, $avail_post_stati)) {
             continue;
         }
         if (empty($num_posts->{$status_name})) {
             if (isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status']) {
                 $num_posts->{$_REQUEST}['post_status'] = 0;
             } else {
                 continue;
             }
         }
         if (isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status']) {
             $class = ' class="current"';
         }
         $status_links[$status_name] = "<a href='" . esc_url(add_query_arg('post_status', $status_name, $url_base)) . "'{$class}>" . sprintf(translate_nooped_plural($status->label_count, $num_posts->{$status_name}), number_format_i18n($num_posts->{$status_name})) . '</a>';
     }
     return $status_links;
 }
Example #9
0
/**
 * {@internal Missing Short Description}}
 *
 * @since unknown
 *
 * @param unknown_type $q
 * @return unknown
 */
function wp_edit_posts_query($q = false)
{
    if (false === $q) {
        $q = $_GET;
    }
    $q['m'] = isset($q['m']) ? (int) $q['m'] : 0;
    $q['cat'] = isset($q['cat']) ? (int) $q['cat'] : 0;
    $post_stati = array('publish' => array(__('Published'), __('Published posts'), _n_noop('Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>')), 'future' => array(__('Scheduled'), __('Scheduled posts'), _n_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>')), 'pending' => array(__('Pending Review'), __('Pending posts'), _n_noop('Pending Review <span class="count">(%s)</span>', 'Pending Review <span class="count">(%s)</span>')), 'draft' => array(__('Draft'), _x('Drafts', 'manage posts header'), _n_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>')), 'private' => array(__('Private'), __('Private posts'), _n_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>')));
    $post_stati = apply_filters('post_stati', $post_stati);
    $avail_post_stati = get_available_post_statuses('post');
    $post_status_q = '';
    if (isset($q['post_status']) && in_array($q['post_status'], array_keys($post_stati))) {
        $post_status_q = '&post_status=' . $q['post_status'];
        $post_status_q .= '&perm=readable';
    }
    if (isset($q['post_status']) && 'pending' === $q['post_status']) {
        $order = 'ASC';
        $orderby = 'modified';
    } elseif (isset($q['post_status']) && 'draft' === $q['post_status']) {
        $order = 'DESC';
        $orderby = 'modified';
    } else {
        $order = 'DESC';
        $orderby = 'date';
    }
    $posts_per_page = apply_filters('edit_posts_per_page', 15);
    wp("post_type=post&what_to_show=posts{$post_status_q}&posts_per_page={$posts_per_page}&order={$order}&orderby={$orderby}");
    return array($post_stati, $avail_post_stati);
}
Example #10
0
"><?php 
    _e('Edit page');
    ?>
</a></p></div>
<?php 
    $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
}
?>

	<form id="posts-filter" action="<?php 
echo CP_Custom_Content_Core::GetInstance()->get_manage_custom_content_url($post_type);
?>
" method="post">
	<ul class="subsubsub">
		<?php 
$avail_post_stati = get_available_post_statuses($post_type);
if (empty($locked_post_status)) {
    $status_links = array();
    $num_posts = wp_count_posts($post_type, 'readable');
    $total_posts = array_sum((array) $num_posts) - $num_posts->trash;
    $class = empty($_GET['post_status']) ? ' class="current"' : '';
    $status_links[] = "<li><a href='" . CP_Custom_Content_Core::GetInstance()->get_manage_custom_content_url($post_type) . "'{$class}>" . sprintf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, $content_title_plural), number_format_i18n($total_posts)) . '</a>';
    foreach ($post_stati as $status => $label) {
        $class = '';
        if (!in_array($status, $avail_post_stati)) {
            continue;
        }
        if (isset($_GET['post_status']) && $status == $_GET['post_status']) {
            $class = ' class="current"';
        }
        $status_links[] = "<li><a href='" . CP_Custom_Content_Core::GetInstance()->get_manage_custom_content_url($post_type) . "&post_status={$status}'{$class}>" . sprintf(_nx($label[2][0], $label[2][1], $num_posts->{$status}, $label[2][2]), number_format_i18n($num_posts->{$status})) . '</a>';
Example #11
0
 /**
  * Count the posts to be displayed in the table
  */
 protected function count_posts()
 {
     $query_args = $this->get_query_args();
     $statuses = $this->get_view_statuses();
     foreach ($statuses as $id => $label) {
         $status = $id;
         if ($id == 'any') {
             $status = array_diff(get_available_post_statuses(), array('trash'));
         }
         $args = array_merge($query_args, array('fields' => 'ids', 'paged' => 1, 'posts_per_page' => -1, 'post_status' => $status));
         $q = new WP_Query($args);
         $this->view_counts[$id] = $q->post_count;
     }
     $this->total_count = $this->view_counts[$this->parameters['status']];
 }
Example #12
0
function cmspo_post_statuses()
{
    $p = get_available_post_statuses('page');
    $exclude = array('trash', 'auto-draft', 'inherit');
    foreach ($exclude as $e) {
        unset($p[array_search($e, $p)]);
    }
    return apply_filters('cmspo_post_statuses', $p);
}
function wp_edit_posts_query( $q = false ) {
	global $wpdb;
	if ( false === $q )
		$q = $_GET;
	$q['m']   = (int) $q['m'];
	$q['cat'] = (int) $q['cat'];
	$post_stati  = array(	//	array( adj, noun )
				'publish' => array(__('Published'), __('Published posts'), __ngettext_noop('Published (%s)', 'Published (%s)')),
				'future' => array(__('Scheduled'), __('Scheduled posts'), __ngettext_noop('Scheduled (%s)', 'Scheduled (%s)')),
				'pending' => array(__('Pending Review'), __('Pending posts'), __ngettext_noop('Pending Review (%s)', 'Pending Review (%s)')),
				'draft' => array(__('Draft'), _c('Drafts|manage posts header'), __ngettext_noop('Draft (%s)', 'Drafts (%s)')),
				'private' => array(__('Private'), __('Private posts'), __ngettext_noop('Private (%s)', 'Private (%s)')),
			);

	$post_stati = apply_filters('post_stati', $post_stati);

	$avail_post_stati = get_available_post_statuses('post');

	$post_status_q = '';
	if ( isset($q['post_status']) && in_array( $q['post_status'], array_keys($post_stati) ) ) {
		$post_status_q = '&post_status=' . $q['post_status'];
		$post_status_q .= '&perm=readable';
	}

	if ( 'pending' === $q['post_status'] ) {
		$order = 'ASC';
		$orderby = 'modified';
	} elseif ( 'draft' === $q['post_status'] ) {
		$order = 'DESC';
		$orderby = 'modified';
	} else {
		$order = 'DESC';
		$orderby = 'date';
	}

	wp("post_type=post&what_to_show=posts$post_status_q&posts_per_page=15&order=$order&orderby=$orderby");

	return array($post_stati, $avail_post_stati);
}
 function get_views()
 {
     global $locked_post_status;
     $post_type = $this->args['post_type'];
     if (!empty($locked_post_status)) {
         return array();
     }
     $status_links = array();
     $num_posts = wp_count_posts($post_type, 'readable');
     $class = '';
     $allposts = '';
     $avail_post_stati = get_available_post_statuses($post_type);
     $total_posts = array_sum((array) $num_posts);
     //
     // Subtract post types that are not included in the admin all list.
     //
     foreach (get_post_stati(array('show_in_admin_all_list' => false)) as $state) {
         $total_posts -= $num_posts->{$state};
     }
     $class = empty($class) && empty($_REQUEST['post_status']) && empty($_REQUEST['show_sticky']) ? ' class="current"' : '';
     $all_url = remove_query_arg('post_status', $this->get_admin_url());
     $status_links['all'] = "<a href='{$all_url}'{$class}>" . sprintf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts'), number_format_i18n($total_posts)) . '</a>';
     foreach (get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status) {
         $class = '';
         $status_name = $status->name;
         if (!in_array($status_name, $avail_post_stati)) {
             continue;
         }
         if (empty($num_posts->{$status_name})) {
             continue;
         }
         if (isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status']) {
             $class = ' class="current"';
         }
         $status_url = add_query_arg(array('post_status' => $status_name), $this->get_admin_url());
         $status_links[$status_name] = "<a href='{$status_url}' {$class}>" . sprintf(translate_nooped_plural($status->label_count, $num_posts->{$status_name}), number_format_i18n($num_posts->{$status_name})) . '</a>';
     }
     return $status_links;
 }
 /**
  * Clone the core WP function, add the possibility to manage the post type
  *
  * @param string $q
  * @return void
  * @author Amaury Balmer
  */
 public static function edit_data_query($q = false)
 {
     if (false === $q) {
         $q = $_GET;
     }
     // Date
     if (isset($q['m'])) {
         $q['m'] = (int) $q['m'];
     }
     // Category
     if (isset($q['cat'])) {
         $q['cat'] = (int) $q['cat'];
     }
     // Quantity
     $q['posts_per_page'] = isset($q['posts_per_page']) ? (int) $q['posts_per_page'] : 0;
     if ($q['posts_per_page'] == 0) {
         $q['posts_per_page'] = 15;
     }
     // Content type
     $q['post_type'] = SimpleTags_Admin::$post_type;
     // Post status
     $post_stati = array('publish' => array(_x('Published', 'post'), __('Published posts'), _n_noop('Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>')), 'future' => array(_x('Scheduled', 'post'), __('Scheduled posts'), _n_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>')), 'pending' => array(_x('Pending Review', 'post'), __('Pending posts'), _n_noop('Pending Review <span class="count">(%s)</span>', 'Pending Review <span class="count">(%s)</span>')), 'draft' => array(_x('Draft', 'post'), _x('Drafts', 'manage posts header'), _n_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>')), 'private' => array(_x('Private', 'post'), __('Private posts'), _n_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>')));
     $post_stati = apply_filters('post_stati', $post_stati);
     $avail_post_stati = get_available_post_statuses(SimpleTags_Admin::$post_type);
     $post_status_q = '';
     if (isset($q['post_status']) && in_array($q['post_status'], array_keys($post_stati))) {
         $post_status_q = '&post_status=' . $q['post_status'];
         $post_status_q .= '&perm=readable';
     } elseif (!isset($q['post_status'])) {
         $q['post_status'] = '';
     }
     if ('pending' === $q['post_status']) {
         $order = 'ASC';
         $orderby = 'modified';
     } elseif ('draft' === $q['post_status']) {
         $order = 'DESC';
         $orderby = 'modified';
     } else {
         $order = 'DESC';
         $orderby = 'date';
     }
     wp("post_type={$q['post_type']}&what_to_show=posts{$post_status_q}&posts_per_page={$q['posts_per_page']}&order={$order}&orderby={$orderby}");
     return array($post_stati, $avail_post_stati);
 }
 /**
  * Outputs a JSON-encoded list of posts and terms on the blog.
  * 
  * @since 6.0
  */
 function jlsuggest_autocomplete()
 {
     if (!function_exists('json_encode')) {
         die;
     }
     if (!current_user_can('manage_options')) {
         die;
     }
     $items = array();
     $include = empty($_GET['types']) ? array() : explode(',', $_GET['types']);
     if ((!$include || in_array('home', $include)) && sustr::ihas($_GET['q'], 'home')) {
         $items[] = array('text' => __('Home', 'seo-ultimate'), 'isheader' => true);
         $items[] = array('text' => __('Blog Homepage', 'seo-ultimate'), 'value' => 'obj_home', 'selectedtext' => __('Blog Homepage', 'seo-ultimate'));
     }
     $posttypeobjs = get_post_types(array('public' => true), 'objects');
     foreach ($posttypeobjs as $posttypeobj) {
         if ($include && !in_array('posttype', $include) && !in_array('posttype_' . $posttypeobj->name, $include)) {
             continue;
         }
         $stati = get_available_post_statuses($posttypeobj->name);
         suarr::remove_value($stati, 'auto-draft');
         $stati = implode(',', $stati);
         $posts = get_posts(array('orderby' => 'title', 'order' => 'ASC', 'post_status' => $stati, 'numberposts' => -1, 'post_type' => $posttypeobj->name, 'post_mime_type' => isset($_GET['post_mime_type']) ? $_GET['post_mime_type'] : '', 'sentence' => 1, 's' => $_GET['q']));
         if (count($posts)) {
             $items[] = array('text' => $posttypeobj->labels->name, 'isheader' => true);
             foreach ($posts as $post) {
                 $items[] = array('text' => $post->post_title, 'value' => 'obj_posttype_' . $posttypeobj->name . '/' . $post->ID, 'selectedtext' => $post->post_title . '<span class="type">&nbsp;&mdash;&nbsp;' . $posttypeobj->labels->singular_name . '</span>');
             }
         }
     }
     $taxonomyobjs = suwp::get_taxonomies();
     foreach ($taxonomyobjs as $taxonomyobj) {
         if ($include && !in_array('taxonomy', $include) && !in_array('taxonomy_' . $posttypeobj->name, $include)) {
             continue;
         }
         $terms = get_terms($taxonomyobj->name, array('search' => $_GET['q']));
         if (count($terms)) {
             $items[] = array('text' => $taxonomyobj->labels->name, 'isheader' => true);
             foreach ($terms as $term) {
                 $items[] = array('text' => $term->name, 'value' => 'obj_taxonomy_' . $taxonomyobj->name . '/' . $term->term_id, 'selectedtext' => $term->name . '<span class="type"> &mdash; ' . $taxonomyobj->labels->singular_name . '</span>');
             }
         }
     }
     if (!$include || in_array('author', $include)) {
         $authors = get_users(array('search' => $_GET['q'], 'fields' => array('ID', 'user_login')));
         if (count($authors)) {
             $items[] = array('text' => __('Author Archives', 'seo-ultimate'), 'isheader' => true);
             foreach ($authors as $author) {
                 $items[] = array('text' => $author->user_login, 'value' => 'obj_author/' . $author->ID, 'selectedtext' => $author->user_login . '<span class="type"> &mdash; ' . __('Author', 'seo-ultimate') . '</span>');
             }
         }
     }
     if ($this->module_exists('internal-link-aliases') && (!$include || in_array('internal-link-alias', $include))) {
         $aliases = $this->get_setting('aliases', array(), 'internal-link-aliases');
         $alias_dir = $this->get_setting('alias_dir', 'go', 'internal-link-aliases');
         if (is_array($aliases) && count($aliases)) {
             $header_outputted = false;
             foreach ($aliases as $alias_id => $alias) {
                 if ($alias['to']) {
                     $h_alias_to = su_esc_html($alias['to']);
                     $to_rel_url = "/{$alias_dir}/{$h_alias_to}/";
                     if (strpos($alias['from'], $_GET['q']) !== false || strpos($to_rel_url, $_GET['q']) !== false) {
                         if (!$header_outputted) {
                             $items[] = array('text' => __('Link Masks', 'seo-ultimate'), 'isheader' => true);
                             $header_outputted = true;
                         }
                         $items[] = array('text' => $to_rel_url, 'value' => 'obj_internal-link-alias/' . $alias_id, 'selectedtext' => $to_rel_url . '<span class="type"> &mdash; ' . __('Link Mask', 'seo-ultimate') . '</span>');
                     }
                 }
             }
         }
     }
     echo json_encode($items);
     die;
 }
 /**
  * Return an associative array ( id => link ) with the list of views
  * available for this table.
  *
  * Calculates the count for each view.
  *
  * @since 1.0.0
  */
 function get_views()
 {
     global $wpdb;
     $post_type = 'audiotheme_gig';
     $post_type_object = get_post_type_object($post_type);
     $avail_post_stati = get_available_post_statuses($post_type);
     $base_url = get_audiotheme_gig_admin_url();
     $status_links = array();
     $num_posts = wp_count_posts($post_type, 'readable');
     $allposts = '';
     $current_user_id = get_current_user_id();
     /*
     // @todo This could be useful in a multiple artist context (for a label).
     if ( $this->user_posts_count ) {
     	if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) )
     		$class = ' class="current"';
     	$status_links['mine'] = "<a href='edit.php?post_type=$post_type&author=$current_user_id'$class>" . sprintf( _nx( 'Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', $this->user_posts_count, 'posts' ), number_format_i18n( $this->user_posts_count ) ) . '</a>';
     	$allposts = '&all_posts=1';
     }
     */
     $total_posts = array_sum((array) $num_posts);
     // Subtract post types that are not included in the admin all list.
     foreach (get_post_stati(array('show_in_admin_all_list' => false)) as $status) {
         $total_posts -= $num_posts->{$status};
     }
     $sql = "SELECT COUNT( DISTINCT p.ID )\r\n\t\t\tFROM {$wpdb->posts} p\r\n\t\t\tINNER JOIN {$wpdb->postmeta} pm ON p.ID=pm.post_id\r\n\t\t\tWHERE p.post_type='audiotheme_gig' AND p.post_status!='auto-draft' AND pm.meta_key='_audiotheme_gig_datetime'";
     $upcoming_count = $wpdb->get_var($wpdb->prepare($sql . ' AND pm.meta_value>=%s', current_time('mysql')));
     $status_links['upcoming'] = sprintf('<a href="%s"%s>%s <span class="count">(%d)</span></a>', esc_url($base_url), 'upcoming' === $this->current_view ? ' class="current"' : '', __('Upcoming', 'audiotheme'), $upcoming_count);
     $past_count = $wpdb->get_var($wpdb->prepare($sql . ' AND pm.meta_value<%s', current_time('mysql')));
     $status_links['past'] = sprintf('<a href="%s"%s>%s <span class="count">(%d)</span></a>', esc_url(add_query_arg(array('gig_date' => current_time('mysql'), 'compare' => '%3C'), $base_url)), 'past' === $this->current_view ? ' class="current"' : '', __('Past', 'audiotheme'), $past_count);
     $class = 'any' === $this->current_view ? ' class="current"' : '';
     $all_url = esc_url(add_query_arg('post_status', 'any', $base_url));
     $status_links['all'] = "<a href='{$all_url}{$allposts}'{$class}>" . sprintf(_nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts'), number_format_i18n($total_posts)) . '</a>';
     foreach (get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status) {
         $class = '';
         $status_name = $status->name;
         if (!in_array($status_name, $avail_post_stati)) {
             continue;
         }
         if (empty($num_posts->{$status_name})) {
             continue;
         }
         if ($status_name === $this->current_view) {
             $class = ' class="current"';
         }
         $status_url = esc_url(add_query_arg(array('post_status' => $status_name, 'post_type' => $post_type), $base_url));
         $status_links[$status_name] = "<a href='{$status_url}'{$class}>" . sprintf(translate_nooped_plural($status->label_count, $num_posts->{$status_name}), number_format_i18n($num_posts->{$status_name})) . '</a>';
     }
     return $status_links;
 }