Skip to content

Commit b38f143

Browse files
committed
Merge branch 'master' of github.com:leonstafford/static-html-output
2 parents 6185ddc + 8655ced commit b38f143

File tree

1 file changed

+37
-45
lines changed

1 file changed

+37
-45
lines changed

src/WPSite.php

Lines changed: 37 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -162,48 +162,45 @@ public function __construct() {
162162
}
163163

164164
public function __toString() {
165-
$wpsite_string = '';
166-
167-
$wpsite_string .= "Site Path: $this->site_path" . PHP_EOL;
168-
$wpsite_string .= "WP Uploads URL: $this->wp_uploads_url" . PHP_EOL;
169-
$wpsite_string .= "WP Uploads Path: $this->wp_uploads_path" . PHP_EOL;
170-
$wpsite_string .= "WP Uploads ??: $this->wp_uploads" . PHP_EOL;
171-
$wpsite_string .= "WP Site Path: $this->wp_site_path" . PHP_EOL;
172-
$wpsite_string .= "WP Site Subdirectory: $this->wp_site_subdir" . PHP_EOL;
173-
$wpsite_string .= "Uploads URL: $this->uploads_url" . PHP_EOL;
174-
$wpsite_string .= "Site URL: $this->site_url" . PHP_EOL;
175-
$wpsite_string .= "Parent Theme URL: $this->parent_theme_url" . PHP_EOL;
176-
$wpsite_string .= "Parent Theme Path: $this->parent_theme_path" . PHP_EOL;
177-
$wpsite_string .= "Child Theme Path: $this->child_theme_path" . PHP_EOL;
178-
$wpsite_string .= "Child Theme Active: $this->child_theme_active" . PHP_EOL;
179-
$wpsite_string .= "Theme Root Path: $this->theme_root_path" . PHP_EOL;
180-
$wpsite_string .= "Themes ??: $this->wp_themes" . PHP_EOL;
181-
$wpsite_string .= "Active Theme ??: $this->wp_active_theme" . PHP_EOL;
182-
$wpsite_string .= "WP Content URL: $this->wp_content_url" . PHP_EOL;
183-
$wpsite_string .= "WP Content Path: $this->wp_content_path" . PHP_EOL;
184-
$wpsite_string .= "WP Content ??: $this->wp_content" . PHP_EOL;
185-
$wpsite_string .= "Plugins Path: $this->plugins_path" . PHP_EOL;
186-
$wpsite_string .= "WP Plugins ??: $this->wp_plugins" . PHP_EOL;
187-
$wpsite_string .= "WP Includes Path: $this->wp_includes_path" . PHP_EOL;
188-
$wpsite_string .= "Permalink Structure: $this->permalink_structure" . PHP_EOL;
189-
$wpsite_string .= "WP Inc Path: $this->wp_inc" . PHP_EOL;
190-
$wpsite_string .= "Subdirectory install?: $this->subdirectory" . PHP_EOL;
191-
192-
return $wpsite_string;
165+
return implode(
166+
PHP_EOL,
167+
[
168+
"Site Path: {$this->site_path}",
169+
"WP Uploads URL: {$this->wp_uploads_url}",
170+
"WP Uploads Path: {$this->wp_uploads_path}",
171+
"WP Uploads ??: {$this->wp_uploads}",
172+
"WP Site Path: {$this->wp_site_path}",
173+
"WP Site Subdirectory: {$this->wp_site_subdir}",
174+
"Uploads URL: {$this->uploads_url}",
175+
"Site URL: {$this->site_url}",
176+
"Parent Theme URL: {$this->parent_theme_url}",
177+
"Parent Theme Path: {$this->parent_theme_path}",
178+
"Child Theme Path: {$this->child_theme_path}",
179+
"Child Theme Active: {$this->child_theme_active}",
180+
"Theme Root Path: {$this->theme_root_path}",
181+
"Themes ??: {$this->wp_themes}",
182+
"Active Theme ??: {$this->wp_active_theme}",
183+
"WP Content URL: {$this->wp_content_url}",
184+
"WP Content Path: {$this->wp_content_path}",
185+
"WP Content ??: {$this->wp_content}",
186+
"Plugins Path: {$this->plugins_path}",
187+
"WP Plugins ??: {$this->wp_plugins}",
188+
"WP Includes Path: {$this->wp_includes_path}",
189+
"Permalink Structure: {$this->permalink_structure}",
190+
"WP Inc Path: {$this->wp_inc}",
191+
"Subdirectory install?: {$this->subdirectory}",
192+
]
193+
) . PHP_EOL;
193194
}
194195

195196
public function isSiteInstalledInSubDirectory() : string {
196197
$parsed_site_url = parse_url( rtrim( $this->site_url, '/' ) );
197198

198-
if ( ! is_array( $parsed_site_url ) ) {
199+
if ( ! is_array( $parsed_site_url ) || ! array_key_exists( 'path', $parsed_site_url ) ) {
199200
return '';
200201
}
201202

202-
if ( array_key_exists( 'path', $parsed_site_url ) ) {
203-
return $parsed_site_url['path'];
204-
}
205-
206-
return '';
203+
return $parsed_site_url['path'];
207204
}
208205

209206
public function uploadsPathIsWritable() : bool {
@@ -219,8 +216,8 @@ public function permalinksAreDefined() : bool {
219216
}
220217

221218
public function detect_base_url() : void {
222-
$site_url = get_option( 'siteurl' );
223-
$home = get_option( 'home' );
219+
$this->site_url = get_option( 'siteurl' );
220+
$this->home = get_option( 'home' );
224221
}
225222

226223
/*
@@ -310,11 +307,7 @@ public function getLastPathSegment( string $path ) : string {
310307
public function getWPContentSubDirectory() : string {
311308
$parsed_url = parse_url( $this->parent_theme_url );
312309

313-
if ( ! is_array( $parsed_url ) ) {
314-
return '';
315-
}
316-
317-
if ( ! array_key_exists( 'path', $parsed_url ) ) {
310+
if ( ! is_array( $parsed_url ) || ! array_key_exists( 'path', $parsed_url ) ) {
318311
return '';
319312
}
320313

@@ -331,11 +324,10 @@ public function getWPContentSubDirectory() : string {
331324
332325
*/
333326

334-
if ( count( $path_segments ) === 5 ) {
335-
return $path_segments[1] . '/';
336-
} else {
327+
if ( count( $path_segments ) !== 5 ) {
337328
return '';
338329
}
330+
331+
return $path_segments[1] . '/';
339332
}
340333
}
341-

0 commit comments

Comments
 (0)