[wp-trac] [WordPress Trac] #61040: Provide a framework for plugin onboarding experiences

WordPress Trac noreply at wordpress.org
Fri Apr 26 10:47:36 UTC 2024


#61040: Provide a framework for plugin onboarding experiences
-------------------------+------------------------------
 Reporter:  jorbin       |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Plugins      |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:  administration
-------------------------+------------------------------

Comment (by costdev):

 > Would a hook be a viable option here? As long as there hasn't been a
 page refresh the plugin's code hasn't run, so any functions defining an
 onboarding/configuration URL would not be available yet, at least from
 what I can tell.

 Yeah it works because `activate_plugin()` calls `plugin_sandbox_scrape()`
 which loads the main plugin file, which is where I would imagine we'd
 advise plugin authors to put it. It's a configuration thing, so I wouldn't
 recommend someone puts it behind an `init` hook. Options/Transients should
 already be available if they want to base their URL on the value of one.

 -----

 For fellow "lemme try" people:

 1. Enable `WP_DEBUG` and `WP_DEBUG_LOG`.
 2. Go to `Plugins > Add New` and install WooCommerce. **Do not activate it
 yet**
 3. Modify `woocommerce/woocommerce.php` to add this after the `ABSPATH`
 bail:
 {{{#!php
 add_filter(
         plugin_basename( __FILE__ ) . '_configuration_url',
         function () {
                 return admin_url( 'admin.php?page=wc-admin' );
         }
 );
 }}}
 4. Modify `wp_ajax_activate_plugin()` (in `src/wp-admin/includes/admin-
 ajax.php`) so it ends with the following:
 {{{#!php
 // Add these two lines above the call to wp_send_json_success().
 $configuration_url = apply_filters( $status['plugin'] .
 '_configuration_url', '' );
 error_log( $configuration_url );

 wp_send_json_success( $status );
 }}}
 4. Activate WooCommerce and check `wp-content/debug.log`.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61040#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list