doufendi9063 2018-02-02 00:56
浏览 56

表单操作/链接以在WordPress前端呈现插件

I am new to WordPress and I'm wondering if anyone could help me understand how I should go for rendering the output of a plugin when a form of a widget is submitted in the front-end.

I'm developing a plugin that has two "views" and one widget. The widget is just a form with a dropdown menu to select a value from a list. When a value is selected, the form should submit this value to a page where the first view of the plugin is rendered. This first view should print links that take the visitor to the second view, like the first view is a list of rows, and the second view is the details of the row selected from the first view. This is the goal.

I've been reading the Plugin API, but I don't seem to have found a proper solution. My question is: should I only rely on the Shortcodes put on certain pages to render the plugin in the front-end? Is this the only way?

I tried to submit a custom action with the form of my widget (with action get_admin_url().'admin-post.php'), and hook it in the plugin with:

add_action('admin_post_customaction', 'handle_customaction');
add_action('admin_post_nopriv_customaction', 'handle_customaction');
function (handle_customaction) {
    //do something
}

but the page admin-post.php truncates the execution, so I guess this practice is only for executing tasks and then redirect, not to display content within a page in the front-end.

Is there a solution beside using Shortcodes? Because then my question would be "which action attribute should I use in the form of the widget?", like how do I know which pages use the Shortcode I need?

Maybe by creating a custom post type? Do you know any plugins that do something similar that I could check? Any hints would be much appreciated!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算