Skip to:
Content

BuddyPress.org

Ticket #7196: 7196.03.patch

File 7196.03.patch, 5.0 KB (added by r-a-y, 3 years ago)
  • bp-loader.php

     
    1515 * Description: BuddyPress helps site builders and WordPress developers add community features to their websites, with user profile fields, activity streams, messaging, and notifications.
    1616 * Author:      The BuddyPress Community
    1717 * Author URI:  https://buddypress.org
    18  * Version:     2.7-beta1
     18 * Version:     2.5
    1919 * Text Domain: buddypress
    2020 * Domain Path: /bp-languages/
    2121 * License:     GPLv2 or later (license.txt)
  • src/bp-core/admin/bp-core-admin-functions.php

     
    11131113        </script>
    11141114        <?php
    11151115}
     1116
     1117/** Upgrade protection *******************************************************/
     1118
     1119/**
     1120 * Determines whether the current installation is running PHP 5.3 or greater.
     1121 *
     1122 * BuddyPress 2.8 introduces a minimum PHP requirement of PHP 5.3.
     1123 *
     1124 * @since 2.7.0
     1125 *
     1126 * @return bool
     1127 */
     1128function bp_core_admin_is_running_php53_or_greater() {
     1129        // @todo Change this back to 5.3 before committing!
     1130        return version_compare( PHP_VERSION, '7', '>=' );
     1131}
     1132
     1133/**
     1134 * Replaces WP's default update notice on plugins.php with an error message, when site is not running PHP 5.3 or greater.
     1135 *
     1136 * @since 2.7.0
     1137 */
     1138function bp_core_admin_maybe_disable_update_row_for_php53_requirement() {
     1139        if ( bp_core_admin_is_running_php53_or_greater() ) {
     1140                return;
     1141        }
     1142
     1143        $loader = basename( constant( 'BP_PLUGIN_DIR' ) ) . '/bp-loader.php';
     1144
     1145        remove_action( "after_plugin_row_{$loader}", 'wp_plugin_update_row', 10, 2 );
     1146        add_action( "after_plugin_row_{$loader}", 'bp_core_admin_php52_plugin_row', 10, 2 );
     1147}
     1148add_action( 'load-plugins.php', 'bp_core_admin_maybe_disable_update_row_for_php53_requirement', 100 );
     1149
     1150/**
     1151 * On the "Dashboard > Updates" page, remove BuddyPress from plugins list if PHP < 5.3.
     1152 *
     1153 * @since 2.7.0
     1154 */
     1155function bp_core_admin_maybe_remove_from_update_core() {
     1156        if ( bp_core_admin_is_running_php53_or_greater() ) {
     1157                return;
     1158        }
     1159
     1160        // Add filter to remove BP from the update plugins list.
     1161        add_filter( 'site_transient_update_plugins', 'bp_core_admin_remove_buddypress_from_update_transient' );
     1162}
     1163add_action( 'load-update-core.php', 'bp_core_admin_maybe_remove_from_update_core' );
     1164
     1165/**
     1166 * Filter callback to remove BuddyPress from the update plugins list.
     1167 *
     1168 * Attached to the 'site_transient_update_plugins' filter.
     1169 *
     1170 * @since 2.7.0
     1171 *
     1172 * @param  object $retval Object of plugin update data.
     1173 * @return object
     1174 */
     1175function bp_core_admin_remove_buddypress_from_update_transient( $retval ) {
     1176        $loader = basename( constant( 'BP_PLUGIN_DIR' ) ) . '/bp-loader.php';
     1177
     1178        // Remove BP from update plugins list.
     1179        if ( isset( $retval->response[ $loader ] ) ) {
     1180                unset( $retval->response[ $loader ] );
     1181        }
     1182
     1183        return $retval;
     1184}
     1185
     1186/**
     1187 * Outputs a replacement for WP's default update notice, when site is not running PHP 5.3 or greater.
     1188 *
     1189 * When we see that a site is not running PHP 5.3 and is trying to update to
     1190 * BP 2.8+, we replace WP's default notice with our own, which both provides a
     1191 * link to our documentation of the requirement, and removes the link that
     1192 * allows a single plugin to be updated.
     1193 *
     1194 * @since 2.7.0
     1195 *
     1196 * @param string $file        Plugin filename. buddypress/bp-loader.php.
     1197 * @param array  $plugin_data Data about the BuddyPress plugin, as returned by the
     1198 *                            plugins API.
     1199 */
     1200function bp_core_admin_php52_plugin_row( $file, $plugin_data ) {
     1201        if ( is_multisite() && ! is_network_admin() ) {
     1202                return;
     1203        }
     1204
     1205        $current = get_site_transient( 'update_plugins' );
     1206        if ( ! isset( $current->response[ $file ] ) ) {
     1207                return false;
     1208        }
     1209
     1210        $response = $current->response[ $file ];
     1211
     1212        // @todo Uncomment the return value before committing!
     1213        if ( version_compare( $response->new_version, '2.8', '<' ) ) {
     1214                //return false;
     1215        }
     1216
     1217        $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
     1218
     1219        if ( is_network_admin() ) {
     1220                $active_class = is_plugin_active_for_network( $file ) ? ' active' : '';
     1221        } else {
     1222                $active_class = is_plugin_active( $file ) ? ' active' : '';
     1223        }
     1224
     1225        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 notice inline notice-error notice-alt"><p>';
     1226
     1227        printf( esc_html__( 'A BuddyPress update is available, but your system is not compatible. See %s for more information.', 'buddypress' ), '<a href="#">some link</a>' );
     1228        echo '</p></td></tr>';
     1229
     1230        // JavaScript to disable the bulk upgrade checkbox.
     1231        $checkbox_id = 'checkbox_' . md5( $plugin_data['Name'] );
     1232        echo "<script type='text/javascript'>document.getElementById('$checkbox_id').disabled = true;</script>";
     1233}