Making WordPress.org

Changeset 5627


Ignore:
Timestamp:
07/07/2017 07:34:23 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Support Forums: Introduce plugin versioning to flush rewrite rules when necessary.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-plugin.php

    r4128 r5627  
    1616     */
    1717    private static $instance;
     18
     19    /**
     20     * @var int Plugin DB revision, increments when changes are made to rewrite rules.
     21     */
     22    private static $db_version = 5627;
    1823
    1924    /**
     
    5156            $this->plugins         = new Plugin_Directory_Compat;
    5257        }
     58
     59        add_action( 'bbp_add_rewrite_rules', array( $this, 'maybe_flush_rewrite_rules' ) );
    5360    }
     61
     62    /**
     63     * Check the plugin version to see if rewrite rules should be flushed.
     64     */
     65    public function maybe_flush_rewrite_rules() {
     66        $db_version_option_name = 'wporg_support_forums_plugin_db_version';
     67
     68        if ( get_option( $db_version_option_name ) != self::$db_version ) {
     69            flush_rewrite_rules();
     70            update_option( $db_version_option_name, self::$db_version );
     71        }
     72    }
     73
    5474}
Note: See TracChangeset for help on using the changeset viewer.