コード例 #1
0
 public function sanitize($value)
 {
     $value = json_decode($value, true);
     if (is_null($value) || !is_array($value)) {
         return null;
     }
     $POST = array();
     foreach ($value as $var) {
         fw_aks(fw_html_attr_name_to_array_multi_key($var['name'], true), $var['value'], $POST);
     }
     $value = fw()->backend->option_type($this->fw_option['type'])->get_value_from_input($this->fw_option, fw_akg(fw_html_attr_name_to_array_multi_key($this->id), $POST));
     return $value;
 }
 public function setting_sanitize_callback($input)
 {
     $input = json_decode($input, true);
     if (is_null($input)) {
         return null;
     }
     $POST = array();
     foreach ($input as $var) {
         fw_aks(fw_html_attr_name_to_array_multi_key($var['name']), $var['value'], $POST);
     }
     $value = fw_get_options_values_from_input(array($this->id => $this->fw_option), fw_akg(FW_Option_Type::get_default_name_prefix(), $POST));
     $value = array_pop($value);
     return $value;
 }
コード例 #3
0
ファイル: backend.php プロジェクト: isatrio/Unyson
 /**
  * Get options values from html generated with 'fw_backend_options_render' ajax action
  *
  * POST vars:
  * - options: '[{option_id: {...}}, {option_id: {...}}, ...]' // Required // String JSON
  * - fw_options... // Use a jQuery "ajax form submit" to emulate real form submit
  *
  * Tip: Inside form html, add: <input type="hidden" name="options" value="[...json...]">
  */
 public function _action_ajax_options_get_values()
 {
     if (!isset($_POST['options'])) {
         wp_send_json_error(array('message' => 'No options'));
     }
     $options = json_decode(FW_Request::POST('options'), true);
     if (!$options) {
         wp_send_json_error(array('message' => 'Wrong options'));
     }
     if (isset($_POST['name_prefix'])) {
         $name_prefix = FW_Request::POST('name_prefix');
     } else {
         $name_prefix = FW_Option_Type::get_default_name_prefix();
     }
     wp_send_json_success(array('values' => fw_get_options_values_from_input($options, FW_Request::POST(fw_html_attr_name_to_array_multi_key($name_prefix), array()))));
 }