function adminSavePanel() { global $ts_rule; $Validation = new TSValidation(); $option = array(); $response = array('global' => array('error' => 1), 'local' => array()); $temp = array(); parse_str(TSHelper::stripslashesPOST($_POST['value']), $temp); foreach ($temp as $index => $value) { $index = preg_replace('/' . PLUGIN_THEME_STYLE_CONTEXT . '_/', null, $index); $data[$index] = $value; } foreach ($ts_rule['panel'] as $panelData) { foreach ($panelData as $panelSection) { foreach ($panelSection['field'] as $panelField) { $value = null; $name = $panelField['id']; if (array_key_exists($name, $data)) { $value = $data[$name]; } $option[$name] = $value; switch ($panelField['type']) { default: if (!$Validation->isColor($value, true)) { $response['local'][] = array(PLUGIN_THEME_STYLE_CONTEXT . '_' . $name, __('Enter valid color in HEX format.', PLUGIN_THEME_STYLE_DOMAIN)); } } } } } $response['global']['error'] = (bool) count($response['local']); if ($response['global']['error']) { $response['global']['notice'] = ' <div class="to-notice to-notice-error"> <span></span> <h4>' . __('Error', PLUGIN_THEME_STYLE_DOMAIN) . '</h4> <h6>' . __('Changes can not be saved.', PLUGIN_THEME_STYLE_DOMAIN) . '</h6> </div> '; } else { $response['global']['notice'] = ' <div class="to-notice to-notice-success"> <span></span> <h4>' . __('Success', PLUGIN_THEME_STYLE_DOMAIN) . '</h4> <h6>' . __('All changes have been saved.', PLUGIN_THEME_STYLE_DOMAIN) . '</h6> </div> '; TSOption::updateOption($option); $this->createCSSFile(); } echo json_encode($response); exit; }