Skip to content

Commit e4c896a

Browse files
committed
Add crawledSitePath option
- Add crawledSitePath option that can be configured and filtered by option hooks. - Remove separate crawled_site_path hook.
1 parent d42e094 commit e4c896a

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

src/CoreOptions.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,13 @@ public static function optionSpecs(): array {
254254
'Crawl Concurrency',
255255
'The maximum number of files that will be crawled at the same time.'
256256
),
257+
self::makeOptionSpec(
258+
'string',
259+
'crawledSitePath',
260+
'wp2static-crawled-site',
261+
'Crawled Site Path',
262+
'Path to the crawled site files.'
263+
),
257264
self::makeOptionSpec(
258265
'array',
259266
'pathsToIgnore',
@@ -849,6 +856,17 @@ public static function savePosted( string $screen = 'core' ): void {
849856
[ 'name' => 'crawlConcurrency' ]
850857
);
851858

859+
$wpdb->update(
860+
$table_name,
861+
[
862+
'value' =>
863+
sanitize_text_field(
864+
strval( filter_input( INPUT_POST, 'crawledSitePath' ) )
865+
),
866+
],
867+
[ 'name' => 'crawledSitePath' ]
868+
);
869+
852870
$paths_to_ignore = preg_replace(
853871
'/^\s+|\s+$/m',
854872
'',

src/StaticSite.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ public static function add( string $path, string $contents ): void {
3434
}
3535

3636
public static function getPath(): string {
37-
return apply_filters(
38-
Controller::getHookName( 'crawled_site_path' ),
39-
SiteInfo::getPath( 'uploads' ) . 'wp2static-crawled-site'
40-
);
37+
return SiteInfo::getPath( 'uploads' ) . CoreOptions::getValue( 'crawledSitePath' );
4138
}
4239

4340
/**

tests/integration/ITTrait.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ public function wpCli( array $args, array $expect_warnings = [] ): array
4848
public function getCrawledFileContents( string $path ): string
4949
{
5050
$wordpress_dir = ITEnv::getWordPressDir();
51-
$crawled_site_dir = $wordpress_dir . '/wp-content/uploads/wp2static-crawled-site';
51+
$crawled_site_dir = $wordpress_dir .
52+
'/wp-content/uploads/' .
53+
$this->getOptionValue( 'crawledSitePath' );
5254
$content = file_get_contents( "{$crawled_site_dir}/$path" );
5355
$this->assertNotFalse( $content, "Failed to read file: {$crawled_site_dir}/$path" );
5456
return $content;

views/advanced-options-page.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353

5454
<table class="widefat striped">
5555
<tbody>
56+
<?php echo $row( 'crawledSitePath' ); ?>
5657
<?php echo $row( 'crawlConcurrency' ); ?>
5758
</tbody>
5859
</table>

0 commit comments

Comments
 (0)