当前位置: 首页>>代码示例>>PHP>>正文


PHP unregister_taxonomy_for_object_type函数代码示例

本文整理汇总了PHP中unregister_taxonomy_for_object_type函数的典型用法代码示例。如果您正苦于以下问题:PHP unregister_taxonomy_for_object_type函数的具体用法?PHP unregister_taxonomy_for_object_type怎么用?PHP unregister_taxonomy_for_object_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了unregister_taxonomy_for_object_type函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onInit

 public static function onInit()
 {
     if (!empty(static::$_to_unregister)) {
         foreach (static::$_to_unregister as $taxonomy) {
             global $wp_taxonomies;
             if (static::exists($taxonomy)) {
                 unset($wp_taxonomies[$taxonomy]);
             }
         }
     }
     if (!empty(static::$_to_register)) {
         foreach (static::$_to_register as $taxonomy => $option) {
             register_taxonomy($taxonomy, $option['object_type'], $option['args']);
         }
     }
     if (!empty(static::$_to_unregister_to_post_type)) {
         foreach (static::$_to_unregister_to_post_type as $taxonomy => $post_types) {
             foreach ($post_types as $post_type) {
                 unregister_taxonomy_for_object_type($taxonomy, $post_type);
             }
         }
     }
     if (!empty(static::$_to_register_to_post_type)) {
         foreach (static::$_to_register_to_post_type as $taxonomy => $post_types) {
             foreach ($post_types as $post_type) {
                 register_taxonomy_for_object_type($taxonomy, $post_type);
             }
         }
     }
 }
开发者ID:daidais,项目名称:morepress,代码行数:30,代码来源:Taxonomy.php

示例2: wpcf_taxonomies_register

/**
 * Handle builtin taxonomies
 *
 * Function add or remove taxonomy to post type
 *
 * @since 1.9.0
 *
 * @param string $taxonomy taxonomy slug/name
 * @param array $data taxonomy configuration
 *
 */
function wpcf_taxonomies_register($taxonomy, $data)
{
    // check which types are supported
    if (isset($data['supports']) && is_array($data['supports'])) {
        if (!empty($data['supports'])) {
            foreach (array_keys($data['supports']) as $post_type) {
                register_taxonomy_for_object_type($taxonomy, $post_type);
            }
        }
        // check for inbuilt Tags (post_tag) and Categories if post is not supported,
        // so it needs to get unregistered
        if (($data['slug'] == 'post_tag' || $data['slug'] == 'category') && !array_key_exists('post', $data['supports'])) {
            unregister_taxonomy_for_object_type($taxonomy, 'post');
        }
    }
    // this is only left for backwards compatibility
    if (isset($data['disabled_post_types']) && is_array($data['disabled_post_types'])) {
        foreach (array_keys($data['disabled_post_types']) as $post_type) {
            unregister_taxonomy_for_object_type($taxonomy, $post_type);
        }
    }
    // unregister
    if (isset($data['disabled']) && $data['disabled']) {
        register_taxonomy($data['slug'], array());
        // hide
    } else {
        if (isset($data['public']) && strval($data['public']) == 'hidden') {
            global $wp_taxonomies;
            $wp_taxonomies[$data['slug']]->public = false;
            $wp_taxonomies[$data['slug']]->show_ui = false;
            $wp_taxonomies[$data['slug']]->show_in_menu = false;
        }
    }
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:45,代码来源:custom-taxonomies.php

示例3: setup_post_types

/**
 * Register custom post types: Place, Event
 */
function setup_post_types()
{
    register_post_type('place', array('label' => 'Place', 'description' => 'Represents physical address or Internet resource', 'labels' => array('name' => 'Places', 'singular_name' => 'Place', 'menu_name' => 'Places', 'name_admin_bar' => 'Place', 'all_items' => 'All Places', 'add_new_item' => 'Add New Place', 'new_item' => 'New Place', 'edit_item' => 'Edit Place', 'update_item' => 'Update Place', 'view_item' => 'View Place', 'search_items' => 'Search Places'), 'taxonomies' => array('post_tag'), 'supports' => array('title', 'editor', 'author', 'thumbnail', 'revisions'), 'public' => true, 'menu_position' => 5, 'menu_icon' => 'dashicons-location-alt'));
    register_post_type('event', array('label' => 'Event', 'description' => 'Represents public event', 'labels' => array('name' => 'Events', 'singular_name' => 'Event', 'menu_name' => 'Events', 'name_admin_bar' => 'Event', 'all_items' => 'All Events', 'add_new_item' => 'Add New Event', 'new_item' => 'New Event', 'edit_item' => 'Edit Event', 'update_item' => 'Update Event', 'view_item' => 'View Event', 'search_items' => 'Search Events'), 'taxonomies' => array('post_tag'), 'supports' => array('title', 'editor', 'author', 'thumbnail', 'revisions'), 'public' => true, 'menu_position' => 5, 'menu_icon' => 'dashicons-calendar-alt'));
    /**
     * Setup Hromada post types filter
     */
    add_filter('hromada_post_types', function (array $post_types) {
        $post_types[] = 'post';
        $post_types[] = 'place';
        $post_types[] = 'event';
        $post_types[] = 'page';
        return $post_types;
    });
    /**
     * Customize post and page features
     */
    $remove_features = array('excerpt', 'trackbacks', 'custom-fields', 'comments', 'page-attributes', 'post-formats');
    foreach ($remove_features as $feature) {
        remove_post_type_support('post', $feature);
    }
    unregister_taxonomy_for_object_type('category', 'post');
    $remove_features = array('author', 'page-attributes', 'custom-fields', 'comments');
    foreach ($remove_features as $feature) {
        remove_post_type_support('page', $feature);
    }
}
开发者ID:roman-kulish,项目名称:hromada-wordpress-authoring,代码行数:30,代码来源:authoring.php

示例4: modify_object_type

 /**
  * Modify "Post" Object Type
  *
  * Rename labels, disable comments, and enable archive.
  */
 public function modify_object_type()
 {
     _x('news', 'URI slug', 'boilerplate');
     $this->obj_page = 'page' === get_option('show_on_front') ? get_option('page_for_posts') : false;
     $this->set_rewrite_slug('news');
     unregister_taxonomy_for_object_type('post_tag', 'post');
     remove_post_type_support($this->obj_type, 'comments');
     remove_post_type_support($this->obj_type, 'custom-fields');
     $object = get_post_type_object($this->obj_type);
     $labels =& $object->labels;
     $labels->name = __('News', 'boilerplate');
     $labels->menu_name = __('News', 'boilerplate');
     $labels->name_admin_bar = __('News', 'boilerplate');
     $labels->singular_name = __('Article', 'boilerplate');
     $labels->search_items = __('Search Articles', 'boilerplate');
     $labels->all_items = __('All Articles', 'boilerplate');
     if ($this->obj_page) {
         $object->has_archive = true;
     }
     /*
             if ( $this->rewrite_slug ) {
                 $object->rewrite['slug'] = $this->rewrite_slug;
             }
     */
     register_post_type($this->obj_type, $object);
 }
开发者ID:locomotivemtl,项目名称:wordpress-boilerplate,代码行数:31,代码来源:post.php

示例5: scoutwp_init

/**
 * Theme init hook.
 * Removes emoticons, comments, post tags and default jquery.
 * Registers javascript and css files and adds post format support, html 5 support and thumbnails.
 * @return null
 */
function scoutwp_init()
{
    // disable emojis
    remove_action('wp_head', 'print_emoji_detection_script', 7);
    remove_action('admin_print_scripts', 'print_emoji_detection_script');
    remove_action('wp_print_styles', 'print_emoji_styles');
    remove_action('admin_print_styles', 'print_emoji_styles');
    remove_filter('the_content_feed', 'wp_staticize_emoji');
    remove_filter('comment_text_rss', 'wp_staticize_emoji');
    remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
    add_filter('tiny_mce_plugins', 'disable_emojis_tinymce');
    // remove comments
    remove_post_type_support('post', 'comments');
    remove_post_type_support('page', 'comments');
    // remove Tags
    unregister_taxonomy_for_object_type('post_tag', 'post');
    // deregister jquery
    wp_deregister_script('jquery');
    // register js scripts
    // Must be before any other jquery
    wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js', array(), null, true);
    wp_register_script('scoutwp-theme', get_stylesheet_directory_uri() . '/js/script.min.js', array(), null, true);
    wp_register_script('unslider', get_stylesheet_directory_uri() . '/js/unslider.min.js', array(), null, true);
    // register css
    wp_register_style('scoutwp-theme', get_template_directory_uri() . '/css/style.min.css', array(), null);
    wp_register_style('scoutwp-icons', get_template_directory_uri() . '/icons/css/sp-icon-font.css', array(), null);
    wp_register_style('scoutwp-fonts', 'http://fonts.googleapis.com/css?family=Bitter:700|Open+Sans:400,400italic,600', array(), null);
    // add post format support
    add_theme_support('post-formats', array('aside', 'image', 'video', 'quote', 'link', 'gallery'));
    // add html 5 support
    add_theme_support('html5', array('gallery'));
    // add thumbnail support
    add_theme_support('post-thumbnails');
}
开发者ID:ajgamble-milner,项目名称:scoutwp_theme,代码行数:40,代码来源:functions.php

示例6: starter_cpt_init

function starter_cpt_init()
{
    /* add new post type
    	register_post_type('news', array(
    		'labels' => array(
    			'name' 				=> 'Articles',
    			'menu_name'			=> 'News',
    			'sungular_name'		=> 'News Post',
    			'add_new_item'     	=> 'Add News Post',
    			'edit_item'			=> 'Edit News Post',
    			'view_item'			=> 'View News Post'
    		),
    		'supports'      		=> array('title', 'editor', 'thumbnail', 'excerpt'),
    		'public'				=> true,
    		'has_archive' 			=> true,
    		'rewrite' 				=> array('slug' => 'news'),
    		//'menu_position'		=> 21,
    		'publicly_queryable'	=> true,
    	));
    	*/
    // remove unused functionality from pages
    remove_post_type_support('page', 'comments');
    unregister_taxonomy_for_object_type('post_tag', 'post');
    // remove unused functionality from posts
    // remove_post_type_support('post', 'tags');
    // add excerpts to pages (e.g. page summaries to be used on page lists)
    add_post_type_support('page', 'excerpt');
}
开发者ID:GaryJones,项目名称:Starter-WP,代码行数:28,代码来源:post-types.php

示例7: wpuxss_eml_on_wp_loaded

function wpuxss_eml_on_wp_loaded()
{
    $wpuxss_eml_taxonomies = get_option('wpuxss_eml_taxonomies');
    if (empty($wpuxss_eml_taxonomies)) {
        $wpuxss_eml_taxonomies = array();
    }
    $taxonomies = get_taxonomies(array(), 'object');
    // discover 'foreign' taxonomies
    foreach ($taxonomies as $taxonomy => $params) {
        if (!empty($params->object_type) && !array_key_exists($taxonomy, $wpuxss_eml_taxonomies) && !in_array('revision', $params->object_type) && !in_array('nav_menu_item', $params->object_type) && $taxonomy != 'post_format') {
            $wpuxss_eml_taxonomies[$taxonomy] = array('eml_media' => 0, 'admin_filter' => 0, 'media_uploader_filter' => 0, 'show_admin_column' => isset($params->show_admin_column) ? $params->show_admin_column : 0, 'show_in_nav_menus' => isset($params->show_in_nav_menus) ? $params->show_in_nav_menus : 0, 'hierarchical' => $params->hierarchical ? 1 : 0, 'sort' => isset($params->sort) ? $params->sort : 0);
            if (in_array('attachment', $params->object_type)) {
                $wpuxss_eml_taxonomies[$taxonomy]['assigned'] = 1;
            } else {
                $wpuxss_eml_taxonomies[$taxonomy]['assigned'] = 0;
            }
        }
    }
    // assign/unassign taxonomies to atachment
    foreach ($wpuxss_eml_taxonomies as $taxonomy => $params) {
        if ($params['assigned']) {
            register_taxonomy_for_object_type($taxonomy, 'attachment');
        }
        if (!$params['assigned']) {
            unregister_taxonomy_for_object_type($taxonomy, 'attachment');
        }
    }
    // update_count_callback for attachment taxonomies if needed
    foreach ($taxonomies as $taxonomy => $params) {
        if (in_array('attachment', $params->object_type)) {
            global $wp_taxonomies;
            if (!isset($wp_taxonomies[$taxonomy]->update_count_callback) || empty($wp_taxonomies[$taxonomy]->update_count_callback)) {
                $wp_taxonomies[$taxonomy]->update_count_callback = '_update_generic_term_count';
            }
        }
    }
    update_option('wpuxss_eml_taxonomies', $wpuxss_eml_taxonomies);
}
开发者ID:coollog,项目名称:theboola,代码行数:38,代码来源:enhanced-media-library.php

示例8: test_registering_taxonomies_to_object_types

 /**
  * @ticket 11058
  */
 function test_registering_taxonomies_to_object_types()
 {
     // Create a taxonomy to test with
     $tax = 'test_tax';
     $this->assertFalse(taxonomy_exists($tax));
     register_taxonomy($tax, 'post', array('hierarchical' => true));
     // Create a post type to test with
     $post_type = 'test_cpt';
     $this->assertFalse(get_post_type($post_type));
     $this->assertObjectHasAttribute('name', register_post_type($post_type));
     // Core taxonomy, core post type
     $this->assertTrue(unregister_taxonomy_for_object_type('category', 'post'));
     $this->assertFalse(unregister_taxonomy_for_object_type('category', 'post'));
     $this->assertTrue(register_taxonomy_for_object_type('category', 'post'));
     // Core taxonomy, non-core post type
     $this->assertTrue(register_taxonomy_for_object_type('category', $post_type));
     $this->assertTrue(unregister_taxonomy_for_object_type('category', $post_type));
     $this->assertFalse(unregister_taxonomy_for_object_type('category', $post_type));
     $this->assertTrue(register_taxonomy_for_object_type('category', $post_type));
     // Core taxonomies, non-post object types
     $this->assertFalse(register_taxonomy_for_object_type('category', 'user'));
     $this->assertFalse(unregister_taxonomy_for_object_type('category', 'user'));
     // Non-core taxonomy, core post type
     $this->assertTrue(unregister_taxonomy_for_object_type($tax, 'post'));
     $this->assertFalse(unregister_taxonomy_for_object_type($tax, 'post'));
     $this->assertTrue(register_taxonomy_for_object_type($tax, 'post'));
     // Non-core taxonomy, non-core post type
     $this->assertTrue(register_taxonomy_for_object_type($tax, $post_type));
     $this->assertTrue(unregister_taxonomy_for_object_type($tax, $post_type));
     $this->assertFalse(unregister_taxonomy_for_object_type($tax, $post_type));
     $this->assertTrue(register_taxonomy_for_object_type($tax, $post_type));
     // Non-core taxonomies, non-post object types
     $this->assertFalse(register_taxonomy_for_object_type($tax, 'user'));
     $this->assertFalse(unregister_taxonomy_for_object_type($tax, 'user'));
     unset($GLOBALS['wp_taxonomies'][$tax]);
     _unregister_post_type($post_type);
 }
开发者ID:Benrajalu,项目名称:philRaj,代码行数:40,代码来源:taxonomy.php

示例9: unregister_post_type

/**
 * Unregisters a post type.
 *
 * Can not be used to unregister built-in post types.
 *
 * @since 4.5.0
 *
 * @global WP_Rewrite $wp_rewrite             WordPress rewrite component.
 * @global WP         $wp                     Current WordPress environment instance.
 * @global array      $_wp_post_type_features Used to remove post type features.
 * @global array      $post_type_meta_caps    Used to remove meta capabilities.
 * @global array      $wp_post_types          List of post types.
 *
 * @param string $post_type Post type to unregister.
 * @return bool|WP_Error True on success, WP_Error on failure.
 */
function unregister_post_type($post_type)
{
    if (!post_type_exists($post_type)) {
        return new WP_Error('invalid_post_type', __('Invalid post type'));
    }
    $post_type_args = get_post_type_object($post_type);
    // Do not allow unregistering internal post types.
    if ($post_type_args->_builtin) {
        return new WP_Error('invalid_post_type', __('Unregistering a built-in post type is not allowed'));
    }
    global $wp, $wp_rewrite, $_wp_post_type_features, $post_type_meta_caps, $wp_post_types;
    // Remove query var.
    if (false !== $post_type_args->query_var) {
        $wp->remove_query_var($post_type_args->query_var);
    }
    // Remove any rewrite rules, permastructs, and rules.
    if (false !== $post_type_args->rewrite) {
        remove_rewrite_tag("%{$post_type}%");
        remove_permastruct($post_type);
        foreach ($wp_rewrite->extra_rules_top as $regex => $query) {
            if (false !== strpos($query, "index.php?post_type={$post_type}")) {
                unset($wp_rewrite->extra_rules_top[$regex]);
            }
        }
    }
    // Remove registered custom meta capabilities.
    foreach ($post_type_args->cap as $cap) {
        unset($post_type_meta_caps[$cap]);
    }
    // Remove all post type support.
    unset($_wp_post_type_features[$post_type]);
    // Unregister the post type meta box if a custom callback was specified.
    if ($post_type_args->register_meta_box_cb) {
        remove_action('add_meta_boxes_' . $post_type, $post_type_args->register_meta_box_cb);
    }
    // Remove the post type from all taxonomies.
    foreach (get_object_taxonomies($post_type) as $taxonomy) {
        unregister_taxonomy_for_object_type($taxonomy, $post_type);
    }
    // Remove the future post hook action.
    remove_action('future_' . $post_type, '_future_post_hook', 5);
    // Remove the post type.
    unset($wp_post_types[$post_type]);
    /**
     * Fires after a post type was unregistered.
     *
     * @since 4.5.0
     *
     * @param string $post_type Post type key.
     */
    do_action('unregistered_post_type', $post_type);
    return true;
}
开发者ID:akalipetis,项目名称:WordPress,代码行数:69,代码来源:post.php

示例10: wpuxss_eml_on_wp_loaded

 function wpuxss_eml_on_wp_loaded()
 {
     global $wp_taxonomies;
     $wpuxss_eml_taxonomies = get_option('wpuxss_eml_taxonomies', array());
     $taxonomies = get_taxonomies(array(), 'object');
     // discover 'foreign' taxonomies
     foreach ($taxonomies as $taxonomy => $params) {
         if (!empty($params->object_type) && !array_key_exists($taxonomy, $wpuxss_eml_taxonomies) && !in_array('revision', $params->object_type) && !in_array('nav_menu_item', $params->object_type) && $taxonomy !== 'post_format' && $taxonomy !== 'link_category') {
             $wpuxss_eml_taxonomies[$taxonomy] = array('eml_media' => 0, 'admin_filter' => 0, 'media_uploader_filter' => 0, 'media_popup_taxonomy_edit' => 0, 'taxonomy_auto_assign' => 0);
             if (in_array('attachment', $params->object_type)) {
                 $wpuxss_eml_taxonomies[$taxonomy]['assigned'] = 1;
             } else {
                 $wpuxss_eml_taxonomies[$taxonomy]['assigned'] = 0;
             }
         }
     }
     // assign/unassign taxonomies to atachment
     foreach ($wpuxss_eml_taxonomies as $taxonomy => $params) {
         if ($params['assigned']) {
             register_taxonomy_for_object_type($taxonomy, 'attachment');
         }
         if (!$params['assigned']) {
             unregister_taxonomy_for_object_type($taxonomy, 'attachment');
         }
     }
     /**
      *  Clean up update_count_callback
      *  Set custom update_count_callback for post type
      *
      *  @since 2.3
      */
     foreach ($taxonomies as $taxonomy => $params) {
         if (in_array('attachment', $params->object_type) && isset($wp_taxonomies[$taxonomy]->update_count_callback) && '_update_generic_term_count' === $wp_taxonomies[$taxonomy]->update_count_callback) {
             unset($wp_taxonomies[$taxonomy]->update_count_callback);
         }
         if (in_array('post', $params->object_type)) {
             if (in_array('attachment', $params->object_type)) {
                 $wp_taxonomies[$taxonomy]->update_count_callback = '_eml_update_post_term_count';
             } else {
                 unset($wp_taxonomies[$taxonomy]->update_count_callback);
             }
         }
     }
     update_option('wpuxss_eml_taxonomies', $wpuxss_eml_taxonomies);
 }
开发者ID:coreymargulis,项目名称:karenmargulis,代码行数:45,代码来源:enhanced-media-library.php

示例11: unregister_taxonomies

 /**
  * Removes the post type from all taxonomies.
  *
  * @since 4.6.0
  * @access public
  */
 public function unregister_taxonomies()
 {
     foreach (get_object_taxonomies($this->name) as $taxonomy) {
         unregister_taxonomy_for_object_type($taxonomy, $this->name);
     }
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:12,代码来源:class-wp-post-type.php

示例12: unregister

 /**
  * Unregisters the Taxonomy.
  *
  * @throws \RuntimeException If the Taxonomy cannot be unregistered.
  */
 public function unregister()
 {
     if (count($this->objectTypes) < 1) {
         return;
     }
     foreach ($this->objectTypes as $objectTypeName => $value) {
         if (!unregister_taxonomy_for_object_type($this->getName(), $objectTypeName)) {
             throw new RuntimeException('Cannot unregister the Taxonomy.');
         }
     }
 }
开发者ID:devaloka,项目名称:devaloka,代码行数:16,代码来源:TaxonomyTrait.php

示例13: myprefix_unregister_tags

function myprefix_unregister_tags()
{
    unregister_taxonomy_for_object_type('category', 'post');
}
开发者ID:synergia,项目名称:mknm-synergia-theme,代码行数:4,代码来源:utils.php

示例14: unregister

 /**
  * Unregisters the taxonomy for attachments.
  *
  * @since 1.0.0
  * @access public
  */
 public function unregister()
 {
     unregister_taxonomy_for_object_type($this->slug, 'attachment');
 }
开发者ID:felixarntz,项目名称:attachment-taxonomies,代码行数:10,代码来源:Existing_Taxonomy.php

示例15: so_unregister_taxonomy

function so_unregister_taxonomy()
{
    unregister_taxonomy_for_object_type('post_tag', 'post');
}
开发者ID:SpiritPixels,项目名称:Code-Snippets,代码行数:4,代码来源:remove-existing-taxonomy.php


注:本文中的unregister_taxonomy_for_object_type函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。