Skip to:
Content

bbPress.org

Changeset 6705


Ignore:
Timestamp:
09/14/2017 10:57:06 PM (9 years ago)
Author:
johnjamesjacoby
Message:

Admin: add an admin notice if database upgrade was skipped.

This change adds a persistent admin notice (who doesn't love those?) in the event that the forums are part of a large WordPress installation that prevented the automatic database upgrade routine from running.

Two links are provided: one to "Go Upgrade" and another to "Hide Forever". The first will take the user (with adequate capability) to the Tools > Forums > Upgrade screen; the second will delete the notice nag key from wp_options.

This includes some admin area CSS tweaks, so the asset version gets a bump as well.

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bbpress.php

    r6699 r6705  
    204204        /** Versions **********************************************************/
    205205
    206         $this->version    = '2.6-rc-6698';
     206        $this->version    = '2.6-rc-6701';
    207207        $this->db_version = '262';
    208208
  • trunk/src/includes/admin/assets/css/admin.css

    r6690 r6705  
    4242.bbp-hive:before {
    4343    content: "\f449";
     44}
     45
     46.notice-bbpress {
     47    border-left: 4px solid #78cd95;
     48    padding-left: 36px;
     49    background-color: rgb(235, 255, 235);
     50    position: relative;
     51}
     52
     53.notice-bbpress .bbpress-logo-icon {
     54    position: absolute;
     55    height: auto;
     56    width: auto;
     57    padding: 7px 9px;
     58    top: 50%;
     59    left: 0;
     60    transform: translateY(-50%);
     61    font: 400 24px/1 dashicons !important;
     62}
     63
     64.notice-bbpress .bbpress-logo-icon:before {
     65    content: "\f477";
     66    color: #555;
    4467}
    4568
  • trunk/src/includes/admin/classes/class-bbp-admin.php

    r6604 r6705  
    150150        /** General Actions ***************************************************/
    151151
     152        add_action( 'bbp_admin_init',              array( $this, 'setup_notices'           ) );
     153        add_action( 'bbp_admin_init',              array( $this, 'hide_notices'            ) );
    152154        add_action( 'bbp_admin_menu',              array( $this, 'admin_menus'             ) ); // Add menu item to settings menu
    153155        add_action( 'bbp_admin_head',              array( $this, 'admin_head'              ) ); // Add some general styling to the admin area
     
    185187        // Allow plugins to modify these actions
    186188        do_action_ref_array( 'bbp_admin_loaded', array( &$this ) );
     189    }
     190
     191    /**
     192     * Setup general admin area notices.
     193     *
     194     * @since 2.6.0 bbPress (r6701)
     195     */
     196    public function setup_notices() {
     197
     198        // Database upgrade skipped?
     199        $skipped = get_option( '_bbp_db_upgrade_skipped', 0 );
     200
     201        // Database upgrade skipped!
     202        if ( ! empty( $skipped ) && ( $skipped < 260 ) && current_user_can( 'bbp_tools_upgrade_page' ) ) {
     203
     204            // Link to upgrade page
     205            $upgrade_url  = add_query_arg( array( 'page' => 'bbp-upgrade' ), admin_url( 'tools.php' ) );
     206            $dismiss_url  = wp_nonce_url( add_query_arg( array( 'bbp-hide-notice' => 'bbp-skip-upgrade' ) ), 'bbp-hide-notice' );
     207            $upgrade_link = '<a href="' . esc_url( $upgrade_url ) . '">' . esc_html__( 'Go Upgrade',   'bbpress' ) . '</a>';
     208            $dismiss_link = '<a href="' . esc_url( $dismiss_url ) . '">' . esc_html__( 'Hide Forever', 'bbpress' ) . '</a>';
     209            $bbp_dashicon = '<span class="bbpress-logo-icon"></span>';
     210            $message      = $bbp_dashicon . sprintf(
     211                esc_html__( 'bbPress requires a manual database upgrade. %s or %s', 'bbpress' ),
     212                $upgrade_link,
     213                $dismiss_link
     214            );
     215
     216            // Add tools feedback
     217            bbp_admin_tools_feedback( $message, 'notice-bbpress', false );
     218        }
     219    }
     220
     221    /**
     222     * Handle hiding of general admin area notices.
     223     *
     224     * @since 2.6.0 bbPress (r6701)
     225     */
     226    public function hide_notices() {
     227
     228        // Bail if not hiding a notice
     229        if ( empty( $_GET['bbp-hide-notice'] ) ) {
     230            return;
     231        }
     232
     233        // Check the admin referer
     234        check_admin_referer( 'bbp-hide-notice' );
     235
     236        // Maybe delete notices
     237        switch ( $_GET['bbp-hide-notice'] ) {
     238
     239            // Skipped upgrade notice
     240            case 'bbp-skip-upgrade' :
     241                delete_option( '_bbp_db_upgrade_skipped' );
     242                break;
     243        }
    187244    }
    188245
  • trunk/src/includes/core/options.php

    r6695 r6705  
    3131
    3232        '_bbp_db_version'             => 0,         // Database version
     33        '_bbp_db_upgrade_skipped'     => 0,         // Database upgrade skipped
    3334
    3435        /** Features **********************************************************/
  • trunk/src/includes/core/update.php

    r6573 r6705  
    315315        /** 2.6 Branch ********************************************************/
    316316
    317         // 2.6.x
     317        // 2.6 Alpha
    318318        if ( $raw_db_version < 261 ) {
    319319
     
    327327                bbp_admin_upgrade_user_topic_subscriptions();
    328328                bbp_admin_upgrade_user_forum_subscriptions();
     329            } else {
     330                update_option( '_bbp_db_upgrade_skipped', $raw_db_version );
    329331            }
    330332        }
    331333
     334        // 2.6 Beta/RC/GM
    332335        if ( $raw_db_version < 262 ) {
    333336
     
    339342            if ( ! bbp_is_large_install() ) {
    340343                bbp_admin_upgrade_user_engagements();
     344            } else {
     345                update_option( '_bbp_db_upgrade_skipped', $raw_db_version );
    341346            }
    342347        }
Note: See TracChangeset for help on using the changeset viewer.