Skip to content

Commit

Permalink
Update PHP 7.4 to 8.0 in our tools (#22046)
Browse files Browse the repository at this point in the history
* Update versions.sh PHP version from 7.4 to 8.0

* Docker: remove php-json ext. included with PHP 8.0

* Remove unused files

Versions are now referenced in .github/versions.sh

* Update phpunit workaround

See: Automattic/jetpack/pull/22046#issuecomment-988887739

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/1885186293
  • Loading branch information
kraftbj authored and matticbot committed Feb 23, 2022
1 parent ac06443 commit 6033512
Show file tree
Hide file tree
Showing 277 changed files with 2,926 additions and 3,908 deletions.
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

80 changes: 0 additions & 80 deletions .eslintrc.cjs

This file was deleted.

71 changes: 6 additions & 65 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,70 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0.0-alpha] - unreleased

This is an alpha version! The changes listed here are not final.

## [1.4.0-beta] - 2022-02-22
### Added
- Add a dependency on the automattic/jetpack-composer-plugin Composer package.
- Added Cloud Critical CSS
- Add My Jetpack page
- E2E tests
- Load the Composer package assets i18n map.
- Refactor and add new core E2E tests
- Suggested steps if critical css failed to generate due to page errors
- UI: Adds My Jetpack functionality for consistent UI across all Jetpack plugins.

### Changed
- Add Jetpack compatibility tests.
- E2E tests: merge Github workflows
- E2E tests: migrate from Jest to Playwright test runner
- E2E tests: updated eslint configuration
- E2E tests renovate: bump dependencies
- General: Boost is now compatible with WordPress 5.9.
- General: update required node version to v16.13.2
- Move Critical CSS recommendation to it's own class.
- Switch to pcov for code coverage.
- Updated composer.lock file.
- Updated composer.lock file.
- Updated Dashboard heading with new Horizontal logo.
- Updated package dependencies
- Updated package dependencies
- Updated package dependencies
- Updated package dependencies
- Updated package dependencies
- Updated package dependencies
- Updated package dependencies
- Updated package dependencies
- Updated package dependencies
- Updated package dependencies.
- Updated package dependencies.
- Updated package dependencies.
- Updated package dependencies.
- Updated package dependencies.
- Updated package dependencies.
- Updated package dependencies.
- Updated package dependencies.
- Updated package dependencies.
- Updated package dependencies.
- Updated package dependencies.
- Updated package dependencies.
- Updated package dependencies.
- Update regular expression to ignore deferring js via ignore attribute with and without quotes.

### Removed
- Removed separate pnpm workspace for e2e tests.

### Fixed
- Added a bunch of missing eslint ignore directives.
- Check that the Assets::alias_textdomains_from_file method exists before calling it.
- E2E tests: update readme
- Fixed e2e tests
- Fixed initial configuration of lazy load behaving opposit to jetpack settings
- Fixed issue with re-serving Critical CSS during generation process
- Re-added Lazy image compatibility
- Sync some E2E deps with the rest of the monorepo to avoid breaking eslint tests.

## [1.3.1-beta] - 2021-11-22
## [1.3.1-beta] - 2021-12-02
### Added
- Critical CSS: Added a filter to allow stylesheets to load synchronously, to avoid CLS issues on certain setups.
- Critical CSS: Exclude "library" posts from Elementor plugin when generating Critical CSS.
Expand All @@ -83,12 +24,13 @@ This is an alpha version! The changes listed here are not final.
- Speed Scores: Include active modules and Jetpack Boost version with Speed Score requests.

### Fixed
- Critical CSS: Ensure CSS files still load when JavaScript is not enabled.
- Critical CSS: Fixed issue with re-serving Critical CSS during generation process
- Critical CSS: Fix handling for corrupted font-face rules.
- Critical CSS: Fix issue with dismissing recommendations after enabling Critical CSS without page refresh.
- Critical CSS: Ensure CSS files still load when JavaScript is not enabled.
- Critical CSS: Use home_url instead of site_url when determining homepage during Critical CSS generation.
- Speed Scores: Do not show comparative scores when no modules are active.
- Minor UI fixes for small screens and tooltip display.
- Speed Scores: Do not show comparative scores when no modules are active.

## [1.3.0-beta] - 2021-10-04
### Security
Expand Down Expand Up @@ -180,7 +122,6 @@ This is an alpha version! The changes listed here are not final.

- First public alpha release

[2.0.0-alpha]: https://github.com/Automattic/jetpack-boost-production/compare/v1.3.1-beta...v2.0.0-alpha
[1.3.1-beta]: https://github.com/Automattic/jetpack-boost-production/compare/v1.3.0-beta...v1.3.1-beta
[1.3.0-beta]: https://github.com/Automattic/jetpack-boost-production/compare/v1.2.0...v1.3.0-beta
[1.2.0]: https://github.com/Automattic/jetpack-boost-production/compare/v1.1.0...v1.2.0-beta
97 changes: 66 additions & 31 deletions app/admin/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@

use Automattic\Jetpack\Admin_UI\Admin_Menu;
use Automattic\Jetpack\Status;
use Automattic\Jetpack_Boost\Features\Optimizations\Optimizations;
use Automattic\Jetpack_Boost\Features\Speed_Score\Speed_Score;
use Automattic\Jetpack_Boost\Jetpack_Boost;
use Automattic\Jetpack_Boost\Lib\Analytics;
use Automattic\Jetpack_Boost\Lib\Environment_Change_Detector;
use Automattic\Jetpack_Boost\REST_API\Permissions\Nonce;
use Automattic\Jetpack_Boost\Lib\Speed_Score;

/**
* Class Admin
*/
class Admin {

/**
Expand Down Expand Up @@ -44,7 +45,7 @@ class Admin {
*
* @var Jetpack_Boost Plugin.
*/
private $modules;
private $jetpack_boost;

/**
* Speed_Score class instance.
Expand All @@ -53,13 +54,21 @@ class Admin {
*/
private $speed_score;

public function __construct( Optimizations $modules ) {
$this->modules = $modules;
$this->speed_score = new Speed_Score( $modules );
/**
* Initialize the class and set its properties.
*
* @param Jetpack_Boost $jetpack_boost Main plugin instance.
*
* @since 1.0.0
*/
public function __construct( Jetpack_Boost $jetpack_boost ) {
$this->jetpack_boost = $jetpack_boost;
$this->speed_score = new Speed_Score( $jetpack_boost );
Environment_Change_Detector::init();

add_action( 'init', array( new Analytics(), 'init' ) );
add_filter( 'plugin_action_links_' . JETPACK_BOOST_PLUGIN_BASE, array( $this, 'plugin_page_settings_link' ) );
add_action( 'rest_api_init', array( $this, 'register_rest_routes' ) );
add_action( 'admin_notices', array( $this, 'show_notices' ) );
add_action( 'wp_ajax_set_show_rating_prompt', array( $this, 'handle_set_show_rating_prompt' ) );
add_filter( 'jetpack_boost_js_constants', array( $this, 'add_js_constants' ) );
Expand Down Expand Up @@ -93,7 +102,7 @@ public function enqueue_styles() {
$internal_path = apply_filters( 'jetpack_boost_asset_internal_path', 'app/assets/dist/' );

wp_enqueue_style(
'jetpack-boost-css',
$this->jetpack_boost->get_plugin_name() . '-css',
plugins_url( $internal_path . 'jetpack-boost.css', JETPACK_BOOST_PATH ),
array( 'wp-components' ),
JETPACK_BOOST_VERSION
Expand All @@ -108,7 +117,7 @@ public function enqueue_styles() {
public function enqueue_scripts() {
$internal_path = apply_filters( 'jetpack_boost_asset_internal_path', 'app/assets/dist/' );

$admin_js_handle = 'jetpack-boost-admin';
$admin_js_handle = $this->jetpack_boost->get_plugin_name() . '-admin';

wp_register_script(
$admin_js_handle,
Expand All @@ -118,15 +127,15 @@ public function enqueue_scripts() {
true
);

$optimizations = ( new Optimizations() )->get_status();
// Prepare configuration constants for JavaScript.
$constants = array(
'version' => JETPACK_BOOST_VERSION,
'api' => array(
'namespace' => JETPACK_BOOST_REST_NAMESPACE,
'prefix' => JETPACK_BOOST_REST_PREFIX,
),
'optimizations' => $optimizations,
'modules' => $this->jetpack_boost->get_available_modules(),
'config' => $this->jetpack_boost->config()->get_data(),
'locale' => get_locale(),
'site' => array(
'url' => get_home_url(),
Expand All @@ -137,14 +146,6 @@ public function enqueue_scripts() {
'preferences' => array(
'showRatingPrompt' => $this->get_show_rating_prompt(),
),

/**
* A bit of necessary magic,
* Explained more in the Nonce class.
*
* Nonces are automatically generated when registering routes.
*/
'nonces' => Nonce::get_generated_nonces(),
);

// Give each module an opportunity to define extra constants.
Expand Down Expand Up @@ -178,7 +179,7 @@ public function plugin_page_settings_link( $links ) {
*/
public function render_settings() {
wp_localize_script(
'jetpack-boost-admin',
$this->jetpack_boost->get_plugin_name() . '-admin',
'wpApiSettings',
array(
'root' => esc_url_raw( rest_url() ),
Expand All @@ -199,14 +200,57 @@ public function check_for_permissions() {
return current_user_can( 'manage_options' );
}

/**
* Register REST routes for settings.
*
* @return void
*/
public function register_rest_routes() {
// Activate and deactivate a module.
register_rest_route(
JETPACK_BOOST_REST_NAMESPACE,
JETPACK_BOOST_REST_PREFIX . '/module/(?P<slug>[a-z\-]+)/status',
array(
'methods' => \WP_REST_Server::EDITABLE,
'callback' => array( $this, 'set_module_status' ),
'permission_callback' => array( $this, 'check_for_permissions' ),
)
);
}

/**
* Handler for the /module/(?P<slug>[a-z\-]+)/status endpoint.
*
* @param \WP_REST_Request $request The request object.
*
* @return \WP_REST_Response|\WP_Error The response.
*/
public function set_module_status( $request ) {
$params = $request->get_json_params();

if ( ! isset( $params['status'] ) ) {
return new \WP_Error(
'jetpack_boost_error_missing_module_status_param',
__( 'Missing status param', 'jetpack-boost' )
);
}

$module_slug = $request['slug'];
$this->jetpack_boost->set_module_status( (bool) $params['status'], $module_slug );

return rest_ensure_response(
$this->jetpack_boost->get_module_status( $module_slug )
);
}

/**
* Show any admin notices from enabled modules.
*/
public function show_notices() {
// Determine if we're already on the settings page.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$on_settings_page = isset( $_GET['page'] ) && self::MENU_SLUG === $_GET['page'];
$notices = $this->get_admin_notices();
$notices = $this->jetpack_boost->get_admin_notices();

// Filter out any that have been dismissed, unless newer than the dismissal.
$dismissed_notices = \get_option( self::DISMISSED_NOTICE_OPTION, array() );
Expand Down Expand Up @@ -237,7 +281,7 @@ function ( $notice ) use ( $dismissed_notices ) {
* @return array List of notice ids.
*/
private function get_shown_admin_notice_ids() {
$notices = $this->get_admin_notices();
$notices = $this->jetpack_boost->get_admin_notices();
$ids = array();
foreach ( $notices as $notice ) {
$ids[] = $notice->get_id();
Expand All @@ -246,15 +290,6 @@ private function get_shown_admin_notice_ids() {
return $ids;
}

/**
* Returns a list of admin notices to show. Asks each module to provide admin notices the user needs to see.
*
* @return \Automattic\Jetpack_Boost\Admin\Admin_Notice[]
*/
public function get_admin_notices() {
return apply_filters( 'jetpack_boost_admin_notices', array() );
}

/**
* Check for a GET parameter used to dismiss an admin notice.
*
Expand Down
4 changes: 0 additions & 4 deletions app/assets/dist/jetpack-boost.css
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@
display: flex;
height: 27px;
}
.jb-settings-header__logo svg {
width: 100%;
height: auto;
}
@media (min-width: 992px) {
.jb-settings-header__logo {
height: 32px;
Expand Down
2 changes: 1 addition & 1 deletion app/assets/dist/jetpack-boost.js

Large diffs are not rendered by default.

Loading

0 comments on commit 6033512

Please sign in to comment.