register_theme_directory

Definition:
function register_theme_directory( $directory) {}

Register a directory that contains themes.

Parameters

  • string $directory: Either the full filesystem path to a theme folder or a folder within WP_CONTENT_DIR

Source code

function register_theme_directory( $directory) {

	global $wp_theme_directories;



	/* If this folder does not exist, return and do not register */

	if ( !file_exists( $directory ) )

			/* Try prepending as the theme directory could be relative to the content directory */

		$registered_directory = WP_CONTENT_DIR . '/' . $directory;

	else

		$registered_directory = $directory;



	/* If this folder does not exist, return and do not register */

	if ( !file_exists( $registered_directory ) )

		return false;



	$wp_theme_directories[] = $registered_directory;



	return true;

}

2689

register_taxonomy_for_object_type

Definition:
function register_taxonomy_for_object_type( $taxonomy, $object_type) {}

Add an already registered taxonomy to an object type.

Parameters

  • string $taxonomy: Name of taxonomy object
  • array|string $object_type: Name of the object type

Return values

returns:True if successful, false if not

Source code

function register_taxonomy_for_object_type( $taxonomy, $object_type) {

	global $wp_taxonomies;



	if ( !isset($wp_taxonomies[$taxonomy]) )

		return false;



	if ( ! get_post_type_object($object_type) )

		return false;



	if ( ! in_array( $object_type, $wp_taxonomies[$taxonomy]->object_type ) )

		$wp_taxonomies[$taxonomy]->object_type[] = $object_type;



	return true;

}

2687

register_taxonomy

Definition:
function register_taxonomy( $taxonomy, $object_type, $args = array() {}

Create or modify a taxonomy object. Do not use before init.
A simple function for creating or modifying a taxonomy object based on the parameters given. The function will accept an array (third optional parameter), along with strings for the taxonomy name and another string for the object type.

Parameters

  • string $taxonomy: Name of taxonomy object
  • array|string $object_type: Name of the object type for the taxonomy object.
  • array|string $args: See above description for the two keys values.

Source code

function register_taxonomy( $taxonomy, $object_type, $args = array() ) {

	global $wp_taxonomies, $wp_rewrite, $wp;



	if ( ! is_array($wp_taxonomies) )

		$wp_taxonomies = array();



	$defaults = array(	'hierarchical' => false,

						'update_count_callback' => '',

						'rewrite' => true,

						'query_var' => $taxonomy,

						'public' => true,

						'show_ui' => null,

						'show_tagcloud' => null,

						'_builtin' => false,

						'labels' => array(),

						'capabilities' => array(),

						'show_in_nav_menus' => null,

					);

	$args = wp_parse_args($args, $defaults);



	if ( false !== $args['query_var'] && !empty($wp) ) {

		if ( true === $args['query_var'] )

			$args['query_var'] = $taxonomy;

		$args['query_var'] = sanitize_title_with_dashes($args['query_var']);

		$wp->add_query_var($args['query_var']);

	}



	if ( false !== $args['rewrite'] && '' != get_option('permalink_structure') ) {

		$args['rewrite'] = wp_parse_args($args['rewrite'], array(

			'slug' => sanitize_title_with_dashes($taxonomy),

			'with_front' => true,

			'hierarchical' => false

		));



		if ( $args['hierarchical'] && $args['rewrite']['hierarchical'] )

			$tag = '(.+?)';

		else

			$tag = '([^/]+)';



		$wp_rewrite->add_rewrite_tag("%$taxonomy%", $tag, $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term=");

		$wp_rewrite->add_permastruct($taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite']['with_front']);

2685

register_sidebar_widget

Definition:
function register_sidebar_widget($name, $output_callback, $classname = '') {}

Register widget for sidebar with backwards compatibility.
Allows $name to be an array that accepts either three elements to grab the first element and the third for the name or just uses the first element of the array for the name.

Parameters

  • string|int $name: Widget ID.
  • callback $output_callback: Run when widget is called.
  • string $classname: Classname widget option.
  • mixed $params,…: Widget parameters.

Source code

function register_sidebar_widget($name, $output_callback, $classname = '') {

	_deprecated_function( __FUNCTION__, '2.8', 'wp_register_sidebar_widget()' );

	// Compat

	if ( is_array($name) ) {

		if ( count($name) == 3 )

			$name = sprintf($name[0], $name[2]);

		else

			$name = $name[0];

	}



	$id = sanitize_title($name);

	$options = array();

	if ( !empty($classname) && is_string($classname) )

		$options['classname'] = $classname;

	$params = array_slice(func_get_args(), 2);

	$args = array($id, $name, $output_callback, $options);

	if ( !empty($params) )

		$args = array_merge($args, $params);



	call_user_func_array('wp_register_sidebar_widget', $args);

}

2683

register_sidebars

Definition:
function register_sidebars($number = 1, $args = array() {}

Creates multiple sidebars.
If you wanted to quickly create multiple sidebars for a theme or internally. This function will allow you to do so. If you don’t pass the ‘name’ and/or ‘id’ in $args, then they will be built for you.

Parameters

  • int $number: Number of sidebars to create.
  • string|array $args: Builds Sidebar based off of ‘name’ and ‘id’ values.

Source code

function register_sidebars($number = 1, $args = array()) {

	global $wp_registered_sidebars;

	$number = (int) $number;



	if ( is_string($args) )

		parse_str($args, $args);



	for ( $i = 1; $i <= $number; $i++ ) {

		$_args = $args;



		if ( $number > 1 )

			$_args['name'] = isset($args['name']) ? sprintf($args['name'], $i) : sprintf(__('Sidebar %d'), $i);

		else

			$_args['name'] = isset($args['name']) ? $args['name'] : __('Sidebar');



		// Custom specified ID's are suffixed if they exist already.

		// Automatically generated sidebar names need to be suffixed regardless starting at -0

		if ( isset($args['id']) ) {

			$_args['id'] = $args['id'];

			$n = 2; // Start at -2 for conflicting custom ID's

			while ( isset($wp_registered_sidebars[$_args['id']]) )

				$_args['id'] = $args['id'] . '-' . $n++;

		} else {

			$n = count($wp_registered_sidebars);

			do {

				$_args['id'] = 'sidebar-' . ++$n;

			} while ( isset($wp_registered_sidebars[$_args['id']]) );

		}

		register_sidebar($_args);

	}

}

2681