I'm upgrading several of my plugins to use PHP namespaces, so that functions, classes, constants etc are all namespaced correctly.
<?php
namespace my\plugin;
function init() {
...
}
// Calls \my\plugin\init();
add_action('init', __NAMESPACE__.'\init');
In several places my plugin calls do_action
or apply_filters
so that other plugins can modify its behaviour. If these are actions or filters that are unique to my plugin, it seems to me they should be namespaced as well, like so:
do_action('\my\plugin\stuff');
$value = apply_filters('\my\plugin\value', $value);
But I don't see anybody else out there doing this. Aside from namespaces requiring PHP 5.3, is there a good reason why not? Are the \
characters going to break on some platforms or with some unusual settings?