wp_page_menu

The timeline below displays how wordpress function wp_page_menu has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Displays or retrieves a list of pages with an 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.
 *
 * @since 2.7.0
 * @since 4.4.0 Added `menu_id`, `container`, `before`, `after`, and `walker` arguments.
 * @since 4.7.0 Added the `item_spacing` argument.
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments to generate a page menu. See wp_list_pages() for additional arguments.
 *
 *     @type string          $sort_column  How to sort the list of pages. Accepts post column names.
 *                                         Default 'menu_order, post_title'.
 *     @type string          $menu_id      ID for the div containing the page list. Default is empty string.
 *     @type string          $menu_class   Class to use for the element containing the page list. Default 'menu'.
 *     @type string          $container    Element to use for the element containing the page list. Default 'div'.
 *     @type bool            $echo         Whether to echo the list or return it. Accepts true (echo) or false (return).
 *                                         Default true.
 *     @type int|bool|string $show_home    Whether to display the link to the home page. Can just enter the text
 *                                         you'd like shown for the home link. 1|true defaults to 'Home'.
 *     @type string          $link_before  The HTML or text to prepend to $show_home text. Default empty.
 *     @type string          $link_after   The HTML or text to append to $show_home text. Default empty.
 *     @type string          $before       The HTML or text to prepend to the menu. Default is '<ul>'.
 *     @type string          $after        The HTML or text to append to the menu. Default is '</ul>'.
 *     @type string          $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve'
 *                                         or 'discard'. Default 'discard'.
 *     @type Walker          $walker       Walker instance to use for listing pages. Default empty which results in a
 *                                         Walker_Page instance being used.
 * }
 * @return void|string Void if 'echo' argument is true, HTML menu if 'echo' is false.
 */
function wp_page_menu($args = array())
{
    $defaults = array('sort_column' => 'menu_order, post_title', 'menu_id' => '', 'menu_class' => 'menu', 'container' => 'div', 'echo' => true, 'link_before' => '', 'link_after' => '', 'before' => '<ul>', 'after' => '</ul>', 'item_spacing' => 'discard', 'walker' => '');
    $args = wp_parse_args($args, $defaults);
    if (!in_array($args['item_spacing'], array('preserve', 'discard'), true)) {
        // Invalid value, fall back to default.
        $args['item_spacing'] = $defaults['item_spacing'];
    }
    if ('preserve' === $args['item_spacing']) {
        $t = "\t";
        $n = "\n";
    } else {
        $t = '';
        $n = '';
    }
    /**
     * Filters the arguments used to generate a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param array $args An array of page menu arguments. See wp_page_menu()
     *                    for information on accepted arguments.
     */
    $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="' . esc_url(home_url('/')) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';
        // If the front page is a page, add it to the exclude list.
        if ('page' === get_option('show_on_front')) {
            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 .= wp_list_pages($list_args);
    $container = sanitize_text_field($args['container']);
    // Fallback in case `wp_nav_menu()` was called without a container.
    if (empty($container)) {
        $container = 'div';
    }
    if ($menu) {
        // wp_nav_menu() doesn't set before and after.
        if (isset($args['fallback_cb']) && 'wp_page_menu' === $args['fallback_cb'] && 'ul' !== $container) {
            $args['before'] = "<ul>{$n}";
            $args['after'] = '</ul>';
        }
        $menu = $args['before'] . $menu . $args['after'];
    }
    $attrs = '';
    if (!empty($args['menu_id'])) {
        $attrs .= ' id="' . esc_attr($args['menu_id']) . '"';
    }
    if (!empty($args['menu_class'])) {
        $attrs .= ' class="' . esc_attr($args['menu_class']) . '"';
    }
    $menu = "<{$container}{$attrs}>" . $menu . "</{$container}>{$n}";
    /**
     * Filters the HTML output of a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param string $menu The HTML output.
     * @param array  $args An array of arguments. See wp_page_menu()
     *                     for information on accepted arguments.
     */
    $menu = apply_filters('wp_page_menu', $menu, $args);
    if ($args['echo']) {
        echo $menu;
    } else {
        return $menu;
    }
}

WordPress Version: 5.7

/**
 * Displays or retrieves a list of pages with an 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.
 *
 * @since 2.7.0
 * @since 4.4.0 Added `menu_id`, `container`, `before`, `after`, and `walker` arguments.
 * @since 4.7.0 Added the `item_spacing` argument.
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments to generate a page menu. See `wp_list_pages()` for additional arguments.
 *
 *     @type string          $sort_column  How to sort the list of pages. Accepts post column names.
 *                                         Default 'menu_order, post_title'.
 *     @type string          $menu_id      ID for the div containing the page list. Default is empty string.
 *     @type string          $menu_class   Class to use for the element containing the page list. Default 'menu'.
 *     @type string          $container    Element to use for the element containing the page list. Default 'div'.
 *     @type bool            $echo         Whether to echo the list or return it. Accepts true (echo) or false (return).
 *                                         Default true.
 *     @type int|bool|string $show_home    Whether to display the link to the home page. Can just enter the text
 *                                         you'd like shown for the home link. 1|true defaults to 'Home'.
 *     @type string          $link_before  The HTML or text to prepend to $show_home text. Default empty.
 *     @type string          $link_after   The HTML or text to append to $show_home text. Default empty.
 *     @type string          $before       The HTML or text to prepend to the menu. Default is '<ul>'.
 *     @type string          $after        The HTML or text to append to the menu. Default is '</ul>'.
 *     @type string          $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve'
 *                                         or 'discard'. Default 'discard'.
 *     @type Walker          $walker       Walker instance to use for listing pages. Default empty (Walker_Page).
 * }
 * @return void|string Void if 'echo' argument is true, HTML menu if 'echo' is false.
 */
function wp_page_menu($args = array())
{
    $defaults = array('sort_column' => 'menu_order, post_title', 'menu_id' => '', 'menu_class' => 'menu', 'container' => 'div', 'echo' => true, 'link_before' => '', 'link_after' => '', 'before' => '<ul>', 'after' => '</ul>', 'item_spacing' => 'discard', 'walker' => '');
    $args = wp_parse_args($args, $defaults);
    if (!in_array($args['item_spacing'], array('preserve', 'discard'), true)) {
        // Invalid value, fall back to default.
        $args['item_spacing'] = $defaults['item_spacing'];
    }
    if ('preserve' === $args['item_spacing']) {
        $t = "\t";
        $n = "\n";
    } else {
        $t = '';
        $n = '';
    }
    /**
     * Filters the arguments used to generate a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param array $args An array of page menu arguments. See wp_page_menu()
     *                    for information on accepted arguments.
     */
    $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('/') . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';
        // If the front page is a page, add it to the exclude list.
        if ('page' === get_option('show_on_front')) {
            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 .= wp_list_pages($list_args);
    $container = sanitize_text_field($args['container']);
    // Fallback in case `wp_nav_menu()` was called without a container.
    if (empty($container)) {
        $container = 'div';
    }
    if ($menu) {
        // wp_nav_menu() doesn't set before and after.
        if (isset($args['fallback_cb']) && 'wp_page_menu' === $args['fallback_cb'] && 'ul' !== $container) {
            $args['before'] = "<ul>{$n}";
            $args['after'] = '</ul>';
        }
        $menu = $args['before'] . $menu . $args['after'];
    }
    $attrs = '';
    if (!empty($args['menu_id'])) {
        $attrs .= ' id="' . esc_attr($args['menu_id']) . '"';
    }
    if (!empty($args['menu_class'])) {
        $attrs .= ' class="' . esc_attr($args['menu_class']) . '"';
    }
    $menu = "<{$container}{$attrs}>" . $menu . "</{$container}>{$n}";
    /**
     * Filters the HTML output of a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param string $menu The HTML output.
     * @param array  $args An array of arguments. See wp_page_menu()
     *                     for information on accepted arguments.
     */
    $menu = apply_filters('wp_page_menu', $menu, $args);
    if ($args['echo']) {
        echo $menu;
    } else {
        return $menu;
    }
}

WordPress Version: 5.5

/**
 * Displays or retrieves a list of pages with an 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.
 *
 * @since 2.7.0
 * @since 4.4.0 Added `menu_id`, `container`, `before`, `after`, and `walker` arguments.
 * @since 4.7.0 Added the `item_spacing` argument.
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments to generate a page menu. See `wp_list_pages()` for additional arguments.
 *
 *     @type string          $sort_column  How to sort the list of pages. Accepts post column names.
 *                                         Default 'menu_order, post_title'.
 *     @type string          $menu_id      ID for the div containing the page list. Default is empty string.
 *     @type string          $menu_class   Class to use for the element containing the page list. Default 'menu'.
 *     @type string          $container    Element to use for the element containing the page list. Default 'div'.
 *     @type bool            $echo         Whether to echo the list or return it. Accepts true (echo) or false (return).
 *                                         Default true.
 *     @type int|bool|string $show_home    Whether to display the link to the home page. Can just enter the text
 *                                         you'd like shown for the home link. 1|true defaults to 'Home'.
 *     @type string          $link_before  The HTML or text to prepend to $show_home text. Default empty.
 *     @type string          $link_after   The HTML or text to append to $show_home text. Default empty.
 *     @type string          $before       The HTML or text to prepend to the menu. Default is '<ul>'.
 *     @type string          $after        The HTML or text to append to the menu. Default is '</ul>'.
 *     @type string          $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve'
 *                                         or 'discard'. Default 'discard'.
 *     @type Walker          $walker       Walker instance to use for listing pages. Default empty (Walker_Page).
 * }
 * @return void|string Void if 'echo' argument is true, HTML menu if 'echo' is false.
 */
function wp_page_menu($args = array())
{
    $defaults = array('sort_column' => 'menu_order, post_title', 'menu_id' => '', 'menu_class' => 'menu', 'container' => 'div', 'echo' => true, 'link_before' => '', 'link_after' => '', 'before' => '<ul>', 'after' => '</ul>', 'item_spacing' => 'discard', 'walker' => '');
    $args = wp_parse_args($args, $defaults);
    if (!in_array($args['item_spacing'], array('preserve', 'discard'), true)) {
        // Invalid value, fall back to default.
        $args['item_spacing'] = $defaults['item_spacing'];
    }
    if ('preserve' === $args['item_spacing']) {
        $t = "\t";
        $n = "\n";
    } else {
        $t = '';
        $n = '';
    }
    /**
     * Filters the arguments used to generate a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param array $args An array of page menu arguments.
     */
    $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('/') . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';
        // If the front page is a page, add it to the exclude list.
        if ('page' === get_option('show_on_front')) {
            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 .= wp_list_pages($list_args);
    $container = sanitize_text_field($args['container']);
    // Fallback in case `wp_nav_menu()` was called without a container.
    if (empty($container)) {
        $container = 'div';
    }
    if ($menu) {
        // wp_nav_menu() doesn't set before and after.
        if (isset($args['fallback_cb']) && 'wp_page_menu' === $args['fallback_cb'] && 'ul' !== $container) {
            $args['before'] = "<ul>{$n}";
            $args['after'] = '</ul>';
        }
        $menu = $args['before'] . $menu . $args['after'];
    }
    $attrs = '';
    if (!empty($args['menu_id'])) {
        $attrs .= ' id="' . esc_attr($args['menu_id']) . '"';
    }
    if (!empty($args['menu_class'])) {
        $attrs .= ' class="' . esc_attr($args['menu_class']) . '"';
    }
    $menu = "<{$container}{$attrs}>" . $menu . "</{$container}>{$n}";
    /**
     * Filters the HTML output of a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param string $menu The HTML output.
     * @param array  $args An array of arguments.
     */
    $menu = apply_filters('wp_page_menu', $menu, $args);
    if ($args['echo']) {
        echo $menu;
    } else {
        return $menu;
    }
}

WordPress Version: 5.4

/**
 * Displays or retrieves a list of pages with an 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.
 *
 * @since 2.7.0
 * @since 4.4.0 Added `menu_id`, `container`, `before`, `after`, and `walker` arguments.
 * @since 4.7.0 Added the `item_spacing` argument.
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments to generate a page menu. See `wp_list_pages()` for additional arguments.
 *
 *     @type string          $sort_column  How to sort the list of pages. Accepts post column names.
 *                                         Default 'menu_order, post_title'.
 *     @type string          $menu_id      ID for the div containing the page list. Default is empty string.
 *     @type string          $menu_class   Class to use for the element containing the page list. Default 'menu'.
 *     @type string          $container    Element to use for the element containing the page list. Default 'div'.
 *     @type bool            $echo         Whether to echo the list or return it. Accepts true (echo) or false (return).
 *                                         Default true.
 *     @type int|bool|string $show_home    Whether to display the link to the home page. Can just enter the text
 *                                         you'd like shown for the home link. 1|true defaults to 'Home'.
 *     @type string          $link_before  The HTML or text to prepend to $show_home text. Default empty.
 *     @type string          $link_after   The HTML or text to append to $show_home text. Default empty.
 *     @type string          $before       The HTML or text to prepend to the menu. Default is '<ul>'.
 *     @type string          $after        The HTML or text to append to the menu. Default is '</ul>'.
 *     @type string          $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve'
 *                                         or 'discard'. Default 'discard'.
 *     @type Walker          $walker       Walker instance to use for listing pages. Default empty (Walker_Page).
 * }
 * @return void|string Void if 'echo' argument is true, HTML menu if 'echo' is false.
 */
function wp_page_menu($args = array())
{
    $defaults = array('sort_column' => 'menu_order, post_title', 'menu_id' => '', 'menu_class' => 'menu', 'container' => 'div', 'echo' => true, 'link_before' => '', 'link_after' => '', 'before' => '<ul>', 'after' => '</ul>', 'item_spacing' => 'discard', 'walker' => '');
    $args = wp_parse_args($args, $defaults);
    if (!in_array($args['item_spacing'], array('preserve', 'discard'))) {
        // Invalid value, fall back to default.
        $args['item_spacing'] = $defaults['item_spacing'];
    }
    if ('preserve' === $args['item_spacing']) {
        $t = "\t";
        $n = "\n";
    } else {
        $t = '';
        $n = '';
    }
    /**
     * Filters the arguments used to generate a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param array $args An array of page menu arguments.
     */
    $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('/') . '">' . $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 .= wp_list_pages($list_args);
    $container = sanitize_text_field($args['container']);
    // Fallback in case `wp_nav_menu()` was called without a container.
    if (empty($container)) {
        $container = 'div';
    }
    if ($menu) {
        // wp_nav_menu() doesn't set before and after.
        if (isset($args['fallback_cb']) && 'wp_page_menu' === $args['fallback_cb'] && 'ul' !== $container) {
            $args['before'] = "<ul>{$n}";
            $args['after'] = '</ul>';
        }
        $menu = $args['before'] . $menu . $args['after'];
    }
    $attrs = '';
    if (!empty($args['menu_id'])) {
        $attrs .= ' id="' . esc_attr($args['menu_id']) . '"';
    }
    if (!empty($args['menu_class'])) {
        $attrs .= ' class="' . esc_attr($args['menu_class']) . '"';
    }
    $menu = "<{$container}{$attrs}>" . $menu . "</{$container}>{$n}";
    /**
     * Filters the HTML output of a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param string $menu The HTML output.
     * @param array  $args An array of arguments.
     */
    $menu = apply_filters('wp_page_menu', $menu, $args);
    if ($args['echo']) {
        echo $menu;
    } else {
        return $menu;
    }
}

WordPress Version: 5.1

/**
 * Displays or retrieves a list of pages with an 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.
 *
 * @since 2.7.0
 * @since 4.4.0 Added `menu_id`, `container`, `before`, `after`, and `walker` arguments.
 * @since 4.7.0 Added the `item_spacing` argument.
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments to generate a page menu. See `wp_list_pages()` for additional arguments.
 *
 *     @type string          $sort_column  How to sort the list of pages. Accepts post column names.
 *                                         Default 'menu_order, post_title'.
 *     @type string          $menu_id      ID for the div containing the page list. Default is empty string.
 *     @type string          $menu_class   Class to use for the element containing the page list. Default 'menu'.
 *     @type string          $container    Element to use for the element containing the page list. Default 'div'.
 *     @type bool            $echo         Whether to echo the list or return it. Accepts true (echo) or false (return).
 *                                         Default true.
 *     @type int|bool|string $show_home    Whether to display the link to the home page. Can just enter the text
 *                                         you'd like shown for the home link. 1|true defaults to 'Home'.
 *     @type string          $link_before  The HTML or text to prepend to $show_home text. Default empty.
 *     @type string          $link_after   The HTML or text to append to $show_home text. Default empty.
 *     @type string          $before       The HTML or text to prepend to the menu. Default is '<ul>'.
 *     @type string          $after        The HTML or text to append to the menu. Default is '</ul>'.
 *     @type string          $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve'
 *                                         or 'discard'. Default 'discard'.
 *     @type Walker          $walker       Walker instance to use for listing pages. Default empty (Walker_Page).
 * }
 * @return string|void HTML menu
 */
function wp_page_menu($args = array())
{
    $defaults = array('sort_column' => 'menu_order, post_title', 'menu_id' => '', 'menu_class' => 'menu', 'container' => 'div', 'echo' => true, 'link_before' => '', 'link_after' => '', 'before' => '<ul>', 'after' => '</ul>', 'item_spacing' => 'discard', 'walker' => '');
    $args = wp_parse_args($args, $defaults);
    if (!in_array($args['item_spacing'], array('preserve', 'discard'))) {
        // invalid value, fall back to default.
        $args['item_spacing'] = $defaults['item_spacing'];
    }
    if ('preserve' === $args['item_spacing']) {
        $t = "\t";
        $n = "\n";
    } else {
        $t = '';
        $n = '';
    }
    /**
     * Filters the arguments used to generate a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param array $args An array of page menu arguments.
     */
    $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('/') . '">' . $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 .= wp_list_pages($list_args);
    $container = sanitize_text_field($args['container']);
    // Fallback in case `wp_nav_menu()` was called without a container.
    if (empty($container)) {
        $container = 'div';
    }
    if ($menu) {
        // wp_nav_menu doesn't set before and after
        if (isset($args['fallback_cb']) && 'wp_page_menu' === $args['fallback_cb'] && 'ul' !== $container) {
            $args['before'] = "<ul>{$n}";
            $args['after'] = '</ul>';
        }
        $menu = $args['before'] . $menu . $args['after'];
    }
    $attrs = '';
    if (!empty($args['menu_id'])) {
        $attrs .= ' id="' . esc_attr($args['menu_id']) . '"';
    }
    if (!empty($args['menu_class'])) {
        $attrs .= ' class="' . esc_attr($args['menu_class']) . '"';
    }
    $menu = "<{$container}{$attrs}>" . $menu . "</{$container}>{$n}";
    /**
     * Filters the HTML output of a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param string $menu The HTML output.
     * @param array  $args An array of arguments.
     */
    $menu = apply_filters('wp_page_menu', $menu, $args);
    if ($args['echo']) {
        echo $menu;
    } else {
        return $menu;
    }
}

WordPress Version: 4.9

/**
 * Displays or retrieves a list of pages with an 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.
 *
 * @since 2.7.0
 * @since 4.4.0 Added `menu_id`, `container`, `before`, `after`, and `walker` arguments.
 * @since 4.7.0 Added the `item_spacing` argument.
 *
 * @param array|string $args {
 *     Optional. Arguments to generate a page menu. See wp_list_pages() for additional arguments.
 *
 *     @type string          $sort_column  How to sort the list of pages. Accepts post column names.
 *                                         Default 'menu_order, post_title'.
 *     @type string          $menu_id      ID for the div containing the page list. Default is empty string.
 *     @type string          $menu_class   Class to use for the element containing the page list. Default 'menu'.
 *     @type string          $container    Element to use for the element containing the page list. Default 'div'.
 *     @type bool            $echo         Whether to echo the list or return it. Accepts true (echo) or false (return).
 *                                         Default true.
 *     @type int|bool|string $show_home    Whether to display the link to the home page. Can just enter the text
 *                                         you'd like shown for the home link. 1|true defaults to 'Home'.
 *     @type string          $link_before  The HTML or text to prepend to $show_home text. Default empty.
 *     @type string          $link_after   The HTML or text to append to $show_home text. Default empty.
 *     @type string          $before       The HTML or text to prepend to the menu. Default is '<ul>'.
 *     @type string          $after        The HTML or text to append to the menu. Default is '</ul>'.
 *     @type string          $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve' or 'discard'. Default 'discard'.
 *     @type Walker          $walker       Walker instance to use for listing pages. Default empty (Walker_Page).
 * }
 * @return string|void HTML menu
 */
function wp_page_menu($args = array())
{
    $defaults = array('sort_column' => 'menu_order, post_title', 'menu_id' => '', 'menu_class' => 'menu', 'container' => 'div', 'echo' => true, 'link_before' => '', 'link_after' => '', 'before' => '<ul>', 'after' => '</ul>', 'item_spacing' => 'discard', 'walker' => '');
    $args = wp_parse_args($args, $defaults);
    if (!in_array($args['item_spacing'], array('preserve', 'discard'))) {
        // invalid value, fall back to default.
        $args['item_spacing'] = $defaults['item_spacing'];
    }
    if ('preserve' === $args['item_spacing']) {
        $t = "\t";
        $n = "\n";
    } else {
        $t = '';
        $n = '';
    }
    /**
     * Filters the arguments used to generate a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param array $args An array of page menu arguments.
     */
    $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('/') . '">' . $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 .= wp_list_pages($list_args);
    $container = sanitize_text_field($args['container']);
    // Fallback in case `wp_nav_menu()` was called without a container.
    if (empty($container)) {
        $container = 'div';
    }
    if ($menu) {
        // wp_nav_menu doesn't set before and after
        if (isset($args['fallback_cb']) && 'wp_page_menu' === $args['fallback_cb'] && 'ul' !== $container) {
            $args['before'] = "<ul>{$n}";
            $args['after'] = '</ul>';
        }
        $menu = $args['before'] . $menu . $args['after'];
    }
    $attrs = '';
    if (!empty($args['menu_id'])) {
        $attrs .= ' id="' . esc_attr($args['menu_id']) . '"';
    }
    if (!empty($args['menu_class'])) {
        $attrs .= ' class="' . esc_attr($args['menu_class']) . '"';
    }
    $menu = "<{$container}{$attrs}>" . $menu . "</{$container}>{$n}";
    /**
     * Filters the HTML output of a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param string $menu The HTML output.
     * @param array  $args An array of arguments.
     */
    $menu = apply_filters('wp_page_menu', $menu, $args);
    if ($args['echo']) {
        echo $menu;
    } else {
        return $menu;
    }
}

WordPress Version: 4.7

/**
 * Displays or retrieves a list of pages with an 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.
 *
 * @since 2.7.0
 * @since 4.4.0 Added `menu_id`, `container`, `before`, `after`, and `walker` arguments.
 * @since 4.7.0 Added the `item_spacing` argument.
 *
 * @param array|string $args {
 *     Optional. Arguments to generate a page menu. See wp_list_pages() for additional arguments.
 *
 *     @type string          $sort_column  How to short the list of pages. Accepts post column names.
 *                                         Default 'menu_order, post_title'.
 *     @type string          $menu_id      ID for the div containing the page list. Default is empty string.
 *     @type string          $menu_class   Class to use for the element containing the page list. Default 'menu'.
 *     @type string          $container    Element to use for the element containing the page list. Default 'div'.
 *     @type bool            $echo         Whether to echo the list or return it. Accepts true (echo) or false (return).
 *                                         Default true.
 *     @type int|bool|string $show_home    Whether to display the link to the home page. Can just enter the text
 *                                         you'd like shown for the home link. 1|true defaults to 'Home'.
 *     @type string          $link_before  The HTML or text to prepend to $show_home text. Default empty.
 *     @type string          $link_after   The HTML or text to append to $show_home text. Default empty.
 *     @type string          $before       The HTML or text to prepend to the menu. Default is '<ul>'.
 *     @type string          $after        The HTML or text to append to the menu. Default is '</ul>'.
 *     @type string          $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve' or 'discard'. Default 'discard'.
 *     @type Walker          $walker       Walker instance to use for listing pages. Default empty (Walker_Page).
 * }
 * @return string|void HTML menu
 */
function wp_page_menu($args = array())
{
    $defaults = array('sort_column' => 'menu_order, post_title', 'menu_id' => '', 'menu_class' => 'menu', 'container' => 'div', 'echo' => true, 'link_before' => '', 'link_after' => '', 'before' => '<ul>', 'after' => '</ul>', 'item_spacing' => 'discard', 'walker' => '');
    $args = wp_parse_args($args, $defaults);
    if (!in_array($args['item_spacing'], array('preserve', 'discard'))) {
        // invalid value, fall back to default.
        $args['item_spacing'] = $defaults['item_spacing'];
    }
    if ('preserve' === $args['item_spacing']) {
        $t = "\t";
        $n = "\n";
    } else {
        $t = '';
        $n = '';
    }
    /**
     * Filters the arguments used to generate a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param array $args An array of page menu arguments.
     */
    $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('/') . '">' . $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 .= wp_list_pages($list_args);
    $container = sanitize_text_field($args['container']);
    // Fallback in case `wp_nav_menu()` was called without a container.
    if (empty($container)) {
        $container = 'div';
    }
    if ($menu) {
        // wp_nav_menu doesn't set before and after
        if (isset($args['fallback_cb']) && 'wp_page_menu' === $args['fallback_cb'] && 'ul' !== $container) {
            $args['before'] = "<ul>{$n}";
            $args['after'] = '</ul>';
        }
        $menu = $args['before'] . $menu . $args['after'];
    }
    $attrs = '';
    if (!empty($args['menu_id'])) {
        $attrs .= ' id="' . esc_attr($args['menu_id']) . '"';
    }
    if (!empty($args['menu_class'])) {
        $attrs .= ' class="' . esc_attr($args['menu_class']) . '"';
    }
    $menu = "<{$container}{$attrs}>" . $menu . "</{$container}>{$n}";
    /**
     * Filters the HTML output of a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param string $menu The HTML output.
     * @param array  $args An array of arguments.
     */
    $menu = apply_filters('wp_page_menu', $menu, $args);
    if ($args['echo']) {
        echo $menu;
    } else {
        return $menu;
    }
}

WordPress Version: 4.6

/**
 * Displays or retrieves a list of pages with an 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.
 *
 * @since 2.7.0
 * @since 4.4.0 Added `menu_id`, `container`, `before`, `after`, and `walker` arguments.
 *
 * @param array|string $args {
 *     Optional. Arguments to generate a page menu. See wp_list_pages() for additional arguments.
 *
 *     @type string          $sort_column How to short the list of pages. Accepts post column names.
 *                                        Default 'menu_order, post_title'.
 *     @type string          $menu_id     ID for the div containing the page list. Default is empty string.
 *     @type string          $menu_class  Class to use for the element containing the page list. Default 'menu'.
 *     @type string          $container   Element to use for the element containing the page list. Default 'div'.
 *     @type bool            $echo        Whether to echo the list or return it. Accepts true (echo) or false (return).
 *                                        Default true.
 *     @type int|bool|string $show_home   Whether to display the link to the home page. Can just enter the text
 *                                        you'd like shown for the home link. 1|true defaults to 'Home'.
 *     @type string          $link_before The HTML or text to prepend to $show_home text. Default empty.
 *     @type string          $link_after  The HTML or text to append to $show_home text. Default empty.
 *     @type string          $before      The HTML or text to prepend to the menu. Default is '<ul>'.
 *     @type string          $after       The HTML or text to append to the menu. Default is '</ul>'.
 *     @type Walker          $walker      Walker instance to use for listing pages. Default empty (Walker_Page).
 * }
 * @return string|void HTML menu
 */
function wp_page_menu($args = array())
{
    $defaults = array('sort_column' => 'menu_order, post_title', 'menu_id' => '', 'menu_class' => 'menu', 'container' => 'div', 'echo' => true, 'link_before' => '', 'link_after' => '', 'before' => '<ul>', 'after' => '</ul>', 'walker' => '');
    $args = wp_parse_args($args, $defaults);
    /**
     * Filters the arguments used to generate a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param array $args An array of page menu arguments.
     */
    $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('/') . '">' . $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));
    $container = sanitize_text_field($args['container']);
    // Fallback in case `wp_nav_menu()` was called without a container.
    if (empty($container)) {
        $container = 'div';
    }
    if ($menu) {
        // wp_nav_menu doesn't set before and after
        if (isset($args['fallback_cb']) && 'wp_page_menu' === $args['fallback_cb'] && 'ul' !== $container) {
            $args['before'] = '<ul>';
            $args['after'] = '</ul>';
        }
        $menu = $args['before'] . $menu . $args['after'];
    }
    $attrs = '';
    if (!empty($args['menu_id'])) {
        $attrs .= ' id="' . esc_attr($args['menu_id']) . '"';
    }
    if (!empty($args['menu_class'])) {
        $attrs .= ' class="' . esc_attr($args['menu_class']) . '"';
    }
    $menu = "<{$container}{$attrs}>" . $menu . "</{$container}>\n";
    /**
     * Filters the HTML output of a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param string $menu The HTML output.
     * @param array  $args An array of arguments.
     */
    $menu = apply_filters('wp_page_menu', $menu, $args);
    if ($args['echo']) {
        echo $menu;
    } else {
        return $menu;
    }
}

WordPress Version: 4.4

/**
 * Display or retrieve list of pages with optional home link.
 *
 * The arguments are listed below and part of the arguments are for {@link
 * wp_list_pages()} function. Check that function for more info on those
 * arguments.
 *
 * @since 2.7.0
 * @since 4.4.0 Added `menu_id`, `container`, `before`, `after`, and `walker` arguments.
 *
 * @param array|string $args {
 *     Optional. Arguments to generate a page menu. See wp_list_pages() for additional arguments.
 *
 *     @type string          $sort_column How to short the list of pages. Accepts post column names.
 *                                        Default 'menu_order, post_title'.
 *     @type string          $menu_id     ID for the div containing the page list. Default is empty string.
 *     @type string          $menu_class  Class to use for the element containing the page list. Default 'menu'.
 *     @type string          $container   Element to use for the element containing the page list. Default 'div'.
 *     @type bool            $echo        Whether to echo the list or return it. Accepts true (echo) or false (return).
 *                                        Default true.
 *     @type int|bool|string $show_home   Whether to display the link to the home page. Can just enter the text
 *                                        you'd like shown for the home link. 1|true defaults to 'Home'.
 *     @type string          $link_before The HTML or text to prepend to $show_home text. Default empty.
 *     @type string          $link_after  The HTML or text to append to $show_home text. Default empty.
 *     @type string          $before      The HTML or text to prepend to the menu. Default is '<ul>'.
 *     @type string          $after       The HTML or text to append to the menu. Default is '</ul>'.
 *     @type Walker          $walker      Walker instance to use for listing pages. Default empty (Walker_Page).
 * }
 * @return string|void HTML menu
 */
function wp_page_menu($args = array())
{
    $defaults = array('sort_column' => 'menu_order, post_title', 'menu_id' => '', 'menu_class' => 'menu', 'container' => 'div', 'echo' => true, 'link_before' => '', 'link_after' => '', 'before' => '<ul>', 'after' => '</ul>', 'walker' => '');
    $args = wp_parse_args($args, $defaults);
    /**
     * Filter the arguments used to generate a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param array $args An array of page menu arguments.
     */
    $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('/') . '">' . $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));
    $container = sanitize_text_field($args['container']);
    // Fallback in case `wp_nav_menu()` was called without a container.
    if (empty($container)) {
        $container = 'div';
    }
    if ($menu) {
        // wp_nav_menu doesn't set before and after
        if (isset($args['fallback_cb']) && 'wp_page_menu' === $args['fallback_cb'] && 'ul' !== $container) {
            $args['before'] = '<ul>';
            $args['after'] = '</ul>';
        }
        $menu = $args['before'] . $menu . $args['after'];
    }
    $attrs = '';
    if (!empty($args['menu_id'])) {
        $attrs .= ' id="' . esc_attr($args['menu_id']) . '"';
    }
    if (!empty($args['menu_class'])) {
        $attrs .= ' class="' . esc_attr($args['menu_class']) . '"';
    }
    $menu = "<{$container}{$attrs}>" . $menu . "</{$container}>\n";
    /**
     * Filter the HTML output of a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param string $menu The HTML output.
     * @param array  $args An array of arguments.
     */
    $menu = apply_filters('wp_page_menu', $menu, $args);
    if ($args['echo']) {
        echo $menu;
    } else {
        return $menu;
    }
}

WordPress Version: 4.3

/**
 * Display or retrieve list of pages with optional home link.
 *
 * The arguments are listed below and part of the arguments are for {@link
 * wp_list_pages()} function. Check that function for more info on those
 * arguments.
 *
 * @since 2.7.0
 *
 * @param array|string $args {
 *     Optional. Arguments to generate a page menu. See wp_list_pages() for additional arguments.
 *
 *     @type string          $sort_column How to short the list of pages. Accepts post column names.
 *                                        Default 'menu_order, post_title'.
 *     @type string          $menu_class  Class to use for the div ID containing the page list. Default 'menu'.
 *     @type bool            $echo        Whether to echo the list or return it. Accepts true (echo) or false (return).
 *                                        Default true.
 *     @type string          $link_before The HTML or text to prepend to $show_home text. Default empty.
 *     @type string          $link_after  The HTML or text to append to $show_home text. Default empty.
 *     @type int|bool|string $show_home   Whether to display the link to the home page. Can just enter the text
 *                                        you'd like shown for the home link. 1|true defaults to 'Home'.
 * }
 * @return string|void HTML menu
 */
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);
    /**
     * Filter the arguments used to generate a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param array $args An array of page menu arguments.
     */
    $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('/') . '">' . $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";
    /**
     * Filter the HTML output of a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param string $menu The HTML output.
     * @param array  $args An array of arguments.
     */
    $menu = apply_filters('wp_page_menu', $menu, $args);
    if ($args['echo']) {
        echo $menu;
    } else {
        return $menu;
    }
}

WordPress Version: 4.2

/**
 * Display or retrieve list of pages with optional home link.
 *
 * The arguments are listed below and part of the arguments are for {@link
 * wp_list_pages()} function. Check that function for more info on those
 * arguments.
 *
 * @since 2.7.0
 *
 * @param array|string $args {
 *     Optional. Arguments to generate a page menu. See wp_list_pages() for additional arguments.
 *
 *     @type string          $sort_column How to short the list of pages. Accepts post column names.
 *                                        Default 'menu_order, post_title'.
 *     @type string          $menu_class  Class to use for the div ID containing the page list. Default 'menu'.
 *     @type bool            $echo        Whether to echo the list or return it. Accepts true (echo) or false (return).
 *                                        Default true.
 *     @type string          $link_before The HTML or text to prepend to $show_home text. Default empty.
 *     @type string          $link_after  The HTML or text to append to $show_home text. Default empty.
 *     @type int|bool|string $show_home   Whether to display the link to the home page. Can just enter the text
 *                                        you'd like shown for the home link. 1|true defaults to 'Home'.
 * }
 * @return string html menu
 */
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);
    /**
     * Filter the arguments used to generate a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param array $args An array of page menu arguments.
     */
    $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('/') . '">' . $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";
    /**
     * Filter the HTML output of a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param string $menu The HTML output.
     * @param array  $args An array of arguments.
     */
    $menu = apply_filters('wp_page_menu', $menu, $args);
    if ($args['echo']) {
        echo $menu;
    } else {
        return $menu;
    }
}

WordPress Version: 4.0

/**
 * Display or retrieve list of pages with optional home link.
 *
 * The arguments are listed below and part of the arguments are for {@link
 * wp_list_pages()} function. Check that function for more info on those
 * arguments.
 *
 * @since 2.7.0
 *
 * @param array|string $args {
 *     Optional. Arguments to generate a page menu. {@see wp_list_pages()}
 *     for additional arguments.
 *
 * @type string     $sort_column How to short the list of pages. Accepts post column names.
 *                               Default 'menu_order, post_title'.
 * @type string     $menu_class  Class to use for the div ID containing the page list. Default 'menu'.
 * @type bool       $echo        Whether to echo the list or return it. Accepts true (echo) or false (return).
 *                               Default true.
 * @type string     $link_before The HTML or text to prepend to $show_home text. Default empty.
 * @type string     $link_after  The HTML or text to append to $show_home text. Default empty.
 * @type int|string $show_home   Whether to display the link to the home page. Can just enter the text
 *                               you'd like shown for the home link. 1|true defaults to 'Home'.
 * }
 * @return string html menu
 */
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);
    /**
     * Filter the arguments used to generate a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param array $args An array of page menu arguments.
     */
    $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('/') . '">' . $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";
    /**
     * Filter the HTML output of a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param string $menu The HTML output.
     * @param array  $args An array of arguments.
     */
    $menu = apply_filters('wp_page_menu', $menu, $args);
    if ($args['echo']) {
        echo $menu;
    } else {
        return $menu;
    }
}

WordPress Version: 3.9

/**
 * Display or retrieve list of pages with optional home link.
 *
 * The arguments are listed below and part of the arguments are for {@link
 * wp_list_pages()} function. Check that function for more info on those
 * arguments.
 *
 * <ul>
 * <li><strong>sort_column</strong> - How to sort the list of pages. Defaults
 * to 'menu_order, post_title'. Use column for posts table.</li>
 * <li><strong>menu_class</strong> - Class to use for the div ID which contains
 * the page list. Defaults to 'menu'.</li>
 * <li><strong>echo</strong> - Whether to echo list or return it. Defaults to
 * echo.</li>
 * <li><strong>link_before</strong> - Text before show_home argument text.</li>
 * <li><strong>link_after</strong> - Text after show_home argument text.</li>
 * <li><strong>show_home</strong> - If you set this argument, then it will
 * display the link to the home page. The show_home argument really just needs
 * to be set to the value of the text of the link.</li>
 * </ul>
 *
 * @since 2.7.0
 *
 * @param array|string $args
 * @return string html menu
 */
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);
    /**
     * Filter the arguments used to generate a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param array $args An array of page menu arguments.
     */
    $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('/') . '">' . $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";
    /**
     * Filter the HTML output of a page-based menu.
     *
     * @since 2.7.0
     *
     * @see wp_page_menu()
     *
     * @param string $menu The HTML output.
     * @param array  $args An array of arguments.
     */
    $menu = apply_filters('wp_page_menu', $menu, $args);
    if ($args['echo']) {
        echo $menu;
    } else {
        return $menu;
    }
}

WordPress Version: 3.7

/**
 * Display or retrieve list of pages with optional home link.
 *
 * The arguments are listed below and part of the arguments are for {@link
 * wp_list_pages()} function. Check that function for more info on those
 * arguments.
 *
 * <ul>
 * <li><strong>sort_column</strong> - How to sort the list of pages. Defaults
 * to 'menu_order, post_title'. Use column for posts table.</li>
 * <li><strong>menu_class</strong> - Class to use for the div ID which contains
 * the page list. Defaults to 'menu'.</li>
 * <li><strong>echo</strong> - Whether to echo list or return it. Defaults to
 * echo.</li>
 * <li><strong>link_before</strong> - Text before show_home argument text.</li>
 * <li><strong>link_after</strong> - Text after show_home argument text.</li>
 * <li><strong>show_home</strong> - If you set this argument, then it will
 * display the link to the home page. The show_home argument really just needs
 * to be set to the value of the text of the link.</li>
 * </ul>
 *
 * @since 2.7.0
 *
 * @param array|string $args
 * @return string html menu
 */
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('/') . '">' . $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;
    }
}