Skip to content

Commit 1e4a204

Browse files
committed
Sync: IDC: Simplify some logic around getting URLs
1 parent c448404 commit 1e4a204

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

sync/class.jetpack-sync-functions.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,16 @@ public static function file_system_write_access() {
150150
*
151151
* @return string
152152
*/
153-
public static function get_raw_or_filtered_url( $url_type, $url_function) {
153+
public static function get_raw_or_filtered_url( $url_type ) {
154154
if (
155155
! Jetpack_Constants::is_defined( 'JETPACK_SYNC_USE_RAW_URL' ) ||
156156
Jetpack_Constants::get_constant( 'JETPACK_SYNC_USE_RAW_URL' )
157157
) {
158158
$url = self::get_raw_url( $url_type );
159159
} else {
160+
$url_function = ( 'home' == $url_type )
161+
? 'home_url'
162+
: 'site_url';
160163
$url = self::normalize_www_in_url( $url_type, $url_function );
161164
$url = self::get_protocol_normalized_url( $url_function, $url );
162165
}
@@ -165,7 +168,7 @@ public static function get_raw_or_filtered_url( $url_type, $url_function) {
165168
}
166169

167170
public static function home_url() {
168-
$url = self::get_raw_or_filtered_url( 'home', 'home_url' );
171+
$url = self::get_raw_or_filtered_url( 'home' );
169172

170173
/**
171174
* Allows overriding of the home_url value that is synced back to WordPress.com.
@@ -178,7 +181,7 @@ public static function home_url() {
178181
}
179182

180183
public static function site_url() {
181-
$url = self::get_raw_or_filtered_url( 'siteurl', 'site_url' );
184+
$url = self::get_raw_or_filtered_url( 'siteurl' );
182185

183186
/**
184187
* Allows overriding of the site_url value that is synced back to WordPress.com.
@@ -218,10 +221,12 @@ public static function get_protocol_normalized_url( $callable, $new_value ) {
218221

219222
public static function get_raw_url( $option_name ) {
220223
$value = null;
221-
if ( 'home' == $option_name && Jetpack_Constants::is_defined( 'WP_HOME' ) ) {
222-
$value = Jetpack_Constants::get_constant( 'WP_HOME' );
223-
} else if ( 'siteurl' == $option_name && Jetpack_Constants::is_defined( 'WP_SITEURL' ) ) {
224-
$value = Jetpack_Constants::get_constant( 'WP_SITEURL' );
224+
$constant = ( 'home' == $option_name )
225+
? 'WP_HOME'
226+
: 'WP_SITEURL';
227+
228+
if ( Jetpack_Constants::is_defined( $constant ) ) {
229+
$value = Jetpack_Constants::get_constant( $constant );
225230
} else {
226231
// Let's get the option from the database so that we can bypass filters. This will help
227232
// ensure that we get more uniform values.

0 commit comments

Comments
 (0)