/** * render_page * * This is the function that is called when a framework option page gets opened. * It checks the current page slug and based on that slug filters the $this->avia_superobject->option_page_data options array. * All option sets with the same slug get renderd with the help of the avia_htmlhelper class. */ function render_page() { $current_slug = $_GET['page']; $firstClass = 'avia_active_container'; //make page title accessible foreach ($this->avia_superobject->option_pages as $key => $data_set) { if ($data_set['parent'] == $data_set['slug'] && $data_set['slug'] == $current_slug) { $this->avia_superobject->currentpage = $data_set['title']; break; } } $this->avia_superobject->page_slug = $current_slug; $html = new avia_htmlhelper($this->avia_superobject); echo $html->page_header(); foreach ($this->avia_superobject->option_pages as $option_page) { if ($current_slug == $option_page['parent']) { echo $html->create_container_based_on_slug($option_page, $firstClass); $firstClass = ""; } } echo $html->page_footer(); }
function avia_ajax_create_dynamic_options() { //check if user is allowed to save and if its his intention with a nonce check if (function_exists('check_ajax_referer')) { check_ajax_referer('avia_nonce_save_backend'); } $options = new avia_database_set(); if ($_POST['method'] == 'add_option_page') { $result = $options->add_option_page($_POST); if (is_array($result)) { $html = new avia_htmlhelper(); $new_slug = $result['slug']; $result = "{avia_ajax_option_page}" . $html->create_container_based_on_slug($result) . "{/avia_ajax_option_page}"; if (isset($_POST['defaul_elements'])) { $elements = unserialize(base64_decode($_POST['defaul_elements'])); $result .= "{avia_ajax_element}"; foreach ($elements as &$element) { $element['id'] = $new_slug . $element['id']; $element['slug'] = $new_slug; //create frontend output $result .= $html->render_single_element($element); //save the element to the database as well $options->add_element_to_db($element, $_POST); } $result .= "{/avia_ajax_element}"; } } } die($result); }