本文整理匯總了PHP中is_object_in_taxonomy函數的典型用法代碼示例。如果您正苦於以下問題:PHP is_object_in_taxonomy函數的具體用法?PHP is_object_in_taxonomy怎麽用?PHP is_object_in_taxonomy使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了is_object_in_taxonomy函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: lazyLoadProperty
protected function lazyLoadProperty($key)
{
switch ($key) {
case 'page_template':
return $this->page_template = get_post_meta($this->ID, '_wp_page_template', true);
case 'post_category':
if (is_object_in_taxonomy($this->post_type, 'category')) {
$terms = get_the_terms($this->ID, 'category');
if (empty($terms)) {
$this->post_category = array();
} else {
$this->post_category = wp_list_pluck($terms, 'term_id');
}
}
return $this->post_category;
case 'tags_input':
if (is_object_in_taxonomy($this->post_type, 'post_tag')) {
$terms = get_the_terms($this->ID, 'post_tag');
if (empty($terms)) {
$this->tags_input = array();
} else {
$this->tags_input = wp_list_pluck($terms, 'name');
}
}
return $this->tags_input;
case 'ancestors':
return $this->ancestors = get_post_ancestors($this);
default:
break;
}
throw new \InvalidArgumentException("Invalid lazy-loaded property '{$key}'");
}
示例2: extra_tablenav
function extra_tablenav($which)
{
global $post_type_object, $cat;
?>
<div class="alignleft actions">
<?php
if ('top' == $which && !is_singular()) {
$this->months_dropdown($post_type_object->name);
if (is_object_in_taxonomy($post_type_object->name, 'category')) {
$dropdown_options = array('show_option_all' => __('View all categories'), 'hide_empty' => 0, 'hierarchical' => 1, 'show_count' => 0, 'orderby' => 'name', 'selected' => $cat);
wp_dropdown_categories($dropdown_options);
}
?>
<input type="checkbox" name="no_recipes" <?php
if (isset($_GET["no_recipes"])) {
echo "checked='checked'";
}
?>
/> Hide Posts With Recipes
<?php
do_action('restrict_manage_posts');
submit_button(__('Filter'), 'secondary', false, false, array('id' => 'post-query-submit'));
}
if ($this->is_trash && current_user_can($post_type_object->cap->edit_others_posts)) {
submit_button(__('Empty Trash'), 'button-secondary apply', 'delete_all', false);
}
?>
</div>
<?php
}
示例3: extra_tablenav
function extra_tablenav($which)
{
global $post_type_object, $cat;
$term_id = 0;
?>
<div class="alignleft actions"> <?php
if ('top' == $which && !is_singular()) {
$this->months_dropdown(self::$post_type);
if (is_object_in_taxonomy(self::$post_type, SI_Record::TAXONOMY)) {
$term_id = isset($_GET[SI_Record::TAXONOMY]) ? $_GET[SI_Record::TAXONOMY] : 0;
$dropdown_options = array('taxonomy' => SI_Record::TAXONOMY, 'show_option_all' => __('View all types'), 'hide_empty' => 0, 'hierarchical' => 1, 'show_count' => 0, 'orderby' => 'name', 'selected' => $term_id, 'name' => SI_Record::TAXONOMY);
wp_dropdown_categories($dropdown_options);
}
do_action('restrict_manage_posts');
submit_button(__('Filter'), 'secondary', false, false, array('id' => 'post-query-submit'));
// Purge
if (count($this->items) > 0) {
if (isset($_GET[SI_Record::TAXONOMY]) && $_GET[SI_Record::TAXONOMY]) {
$term = get_term($_GET[SI_Record::TAXONOMY], SI_Record::TAXONOMY);
$button_label = __('Purge') . ' ' . $term->name . ' ' . __('Type');
}
$button_label = isset($button_label) ? $button_label : __('Purge All Types');
printf('<button type="submit" name="purge_records" class="button" value="%s">%s</button>', $term_id, $button_label);
printf('<input type="hidden" name="%s" value="%s" />', SI_Internal_Records::RECORD_PURGE_NONCE, wp_create_nonce(SI_Internal_Records::RECORD_PURGE_NONCE));
}
}
?>
</div> <?php
}
示例4: sfhiv_draw_taxonomy_query_menu
function sfhiv_draw_taxonomy_query_menu($tax_name, $query, $args = array())
{
if (!is_object_in_taxonomy($query->query_vars['post_type'], $tax_name)) {
return;
}
if (!isset($args['include'])) {
$query = sfhiv_remove_url_vars_from_query($query, array($tax_name));
$query = sfhiv_unpage_query($query);
$categories = sfhiv_get_taxonomy_in($query, $tax_name, 'ids');
$args['include'] = implode(",", $categories);
if (!isset($args['min_display'])) {
$args['min_display'] = 2;
}
if (count($categories) < $args['min_display']) {
return;
}
}
if (!isset($args['base_link'])) {
if (is_page() && mini_archive_on_page(get_the_ID())) {
$args['base_link'] = get_permalink();
} else {
$args['base_link'] = get_post_type_archive_link($query->query_vars['post_type']);
}
}
if (!isset($args['title_li'])) {
$taxonomies = get_taxonomies(array('name' => $tax_name), 'objects');
foreach ($taxonomies as $taxonomy) {
$args['title_li'] = $taxonomy->label;
}
}
$args = array_merge(array('taxonomy' => $tax_name, 'show_all_link' => true), $args);
sfhiv_draw_taxonomy_menu($args);
}
示例5: twentyten_posted_in
function twentyten_posted_in()
{
// Retrieves tag list of current post, separated by commas.
$tag_list = get_the_tag_list('', ', ');
$temp_tag_array = explode(', ', $tag_list);
$buf_tag_list = array();
foreach ($temp_tag_array as $temp_tag) {
if (strpos($temp_tag, "html") > 0) {
$buf_tag_list[] = '<div class="html">' . $temp_tag . '</div>';
} elseif (strpos($temp_tag, "css") > 0) {
$buf_tag_list[] = '<div class="css">' . $temp_tag . '</div>';
} elseif (strpos($temp_tag, "jquery") > 0) {
$buf_tag_list[] = '<div class="jquery">' . $temp_tag . '</div>';
} elseif (strpos($temp_tag, "Javascript") > 0) {
$buf_tag_list[] = '<div class="Javascript">' . $temp_tag . '</div>';
} elseif (strpos($temp_tag, "wordpress") > 0) {
$buf_tag_list[] = '<div class="wordpress">' . $temp_tag . '</div>';
} else {
$buf_tag_list[] = $temp_tag;
}
}
$tag_list = implode(', ', $buf_tag_list);
if ($tag_list) {
$posted_in = __('This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten');
} elseif (is_object_in_taxonomy(get_post_type(), 'category')) {
$posted_in = __('This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten');
} else {
$posted_in = __('Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'twentyten');
}
// Prints the string, replacing the placeholders.
printf($posted_in, get_the_category_list(', '), $tag_list, get_permalink(), the_title_attribute('echo=0'));
}
示例6: iron_post_class_terms
function iron_post_class_terms($classes = array())
{
global $post, $iron_taxonomies;
/*
// Tags
if ( is_object_in_taxonomy( $post->post_type, 'post_tag' ) ) {
foreach ( (array) get_the_tags($post->ID) as $tag ) {
if ( empty($tag->slug ) )
continue;
$classes[] = 'tag-' . sanitize_html_class($tag->slug, $tag->term_id);
}
}
*/
global $post;
foreach ($iron_taxonomies as $tax) {
if (is_object_in_taxonomy($post->post_type, $tax)) {
$terms = get_the_terms($post->ID, $tax);
foreach ((array) $terms as $term) {
if (empty($term->slug)) {
continue;
}
$classes[] = sanitize_html_class($tax, 'tax') . '-' . sanitize_html_class($term->slug, $term->term_id);
}
# Alternate
// $terms = wp_list_pluck($terms, 'slug');
// $classes = array_merge($classes, $terms);
}
}
return $classes;
}
示例7: zm_base_posted_in
function zm_base_posted_in()
{
// Retrieves tag list of current post, separated by commas.
$tag_list = get_the_tag_list('', ', ');
if ($tag_list) {
$posted_in = __('<span class="zm-base-posted-in"> Posted in %1$s </span> Tags %2$s', 'collection');
} elseif (is_object_in_taxonomy(get_post_type(), 'category')) {
$posted_in = __('<span class="zm-base-posted-in"> Posted in %1$s </span> ', 'collection');
} else {
$posted_in = null;
}
// Prints the string, replacing the placeholders.
printf($posted_in, get_the_category_list(', '), $tag_list, get_the_category_list(', '));
}
示例8: theme_posted_in
/**
* Prints HTML with meta information for the current post (category, tags and permalink).
*
* @since Twenty Ten 1.0
*/
function theme_posted_in()
{
// Retrieves tag list of current post, separated by commas.
$tag_list = get_the_tag_list('', ', ');
if ($tag_list) {
$posted_in = __('This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'wpdance');
} elseif (is_object_in_taxonomy(get_post_type(), 'category')) {
$posted_in = __('This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'wpdance');
} else {
$posted_in = __('Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'wpdance');
}
// Prints the string, replacing the placeholders.
printf($posted_in, get_the_category_list(', '), $tag_list, get_permalink(), the_title_attribute('echo=0'));
}
示例9: teamtheme_posted_in
/**
* Prints HTML with meta information for the current post (category, tags and permalink).
*
* @since 1.0
*/
function teamtheme_posted_in()
{
// Retrieves tag list of current post, separated by commas.
$tag_list = get_the_tag_list('', ', ');
if ($tag_list) {
$posted_in = __('This entry was posted in %1$s and tagged %2$s. ', 'twentyten');
} elseif (is_object_in_taxonomy(get_post_type(), 'category')) {
$posted_in = __('This entry was posted in %1$s.', 'twentyten');
} else {
$posted_in = __('', 'twentyten');
}
// Prints the string, replacing the placeholders.
printf($posted_in, get_the_category_list(', '), $tag_list, the_title_attribute('echo=0'));
}
示例10: wp_rest_api_add_taxonomies
function wp_rest_api_add_taxonomies()
{
$post_types = get_post_types(array('public' => true), 'objects');
foreach ($post_types as $post_type) {
$show_in_rest = isset($post_type->show_in_rest) && $post_type->show_in_rest ? true : false;
if ($show_in_rest) {
$taxonomies = get_taxonomies(array(), "objects");
foreach ($taxonomies as $taxonomy) {
if (is_object_in_taxonomy($post_type->name, $taxonomy->name)) {
register_api_field($post_type->name, $taxonomy->name, array('get_callback' => array($this, 'wp_rest_api_register_taxonomy'), 'schema' => null));
}
}
}
}
}
示例11: register_table_filter_query_vars
/**
* This filter registers the necessary query variables in WP_Query to detect whether we should filter by them.
*
* @since 0.6.1
* @param array $vars array of original query vars
* @return array the query vars array including the new ones
*/
public function register_table_filter_query_vars($vars)
{
$table_columns = $this->component->table_columns;
foreach ($table_columns as $column_slug => $column_args) {
if (is_array($column_args) && $column_args['filterable']) {
if (isset($column_args['taxonomy_slug']) && !empty($column_args['taxonomy_slug'])) {
if ('category' !== $column_args['taxonomy_slug'] && is_object_in_taxonomy($this->component->slug, $column_args['taxonomy_slug'])) {
$vars[] = $column_slug;
}
} elseif (isset($column_args['meta_key']) && !empty($column_args['meta_key'])) {
$vars[] = $column_slug;
}
}
}
return $vars;
}
示例12: tx_folio_term
function tx_folio_term($taxonomy)
{
global $post;
$folio_categories = array();
$folio_cats = "";
$tax_seperator = "";
if (is_object_in_taxonomy($post->post_type, $taxonomy)) {
foreach ((array) wp_get_post_terms($post->ID, $taxonomy) as $term) {
if (empty($term->name)) {
continue;
}
$folio_cats .= $tax_seperator . $term->name;
$tax_seperator = ', ';
}
}
return $folio_cats;
}
示例13: test_register_taxonomy_for_object_type
function test_register_taxonomy_for_object_type()
{
global $wp_taxonomies;
register_post_type('bar');
register_taxonomy_for_object_type('post_tag', 'bar');
$this->assertEquals(array('post_tag'), get_object_taxonomies('bar'));
register_taxonomy_for_object_type('category', 'bar');
$this->assertEquals(array('category', 'post_tag'), get_object_taxonomies('bar'));
$this->assertTrue(is_object_in_taxonomy('bar', 'post_tag'));
$this->assertTrue(is_object_in_taxonomy('bar', 'post_tag'));
// Clean up. Remove the 'bar' post type from these taxonomies.
$GLOBALS['wp_taxonomies']['post_tag']->object_type = array('post');
$GLOBALS['wp_taxonomies']['category']->object_type = array('post');
$this->assertFalse(is_object_in_taxonomy('bar', 'post_tag'));
$this->assertFalse(is_object_in_taxonomy('bar', 'post_tag'));
_unregister_post_type('bar');
}
示例14: wp_event_calendar_add_dropdown_filters
/**
* Output dropdowns & filters
*
* @since 0.1.2
*/
function wp_event_calendar_add_dropdown_filters($post_type = '')
{
// Bail if not the event post type
if ('event' !== $post_type) {
return;
}
// Bail if event type taxonomy was unregistered
if (!is_object_in_taxonomy('event', 'event-type')) {
return;
}
// Get registered taxonomies
$taxonomies = get_object_taxonomies('event', 'objects');
// Loop through query vars
foreach ($taxonomies as $taxonomy) {
// Is this taxonomy being queried?
$selected = isset($_GET[$taxonomy->query_var]) ? sanitize_key($_GET[$taxonomy->query_var]) : '';
// Output lable & dropdown
echo '<label class="screen-reader-text" for="event-type">' . sprintf(__('Filter by %s', 'wp-event-calendar'), strtolower($taxonomy->labels->singular_name)) . '</label>';
wp_dropdown_categories(array('show_option_none' => $taxonomy->labels->all_items, 'option_none_value' => 0, 'hide_empty' => true, 'hierarchical' => false, 'taxonomy' => $taxonomy->name, 'show_count' => 0, 'orderby' => 'name', 'name' => $taxonomy->query_var, 'selected' => $selected));
}
}
示例15: __wcb_post_single_meta
function __wcb_post_single_meta($meta)
{
if (get_post_type() != 'post' || !is_single()) {
return $meta;
}
if (is_object_in_taxonomy(get_post_type(), 'category')) {
$meta['category'] = sprintf(__('Posted in %s', 'wordcampbase'), get_the_category_list(', '));
}
if (is_object_in_taxonomy(get_post_type(), 'tag')) {
$meta['tag'] = sprintf(__('Tagged %s', 'wordcampbase'), get_the_tag_list('', ', '));
}
$meta['order'][] = 'br';
if (isset($meta['category']) && isset($meta['tag'])) {
array_push($meta['order'], 'category', 'sep', 'tag');
} elseif (isset($meta['category'])) {
$meta['order'][] = 'category';
} elseif (isset($meta['tag'])) {
$meta['order'][] = 'tag';
} else {
array_pop($meta['order']);
}
return $meta;
}