public function ajax_save() { if (!wp_verify_nonce($_REQUEST['nonce'], "avadaredux_ajax_nonce" . $this->args['opt_name'])) { echo json_encode(array('status' => __('Invalid security credential. Please reload the page and try again.', 'avadaredux-framework'), 'action' => '')); die; } if (!current_user_can($this->args['page_permissions'])) { echo json_encode(array('status' => __('Invalid user capability. Please reload the page and try again.', 'avadaredux-framework'), 'action' => '')); die; } $avadaredux = AvadaReduxFrameworkInstances::get_instance($_POST['opt_name']); if (!empty($_POST['data']) && !empty($avadaredux->args['opt_name'])) { $values = array(); //if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) { // $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); // while (list($key, $val) = each($process)) { // foreach ($val as $k => $v) { // unset($process[$key][$k]); // if (is_array($v)) { // $process[$key][stripslashes($k)] = $v; // $process[] = &$process[$key][stripslashes($k)]; // } else { // $process[$key][stripslashes($k)] = stripslashes($v); // } // } // } // unset($process); //} $_POST['data'] = stripslashes($_POST['data']); // Old method of saving, in case we need to go back! - kp //parse_str( $_POST['data'], $values ); // New method to avoid input_var nonesense. Thanks @harunbasic $values = $this->avadaredux_parse_str($_POST['data']); $values = $values[$avadaredux->args['opt_name']]; if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) { $values = array_map('stripslashes_deep', $values); } if (!empty($values)) { try { if (isset($avadaredux->validation_ran)) { unset($avadaredux->validation_ran); } $avadaredux->set_options($avadaredux->_validate_options($values)); $do_reload = false; if (isset($this->reload_fields) && !empty($this->reload_fields)) { if (!empty($this->transients['changed_values'])) { foreach ($this->reload_fields as $idx => $val) { if (array_key_exists($val, $this->transients['changed_values'])) { $do_reload = true; } } } } if ($do_reload || isset($values['defaults']) && !empty($values['defaults']) || isset($values['defaults-section']) && !empty($values['defaults-section'])) { echo json_encode(array('status' => 'success', 'action' => 'reload')); die; } require_once 'core/enqueue.php'; $enqueue = new avadareduxCoreEnqueue($avadaredux); $enqueue->get_warnings_and_errors_array(); $return_array = array('status' => 'success', 'options' => $avadaredux->options, 'errors' => isset($avadaredux->localize_data['errors']) ? $avadaredux->localize_data['errors'] : null, 'warnings' => isset($avadaredux->localize_data['warnings']) ? $avadaredux->localize_data['warnings'] : null); } catch (Exception $e) { $return_array = array('status' => $e->getMessage()); } } else { echo json_encode(array('status' => __('Your panel has no fields. Nothing to save.', 'avadaredux-framework'))); } } if (isset($this->transients['run_compiler']) && $this->transients['run_compiler']) { $this->no_output = true; $this->_enqueue_output(); try { /** * action 'avadaredux-compiler-{opt_name}' * * @deprecated * * @param array options * @param string CSS that get sent to the compiler hook */ do_action("avadaredux-compiler-{$this->args['opt_name']}", $this->options, $this->compilerCSS, $this->transients['changed_values']); // REMOVE /** * action 'avadaredux/options/{opt_name}/compiler' * * @param array options * @param string CSS that get sent to the compiler hook */ do_action("avadaredux/options/{$this->args['opt_name']}/compiler", $this->options, $this->compilerCSS, $this->transients['changed_values']); /** * action 'avadaredux/options/{opt_name}/compiler/advanced' * * @param array options * @param string CSS that get sent to the compiler hook, which sends the full AvadaRedux object */ do_action("avadaredux/options/{$this->args['opt_name']}/compiler/advanced", $this); } catch (Exception $e) { $return_array = array('status' => $e->getMessage()); } unset($this->transients['run_compiler']); $this->set_transients(); } if (isset($return_array)) { if ($return_array['status'] == "success") { require_once 'core/panel.php'; $panel = new avadareduxCorePanel($avadaredux); ob_start(); $panel->notification_bar(); $notification_bar = ob_get_contents(); ob_end_clean(); $return_array['notification_bar'] = $notification_bar; } echo json_encode(apply_filters("avadaredux/options/{$this->args['opt_name']}/ajax_save/response", $return_array)); } die; }
function enqueue_controls_css() { require_once AvadaReduxFramework::$_dir . 'core/enqueue.php'; $enqueue = new avadareduxCoreEnqueue($this->parent); $enqueue->get_warnings_and_errors_array(); $enqueue->init(); wp_enqueue_style('avadaredux-extension-advanced-customizer', $this->_extension_url . 'extension_customizer.css', '', time()); wp_enqueue_script('avadaredux-extension-customizer', $this->_extension_url . 'extension_customizer' . AvadaRedux_Functions::isMin() . '.js', array('jquery', 'avadaredux-js'), AvadaReduxFramework_extension_customizer::$version, true); wp_localize_script('avadaredux-extension-customizer', 'avadaredux_customizer', array('body_class' => sanitize_html_class('admin-color-' . get_user_option('admin_color'), 'fresh'))); }