add_role

Definition:
function add_role( $role, $display_name, $capabilities = array() {}

Add role, if it does not exist.

Parameters

  • string $role: Role name.
  • string $display_name: Display name for role.
  • array $capabilities: List of capabilities, e.g. array( ‘edit_posts’ => true, ‘delete_posts’ => false );

Return values

returns:WP_Role object if role is added, null if already exists.

Source code

function add_role( $role, $display_name, $capabilities = array() ) {

	global $wp_roles;



	if ( ! isset( $wp_roles ) )

		$wp_roles = new WP_Roles();



	return $wp_roles->add_role( $role, $display_name, $capabilities );

}

295

add_rewrite_rule

Definition:
function add_rewrite_rule($regex, $redirect, $after = 'bottom') {}

Add a straight rewrite rule.

Parameters

  • string $regex: Regular Expression to match request against.
  • string $redirect: Page to redirect to.
  • string $after: Optional, default is ‘bottom’. Where to add rule, can also be ‘top’.

Source code

function add_rewrite_rule($regex, $redirect, $after = 'bottom') {

	global $wp_rewrite;

	$wp_rewrite->add_rule($regex, $redirect, $after);

}

291

add_rewrite_endpoint

Definition:
function add_rewrite_endpoint($name, $places) {}

Add an endpoint, like /trackback/.
The endpoints are added to the end of the request. So a request matching "/2008/10/14/my_post/myep/", the endpoint will be "/myep/".

Parameters

  • unknown_type $name
  • unknown_type $places

Source code

function add_rewrite_endpoint($name, $places) {

	global $wp_rewrite;

	$wp_rewrite->add_endpoint($name, $places);

}

289

add_query_arg

Definition:
function add_query_arg() {}

Retrieve a modified URL query string.
You can rebuild the URL and append a new query variable to the URL query by using this function. You can also retrieve the full URL with query data.

Parameters

  • mixed $param1: Either newkey or an associative_array
  • mixed $param2: Either newvalue or oldquery or uri
  • mixed $param3: Optional. Old query or uri

Return values

returns:New URL query string.

Source code

function add_query_arg() {

	$ret = '';

	if ( is_array( func_get_arg(0) ) ) {

		if ( @func_num_args() < 2 || false === @func_get_arg( 1 ) )

			$uri = $_SERVER['REQUEST_URI'];

		else

			$uri = @func_get_arg( 1 );

	} else {

		if ( @func_num_args() < 3 || false === @func_get_arg( 2 ) )

			$uri = $_SERVER['REQUEST_URI'];

		else

			$uri = @func_get_arg( 2 );

	}



	if ( $frag = strstr( $uri, '#' ) )

		$uri = substr( $uri, 0, -strlen( $frag ) );

	else

		$frag = '';



	if ( preg_match( '|^https?://|i', $uri, $matches ) ) {

		$protocol = $matches[0];

		$uri = substr( $uri, strlen( $protocol ) );

	} else {

		$protocol = '';

	}



	if ( strpos( $uri, '?' ) !== false ) {

		$parts = explode( '?', $uri, 2 );

		if ( 1 == count( $parts ) ) {

			$base = '?';

			$query = $parts[0];

		} else {

			$base = $parts[0] . '?';

			$query = $parts[1];

		}

	} elseif ( !empty( $protocol ) || strpos( $uri, '=' ) === false ) {

		$base = $uri . '?';

		$query = '';

	} else {

		$base = '';

		$query = $uri;

	}



	wp_parse_str( $query, $qs );

	$qs = urlencode_deep( $qs ); // this re-URL-encodes things that were already in the query string

	if ( is_array( func_get_arg( 0 ) ) ) {

		$kayvees = func_get_arg( 0 );

		$qs = array_merge( $qs, $kayvees );

	} else {

		$qs[func_get_arg( 0 )] = func_get_arg( 1 );

	}



	foreach ( (array) $qs as $k => $v ) {

		if ( $v === false )

			unset( $qs[$k] );

	}



	$ret = build_query( $qs );

	$ret = trim( $ret, '?' );

	$ret = preg_replace( '#=(&|$)#', '$1', $ret );

	$ret = $protocol . $base . $ret . $frag;

	$ret = rtrim( $ret, '?' );

	return $ret;

}

287

add_post_type_support

Definition:
function add_post_type_support( $post_type, $feature ) {}

Register support of certain features for a post type.
All features are directly associated with a functional area of the edit screen, such as the editor or a meta box: ‘title’, ‘editor’, ‘comments’, ‘revisions’, ‘trackbacks’, ‘author’, ‘excerpt’, ‘page-attributes’, ‘thumbnail’, and ‘custom-fields’.

Parameters

  • string $post_type: The post type for which to add the feature
  • string|array $feature: the feature being added, can be an array of feature strings or a single string

Source code

function add_post_type_support( $post_type, $feature ) {

	global $_wp_post_type_features;



	$features = (array) $feature;

	foreach ($features as $feature) {

		if ( func_num_args() == 2 )

			$_wp_post_type_features[$post_type][$feature] = true;

		else

			$_wp_post_type_features[$post_type][$feature] = array_slice( func_get_args(), 2 );

	}

}

285