我在自定义插件的根目录中有两个文件“my-plugin.php”和“test.view.php”。“my-plugin.php”的内容是:
/*
Plugin Name: test
Plugin URI: test.com
Description: test
Version: 1.0
Author: test
Author URI: test
License: GPLv2+
Text Domain: conference
*/
class Test{
function __construct() {
add_shortcode('testShortCode' , array( $this, 'shortCode'));
}
function shortCode() {
return include 'test.view.php';
}
}
new Test();
而“test.view.php”是:
<h1>Test</h1>