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

plugin development - update_option() passing empty array() but still updating

programmeradmin1浏览0评论

I am reviewing some code in a custom plugin but I am not understanding how it could be working.

All form fields are indexed by name="opm_settings[name]"

At the top of the page inside the function that draws the page is the following code:

    global $opm_settings;
    
    if ( array_key_exists('submit', $_POST) ) 
    {
        update_option('opm_settings', array());?> 
            
    <div id="setting-error-settings-updated" class="settings_error notice notice-success is-dismissible">
        <p><?php _e('Settings updated.', 'opm_domain'); ?></p>
    </div>
    
    <?php }

In the call to update_option() the 2nd parameter being passed is array() which is just an empty array ...

THe required value is:

(mixed) (Required) 
Option value. Must be serializable if non-scalar. Expected to not be SQL-escaped.

however, the actual data in the form is getting submitted and entered into the DB, not an empty array ... How? I don't understand.

发布评论

评论列表(0)

  1. 暂无评论