| | 1992 | * Retrieve page parents with separator. |
| | 1993 | * |
| | 1994 | * @since 2.8 |
| | 1995 | * |
| | 1996 | * @param int $id Page ID. |
| | 1997 | * @param bool $link Optional, default is false. Whether to format with link. |
| | 1998 | * @param string $separator Optional, default is '/'. How to separate pages. |
| | 1999 | * @param bool $nicename Optional, default is false. Whether to use nice name for display. |
| | 2000 | * @param array $visited Optional. Already linked to pages to prevent duplicates. |
| | 2001 | * @return string |
| | 2002 | */ |
| | 2003 | function get_page_parents( $id, $link = false, $separator = '/', $nicename = false, $visited = array() ) { |
| | 2004 | $chain = ''; |
| | 2005 | $parent = &get_page( $id ); |
| | 2006 | if ( is_wp_error( $parent ) ) |
| | 2007 | return $parent; |
| | 2008 | |
| | 2009 | if ( $nicename ) |
| | 2010 | $name = $parent->post_name; |
| | 2011 | else |
| | 2012 | $name = $parent->post_title; |
| | 2013 | |
| | 2014 | if ( $parent->post_parent && ( $parent->post_parent != $parent->ID ) && !in_array( $parent->post_parent, $visited ) ) { |
| | 2015 | $visited[] = $parent->post_parent; |
| | 2016 | $chain .= get_page_parents( $parent->post_parent, $link, $separator, $nicename, $visited ); |
| | 2017 | } |
| | 2018 | |
| | 2019 | if ( $link ) |
| | 2020 | $chain .= '<a href="' . get_page_link( $parent->ID ) . '" title="' . $parent->post_title . '">'.$name.'</a>' . $separator; |
| | 2021 | else |
| | 2022 | $chain .= $name.$separator; |
| | 2023 | return $chain; |
| | 2024 | } |
| | 2025 | |
| | 2026 | /** |