* //JavaScript Ajax Request * Duplicator.UI.SaveViewState('dup-pack-archive-panel', 1); * * //Call PHP Code * $view_state = DUP_UI_ViewState::getValue('dup-pack-archive-panel'); * $ui_css_archive = ($view_state == 1) ? 'display:block' : 'display:none'; * */ public function SaveViewState($post) { $post = $this->postParamMerge($post); $result = new DUP_CTRL_Result($this); try { //CONTROLLER LOGIC $post = stripslashes_deep($_POST); $key = esc_html($post['key']); $value = esc_html($post['value']); $success = DUP_UI_ViewState::save($key, $value); $payload = array(); $payload['key'] = $key; $payload['value'] = $value; $payload['update-success'] = $success; //RETURN RESULT $test = ($success) ? DUP_CTRL_Status::SUCCESS : DUP_CTRL_Status::FAILED; return $result->process($payload, $test); } catch (Exception $exc) { $result->processError($exc); } } /** * Returns a JSON list of all saved view state items * * @notes: Testing: See Testing Interface * URL = /wp-admin/admin-ajax.php?action=DUP_CTRL_UI_GetViewStateList * * * See SaveViewState() * */ public function GetViewStateList() { $result = new DUP_CTRL_Result($this); try { //CONTROLLER LOGIC $payload = DUP_UI_ViewState::getArray(); //RETURN RESULT $test = (count($payload)) ? DUP_CTRL_Status::SUCCESS : DUP_CTRL_Status::FAILED; return $result->process($payload, $test); } catch (Exception $exc) { $result->processError($exc); } } }