/** * 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 form($instance) { $instance = wp_parse_args((array) $instance, array('title' => '', 'count' => '', 'cat' => '', 'excerpt' => '')); $title = strip_tags($instance['title']); $count = strip_tags($instance['count']); $excerpt = strip_tags($instance['excerpt']); $elementCat = array("name" => "Which categories should be used for the portfolio?", "desc" => "You can select multiple categories here", "id" => $this->get_field_name('cat') . "[]", "type" => "select", "std" => strip_tags($instance['cat']), "class" => "", "multiple" => 6, "subtype" => "cat"); //check if a different taxonomy than the default is set if (!empty($this->avia_term)) { $elementCat['taxonomy'] = $this->avia_term; } $html = new avia_htmlhelper(); ?> <p><label for="<?php echo $this->get_field_id('title'); ?> ">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo esc_attr($title); ?> " /></label></p> <p> <label for="<?php echo $this->get_field_id('count'); ?> ">How many entries do you want to display: </label> <select class="widefat" id="<?php echo $this->get_field_id('count'); ?> " name="<?php echo $this->get_field_name('count'); ?> "> <?php $list = ""; for ($i = 1; $i <= 20; $i++) { $selected = ""; if ($count == $i) { $selected = 'selected="selected"'; } $list .= "<option {$selected} value='{$i}'>{$i}</option>"; } $list .= "</select>"; echo $list; ?> </p> <p><label for="<?php echo $this->get_field_id('cat'); ?> ">Choose the categories you want to display (multiple selection possible): <?php echo $html->select($elementCat); ?> </label></p> <p> <label for="<?php echo $this->get_field_id('excerpt'); ?> ">Display title only or title & excerpt</label> <select class="widefat" id="<?php echo $this->get_field_id('excerpt'); ?> " name="<?php echo $this->get_field_name('excerpt'); ?> "> <?php $list = ""; $answers = array('show title only', 'display title and excerpt'); foreach ($answers as $answer) { $selected = ""; if ($answer == $excerpt) { $selected = 'selected="selected"'; } $list .= "<option {$selected} value='{$answer}'>{$answer}</option>"; } $list .= "</select>"; echo $list; ?> </p> <?php }
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); }