Skip to content

Commit d329f00

Browse files
committed
Reorder detection so that files come first
We have multiple ways to discover paths, and some come with a filename while others don't. Only the first version of a detected URL is crawled. Reorder detection so that in the event of a duplicate, we will get the filename detected before we get a version without the filename.
1 parent 5184e32 commit d329f00

1 file changed

Lines changed: 25 additions & 40 deletions

File tree

src/URLDetector.php

Lines changed: 25 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ public static function detectURLsIter( bool $quiet = false ) : \Iterator {
4242

4343
$arrays_to_merge = [];
4444

45-
// TODO: detect robots.txt, etc before adding
4645
$arrays_to_merge[] = [
4746
'/',
4847
'/robots.txt',
@@ -52,45 +51,6 @@ public static function detectURLsIter( bool $quiet = false ) : \Iterator {
5251

5352
$iterators_to_merge = [];
5453

55-
/*
56-
TODO: reimplement detection for URLs:
57-
'detectCommentPagination',
58-
'detectComments',
59-
'detectFeedURLs',
60-
61-
// other options:
62-
63-
- robots
64-
- favicon
65-
- sitemaps
66-
67-
*/
68-
69-
if ( CoreOptions::getValue( 'detectPosts' ) ) {
70-
$arrays_to_merge[] = DetectPostURLs::detect();
71-
}
72-
73-
if ( CoreOptions::getValue( 'detectPages' ) ) {
74-
$arrays_to_merge[] = DetectPageURLs::detect();
75-
}
76-
77-
if ( CoreOptions::getValue( 'detectCustomPostTypes' ) ) {
78-
$arrays_to_merge[] = DetectCustomPostTypeURLs::detect();
79-
}
80-
81-
if ( CoreOptions::getValue( 'detectUploads' ) ) {
82-
$iterators_to_merge[] =
83-
$filtering->getListOfLocalFilesByDir(
84-
SiteInfo::getPath( 'uploads' ),
85-
);
86-
}
87-
88-
$detect_sitemaps = apply_filters( 'wp2static_detect_sitemaps', 1 );
89-
90-
if ( $detect_sitemaps ) {
91-
$arrays_to_merge[] = DetectSitemapsURLs::detect( SiteInfo::getURL( 'site' ) );
92-
}
93-
9454
$detect_parent_theme = apply_filters( 'wp2static_detect_parent_theme', 1 );
9555

9656
if ( $detect_parent_theme ) {
@@ -115,12 +75,37 @@ public static function detectURLsIter( bool $quiet = false ) : \Iterator {
11575
$iterators_to_merge[] = DetectWPIncludesAssets::detect( $filtering );
11676
}
11777

78+
if ( CoreOptions::getValue( 'detectUploads' ) ) {
79+
$iterators_to_merge[] =
80+
$filtering->getListOfLocalFilesByDir(
81+
SiteInfo::getPath( 'uploads' ),
82+
);
83+
}
84+
11885
$detect_vendor_cache = apply_filters( 'wp2static_detect_vendor_cache', 1 );
11986

12087
if ( $detect_vendor_cache ) {
12188
$iterators_to_merge[] = DetectVendorFiles::detect( $filtering, SiteInfo::getURL( 'site' ) );
12289
}
12390

91+
$detect_sitemaps = apply_filters( 'wp2static_detect_sitemaps', 1 );
92+
93+
if ( $detect_sitemaps ) {
94+
$arrays_to_merge[] = DetectSitemapsURLs::detect( SiteInfo::getURL( 'site' ) );
95+
}
96+
97+
if ( CoreOptions::getValue( 'detectPosts' ) ) {
98+
$arrays_to_merge[] = DetectPostURLs::detect();
99+
}
100+
101+
if ( CoreOptions::getValue( 'detectPages' ) ) {
102+
$arrays_to_merge[] = DetectPageURLs::detect();
103+
}
104+
105+
if ( CoreOptions::getValue( 'detectCustomPostTypes' ) ) {
106+
$arrays_to_merge[] = DetectCustomPostTypeURLs::detect();
107+
}
108+
124109
$detect_posts_pagination = apply_filters( 'wp2static_detect_posts_pagination', 1 );
125110

126111
if ( $detect_posts_pagination ) {

0 commit comments

Comments
 (0)