PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3
Jetpack – WP Security, Backup, Speed, & Growth v16.3
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 All 508 releases
← All changes | jetpack_vendor/automattic/jetpack-connection/src/class-urls.php +32 -3 12.4.2 → 16.3 View file →
@@ -81,10 +81,10 @@
81 81
82 82 /**
83 83 * Return URL with a normalized protocol.
84 84 *
85 - * @param callable $callable Function to retrieve URL option.
86 - * @param string $new_value URL Protocol to set URLs to.
85 + * @param string $callable Function name that was used to retrieve URL option.
86 + * @param string $new_value URL Protocol to set URLs to.
87 87 * @return string Normalized URL.
88 88 */
89 89 public static function get_protocol_normalized_url( $callable, $new_value ) {
90 90 $option_key = self::HTTPS_CHECK_OPTION_PREFIX . $callable;
@@ -89,8 +89,9 @@
89 89 public static function get_protocol_normalized_url( $callable, $new_value ) {
90 90 $option_key = self::HTTPS_CHECK_OPTION_PREFIX . $callable;
91 91
92 92 $parsed_url = wp_parse_url( $new_value );
93 +
93 94 if ( ! $parsed_url ) {
94 95 return $new_value;
95 96 }
96 97 if ( array_key_exists( 'scheme', $parsed_url ) ) {
@@ -97,9 +98,14 @@
97 98 $scheme = $parsed_url['scheme'];
98 99 } else {
99 100 $scheme = '';
100 101 }
101 - $scheme_history = get_option( $option_key, array() );
102 + $scheme_history = get_option( $option_key, array() );
103 +
104 + if ( ! is_array( $scheme_history ) ) {
105 + $scheme_history = array();
106 + }
107 +
102 108 $scheme_history[] = $scheme;
103 109
104 110 // Limit length to self::HTTPS_CHECK_HISTORY.
105 111 $scheme_history = array_slice( $scheme_history, ( self::HTTPS_CHECK_HISTORY * -1 ) );
@@ -183,5 +189,28 @@
183 189 public static function main_network_site_url() {
184 190 return self::get_protocol_normalized_url( 'main_network_site_url', network_site_url() );
185 191 }
186 192
193 + /**
194 + * Maybe add the origin_site_id query parameter to a URL.
195 + *
196 + * The parameter is only added for users who are members of the current blog.
197 + *
198 + * @since 7.1.0
199 + *
200 + * @param string $url The URL to add the query param to.
201 + * @return string The URL with the origin_site_id query parameter maybe added.
202 + */
203 + public static function maybe_add_origin_site_id( $url ) {
204 + $site_id = Manager::get_site_id();
205 + if ( is_wp_error( $site_id ) ) {
206 + return $url;
207 + }
208 +
209 + // Add query param to URL only for users who can access wp-admin.
210 + if ( ! is_user_member_of_blog() ) {
211 + return $url;
212 + }
213 +
214 + return add_query_arg( 'origin_site_id', $site_id, $url );
215 + }
187 216 }