<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][11390] trunk/src/bp-core: Deprecate 2.7 functions protect against BP upgrades on PHP 5.2.x.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://buddypress.trac.wordpress.org/changeset/11390">11390</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/11390","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>boonebgorges</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2017-01-19 19:39:12 +0000 (Thu, 19 Jan 2017)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Deprecate 2.7 functions protect against BP upgrades on PHP 5.2.x.
BuddyPress 2.8 will not load on systems running PHP 5.2.x, so that
these functions will do nothing. In the future, their logic can be
repurposed for further PHP requirement upgrades.
Fixes <a href="http://buddypress.trac.wordpress.org/ticket/7277">#7277</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpcoreadminbpcoreadminfunctionsphp">trunk/src/bp-core/admin/bp-core-admin-functions.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunksrcbpcoredeprecated28php">trunk/src/bp-core/deprecated/2.8.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpcoreadminbpcoreadminfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-core/admin/bp-core-admin-functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/admin/bp-core-admin-functions.php 2017-01-19 19:25:11 UTC (rev 11389)
+++ trunk/src/bp-core/admin/bp-core-admin-functions.php 2017-01-19 19:39:12 UTC (rev 11390)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1114,192 +1114,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/** Upgrade protection *******************************************************/
-
</del><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Determines whether the current installation is running PHP 5.3 or greater.
- *
- * BuddyPress 2.8 introduces a minimum PHP requirement of PHP 5.3.
- *
- * @since 2.7.0
- *
- * @return bool
- */
-function bp_core_admin_is_running_php53_or_greater() {
- return version_compare( PHP_VERSION, '5.3', '>=' );
-}
-
-/**
- * Replaces WP's default update notice on plugins.php with an error message, when site is not running PHP 5.3 or greater.
- *
- * @since 2.7.0
- */
-function bp_core_admin_maybe_disable_update_row_for_php53_requirement() {
- if ( bp_core_admin_is_running_php53_or_greater() ) {
- return;
- }
-
- $loader = basename( constant( 'BP_PLUGIN_DIR' ) ) . '/bp-loader.php';
-
- remove_action( "after_plugin_row_{$loader}", 'wp_plugin_update_row', 10 );
- add_action( "after_plugin_row_{$loader}", 'bp_core_admin_php52_plugin_row', 10, 2 );
-}
-add_action( 'load-plugins.php', 'bp_core_admin_maybe_disable_update_row_for_php53_requirement', 100 );
-
-/**
- * On the "Dashboard > Updates" page, remove BuddyPress from plugins list if PHP < 5.3.
- *
- * @since 2.7.0
- */
-function bp_core_admin_maybe_remove_from_update_core() {
- if ( bp_core_admin_is_running_php53_or_greater() ) {
- return;
- }
-
- // Add filter to remove BP from the update plugins list.
- add_filter( 'site_transient_update_plugins', 'bp_core_admin_remove_buddypress_from_update_transient' );
-}
-add_action( 'load-update-core.php', 'bp_core_admin_maybe_remove_from_update_core' );
-
-/**
- * Filter callback to remove BuddyPress from the update plugins list.
- *
- * Attached to the 'site_transient_update_plugins' filter.
- *
- * @since 2.7.0
- *
- * @param object $retval Object of plugin update data.
- * @return object
- */
-function bp_core_admin_remove_buddypress_from_update_transient( $retval ) {
- $loader = basename( constant( 'BP_PLUGIN_DIR' ) ) . '/bp-loader.php';
-
- // Remove BP from update plugins list.
- if ( isset( $retval->response[ $loader ] ) ) {
- unset( $retval->response[ $loader ] );
- }
-
- return $retval;
-}
-
-/**
- * Outputs a replacement for WP's default update notice, when site is not running PHP 5.3 or greater.
- *
- * When we see that a site is not running PHP 5.3 and is trying to update to
- * BP 2.8+, we replace WP's default notice with our own, which both provides a
- * link to our documentation of the requirement, and removes the link that
- * allows a single plugin to be updated.
- *
- * @since 2.7.0
- *
- * @param string $file Plugin filename. buddypress/bp-loader.php.
- * @param array $plugin_data Data about the BuddyPress plugin, as returned by the
- * plugins API.
- */
-function bp_core_admin_php52_plugin_row( $file, $plugin_data ) {
- if ( is_multisite() && ! is_network_admin() ) {
- return;
- }
-
- $current = get_site_transient( 'update_plugins' );
- if ( ! isset( $current->response[ $file ] ) ) {
- return false;
- }
-
- $response = $current->response[ $file ];
-
- // No need to do this if update is for < BP 2.8.
- if ( version_compare( $response->new_version, '2.8', '<' ) ) {
- return false;
- }
-
- $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
-
- if ( is_network_admin() ) {
- $active_class = is_plugin_active_for_network( $file ) ? ' active' : '';
- } else {
- $active_class = is_plugin_active( $file ) ? ' active' : '';
- }
-
- // WP 4.6 uses different markup for the plugin row notice.
- if ( function_exists( 'wp_get_ext_types' ) ) {
- $p = '<p>%s</p>';
-
- // WP < 4.6.
- } else {
- $p = '%s';
-
- // Ugh.
- $active_class .= ' not-shiny';
- }
-
- echo '<tr class="plugin-update-tr' . $active_class . '" id="' . esc_attr( $response->slug . '-update' ) . '" data-slug="' . esc_attr( $response->slug ) . '" data-plugin="' . esc_attr( $file ) . '"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message inline notice notice-error notice-alt">';
-
- printf( $p,
- esc_html__( 'A BuddyPress update is available, but your system is not compatible.', 'buddypress' ) . ' ' .
- sprintf( __( 'See <a href="%s">the Codex guide</a> for more information.', 'buddypress' ), 'https://codex.buddypress.org/getting-started/buddypress-2-8-will-require-php-5-3/' )
- );
-
- echo '</div></td></tr>';
-
- /*
- * JavaScript to disable the bulk upgrade checkbox.
- * See WP_Plugins_List_Table::single_row().
- */
- $checkbox_id = 'checkbox_' . md5( $plugin_data['Name'] );
- echo "<script type='text/javascript'>document.getElementById('$checkbox_id').disabled = true;</script>";
-}
-
-/**
- * Add an admin notice to installations that are not running PHP 5.3+.
- *
- * @since 2.7.0
- */
-function bp_core_admin_php53_admin_notice() {
- // If not on the Plugins page, stop now.
- if ( 'plugins' !== get_current_screen()->parent_base ) {
- return;
- }
-
- if ( ! current_user_can( 'update_core' ) ) {
- return;
- }
-
- if ( bp_core_admin_is_running_php53_or_greater() ) {
- return;
- }
-
- $notice_id = 'bp28-php53';
- if ( bp_get_option( "bp-dismissed-notice-$notice_id" ) ) {
- return;
- }
-
- $bp = buddypress();
- $min = bp_core_get_minified_asset_suffix();
-
- wp_enqueue_script(
- 'bp-dismissible-admin-notices',
- "{$bp->plugin_url}bp-core/admin/js/dismissible-admin-notices{$min}.js",
- array( 'jquery' ),
- bp_get_version(),
- true
- );
-
- $php_version = PHP_VERSION;
-
- ?>
-
- <div id="message" class="error notice is-dismissible bp-is-dismissible" data-noticeid="<?php echo esc_attr( $notice_id ); ?>">
- <p><strong><?php esc_html_e( 'Your site is not ready for BuddyPress 2.8.', 'buddypress' ); ?></strong></p>
- <p><?php printf( esc_html__( 'Your site is currently running PHP version %s, while BuddyPress 2.8 will require version 5.3+.', 'buddypress' ), $php_version ); ?> <?php printf( __( 'See <a href="%s">the Codex guide</a> for more information.', 'buddypress' ), 'https://codex.buddypress.org/getting-started/buddypress-2-8-will-require-php-5-3/' ); ?></p>
- <?php wp_nonce_field( "bp-dismissible-notice-$notice_id", "bp-dismissible-nonce-$notice_id" ); ?>
- </div>
- <?php
-}
-add_action( 'admin_notices', 'bp_core_admin_php53_admin_notice' );
-add_action( 'network_admin_notices', 'bp_core_admin_php53_admin_notice' );
-
-/**
</del><span class="cx" style="display: block; padding: 0 10px"> * Catch and process an admin notice dismissal.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.7.0
</span></span></pre></div>
<a id="trunksrcbpcoredeprecated28php"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/bp-core/deprecated/2.8.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/deprecated/2.8.php (rev 0)
+++ trunk/src/bp-core/deprecated/2.8.php 2017-01-19 19:39:12 UTC (rev 11390)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,199 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Deprecated functions.
+ *
+ * @deprecated 2.8.0
+ */
+
+// Exit if accessed directly.
+defined( 'ABSPATH' ) || exit;
+
+/**
+ * Determines whether the current installation is running PHP 5.3 or greater.
+ *
+ * BuddyPress 2.8 introduces a minimum PHP requirement of PHP 5.3.
+ *
+ * @since 2.7.0
+ * @deprecated 2.8.0
+ *
+ * @return bool
+ */
+function bp_core_admin_is_running_php53_or_greater() {
+ return version_compare( PHP_VERSION, '5.3', '>=' );
+}
+
+/**
+ * Replaces WP's default update notice on plugins.php with an error message, when site is not running PHP 5.3 or greater.
+ *
+ * Originally hooked to 'load-plugins.php' with priority 100.
+ *
+ * @since 2.7.0
+ * @deprecated 2.8.0
+ */
+function bp_core_admin_maybe_disable_update_row_for_php53_requirement() {
+ if ( bp_core_admin_is_running_php53_or_greater() ) {
+ return;
+ }
+
+ $loader = basename( constant( 'BP_PLUGIN_DIR' ) ) . '/bp-loader.php';
+
+ remove_action( "after_plugin_row_{$loader}", 'wp_plugin_update_row', 10 );
+ add_action( "after_plugin_row_{$loader}", 'bp_core_admin_php52_plugin_row', 10, 2 );
+}
+
+/**
+ * On the "Dashboard > Updates" page, remove BuddyPress from plugins list if PHP < 5.3.
+ *
+ * Originally hooked to 'load-update-core.php'.
+ *
+ * @since 2.7.0
+ * @deprecated 2.8.0
+ */
+function bp_core_admin_maybe_remove_from_update_core() {
+ if ( bp_core_admin_is_running_php53_or_greater() ) {
+ return;
+ }
+
+ // Add filter to remove BP from the update plugins list.
+ add_filter( 'site_transient_update_plugins', 'bp_core_admin_remove_buddypress_from_update_transient' );
+}
+
+/**
+ * Filter callback to remove BuddyPress from the update plugins list.
+ *
+ * Attached to the 'site_transient_update_plugins' filter.
+ *
+ * @since 2.7.0
+ * @deprecated 2.8.0
+ *
+ * @param object $retval Object of plugin update data.
+ * @return object
+ */
+function bp_core_admin_remove_buddypress_from_update_transient( $retval ) {
+ $loader = basename( constant( 'BP_PLUGIN_DIR' ) ) . '/bp-loader.php';
+
+ // Remove BP from update plugins list.
+ if ( isset( $retval->response[ $loader ] ) ) {
+ unset( $retval->response[ $loader ] );
+ }
+
+ return $retval;
+}
+
+/**
+ * Outputs a replacement for WP's default update notice, when site is not running PHP 5.3 or greater.
+ *
+ * When we see that a site is not running PHP 5.3 and is trying to update to
+ * BP 2.8+, we replace WP's default notice with our own, which both provides a
+ * link to our documentation of the requirement, and removes the link that
+ * allows a single plugin to be updated.
+ *
+ * @since 2.7.0
+ * @deprecated 2.8.0
+ *
+ * @param string $file Plugin filename. buddypress/bp-loader.php.
+ * @param array $plugin_data Data about the BuddyPress plugin, as returned by the
+ * plugins API.
+ */
+function bp_core_admin_php52_plugin_row( $file, $plugin_data ) {
+ if ( is_multisite() && ! is_network_admin() ) {
+ return;
+ }
+
+ $current = get_site_transient( 'update_plugins' );
+ if ( ! isset( $current->response[ $file ] ) ) {
+ return false;
+ }
+
+ $response = $current->response[ $file ];
+
+ // No need to do this if update is for < BP 2.8.
+ if ( version_compare( $response->new_version, '2.8', '<' ) ) {
+ return false;
+ }
+
+ $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
+
+ if ( is_network_admin() ) {
+ $active_class = is_plugin_active_for_network( $file ) ? ' active' : '';
+ } else {
+ $active_class = is_plugin_active( $file ) ? ' active' : '';
+ }
+
+ // WP 4.6 uses different markup for the plugin row notice.
+ if ( function_exists( 'wp_get_ext_types' ) ) {
+ $p = '<p>%s</p>';
+
+ // WP < 4.6.
+ } else {
+ $p = '%s';
+
+ // Ugh.
+ $active_class .= ' not-shiny';
+ }
+
+ echo '<tr class="plugin-update-tr' . $active_class . '" id="' . esc_attr( $response->slug . '-update' ) . '" data-slug="' . esc_attr( $response->slug ) . '" data-plugin="' . esc_attr( $file ) . '"><td colspan="' . esc_attr( $wp_list_table->get_column_count() ) . '" class="plugin-update colspanchange"><div class="update-message inline notice notice-error notice-alt">';
+
+ printf( $p,
+ esc_html__( 'A BuddyPress update is available, but your system is not compatible.', 'buddypress' ) . ' ' .
+ sprintf( __( 'See <a href="%s">the Codex guide</a> for more information.', 'buddypress' ), 'https://codex.buddypress.org/getting-started/buddypress-2-8-will-require-php-5-3/' )
+ );
+
+ echo '</div></td></tr>';
+
+ /*
+ * JavaScript to disable the bulk upgrade checkbox.
+ * See WP_Plugins_List_Table::single_row().
+ */
+ $checkbox_id = 'checkbox_' . md5( $plugin_data['Name'] );
+ echo "<script type='text/javascript'>document.getElementById('$checkbox_id').disabled = true;</script>";
+}
+
+/**
+ * Add an admin notice to installations that are not running PHP 5.3+.
+ *
+ * @since 2.7.0
+ * @deprecated 2.8.0
+ */
+function bp_core_admin_php53_admin_notice() {
+ // If not on the Plugins page, stop now.
+ if ( 'plugins' !== get_current_screen()->parent_base ) {
+ return;
+ }
+
+ if ( ! current_user_can( 'update_core' ) ) {
+ return;
+ }
+
+ if ( bp_core_admin_is_running_php53_or_greater() ) {
+ return;
+ }
+
+ $notice_id = 'bp28-php53';
+ if ( bp_get_option( "bp-dismissed-notice-$notice_id" ) ) {
+ return;
+ }
+
+ $bp = buddypress();
+ $min = bp_core_get_minified_asset_suffix();
+
+ wp_enqueue_script(
+ 'bp-dismissible-admin-notices',
+ "{$bp->plugin_url}bp-core/admin/js/dismissible-admin-notices{$min}.js",
+ array( 'jquery' ),
+ bp_get_version(),
+ true
+ );
+
+ $php_version = PHP_VERSION;
+
+ ?>
+
+ <div id="message" class="error notice is-dismissible bp-is-dismissible" data-noticeid="<?php echo esc_attr( $notice_id ); ?>">
+ <p><strong><?php esc_html_e( 'Your site is not ready for BuddyPress 2.8.', 'buddypress' ); ?></strong></p>
+ <p><?php printf( esc_html__( 'Your site is currently running PHP version %s, while BuddyPress 2.8 will require version 5.3+.', 'buddypress' ), $php_version ); ?> <?php printf( __( 'See <a href="%s">the Codex guide</a> for more information.', 'buddypress' ), 'https://codex.buddypress.org/getting-started/buddypress-2-8-will-require-php-5-3/' ); ?></p>
+ <?php wp_nonce_field( "bp-dismissible-notice-$notice_id", "bp-dismissible-nonce-$notice_id" ); ?>
+ </div>
+ <?php
+}
+
</ins></span></pre>
</div>
</div>
</body>
</html>