check_admin_referer

Definition:
function check_admin_referer($action = -1, $query_arg = '_wpnonce') {}

Makes sure that a user was referred from another admin page.
To avoid security exploits.

Parameters

  • string $action: Action nonce
  • string $query_arg: where to look for nonce in $_REQUEST (since 2.5)

Defined actions

  • check_admin_referer
    do_action('check_admin_referer', $action, $result);

Source code

function check_admin_referer($action = -1, $query_arg = '_wpnonce') {

	if ( -1 == $action )

		_doing_it_wrong( __FUNCTION__, __( 'You should specify a nonce action to be verified by using the first parameter.' ), '3.2' );



	$adminurl = strtolower(admin_url());

	$referer = strtolower(wp_get_referer());

	$result = isset($_REQUEST[$query_arg]) ? wp_verify_nonce($_REQUEST[$query_arg], $action) : false;

	if ( !$result && !(-1 == $action && strpos($referer, $adminurl) === 0) ) {

		wp_nonce_ays($action);

		die();

	}

	do_action('check_admin_referer', $action, $result);

	return $result;

}endif;

593

checked

Definition:
function checked( $checked, $current = true, $echo = true ) {}

Outputs the html checked attribute.
Compares the first two arguments and if identical marks as checked

Parameters

  • mixed $checked: One of the values to compare
  • mixed $current: (true) The other value to compare if not just true
  • bool $echo: Whether to echo or just return the string

Return values

returns:html attribute or empty string

Source code

function checked( $checked, $current = true, $echo = true ) {

	return __checked_selected_helper( $checked, $current, $echo, 'checked' );

}

591

cat_is_ancestor_of

Definition:
function cat_is_ancestor_of( $cat1, $cat2 ) {}

Check if a category is an ancestor of another category.
You can use either an id or the category object for both parameters. If you use an integer the category will be retrieved.

Parameters

  • int|object $cat1: ID or object to check if this is the parent category.
  • int|object $cat2: The child category.

Return values

returns:Whether $cat2 is child of $cat1

Source code

function cat_is_ancestor_of( $cat1, $cat2 ) {

	if ( ! isset($cat1->term_id) )

		$cat1 = &get_category( $cat1 );

	if ( ! isset($cat2->parent) )

		$cat2 = &get_category( $cat2 );



	if ( empty($cat1->term_id) || empty($cat2->parent) )

		return false;

	if ( $cat2->parent == $cat1->term_id )

		return true;



	return cat_is_ancestor_of( $cat1, get_category( $cat2->parent ) );

}

589

category_exists

Definition:
function category_exists($cat_name, $parent = 0) {}

Parameters

  • unknown_type $cat_name
  • $parent

Source code

function category_exists($cat_name, $parent = 0) {

	$id = term_exists($cat_name, 'category', $parent);

	if ( is_array($id) )

		$id = $id['term_id'];

	return $id;

}

587

category_description

Definition:
function category_description( $category = 0 ) {}

Retrieve category description.

Parameters

  • int $category: Optional. Category ID. Will use global category ID by default.

Return values

returns:Category description, available.

Source code

function category_description( $category = 0 ) {

	return term_description( $category, 'category' );

}

585