public function ajax_save()
 {
     if (!wp_verify_nonce($_REQUEST['nonce'], "redux_ajax_nonce")) {
         json_encode(array('status' => __('Invalid security credential, please reload the page and try again.', 'redux-framework'), 'action' => 'reload'));
         die;
     }
     $redux = ReduxFrameworkInstances::get_instance($_POST['opt_name']);
     if (!empty($_POST['data']) && !empty($redux->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']);
         parse_str($_POST['data'], $values);
         $values = $values[$redux->args['opt_name']];
         if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
             $values = array_map('stripslashes_deep', $values);
         }
         //$beforeDeep = $values;
         //// Ace editor hack for < PHP 5.4. Oy
         //if ( isset( $this->fields['ace_editor'] ) ) {
         //    if ( function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() ) {
         //        foreach ( $this->fields['ace_editor'] as $id => $v ) {
         //            if ( version_compare( phpversion(), '5.4', '<' ) ) {
         //                $values[ $id ] = stripslashes( $beforeDeep[ $id ] );
         //            } else {
         //                $values[ $id ] = $beforeDeep[ $id ];
         //            }
         //        }
         //    }
         //}
         if (!empty($values)) {
             try {
                 if (isset($redux->validation_ran)) {
                     unset($redux->validation_ran);
                 }
                 $redux->set_options($redux->_validate_options($values));
                 if (isset($values['defaults']) && !empty($values['defaults']) || isset($values['defaults-section']) && !empty($values['defaults-section'])) {
                     echo json_encode(array('status' => 'success', 'action' => 'reload'));
                     die;
                 }
                 include_once 'core/enqueue.php';
                 $enqueue = new reduxCoreEnqueue($redux);
                 $enqueue->get_warnings_and_errors_array();
                 include_once 'core/panel.php';
                 $panel = new reduxCorePanel($redux);
                 ob_start();
                 $panel->notification_bar();
                 $notification_bar = ob_get_contents();
                 ob_end_clean();
                 $success = array('status' => 'success', 'options' => $redux->options, 'errors' => isset($redux->localize_data['errors']) ? $redux->localize_data['errors'] : null, 'warnings' => isset($redux->localize_data['warnings']) ? $redux->localize_data['warnings'] : null, 'notification_bar' => $notification_bar);
                 echo json_encode($success);
             } catch (Exception $e) {
                 echo json_encode(array('status' => $e->getMessage()));
             }
         } else {
             echo json_encode(array('status' => __('Your panel has no fields. Nothing to save.', 'redux-framework')));
         }
     }
     if (isset($this->transients['run_compiler']) && $this->transients['run_compiler']) {
         $this->no_output = true;
         $this->_enqueue_output();
         /**
          * action 'redux-compiler-{opt_name}'
          *
          * @deprecated
          *
          * @param array  options
          * @param string CSS that get sent to the compiler hook
          */
         do_action("redux-compiler-{$this->args['opt_name']}", $this->options, $this->compilerCSS, $this->transients['changed_values']);
         // REMOVE
         /**
          * action 'redux/options/{opt_name}/compiler'
          *
          * @param array  options
          * @param string CSS that get sent to the compiler hook
          */
         do_action("redux/options/{$this->args['opt_name']}/compiler", $this->options, $this->compilerCSS, $this->transients['changed_values']);
         /**
          * action 'redux/options/{opt_name}/compiler/advanced'
          *
          * @param array  options
          * @param string CSS that get sent to the compiler hook, which sends the full Redux object
          */
         do_action("redux/options/{$this->args['opt_name']}/compiler/advanced", $this);
         unset($this->transients['run_compiler']);
         $this->set_transients();
     }
     die;
 }
 function enqueue_controls_css()
 {
     include_once ReduxFramework::$_dir . 'core/enqueue.php';
     $enqueue = new reduxCoreEnqueue($this->parent);
     $enqueue->get_warnings_and_errors_array();
     $enqueue->init();
     wp_enqueue_style('redux-extension-advanced-customizer', $this->_extension_url . 'extension_customizer.css', '', time());
     wp_enqueue_script('redux-extension-customizer', $this->_extension_url . 'extension_customizer' . Redux_Functions::isMin() . '.js', array('jquery', 'redux-js'), ReduxFramework_extension_customizer::$version, true);
     wp_localize_script('redux-extension-customizer', 'redux_customizer', array('body_class' => sanitize_html_class('admin-color-' . get_user_option('admin_color'), 'fresh')));
 }
示例#3
0
 public function ajax_save()
 {
     if (!wp_verify_nonce($_REQUEST['nonce'], "redux_ajax_nonce" . $this->args['opt_name'])) {
         echo json_encode(array('status' => __('Invalid security credential.  Please reload the page and try again.', 'redux-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.', 'redux-framework'), 'action' => ''));
         die;
     }
     $redux = ReduxFrameworkInstances::get_instance($_POST['opt_name']);
     if (!empty($_POST['data']) && !empty($redux->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->redux_parse_str($_POST['data']);
         $values = $values[$redux->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($redux->validation_ran)) {
                     unset($redux->validation_ran);
                 }
                 $redux->set_options($redux->_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 reduxCoreEnqueue($redux);
                 $enqueue->get_warnings_and_errors_array();
                 $return_array = array('status' => 'success', 'options' => $redux->options, 'errors' => isset($redux->localize_data['errors']) ? $redux->localize_data['errors'] : null, 'warnings' => isset($redux->localize_data['warnings']) ? $redux->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.', 'redux-framework')));
         }
     }
     if (isset($this->transients['run_compiler']) && $this->transients['run_compiler']) {
         $this->no_output = true;
         $this->_enqueue_output();
         try {
             /**
              * action 'redux-compiler-{opt_name}'
              *
              * @deprecated
              *
              * @param array  options
              * @param string CSS that get sent to the compiler hook
              */
             do_action("redux-compiler-{$this->args['opt_name']}", $this->options, $this->compilerCSS, $this->transients['changed_values']);
             // REMOVE
             /**
              * action 'redux/options/{opt_name}/compiler'
              *
              * @param array  options
              * @param string CSS that get sent to the compiler hook
              */
             do_action("redux/options/{$this->args['opt_name']}/compiler", $this->options, $this->compilerCSS, $this->transients['changed_values']);
             /**
              * action 'redux/options/{opt_name}/compiler/advanced'
              *
              * @param array  options
              * @param string CSS that get sent to the compiler hook, which sends the full Redux object
              */
             do_action("redux/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 reduxCorePanel($redux);
             ob_start();
             $panel->notification_bar();
             $notification_bar = ob_get_contents();
             ob_end_clean();
             $return_array['notification_bar'] = $notification_bar;
         }
         echo json_encode(apply_filters("redux/options/{$this->args['opt_name']}/ajax_save/response", $return_array));
     }
     die;
 }
 public function ajax_save()
 {
     if (!wp_verify_nonce($_REQUEST['nonce'], "redux_ajax_nonce")) {
         json_encode(array('status' => __('Invalid security credential, please reload the page and try again.', 'redux-framework'), 'action' => 'reload'));
         die;
     }
     $redux = ReduxFrameworkInstances::get_instance($_POST['opt_name']);
     if (!empty($_POST['data']) && !empty($redux->args['opt_name'])) {
         $values = array();
         parse_str($_POST['data'], $values);
         $values = $values[$redux->args['opt_name']];
         $values = array_map('stripslashes_deep', $values);
         if (!empty($values)) {
             try {
                 if (isset($redux->validation_ran)) {
                     unset($redux->validation_ran);
                 }
                 $redux->set_options($redux->_validate_options($values));
                 if (isset($values['defaults']) && !empty($values['defaults']) || isset($values['defaults-section']) && !empty($values['defaults-section'])) {
                     echo json_encode(array('status' => 'success', 'action' => 'reload'));
                     die;
                 }
                 include_once 'core/enqueue.php';
                 $enqueue = new reduxCoreEnqueue($redux);
                 $enqueue->get_warnings_and_errors_array();
                 include_once 'core/panel.php';
                 $panel = new reduxCorePanel($redux);
                 ob_start();
                 $panel->notification_bar();
                 $notification_bar = ob_get_contents();
                 ob_end_clean();
                 $success = array('status' => 'success', 'options' => $redux->options, 'errors' => isset($redux->localize_data['errors']) ? $redux->localize_data['errors'] : null, 'warnings' => isset($redux->localize_data['warnings']) ? $redux->localize_data['warnings'] : null, 'notification_bar' => $notification_bar);
                 echo json_encode($success);
             } catch (Exception $e) {
                 echo json_encode(array('status' => $e->getMessage()));
             }
         } else {
             echo json_encode(array('status' => __('Your panel has no fields. Nothing to save.', 'redux-framework')));
         }
     }
     if (isset($this->transients['run_compiler']) && $this->transients['run_compiler']) {
         $this->no_output = true;
         $this->_enqueue_output();
         /**
          * action 'redux-compiler-{opt_name}'
          *
          * @deprecated
          *
          * @param array  options
          * @param string CSS that get sent to the compiler hook
          */
         do_action("redux-compiler-{$this->args['opt_name']}", $this->options, $this->compilerCSS, $this->transients['changed_values']);
         // REMOVE
         /**
          * action 'redux/options/{opt_name}/compiler'
          *
          * @param array  options
          * @param string CSS that get sent to the compiler hook
          */
         do_action("redux/options/{$this->args['opt_name']}/compiler", $this->options, $this->compilerCSS, $this->transients['changed_values']);
         /**
          * action 'redux/options/{opt_name}/compiler/advanced'
          *
          * @param array  options
          * @param string CSS that get sent to the compiler hook, which sends the full Redux object
          */
         do_action("redux/options/{$this->args['opt_name']}/compiler/advanced", $this);
         unset($this->transients['run_compiler']);
         $this->set_transients();
     }
     die;
 }
 function enqueue_controls_css()
 {
     include_once ReduxFramework::$_dir . 'core/enqueue.php';
     $enqueue = new reduxCoreEnqueue($this->parent);
     $enqueue->get_warnings_and_errors_array();
     $enqueue->init();
     wp_enqueue_style('redux-extension-advanced-customizer', $this->_extension_url . 'extension_customizer.css', '', time());
     wp_enqueue_script('redux-extension-customizer', $this->_extension_url . 'extension_customizer.js', array('jquery'), time(), ReduxFramework_extension_customizer::$version, true);
     wp_localize_script('redux-extension-customizer', 'redux_customizer', array('body_class' => sanitize_html_class('admin-color-' . get_user_option('admin_color'), 'fresh')));
     //require_once( ABSPATH . '/wp-includes/class-wp-editor.php' );
     //_WP_Editors::enqueue_scripts();
     //_WP_Editors::editor_js();
 }
 function enqueue_controls_css()
 {
     include_once ReduxFramework::$_dir . 'core/enqueue.php';
     $enqueue = new reduxCoreEnqueue($this->parent);
     $enqueue->get_warnings_and_errors_array();
     $enqueue->init();
     wp_enqueue_style('redux-extension-advanced-customizer', $this->_extension_url . 'extension_advanced_customizer.css');
     wp_enqueue_script('redux-extension-advanced-customizer', $this->_extension_url . 'extension_advanced_customizer.js', array('jquery'), ReduxFramework_extension_advanced_customizer::$version . '4', true);
     require_once ABSPATH . '/wp-includes/class-wp-editor.php';
     _WP_Editors::enqueue_scripts();
     _WP_Editors::editor_js();
 }