[wp-hackers] Setting default options for plugin
Peter Westwood
peter.westwood at ftwr.co.uk
Sat Sep 1 08:10:33 GMT 2007
On 1 Sep 2007, at 07:35, Stephen Rider wrote:
>
> On Aug 31, 2007, at 5:38 PM, John Blackbourn wrote:
>
>> You should use the register_activation_hook function instead of
>> calling the activate_xxx action directly. Unfortunately this isn't a
>> well documented function.
>
> LOL -- I'll say! It's not even documented on the page you send me
> to. (That page links to a broken link....)
>
> I think I'll figure it out.... ;-)
What is wrong with the following documentation that means it doesn't
explain how register_activation_hook works?
<current_docs>
activate_{plugin-filename}
activate_{plugin-filename} is triggered when a plugin file of that
name is activated. Instead of using it directly, use
register_activation_hook($file, $function) where $fileis the plugin
file (don't hardcode it... use __FILE__) and $function is the
function you want to be run on plugin activation.
Context:
File: wp-admin/plugins.php
if ('activate' == $_GET['action']) {
$current = get_settings('active_plugins');
if (!in_array($_GET['plugin'], $current)) {
$current[] = trim( $_GET['plugin'] );
sort($current);
update_option('active_plugins', $current);
include(ABSPATH . 'wp-content/plugins/' . trim( $_GET['plugin'] ));
do_action('activate_' . trim( $_GET['plugin'] ));
}
</current_docs>
It makes reasonable sense to me - if you have any feedback on making
it more meanful let me know and I will get it updated.
westi
--
Peter Westwood <peter.westwood at ftwr.co.uk>
Blog: http://blog.ftwr.co.uk/
WordPress Plugins: http://blog.ftwr.co.uk/wordpress/
More information about the wp-hackers
mailing list