config = array ( "number" => 1, "title" => "ICIT Navigation", "label" => "icit-navigation-widget", "settings" => array( array("name" => "title", "default-value" => "", "type" => "text", "description" => "Global title"), array("name" => "nav_title","default-value" => "Navigate", "type" => "text", "description" => "title"), array("name" => "cat_title","default-value" => "Categories","type" => "text", "description" => "Category title"), array("name" => "arc_title","default-value" => "Archive", "type" => "text", "description" => "Archive title"), array("name" => "lnk_title","default-value" => "Links", "type" => "text", "description" => "Links title"), array("name" => "rss", "default-value" => true, "type" => "checkbox", "description" => "Show RSS link"), array("name" => "category", "default-value" => true, "type" => "checkbox", "description" => "Show Categories"), array("name" => "archive", "default-value" => true, "type" => "checkbox", "description" => "Show Archives"), array("name" => "links", "default-value" => true, "type" => "checkbox", "description" => "Show Links"), array("name" => "links_cat","default-value" => false, "type" => "checkbox", "description" => "Categorise Links") ) ); } // Widgets visitor facing element. function widget_output($args,$label = 1) { $params = func_get_args(); foreach ($params as $param) if (is_array($param)) extract($param,EXTR_SKIP); // Output. echo $before_widget; if ($title) echo $before_title.$title.$after_title; ?> RSS $nav_title" : "

Navigate

" ); global $post; $exclude = get_option("page_on_front"); if ((is_home() and get_option("show_on_front") != "page") or ((get_option("page_on_front") == "{$post->ID}") and get_option("show_on_front") == "page")) { $highlight = " current_page_item"; }?> $cat_title" : "" ); ?> $arc_title" : "" ); ?> "name", "order" => "ASC", "limit" => -1, "category" => "", "category_name" => "", "hide_invisible" => 1, "show_updated" => 0, "echo" => 1, "categorize" => $links_cat, "title_li" => "", "title_before" => "

", "title_after" => "

", "category_orderby" => "name", "category_order" => "ASC", "class" => "linkcat", "category_before" => "
  • ", "category_after" => "
  • "); echo ($lnk_title != "" ? "

    $lnk_title

    " : "" ); ?> original = $this->settings = get_option("{$this->config["label"]}-options"); // Check to see if there was a change to the number of widgets and update. if ($_POST["{$this->config["label"]}-submit"] != "") { $this->settings["number"] = strip_tags(stripslashes($_POST["{$this->config["label"]}-count"])); } // Check to see if the number of widgets is within range. if ($this->settings["number"] < 1) $this->settings["number"] = 1; if ($this->settings["number"] > $this->config["number"]) $this->settings["number"] = $this->config["number"]; for ($i = 1; $i <= $this->settings["number"]; $i++) { if ($this->settings[$i]["defaults_set"] != true) $setdefaults = $this->settings[$i]["defaults_set"] = true; if (count($this->config["settings"]) >= 1 && is_array($this->config["settings"])) foreach ($this->config["settings"] as $item) { if (is_array($item)) { $label = "{$this->config["label"]}-$i-{$item["name"]}"; $value = $this->settings[$i]["{$item["name"]}"]; $default = $item["default-value"]; if ($setdefaults) $this->settings[$i]["{$item["name"]}"] = $default; if ($_POST["{$this->config["label"]}-$i-submitted"]) { $this->settings[$i]["{$item["name"]}"] = strip_tags(stripslashes($_POST[$label])); // Call the validator if one is set. The validator function should return True is all is good else I will set the value to the default. if (method_exists($this,$item["validator"])) { if(!call_user_func(array($this,$item["validator"]),$this->settings[$i]["{$item["name"]}"])) $this->settings[$i]["{$item["name"]}"] = $item["default-value"];; } elseif (function_exists($item["validator"])) { if(!call_user_func($item["validator"],$this->settings[$i]["{$item["name"]}"])) $this->settings[$i]["{$item["name"]}"] = $item["default-value"]; } } } } } // Save the options if they have chaanged. if ($this->original != $this->settings) $this->save_settings(); // Look for and execute a function called additional_filters; if (method_exists($this,"additional_filters")) call_user_func(array($this,"additional_filters")); } function save_settings() { add_option("{$this->config["label"]}-options",'',"{$this->config["title"]}",'yes'); update_option("{$this->config["label"]}-options", $this->settings); } // The setting interface function widget_control($i = 1) { foreach ($this->config["settings"] as $item) { if (is_array($item)) { $label = "{$this->config["label"]}-$i-{$item["name"]}"; $value = $this->settings[$i]["{$item["name"]}"]; $description = $item["description"]; $type = $item["type"]; echo "
    "; switch ($type){ case "text" : echo ""; break; case "checkbox" : echo ""; break; case "select" : // First check that the option-list is an array and set the options to that if it is. // Else I presume its a call to a function that outputs and array so try and execute it. if (is_array($item["option-list"])) { $optionlist = $item["option-list"]; } elseif (method_exists($this,$item["option-list"])) { $optionlist = call_user_func(array($this,$item["option-list"])); } // Check that the previous section outputted an array and that the array has content. if (!is_array($optionlist) && !count($optionlist) >= 1) { echo "Error: missing or corrupt option-list array.
    "; break; } echo ""; break; } echo "
    "; } } ?> config["label"]}-$i-submitted";?>" id="-submitted"/>

    config["title"]; ?>

    -submit" id="config["label"];?>-submit" value="Save" />

    get_settings(); // Add a widget and controller for the number stated. for ($i = 1; $i <= $this->settings['number']; $i++) { if ($this->config['number'] == 1) { $name = array("{$this->config["title"]}", "widgets", $i); } else { $name = array("{$this->config["title"]} %s", "widgets", $i); } register_sidebar_widget($name, array($this,'widget_output'), "{$this->config["label"]}",$this->settings[$i]); if (count($this->config["settings"]) >= 1) register_widget_control($name, array($this,'widget_control'),310,(count($this->config["settings"])*40)+10,$i); } // Add the interface to choose how many widgets you want available. if ($this->config["number"] > 1) add_action('sidebar_admin_page', array($this,'page')); } }?>