本文整理汇总了PHP中wp_edit_posts_query函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_edit_posts_query函数的具体用法?PHP wp_edit_posts_query怎么用?PHP wp_edit_posts_query使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_edit_posts_query函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle_bulkactions
/**
* @since 1.0
*/
public function handle_bulkactions($action, $result)
{
global $wp_list_table, $wp_query;
if (!$result || $action != 'bulk-posts') {
return;
}
if (empty($wp_list_table)) {
return;
}
if (!in_array($wp_list_table->current_action(), array('trash', 'untrash', 'delete')) || empty($_REQUEST['post'])) {
return;
}
if (empty($_REQUEST['basa-selectall']) || empty($_REQUEST['basa-num-items'])) {
return;
}
$num_items = intval($_REQUEST['basa-num-items']);
if (!$num_items) {
return;
}
add_filter('request', array($this, 'request_all_ids'));
wp_edit_posts_query();
remove_filter('request', array($this, 'request_all_ids'));
$num_posts = count($wp_query->posts);
if ($num_items != $num_posts) {
return;
}
$_REQUEST['post'] = $wp_query->posts;
}
示例2: prepare_items
function prepare_items() {
global $post_type_object, $avail_post_stati, $wp_query, $per_page, $mode;
$avail_post_stati = wp_edit_posts_query();
$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
) );
}
示例3: prepare_items
function prepare_items()
{
global $avail_post_stati, $wp_query, $per_page, $mode;
$avail_post_stati = wp_edit_posts_query();
$this->hierarchical_display = is_post_type_hierarchical($this->screen->post_type) && 'menu_order title' == $wp_query->query['orderby'];
$total_items = $this->hierarchical_display ? $wp_query->post_count : $wp_query->found_posts;
$post_type = $this->screen->post_type;
$per_page = $this->get_items_per_page('edit_' . $post_type . '_per_page');
/** This filter is documented in wp-admin/includes/post.php */
$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));
}
示例4: prepare_items
function prepare_items()
{
global $post_type_object, $avail_post_stati, $wp_query, $per_page, $mode;
$avail_post_stati = wp_edit_posts_query();
$this->hierarchical_display = false;
$total_items = $this->hierarchical_display ? $wp_query->post_count : $wp_query->found_posts;
$post_type = 'post';
//$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);
$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));
$columns = $this->get_columns();
$hidden = array();
$sortable = array();
$this->_column_headers = array($columns, $hidden, $sortable);
$current_page = $this->get_pagenum();
}
示例5: prepare_items
/**
*
* @global array $avail_post_stati
* @global WP_Query $wp_query
* @global int $per_page
* @global string $mode
*/
public function prepare_items()
{
global $avail_post_stati, $wp_query, $per_page, $mode;
// is going to call wp()
$avail_post_stati = wp_edit_posts_query();
$this->set_hierarchical_display(is_post_type_hierarchical($this->screen->post_type) && 'menu_order title' === $wp_query->query['orderby']);
$post_type = $this->screen->post_type;
$per_page = $this->get_items_per_page('edit_' . $post_type . '_per_page');
/** This filter is documented in wp-admin/includes/post.php */
$per_page = apply_filters('edit_posts_per_page', $per_page, $post_type);
if ($this->hierarchical_display) {
$total_items = $wp_query->post_count;
} elseif ($wp_query->found_posts || $this->get_pagenum() === 1) {
$total_items = $wp_query->found_posts;
} else {
$post_counts = (array) wp_count_posts($post_type, 'readable');
if (isset($_REQUEST['post_status']) && in_array($_REQUEST['post_status'], $avail_post_stati)) {
$total_items = $post_counts[$_REQUEST['post_status']];
} elseif (isset($_REQUEST['show_sticky']) && $_REQUEST['show_sticky']) {
$total_items = $this->sticky_posts_count;
} elseif (isset($_GET['author']) && $_GET['author'] == get_current_user_id()) {
$total_items = $this->user_posts_count;
} else {
$total_items = array_sum($post_counts);
// 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_items -= $post_counts[$state];
}
}
}
if (!empty($_REQUEST['mode'])) {
$mode = $_REQUEST['mode'] === 'excerpt' ? 'excerpt' : 'list';
set_user_setting('posts_list_mode', $mode);
} else {
$mode = get_user_setting('posts_list_mode', 'list');
}
$this->is_trash = isset($_REQUEST['post_status']) && $_REQUEST['post_status'] === 'trash';
$this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page));
}
示例6: add_query_arg
}
if (isset($deleted)) {
$sendback = add_query_arg('deleted', $deleted, $sendback);
}
wp_redirect($sendback);
exit;
} elseif (isset($_GET['_wp_http_referer']) && !empty($_GET['_wp_http_referer'])) {
wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
exit;
}
if (empty($title)) {
$title = __('Edit Posts');
}
$parent_file = 'edit.php';
wp_enqueue_script('inline-edit-post');
list($post_stati, $avail_post_stati) = wp_edit_posts_query();
require_once 'admin-header.php';
if (!isset($_GET['paged'])) {
$_GET['paged'] = 1;
}
if (empty($_GET['mode'])) {
$mode = 'list';
} else {
$mode = attribute_escape($_GET['mode']);
}
?>
<div class="wrap">
<?php
screen_icon();
?>
示例7: elseif
exit;
} elseif (!empty($_GET['_wp_http_referer'])) {
wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
exit;
}
$title = sprintf(__('Edit %s'), $post_type_object->label);
wp_enqueue_script('inline-edit-post');
$user_posts = false;
if (!current_user_can($post_type_object->edit_others_cap)) {
$user_posts_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(1) FROM {$wpdb->posts} WHERE post_type = '%s' AND post_status NOT IN ('trash', 'auto-draft') AND post_author = %d", $post_type, $current_user->ID));
$user_posts = true;
if ($user_posts_count && empty($_GET['post_status']) && empty($_GET['all_posts']) && empty($_GET['author'])) {
$_GET['author'] = $current_user->ID;
}
}
$avail_post_stati = wp_edit_posts_query();
if ($post_type_object->hierarchical) {
$num_pages = ceil($wp_query->post_count / $per_page);
} else {
$num_pages = $wp_query->max_num_pages;
}
require_once './admin-header.php';
if (empty($_GET['mode'])) {
$mode = 'list';
} else {
$mode = esc_attr($_GET['mode']);
}
?>
<div class="wrap">
<?php
示例8: orders_page
function orders_page()
{
//load single order view if id is set
if (isset($_GET['order_id'])) {
$this->single_order_page();
return;
}
//force post type
global $wpdb, $post_type, $wp_query, $wp_locale, $current_screen;
$post_type = 'mp_order';
$_GET['post_type'] = $post_type;
$post_type_object = get_post_type_object($post_type);
if (!current_user_can($post_type_object->cap->edit_posts)) {
wp_die(__('Cheatin’ uh?'));
}
$pagenum = isset($_GET['paged']) ? absint($_GET['paged']) : 0;
if (empty($pagenum)) {
$pagenum = 1;
}
$per_page = 'edit_' . $post_type . '_per_page';
$per_page = (int) get_user_option($per_page);
if (empty($per_page) || $per_page < 1) {
$per_page = 15;
}
// @todo filter based on type
$per_page = apply_filters('edit_posts_per_page', $per_page);
// Handle bulk actions
if (isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['bulk_edit']) || isset($_GET['action'])) {
check_admin_referer('update-order-status');
$sendback = remove_query_arg(array('received', 'paid', 'shipped', 'closed', 'ids'), wp_get_referer());
if (($_GET['action'] != -1 || $_GET['action2'] != -1) && (isset($_GET['post']) || isset($_GET['ids']))) {
$post_ids = isset($_GET['post']) ? array_map('intval', (array) $_GET['post']) : explode(',', $_GET['ids']);
$doaction = $_GET['action'] != -1 ? $_GET['action'] : $_GET['action2'];
}
switch ($doaction) {
case 'received':
$received = 0;
foreach ((array) $post_ids as $post_id) {
$this->update_order_status($post_id, 'received');
$received++;
}
$msg = sprintf(_n('%s order marked as Received.', '%s orders marked as Received.', $received, 'mp'), number_format_i18n($received));
break;
case 'paid':
$paid = 0;
foreach ((array) $post_ids as $post_id) {
$this->update_order_status($post_id, 'paid');
$paid++;
}
$msg = sprintf(_n('%s order marked as Paid.', '%s orders marked as Paid.', $paid, 'mp'), number_format_i18n($paid));
break;
case 'shipped':
$shipped = 0;
foreach ((array) $post_ids as $post_id) {
$this->update_order_status($post_id, 'shipped');
$shipped++;
}
$msg = sprintf(_n('%s order marked as Shipped.', '%s orders marked as Shipped.', $shipped, 'mp'), number_format_i18n($shipped));
break;
case 'closed':
$closed = 0;
foreach ((array) $post_ids as $post_id) {
$this->update_order_status($post_id, 'closed');
$closed++;
}
$msg = sprintf(_n('%s order Closed.', '%s orders Closed.', $closed, 'mp'), number_format_i18n($closed));
break;
}
}
$avail_post_stati = wp_edit_posts_query();
$num_pages = $wp_query->max_num_pages;
$mode = 'list';
?>
<div class="wrap">
<div class="icon32"><img src="<?php
echo $this->plugin_url . 'images/shopping-cart.png';
?>
" /></div>
<h2><?php
_e('Manage Orders', 'mp');
if (isset($_GET['s']) && $_GET['s']) {
printf('<span class="subtitle">' . __('Search results for “%s”') . '</span>', get_search_query());
}
?>
</h2>
<?php
if (isset($msg)) {
?>
<div class="updated fade"><p>
<?php
echo $msg;
?>
</p></div>
<?php
}
?>
<form id="posts-filter" action="<?php
//.........这里部分代码省略.........
示例9: ajax_get_posts_list_table
/**
* Get the post list table rows for the searched term.
*
* Mimics admin/edit.php without all the chrome elements.
*
* @since 1.2.0
* @todo Account for private status on media items?
*/
public static function ajax_get_posts_list_table()
{
global $hook_suffix, $pagenow, $post_type, $post_type_object, $per_page, $mode, $wp_query;
if (!isset($_REQUEST['nonce']) || !wp_verify_nonce($_REQUEST['nonce'], 'bils-posts-list-table-instant-search')) {
echo '<tr class="no-items bils-error"><td class="colspanchange">Invalid nonce.</td></tr>';
wp_die();
}
$post_type = $_REQUEST['post_type'];
$post_type_object = get_post_type_object($post_type);
// Determine the orderby argument.
if (isset($_REQUEST['orderby']) && !empty($_REQUEST['orderby'])) {
$orderby = $_REQUEST['orderby'];
} else {
$orderby = $post_type_object->hierarchical ? 'title' : 'post_date';
}
// Determine the order argument.
if (isset($_REQUEST['order']) && !empty($_REQUEST['order'])) {
$order = 'asc' == strtolower($_REQUEST['order']) ? 'asc' : 'desc';
} else {
$order = $post_type_object->hierarchical ? 'asc' : 'desc';
}
$args = array('s' => $_REQUEST['s'], 'post_type' => $post_type, 'post_status' => $_REQUEST['post_status'], 'orderby' => $orderby, 'order' => $order, 'posts_per_page' => 20);
if ('attachment' == $post_type) {
$args['post_status'] = 'inherit';
$args['post_mime_type'] = $_REQUEST['post_mime_type'];
}
// WordPress SEO compatibility.
if (function_exists('wpseo_admin_init')) {
$pagenow = 'edit.php';
wpseo_admin_init();
if (class_exists('WPSEO_Metabox')) {
$wpseo_metabox = new WPSEO_Metabox();
$wpseo_metabox->setup_page_analysis();
}
}
set_current_screen($_REQUEST['screen']);
// Posts 2 Posts column compatibility.
do_action('load-edit.php');
add_filter('posts_search', array('Better_Internal_Link_Search', 'limit_search_to_title'), 10, 2);
wp_edit_posts_query($args);
if ('attachment' == $post_type) {
$wp_list_table = _get_list_table('WP_Media_List_Table', array('screen' => $_REQUEST['screen']));
} else {
$wp_list_table = _get_list_table('WP_Posts_List_Table', array('screen' => $_REQUEST['screen']));
}
$wp_list_table->prepare_items();
$wp_list_table->display_rows_or_placeholder();
wp_die();
}
示例10: get_query
protected function get_query(array $args)
{
global $wp_query, $wp_the_query;
$wp_the_query = $wp_query = new WP_Query();
wp_edit_posts_query($args);
return $wp_query;
}
示例11: views_list
function views_list($views)
{
global $wp_query;
$avail_post_stati = wp_edit_posts_query();
$num_posts = wp_count_posts('incsub_event', 'readable');
$argvs = array('post_type' => 'incsub_event');
foreach (get_post_stati($argvs, '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($_GET['post_status']) && $status_name == $_GET['post_status']) {
$class = ' class="current"';
}
$views[$status_name] = "<li><a href='edit.php?post_type=incsub_event&post_status={$status_name}'{$class}>" . sprintf(_n($status->label_count[0], $status->label_count[1], $num_posts->{$status_name}), number_format_i18n($num_posts->{$status_name})) . '</a>';
}
return $views;
}