【问题标题】:Wordpress OOP Framework not working with update_options functionWordpress OOP 框架不适用于 update_options 函数
【发布时间】:2013-02-05 20:49:01
【问题描述】:

我正在尝试让 update_options 使用此功能。基本上,用户输入激活码并通过插件选项页面提交。代码发送给第三方,如果成功则返回状态。这一切都可以正常工作,但我无法让 update_options 更改相关选项的状态。

这里是更新函数(我正在使用的 OOP 框架的一部分):

  private function _admin_options_update() {
    // Verify submission for processing using wp_nonce
    if( wp_verify_nonce( $_REQUEST['_wpnonce'], "{$this->namespace}-update-options" ) ) {
        $data = array();
        /**
         * Loop through each POSTed value and sanitize it to protect against malicious code. Please
         * note that rich text (or full HTML fields) should not be processed by this function and 
         * dealt with directly.
         */
        foreach( $_POST['data'] as $key => $val ) {
            $data[$key] = $this->_sanitize( $val );
        }

        /**
         * Place your options processing and storage code here
         */

        // Update the options value with the data submitted
        update_option( $this->option_name, $data );

        // Redirect back to the options page with the message flag to show the saved message
        wp_safe_redirect( $_REQUEST['_wp_http_referer'] . '&update=1' );
        exit;
    }
}

我正在尝试运行这个函数:

update_option($WPBackitup->options['status'], $license_data->license);

【问题讨论】:

    标签: wordpress oop frameworks options


    【解决方案1】:

    这是我自己想出来的。基本上,该框架正在清理通过其表单变量提交的所有数据,然后将其提交给数据库。我通过手动将其返回加载到框架清理并发送到数据库的数组中来使第三方 API 工作。一旦我这样做了,update_options() 就像一个魅力!

    【讨论】:

      猜你喜欢
      • 2013-08-23
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-04
      • 1970-01-01
      • 2015-11-12
      相关资源
      最近更新 更多