/** * Retreive an instance of SeedReduxFramework * * @param string $opt_name the defined opt_name as passed in $args * * @return object SeedReduxFramework */ function get_seedredux_instance($opt_name) { return SeedReduxFrameworkInstances::get_instance($opt_name); }
public function ajax_save() { if (!wp_verify_nonce($_REQUEST['nonce'], "seedredux_ajax_nonce")) { json_encode(array('status' => __('Invalid security credential, please reload the page and try again.', 'seedredux-framework'), 'action' => 'reload')); die; } $seedredux = SeedReduxFrameworkInstances::get_instance($_POST['opt_name']); if (!empty($_POST['data']) && !empty($seedredux->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[$seedredux->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($seedredux->validation_ran)) { unset($seedredux->validation_ran); } $seedredux->set_options($seedredux->_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 seedreduxCoreEnqueue($seedredux); $enqueue->get_warnings_and_errors_array(); include_once 'core/panel.php'; $panel = new seedreduxCorePanel($seedredux); ob_start(); $panel->notification_bar(); $notification_bar = ob_get_contents(); ob_end_clean(); $success = array('status' => 'success', 'options' => $seedredux->options, 'errors' => isset($seedredux->localize_data['errors']) ? $seedredux->localize_data['errors'] : null, 'warnings' => isset($seedredux->localize_data['warnings']) ? $seedredux->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.', 'seedredux-framework'))); } } if (isset($this->transients['run_compiler']) && $this->transients['run_compiler']) { $this->no_output = true; $this->_enqueue_output(); /** * action 'seedredux-compiler-{opt_name}' * * @deprecated * * @param array options * @param string CSS that get sent to the compiler hook */ do_action("seedredux-compiler-{$this->args['opt_name']}", $this->options, $this->compilerCSS, $this->transients['changed_values']); // REMOVE /** * action 'seedredux/options/{opt_name}/compiler' * * @param array options * @param string CSS that get sent to the compiler hook */ do_action("seedredux/options/{$this->args['opt_name']}/compiler", $this->options, $this->compilerCSS, $this->transients['changed_values']); /** * action 'seedredux/options/{opt_name}/compiler/advanced' * * @param array options * @param string CSS that get sent to the compiler hook, which sends the full SeedRedux object */ do_action("seedredux/options/{$this->args['opt_name']}/compiler/advanced", $this); unset($this->transients['run_compiler']); $this->set_transients(); } die; }
public static function loadSeedRedux($opt_name = "") { if (empty($opt_name)) { return; } $check = SeedReduxFrameworkInstances::get_instance($opt_name); if (isset($check->apiHasRun)) { return; } $args = self::constructArgs($opt_name); $sections = self::constructSections($opt_name); if (!class_exists('SeedReduxFramework')) { echo '<div id="message" class="error"><p>SeedRedux Framework is <strong>not installed</strong>. Please install it.</p></div>'; return; } if (isset(self::$uses_extensions[$opt_name]) && !empty(self::$uses_extensions[$opt_name])) { add_action("seedredux/extensions/{$opt_name}/before", array('SeedRedux', 'loadExtensions'), 0); } $seedredux = new SeedReduxFramework($sections, $args); $seedredux->apiHasRun = 1; self::$init[$opt_name] = 1; if (isset($seedredux->args['opt_name']) && $seedredux->args['opt_name'] != $opt_name) { self::$init[$seedredux->args['opt_name']] = 1; } }