Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-09-08 13:08:26

Walker
Plugin Author
From: Boston, MA
Registered: 2004-02-24
Posts: 592
Website

Plugin_lifecycle_notify & Plugin_has_prefs

Anybody have documentation &/or help for these two plugin options?

PLUGIN_LIFECYCLE_NOTIFY & PLUGIN_HAS_PREFS

Offline

#2 2009-09-08 13:38:26

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,447
Website GitHub

Re: Plugin_lifecycle_notify & Plugin_has_prefs

Not yet, sorry. They will be here when I get my act together. There’s a little bit on the core callbacks page.

Essentially you set the flags you want in your plugin template (or click the relevent checkboxes in the ied_plugin_composer) and add callbacks like this:

register_callback('my_prefs_page', 'plugin_prefs.abc_my_plugin_name');

And for lifecycle management, one or more of:

register_callback('my_install_routine', 'plugin_lifecycle.abc_my_plugin_name', 'installed');
register_callback('my_delete_routine', 'plugin_lifecycle.abc_my_plugin_name', 'deleted');
register_callback('my_enable_routine', 'plugin_lifecycle.abc_my_plugin_name', 'enabled');;
register_callback('my_disable_routine', 'plugin_lifecycle.abc_my_plugin_name', 'disabled');

Last edited by Bloke (2009-09-08 13:39:45)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2009-09-08 13:56:53

Walker
Plugin Author
From: Boston, MA
Registered: 2004-02-24
Posts: 592
Website

Re: Plugin_lifecycle_notify & Plugin_has_prefs

Ah…I thought there was more to it. In the “core callbacks” it makes them look like they’re some sort of defined variable (with the ALL CAPS, etc)

Offline

#4 2009-09-09 06:08:29

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: Plugin_lifecycle_notify & Plugin_has_prefs

They are.

Background: From Textpattern 4.2.0 on, plugins can opt into receiving plugin_prefs.abc_my_plugin_name and plugin_lifecycle.abc_my_plugin_name events. This opt-in is signalled to the core by raising the appropriate bits in $plugin['flags'].

PLUGIN_LIFECYCLE_NOTIFY and PLUGIN_HAS_PREFS are simply human-readable defined bit masks for your coding pleasure. Use them in any appropriate or’ed combination (PLUGIN_LIFECYCLE_NOTIFY | PLUGIN_HAS_PREFS etc.).

Of note: Textpattern reserves to lower twelve bits of $plugin['flags'] for its own use, plugin authors may take advantage of the remaining four (~PLUGIN_RESERVED_FLAGS). Might come handy to trigger some one-time actions, as these bits are copied into the txp_plugin table row for any particular plugin whenever it is uploaded.

Offline

Board footer

Powered by FluxBB