Beispiel #1
0
 /**
  * Unregister existing post types and register defaults.
  *
  * Run before each test in order to clean up the global scope, in case
  * a test forgets to unregister a post type on its own, or fails before
  * it has a chance to do so.
  */
 protected function reset_post_types()
 {
     foreach (get_post_types() as $pt) {
         _unregister_post_type($pt);
     }
     create_initial_post_types();
 }
 function setUp()
 {
     global $wp_rewrite;
     parent::setUp();
     $wp_rewrite->init();
     $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/');
     $this->assertNotEmpty($wp_rewrite->wp_rewrite_rules());
     create_initial_post_types();
     create_initial_taxonomies();
     // Force the install/upgrade routines for each Babble class to run (ugh)
     remove_action('admin_init', '_maybe_update_core');
     remove_action('admin_init', '_maybe_update_plugins');
     remove_action('admin_init', '_maybe_update_themes');
     do_action('admin_init');
 }
 function callback($path = '', $blog_id = 0)
 {
     $blog_id = $this->api->switch_to_blog_and_validate_user($this->api->get_blog_id($blog_id));
     if (is_wp_error($blog_id)) {
         return $blog_id;
     }
     if (defined('IS_WPCOM') && IS_WPCOM) {
         $this->load_theme_functions();
     }
     $args = $this->query_args();
     /**
      * Whether API responses should be returned in a custom locale.  False
      * for Jetpack; may be true for WP.com requests.
      *
      * @since 3.9.2
      */
     if (apply_filters('rest_api_localize_response', false)) {
         // API localization occurs after the initial post types have been
         // registered, so re-register if localizing response
         create_initial_post_types();
     }
     $queryable_only = isset($args['api_queryable']) && $args['api_queryable'];
     // Get a list of available post types
     $post_types = get_post_types(array('public' => true));
     $formatted_post_type_objects = array();
     // Retrieve post type object for each post type
     foreach ($post_types as $post_type) {
         // Skip non-queryable if filtering on queryable only
         $is_queryable = $this->is_post_type_allowed($post_type);
         if ($queryable_only && !$is_queryable) {
             continue;
         }
         $post_type_object = get_post_type_object($post_type);
         $formatted_post_type_object = array();
         // Include only the desired keys in the response
         foreach (self::$post_type_keys_to_include as $key => $value) {
             $formatted_post_type_object[$value] = $post_type_object->{$key};
         }
         $formatted_post_type_object['api_queryable'] = $is_queryable;
         $formatted_post_type_object['supports'] = get_all_post_type_supports($post_type);
         if ($this->post_type_supports_tags($post_type)) {
             $formatted_post_type_object['supports']['tags'] = true;
         }
         $formatted_post_type_objects[] = $formatted_post_type_object;
     }
     return array('found' => count($formatted_post_type_objects), 'post_types' => $formatted_post_type_objects);
 }
    unset($network_plugin);
}
do_action('muplugins_loaded');
if (is_multisite()) {
    ms_cookie_constants();
}
// Define constants after multisite is loaded. Cookie-related constants may be overridden in ms_network_cookies().
wp_cookie_constants();
// Define and enforce our SSL constants
wp_ssl_constants();
// Create common globals.
require ABSPATH . WPINC . '/vars.php';
// Make taxonomies and posts available to plugins and themes.
// @plugin authors: warning: these get registered again on the init hook.
create_initial_taxonomies();
create_initial_post_types();
// Register the default theme directory root
register_theme_directory(get_theme_root());
// Load active plugins.
foreach (wp_get_active_and_valid_plugins() as $plugin) {
    include_once $plugin;
}
unset($plugin);
// Load pluggable functions.
require ABSPATH . WPINC . '/pluggable.php';
require ABSPATH . WPINC . '/pluggable-deprecated.php';
// Set internal encoding.
wp_set_internal_encoding();
// Run wp_cache_postload() if object cache is enabled and the function exists.
if (WP_CACHE && function_exists('wp_cache_postload')) {
    wp_cache_postload();
Beispiel #5
0
 public function requirePostTypes()
 {
     if (!empty($this->context['wp_post_types'])) {
         return;
     }
     create_initial_post_types();
 }