wp_page_menu

Definition:
function wp_page_menu( $args = array() {}

Display or retrieve list of pages with optional home link.
The arguments are listed below and part of the arguments are for wp_list_pages() function. Check that function for more info on those arguments.

Parameters

  • array|string $args

Defined filters

  • wp_page_menu_args
    apply_filters( 'wp_page_menu_args', $args )
  • wp_page_menu
    apply_filters( 'wp_page_menu', $menu, $args )

Source code

function wp_page_menu( $args = array() ) {

	$defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '');

	$args = wp_parse_args( $args, $defaults );

	$args = apply_filters( 'wp_page_menu_args', $args );



	$menu = '';



	$list_args = $args;



	// Show Home in the menu

	if ( ! empty($args['show_home']) ) {

		if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] )

			$text = __('Home');

		else

			$text = $args['show_home'];

		$class = '';

		if ( is_front_page() && !is_paged() )

			$class = 'class="current_page_item"';

		$menu .= '<li ' . $class . '><a href="' . home_url( '/' ) . '" title="' . esc_attr($text) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';

		// If the front page is a page, add it to the exclude list

		if (get_option('show_on_front') == 'page') {

			if ( !empty( $list_args['exclude'] ) ) {

				$list_args['exclude'] .= ',';

			} else {

				$list_args['exclude'] = '';

			}

			$list_args['exclude'] .= get_option('page_on_front');

		}

	}



	$list_args['echo'] = false;

	$list_args['title_li'] = '';

	$menu .= str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages($list_args) );



	if ( $menu )

		$menu = '<ul>' . $menu . '</ul>';



	$menu = '<div class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\n";

	$menu = apply_filters( 'wp_page_menu', $menu, $args );

	if ( $args['echo'] )

		echo $menu;

	else

		return $menu;

}

3969

wp_original_referer_field

Definition:
function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {}

Retrieve or display original referer hidden field for forms.
The input name is ‘_wp_original_http_referer’ and will be either the same value of wp_referer_field(), if that was posted already or it will be the current page, if it doesn’t exist.

Parameters

  • bool $echo: Whether to echo the original http referer
  • string $jump_back_to: Optional, default is ‘current’. Can be ‘previous’ or page you want to jump back to.

Return values

returns:Original referer field.

Source code

function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {

	$jump_back_to = ( 'previous' == $jump_back_to ) ? wp_get_referer() : $_SERVER['REQUEST_URI'];

	$ref = ( wp_get_original_referer() ) ? wp_get_original_referer() : $jump_back_to;

	$orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr( stripslashes( $ref ) ) . '" />';

	if ( $echo )

		echo $orig_referer_field;

	return $orig_referer_field;

}

3967

wp_old_slug_redirect

Definition:
function wp_old_slug_redirect() {}

Redirect old slugs to the correct permalink.
Attempts to find the current slug from the past slugs.

Return values

returns:If no link is found, null is returned.

Source code

function wp_old_slug_redirect() {

	global $wp_query;

	if ( is_404() && '' != $wp_query->query_vars['name'] ) :

		global $wpdb;



		// Guess the current post_type based on the query vars.

		if ( get_query_var('post_type') )

			$post_type = get_query_var('post_type');

		elseif ( !empty($wp_query->query_vars['pagename']) )

			$post_type = 'page';

		else

			$post_type = 'post';



		if ( is_array( $post_type ) ) {

			if ( count( $post_type ) > 1 )

				return;

			$post_type = array_shift( $post_type );

		}



		// Do not attempt redirect for hierarchical post types

		if ( is_post_type_hierarchical( $post_type ) )

			return;



		$query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta, $wpdb->posts WHERE ID = post_id AND post_type = %s AND meta_key = '_wp_old_slug' AND meta_value = %s", $post_type, $wp_query->query_vars['name']);



		// if year, monthnum, or day have been specified, make our query more precise

		// just in case there are multiple identical _wp_old_slug values

		if ( '' != $wp_query->query_vars['year'] )

			$query .= $wpdb->prepare(" AND YEAR(post_date) = %d", $wp_query->query_vars['year']);

		if ( '' != $wp_query->query_vars['monthnum'] )

			$query .= $wpdb->prepare(" AND MONTH(post_date) = %d", $wp_query->query_vars['monthnum']);

		if ( '' != $wp_query->query_vars['day'] )

			$query .= $wpdb->prepare(" AND DAYOFMONTH(post_date) = %d", $wp_query->query_vars['day']);



		$id = (int) $wpdb->get_var($query);



		if ( ! $id )

			return;



		$link = get_permalink($id);



		if ( !$link )

			return;



		wp_redirect( $link, 301 ); // Permanent redirect

		exit;

	endif;

}

3965

wp_oembed_get

Definition:
function wp_oembed_get( $url, $args = '' ) {}

Attempts to fetch the embed HTML for a provided URL using oEmbed.

Parameters

  • string $url: The URL that should be embedded.
  • array $args: Additional arguments and parameters.

Return values

returns:The original URL on failure or the embed HTML on success.

Source code

function wp_oembed_get( $url, $args = '' ) {

	require_once( ABSPATH . WPINC . '/class-oembed.php' );

	$oembed = _wp_oembed_get_object();

	return $oembed->get_html( $url, $args );

}

3963

wp_oembed_add_provider

Definition:
function wp_oembed_add_provider( $format, $provider, $regex = false ) {}

Adds a URL format and oEmbed provider URL pair.

Parameters

  • string $format: The format of URL that this provider can handle. You can use asterisks as wildcards.
  • string $provider: The URL to the oEmbed provider.
  • boolean $regex: Whether the $format parameter is in a regex format.

Source code

function wp_oembed_add_provider( $format, $provider, $regex = false ) {

	require_once( ABSPATH . WPINC . '/class-oembed.php' );

	$oembed = _wp_oembed_get_object();

	$oembed->providers[$format] = array( $provider, $regex );

}

3961