Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into enhancement/4145-adsense-cta-widget.
- Loading branch information
Showing
24 changed files
with
346 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
assets/js/feature-tours/pagespeed-insights-force-active.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/** | ||
* Page Speed Insight Force Active tour for the dashboard. | ||
* | ||
* Site Kit by Google, Copyright 2021 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/* | ||
* Internal dependencies | ||
*/ | ||
import { | ||
VIEW_CONTEXT_DASHBOARD, | ||
VIEW_CONTEXT_PAGE_DASHBOARD, | ||
} from '../googlesitekit/constants'; | ||
import { CORE_SITE } from '../googlesitekit/datastore/site/constants'; | ||
import { | ||
MODULES_PAGESPEED_INSIGHTS, | ||
STRATEGY_DESKTOP, | ||
STRATEGY_MOBILE, | ||
} from '../modules/pagespeed-insights/datastore/constants'; | ||
|
||
const pagespeedInsightsForceActive = { | ||
slug: 'pagespeedInsightsForceActive', | ||
contexts: [ VIEW_CONTEXT_DASHBOARD, VIEW_CONTEXT_PAGE_DASHBOARD ], | ||
version: '1.46.0', | ||
gaEventCategory: ( viewContext ) => | ||
`${ viewContext }_pagespeed-widget-force-active`, | ||
checkRequirements: ( { | ||
select, | ||
__experimentalResolveSelect: resolveSelect, | ||
} ) => { | ||
if ( ! global._googlesitekitBaseData.showPSIForceActiveTour ) { | ||
return false; | ||
} | ||
|
||
const referenceURL = select( CORE_SITE ).getCurrentReferenceURL(); | ||
const { getReport: asyncGetReport } = resolveSelect( | ||
MODULES_PAGESPEED_INSIGHTS | ||
); | ||
|
||
// Only show the tour if reports are available within .5 sec. | ||
return Promise.race( [ | ||
// If both reports finish first, the tour will be shown. | ||
Promise.all( [ | ||
asyncGetReport( referenceURL, STRATEGY_DESKTOP ), | ||
asyncGetReport( referenceURL, STRATEGY_MOBILE ), | ||
] ).then( () => true ), | ||
// If the timeout resolves first, the tour will not be shown. | ||
new Promise( ( resolve ) => setTimeout( resolve, 500 ) ).then( | ||
() => false | ||
), | ||
] ); | ||
}, | ||
steps: [ | ||
{ | ||
target: '.googlesitekit-widget-area--dashboardSpeed', | ||
title: __( | ||
'PageSpeed Insights is now active for everyone', | ||
'google-site-kit' | ||
), | ||
content: __( | ||
'Keep track of how your pages are doing in terms of speed and user experience and see recommendations on what to improve.', | ||
'google-site-kit' | ||
), | ||
}, | ||
], | ||
}; | ||
|
||
export default pagespeedInsightsForceActive; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?php | ||
/** | ||
* Migration for 1.46.0 | ||
* | ||
* @package Google\Site_Kit\Core\Util | ||
* @copyright 2021 Google LLC | ||
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0 | ||
* @link https://sitekit.withgoogle.com | ||
*/ | ||
|
||
namespace Google\Site_Kit\Core\Util; | ||
|
||
use Google\Site_Kit\Context; | ||
use Google\Site_Kit\Core\Authentication\Authentication; | ||
use Google\Site_Kit\Core\Authentication\Google_Proxy; | ||
use Google\Site_Kit\Core\Authentication\Profile; | ||
use Google\Site_Kit\Core\Authentication\Verification_File; | ||
use Google\Site_Kit\Core\Authentication\Verification_Meta; | ||
use Google\Site_Kit\Core\Permissions\Permissions; | ||
use Google\Site_Kit\Core\Storage\Options; | ||
use Google\Site_Kit\Core\Storage\User_Options; | ||
use WP_User; | ||
use WP_Error; | ||
|
||
/** | ||
* Class Migration_1_46_0 | ||
* | ||
* @since 1.46.0 | ||
* @access private | ||
* @ignore | ||
*/ | ||
class Migration_1_46_0 { | ||
/** | ||
* Target DB version. | ||
*/ | ||
const DB_VERSION = '1.46.0'; | ||
|
||
const OPTION_KEY_PSI_UPDATED = 'googlesitekit_psi_updated'; | ||
|
||
/** | ||
* Context instance. | ||
* | ||
* @since 1.46.0 | ||
* @var Context | ||
*/ | ||
protected $context; | ||
|
||
/** | ||
* Options instance. | ||
* | ||
* @since 1.46.0 | ||
* @var Options | ||
*/ | ||
protected $options; | ||
|
||
/** | ||
* User_Options instance. | ||
* | ||
* @since 1.46.0 | ||
* @var User_Options | ||
*/ | ||
protected $user_options; | ||
|
||
/** | ||
* Authentication instance. | ||
* | ||
* @since 1.46.0 | ||
* @var Authentication | ||
*/ | ||
protected $authentication; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @since 1.46.0 | ||
* | ||
* @param Context $context Plugin context instance. | ||
* @param Options $options Optional. Options instance. | ||
* @param Authentication $authentication Optional. Authentication instance. Default is a new instance. | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
Options $options = null, | ||
Authentication $authentication = null | ||
) { | ||
$this->context = $context; | ||
$this->options = $options ?: new Options( $this->context ); | ||
$this->authentication = $authentication ?: new Authentication( $this->context, $this->options, $this->user_options ); | ||
} | ||
|
||
/** | ||
* Registers hooks. | ||
* | ||
* @since 1.46.0 | ||
*/ | ||
public function register() { | ||
add_action( 'admin_init', array( $this, 'migrate' ) ); | ||
} | ||
|
||
/** | ||
* Migrates the DB. | ||
* | ||
* @since 1.46.0 | ||
*/ | ||
public function migrate() { | ||
$db_version = $this->options->get( 'googlesitekit_db_version' ); | ||
|
||
// Do not run if database version already updated. | ||
if ( $db_version && version_compare( $db_version, self::DB_VERSION, '>=' ) ) { | ||
return; | ||
} | ||
|
||
if ( $this->authentication->is_setup_completed() ) { | ||
$this->options->set( self::OPTION_KEY_PSI_UPDATED, true ); | ||
} | ||
|
||
// Update database version. | ||
$this->options->set( 'googlesitekit_db_version', self::DB_VERSION ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.