Automattic / gutenberg-ramp

Control conditions under which Gutenberg loads - either from your theme code or from a UI
https://wordpress.org/plugins/gutenberg-ramp/
76 stars 15 forks source link

Prefix update for .org consistency #46

Closed maevelander closed 6 years ago

maevelander commented 6 years ago

Ramp plugin was approved for .org repo with slug gutenberg-ramp. We had intended it would be ramp-for-gutenberg (inline with the plugin guidelines on project names). Thus we used the prefix ramp_for_gutenberg_ in the plugin. To remove inconsistency, we should:

pyronaur commented 6 years ago

I submitted a PR, a few notes:

To avoid two reloads, we could do something like this on VIP Go helper file, but this seems like overkill:


function gutenberg_ramp_migrate() {

    $old_criteria = get_option( 'ramp_for_gutenberg_load_critera' );

    // Fail fast if there is no old criteria
    if ( false === $old_criteria ) {
        return false;
    }

    $new_criteria = get_option( 'gutenberg_ramp_load_critera' );

    // Cancel if there is already new criteria
    if ( ! empty( $new_criteria ) ) {
        return false;
    }

    // --- at this point $new_criteria doesn't exist, and $old_criteria has been defined

    // Update new option
    update_option( 'gutenberg_ramp_load_critera', $old_criteria );

    // Delete the old option
    delete_option( 'ramp_for_gutenberg_load_critera' );
}

// Ready, Set, Migrate:
// This would run before anything else related to Gutenberg Ramp
// For example
gutenberg_ramp_migrate();

^^-- If that snippet is used, we need to make sure it's loaded before anything else related to Gutenberg Ramp. This seems like a good place to do so.