wp_rss

Definition:
function wp_rss( $url, $num_items = -1 ) {}

Display all RSS items in a HTML ordered list.

Parameters

  • string $url: URL of feed to display. Will not auto sense feed URL.
  • int $num_items: Optional. Number of items to display, default is all.

Source code

function wp_rss( $url, $num_items = -1 ) {

	if ( $rss = fetch_rss( $url ) ) {

		echo '<ul>';



		if ( $num_items !== -1 ) {

			$rss->items = array_slice( $rss->items, 0, $num_items );

		}



		foreach ( (array) $rss->items as $item ) {

			printf(

				'<li><a href="%1$s" title="%2$s">%3$s</a></li>',

				esc_url( $item['link'] ),

				esc_attr( strip_tags( $item['description'] ) ),

				esc_html( $item['title'] )

			);

		}



		echo '</ul>';

	} else {

		_e( 'An error has occurred, which probably means the feed is down. Try again later.' );

	}

}

4069

wp_richedit_pre

Definition:
function wp_richedit_pre($text) {}

Formats text for the rich text editor.
The filter ‘richedit_pre’ is applied here. If $text is empty the filter will be applied to an empty string.

Parameters

  • string $text: The text to be formatted.

Return values

returns:The formatted text after filter is applied.

Defined filters

  • richedit_pre
    apply_filters('richedit_pre', '')
  • richedit_pre
    apply_filters('richedit_pre', $output)

Source code

function wp_richedit_pre($text) {

	// Filtering a blank results in an annoying <br />\n

	if ( empty($text) ) return apply_filters('richedit_pre', '');



	$output = convert_chars($text);

	$output = wpautop($output);

	$output = htmlspecialchars($output, ENT_NOQUOTES);



	return apply_filters('richedit_pre', $output);

}

4067

wp_revoke_user

Definition:
function wp_revoke_user($id) {}

Remove all capabilities from user.

Parameters

  • int $id: User ID.

Source code

function wp_revoke_user($id) {

	$id = (int) $id;



	$user = new WP_User($id);

	$user->remove_all_caps();

}

4065

wp_restore_post_revision

Definition:
function wp_restore_post_revision( $revision_id, $fields = null ) {}

Restores a post to the specified revision.
Can restore a past revision using all fields of the post revision, or only selected fields.

Parameters

  • int|object $revision_id: Revision ID or revision object.
  • array $fields: Optional. What fields to restore from. Defaults to all.

Return values

returns:Null if error, false if no fields to restore, (int) post ID if success.

Defined actions

  • wp_restore_post_revision
    do_action( 'wp_restore_post_revision', $post_id, $revision['ID'] );

Source code

function wp_restore_post_revision( $revision_id, $fields = null ) {

	if ( !$revision = wp_get_post_revision( $revision_id, ARRAY_A ) )

		return $revision;



	if ( !is_array( $fields ) )

		$fields = array_keys( _wp_post_revision_fields() );



	$update = array();

	foreach( array_intersect( array_keys( $revision ), $fields ) as $field )

		$update[$field] = $revision[$field];



	if ( !$update )

		return false;



	$update['ID'] = $revision['post_parent'];



	$update = add_magic_quotes( $update ); //since data is from db



	$post_id = wp_update_post( $update );

	if ( is_wp_error( $post_id ) )

		return $post_id;



	if ( $post_id )

		do_action( 'wp_restore_post_revision', $post_id, $revision['ID'] );



	return $post_id;

}

4063

wp_restore_image

Definition:
function wp_restore_image($post_id) {}

Parameters

  • $post_id

Defined filters

  • intermediate_image_sizes
    apply_filters( 'intermediate_image_sizes', array('large', 'medium', 'thumbnail')
  • wp_delete_file
    apply_filters('wp_delete_file', $file)
  • wp_delete_file
    apply_filters( 'wp_delete_file', path_join($parts['dirname'], $meta['sizes'][$default_size]['file'])

Source code

function wp_restore_image($post_id) {

	$meta = wp_get_attachment_metadata($post_id);

	$file = get_attached_file($post_id);

	$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );

	$restored = false;

	$msg = new stdClass;



	if ( !is_array($backup_sizes) ) {

		$msg->error = __('Cannot load image metadata.');

		return $msg;

	}



	$parts = pathinfo($file);

	$suffix = time() . rand(100, 999);

	$default_sizes = apply_filters( 'intermediate_image_sizes', array('large', 'medium', 'thumbnail') );



	if ( isset($backup_sizes['full-orig']) && is_array($backup_sizes['full-orig']) ) {

		$data = $backup_sizes['full-orig'];



		if ( $parts['basename'] != $data['file'] ) {

			if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ) {

				// delete only if it's edited image

				if ( preg_match('/-e[0-9]{13}\./', $parts['basename']) ) {

					$delpath = apply_filters('wp_delete_file', $file);

					@unlink($delpath);

				}

			} else {

				$backup_sizes["full-$suffix"] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $parts['basename']);

			}

		}



		$restored_file = path_join($parts['dirname'], $data['file']);

		$restored = update_attached_file($post_id, $restored_file);



		$meta['file'] = _wp_relative_upload_path( $restored_file );

		$meta['width'] = $data['width'];

		$meta['height'] = $data['height'];

		list ( $uwidth, $uheight ) = wp_constrain_dimensions($meta['width'], $meta['height'], 128, 96);

		$meta['hwstring_small'] = "height='$uheight' width='$uwidth'";

	}



	foreach ( $default_sizes as $default_size ) {

		if ( isset($backup_sizes["$default_size-orig"]) ) {

			$data = $backup_sizes["$default_size-orig"];

			if ( isset($meta['sizes'][$default_size]) && $meta['sizes'][$default_size]['file'] != $data['file'] ) {

				if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ) {

					// delete only if it's edited image

					if ( preg_match('/-e[0-9]{13}-/', $meta['sizes'][$default_size]['file']) ) {

						$delpath = apply_filters( 'wp_delete_file', path_join($parts['dirname'], $meta['sizes'][$default_size]['file']) );

						@unlink($delpath);

					}

				} else {

					$backup_sizes["$default_size-{$suffix}"] = $meta['sizes'][$default_size];

				}

			}



			$meta['sizes'][$default_size] = $data;

		} else {

			unset($meta['sizes'][$default_size]);

		}

	}

4061