【问题标题】:How to save the settings from my Wordpress plugin?如何保存我的 Wordpress 插件中的设置?
【发布时间】:2015-11-08 12:36:36
【问题描述】:

我目前正在制作一个带有设置页面的 wordpress 插件,用户可以在其中输入图像、名称和 URL,然后使用小部件和简码将其显示在网站上。当然,我想保存这些设置,以便它们可以显示在网站上。 我找到了这段代码,但我不知道它是否是(最好的)方式:

<form method="post" action="options.php">
    <?php wp_nonce_field('update-options') ?>
    <p><strong>One 1:</strong><br />
        <input type="text" placeholder="Name" name="name" size="45" value="<?php echo get_option('name'); ?>" />
        <input type="text" placeholder="Logo" name="logo" size="45" value="<?php echo get_option('logo'); ?>" />
        <input type="text" placeholder="Website" name="website" size="45" value="<?php echo get_option('website'); ?>" />
    </p>
    <input type="submit" name="Submit" value="Save" /></p>
    <input type="hidden" name="action" value="update" />
    <input type="hidden" name="page_options" value="name, logo, website" />
</form>

你有什么建议?

【问题讨论】:

    标签: php wordpress plugins settings


    【解决方案1】:

    从 Wordpress 中阅读 Settings API,创建选项页面所需的一切。

    【讨论】:

    • 这很有用!觉得自己很愚蠢,我没想到...谢谢!
    猜你喜欢
    • 2019-07-21
    • 1970-01-01
    • 2022-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-22
    • 1970-01-01
    相关资源
    最近更新 更多