diff options
Diffstat (limited to 'plugins/jetpack/sync/class.jetpack-sync-functions.php')
-rw-r--r-- | plugins/jetpack/sync/class.jetpack-sync-functions.php | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/plugins/jetpack/sync/class.jetpack-sync-functions.php b/plugins/jetpack/sync/class.jetpack-sync-functions.php index 8fbe3dc9..0ba278aa 100644 --- a/plugins/jetpack/sync/class.jetpack-sync-functions.php +++ b/plugins/jetpack/sync/class.jetpack-sync-functions.php @@ -165,6 +165,11 @@ class Jetpack_Sync_Functions { } ob_start(); + + if ( ! function_exists( 'request_filesystem_credentials' ) ) { + require_once( ABSPATH . 'wp-admin/includes/file.php' ); + } + $filesystem_credentials_are_stored = request_filesystem_credentials( self_admin_url() ); ob_end_clean(); if ( $filesystem_credentials_are_stored ) { @@ -336,12 +341,12 @@ class Jetpack_Sync_Functions { return $wp_version; } - public static function site_icon_url() { + public static function site_icon_url( $size = 512 ) { if ( ! function_exists( 'get_site_icon_url' ) || ! has_site_icon() ) { return get_option( 'jetpack_site_icon_url' ); } - return get_site_icon_url(); + return get_site_icon_url( $size ); } public static function roles() { @@ -349,4 +354,34 @@ class Jetpack_Sync_Functions { return $wp_roles->roles; } + /** + * Determine time zone from WordPress' options "timezone_string" + * and "gmt_offset". + * + * 1. Check if `timezone_string` is set and return it. + * 2. Check if `gmt_offset` is set, formats UTC-offset from it and return it. + * 3. Default to "UTC+0" if nothing is set. + * + * @return string + */ + public static function get_timezone() { + $timezone_string = get_option( 'timezone_string' ); + + if ( ! empty( $timezone_string ) ) { + return str_replace( '_', ' ', $timezone_string ); + } + + $gmt_offset = get_option( 'gmt_offset', 0 ); + + $formatted_gmt_offset = sprintf( '%+g', floatval( $gmt_offset ) ); + + $formatted_gmt_offset = str_replace( + array( '.25', '.5', '.75' ), + array( ':15', ':30', ':45' ), + (string) $formatted_gmt_offset + ); + + /* translators: %s is UTC offset, e.g. "+1" */ + return sprintf( __( 'UTC%s' ), $formatted_gmt_offset ); + } } |