我正在使用wordpress插件样板开发一个插件,我试图创建一个在页面内容中使用占位符的函数,但没有任何反应。
这是代码:
//class-annuncifunebri-public.php
public function annuncio_register_shortcode() {
$plugin = new Annunci_Funebri_Public( $this->get_plugin_name(), $this->get_version() );
add_shortcode( 'ANNUNCIFUNEBRI_ANNUNCIO', array( $plugin, 'annuncio_shortcode' ) );
}
public function annuncio_shortcode() {
ob_start();
require_once( 'partials/annuncio.php' );
$content = ob_get_contents();
ob_end_clean();
return $content;
}
//class-annuncifunebri.php
private function define_public_hooks() {
$plugin_public = new Annunci_Funebri_Public( $this->get_plugin_name(), $this->get_version() );
...
$this->loader->add_action('init', $plugin_public, 'annuncio_register_shortcode');
}