summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2017-09-01 20:14:25 -0400
committerAnthony G. Basile <blueness@gentoo.org>2017-09-01 20:14:25 -0400
commit9577a2e9108f48dc19beca28264c0af227567aac (patch)
tree62c639f4a486320e595f84e8d986cf8b9c1f0174 /plugins/jetpack/sync/class.jetpack-sync-functions.php
parentUpdate akismet 3.3.4 (diff)
downloadblogs-gentoo-9577a2e9108f48dc19beca28264c0af227567aac.tar.gz
blogs-gentoo-9577a2e9108f48dc19beca28264c0af227567aac.tar.bz2
blogs-gentoo-9577a2e9108f48dc19beca28264c0af227567aac.zip
Update jetpack 5.2.1
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'plugins/jetpack/sync/class.jetpack-sync-functions.php')
-rw-r--r--plugins/jetpack/sync/class.jetpack-sync-functions.php68
1 files changed, 60 insertions, 8 deletions
diff --git a/plugins/jetpack/sync/class.jetpack-sync-functions.php b/plugins/jetpack/sync/class.jetpack-sync-functions.php
index 596af357..f8d76def 100644
--- a/plugins/jetpack/sync/class.jetpack-sync-functions.php
+++ b/plugins/jetpack/sync/class.jetpack-sync-functions.php
@@ -144,18 +144,53 @@ class Jetpack_Sync_Functions {
return false;
}
+ /**
+ * Helper function that is used when getting home or siteurl values. Decides
+ * whether to get the raw or filtered value.
+ *
+ * @return string
+ */
+ public static function get_raw_or_filtered_url( $url_type ) {
+ if (
+ ! Jetpack_Constants::is_defined( 'JETPACK_SYNC_USE_RAW_URL' ) ||
+ Jetpack_Constants::get_constant( 'JETPACK_SYNC_USE_RAW_URL' )
+ ) {
+ $url = self::get_raw_url( $url_type );
+ } else {
+ $url_function = ( 'home' == $url_type )
+ ? 'home_url'
+ : 'site_url';
+ $url = self::normalize_www_in_url( $url_type, $url_function );
+ $url = self::get_protocol_normalized_url( $url_function, $url );
+ }
+
+ return $url;
+ }
+
public static function home_url() {
- return self::get_protocol_normalized_url(
- 'home_url',
- self::normalize_www_in_url( 'home', 'home_url' )
- );
+ $url = self::get_raw_or_filtered_url( 'home' );
+
+ /**
+ * Allows overriding of the home_url value that is synced back to WordPress.com.
+ *
+ * @since 5.2
+ *
+ * @param string $home_url
+ */
+ return esc_url_raw( apply_filters( 'jetpack_sync_home_url', $url ) );
}
public static function site_url() {
- return self::get_protocol_normalized_url(
- 'site_url',
- self::normalize_www_in_url( 'siteurl', 'site_url' )
- );
+ $url = self::get_raw_or_filtered_url( 'siteurl' );
+
+ /**
+ * Allows overriding of the site_url value that is synced back to WordPress.com.
+ *
+ * @since 5.2
+ *
+ * @param string $site_url
+ */
+ return esc_url_raw( apply_filters( 'jetpack_sync_site_url', $url ) );
}
public static function main_network_site_url() {
@@ -184,6 +219,23 @@ class Jetpack_Sync_Functions {
return set_url_scheme( $new_value, $forced_scheme );
}
+ public static function get_raw_url( $option_name ) {
+ $value = null;
+ $constant = ( 'home' == $option_name )
+ ? 'WP_HOME'
+ : 'WP_SITEURL';
+
+ if ( Jetpack_Constants::is_defined( $constant ) ) {
+ $value = Jetpack_Constants::get_constant( $constant );
+ } else {
+ // Let's get the option from the database so that we can bypass filters. This will help
+ // ensure that we get more uniform values.
+ $value = Jetpack_Options::get_raw_option( $option_name );
+ }
+
+ return $value;
+ }
+
public static function normalize_www_in_url( $option, $url_function ) {
$url = wp_parse_url( call_user_func( $url_function ) );
$option_url = wp_parse_url( get_option( $option ) );