Core callback list
From Textbook
The following is a list of callbacks in Textpattern. It is current as of TXP v4.2.0 and is organised by file / plugin tab:
Regular public-side callbacks
publish.php
- event = pretext
- occurs at the very top of the
pretext()function, just after the prefs have been extracted - event = pretext_end
- occurs just after
pretext()has run but before its variables have been extracted into the global scope - useful for overriding anything set in
pretext()or adding variables to it - event = file_download
- occurs as soon as a file_download is detected, allowing you to intercept the regular file downloading process
- event = textpattern
- occurs just before the page is rendered
- event = textpattern_end
- occurs once the page has been fully rendered
publish/atom.php
- event = atom_head
- occurs after the feed's header has been set
- allows you to add items to the feed's header
- event = atom_entry
- occurs as soon as the article's data has been populated
- allows you to inject extra markup after the standard feed items have been generated
publish/rss.php
- event = rss_head
- occurs after the feed's header has been set
- allows you to add items to the feed's header
- event = rss_entry
- occurs as soon as the article's data has been populated
- allows you to inject extra markup after the standard feed items have been generated
publish/comment.php
- event = comment.form
- occurs at the end of the
commentForm()function - allows you to inject markup after the textarea generated by the
<txp:comment_message_input />tag - event = comment.save
- occurs just before a comment is posted
- allows you to make additional decisions based on the comment content, e.g. anti-spam plugins
publish/log.php
- event = log_hit
- occurs just before a log message is recorded in the txp_log table
- allows you to alter the log message
Function- and tag-based callbacks
lib/txplib_misc.php
- event = sanitize_for_url
- occurs at the start of the
sanitizeForUrl()function allowing you to apply your own URL-dumbdown rules - passes the text to be sanitized as the callback's 4th argument
- event = sanitize_for_file
- occurs at the start of the
sanitizeForFile()function allowing you to apply your own filename-dumbdown rules - passes the text to be sanitized as the callback's 4th argument
- event = txp_die
step = http_status_code - occurs once the page's HTTP status has been determined
- passes the numerical HTTP status code as the callback's step (e.g.
410,301, etc) allowing you to target particular status codes and take action
Plugin callbacks
include/txp_plugin.php
In order to process these callbacks, your plugin must raise the PLUGIN_LIFECYCLE_NOTIFY flag to register its intent. In addition, if you wish to offer a link to your plugin's preferences from the Admin->Plugins tab, you must raise the PLUGIN_HAS_PREFS flag.
- event = plugin_lifecycle.abc_your_plugin
step = enabled - occurs when somebody switches abc_your_plugin to Yes from the Admin->Plugins tab
- event = plugin_lifecycle.abc_your_plugin
step = disabled - occurs when somebody switches abc_your_plugin to No from the Admin->Plugins tab
- event = plugin_lifecycle.abc_your_plugin
step = installed - occurs when abc_your_plugin has been installed by the act of the user pasting its code in the Admin->Plugins tab and clicking Install on the next screen
- event = plugin_lifecycle.abc_your_plugin
step = deleted - occurs when abc_your_plugin has been removed by the act of the user selecting it and deleting it from the Admin->Plugins tab
- note that the plugin_lifecycle.abc_your_plugin / disabled callback fires first
Regular admin-side callbacks
lib/txplib_head.php
- event = admin_side
step = head_end - occurs just before the closing
</head>tag on every admin side tab - useful for injecting javascript or style rules into the page's header
- event = admin_side
step = pagetop - occurs immediately before control is handed to the theme to render the tab bar
- event = admin_side
step = pagetop_end - occurs immediately after the theme has finished rendering the tab bar
- useful for adding admin-wide markup below pagetop
lib/txplib_html.php
- event = admin_side
step = body_end - occurs once the theme has rendered its footer
- allows you to tack on any extra admin-wide information immediately before the closing
</body>tag
include/txp_diag.php
- event = diag_results
step = high or low - occurs at the end of the
doDiagnostics()function for rendering the content of the Admin->Diagnostics tab - allows you to add any extra information to the diagnostic output depending on the level of output the user has chosen (high or low)
include/txp_article.php
- event = ping
- occurs just before a ping notification is sent upon publication of an article so you may intercept the ping and provide your own
pluggable_ui() callbacks
Argument #1 passed to your function is the event and argument #2 is the step. Arguments 3 and 4 (and occasionally 5) vary depending on the functionality of the UI component. In general, the following holds true unless otherwise stated:
- argument #3 is the default markup
- argument #4 is the record set of the item that is being edited (if applicable)
Parsing argument #3 allows you to alter what was originally going to be displayed, and then return it. Or you may discard this markup and return your own instead.
Write tab (include/txp_article.php)
All of the UI elements on this page have the same event = article_ui.
- step = sidehelp
- allows you to replace or alter the 'Textile Help' lever and its entire contents
- step = extend_col_1
- allows you to add your own markup below the sidehelp
- argument #3 is empty as there is no default content here
- step = markup
- allows you to replace or alter the two select lists for article and excerpt markup
- step = override
- allows you to alter or replace the override form select list
- step = custom_fields
- allows you to alter or replace the block of custom field input controls
- step = keywords
- allows you to alter or replace the keywords area
- step = article_image
- allows you to alter or replace the article_image area
- step = url_title
- allows you to alter or replace the URL title input area
- step = title
- allows you to alter or replace the article's title element
- step = body
- allows you to alter or replace the article's body element
- step = excerpt
- allows you to alter or replace the article's excerpt element
- step = view
- allows you to alter or replace the three vertical tabs down the right hand side of the central column
- step = status
- allows you to alter or replace the article's status area
- step = categories
- allows you to alter or replace the article's category1/category2 area
- be careful here because this UI element is inside a fieldset which is finished in the next
pluggable_ui()call - step = section
- allows you to alter or replace the article's section select list
- be careful here because this UI element is inside a fieldset which is started in the previous
pluggable_ui()call - step = annotate_invite
- allows you to alter or replace the article's comments on/off and comments invite area
- step = timestamp
- allows you to alter or replace the article's timestamp area
- step = expires
- allows you to alter or replace the article expiry area
Categories tab (include/txp_category.php)
- event = category_ui
step = extend_detail_form - allows you to add markup above the category Save button when editing an individual category
- argument #3 is empty because there is no default content
Images tab (include/txp_image.php)
- event = image_ui
step = extend_detail_form - allows you to add markup above the image Save button when editing an image
- argument #3 is empty because there is no default content
Files tab (include/txp_file.php)
- event = file_ui
step = extend_detail_form - allows you to add markup above the file Save button when editing a file
- argument #3 is empty because there is no default content
- the same callback is used whether the file you are editing exists or is missing from the database -- use the absence or availability of the 4th argument (record set) to determine which state the tab is in
Links tab (include/txp_links.php)
- event = link_ui
step = extend_detail_form - allows you to add markup above the link Save button
- argument #3 is empty because there is no default content
Sections tab (include/txp_section.php)
- event = section_ui
step = extend_detail_form - allows you to add markup immediately above the 'Save' button in both the 'default' area and every regular section
- argument #3 is empty because there is no default content
- the record set in argument #4 contains only the columns page and css when in the default area, and contains all columns at other times
Users tab (include/txp_admin.php)
- event = author_ui
step = extend_detail_form - allows you to add markup immediately above the author Save button
- argument #3 is empty because there is no default content
Preferences tab (include/txp_prefs.php)
- event = prefs_ui
step = gmtoffset - allows you to alter or replace the Time zone select list (just the input control, not the label)
- argument #4 is the preference name in the txp_prefs table (timezone_key in this case)
- argument #5 is the preference's value (i.e. the chosen item)
- event = prefs_ui
step = is_dst - allows you to alter or replace the DST enabled radio buttons (just the input control, not the label)
- argument #4 is the preference name in the txp_prefs table (is_dst in this case)
- argument #5 is the preference's value (i.e. the numerical state of the radio button)
- event = prefs_ui
step = weeks - allows you to alter or replace the Comments disabled after select list (just the input control, not the label)
- argument #4 is the preference name in the txp_prefs table (comments_disabled_after in this case)
- argument #5 is the preference's value (i.e. the numerical value of the selected item; in this case the number of days to keep commenting open)
- event = prefs_ui
step = custom_set - allows you to alter or replace the Custom Field text boxes on the Advanced Prefs tab (just the input controls, not the labels). Each text box is called separately; you distinguish between them using argument #4
- argument #4 is the preference name in the txp_prefs table (custom_set_N by default, where N is the custom field number)
- argument #5 is the preference's value (i.e. the name of the custom field)
- event = prefs_ui
step = theme_name - allows you to alter or replace the Admin theme select list on the Advanced Prefs tab (just the input control, not the label)
Theme callbacks
The following callbacks are all usable to alter various elements within admin-side themes.
lib/txplib_theme.php
- event = admin_side
step = theme_name - allows you to alter a theme's name when it is being initialised
- there is no argument #4
lib/txplib_head.php
- event = admin_side
step = header - allows you to replace the standard pagetop header with something of your choosing. Theme authors do this by writing a
header()function in their theme's PHP file - there is no argument #4
lib/txplib_html.php
- event = admin_side
step = footer - allows you to replace the standard end_page footer with something of your choosing. Theme authors do this by writing a
footer()function in their theme's PHP file - there is no spoon
- event = some_event_ui
step = upload_form - allows you to alter or replace TXP's standard upload forms throughout the admin side
- some_event is the name of the event on the tab upon which the input form appears (e.g. on the Files tab, the event is 'file' so the
pluggable_ui()event name is file_ui) - argument #4 contains the remainder of the arguments to the
upload_form()function, i.e. 'label', 'pophelp', 'step', 'event', 'id', 'max_file_size', 'label_id' and 'class'.




