下面是一个使用原始代码成功注册短代码的简单示例。您需要实例化Loader
类,然后调用其activate()
方法
class Shortcodes {
public static function notifications_shortcode( $atts, $content = "" ) {
return \'notifications foo foo\';
}
}
class MvcPluginLoader {
function __construct() {
}
}
class Loader extends MvcPluginLoader {
function __construct() {
parent::__construct();
}
function add_shortcodes() {
add_shortcode( \'ls_notifications\', array( \'Shortcodes\', \'notifications_shortcode\' ) );
}
}
add_action( \'init\', \'LoaderInit\' );
function LoaderInit() {
$my_loader = new Loader();
$my_loader->add_shortcodes();
}