Skip to content

Commit

Permalink
General: remove WP 6.1 backwards compatibility checks
Browse files Browse the repository at this point in the history
See #31638

This mostly removes checks that were added in #28710
  • Loading branch information
jeherve committed Aug 30, 2023
1 parent d7f7861 commit 84b9188
Show file tree
Hide file tree
Showing 32 changed files with 127 additions and 166 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

General: remove WP 6.1 backwards compatibility checks
17 changes: 6 additions & 11 deletions projects/packages/backup/src/js/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ThemeProvider } from '@automattic/jetpack-components';
import { createReduxStore, register } from '@wordpress/data';
import * as WPElement from '@wordpress/element';
import { render } from '@wordpress/element';
import React from 'react';
import Admin from './components/Admin';
import { STORE_ID, storeConfig } from './store';
Expand All @@ -11,24 +11,19 @@ register( store );
/**
* Initial render function.
*/
function render() {
function renderDash() {
const container = document.getElementById( 'jetpack-backup-root' );

if ( null === container ) {
return;
}

// @todo: Remove fallback when we drop support for WP 6.1
const component = (
render(
<ThemeProvider>
<Admin />
</ThemeProvider>
</ThemeProvider>,
container
);
if ( WPElement.createRoot ) {
WPElement.createRoot( container ).render( component );
} else {
WPElement.render( component, container );
}
}

render();
renderDash();
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

General: remove WP 6.1 backwards compatibility checks
4 changes: 0 additions & 4 deletions projects/packages/connection/tests/php/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
*/
require_once __DIR__ . '/../../vendor/autoload.php';

// Disable warning about deprecated request library.
// @todo Remove this once we drop support for WordPress 6.1
define( 'REQUESTS_SILENCE_PSR0_DEPRECATIONS', true );

// Work around WordPress bug when `@runInSeparateProcess` is used.
if ( empty( $_SERVER['SCRIPT_FILENAME'] ) ) {
$_SERVER['SCRIPT_FILENAME'] = __DIR__ . '/vendor/phpunit/phpunit/phpunit';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

General: remove WP 6.1 backwards compatibility checks
14 changes: 4 additions & 10 deletions projects/packages/identity-crisis/src/_inc/admin.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IDCScreen } from '@automattic/jetpack-idc';
import * as WPElement from '@wordpress/element';
import { render } from '@wordpress/element';
import React from 'react';

import './admin-bar.scss';
Expand All @@ -8,7 +8,7 @@ import './style.scss';
/**
* The initial renderer function.
*/
function render() {
function renderIdc() {
if ( ! window.hasOwnProperty( 'JP_IDENTITY_CRISIS__INITIAL_STATE' ) ) {
return;
}
Expand Down Expand Up @@ -36,7 +36,6 @@ function render() {
} = window.JP_IDENTITY_CRISIS__INITIAL_STATE;

if ( ! isSafeModeConfirmed ) {
// @todo: Remove fallback when we drop support for WP 6.1
const component = (
<IDCScreen
wpcomHomeUrl={ wpcomHomeUrl }
Expand All @@ -54,13 +53,8 @@ function render() {
possibleDynamicSiteUrlDetected={ possibleDynamicSiteUrlDetected }
/>
);

if ( WPElement.createRoot ) {
WPElement.createRoot( container ).render( component );
} else {
WPElement.render( component, container );
}
render( component, container );
}
}

window.addEventListener( 'load', () => render() );
window.addEventListener( 'load', () => renderIdc() );
13 changes: 4 additions & 9 deletions projects/packages/my-jetpack/_inc/admin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import { ThemeProvider } from '@automattic/jetpack-components';
import * as WPElement from '@wordpress/element';
import { render } from '@wordpress/element';
import React, { useEffect } from 'react';
import { HashRouter, Navigate, Routes, Route, useLocation } from 'react-router-dom';
/**
Expand Down Expand Up @@ -74,18 +74,13 @@ const MyJetpack = () => (
/**
* The initial renderer function.
*/
function render() {
function renderMyJetpack() {
const container = document.getElementById( 'my-jetpack-container' );
if ( null === container ) {
return;
}

// @todo: Remove fallback when we drop support for WP 6.1
if ( WPElement.createRoot ) {
WPElement.createRoot( container ).render( <MyJetpack /> );
} else {
WPElement.render( <MyJetpack />, container );
}
render( <MyJetpack />, container );
}

render();
renderMyJetpack();
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

General: remove WP 6.1 backwards compatibility checks
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

General: remove WP 6.1 backwards compatibility checks
9 changes: 2 additions & 7 deletions projects/packages/search/src/dashboard/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createReduxStore, register } from '@wordpress/data';
import * as WPElement from '@wordpress/element';
import { render } from '@wordpress/element';
import React from 'react';
import SearchDashboard from './components/dashboard/wrapped-dashboard';
import { STORE_ID, storeConfig } from './store';
Expand All @@ -17,12 +17,7 @@ function init() {
return;
}

// @todo: Remove fallback when we drop support for WP 6.1
if ( WPElement.createRoot ) {
WPElement.createRoot( container ).render( <SearchDashboard /> );
} else {
WPElement.render( <SearchDashboard />, container );
}
render( <SearchDashboard />, container );
}

// Initialize the dashboard when DOMContentLoaded is fired, or immediately if it already has been.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

General: remove WP 6.1 backwards compatibility checks
13 changes: 4 additions & 9 deletions projects/packages/videopress/src/client/admin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import { ThemeProvider } from '@automattic/jetpack-components';
import * as WPElement from '@wordpress/element';
import { render } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { useEffect } from 'react';
import { HashRouter, Switch, Route, useLocation } from 'react-router-dom';
Expand Down Expand Up @@ -66,19 +66,14 @@ const VideoPress = () => {
/**
* Initial render function.
*/
function render() {
function renderVideopress() {
const container = document.getElementById( 'jetpack-videopress-root' );

if ( null === container ) {
return;
}

// @todo: Remove fallback when we drop support for WP 6.1
if ( WPElement.createRoot ) {
WPElement.createRoot( container ).render( <VideoPress /> );
} else {
WPElement.render( <VideoPress />, container );
}
render( <VideoPress />, container );
}

render();
renderVideopress();
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

General: remove WP 6.1 backwards compatibility checks
13 changes: 4 additions & 9 deletions projects/packages/wordads/src/dashboard/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ThemeProvider } from '@automattic/jetpack-components';
import { createReduxStore, register } from '@wordpress/data';
import * as WPElement from '@wordpress/element';
import { render } from '@wordpress/element';
import React from 'react';
import WordAdsDashboard from './components/dashboard';
import { STORE_ID, storeConfig } from './store';
Expand All @@ -18,17 +18,12 @@ function init() {
return;
}

// @todo: Remove fallback when we drop support for WP 6.1
const component = (
render(
<ThemeProvider>
<WordAdsDashboard />
</ThemeProvider>
</ThemeProvider>,
container
);
if ( WPElement.createRoot ) {
WPElement.createRoot( container ).render( component );
} else {
WPElement.render( component, container );
}
}

// Initialize the dashboard when DOMContentLoaded is fired, or immediately if it already has been.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@
let root;
afterUpdate( () => {
const { this: component, children, ...props } = $$props;
// @todo: Remove fallback when we drop support for WP 6.1
if ( WPElement.createRoot ) {
root = WPElement.createRoot( container );
} else {
const theContainer = container;
root = {
render: theComponent => WPElement.render( theComponent, theContainer ),
unmount: () => WPElement.unmountComponentAtNode( theContainer ),
};
}
const theContainer = container;
root = {
render: theComponent => WPElement.render( theComponent, theContainer ),
unmount: () => WPElement.unmountComponentAtNode( theContainer ),
};
root.render( React.createElement( component, props, children ) );
} );
onDestroy( () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: changed

General: remove WP 6.1 backwards compatibility checks
13 changes: 4 additions & 9 deletions projects/plugins/jetpack/_inc/client/activation-modal-entry.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as WPElement from '@wordpress/element';
import { render } from '@wordpress/element';
import React from 'react';
import { Provider } from 'react-redux';
import store from 'state/redux-store-minimal';
Expand All @@ -10,17 +10,12 @@ import ActivationModal from './portals/activation-modal';
function initActivationModalApp() {
const container = document.getElementById( 'jetpack-plugin-portal-app' );

// @todo: Remove fallback when we drop support for WP 6.1
const component = (
render(
<Provider store={ store }>
<ActivationModal />
</Provider>
</Provider>,
container
);
if ( WPElement.createRoot ) {
WPElement.createRoot( container ).render( component );
} else {
WPElement.render( component, container );
}
}

if ( document.readyState !== 'loading' ) {
Expand Down
15 changes: 5 additions & 10 deletions projects/plugins/jetpack/_inc/client/admin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as WPElement from '@wordpress/element';
import { render } from '@wordpress/element';
import { _x } from '@wordpress/i18n';
import accessibleFocus from 'lib/accessible-focus';
import { assign } from 'lodash';
Expand All @@ -20,19 +20,18 @@ if ( 'undefined' !== typeof window && process.env.NODE_ENV === 'development' ) {
} );
}

render();
renderApp();

/**
*
* Initial render function.
*/
function render() {
function renderApp() {
const container = document.getElementById( 'jp-plugin-container' );

if ( container === null ) {
return;
}

// @todo: Remove fallback when we drop support for WP 6.1
const component = (
<div>
<Provider store={ store }>
Expand Down Expand Up @@ -100,11 +99,7 @@ function render() {
</Provider>
</div>
);
if ( WPElement.createRoot ) {
WPElement.createRoot( container ).render( component );
} else {
WPElement.render( component, container );
}
render( component, container );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,11 @@ export default class RootChild extends React.Component {
componentDidMount() {
this.container = document.createElement( 'div' );
document.body.appendChild( this.container );
// @todo: Remove fallback when we drop support for WP 6.1
if ( WPElement.createRoot ) {
this.containerRoot = WPElement.createRoot( this.container );
} else {
const theContainer = this.container;
this.containerRoot = {
render: component => WPElement.render( component, theContainer ),
unmount: () => WPElement.unmountComponentAtNode( theContainer ),
};
}
const theContainer = this.container;
this.containerRoot = {
render: component => WPElement.render( component, theContainer ),
unmount: () => WPElement.unmountComponentAtNode( theContainer ),
};
this.renderChildren();
}

Expand Down
13 changes: 4 additions & 9 deletions projects/plugins/jetpack/_inc/client/plugins-entry.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as WPElement from '@wordpress/element';
import { render } from '@wordpress/element';
import React from 'react';
import { Provider } from 'react-redux';
import store from 'state/redux-store-minimal';
Expand All @@ -10,17 +10,12 @@ import PluginDeactivation from './portals/plugin-deactivation';
function initPluginsPageApp() {
const container = document.getElementById( 'jetpack-plugin-portal-app' );

// @todo: Remove fallback when we drop support for WP 6.1
const component = (
render(
<Provider store={ store }>
<PluginDeactivation />
</Provider>
</Provider>,
container
);
if ( WPElement.createRoot ) {
WPElement.createRoot( container ).render( component );
} else {
WPElement.render( component, container );
}
}

if ( document.readyState !== 'loading' ) {
Expand Down
Loading

0 comments on commit 84b9188

Please sign in to comment.