From 0d7e33a0895b33b23ab3532662e97e6f954b35b7 Mon Sep 17 00:00:00 2001
From: Mahmoud Al-Qudsi <mqudsi@neosmart.net>
Date: Wed, 20 Sep 2017 12:06:36 -0500
Subject: [PATCH] Fix undefined offset -1 notice in $pages array in
post-template.php
If no pages are defined, WordPress attempts to access $pages[$page - 1]
which evaluates to $pages[-1], causing a notice to be shown.
---
wp-includes/post-template.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php
index 3734373..1328bc4 100644
a
|
b
|
function get_the_content( $more_link_text = null, $strip_teaser = false ) { |
284 | 284 | if ( $page > count( $pages ) ) // if the requested page doesn't exist |
285 | 285 | $page = count( $pages ); // give them the highest numbered page that DOES exist |
286 | 286 | |
| 287 | if ( $page == 0 ) { // if there aren't multiple pages |
| 288 | $page = 1; // show the only page |
| 289 | } |
| 290 | |
287 | 291 | $content = $pages[$page - 1]; |
288 | 292 | if ( preg_match( '/<!--more(.*?)?-->/', $content, $matches ) ) { |
289 | 293 | $content = explode( $matches[0], $content, 2 ); |