sc_url below. echo "\n"; echo "\n"; } /** * Make sure the login form is POSTed to the signed URL so we can reverify the request. * * @param string $url Redirect URL. * @param string $path Path. * @param string $scheme URL Scheme. * * @see https://github.com/Automattic/jetpack/blob/trunk/projects/plugins/jetpack/class.jetpack.php#L5318 */ public function post_login_form_to_signed_url( $url, $path, $scheme ) { if ( 'wp-login.php' !== $path || ( 'login_post' !== $scheme && 'login' !== $scheme ) ) { return $url; } $query_string = isset( $_SERVER['QUERY_STRING'] ) ? wp_unslash( $_SERVER['QUERY_STRING'] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $parsed_url = wp_parse_url( $url ); $url = strtok( $url, '?' ); $url = "$url?{$query_string}"; if ( ! empty( $parsed_url['query'] ) ) { $url .= "&{$parsed_url['query']}"; } return $url; } /** * Add the Access Code details to the public-api.wordpress.com redirect. * * @param string $redirect_to URL. * @param string $original_redirect_to URL. * @param WP_User $user WP_User for the redirect. * * @return string * * @see https://github.com/Automattic/jetpack/blob/6066d7181f78bdec7c355d8b2152733f4691e8a9/projects/plugins/jetpack/class.jetpack.php#L5401 */ public function add_token_to_login_redirect_json_api_authorization( $redirect_to, $original_redirect_to, $user ) { return add_query_arg( urlencode_deep( [ 'jetpack-code' => get_user_meta( $user->ID, 'jetpack_json_api_' . $this->json_api_authorization_request['client_id'], true ), 'jetpack-user-id' => (int) $user->ID, 'jetpack-state' => $this->json_api_authorization_request['state'], ] ), $redirect_to ); } /** * Add public-api.wordpress.com to the safe redirect allowed list - only added when someone allows API access. * To be used with a filter of allowed domains for a redirect. * * @param array $domains Allowed WP.com Environments. * * @see https://github.com/Automattic/jetpack/blob/6066d7181f78bdec7c355d8b2152733f4691e8a9/projects/plugins/jetpack/class.jetpack.php#L5363 */ public function allow_wpcom_public_api_domain( $domains ) { $domains[] = 'public-api.wordpress.com'; return $domains; } /** * Check if the redirect is encoded. * * @param string $redirect_url Redirect URL. * * @return bool If redirect has been encoded. * * @see https://github.com/Automattic/jetpack/blob/6066d7181f78bdec7c355d8b2152733f4691e8a9/projects/plugins/jetpack/class.jetpack.php#L5375 */ public static function is_redirect_encoded( $redirect_url ) { return preg_match( '/https?%3A%2F%2F/i', $redirect_url ) > 0; } /** * HTML for the JSON API authorization notice. * * @return string * * @see https://github.com/Automattic/jetpack/blob/6066d7181f78bdec7c355d8b2152733f4691e8a9/projects/plugins/jetpack/class.jetpack.php#L5603 */ public function login_message_json_api_authorization() { return '

' . sprintf( /* translators: Name/image of the client requesting authorization */ esc_html__( '%s wants to access your site’s data. Log in to authorize that access.', 'google-listings-and-ads' ), '' . esc_html( $this->json_api_authorization_request['client_title'] ) . '' ) . '

'; } /** * Verifies the request by checking the signature * * @param null|array $environment Value to override $_REQUEST. * * @see https://github.com/Automattic/jetpack/blob/trunk/projects/plugins/jetpack/class.jetpack.php#L5422 */ public function verify_json_api_authorization_request( $environment = null ) { $environment = $environment === null ? $_REQUEST // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- nonce verification handled later in function. : $environment; list( $env_token,, $env_user_id ) = explode( ':', $environment['token'] ); $token = ( new Tokens() )->get_access_token( $env_user_id, $env_token ); if ( ! $token || empty( $token->secret ) ) { wp_die( esc_html__( 'You must connect your Jetpack plugin to WordPress.com to use this feature.', 'google-listings-and-ads' ) ); } $die_error = __( 'Someone may be trying to trick you into giving them access to your site. Or it could be you just encountered a bug :). Either way, please close this window.', 'google-listings-and-ads' ); // Host has encoded the request URL, probably as a result of a bad http => https redirect. if ( self::is_redirect_encoded( esc_url_raw( wp_unslash( $_GET['redirect_to'] ) ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotValidated -- no site changes, we're erroring out. /** * Jetpack authorisation request Error. */ do_action( 'jetpack_verify_api_authorization_request_error_double_encode' ); $die_error = sprintf( /* translators: %s is a URL */ __( 'Your site is incorrectly double-encoding redirects from http to https. This is preventing Jetpack from authenticating your connection. Please visit our support page for details about how to resolve this.', 'google-listings-and-ads' ), esc_url( 'https://jetpack.com/support/double-encoding/' ) ); } $jetpack_signature = new Jetpack_Signature( $token->secret, (int) Jetpack_Options::get_option( 'time_diff' ) ); if ( isset( $environment['jetpack_json_api_original_query'] ) ) { $signature = $jetpack_signature->sign_request( $environment['token'], $environment['timestamp'], $environment['nonce'], '', 'GET', $environment['jetpack_json_api_original_query'], null, true ); } else { $signature = $jetpack_signature->sign_current_request( [ 'body' => null, 'method' => 'GET', ] ); } if ( ! $signature ) { wp_die( wp_kses( $die_error, [ 'a' => [ 'href' => [], ], ] ) ); } elseif ( is_wp_error( $signature ) ) { wp_die( wp_kses( $die_error, [ 'a' => [ 'href' => [], ], ] ) ); } elseif ( ! hash_equals( $signature, $environment['signature'] ) ) { if ( is_ssl() ) { // If we signed an HTTP request on the Jetpack Servers, but got redirected to HTTPS by the local blog, check the HTTP signature as well. $signature = $jetpack_signature->sign_current_request( [ 'scheme' => 'http', 'body' => null, 'method' => 'GET', ] ); if ( ! $signature || is_wp_error( $signature ) || ! hash_equals( $signature, $environment['signature'] ) ) { wp_die( wp_kses( $die_error, [ 'a' => [ 'href' => [], ], ] ) ); } } else { wp_die( wp_kses( $die_error, [ 'a' => [ 'href' => [], ], ] ) ); } } $timestamp = (int) $environment['timestamp']; $nonce = stripslashes( (string) $environment['nonce'] ); if ( ! $this->connection_manager ) { $this->connection_manager = new Connection_Manager(); } if ( ! ( new Nonce_Handler() )->add( $timestamp, $nonce ) ) { // De-nonce the nonce, at least for 5 minutes. // We have to reuse this nonce at least once (used the first time when the initial request is made, used a second time when the login form is POSTed). $old_nonce_time = get_option( "jetpack_nonce_{$timestamp}_{$nonce}" ); if ( $old_nonce_time < time() - 300 ) { wp_die( esc_html__( 'The authorization process expired. Please go back and try again.', 'google-listings-and-ads' ) ); } } $data = json_decode( base64_decode( stripslashes( $environment['data'] ) ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode $data_filters = [ 'state' => 'opaque', 'client_id' => 'int', 'client_title' => 'string', 'client_image' => 'url', ]; foreach ( $data_filters as $key => $sanitation ) { if ( ! isset( $data->$key ) ) { wp_die( wp_kses( $die_error, [ 'a' => [ 'href' => [], ], ] ) ); } switch ( $sanitation ) { case 'int': $this->json_api_authorization_request[ $key ] = (int) $data->$key; break; case 'opaque': $this->json_api_authorization_request[ $key ] = (string) $data->$key; break; case 'string': $this->json_api_authorization_request[ $key ] = wp_kses( (string) $data->$key, [] ); break; case 'url': $this->json_api_authorization_request[ $key ] = esc_url_raw( (string) $data->$key ); break; } } if ( empty( $this->json_api_authorization_request['client_id'] ) ) { wp_die( wp_kses( $die_error, [ 'a' => [ 'href' => [], ], ] ) ); } } }
Warning: class_implements(): Class Automattic\WooCommerce\GoogleListingsAndAds\Integration\JetpackWPCOM does not exist and could not be loaded in /htdocs/wp-content/plugins/google-listings-and-ads/src/Internal/DependencyManagement/AbstractServiceProvider.php on line 119

Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, false given in /htdocs/wp-content/plugins/google-listings-and-ads/src/Internal/DependencyManagement/AbstractServiceProvider.php:120 Stack trace: #0 /htdocs/wp-content/plugins/google-listings-and-ads/src/Internal/DependencyManagement/AbstractServiceProvider.php(120): array_key_exists('Automattic\\WooC...', false) #1 /htdocs/wp-content/plugins/google-listings-and-ads/src/Internal/DependencyManagement/IntegrationServiceProvider.php(51): Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement\AbstractServiceProvider->conditionally_share_with_tags('Automattic\\WooC...') #2 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/ServiceProvider/ServiceProviderAggregate.php(71): Automattic\WooCommerce\GoogleListingsAndAds\Internal\DependencyManagement\IntegrationServiceProvider->register() #3 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Container.php(192): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\ServiceProvider\ServiceProviderAggregate->register('Automattic\\WooC...') #4 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Container.php(118): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Container->resolve('Automattic\\WooC...') #5 /htdocs/wp-content/plugins/google-listings-and-ads/src/Container.php(99): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Container->get('Automattic\\WooC...') #6 /htdocs/wp-content/plugins/google-listings-and-ads/src/Infrastructure/GoogleListingsAndAdsPlugin.php(131): Automattic\WooCommerce\GoogleListingsAndAds\Container->get('Automattic\\WooC...') #7 /htdocs/wp-content/plugins/google-listings-and-ads/src/Infrastructure/GoogleListingsAndAdsPlugin.php(91): Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\GoogleListingsAndAdsPlugin->maybe_register_services() #8 /htdocs/wp-includes/class-wp-hook.php(324): Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\GoogleListingsAndAdsPlugin->Automattic\WooCommerce\GoogleListingsAndAds\Infrastructure\{closure}('') #9 /htdocs/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #10 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #11 /htdocs/wp-settings.php(578): do_action('plugins_loaded') #12 /htdocs/wp-config.php(90): require_once('/htdocs/wp-sett...') #13 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #14 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #15 /htdocs/index.php(17): require('/htdocs/wp-blog...') #16 {main} thrown in /htdocs/wp-content/plugins/google-listings-and-ads/src/Internal/DependencyManagement/AbstractServiceProvider.php on line 120