diff --git a/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php b/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php index 021c35a094..a42ef5903a 100644 --- a/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php +++ b/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php @@ -238,6 +238,27 @@ public static function is_plugin_outdated( $post = null ) { return version_compare( $version_to_check_against, $tested_up_to, '>' ); } + /** + * Checks if the plugin is many years out of date. + * + * @static + * + * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. + * @return bool True if the plugin is obsolete, false otherwise. + */ + public static function is_plugin_obsolete( $post = null ) { + $post = get_post( $post ); + $tested_up_to = (string) $post->tested; + $version_to_check_against = (string) ( self::get_current_major_wp_version() - 3.5 ); // 35 major releases behind is at least 10 years. + + $last_updated = new \DateTime( $post->last_updated ?: $post->post_modified_gmt ); + $date_threshold = new \DateTime( '10 years ago' ); + + // A plugin is obsolete if it hasn't been updated in a long time AND hasn't been tested against a modern version. + return version_compare( $version_to_check_against, $tested_up_to, '>' ) + && $last_updated < $date_threshold; + } + /** * Returns a string representing the number of active installations for an item. * @@ -721,6 +742,26 @@ public static function download_link( $post = null, $version = 'latest' ) { } } + /** + * Determine whether or not we should show a primary Download button for a given plugin. + * Generally yes, but there are exceptions for closed and very old buttons. + * + * @param int|\WP_Post|null $post Optional. Post ID or object. Defaults to global $post. + * @return bool True if the button should be shown; false otherwise. + */ + public static function is_download_available( $post = null ) { + $post = get_post( $post ); + + if ( 'publish' === get_post_status() || current_user_can( 'plugin_admin_view', $post ) ) { + // We usually want to have a download button for published plugins; but not if it's ancient. + if ( ! self::is_plugin_obsolete( $post ) ) { + return true; + } + } + + return false; + } + /** * Is a live preview available for the plugin, and allowed for the current user to view? * @@ -1117,7 +1158,7 @@ public static function get_close_data( $post = null ) { $result['public'] = true; } - return $result; + return $result; } /** diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/inc/template-tags.php b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/inc/template-tags.php index 51013b327e..59e01c8763 100644 --- a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/inc/template-tags.php +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/inc/template-tags.php @@ -177,7 +177,12 @@ function get_plugin_status_notice( $post = null ) { switch ( $post_status ) { case 'publish': - if ( Template::is_plugin_outdated( $post ) ) { + if ( Template::is_plugin_obsolete( $post ) ) { + $message = sprintf( + $warning_notice, + __( 'This plugin is obsolete. It has not been maintained in many years, and should not be used on a new site. It is available here for archival and historical reasons.', 'wporg-plugins' ) + ); + } elseif ( Template::is_plugin_outdated( $post ) ) { $message = sprintf( $warning_notice, __( 'This plugin hasnt been tested with the latest 3 major releases of WordPress. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.', 'wporg-plugins' ) diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/template-parts/plugin-single.php b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/template-parts/plugin-single.php index b28bcffb99..5ce3476a95 100644 --- a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/template-parts/plugin-single.php +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/template-parts/plugin-single.php @@ -51,7 +51,7 @@ '; - if ( 'publish' === get_post_status() || current_user_can( 'plugin_admin_view', $post ) ) { + if ( Template::is_download_available() ) { $buttons .= sprintf( '