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


PHP remove_permastruct函数代码示例

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


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

示例1: test_remove_permastruct

 public function test_remove_permastruct()
 {
     global $wp_rewrite;
     add_permastruct('foo', 'bar/%foo%');
     $this->assertInternalType('array', $wp_rewrite->extra_permastructs['foo']);
     $this->assertSame('/bar/%foo%', $wp_rewrite->extra_permastructs['foo']['struct']);
     remove_permastruct('foo');
     $this->assertFalse(isset($wp_rewrite->extra_permastructs['foo']));
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:9,代码来源:permastructs.php

示例2: unregister_taxonomy

/**
 * Unregisters a taxonomy.
 *
 * Can not be used to unregister built-in taxonomies.
 *
 * @since 4.5.0
 *
 * @global WP    $wp            Current WordPress environment instance.
 * @global array $wp_taxonomies List of taxonomies.
 *
 * @param string $taxonomy Taxonomy name.
 * @return bool|WP_Error True on success, WP_Error on failure or if the taxonomy doesn't exist.
 */
function unregister_taxonomy($taxonomy)
{
    if (!taxonomy_exists($taxonomy)) {
        return new WP_Error('invalid_taxonomy', __('Invalid taxonomy.'));
    }
    $taxonomy_args = get_taxonomy($taxonomy);
    // Do not allow unregistering internal taxonomies.
    if ($taxonomy_args->_builtin) {
        return new WP_Error('invalid_taxonomy', __('Unregistering a built-in taxonomy is not allowed'));
    }
    global $wp, $wp_taxonomies;
    // Remove query var.
    if (false !== $taxonomy_args->query_var) {
        $wp->remove_query_var($taxonomy_args->query_var);
    }
    // Remove rewrite tags and permastructs.
    if (false !== $taxonomy_args->rewrite) {
        remove_rewrite_tag("%{$taxonomy}%");
        remove_permastruct($taxonomy);
    }
    // Unregister callback handling for meta box.
    remove_filter('wp_ajax_add-' . $taxonomy, '_wp_ajax_add_hierarchical_term');
    // Remove the taxonomy.
    unset($wp_taxonomies[$taxonomy]);
    /**
     * Fires after a taxonomy is unregistered.
     *
     * @since 4.5.0
     *
     * @param string $taxonomy Taxonomy name.
     */
    do_action('unregistered_taxonomy', $taxonomy);
    return true;
}
开发者ID:nicholasgriffintn,项目名称:WordPress,代码行数:47,代码来源:taxonomy.php

示例3: 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

示例4: remove_rewrite_rules

 /**
  * Removes any rewrite rules, permastructs, and rules for the post type.
  *
  * @since 4.6.0
  * @access public
  *
  * @global WP_Rewrite $wp_rewrite          WordPress rewrite component.
  * @global WP         $wp                  Current WordPress environment instance.
  * @global array      $post_type_meta_caps Used to remove meta capabilities.
  */
 public function remove_rewrite_rules()
 {
     global $wp, $wp_rewrite, $post_type_meta_caps;
     // Remove query var.
     if (false !== $this->query_var) {
         $wp->remove_query_var($this->query_var);
     }
     // Remove any rewrite rules, permastructs, and rules.
     if (false !== $this->rewrite) {
         remove_rewrite_tag("%{$this->name}%");
         remove_permastruct($this->name);
         foreach ($wp_rewrite->extra_rules_top as $regex => $query) {
             if (false !== strpos($query, "index.php?post_type={$this->name}")) {
                 unset($wp_rewrite->extra_rules_top[$regex]);
             }
         }
     }
     // Remove registered custom meta capabilities.
     foreach ($this->cap as $cap) {
         unset($post_type_meta_caps[$cap]);
     }
 }
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:32,代码来源:class-wp-post-type.php

示例5: remove_rewrite_rules

 /**
  * Removes any rewrite rules, permastructs, and rules for the taxonomy.
  *
  * @since 4.7.0
  * @access public
  *
  * @global WP $wp Current WordPress environment instance.
  */
 public function remove_rewrite_rules()
 {
     /* @var WP $wp */
     global $wp;
     // Remove query var.
     if (false !== $this->query_var) {
         $wp->remove_query_var($this->query_var);
     }
     // Remove rewrite tags and permastructs.
     if (false !== $this->rewrite) {
         remove_rewrite_tag("%{$this->name}%");
         remove_permastruct($this->name);
     }
 }
开发者ID:aaemnnosttv,项目名称:develop.git.wordpress.org,代码行数:22,代码来源:class-wp-taxonomy.php


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