本文整理汇总了PHP中get_post_stati函数的典型用法代码示例。如果您正苦于以下问题:PHP get_post_stati函数的具体用法?PHP get_post_stati怎么用?PHP get_post_stati使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_post_stati函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: tally_term_counts
public static function tally_term_counts(&$terms, $taxonomy, $args = array())
{
global $wpdb, $pp_current_user;
if (!$terms) {
return;
}
$defaults = array('pad_counts' => true, 'post_type' => '', 'required_operation' => '');
$args = array_merge($defaults, (array) $args);
extract($args);
$term_items = array();
if ($terms) {
if (!is_object(reset($terms))) {
return $terms;
}
foreach ((array) $terms as $key => $term) {
$terms_by_id[$term->term_id] =& $terms[$key];
$term_ids[$term->term_taxonomy_id] = $term->term_id;
}
}
// Get the object and term ids and stick them in a lookup table
$tax_obj = get_taxonomy($taxonomy);
$object_types = $post_type ? (array) $post_type : (array) esc_sql($tax_obj->object_type);
if (pp_unfiltered()) {
$stati = get_post_stati(array('public' => true, 'private' => true), 'names', 'or');
$type_status_clause = "AND post_type IN ('" . implode("', '", $object_types) . "') AND post_status IN ('" . implode("', '", $stati) . "')";
} else {
global $query_interceptor;
$type_status_clause = $query_interceptor->get_posts_where(array('post_types' => $object_types, 'required_operation' => $required_operation));
// need to apply term restrictions in case post is restricted by another taxonomy
}
if (!$required_operation) {
$required_operation = pp_is_front() && !is_preview() ? 'read' : 'edit';
}
$results = $wpdb->get_results("SELECT object_id, term_taxonomy_id FROM {$wpdb->term_relationships} INNER JOIN {$wpdb->posts} ON object_id = ID WHERE term_taxonomy_id IN ('" . implode("','", array_keys($term_ids)) . "') {$type_status_clause}");
foreach ($results as $row) {
$id = $term_ids[$row->term_taxonomy_id];
$term_items[$id][$row->object_id] = isset($term_items[$id][$row->object_id]) ? ++$term_items[$id][$row->object_id] : 1;
}
// Touch every ancestor's lookup row for each post in each term
foreach ($term_ids as $term_id) {
$child = $term_id;
while (!empty($terms_by_id[$child]) && ($parent = $terms_by_id[$child]->parent)) {
if (!empty($term_items[$term_id])) {
foreach ($term_items[$term_id] as $item_id => $touches) {
$term_items[$parent][$item_id] = isset($term_items[$parent][$item_id]) ? ++$term_items[$parent][$item_id] : 1;
}
}
$child = $parent;
}
}
foreach (array_keys($terms_by_id) as $key) {
$terms_by_id[$key]->count = 0;
}
// Transfer the touched cells
foreach ((array) $term_items as $id => $items) {
if (isset($terms_by_id[$id])) {
$terms_by_id[$id]->count = count($items);
}
}
}
开发者ID:estrategasdigitales,项目名称:glummer,代码行数:60,代码来源:terms-query-lib_pp.php
示例2: test__unregister_post_status
public function test__unregister_post_status()
{
register_post_status('foo');
_unregister_post_status('foo');
$stati = get_post_stati();
$this->assertFalse(isset($stati['foo']));
}
开发者ID:boonebgorges,项目名称:develop.wordpress,代码行数:7,代码来源:helpers.php
示例3: get_views
function get_views()
{
$status_links = array();
$num_posts = wp_count_posts(self::$post_type, 'readable');
$allposts = '';
$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($_REQUEST['post_status']) ? ' class="current"' : '';
$status_links['all'] = "<a href='edit.php?post_type=sa_invoice&page=sprout-apps/invoice_payments{$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 (empty($num_posts->{$status_name})) {
continue;
}
if (isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status']) {
$class = ' class="current"';
}
// replace "Published" with "Complete".
$label = str_replace('Published', 'Complete', translate_nooped_plural($status->label_count, $num_posts->{$status_name}));
$status_links[$status_name] = "<a href='edit.php?post_type=sa_invoice&page=sprout-apps/invoice_payments&post_status={$status_name}'{$class}>" . sprintf($label, number_format_i18n($num_posts->{$status_name})) . '</a>';
}
return $status_links;
}
开发者ID:danielbachhuber,项目名称:marcgratch.com,代码行数:27,代码来源:Payments_Admin_Table.php
示例4: us_ajax_blog
function us_ajax_blog()
{
// Filtering $template_vars, as is will be extracted to the template as local variables
$template_vars = shortcode_atts(array('query_args' => array(), 'layout_type' => 'large', 'metas' => array(), 'content_type' => 'none', 'show_read_more' => FALSE, 'pagination' => 'regular', 'el_class' => ''), us_maybe_get_post_json('template_vars'));
// Filtering query_args
if (isset($template_vars['query_args']) and is_array($template_vars['query_args'])) {
// Query Args keys, that won't be filtered
$allowed_query_keys = array('category_name', 'year', 'monthnum', 'day', 'tag', 's', 'paged', 'orderby', 'posts_per_page', 'post_type');
foreach ($template_vars['query_args'] as $query_key => $query_val) {
if (!in_array($query_key, $allowed_query_keys)) {
unset($template_vars['query_args'][$query_key]);
}
}
if (!isset($template_vars['query_args']['s']) and !isset($template_vars['post_type'])) {
$template_vars['query_args']['post_type'] = 'post';
}
// Providing proper post statuses
$template_vars['query_args']['post_status'] = array('publish' => 'publish');
$template_vars['query_args']['post_status'] += (array) get_post_stati(array('public' => TRUE));
// Add private states if user is capable to view them
if (is_user_logged_in() and current_user_can('read_private_posts')) {
$template_vars['query_args']['post_status'] += (array) get_post_stati(array('private' => TRUE));
}
$template_vars['query_args']['post_status'] = array_values($template_vars['query_args']['post_status']);
}
// Passing values that were filtered due to post protocol
us_load_template('templates/blog/listing', $template_vars);
// We don't use JSON to reduce data size
die;
}
开发者ID:afquinterog,项目名称:zephyr,代码行数:30,代码来源:blog.php
示例5: post_status
public function post_status($haystack = array('draft', 'publish', 'private'))
{
if (empty($haystack)) {
$haystack = array_values(get_post_stati());
}
return $this->generator->randomElement((array) $haystack);
}
开发者ID:juanfra,项目名称:fakerpress,代码行数:7,代码来源:wp-post.php
示例6: stats_load
function stats_load()
{
global $wp_roles;
Jetpack::enable_module_configurable(__FILE__);
Jetpack::module_configuration_load(__FILE__, 'stats_configuration_load');
Jetpack::module_configuration_head(__FILE__, 'stats_configuration_head');
Jetpack::module_configuration_screen(__FILE__, 'stats_configuration_screen');
// Tell HQ about changed posts
$post_stati = get_post_stati(array('public' => true));
// All public post stati
$post_stati[] = 'private';
// Content from private stati will be redacted
Jetpack_Sync::sync_posts(__FILE__, array('post_types' => get_post_types(array('public' => true)), 'post_stati' => $post_stati));
// Generate the tracking code after wp() has queried for posts.
add_action('template_redirect', 'stats_template_redirect', 1);
add_action('wp_head', 'stats_admin_bar_head', 100);
add_action('wp_head', 'stats_hide_smile_css');
add_action('jetpack_admin_menu', 'stats_admin_menu');
// Map stats caps
add_filter('map_meta_cap', 'stats_map_meta_caps', 10, 4);
if (isset($_GET['oldwidget'])) {
// Old one.
add_action('wp_dashboard_setup', 'stats_register_dashboard_widget');
} else {
add_action('admin_init', 'stats_merged_widget_admin_init');
}
add_filter('jetpack_xmlrpc_methods', 'stats_xmlrpc_methods');
add_filter('pre_option_db_version', 'stats_ignore_db_version');
}
开发者ID:jordankoschei,项目名称:jordankoschei-dot-com,代码行数:29,代码来源:stats.php
示例7: countPosts
/**
* Counts the posts of the specified post type.
*
* This is another version of wp_count_posts() without a filter.
*
* @since 2.0.0
*/
public static function countPosts($strPostType, $perm = '')
{
global $wpdb;
if (!post_type_exists($strPostType)) {
return new stdClass();
}
$oUser = wp_get_current_user();
$cache_key = 'posts-' . $strPostType;
$query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s";
if ('readable' == $perm && is_user_logged_in()) {
$post_type_object = get_post_type_object($strPostType);
if (!current_user_can($post_type_object->cap->read_private_posts)) {
$cache_key .= '_' . $perm . '_' . $oUser->ID;
$query .= " AND (post_status != 'private' OR ( post_author = '{$oUser->ID}' AND post_status = 'private' ))";
}
}
$query .= ' GROUP BY post_status';
$oCount = wp_cache_get($cache_key, 'counts');
if (false === $oCount) {
$results = (array) $wpdb->get_results($wpdb->prepare($query, $strPostType), ARRAY_A);
$oCount = array_fill_keys(get_post_stati(), 0);
foreach ($results as $row) {
$oCount[$row['post_status']] = $row['num_posts'];
}
$oCount = (object) $oCount;
wp_cache_set($cache_key, $oCount, 'counts');
}
return $oCount;
}
开发者ID:ashik968,项目名称:digiplot,代码行数:36,代码来源:AmazonAutoLinks_WPUtility_Post.php
示例8: Relevanssi_Search_Filter_RS
function Relevanssi_Search_Filter_RS()
{
$this->valid_stati = array_merge(get_post_stati(array('public' => true)), get_post_stati(array('private' => true)));
remove_filter('relevanssi_post_ok', 'relevanssi_default_post_ok');
add_filter('relevanssi_post_ok', array(&$this, 'relevanssi_post_ok'));
add_filter('relevanssi_results', array(&$this, 'relevanssi_log_results'));
}
开发者ID:par-orillonsoft,项目名称:creationOfSociety,代码行数:7,代码来源:relevanssi-helper-front_rs.php
示例9: get_reqd_caps
function get_reqd_caps()
{
$reqd_caps = array();
$generic_uri = in_array($GLOBALS['pagenow'], array('index.php', 'comments.php'));
if (!$generic_uri && ($_post_type = cr_find_post_type('', false))) {
// arg: don't return 'post' as default if detection fails
$post_types = array($_post_type => get_post_type_object($_post_type));
} else {
$post_types = array_diff_key(get_post_types(array('public' => true), 'object'), array('attachment' => true));
}
$use_post_types = scoper_get_option('use_post_types');
$post_statuses = get_post_stati(array('internal' => null), 'object');
foreach ($post_types as $_post_type => $type_obj) {
if (empty($use_post_types[$_post_type])) {
continue;
}
foreach ($post_statuses as $status => $status_obj) {
$reqd_caps[$_post_type][$status] = array($type_obj->cap->edit_others_posts);
if (scoper_get_option('require_moderate_comments_cap')) {
$reqd_caps[$_post_type][$status][] = 'moderate_comments';
}
if ($status_obj->private) {
$reqd_caps[$_post_type][$status][] = $type_obj->cap->edit_private_posts;
}
if ($status_obj->public || 'future' == $status) {
$reqd_caps[$_post_type][$status][] = $type_obj->cap->edit_published_posts;
}
}
}
return $reqd_caps;
}
开发者ID:joostrijneveld,项目名称:cscircles-wp-content,代码行数:31,代码来源:comments-interceptor-admin_rs.php
示例10: break_remaining_events_from_series
/**
* @param int $first_event_of_new_series The post ID of the first event of the new series
*
* @return void
*/
public function break_remaining_events_from_series($first_event_of_new_series)
{
$post = get_post($first_event_of_new_series);
$parent_id = $post->post_parent;
if (empty($parent_id)) {
return;
}
$children = get_posts(array('post_type' => Tribe__Events__Main::POSTTYPE, 'post_parent' => $parent_id, 'post_status' => get_post_stati(), 'meta_key' => '_EventStartDate', 'orderby' => 'meta_key', 'order' => 'ASC', 'fields' => 'ids', 'posts_per_page' => -1));
$children_to_move_to_new_series = array();
$break_date = get_post_meta($first_event_of_new_series, '_EventStartDate', true);
foreach ($children as $child_id) {
$child_date = get_post_meta($child_id, '_EventStartDate', true);
if ($child_date > $break_date) {
$children_to_move_to_new_series[$child_id] = $child_date;
}
}
$this->copy_post_meta($parent_id, $first_event_of_new_series);
$parent_recurrence = get_post_meta($parent_id, '_EventRecurrence', true);
$new_recurrence = get_post_meta($first_event_of_new_series, '_EventRecurrence', true);
$recurrences = Tribe__Events__Pro__Recurrence__Meta::get_recurrence_for_event($parent_id);
$earliest_date = strtotime(Tribe__Events__Pro__Recurrence__Meta::$scheduler->get_earliest_date());
$latest_date = strtotime(Tribe__Events__Pro__Recurrence__Meta::$scheduler->get_latest_date());
$child_movements_by_rule = array();
foreach ($parent_recurrence['rules'] as $rule_key => $rule) {
if (empty($recurrences['rules'][$rule_key])) {
continue;
}
$child_movements_by_rule[$rule_key] = 0;
$recurrences['rules'][$rule_key]->setMinDate($earliest_date);
$recurrences['rules'][$rule_key]->setMaxDate($latest_date);
$dates = $recurrences['rules'][$rule_key]->getDates();
// count the number of child events that are in this rule that are being moved
foreach ($children_to_move_to_new_series as $child_id => $child_date) {
$child_movements_by_rule[$rule_key] += (int) in_array($child_date, $dates);
}
if ('After' === $rule['end-type']) {
$parent_recurrence['rules'][$rule_key]['end-count'] -= $child_movements_by_rule[$rule_key] + 1;
$new_recurrence['rules'][$rule_key]['end-count'] = $child_movements_by_rule[$rule_key] + 1;
} else {
$parent_recurrence['rules'][$rule_key]['end'] = date('Y-m-d', strtotime($break_date));
}
}
update_post_meta($parent_id, '_EventRecurrence', $parent_recurrence);
update_post_meta($first_event_of_new_series, '_EventRecurrence', $new_recurrence);
add_post_meta($first_event_of_new_series, '_EventOriginalParent', $parent_id);
if (count($children) - count($children_to_move_to_new_series) == 1) {
delete_post_meta($parent_id, '_EventRecurrence');
}
$new_parent = get_post($first_event_of_new_series);
$new_parent->post_parent = 0;
$new_parent->comment_count = 0;
wp_update_post($new_parent);
foreach ($children_to_move_to_new_series as $child_id => $child_date) {
$child = get_post($child_id);
$child->post_parent = $first_event_of_new_series;
$child->comment_count = 0;
wp_update_post($child);
}
}
开发者ID:TakenCdosG,项目名称:chefs,代码行数:64,代码来源:Series_Splitter.php
示例11: test_all_public_post_stati_should_be_included_when_no_post_status_is_provided
public function test_all_public_post_stati_should_be_included_when_no_post_status_is_provided()
{
register_post_status('foo', array('public' => true));
$q = new WP_Query(array('posts_per_page' => 1));
foreach (get_post_stati(array('public' => true)) as $status) {
$this->assertContains("post_status = '{$status}'", $q->request);
}
}
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:8,代码来源:postStatus.php
示例12: test_get_items
public function test_get_items()
{
$request = new WP_REST_Request('GET', '/wp/v2/statuses');
$response = $this->server->dispatch($request);
$data = $response->get_data();
$statuses = get_post_stati(array('public' => true), 'objects');
$this->assertEquals(1, count($data));
$this->assertEquals('publish', $data['publish']['slug']);
}
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:9,代码来源:rest-post-statuses-controller.php
示例13: setup_post_status
public function setup_post_status()
{
if (isset($this->post_status) or empty($this->post_type)) {
return;
}
$args = array('private' => false, 'internal' => false, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true);
current_user_can(get_post_type_object($this->post_type)->cap->read_private_posts) and $args['private'] = true;
$this->post_status = get_post_stati($args);
}
开发者ID:nengineer,项目名称:WP-Anatomy,代码行数:9,代码来源:base.abstract.php
示例14: get_views
function get_views()
{
$status_links = array();
$num_posts = wp_count_posts(self::$storage_post_type, 'readable');
$entries_stati = get_post_stati(array('show_in_admin_status_list' => true), 'objects');
$view_link = add_query_arg(array('page' => 'cf7_storage'), admin_url('admin.php'));
$status_links['all'] = sprintf('<a href="%s">%s <span class="count">(%d)</span></a>', $view_link, esc_html__('All', 'cf7-storage'), $num_posts->publish);
$status_links['trash'] = sprintf('<a href="%s" %s>%s</a>', add_query_arg('post_status', 'trash', $view_link), $this->is_trash ? 'class="current"' : null, sprintf(translate_nooped_plural($entries_stati['trash']->label_count, $num_posts->trash), number_format_i18n($num_posts->trash)));
return $status_links;
}
开发者ID:misfist,项目名称:missdrepants-network,代码行数:10,代码来源:admin-list-view.php
示例15: current_user_can_read
public function current_user_can_read($post_id)
{
$post = get_post($post_id);
if (in_array($post->post_status, get_post_stati(array('public' => true)))) {
return true;
}
$post_type_object = get_post_type_object($post->post_type);
$user = wp_get_current_user();
return is_user_logged_in() && (current_user_can($post_type_object->cap->read_private_posts) || $user->ID == $post->post_author);
}
开发者ID:iq007,项目名称:MadScape,代码行数:10,代码来源:links.php
示例16: get_statuses
public function get_statuses()
{
if (empty($this->statuses)) {
$stati = get_post_stati(array('internal' => 0), 'objects');
foreach ($stati as $k => $status) {
$this->statuses[$k] = $status->label;
}
}
return $this->statuses;
}
开发者ID:coreymargulis,项目名称:karenmargulis,代码行数:10,代码来源:status.php
示例17: flt_comments_clauses
public static function flt_comments_clauses($clauses, &$qry_obj)
{
global $wpdb;
$stati = get_post_stati(array('public' => true, 'private' => true), 'names', 'or');
if (!defined('PP_NO_ATTACHMENT_COMMENTS')) {
$stati[] = 'inherit';
}
$status_csv = "'" . implode("','", $stati) . "'";
$clauses['where'] = preg_replace("/\\s*AND\\s*{$wpdb->posts}.post_status\\s*=\\s*[']?publish[']?/", "AND {$wpdb->posts}.post_status IN ({$status_csv})", $clauses['where']);
return $clauses;
}
开发者ID:severnrescue,项目名称:web,代码行数:11,代码来源:comments-int-administrator_pp.php
示例18: get_core_info
/**
*
* @global object $wpdb
*
*/
function get_core_info()
{
global $wpdb;
$jquery_ver = __('n/a', 'wpv-views');
if (wp_script_is('jquery', 'registered')) {
$reg_scripts = $GLOBALS['wp_scripts']->registered;
$jquery_ver = $reg_scripts['jquery']->ver;
}
$core = array('Wordpress' => array('Multisite' => is_multisite() ? 'Yes' : 'No', 'SiteURL' => site_url(), 'HomeURL' => home_url(), 'Version' => get_bloginfo('version'), 'PermalinkStructure' => get_option('permalink_structure'), 'PostTypes' => implode(', ', get_post_types('', 'names')), 'PostSatus' => implode(', ', get_post_stati())), 'Server' => array('jQueryVersion' => $jquery_ver, 'PHPVersion' => phpversion(), 'MySQLVersion' => $wpdb->db_version(), 'ServerSoftware' => $_SERVER['SERVER_SOFTWARE']), 'PHP' => array('MemoryLimit' => ini_get('memory_limit'), 'UploadMax' => ini_get('upload_max_filesize'), 'PostMax' => ini_get('post_max_size'), 'TimeLimit' => ini_get('max_execution_time'), 'MaxInputVars' => ini_get('max_input_vars')));
return $core;
}
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:16,代码来源:functions_debug_information.php
示例19: post_status_change
/**
* Post status change
*
* @param string $new_status The new status of the post
* @param string $old_status The old statud of the post
* @param WP_Post $post The WP_Post object
* @return null
*/
function post_status_change($new_status, $old_status, $post)
{
$post_statuses = get_post_stati();
$hook_settings = gnt_get_hook_settings();
foreach ($post_statuses as $post_status) {
if (isset($hook_settings['post_status_' . $post_status . '-enable']) && $hook_settings['post_status_' . $post_status . '-enable']) {
if ($old_status !== $post_status && $new_status === $post_status) {
do_action('gnt_hook_post_status_' . $post_status, array('hook' => 'post_' . $post_status, 'text' => $post->post_title . __(' changed status to ', 'get-notified') . $post_status, 'post' => $post, 'post_status' => $post_status));
}
}
}
}
开发者ID:kjbenk,项目名称:get-notified,代码行数:20,代码来源:posts.php
示例20: sanitize_request
protected function sanitize_request()
{
$request_data = parent::sanitize_request();
$this->post_type = $request_data['req_ptype'] ? $request_data['req_ptype'] : 'post';
$post_statuses = array_keys(get_post_stati());
$post_status = get_query_var('post_status');
if (is_string($post_status)) {
$post_status = $post_status ? array($post_status) : array();
}
$illegal_status = array_diff($post_status, $post_statuses);
$this->post_status = array_diff($post_status, $illegal_status);
}
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:12,代码来源:wpml-post-language-filter.class.php
注:本文中的get_post_stati函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论