我有一个自定义的WordPress插件,用来处理认证。
在plugin-name/src/Classes/Auth.php里面有一个函数logTheUserIn()。
我需要这个函数在用户点击自定义WordPress模板页面(page-authPortal.php)时运行,该页面顶部有这个代码。
include_once('wp-includes/pluggable.php');
include_once("wp-content/plugins/ad-auth-bridge/src/Classes/Auth.php");
print "test";
我创建了一个名为 "authPortal "的WordPress页面,它显示了 "测试 "文本,所以我知道这个自定义页面正在被加载和呈现。现在我只需要启动logTheUserIn()就可以了。
我试着在Auth.php中添加短代码和动作。
class Auth {
public function InitHooks() {
add_shortcode ('authNow', 'logTheUserIn');
add_action ('authAction', 'logTheUserIn');
然后我试着在WordPress编辑器中使用实际的短码[authNow],我也试过do_shortcode和do_action。
我在这里错过了什么?