Skip to content
This repository has been archived by the owner on Feb 23, 2019. It is now read-only.

Commit

Permalink
a tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
amiga-500 committed Feb 13, 2017
1 parent 8a47961 commit 972c023
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions Util_PageUrls.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,32 +92,33 @@ static public function get_post_urls( $post_id ) {
if ( !isset( $post_urls[$post_id] ) ) {
$full_urls = array();
$post = get_post( $post_id );

// On the admin page when changing a post type to "Draft" or "Pending Review"
// the get_permalink() returns back in the form: http://foo.bar/?p=###
// even if the site's permalink setting is different (e.g. http://foo.bar/post-name/).
// When this happens the post can potentially not get flushed.
// Setting the "post_status" to empty forces get_permalink() to return
// the correct url for flushing.

$post->post_status = "";
$post_link = get_permalink( $post );
$post_uri = str_replace( Util_Environment::home_domain_root_url(), '', $post_link );

$full_urls[] = $post_link;
$uris[] = $post_uri;
$matches =array();
if ( $post && ( $post_pages_number = preg_match_all( '/\<\!\-\-nextpage\-\-\>/', $post->post_content, $matches ) )>0 ) {
global $wp_rewrite;
$post_pages_number++;
for ( $pagenum = 2; $pagenum <= $post_pages_number; $pagenum++ ) {
if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post->ID )
$post_pagenum_link = trailingslashit( $post_link ) . user_trailingslashit( "$wp_rewrite->pagination_base/" . $pagenum, 'single_paged' );
else
$post_pagenum_link = trailingslashit( $post_link ) . user_trailingslashit( $pagenum, 'single_paged' );
$full_urls[] = $post_pagenum_link;
if ( $post ) {
// On the admin page when changing a post type to "Draft" or "Pending Review"
// the get_permalink() returns back in the form: http://foo.bar/?p=###
// even if the site's permalink setting is different (e.g. http://foo.bar/post-name/).
// When this happens the post can potentially not get flushed.
// Setting the "post_status" to empty forces get_permalink() to return
// the correct url for flushing.

$post->post_status = "";
$post_link = get_permalink( $post );
$post_uri = str_replace( Util_Environment::home_domain_root_url(), '', $post_link );

$full_urls[] = $post_link;
$uris[] = $post_uri;
$matches =array();
if ( $post && ( $post_pages_number = preg_match_all( '/\<\!\-\-nextpage\-\-\>/', $post->post_content, $matches ) )>0 ) {
global $wp_rewrite;
$post_pages_number++;
for ( $pagenum = 2; $pagenum <= $post_pages_number; $pagenum++ ) {
if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post->ID )
$post_pagenum_link = trailingslashit( $post_link ) . user_trailingslashit( "$wp_rewrite->pagination_base/" . $pagenum, 'single_paged' );
else
$post_pagenum_link = trailingslashit( $post_link ) . user_trailingslashit( $pagenum, 'single_paged' );
$full_urls[] = $post_pagenum_link;
}
}
}
}
$post_urls[$post_id] = $full_urls;
}
return $post_urls[$post_id];
Expand Down

0 comments on commit 972c023

Please sign in to comment.