To customize a fresh new WP install, there are a bunch of pluginable functions that can be overridden. Namely wp_install()
and wp_install_defaults()
. And wp_new_blog_notification()
.
I’d like to override a couple of default options without needing to keep custom versions of the latter in sync with core in my wp-content/install.php
file.
I’m not finding any obvious hook to do so in the wp-includes/upgrade.php
file, however. Might I be missing anything?
Edit: so, the pre_option_$option_name
is valid for options. Is there another, or some not-too-twisted procedure, that would allow to auto-enable permalinks, including (important) writing to the htaccess file as needed?
if you have a file at WP_CONTENT_DIR/install.php it will be run before the upgrade starts. If you want to override specific option then you can use the pre_update_option_$optionname filter to control the value written to the DB.
something like
caution – wasn’t tested but I assume that the filter API is available at that stage.
As for rewrite rules, the tricky part is generating the .htaccess file but since you obviously create your own installation image then you can add to it the .htaccess file in the root directory (the .htaccess is very generic and not tied to a specific domain name or directory location). Then all that is left to do is to control the rewrite rules options using the technique described above.
There are a couple of interesting hooks for use in an
install.php
:pre_update_option_{$option_name}
Generally useful to override defaults as they get stored.
added_user_meta
Allows to disable the welcome screen
But for heavy listing such as changing the default category’s name, the default post and page, or changing permalinks, hooks are definitely missing. In particular, a bunch of options are added using
populate_options()
, and do so without any plugin hook whatsoever.I’ve opened a ticket requesting new hooks here:
http://core.trac.wordpress.org/ticket/25762
The easiest in the meanwhile is to override
wp_new_blog_notification()
â the function is relatively simple to keep in sync with the WP core.