Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: changed

Random Redirect: Defer to WordPress core's random content redirects on WordPress 7.2 and later.
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,10 @@ public static function load_custom_css() {
* Load the Random Redirect feature.
*/
public static function load_wpcom_random_redirect() {
// WordPress 7.2 handles random content redirects (/random/, ?random) in core; every 7.2 beta includes it.
if ( version_compare( $GLOBALS['wp_version'], '7.2-beta', '>=' ) ) {
return;
}
require_once __DIR__ . '/features/random-redirect/random-redirect.php';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

/**
* Redirects to a random post on the site.
*
* @deprecated $$next-version$$ WordPress 7.2 and later handle random content redirects in core, and this loads only on older versions.
*/
function jetpack_matt_random_redirect() {
// Verify that the Random Redirect plugin this code is from is not active
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: compat

Random Redirect: Defer to WordPress core's random content redirects on WordPress 7.2 and later.
6 changes: 5 additions & 1 deletion projects/plugins/jetpack/modules/module-extras.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
// Theme Tools.
'theme-tools.php',
'theme-tools/social-links.php',
'theme-tools/random-redirect.php',
'theme-tools/featured-content.php',
'theme-tools/responsive-videos.php',
'theme-tools/site-logo.php',
Expand All @@ -40,6 +39,11 @@
'canonical-urls/canonical-urls-conflicts.php',
);

// WordPress 7.2 handles random content redirects (/random/, ?random) in core; every 7.2 beta includes it.
if ( version_compare( $GLOBALS['wp_version'], '7.2-beta', '<' ) ) {
$tools[] = 'theme-tools/random-redirect.php';
}

// Some features are only available when connected to WordPress.com.
$connected_tools = array(
'external-media/external-media.php',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
if ( ! function_exists( 'jetpack_matt_random_redirect' ) ) {
/**
* Redirects to a random post on the site.
*
* @deprecated $$next-version$$ WordPress 7.2 and later handle random content redirects in core, and Jetpack loads this only on older versions.
*/
function jetpack_matt_random_redirect() {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public function intercept_redirect( $location ) {
*/
protected function get_redirect_location() {
try {
// @phan-suppress-next-line PhanDeprecatedFunction -- Still the handler on WordPress before 7.2.
jetpack_matt_random_redirect();
} catch ( Exception $e ) {
return $e->getMessage();
Expand Down
Loading