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/functions.php +7 -93 trunk1.0.2 View file →
@@ -4,16 +4,13 @@
4 4 *
5 5 * @package FaustWP
6 6 */
7 7
8 -declare(strict_types=1);
9 -
10 8 namespace WPE\FaustWP\Replacement;
11 9
12 10 use function WPE\FaustWP\Settings\{
13 11 faustwp_get_setting,
14 - is_rewrites_enabled,
15 - use_wp_domain_for_post_and_category_urls,
12 + is_rewrites_enabled
16 13 };
17 14
18 15 if ( ! defined( 'ABSPATH' ) ) {
19 16 exit;
@@ -21,8 +18,10 @@
21 18
22 19 /**
23 20 * Determine if domain replacement can be done.
24 21 *
22 + * Enabled if query string parameter 'replace-domain' is present.
23 + *
25 24 * @return bool True if can proceed with replacement, false if else.
26 25 */
27 26 function domain_replacement_enabled() {
28 27 /**
@@ -31,9 +30,9 @@
31 30 * Used to override or extend if domain replacement is enabled.
32 31 *
33 32 * @param bool $enabled True if domain replacement is enabled, false if else.
34 33 */
35 - return apply_filters( 'faustwp_domain_replacement_enabled', ! use_wp_domain_for_post_and_category_urls() );
34 + return apply_filters( 'faustwp_domain_replacement_enabled', is_rewrites_enabled() );
36 35 }
37 36
38 37 /**
39 38 * Returns the equivalent WordPress URL given a frontend URL.
@@ -98,15 +97,15 @@
98 97
99 98 /**
100 99 * Check if a string has a file extension.
101 100 *
102 - * @param string $file The string to check.
101 + * @param string $string The string to check.
103 102 * @return boolean
104 103 */
105 -function has_file_extension( $file ) {
104 +function has_file_extension( $string ) {
106 105 $file_extension_pattern = '/\.[a-zA-Z0-9]+$/';
107 106
108 - if ( preg_match( $file_extension_pattern, $file ) ) {
107 + if ( preg_match( $file_extension_pattern, $string ) ) {
109 108 return true;
110 109 } else {
111 110 return false; // String does not have a file extension.
112 111 }
@@ -111,89 +110,4 @@
111 110 return false; // String does not have a file extension.
112 111 }
113 112 }
114 113
115 -/**
116 - * Determines if an AJAX request to generate permalinks is in progress.
117 - *
118 - * @return boolean
119 - */
120 -function is_ajax_generate_permalink_request(): bool {
121 - return ( ! empty( $_POST['samplepermalinknonce'] ) && check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' ) );
122 -}
123 -
124 -/**
125 - * Determines if a wp-link-ajax request is in progress.
126 - *
127 - * @return boolean
128 - */
129 -function is_wp_link_ajax_request(): bool {
130 - return ( wp_doing_ajax()
131 - && ! empty( $_POST['_ajax_linking_nonce'] )
132 - && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_ajax_linking_nonce'] ) ), 'internal-linking' )
133 - && ! empty( $_POST['action'] )
134 - && 'wp-link-ajax' === $_POST['action'] );
135 -}
136 -
137 -
138 -/**
139 - * Get all site URLs for each possible HTTP protocol.
140 - *
141 - * @param string $site_url The site url.
142 - *
143 - * @return array<string> An array of site urls.
144 - */
145 -function faustwp_get_wp_site_urls( string $site_url ): array {
146 -
147 - $host_url_parse = wp_parse_url( $site_url );
148 - $host_url = $host_url_parse['host'] ?? '';
149 - if ( ! empty( $host_url_parse['port'] ) ) {
150 - $host_url .= ':' . $host_url_parse['port'];
151 - }
152 - $is_https = strpos( $site_url, 'https://' ) === 0;
153 -
154 - return apply_filters(
155 - 'faustwp_get_wp_site_urls',
156 - array(
157 - $is_https ? "https://$host_url" : "http://$host_url",
158 - $is_https ? "http://$host_url" : "https://$host_url",
159 - "//$host_url",
160 - )
161 - );
162 -}
163 -
164 -
165 -/**
166 - * Get all media urls based off the available site urls
167 - *
168 - * @param array<string> $wp_site_urls The array of potential site urls.
169 - * @param string $relative_upload_url The relative upload url.
170 - *
171 - * @return array<string> The array of media Urls
172 - */
173 -function faustwp_get_wp_media_urls( array $wp_site_urls, string $relative_upload_url ) {
174 -
175 - $media_urls = array();
176 - foreach ( $wp_site_urls as $site_url ) {
177 - $media_urls[] = $site_url . $relative_upload_url;
178 - }
179 -
180 - return apply_filters( 'faustwp_get_wp_site_media_urls', $media_urls );
181 -}
182 -
183 -
184 -/**
185 - * Gets the relative wp-content upload URL.
186 - *
187 - * @param array<string>|string $site_urls An array of site URLs.
188 - * @param string $upload_url An array of site URLs.
189 - *
190 - * @return string The relative upload URL.
191 - */
192 -function faustwp_get_relative_upload_url( array $site_urls, string $upload_url = '' ): string {
193 - foreach ( $site_urls as $site_url ) {
194 - if ( strpos( $upload_url, $site_url ) === 0 ) {
195 - return (string) str_replace( $site_url, '', $upload_url );
196 - }
197 - }
198 - return '';
199 -}