0

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 );

4

1 に答える 1

0

これは自分で考え出しました。基本的に、フレームワークはフォーム変数を介して送信されたデータをサニタイズし、DB に送信していました。フレームワークがサニタイズしてDBに送信した配列にその戻り値を手動でロードすることにより、サードパーティのAPIを機能させました。私がそれをしたら、 update_options() は魔法のように働きました!

于 2013-02-07T23:48:01.730 に答える