create_initial_taxonomies

Definition:
function create_initial_taxonomies() {}

Creates the initial taxonomies when ‘init’ action is fired.

Defined filters

  • post_format_rewrite_base
    apply_filters( 'post_format_rewrite_base', 'type' )

Source code

function create_initial_taxonomies() {

	global $wp_rewrite;



	register_taxonomy( 'category', 'post', array(

		'hierarchical' => true,

		'query_var' => 'category_name',

		'rewrite' => did_action( 'init' ) ? array(

					'hierarchical' => true,

					'slug' => get_option('category_base') ? get_option('category_base') : 'category',

					'with_front' => ( get_option('category_base') && ! $wp_rewrite->using_index_permalinks() ) ? false : true ) : false,

		'public' => true,

		'show_ui' => true,

		'_builtin' => true,

	) );



	register_taxonomy( 'post_tag', 'post', array(

	 	'hierarchical' => false,

		'query_var' => 'tag',

		'rewrite' => did_action( 'init' ) ? array(

					'slug' => get_option('tag_base') ? get_option('tag_base') : 'tag',

					'with_front' => ( get_option('tag_base') && ! $wp_rewrite->using_index_permalinks() ) ? false : true ) : false,

		'public' => true,

		'show_ui' => true,

		'_builtin' => true,

	) );



	register_taxonomy( 'nav_menu', 'nav_menu_item', array(

		'public' => false,

		'hierarchical' => false,

		'labels' => array(

			'name' => __( 'Navigation Menus' ),

			'singular_name' => __( 'Navigation Menu' ),

		),

		'query_var' => false,

		'rewrite' => false,

		'show_ui' => false,

		'_builtin' => true,

		'show_in_nav_menus' => false,

	) );



	register_taxonomy( 'link_category', 'link', array(

		'hierarchical' => false,

		'labels' => array(

			'name' => __( 'Link Categories' ),

			'singular_name' => __( 'Link Category' ),

			'search_items' => __( 'Search Link Categories' ),

			'popular_items' => null,

			'all_items' => __( 'All Link Categories' ),

			'edit_item' => __( 'Edit Link Category' ),

			'update_item' => __( 'Update Link Category' ),

			'add_new_item' => __( 'Add New Link Category' ),

			'new_item_name' => __( 'New Link Category Name' ),

			'separate_items_with_commas' => null,

			'add_or_remove_items' => null,

			'choose_from_most_used' => null,

		),

		'query_var' => false,

		'rewrite' => false,

		'public' => false,

		'show_ui' => false,

		'_builtin' => true,

	) );



	$rewrite = false;

	if ( did_action( 'init' ) ) {

		$rewrite = apply_filters( 'post_format_rewrite_base', 'type' );

		$rewrite = $rewrite ? array( 'slug' => $rewrite ) : false;

	}



	register_taxonomy( 'post_format', 'post', array(

		'public' => true,

		'hierarchical' => false,

		'labels' => array(

			'name' => _x( 'Format', 'post format' ),

			'singular_name' => _x( 'Format', 'post format' ),

		),

		'query_var' => true,

		'rewrite' => $rewrite,

		'show_ui' => false,

		'_builtin' => true,

		'show_in_nav_menus' => false,

	) );

}

744

create_initial_post_types

Definition:
function create_initial_post_types() {}

Creates the initial post types when ‘init’ action is fired.

Source code

function create_initial_post_types() {

	register_post_type( 'post', array(

		'labels' => array(

			'name_admin_bar' => _x( 'Post', 'add new on admin bar' ),

		),

		'public'  => true,

		'_builtin' => true, /* internal use only. don't use this when registering your own post type. */

		'_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */

		'capability_type' => 'post',

		'map_meta_cap' => true,

		'hierarchical' => false,

		'rewrite' => false,

		'query_var' => false,

		'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ),

	) );



	register_post_type( 'page', array(

		'labels' => array(

			'name_admin_bar' => _x( 'Page', 'add new on admin bar' ),

		),

		'public' => true,

		'publicly_queryable' => false,

		'_builtin' => true, /* internal use only. don't use this when registering your own post type. */

		'_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */

		'capability_type' => 'page',

		'map_meta_cap' => true,

		'hierarchical' => true,

		'rewrite' => false,

		'query_var' => false,

		'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions' ),

	) );



	register_post_type( 'attachment', array(

		'labels' => array(

			'name' => __( 'Media' ),

			'edit_item' => __( 'Edit Media' ),

		),

		'public' => true,

		'show_ui' => false,

		'_builtin' => true, /* internal use only. don't use this when registering your own post type. */

		'_edit_link' => 'media.php?attachment_id=%d', /* internal use only. don't use this when registering your own post type. */

		'capability_type' => 'post',

		'map_meta_cap' => true,

		'hierarchical' => false,

		'rewrite' => false,

		'query_var' => false,

		'show_in_nav_menus' => false,

		'supports' => array( 'comments' ),

	) );



	register_post_type( 'revision', array(

		'labels' => array(

			'name' => __( 'Revisions' ),

			'singular_name' => __( 'Revision' ),

		),

		'public' => false,

		'_builtin' => true, /* internal use only. don't use this when registering your own post type. */

		'_edit_link' => 'revision.php?revision=%d', /* internal use only. don't use this when registering your own post type. */

		'capability_type' => 'post',

		'map_meta_cap' => true,

		'hierarchical' => false,

		'rewrite' => false,

		'query_var' => false,

		'can_export' => false,

	) );



	register_post_type( 'nav_menu_item', array(

		'labels' => array(

			'name' => __( 'Navigation Menu Items' ),

			'singular_name' => __( 'Navigation Menu Item' ),

		),

		'public' => false,

		'_builtin' => true, /* internal use only. don't use this when registering your own post type. */

		'hierarchical' => false,

		'rewrite' => false,

		'query_var' => false,

	) );



	register_post_status( 'publish', array(

		'label'       => _x( 'Published', 'post' ),

		'public'      => true,

		'_builtin'    => true, /* internal use only. */

		'label_count' => _n_noop( 'Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>' ),

	) );



	register_post_status( 'future', array(

		'label'       => _x( 'Scheduled', 'post' ),

		'protected'   => true,

		'_builtin'    => true, /* internal use only. */

		'label_count' => _n_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>' ),

	) );



	register_post_status( 'draft', array(

		'label'       => _x( 'Draft', 'post' ),

		'protected'   => true,

		'_builtin'    => true, /* internal use only. */

		'label_count' => _n_noop( 'Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>' ),

	) );



	register_post_status( 'pending', array(

		'label'       => _x( 'Pending', 'post' ),

		'protected'   => true,

		'_builtin'    => true, /* internal use only. */

		'label_count' => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>' ),

	) );



	register_post_status( 'private', array(

		'label'       => _x( 'Private', 'post' ),

		'private'     => true,

		'_builtin'    => true, /* internal use only. */

		'label_count' => _n_noop( 'Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>' ),

	) );



	register_post_status( 'trash', array(

		'label'       => _x( 'Trash', 'post' ),

		'internal'    => true,

		'_builtin'    => true, /* internal use only. */

		'label_count' => _n_noop( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>' ),

		'show_in_admin_status_list' => true,

	) );



	register_post_status( 'auto-draft', array(

		'label'    => 'auto-draft',

		'internal' => true,

		'_builtin' => true, /* internal use only. */

	) );



	register_post_status( 'inherit', array(

		'label'    => 'inherit',

		'internal' => true,

		'_builtin' => true, /* internal use only. */

		'exclude_from_search' => false,

	) );

}

742

create_empty_blog

Definition:
function create_empty_blog( $domain, $path, $weblog_title, $site_id = 1 ) {}

Create an empty blog.

Parameters

  • string $domain: The new blog’s domain.
  • string $path: The new blog’s path.
  • string $string: The new blog’s title.
  • int $site: Optional. Defaults to 1.
  • $weblog_title
  • $site_id

Return values

returns:The ID of the newly created blog

Source code

function create_empty_blog( $domain, $path, $weblog_title, $site_id = 1 ) {

	$domain			= addslashes( $domain );

	$weblog_title	= addslashes( $weblog_title );



	if ( empty($path) )

		$path = '/';



	// Check if the domain has been used already. We should return an error message.

	if ( domain_exists($domain, $path, $site_id) )

		return __( '<strong>ERROR</strong>: Site URL already taken.' );



	// Need to back up wpdb table names, and create a new wp_blogs entry for new blog.

	// Need to get blog_id from wp_blogs, and create new table names.

	// Must restore table names at the end of function.



	if ( ! $blog_id = insert_blog($domain, $path, $site_id) )

		return __( '<strong>ERROR</strong>: problem creating site entry.' );



	switch_to_blog($blog_id);

	install_blog($blog_id);

	restore_current_blog();



	return $blog_id;

}

740

count_user_posts

Definition:
function count_user_posts($userid) {}

Number of posts user has written.

Parameters

  • int $userid: User ID.

Return values

returns:Amount of posts user has written.

Defined filters

  • get_usernumposts
    apply_filters('get_usernumposts', $count, $userid)

Source code

function count_user_posts($userid) {

	global $wpdb;



	$where = get_posts_by_author_sql('post', TRUE, $userid);



	$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" );



	return apply_filters('get_usernumposts', $count, $userid);

}

738

count_users

Definition:
function count_users($strategy = 'time') {}

Count number of users who have each of the user roles.
Assumes there are neither duplicated nor orphaned capabilities meta_values. Assumes role names are unique phrases. Same assumption made by WP_User_Query::prepare_query() Using $strategy = ‘time’ this is CPU-intensive and should handle around 10^7 users. Using $strategy = ‘memory’ this is memory-intensive and should handle around 10^5 users, but see WP Bug #12257.

Parameters

  • string $strategy: ‘time’ or ‘memory’

Return values

returns:Includes a grand total and an array of counts indexed by role strings.

Source code

function count_users($strategy = 'time') {

	global $wpdb, $wp_roles;



	// Initialize

	$id = get_current_blog_id();

	$blog_prefix = $wpdb->get_blog_prefix($id);

	$result = array();



	if ( 'time' == $strategy ) {

		global $wp_roles;



		if ( ! isset( $wp_roles ) )

			$wp_roles = new WP_Roles();



		$avail_roles = $wp_roles->get_names();



		// Build a CPU-intensive query that will return concise information.

		$select_count = array();

		foreach ( $avail_roles as $this_role => $name ) {

			$select_count[] = "COUNT(NULLIF(`meta_value` LIKE '%" . like_escape($this_role) . "%', FALSE))";

		}

		$select_count = implode(', ', $select_count);



		// Add the meta_value index to the selection list, then run the query.

		$row = $wpdb->get_row( "SELECT $select_count, COUNT(*) FROM $wpdb->usermeta WHERE meta_key = '{$blog_prefix}capabilities'", ARRAY_N );



		// Run the previous loop again to associate results with role names.

		$col = 0;

		$role_counts = array();

		foreach ( $avail_roles as $this_role => $name ) {

			$count = (int) $row[$col++];

			if ($count > 0) {

				$role_counts[$this_role] = $count;

			}

		}



		// Get the meta_value index from the end of the result set.

		$total_users = (int) $row[$col];



		$result['total_users'] = $total_users;

		$result['avail_roles'] =& $role_counts;

	} else {

736