Make WordPress Core

Ticket #43463: 0001-Handle-negative-page-indexes-in-get_the_content.patch

File 0001-Handle-negative-page-indexes-in-get_the_content.patch, 976 bytes (added by ComputerGuru, 8 years ago)
  • wp-includes/post-template.php

    From d7599e834d681ec6cdfc48baa6ae9e93849541c7 Mon Sep 17 00:00:00 2001
    From: Mahmoud Al-Qudsi <mqudsi@neosmart.net>
    Date: Sat, 3 Mar 2018 19:31:00 -0600
    Subject: [PATCH] Handle negative page indexes in get_the_content
    
    ---
     wp-includes/post-template.php | 3 +++
     1 file changed, 3 insertions(+)
    
    diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php
    index 9bbfd764b0..35804c5c59 100644
    a b function get_the_content( $more_link_text = null, $strip_teaser = false ) { 
    292292        if ( $page > count( $pages ) ) { // if the requested page doesn't exist
    293293                $page = count( $pages ); // give them the highest numbered page that DOES exist
    294294        }
     295        else if ( $page < 1 ) { // or if the requested page was zero or not set
     296                $page = 1; // return the first page instead
     297        }
    295298
    296299        $content = $pages[ $page - 1 ];
    297300        if ( preg_match( '/<!--more(.*?)?-->/', $content, $matches ) ) {