<!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][11174] trunk/src/bp-core/admin: Admin: Block updates to BuddyPress 2.8 if PHP version is < 5.3.</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/11174">11174</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/11174","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>r-a-y</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-10-06 07:30:54 +0000 (Thu, 06 Oct 2016)</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'>Admin: Block updates to BuddyPress 2.8 if PHP version is < 5.3.

BuddyPress 2.8 is going to require PHP 5.3+.  To prepare for this, we are
adding some functionality to block updates to BP 2.8 in the WP admin
dashboard for BP 2.7.0.

Props boonebgorges, r-a-y, hnla, mercime.

See <a href="http://buddypress.trac.wordpress.org/ticket/7196">#7196</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpcoreadminbpcoreadminfunctionsphp">trunk/src/bp-core/admin/bp-core-admin-functions.php</a></li>
<li><a href="#trunksrcbpcoreadmincsscommonrtlcss">trunk/src/bp-core/admin/css/common-rtl.css</a></li>
<li><a href="#trunksrcbpcoreadmincsscommoncss">trunk/src/bp-core/admin/css/common.css</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       2016-10-05 19:26:47 UTC (rev 11173)
+++ trunk/src/bp-core/admin/bp-core-admin-functions.php 2016-10-06 07:30:54 UTC (rev 11174)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1113,3 +1113,139 @@
</span><span class="cx" style="display: block; padding: 0 10px">        </script>
</span><span class="cx" style="display: block; padding: 0 10px">        <?php
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/** Upgrade protection *******************************************************/
+
+/**
+ * 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, 2 );
+       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>";
+}
</ins></span></pre></div>
<a id="trunksrcbpcoreadmincsscommonrtlcss"></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/css/common-rtl.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/admin/css/common-rtl.css        2016-10-05 19:26:47 UTC (rev 11173)
+++ trunk/src/bp-core/admin/css/common-rtl.css  2016-10-06 07:30:54 UTC (rev 11174)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -21,6 +21,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 3.0 User's Lists
</span><span class="cx" style="display: block; padding: 0 10px"> 4.0 Emails - Edit page
</span><span class="cx" style="display: block; padding: 0 10px"> 5.0 Tools - BuddyPress
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+6.0 Plugins page
</ins><span class="cx" style="display: block; padding: 0 10px"> ------------------------------------------------------------------------------*/
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /*------------------------------------------------------------------------------
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -536,3 +537,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">                padding: 0 30px 0 0;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+
+/*------------------------------------------------------------------------------
+ * 6.0 Plugins page
+ *----------------------------------------------------------------------------*/
+#buddypress-update.not-shiny .update-message {
+       border-right: 0;
+       padding-right: 36px;
+}
+
+#buddypress-update.not-shiny .update-message:before {
+       content: "\f534";
+}
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre></div>
<a id="trunksrcbpcoreadmincsscommoncss"></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/css/common.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-core/admin/css/common.css    2016-10-05 19:26:47 UTC (rev 11173)
+++ trunk/src/bp-core/admin/css/common.css      2016-10-06 07:30:54 UTC (rev 11174)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -21,6 +21,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 3.0 User's Lists
</span><span class="cx" style="display: block; padding: 0 10px"> 4.0 Emails - Edit page
</span><span class="cx" style="display: block; padding: 0 10px"> 5.0 Tools - BuddyPress
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+6.0 Plugins page
</ins><span class="cx" style="display: block; padding: 0 10px"> ------------------------------------------------------------------------------*/
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /*------------------------------------------------------------------------------
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -536,3 +537,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">                padding: 0 0 0 30px;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+
+/*------------------------------------------------------------------------------
+ * 6.0 Plugins page
+ *----------------------------------------------------------------------------*/
+#buddypress-update.not-shiny .update-message {
+       border-left: 0;
+       padding-left: 36px;
+}
+
+#buddypress-update.not-shiny .update-message:before {
+       content: "\f534";
+}
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span></span></pre>
</div>
</div>

</body>
</html>