PluginProbe
Faust.js / 1.0.2
Faust.js v1.0.2
1.8.12 1.8.11 1.4.1 1.8.0 1.8.8 1.8.9 trunk 0.7.0 0.7.1 0.7.10 0.7.11 0.7.3 0.7.4 0.7.5 0.7.6 0.7.7 0.7.8 0.7.9 0.8.0 0.8.1 0.8.3 0.8.4 0.8.5 0.8.6 0.8.7 All 40 releases
← All changes | includes/replacement/graphql-callbacks.php +19 -3 0.7.0 → 1.0.2 View file →
@@ -7,8 +7,9 @@
7 7
8 8 namespace WPE\FaustWP\Replacement;
9 9
10 10 use function WPE\FaustWP\Settings\faustwp_get_setting;
11 +use function WPE\FaustWP\Replacement\has_file_extension;
11 12
12 13 if ( ! defined( 'ABSPATH' ) ) {
13 14 exit;
14 15 }
@@ -40,18 +41,33 @@
40 41
41 42 return $response;
42 43 }
43 44
45 +/**
46 + * Replaces the WordPress Site URL with the replacement domain
47 + * in 'url' and 'href' fields, skipping over values with file extensions.
48 + *
49 + * @param array $data The response data.
50 + */
44 51 function url_replace_recursive( &$data ) {
45 52 foreach ( $data as $key => &$value ) {
46 - if ( $key === 'generalSettings' ) {
53 + // Exclude generalSettings from URL replacement.
54 + if ( 'generalSettings' === $key ) {
47 55 continue;
48 56 }
49 57
50 - if ( ( 'url' === $key || 'href' === $key ) && is_string( $value ) ) {
58 + if (
59 + ( 'url' === $key || 'href' === $key ) &&
60 + is_string( $value ) &&
61 + ! has_file_extension( $value )
62 + ) {
51 63 $replacement = faustwp_get_setting( 'frontend_uri', '/' );
52 64 $value = str_replace( site_url(), $replacement, $value );
53 - } else if ( is_array( $value ) ) {
65 + } elseif ( ( 'path' === $key && is_multisite() ) && is_string( $value ) ) {
66 + $site = get_site();
67 + $subdirectory = untrailingslashit( $site->path );
68 + $value = str_replace( $subdirectory, '', $value );
69 + } elseif ( is_array( $value ) ) {
54 70 url_replace_recursive( $value );
55 71 }
56 72 }
57 73 }