get_page_permastruct example

/** * Retrieves all of the rewrite rules for pages. * * @since 1.5.0 * * @return string[] Page rewrite rules. */
    public function page_rewrite_rules() {
        // The extra .? at the beginning prevents clashes with other regular expressions in the rules array.         $this->add_rewrite_tag( '%pagename%', '(.?.+?)', 'pagename=' );

        return $this->generate_rewrite_rules( $this->get_page_permastruct(), EP_PAGES, true, true, false, false );
    }

    /** * Retrieves date permalink structure, with year, month, and day. * * The permalink structure for the date, if not set already depends on the * permalink structure. It can be one of three formats. The first is year, * month, day; the second is day, month, year; and the last format is month, * day, year. These are matched against the permalink structure for which * one is used. If none matches, then the default will be used, which is * year, month, day. * * Prevents post ID and date permalinks from overlapping. In the case of * post_id, the date permalink will be prepended with front permalink with * 'date/' before the actual permalink to form the complete date permalink * structure. * * @since 1.5.0 * * @return string|false Date permalink structure on success, false on failure. */

function _get_page_link( $post = false, $leavename = false, $sample = false ) {
    global $wp_rewrite;

    $post = get_post( $post );

    $force_plain_link = wp_force_plain_post_permalink( $post );

    $link = $wp_rewrite->get_page_permastruct();

    if ( ! empty( $link ) && ( ( isset( $post->post_status ) && ! $force_plain_link ) || $sample ) ) {
        if ( ! $leavename ) {
            $link = str_replace( '%pagename%', get_page_uri( $post )$link );
        }

        $link = home_url( $link );
        $link = user_trailingslashit( $link, 'page' );
    } else {
        $link = home_url( '?page_id=' . $post->ID );
    }

    
Home | Imprint | This part of the site doesn't use cookies.