Plugin Directory

Changeset 3382121


Ignore:
Timestamp:
10/21/2025 06:03:12 PM (5 months ago)
Author:
abtestkit
Message:

Bump to 1.0.1; harden activation redirect so onboarding opens reliably.

Location:
abtestkit/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • abtestkit/trunk/abtestkit.php

    r3380834 r3382121  
    22/**
    33 * Plugin Name:       abtestkit
    4  * Plugin URI:        https://github.com/abtestkit
     4 * Plugin URI:        https://wordpress.org/plugins/abtestkit
    55 * Description:       Simple, in-editor testing for WordPress Core Editor (Gutenberg).
    6  * Version:           1.0.0
     6 * Version:           1.0.1
    77 * Author:            abtestkit
    88 * License:           GPL-2.0-or-later
     
    7979    return [
    8080        'plugin'   => 'abtestkit',
    81         'version'  => '1.0.0',
     81        'version'  => '1.0.1',
    8282        'site'     => md5( home_url() ), // anonymous hash
    8383        'wp'       => get_bloginfo( 'version' ),
     
    104104
    105105// ───────────────────────────────────────────────────────────
    106 // One-time redirect + "onboarding complete" flag
     106// One-time redirect + "onboarding complete" flag (hardened)
    107107// ───────────────────────────────────────────────────────────
    108108register_activation_hook( __FILE__, 'abtestkit_activate_onboarding' );
    109109function abtestkit_activate_onboarding() {
    110     if ( ! get_option( 'abtestkit_onboarding_done' ) ) {
     110    // Create the "done" flag if missing
     111    if ( get_option( 'abtestkit_onboarding_done', null ) === null ) {
    111112        add_option( 'abtestkit_onboarding_done', '0' );
    112113    }
    113     add_option( 'abtestkit_do_activation_redirect', '1' );
    114 }
    115 
     114    // Set the one-time redirect flag
     115    update_option( 'abtestkit_do_activation_redirect', '1', true );
     116}
     117
     118/**
     119 * Some activation paths don’t reliably run the activation callback in the
     120 * same request pipeline that lands you back in wp-admin. This ensures the
     121 * flag is still set right after the specific plugin is activated.
     122 */
     123add_action( 'activated_plugin', function( $plugin ) {
     124    if ( $plugin === plugin_basename( __FILE__ ) ) {
     125        update_option( 'abtestkit_do_activation_redirect', '1', true );
     126    }
     127}, 10, 1 );
     128
     129/**
     130 * Perform the one-time redirect as soon as we’re safely in admin.
     131 */
    116132add_action( 'admin_init', function () {
    117     if ( '1' === get_option( 'abtestkit_do_activation_redirect' ) ) {
    118         delete_option( 'abtestkit_do_activation_redirect' );
    119 
    120         // Avoid redirect loops / bulk activations / Ajax
    121         if ( ! wp_doing_ajax() && ! isset( $_GET['activate-multi'] ) ) {
    122             wp_safe_redirect( admin_url( 'admin.php?page=abtestkit-get-started' ) );
    123             exit;
    124         }
    125     }
     133    // Only once
     134    if ( '1' !== get_option( 'abtestkit_do_activation_redirect' ) ) {
     135        return;
     136    }
     137
     138    // Clear the flag immediately to avoid loops
     139    delete_option( 'abtestkit_do_activation_redirect' );
     140
     141    // Don’t redirect in these contexts
     142    if ( wp_doing_ajax() ) return;
     143    if ( is_network_admin() ) return; // Multisite network screens
     144    if ( isset( $_GET['activate-multi'] ) ) return; // Bulk activate
     145
     146    // Only redirect admins who can actually view the page
     147    if ( ! current_user_can( 'manage_options' ) ) return;
     148
     149    // Final hop to the hidden onboarding screen
     150    $url = admin_url( 'admin.php?page=abtestkit-get-started' );
     151    wp_safe_redirect( $url );
     152    exit;
    126153} );
    127154
     
    163190        plugins_url( 'assets/js/onboarding.js', __FILE__ ),
    164191        array( 'wp-element', 'wp-components', 'wp-api-fetch' ),
    165         '1.0.0',
     192        '1.0.1',
    166193        true
    167194    );
     
    12321259            'appsScriptUrl' => ABTESTKIT_EMAIL_APPS_SCRIPT, // includes ?key=...
    12331260            'plugin'        => 'abtestkit',
    1234             'version'       => '1.0.0',
     1261            'version'       => '1.0.1',
    12351262            // Base fields so GAS fills standard columns
    12361263            'site'          => md5( home_url() ),
  • abtestkit/trunk/readme.txt

    r3380839 r3382121  
    55Tested up to: 6.6
    66Requires PHP: 7.4
    7 Stable tag: 1.0.0
     7Stable tag: 1.0.1
    88License: GPL-2.0-or-later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    130130== Changelog ==
    131131
     132= 1.0.1 =
     133* Fixed: Activation redirect now runs reliably so the onboarding wizard opens immediately after first activation. 
     134* Improved: Activation logic hardened for multisite and bulk activation contexts. 
     135* Minor: Internal code clean-up for future stability.
     136
    132137= 1.0.0 =
    133 * First release of abtestkit — simple A/B testing inside the WordPress Core Editor. 
    134 * Supported blocks: buttons, headings, paragraphs, images. 
     138* Initial public release of abtestkit — simple A/B testing inside the WordPress Core Editor. 
     139* Supported blocks: buttons, headings, paragraphs, and images. 
    135140* Automatic winner declaration with Bayesian evaluation. 
    136141* Grouped test support. 
    137 * Opt-in anonymous telemetry
     142* Optional anonymous telemetry (opt-in)
    138143
    139144== Upgrade Notice ==
    140145
     146= 1.0.1 =
     147Fixes onboarding not opening automatically after activation and improves reliability on multisite setups.
     148Updating is strongly recommended to ensure a smooth first-time setup experience.
     149
    141150= 1.0.0 =
    142151First public release — validate your ideas, grow your website, and reach your goals with A/B testing built directly into the WordPress block editor.
Note: See TracChangeset for help on using the changeset viewer.