最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Best practice to call a function from a button-link?

programmeradmin1浏览0评论

I am developing a WordPress website where I have to link a button to a function inside the functions.php file. Meaning that when someone clicks on a certain button, this will trigger a call to a specific function.

I have read about various ways to approach this:

By creating a link acting as a button:

<a href="?action=linked_function" class="button btn btn-primary">Click to call function</a>

Or a form submission:

<form action="functions.php" method="post">
    <input type="submit" value="Call function" />
</form>

Others suggest using ajax for this case, although I don't really care if the page has to reload after the function call or if I have to redirect the user to the previous page.

I am wondering though what are the best and most importantly safest options to develop this.

Any suggestions?

Thanks!

发布评论

评论列表(0)

  1. 暂无评论