setup_userdata

Definition:
function setup_userdata($for_user_id = '') {}

Set up global user vars.
Used by wp_set_current_user() for back compat. Might be deprecated in the future.

Parameters

  • int $for_user_id: Optional. User ID to set up global data.

Source code

function setup_userdata($for_user_id = '') {

	global $user_login, $userdata, $user_level, $user_ID, $user_email, $user_url, $user_pass_md5, $user_identity;



	if ( '' == $for_user_id )

		$user = wp_get_current_user();

	else

		$user = new WP_User($for_user_id);



	$userdata   = $user->data;

	$user_ID    = (int) $user->ID;

	$user_level = (int) isset($user->user_level) ? $user->user_level : 0;



	if ( 0 == $user->ID ) {

		$user_login = $user_email = $user_url = $user_pass_md5 = $user_identity = '';

		return;

	}



	$user_login	= $user->user_login;

	$user_email	= $user->user_email;

	$user_url	= $user->user_url;

	$user_pass_md5	= md5($user->user_pass);

	$user_identity	= $user->display_name;

}

2839

setup_postdata

Definition:
function setup_postdata($post) {}

Set up global post data.

Parameters

  • object $post: Post data.

Return values

returns:True when finished.

Defined actions

  • the_post
    do_action_ref_array('the_post', array(&$post));

Source code

function setup_postdata($post) {

	global $id, $authordata, $currentday, $currentmonth, $page, $pages, $multipage, $more, $numpages;



	$id = (int) $post->ID;



	$authordata = get_userdata($post->post_author);



	$currentday = mysql2date('d.m.y', $post->post_date, false);

	$currentmonth = mysql2date('m', $post->post_date, false);

	$numpages = 1;

	$page = get_query_var('page');

	if ( !$page )

		$page = 1;

	if ( is_single() || is_page() || is_feed() )

		$more = 1;

	$content = $post->post_content;

	if ( strpos( $content, '<!--nextpage-->' ) ) {

		if ( $page > 1 )

			$more = 1;

		$multipage = 1;

		$content = str_replace("\n<!--nextpage-->\n", '<!--nextpage-->', $content);

		$content = str_replace("\n<!--nextpage-->", '<!--nextpage-->', $content);

		$content = str_replace("<!--nextpage-->\n", '<!--nextpage-->', $content);

		$pages = explode('<!--nextpage-->', $content);

		$numpages = count($pages);

	} else {

		$pages = array( $post->post_content );

		$multipage = 0;

	}



	do_action_ref_array('the_post', array(&$post));



	return true;

}

2837

settings_fields

Definition:
function settings_fields($option_group) {}

Output nonce, action, and option_page fields for a settings page.

Parameters

  • string $option_group: A settings group name. This should match the group name used in register_setting().

Source code

function settings_fields($option_group) {

	echo "<input type='hidden' name='option_page' value='" . esc_attr($option_group) . "' />";

	echo '<input type="hidden" name="action" value="update" />';

	wp_nonce_field("$option_group-options");

}

2835

settings_errors

Definition:
function settings_errors( $setting = '', $sanitize = FALSE, $hide_on_update = FALSE ) {}

Display settings errors registered by add_settings_error()
Part of the Settings API. Outputs a <div> for each error retrieved by get_settings_errors().

Parameters

  • string $setting: Optional slug title of a specific setting who’s errors you want.
  • boolean $sanitize: Whether to re-sanitize the setting value before returning errors.
  • boolean $hide_on_update: If set to true errors will not be shown if the settings page has already been submitted.

Source code

function settings_errors( $setting = '', $sanitize = FALSE, $hide_on_update = FALSE ) {



	if ($hide_on_update AND $_GET['settings-updated']) return;



	$settings_errors = get_settings_errors( $setting, $sanitize );



	if ( !is_array($settings_errors) ) return;



	$output = '';

	foreach ( $settings_errors as $key => $details ) {

		$css_id = 'setting-error-' . $details['code'];

		$css_class = $details['type'] . ' settings-error';

		$output .= "<div id='$css_id' class='$css_class'> \n";

		$output .= "<p><strong>{$details['message']}</strong></p>";

		$output .= "</div> \n";

	}

2833

separate_comments

Definition:
function &separate_comments(&$comments) {}

Separates an array of comments into an array keyed by comment_type.

Parameters

  • array $comments: Array of comments
  • &$comments

Return values

returns:Array of comments keyed by comment_type.

Source code

function &separate_comments(&$comments) {

	$comments_by_type = array('comment' => array(), 'trackback' => array(), 'pingback' => array(), 'pings' => array());

	$count = count($comments);

	for ( $i = 0; $i < $count; $i++ ) {

		$type = $comments[$i]->comment_type;

		if ( empty($type) )

			$type = 'comment';

		$comments_by_type[$type][] = &$comments[$i];

		if ( 'trackback' == $type || 'pingback' == $type )

			$comments_by_type['pings'][] = &$comments[$i];

	}



	return $comments_by_type;

}

2831