Skip to content

Commit d4de841

Browse files
committed
v 0.126.2
Diagnostic : detect pages with empty titles or invalid slugs.
1 parent 47d0e7c commit d4de841

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

tools/diagnostic/inc/40-wordpress.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ function wputools_test_rss_feed($rss_url) {
695695

696696
$empty_pages = array();
697697
$lorem_pages = array();
698+
$empty_titles = array();
699+
$invalid_slugs = array();
698700
foreach ($all_posts as $p) {
699701
if (empty($p->post_content) && empty($p->post_excerpt)) {
700702
$empty_pages[] = get_permalink($p) . ' (' . $p->post_type . ')';
@@ -706,6 +708,12 @@ function wputools_test_rss_feed($rss_url) {
706708
}
707709
}
708710
}
711+
if (empty($p->post_title)) {
712+
$empty_titles[] = get_permalink($p) . ' (' . $p->post_type . ')';
713+
}
714+
if ($p->post_name == $p->ID || (is_numeric($p->post_name) && $p->post_title && !is_numeric($p->post_title))) {
715+
$invalid_slugs[] = get_permalink($p) . ' (' . $p->post_type . ')';
716+
}
709717
}
710718

711719
if (!empty($empty_pages)) {
@@ -716,6 +724,14 @@ function wputools_test_rss_feed($rss_url) {
716724
$wputools_errors[] = sprintf("The following posts contains some lorem ipsum: \n-- %s", implode("\n-- ", $lorem_pages));
717725
}
718726

727+
if (!empty($empty_titles)) {
728+
$wputools_errors[] = sprintf("The following posts don't have any title: \n-- %s", implode("\n-- ", $empty_titles));
729+
}
730+
731+
if (!empty($invalid_slugs)) {
732+
$wputools_errors[] = sprintf("The following posts have an invalid slug: \n-- %s", implode("\n-- ", $invalid_slugs));
733+
}
734+
719735
/* ----------------------------------------------------------
720736
Check image sizes
721737
---------------------------------------------------------- */

wputools.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
WPUTools(){
44

5-
local _WPUTOOLS_VERSION='0.126.1';
5+
local _WPUTOOLS_VERSION='0.126.2';
66
local _PHP_VERSIONS=(7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4 8.5 9.0)
77
local _PHP_VERSIONS_OBSOLETES=(7.0 7.1 7.2 7.3 7.4 8.0)
88
local _PHP_VERSIONS_ADVANCED=(8.3 8.4 8.5 9.0)

0 commit comments

Comments
 (0)