本文整理汇总了PHP中Post::list_post_statuses方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::list_post_statuses方法的具体用法?PHP Post::list_post_statuses怎么用?PHP Post::list_post_statuses使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post::list_post_statuses方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search_to_get
/**
* Parses a search string for status, type, author, and tag keywords. Returns
* an associative array which can be passed to Posts::get(). If multiple
* authors, statuses, tags, or types are specified, we assume an implicit OR
* such that (e.g.) any author that matches would be returned.
*
* @param string $search_string The search string
* @return array An associative array which can be passed to Posts::get()
*/
public static function search_to_get($search_string)
{
// if adding to this array, make sure you update the consequences of a search on this below in the switch.
$keywords = array('author' => 1, 'status' => 1, 'type' => 1, 'tag' => 1, 'info' => 1);
$statuses = Post::list_post_statuses();
$types = Post::list_active_post_types();
$arguments = array('user_id' => array(), 'status' => array(), 'content_type' => array(), 'tag' => array(), 'info' => array());
$criteria = '';
// this says, find stuff that has the keyword at the start, and then some term straight after.
// the terms should have no whitespace, or if it does, be ' delimited.
// ie tag:foo or tag:'foo bar'
$flag_regex = '/(?P<flag>' . implode('|', array_keys($keywords)) . '):(?P<value>[^\'"][^\\s]*(?:\\s|$)|([\'"]+)(?P<quotedvalue>[^\\3]+)(?<!\\\\)\\3)/Uui';
// now do some matching.
preg_match_all($flag_regex, $search_string, $matches, PREG_SET_ORDER);
// now we remove those terms from the search string, otherwise the keyword search below has issues. It will pick up things like
// from tag:'pair of' -> matches of'
$criteria = trim(preg_replace($flag_regex, '', $search_string));
// go through flagged things.
foreach ($matches as $match) {
// switch on the type match. ie status, type et al.
// also, trim out the quote marks that have been matched.
if (isset($match['quotedvalue']) && $match['quotedvalue']) {
$value = stripslashes($match['quotedvalue']);
} else {
$value = $match['value'];
}
switch (strtolower($match['flag'])) {
case 'author':
if ($u = User::get($value)) {
$arguments['user_id'][] = (int) $u->id;
}
break;
case 'tag':
$arguments['tag'][] = $value;
break;
case 'status':
if (isset($statuses[$value])) {
$arguments['status'][] = (int) $statuses[$value];
}
break;
case 'type':
if (isset($types[$value])) {
$arguments['content_type'][] = (int) $types[$value];
}
break;
case 'info':
if (strpos($value, ':') !== FALSE) {
list($infokey, $infovalue) = explode(':', $value, 2);
$arguments['info'][] = array($infokey => $infovalue);
}
break;
}
}
// flatten keys that have single-element or no-element arrays
foreach ($arguments as $key => $arg) {
switch (count($arg)) {
case 0:
unset($arguments[$key]);
break;
case 1:
$arguments[$key] = $arg[0];
break;
}
}
if ($criteria != '') {
$arguments['criteria'] = $criteria;
}
return $arguments;
}
示例2: search_to_get
/**
* Parses a search string for status, type, author, and tag keywords. Returns
* an associative array which can be passed to Posts::get(). If multiple
* authors, statuses, tags, or types are specified, we assume an implicit OR
* such that (e.g.) any author that matches would be returned.
*
* @param string $search_string The search string
* @return array An associative array which can be passed to Posts::get()
*/
public static function search_to_get($search_string)
{
$keywords = array('author' => 1, 'status' => 1, 'type' => 1, 'tag' => 1);
$statuses = Post::list_post_statuses();
$types = Post::list_active_post_types();
$arguments = array('user_id' => array(), 'status' => array(), 'content_type' => array(), 'tag' => array());
$criteria = '';
$tokens = explode(' ', $search_string);
foreach ($tokens as $token) {
//check for triple combination
if (preg_match('/^\\w+:[^:\\s]*:\\S+$/', $token)) {
list($keyword, $infokey, $infovalue) = explode(':', $token);
$keyword = strtolower($keyword);
switch ($keyword) {
case 'info':
$arguments['info'][] = array($infokey => $infovalue);
break;
}
}
// check for a keyword:value pair
if (preg_match('/^\\w+:\\S+$/', $token)) {
list($keyword, $value) = explode(':', $token);
$keyword = strtolower($keyword);
switch ($keyword) {
case 'author':
if ($u = User::get($value)) {
$arguments['user_id'][] = (int) $u->id;
}
break;
case 'tag':
$arguments['tag'][] = $value;
break;
case 'status':
if (isset($statuses[$value])) {
$arguments['status'][] = (int) $statuses[$value];
}
break;
case 'type':
if (isset($types[$value])) {
$arguments['content_type'][] = (int) $types[$value];
}
break;
}
} else {
$criteria .= $token . ' ';
}
}
// flatten keys that have single-element or no-element arrays
foreach ($arguments as $key => $arg) {
switch (count($arg)) {
case 0:
unset($arguments[$key]);
break;
case 1:
$arguments[$key] = $arg[0];
break;
}
}
if ($criteria != '') {
$arguments['criteria'] = $criteria;
}
return $arguments;
}
示例3: get_form
/**
* Returns a form for editing this post
* @param string $context The context the form is being created in, most often 'admin'
* @return FormUI A form appropriate for creating and updating this post.
*/
public function get_form( $context )
{
$form = new FormUI( 'create-content' );
$form->class[] = 'create';
$newpost = ( 0 === $this->id );
// If the post has already been saved, add a link to its permalink
if ( !$newpost ) {
$post_links = $form->append( 'wrapper', 'post_links' );
$permalink = ( $this->status != Post::status( 'published' ) ) ? $this->permalink . '?preview=1' : $this->permalink;
$post_links->append( 'static', 'post_permalink', '<a href="'. $permalink .'" class="viewpost" >'.( $this->status != Post::status( 'published' ) ? _t( 'Preview Post' ) : _t( 'View Post' ) ).'</a>' );
$post_links->class ='container';
}
// Create the Title field
$form->append( 'text', 'title', 'null:null', _t( 'Title' ), 'admincontrol_text' );
$form->title->class[] = 'important';
$form->title->class[] = 'check-change';
$form->title->tabindex = 1;
$form->title->value = $this->title;
// Create the silos
if ( count( Plugins::get_by_interface( 'MediaSilo' ) ) ) {
$form->append( 'silos', 'silos' );
$form->silos->silos = Media::dir();
}
// Create the Content field
$form->append( 'textarea', 'content', 'null:null', _t( 'Content' ), 'admincontrol_textarea' );
$form->content->class[] = 'resizable';
$form->content->class[] = 'check-change';
$form->content->tabindex = 2;
$form->content->value = $this->content;
$form->content->raw = true;
// Create the tags field
$form->append( 'text', 'tags', 'null:null', _t( 'Tags, separated by, commas' ), 'admincontrol_text' );
$form->tags->class = 'check-change';
$form->tags->tabindex = 3;
$tags = (array)$this->get_tags();
array_map(
create_function( '$a',
'$a->term_display = MultiByte::strpos( $a->term_display, \',\' ) === false ? $a->term_display : $a->tag_text_searchable;' ),
$tags
);
$form->tags->value = implode( ', ', $tags );
// Create the splitter
$publish_controls = $form->append( 'tabs', 'publish_controls' );
// Create the publishing controls
// pass "false" to list_post_statuses() so that we don't include internal post statuses
$statuses = Post::list_post_statuses( $this );
unset( $statuses[array_search( 'any', $statuses )] );
$statuses = Plugins::filter( 'admin_publish_list_post_statuses', $statuses );
$settings = $publish_controls->append( 'fieldset', 'settings', _t( 'Settings' ) );
$settings->append( 'select', 'status', 'null:null', _t( 'Content State' ), array_flip( $statuses ), 'tabcontrol_select' );
$settings->status->value = $this->status;
// hide the minor edit checkbox if the post is new
if ( $newpost ) {
$settings->append( 'hidden', 'minor_edit', 'null:null' );
$settings->minor_edit->value = false;
}
else {
$settings->append( 'checkbox', 'minor_edit', 'null:null', _t( 'Minor Edit' ), 'tabcontrol_checkbox' );
$settings->minor_edit->value = true;
$form->append( 'hidden', 'modified', 'null:null' )->value = $this->modified;
}
$settings->append( 'checkbox', 'comments_enabled', 'null:null', _t( 'Comments Allowed' ), 'tabcontrol_checkbox' );
$settings->comments_enabled->value = $this->info->comments_disabled ? false : true;
$settings->append( 'text', 'pubdate', 'null:null', _t( 'Publication Time' ), 'tabcontrol_text' );
$settings->pubdate->value = $this->pubdate->format( 'Y-m-d H:i:s' );
$settings->pubdate->helptext = _t( 'YYYY-MM-DD HH:MM:SS' );
$settings->append( 'hidden', 'updated', 'null:null' );
$settings->updated->value = $this->updated->int;
$settings->append( 'text', 'newslug', 'null:null', _t( 'Content Address' ), 'tabcontrol_text' );
$settings->newslug->value = $this->slug;
// Create the button area
$buttons = $form->append( 'fieldset', 'buttons' );
$buttons->template = 'admincontrol_buttons';
$buttons->class[] = 'container';
$buttons->class[] = 'buttons';
$buttons->class[] = 'publish';
// Create the Save button
//.........这里部分代码省略.........
示例4: search_to_get
/**
* Parses a search string for status, type, author, and tag keywords. Returns
* an associative array which can be passed to Posts::get(). If multiple
* authors, statuses, tags, or types are specified, we assume an implicit OR
* such that (e.g.) any author that matches would be returned.
*
* @param string $search_string The search string
* @return array An associative array which can be passed to Posts::get()
*/
public static function search_to_get($search_string)
{
// if adding to this array, make sure you update the consequences of a search on this below in the switch.
$keywords = array('author' => 1, 'status' => 1, 'type' => 1, 'tag' => 1, 'info' => 1);
$statuses = Post::list_post_statuses();
$types = Post::list_active_post_types();
$arguments = array('user_id' => array(), 'status' => array(), 'content_type' => array(), 'vocabulary' => array(), 'info' => array());
$criteria = '';
// this says, find stuff that has the keyword at the start, and then some term straight after.
// the terms should have no whitespace, or if it does, be ' delimited.
// ie tag:foo or tag:'foo bar'
$flag_regex = '/(?P<flag>\\w+):(?P<value>[^\'"][^\\s]*|(?P<quote>[\'"])[^\\3]+(?<!\\\\)\\3)/i';
// now do some matching.
preg_match_all($flag_regex, $search_string, $matches, PREG_SET_ORDER);
// now we remove those terms from the search string, otherwise the keyword search below has issues. It will pick up things like
// from tag:'pair of' -> matches of'
$criteria = trim(preg_replace($flag_regex, '', $search_string));
// Add special criteria based on the flag parameters.
foreach ($matches as $match) {
// trim out any quote marks that have been matched.
$quote = isset($match['quote']) ? $match['quote'] : ' ';
$value = trim(stripslashes($match['value']), $quote);
$flag = $match['flag'];
$arguments = Plugins::filter('posts_search_to_get', $arguments, $flag, $value, $match, $search_string);
switch ($flag) {
case 'author':
if ($u = User::get($value)) {
$arguments['user_id'][] = (int) $u->id;
}
break;
case 'tag':
$arguments['vocabulary'][Tags::vocabulary()->name . ':term_display'][] = $value;
break;
case 'status':
if (isset($statuses[$value])) {
$arguments['status'][] = (int) $statuses[$value];
}
break;
case 'type':
if (isset($types[$value])) {
$arguments['content_type'][] = (int) $types[$value];
}
break;
case 'info':
if (strpos($value, ':') !== false) {
list($infokey, $infovalue) = explode(':', $value, 2);
$arguments['info'][] = array($infokey => $infovalue);
}
break;
}
}
// flatten keys that have single-element or no-element arrays
foreach ($arguments as $key => $arg) {
switch (count($arg)) {
case 0:
unset($arguments[$key]);
break;
case 1:
if (is_array($arg)) {
$arguments[$key] = $arg;
} else {
$arguments[$key] = $arg[0];
}
break;
}
}
if ($criteria != '') {
$arguments['criteria'] = $criteria;
}
return $arguments;
}
示例5: _t
</a></span>
</div>
<div>
<span class="nothing"> </span>
<span class="aka">
<?php
if (!$user->info->authenticate_time) {
$last_login_message = _t('has not logged in yet');
} else {
$last_login_message = _t('was last seen %1$s at %2$s');
$last_login_message = sprintf($last_login_message, '<strong>' . date(DateTime::get_default_date_format(), strtotime($user->info->authenticate_time)) . '</strong>', '<strong>' . date(DateTime::get_default_time_format(), strtotime($user->info->authenticate_time)) . '</strong>');
}
$message_bits = array();
$post_statuses = Post::list_post_statuses();
unset($post_statuses[array_search('any', $post_statuses)]);
foreach ($post_statuses as $status_name => $status_id) {
$status_name = Plugins::filter('post_status_display', $status_name);
$count = Posts::count_by_author($user->id, $status_id);
if ($count > 0) {
$message = '<strong><a href="' . Utils::htmlspecialchars(URL::get('admin', array('page' => 'posts', 'user_id' => $user->id, 'type' => Post::type('any'), 'status' => $status_id))) . '">';
$message .= _n(_t('%1$d %2$s post', array($count, $status_name)), _t('%1$d %2$s posts', array($count, $status_name)), $count);
$message .= '</a></strong>';
$message_bits[] = $message;
}
}
if (!empty($message_bits)) {
$string = _t('%1$s and currently has %2$s', array($last_login_message, Format::and_list($message_bits)));
} else {
$string = $last_login_message;
示例6: post_posts
/**
* Handles POST values from /manage/entries.
* Used to control what content to show / manage.
*/
public function post_posts()
{
$this->fetch_posts();
// Get special search statuses
$statuses = array_keys(Post::list_post_statuses());
array_shift($statuses);
$statuses = array_combine($statuses, array_map(create_function('$a', 'return "status:{$a}";'), $statuses));
// Get special search types
$types = array_keys(Post::list_active_post_types());
array_shift($types);
$types = array_combine($types, array_map(create_function('$a', 'return "type:{$a}";'), $types));
$this->theme->admin_page = _t('Manage Posts');
$this->theme->admin_title = _t('Manage Posts');
$this->theme->special_searches = Plugins::filter('special_searches', array_merge($statuses, $types));
$this->display('posts');
}
示例7: post_posts
/**
* Handles POST values from /manage/posts.
* Used to control what content to show / manage.
*/
public function post_posts()
{
$this->fetch_posts();
// Get special search statuses
$statuses = array_keys(Post::list_post_statuses());
array_shift($statuses);
$labels = array_map(function ($a) {
return MultiByte::ucfirst(Plugins::filter("post_status_display", $a));
}, $statuses);
$terms = array_map(function ($a) {
return "status:{$a}";
}, $statuses);
$statuses = array_combine($terms, $labels);
// Get special search types
$types = array_keys(Post::list_active_post_types());
array_shift($types);
$labels = array_map(function ($a) {
return Plugins::filter("post_type_display", $a, "singular");
}, $types);
$terms = array_map(function ($a) {
return "type:{$a}";
}, $types);
$types = array_combine($terms, $labels);
$special_searches = array_merge($statuses, $types);
// Add a filter to get the only the user's posts
$special_searches["author:" . User::identify()->username] = _t('My Posts');
$this->theme->admin_page = _t('Manage Posts');
$this->theme->admin_title = _t('Manage Posts');
$this->theme->special_searches = Plugins::filter('special_searches', $special_searches);
$this->display('posts');
}
示例8: filter_dash_module_post_types_and_statuses
/**
* filter_dash_module_post_types
* Function used to set theme variables to the post types dashboard widget
* @param string $module_id
* @return string The contents of the module
*/
public function filter_dash_module_post_types_and_statuses( $module, $module_id, $theme )
{
$messages = array();
$user = User::identify();
$post_types = Post::list_active_post_types();
array_shift( $post_types );
$post_statuses = array_values( Post::list_post_statuses() );
array_shift( $post_statuses );
foreach( $post_types as $type => $type_id ) {
$plural = Plugins::filter( 'post_type_display', $type, 'plural' );
foreach( $post_statuses as $status => $status_id ) {
$status_display = MultiByte::ucfirst( Plugins::filter( 'post_status_display', Post::status_name( $status_id ) ) );
$site_count = Posts::get( array( 'content_type' => $type_id, 'count' => true, 'status' => $status_id ) );
$user_count = Posts::get( array( 'content_type' => $type_id, 'count' => true, 'status' => $status_id, 'user_id' => $user->id ) );
// @locale First variable is the post status, second is the post type
$message['label'] = _t( '%1$s %2$s', array( $status_display, $plural ) );
if( ! $site_count ) {
$message['site_count'] = '';
}
else if( $user->cannot( 'post_unpublished' ) && Post::status_name( $status_id ) != 'published' ) {
$message['site_count'] = '';
}
else {
$message['site_count'] = $site_count;
}
$perms = array(
'post_any' => array( ACL::get_bitmask( 'delete' ), ACL::get_bitmask( 'edit' ) ),
'own_posts' => array( ACL::get_bitmask( 'delete' ), ACL::get_bitmask( 'edit' ) ),
'post_' . $type => array( ACL::get_bitmask( 'delete' ), ACL::get_bitmask( 'edit' ) ),
);
if ( $user->can_any( $perms ) && $message['site_count'] ) {
$message['site_count'] = '<a href="' . Utils::htmlspecialchars( URL::get( 'admin', array( 'page' => 'posts', 'type' => Post::type( $type ), 'status' => $status_id ) ) ) . '">' . Utils::htmlspecialchars( $message['site_count'] ) . '</a>';
}
if( ! $user_count ) {
$message['user_count'] = '';
}
else {
$message['user_count'] = $user_count;
}
// @locale First variable is the post status, second is the post type
$perms = array(
'own_posts' => array( ACL::get_bitmask( 'delete' ), ACL::get_bitmask( 'edit' ) ),
'post_' . $type => array( ACL::get_bitmask( 'delete' ), ACL::get_bitmask( 'edit' ) ),
);
if ( $user->can_any( $perms ) && $message['user_count'] ) {
$message['user_count'] = '<a href="' . Utils::htmlspecialchars( URL::get( 'admin', array( 'page' => 'posts', 'type' => Post::type( $type ), 'status' => $status_id, 'user_id' => $user->id ) ) ) . '">' . Utils::htmlspecialchars( $message['user_count'] ) . '</a>';
}
if( $message['site_count'] || $message['user_count'] ) {
$messages[] = $message;
}
}
}
$theme->type_messages = $messages;
$module['title'] = _t( 'Post Types and Statuses' );
$module['content'] = $theme->fetch( 'dash_posttypes' );
return $module;
}
示例9: get_form
/**
* Returns a form for editing this post
* @param string $context The context the form is being created in, most often 'admin'
* @return FormUI A form appropriate for creating and updating this post.
*/
public function get_form($context)
{
/** @var FormUI $form */
$form = new FormUI('create-content', null, array('class' => array('create')));
$form->set_wrap_each('<div class="container">%s</div>');
$newpost = 0 === $this->id;
// If the post has already been saved, add a link to its permalink
if (!$newpost) {
/** @var FormControlWrapper $post_links */
$post_links = $form->append(FormControlWrapper::create('post_links', null, array('class' => 'container')));
$permalink = $this->status != Post::status('published') ? $this->permalink . '?preview=1' : $this->permalink;
$post_links->append(FormControlStatic::create('post_permalink')->set_static('<a href="' . $permalink . '" class="viewpost" >' . ($this->status != Post::status('published') ? _t('Preview Post') : _t('View Post')) . '</a>'));
}
// Store this post instance into a hidden field for later use when saving data
$form->append(FormControlData::create('post')->set_value($this));
// Create the Title field
$form->append(FormControlLabel::wrap(_t('Title'), FormControlText::create('title', null, array('class' => array('check-change full-width')))->set_value($this->title_internal)));
// Create the silos
if (count(Plugins::get_by_interface('MediaSilo'))) {
$silos = FormControlSilos::create('silos')->set_setting('wrap', '<div class="container silos">%s</div>');
$form->append($silos);
}
// Create the Content field
$form->append(FormControlLabel::wrap(_t('Content'), FormControlTextArea::create('content', null, array('class' => array('resizable', 'check-change full-width rte')))->set_value($this->content_internal)));
$form->content->raw = true;
// @todo What does this do?
// Create the tags field
/** @var FormControlAutocomplete $tags_control */
$form->append(FormControlLabel::wrap(_t('Tags, separated by, commas'), $tags_control = FormControlAutocomplete::create('tags', null, array('style' => 'width:100%;margin:0px 0px 20px;', 'class' => 'check-change full-width'), array('allow_new' => true, 'init_selection' => true)))->set_properties(array('style' => 'width:100%;margin:0px 0px 20px;')));
$tags = (array) $this->get_tags();
array_walk($tags, function (&$element, $key) {
$element->term_display = MultiByte::strpos($element->term_display, ',') === false ? $element->term_display : $element->tag_text_searchable;
});
$tags_control->set_value(implode(',', $tags));
$tags_control->set_ajax(URL::auth_ajax('tag_list'));
// Create the splitter
/** @var FormControlTabs $publish_controls */
$publish_controls = $form->append(FormControlTabs::create('publish_controls')->set_setting('wrap', '%s')->set_setting('class_each', 'container'));
// Create the publishing controls
// pass "false" to list_post_statuses() so that we don't include internal post statuses
$statuses = Post::list_post_statuses($this);
unset($statuses[array_search('any', $statuses)]);
$statuses = Plugins::filter('admin_publish_list_post_statuses', $statuses);
/** @var FormControlFieldset $settings */
$settings = $publish_controls->append(FormControlFieldset::create('post_settings')->set_caption(_t('Settings')));
$settings->append(FormControlLabel::wrap(_t('Content State'), FormControlSelect::create('status')->set_options(array_flip($statuses))->set_value($this->status)));
// hide the minor edit checkbox if the post is new
if ($newpost) {
$settings->append(FormControlData::create('minor_edit')->set_value(false));
} else {
$settings->append(FormControlLabel::wrap(_t('Minor Edit'), FormControlCheckbox::create('minor_edit')->set_value(true)));
$form->append(FormControlData::create('modified')->set_value($this->modified));
}
$settings->append(FormControlLabel::wrap(_t('Comments Allowed'), FormControlCheckbox::create('comments_enabled')->set_value($this->info->comments_disabled ? false : true)));
$settings->append(FormControlLabel::wrap(_t('Publication Time'), FormControlText::create('pubdate')->set_value($this->pubdate->format('Y-m-d H:i:s'))));
$settings->pubdate->set_helptext(_t('YYYY-MM-DD HH:MM:SS'));
$settings->append(FormControlData::create('updated')->set_value($this->updated->int));
$settings->append(FormControlLabel::wrap(_t('Content Address'), FormControlText::create('newslug')->set_value($this->slug)));
// Create the button area
$buttons = $form->append(FormControlFieldset::create('buttons', null, array('class' => array('container', 'buttons', 'publish'))));
// What buttons should we have?
$require_any = array('own_posts' => 'create', 'post_any' => 'create', 'post_' . Post::type_name($this->content_type) => 'create');
$show_buttons = array();
if ($newpost) {
if (User::identify()->can_any($require_any)) {
$show_buttons['save'] = true;
$show_buttons['publish'] = true;
}
} else {
if (ACL::access_check($this->get_access(), 'edit')) {
if ($this->status == Post::status('draft')) {
$show_buttons['publish'] = true;
}
$show_buttons['save'] = true;
}
if (ACL::access_check($this->get_access(), 'delete')) {
$show_buttons['delete'] = true;
}
}
$show_buttons = Plugins::filter('publish_form_buttons', $show_buttons, $this);
if (isset($show_buttons['delete'])) {
// Create the Delete button
$buttons->append(FormControlSubmit::create('delete', null, array('class' => 'three columns'))->set_caption(_t('Delete'))->on_success(array($this, 'form_publish_delete')));
}
if (isset($show_buttons['save'])) {
// Create the Save button
$buttons->append(FormControlSubmit::create('save', null, array('class' => 'three columns'))->set_caption(_t('Save')));
}
if (isset($show_buttons['publish'])) {
// Create the Publish button
$buttons->append(FormControlSubmit::create('publish', null, array('class' => 'three columns'))->set_caption(_t('Publish'))->add_validator(function ($value, FormControlSubmit $control, FormUI $form) {
$form->status->set_value(Post::status('published'));
$allow = Plugins::filter('post_publish_allow', true, $this);
if (!$allow) {
return array('Publishing has been denied');
//.........这里部分代码省略.........
示例10: filter_facetvalues
/**
* Plugin hook filter for the values of a faceted search
* @param array $other_values The incoming array of values for this facet
* @param string $facet The selected facet
* @param string $q A string filter for facet values
* @return array The returned list of possible values
*/
public static function filter_facetvalues($other_values, $facet, $q)
{
switch ($facet) {
case 'type':
$values = array_keys(Post::list_active_post_types());
break;
case 'status':
$values = array_keys(Post::list_post_statuses());
break;
case 'tag':
$tags = Tags::search($q);
$values = array();
foreach ($tags as $tag) {
$values[] = $tag->term_display;
}
break;
case 'author':
$values = array();
$users = Users::get(array('criteria' => $q));
foreach ($users as $user) {
$values[] = $user->username;
}
break;
case 'before':
case 'after':
$values = array($q);
break;
}
return array_merge($other_values, $values);
}