本文整理汇总了PHP中wp_get_object_terms函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_object_terms函数的具体用法?PHP wp_get_object_terms怎么用?PHP wp_get_object_terms使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_get_object_terms函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: manage_screen_options_columns
function manage_screen_options_columns($column, $post_id)
{
global $post;
$chosen_client_id = get_post_meta($post_id, 'chosen_client', true);
switch ($column) {
case 'invnumber':
$invnumber = get_post_meta($post_id, 'invoice_serial_number', true);
echo "№ " . str_pad($invnumber, 10, "0", STR_PAD_LEFT);
break;
case 'company_name':
$company_name = get_post_meta($chosen_client_id, 'company_name', true);
if (empty($company_name)) {
echo __('Unknown');
} else {
echo __($company_name);
}
break;
case 'status':
$status = wp_get_object_terms($post_id, 'status');
if (empty($status)) {
echo __(' - ');
} else {
foreach ($status as $the_status) {
echo $the_status->name . " ";
}
}
default:
break;
}
}
开发者ID:kamena,项目名称:kdwp-invoice,代码行数:30,代码来源:custom_screen_options.php
示例2: prepare_items
public function prepare_items()
{
if (!empty($this->items)) {
return;
}
$per_page = $this->get_items_per_page('edit_wpsc-product-variations_per_page');
$per_page = apply_filters('edit_wpsc_product_variations_per_page', $per_page);
$this->args = array('post_type' => 'wpsc-product', 'orderby' => 'menu_order title', 'post_parent' => $this->product_id, 'post_status' => 'publish, inherit', 'numberposts' => -1, 'order' => "ASC", 'posts_per_page' => $per_page);
if (isset($_REQUEST['post_status'])) {
$this->args['post_status'] = $_REQUEST['post_status'];
}
if (isset($_REQUEST['s'])) {
$this->args['s'] = $_REQUEST['s'];
}
if (isset($_REQUEST['paged'])) {
$this->args['paged'] = $_REQUEST['paged'];
}
$query = new WP_Query($this->args);
$this->items = $query->posts;
$total_items = $query->found_posts;
$total_pages = $query->max_num_pages;
$this->set_pagination_args(array('total_items' => $total_items, 'total_pages' => $total_pages, 'per_page' => $per_page));
if (empty($this->items)) {
return;
}
$ids = wp_list_pluck($this->items, 'ID');
$object_terms = wp_get_object_terms($ids, 'wpsc-variation', array('fields' => 'all_with_object_id'));
foreach ($object_terms as $term) {
if (!array_key_exists($term->object_id, $this->object_terms_cache)) {
$this->object_terms_cache[$term->object_id] = array();
}
$this->object_terms_cache[$term->object_id][$term->parent] = $term->name;
}
}
开发者ID:VanessaGarcia-Freelance,项目名称:ButtonHut,代码行数:34,代码来源:product-variation-list-table.class.php
示例3: filter_content
public function filter_content($content)
{
// Get Templates
$templates = self::get_option('rwp_templates');
$terms = wp_get_object_terms(get_the_ID(), array_keys(get_taxonomies()));
$terms_keys = array();
foreach ($terms as $term) {
$terms_keys[$term->taxonomy][] = $term->term_id;
}
//self::pretty_print( $terms_keys );
foreach ($templates as $template) {
if (isset($template['template_auto_reviews']) && !empty($template['template_auto_reviews'])) {
if (is_singular($template['template_auto_reviews']) && is_main_query()) {
if (isset($template['template_exclude_terms'])) {
$to_exclude = false;
foreach ($template['template_exclude_terms'] as $id) {
$i = explode('-', $id);
if (in_array($i[1], $terms_keys[$i[0]])) {
$to_exclude = true;
break;
}
}
if ($to_exclude) {
continue;
}
}
$new_content = '[rwp-review id="-1" template="' . $template['template_id'] . '"]';
$content .= $new_content;
}
}
}
return $content;
}
开发者ID:jprdev,项目名称:S.J-Enterprise,代码行数:33,代码来源:class-reviewer.php
示例4: generate_tag_cloud
function generate_tag_cloud($post_type)
{
global $wpdb;
// database calls must be sensitive to multisite
$query = $wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type = %s", $post_type);
$attachment_ids = $wpdb->get_col($query);
$terms = wp_get_object_terms($attachment_ids, 'post_tag', array('orderby' => 'count', 'order' => 'DESC'));
$tags = array();
// limit to 45 tags
foreach ($terms as $term) {
$tags[$term->term_id] = $term;
if (count($tags) >= 45) {
break;
}
}
if (empty($tags)) {
die(__('No tags found!', THEMEDOMAIN));
}
if (is_wp_error($tags)) {
die($tags->get_error_message());
}
foreach ($tags as $key => $tag) {
$tags[$key]->link = '#';
$tags[$key]->id = $tag->term_id;
}
// We need raw tag names here, so don't filter the output
$return = wp_generate_tag_cloud($tags, array('filter' => 0));
if (empty($return)) {
die('0');
}
echo $return;
exit;
}
开发者ID:googlecode-mirror,项目名称:wpmu-demo,代码行数:33,代码来源:shiba-mlib-ajax.php
示例5: type_permalink
function type_permalink($permalink, $post_id, $leavename)
{
if (strpos($permalink, '%event_type%') === FALSE) {
return $permalink;
}
if (strpos($permalink, '%event_place%') === FALSE) {
return $permalink;
}
// Get post
$post = get_post($post_id);
if (!$post) {
return $permalink;
}
// Get taxonomy terms
$terms = wp_get_object_terms($post->ID, 'event_type');
if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) {
$taxonomy_slug = $terms[0]->slug;
} else {
$taxonomy_slug = 'no-type';
}
return str_replace('%event_type%', $taxonomy_slug, $permalink);
// Get taxonomy terms
$terms = wp_get_object_terms($post->ID, 'event_place');
if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) {
$taxonomy_slug = $terms[0]->slug;
} else {
$taxonomy_slug = 'no-place';
}
return str_replace('%event_place%', $taxonomy_slug, $permalink);
}
开发者ID:kReEsTaL,项目名称:uxrennes-wp-theme,代码行数:30,代码来源:cpt-events.php
示例6: widget
/**
* widget function.
*
* @see WP_Widget
* @access public
* @param array $args
* @param array $instance
* @return void
*/
function widget($args, $instance)
{
if ($this->get_cached_widget($args)) {
return;
}
if (!class_exists('WP_Job_Manager_Job_Tags')) {
return;
}
global $job_manager, $post;
extract($args);
$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
$icon = isset($instance['icon']) ? $instance['icon'] : null;
if ($icon) {
$before_title = sprintf($before_title, 'ion-' . $icon);
}
$tags = wp_get_object_terms($post->ID, 'job_listing_tag');
if (is_wp_error($tags) || empty($tags)) {
return;
}
ob_start();
echo $before_widget;
if ($title) {
echo $before_title . $title . $after_title;
}
do_action('listify_widget_job_listing_tags_before');
wp_terms_checklist($post->ID, array('taxonomy' => 'job_listing_tag', 'checked_ontop' => false, 'walker' => new Listify_Walker_Tags_Checklist()));
do_action('listify_widget_job_listing_tags_after');
echo $after_widget;
$content = ob_get_clean();
echo apply_filters($this->widget_id, $content);
$this->cache_widget($args, $content);
}
开发者ID:abdullahrahim,项目名称:shadighar,代码行数:41,代码来源:class-widget-job_listing-tags.php
示例7: convert
/**
* convert post data to an object with meta data
* @param object $post
* @return post object after convert
* - wp_error object if post invalid
* @author Dakachi
* @since 1.0
*/
public function convert($post)
{
$result = array();
$post = (array) $post;
/**
* convert need post data
*/
foreach ($this->convert as $key) {
if (isset($post[$key])) {
$result[$key] = $post[$key];
}
}
// generate post taxonomy
if (!empty($this->taxs)) {
foreach ($this->taxs as $name) {
$result[$name] = wp_get_object_terms($post['ID'], $name);
}
}
// generate meta data
if (!empty($this->meta)) {
foreach ($this->meta as $key) {
$result[$key] = get_post_meta($post['ID'], $key, true);
}
}
unset($result['post_password']);
$result['id'] = $post['ID'];
/**
* assign convert post to current post
*/
$this->current_post = apply_filters('ae_convert_post', (object) $result);
return $this->current_post;
}
开发者ID:callmeaatrey,项目名称:zap-query,代码行数:40,代码来源:class-ae-post.php
示例8: get_values_for_product
/**
* Retrieve the values that should be output for a particular product
* Takes into account store defaults, category defaults, and per-product
* settings
*
* @access public
* @param int $product_id The ID of the product to retrieve info for
* @param string $feed_format The feed format being generated
* @param boolean $defaults_only Whether to retrieve the
* store/category defaults only
* @return array The values for the product
*/
public function get_values_for_product($product_id = null, $feed_format = 'all', $defaults_only = false)
{
if (!$product_id) {
return false;
}
// Get Store defaults
$settings = $this->remove_blanks($this->settings['product_defaults']);
if ($feed_format != 'all') {
$settings = $this->remove_other_feeds($settings, $feed_format);
}
// Merge category settings
$categories = wp_get_object_terms($product_id, 'product_cat', array('fields' => 'ids'));
foreach ($categories as $category_id) {
$category_settings = $this->get_values_for_category($category_id);
$category_settings = $this->remove_blanks($category_settings);
if ($feed_format != 'all') {
$category_settings = $this->remove_other_feeds($category_settings, $feed_format);
}
if ($category_settings) {
$settings = array_merge($settings, $category_settings);
}
}
if ($defaults_only) {
return $settings;
}
// Merge product settings
$product_settings = get_post_meta($product_id, '_woocommerce_gpf_data', true);
if ($product_settings) {
$product_settings = $this->remove_blanks($product_settings);
$settings = array_merge($settings, $product_settings);
}
return $settings;
}
开发者ID:iplaydu,项目名称:Bob-Ellis-Shoes,代码行数:45,代码来源:woocommerce-gpf-common.php
示例9: export_csv
function export_csv()
{
global $simple_map, $sm_locations;
if (isset($_POST['sm-action']) && 'export-csv' == $_POST['sm-action']) {
// Grab locations
$content = array();
set_time_limit(0);
$location_offset = 0;
while ($locations = query_posts(array('post_status' => 'publish', 'post_type' => 'sm-location', 'posts_per_page' => 200, 'offset' => $location_offset))) {
// Include CSV library
require_once SIMPLEMAP_PATH . '/classes/parsecsv.lib.php';
$taxonomies = get_object_taxonomies('sm-location');
foreach ($locations as $key => $location) {
$location_offset++;
$location_data = array('name' => esc_attr($location->post_title), 'address' => esc_attr(get_post_meta($location->ID, 'location_address', true)), 'address2' => esc_attr(get_post_meta($location->ID, 'location_address2', true)), 'city' => esc_attr(get_post_meta($location->ID, 'location_city', true)), 'state' => esc_attr(get_post_meta($location->ID, 'location_state', true)), 'zip' => esc_attr(get_post_meta($location->ID, 'location_zip', true)), 'country' => esc_attr(get_post_meta($location->ID, 'location_country', true)), 'phone' => esc_attr(get_post_meta($location->ID, 'location_phone', true)), 'email' => esc_attr(get_post_meta($location->ID, 'location_email', true)), 'fax' => esc_attr(get_post_meta($location->ID, 'location_fax', true)), 'url' => esc_attr(get_post_meta($location->ID, 'location_url', true)), 'description' => esc_attr($location->post_content), 'special' => esc_attr(get_post_meta($location->ID, 'location_special', true)), 'lat' => esc_attr(get_post_meta($location->ID, 'location_lat', true)), 'lng' => esc_attr(get_post_meta($location->ID, 'location_lng', true)), 'dateUpdated' => esc_attr($location->post_modified));
foreach ($taxonomies as $tax) {
$term_value = '';
if ($terms = wp_get_object_terms($location->ID, $tax, array('fields' => 'names'))) {
$term_value = implode(',', $terms);
}
$location_data["tax_{$tax}"] = esc_attr($term_value);
}
$content[] = $location_data;
}
}
if (!empty($content)) {
$csv = new smParseCSV();
$csv->output(true, 'simplemap.csv', $content, array_keys(reset($content)));
die;
}
}
}
开发者ID:ugurbastan,项目名称:swe-574-group4,代码行数:32,代码来源:import-export.php
示例10: get_offer_categories
function get_offer_categories($post_id = null, $args = array())
{
if (null === $post_id) {
return get_terms('circleflip-offer-category');
}
return wp_get_object_terms($post_id, 'circleflip-offer-category', $args);
}
开发者ID:purgesoftwares,项目名称:purges,代码行数:7,代码来源:circle-flip-offer-functions.php
示例11: wpsc_variations
function wpsc_variations($product_id)
{
global $wpdb;
$product_terms = wp_get_object_terms($product_id, 'wpsc-variation');
$this->variation_groups = array();
$this->first_variations = array();
$this->all_associated_variations = array();
foreach ($product_terms as $product_term) {
if ($product_term->parent > 0) {
if (empty($this->all_associated_variations[$product_term->parent])) {
$this->all_associated_variations[$product_term->parent][0] = new stdClass();
$this->all_associated_variations[$product_term->parent][0]->term_id = 0;
$this->all_associated_variations[$product_term->parent][0]->name = '-- Escolha --';
}
$this->all_associated_variations[$product_term->parent][] = $product_term;
} else {
$this->variation_groups[] = $product_term;
}
}
foreach ((array) $this->variation_groups as $variation_group) {
$variation_id = $variation_group->term_id;
$this->first_variations[] = $this->all_associated_variations[$variation_id][0]->term_id;
}
$this->variation_group_count = count($this->variation_groups);
}
开发者ID:hornet9,项目名称:Morato,代码行数:25,代码来源:variations.class.php
示例12: test_function_post_created
/**
* Test that a post is created for the function.
*/
public function test_function_post_created()
{
$posts = get_posts(array('post_type' => $this->importer->post_type_function));
$this->assertCount(1, $posts);
$post = $posts[0];
// Check that the post attributes are correct.
$this->assertEquals('<p>This function is just here for tests. This is its longer description.</p>', $post->post_content);
$this->assertEquals('This is a function summary.', $post->post_excerpt);
$this->assertEquals('wp_parser_test_func', $post->post_name);
$this->assertEquals(0, $post->post_parent);
$this->assertEquals('wp_parser_test_func', $post->post_title);
// It should be assigned to the file's taxonomy term.
$terms = wp_get_object_terms($post->ID, $this->importer->taxonomy_file);
$this->assertCount(1, $terms);
$this->assertEquals('file.inc', $terms[0]->name);
// It should be assigned to the correct @since taxonomy term.
$terms = wp_get_object_terms($post->ID, $this->importer->taxonomy_since_version);
$this->assertCount(1, $terms);
$this->assertEquals('1.4.0', $terms[0]->name);
// It should be assigned the correct @package taxonomy term.
$terms = wp_get_object_terms($post->ID, $this->importer->taxonomy_package);
$this->assertCount(1, $terms);
$this->assertEquals('Something', $terms[0]->name);
// Check that the metadata was imported.
$this->assertEquals(array(array('name' => '$var', 'default' => null, 'type' => ''), array('name' => '$ids', 'default' => 'array()', 'type' => 'array')), get_post_meta($post->ID, '_wp-parser_args', true));
$this->assertEquals(25, get_post_meta($post->ID, '_wp-parser_line_num', true));
$this->assertEquals(28, get_post_meta($post->ID, '_wp-parser_end_line_num', true));
$this->assertEquals(array(array('name' => 'since', 'content' => '1.4.0'), array('name' => 'param', 'content' => 'A string variable which is the first parameter.', 'types' => array('string'), 'variable' => '$var'), array('name' => 'param', 'content' => 'An array of user IDs.', 'types' => array('int[]'), 'variable' => '$ids'), array('name' => 'return', 'content' => 'The return type is random. (Not really.)', 'types' => array('mixed'))), get_post_meta($post->ID, '_wp-parser_tags', true));
}
开发者ID:lkwdwrd,项目名称:phpdoc-parser,代码行数:32,代码来源:file.php
示例13: live_blogs_for_entry_id
/**
* @param $entry_id
*
* @return LiveBlogging_LiveBlog|null
*/
public static function live_blogs_for_entry_id($entry_id)
{
foreach (wp_get_object_terms(array($entry_id), 'liveblog') as $liveblog_term) {
return new LiveBlogging_LiveBlog($liveblog_term);
}
return null;
}
开发者ID:ifreaker,项目名称:liveblogging,代码行数:12,代码来源:LiveBlogEntry.php
示例14: edd_dwqa_categories_save_post_download
function edd_dwqa_categories_save_post_download($post_ID, $post, $update)
{
global $wpdb;
$bundle = get_post_meta($post_ID, '_edd_product_type', true);
if ($bundle == 'bundle') {
return true;
}
$checked_terms = wp_get_object_terms($post_ID, 'download_category', array('fields' => 'ids'));
if (is_array($checked_terms) && !empty($checked_terms)) {
foreach ($checked_terms as $category) {
//check if product category is dwqa category also
$term_taxonomy_id = $wpdb->get_results($wpdb->prepare("SELECT term_taxonomy_id FROM " . $wpdb->prefix . "term_taxonomy WHERE term_id = %d AND taxonomy = 'dwqa-question_category' ", $category));
if ($term_taxonomy_id > 0) {
$post_object['parent'] = $category;
} else {
$post_object['parent'] = 0;
}
$post_object = array();
$post_object['action'] = 'add-tag';
$tag = wp_insert_term($post->post_title, 'dwqa-question_category', $post_object);
if (!is_wp_error($tag)) {
$wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "edd_dwqa_categories (id, dwqa_category_id, edd_product_id, edd_product_category_id) VALUES ('', %d, %d, '')", $tag['term_id'], $post_ID));
}
}
} else {
$post_object = array();
$post_object['action'] = 'add-tag';
$post_object['parent'] = 0;
$tag = wp_insert_term($post->post_title, 'dwqa-question_category', $post_object);
if (!is_wp_error($tag)) {
$wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "edd_dwqa_categories (id, dwqa_category_id, edd_product_id, edd_product_category_id) VALUES ('', %d, %d, '')", $tag['term_id'], $post_ID));
}
}
return true;
}
开发者ID:jomsocial,项目名称:eddDwqaCategories,代码行数:35,代码来源:edd_dwqa_categories.php
示例15: __construct
public function __construct($post = null)
{
if (!empty($post) && ($post = get_post($post))) {
$this->id = $post->ID;
$this->date = get_the_time(__('Y/m/d g:i:s A', 'flamingo'), $this->id);
$this->subject = get_post_meta($post->ID, '_subject', true);
$this->from = get_post_meta($post->ID, '_from', true);
$this->from_name = get_post_meta($post->ID, '_from_name', true);
$this->from_email = get_post_meta($post->ID, '_from_email', true);
$this->fields = get_post_meta($post->ID, '_fields', true);
foreach ($this->fields as $key => $value) {
$meta_key = sanitize_key('_field_' . $key);
if (metadata_exists('post', $post->ID, $meta_key)) {
$value = get_post_meta($post->ID, $meta_key, true);
$this->fields[$key] = $value;
}
}
$this->meta = get_post_meta($post->ID, '_meta', true);
$this->akismet = get_post_meta($post->ID, '_akismet', true);
$terms = wp_get_object_terms($this->id, self::channel_taxonomy);
if (!empty($terms) && !is_wp_error($terms)) {
$this->channel = $terms[0]->slug;
}
if (self::spam_status == get_post_status($post)) {
$this->spam = true;
} else {
$this->spam = !empty($this->akismet['spam']);
}
}
}
开发者ID:EcvetStep,项目名称:ecvet-step.eu,代码行数:30,代码来源:class-inbound-message.php
示例16: submit
/**
* Submit Step
*/
public function submit()
{
global $post;
$resume = get_post($this->resume_id);
if (empty($this->resume_id) || $resume->post_status !== 'publish' && $resume->post_status !== 'hidden') {
echo wpautop(__('Invalid resume', 'wp-job-manager-resumes'));
return;
}
$this->init_fields();
foreach ($this->fields as $group_key => $group_fields) {
foreach ($group_fields as $key => $field) {
if (!isset($this->fields[$group_key][$key]['value'])) {
if ('candidate_name' === $key) {
$this->fields[$group_key][$key]['value'] = $resume->post_title;
} elseif ('resume_content' === $key) {
$this->fields[$group_key][$key]['value'] = $resume->post_content;
} elseif (!empty($field['taxonomy'])) {
$this->fields[$group_key][$key]['value'] = wp_get_object_terms($resume->ID, $field['taxonomy'], array('fields' => 'ids'));
} elseif ('resume_skills' === $key) {
$this->fields[$group_key][$key]['value'] = implode(', ', wp_get_object_terms($resume->ID, 'resume_skill', array('fields' => 'names')));
} else {
$this->fields[$group_key][$key]['value'] = get_post_meta($resume->ID, '_' . $key, true);
}
}
}
}
$this->fields = apply_filters('submit_resume_form_fields_get_resume_data', $this->fields, $resume);
get_job_manager_template('resume-submit.php', array('class' => $this, 'form' => $this->form_name, 'job_id' => '', 'resume_id' => $this->get_resume_id(), 'action' => $this->get_action(), 'resume_fields' => $this->get_fields('resume_fields'), 'step' => $this->get_step(), 'submit_button_text' => __('Save changes', 'wp-job-manager-resumes')), 'wp-job-manager-resumes', RESUME_MANAGER_PLUGIN_DIR . '/templates/');
}
开发者ID:vinodhip,项目名称:Function-22-Website,代码行数:32,代码来源:class-wp-resume-manager-form-edit-resume.php
示例17: submit
/**
* Submit Step
*/
public function submit()
{
$job = get_post($this->job_id);
if (empty($this->job_id) || $job->post_status !== 'publish' && !job_manager_user_can_edit_pending_submissions()) {
echo wpautop(__('Invalid listing', 'wp-job-manager'));
return;
}
$this->init_fields();
foreach ($this->fields as $group_key => $group_fields) {
foreach ($group_fields as $key => $field) {
if (!isset($this->fields[$group_key][$key]['value'])) {
if ('job_title' === $key) {
$this->fields[$group_key][$key]['value'] = $job->post_title;
} elseif ('job_description' === $key) {
$this->fields[$group_key][$key]['value'] = $job->post_content;
} elseif ('company_logo' === $key) {
$this->fields[$group_key][$key]['value'] = has_post_thumbnail($job->ID) ? get_post_thumbnail_id($job->ID) : get_post_meta($job->ID, '_' . $key, true);
} elseif (!empty($field['taxonomy'])) {
$this->fields[$group_key][$key]['value'] = wp_get_object_terms($job->ID, $field['taxonomy'], array('fields' => 'ids'));
} else {
$this->fields[$group_key][$key]['value'] = get_post_meta($job->ID, '_' . $key, true);
}
}
}
}
$this->fields = apply_filters('submit_job_form_fields_get_job_data', $this->fields, $job);
wp_enqueue_script('wp-job-manager-job-submission');
get_job_manager_template('job-submit.php', array('form' => $this->form_name, 'job_id' => $this->get_job_id(), 'action' => $this->get_action(), 'job_fields' => $this->get_fields('job'), 'company_fields' => $this->get_fields('company'), 'step' => $this->get_step(), 'submit_button_text' => __('Save changes', 'wp-job-manager')));
}
开发者ID:durichitayat,项目名称:befolio-wp,代码行数:32,代码来源:class-wp-job-manager-form-edit-job.php
示例18: add_attachment_fields_to_edit
static function add_attachment_fields_to_edit($form_fields, $post)
{
$terms = get_object_term_cache($post->ID, self::TAXONOMY);
$field = array();
$taxonomy_obj = (array) get_taxonomy(self::TAXONOMY);
if (!$taxonomy_obj['public'] || !$taxonomy_obj['show_ui']) {
continue;
}
if (false === $terms) {
$terms = wp_get_object_terms($post->ID, self::TAXONOMY);
}
$values = wp_list_pluck($terms, 'term_id');
ob_start();
wp_terms_checklist($post->ID, array('taxonomy' => self::TAXONOMY, 'checked_ontop' => false, 'walker' => new Walker_WP_Media_Taxonomy_Checklist($post->ID)));
$output = ob_get_clean();
if (!empty($output)) {
$output = '<ul class="term-list">' . $output . '</ul>';
$output .= wp_nonce_field('save_attachment_media_categories', 'media_category_nonce', false, false);
} else {
$output = '<ul class="term-list"><li>No ' . $taxonomy_obj['label'] . '</li></ul>';
}
$field = array('label' => !empty($taxonomy_obj['label']) ? $taxonomy_obj['label'] : self::TAXONOMY, 'value' => join(', ', $values), 'show_in_edit' => false, 'input' => 'html', 'html' => $output);
$form_fields[self::TAXONOMY] = $field;
return $form_fields;
}
开发者ID:kevinlangleyjr,项目名称:wp-media-categories,代码行数:25,代码来源:wp-media-categories.php
示例19: synchronize_terms
/**
* @param int $original_post_id
* @param string $lang
* @param bool $duplicate sets whether missing terms should be created by duplicating the original term
*/
private function synchronize_terms($original_post_id, $lang, $duplicate)
{
global $wpml_post_translations;
$wpml_post_translations->reload();
$translated_post_id = $wpml_post_translations->element_id_in($original_post_id, $lang);
if ((bool) $translated_post_id === true) {
$taxonomies = get_post_taxonomies($original_post_id);
foreach ($taxonomies as $tax) {
$terms_on_original = wp_get_object_terms($original_post_id, $tax);
if (!$this->sitepress->is_translated_taxonomy($tax)) {
if ($this->sitepress->get_setting('sync_post_taxonomies')) {
// Taxonomy is not translated so we can just copy from the original
foreach ($terms_on_original as $key => $term) {
$terms_on_original[$key] = $term->term_id;
}
wp_set_object_terms($translated_post_id, $terms_on_original, $tax);
}
} else {
/** @var int[] $translated_terms translated term_ids */
$translated_terms = $this->get_translated_term_ids($terms_on_original, $lang, $tax, $duplicate);
wp_set_object_terms($translated_post_id, $translated_terms, $tax);
}
}
}
clean_object_term_cache($original_post_id, get_post_type($original_post_id));
}
开发者ID:aarongillett,项目名称:B22-151217,代码行数:31,代码来源:wpml-term-translation-utils.class.php
示例20: load_value
function load_value($value, $post_id, $field)
{
// get valid terms
$value = acf_get_valid_terms($value, $field['taxonomy']);
// load/save
if ($field['load_save_terms']) {
// bail early if no value
if (empty($value)) {
return $value;
}
// get current ID's
$term_ids = wp_get_object_terms($post_id, $field['taxonomy'], array('fields' => 'ids', 'orderby' => 'none'));
// case
if (empty($term_ids)) {
// 1. no terms for this post
return null;
} elseif (is_array($value)) {
// 2. remove metadata terms which are no longer for this post
$value = array_map('intval', $value);
$value = array_intersect($value, $term_ids);
} elseif (!in_array($value, $term_ids)) {
// 3. term is no longer for this post
return null;
}
}
// return
return $value;
}
开发者ID:Didox,项目名称:beminfinito,代码行数:28,代码来源:taxonomy.php
注:本文中的wp_get_object_terms函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论