wp_register

Definition:
function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {}

Display the Registration or Admin link.
Display a link which allows the user to navigate to the registration page if not logged in and registration is enabled or to the dashboard if logged in.

Parameters

  • string $before: Text to output before the link (defaults to <li>).
  • string $after: Text to output after the link (defaults to </li>).
  • boolean $echo: Default to echo and not return the link.

Defined filters

  • register
    apply_filters('register', $link)
  • register
    apply_filters('register', $link)

Source code

function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {



	if ( ! is_user_logged_in() ) {

		if ( get_option('users_can_register') )

			$link = $before . '<a href="' . site_url('wp-login.php?action=register', 'login') . '">' . __('Register') . '</a>' . $after;

		else

			$link = '';

	} else {

		$link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;

	}



	if ( $echo )

		echo apply_filters('register', $link);

	else

		return apply_filters('register', $link);

}

4019

wp_referer_field

Definition:
function wp_referer_field( $echo = true ) {}

Retrieve or display referer hidden field for forms.
The referer link is the current Request URI from the server super global. The input name is ‘_wp_http_referer’, in case you wanted to check manually.

Parameters

  • bool $echo: Whether to echo or return the referer field.

Return values

returns:Referer field.

Source code

function wp_referer_field( $echo = true ) {

	$ref = esc_attr( $_SERVER['REQUEST_URI'] );

	$referer_field = '<input type="hidden" name="_wp_http_referer" value="'. $ref . '" />';



	if ( $echo )

		echo $referer_field;

	return $referer_field;

}

4017

wp_redirect

Definition:
function wp_redirect($location, $status = 302) {}

Redirects to another page.

Parameters

  • string $location: The path to redirect to
  • int $status: Status code to use

Return values

returns:False if $location is not set

Defined filters

  • wp_redirect
    apply_filters('wp_redirect', $location, $status)
  • wp_redirect_status
    apply_filters('wp_redirect_status', $status, $location)

Source code

function wp_redirect($location, $status = 302) {

	global $is_IIS;



	$location = apply_filters('wp_redirect', $location, $status);

	$status = apply_filters('wp_redirect_status', $status, $location);



	if ( !$location ) // allows the wp_redirect filter to cancel a redirect

		return false;



	$location = wp_sanitize_redirect($location);



	if ( !$is_IIS && php_sapi_name() != 'cgi-fcgi' )

		status_header($status); // This causes problems on IIS and some FastCGI setups



	header("Location: $location", true, $status);

}

4015

wp_rand

Definition:
function wp_rand( $min = 0, $max = 0 ) {}

Generates a random number

Parameters

  • int $min: Lower limit for the generated number (optional, default is 0)
  • int $max: Upper limit for the generated number (optional, default is 4294967295)

Return values

returns:A random number between min and max

Source code

function wp_rand( $min = 0, $max = 0 ) {

	global $rnd_value;



	// Reset $rnd_value after 14 uses

	// 32(md5) + 40(sha1) + 40(sha1) / 8 = 14 random numbers from $rnd_value

	if ( strlen($rnd_value) < 8 ) {

		if ( defined( 'WP_SETUP_CONFIG' ) )

			static $seed = '';

		else

			$seed = get_transient('random_seed');

		$rnd_value = md5( uniqid(microtime() . mt_rand(), true ) . $seed );

		$rnd_value .= sha1($rnd_value);

		$rnd_value .= sha1($rnd_value . $seed);

		$seed = md5($seed . $rnd_value);

		if ( ! defined( 'WP_SETUP_CONFIG' ) )

			set_transient('random_seed', $seed);

	}



	// Take the first 8 digits for our value

	$value = substr($rnd_value, 0, 8);



	// Strip the first eight, leaving the remainder for the next call to wp_rand().

	$rnd_value = substr($rnd_value, 8);



	$value = abs(hexdec($value));



	// Reduce the value to be within the min - max range

	// 4294967295 = 0xffffffff = max random number

	if ( $max != 0 )

		$value = $min + (($max - $min + 1) * ($value / (4294967295 + 1)));



	return abs(intval($value));

}

4011