Breadcrumb NavXT. Version: 2.2.99 Author: John Havlik Author URI: http://mtekk.weblogs.us/ */ //Include the breadcrumb class (if needed) if(!class_exists('bcn_breadcrumb')) { require_once(dirname(__FILE__) . '/breadcrumb_navxt_class.php'); } //Include the supplemental functions require_once(dirname(__FILE__) . '/breadcrumb_navxt_api.php'); //The administrative interface class class bcn_admin { private $version; private $breadcrumb_trail; /** * bcn_admin * * Administrative interface class default constructor */ function bcn_admin() { //Setup our internal version $this->version = "3.0.0"; //We'll let the fail fataly if the class isn't there as we depend on it $this->breadcrumb_trail = new bcn_breadcrumb_trail; //Installation Script hook add_action('activate_breadcrumb-navxt/breadcrumb_navxt_admin.php', array(&$this, 'install')); //WordPress Admin interface hook add_action('admin_menu', array(&$this, 'add_page')); //WordPress Hook for the widget add_action('plugins_loaded', array(&$this, 'register_widget')); //Admin Options hook if(isset($_POST['bcn_admin_options'])) { add_action('init', array(&$this, 'update')); } } /** * security * * Makes sure the current user can manage options to proceed */ function security() { //If the user can not manage options we will die on them if(!current_user_can('manage_options')) { _e('Insufficient privileges to proceed.', 'breadcrumb_navxt'); die(); } } /** * install * * This setsup and upgrades the database settings, runs on every activation */ function install() { //Call our little security function $this->security(); //Reduce db queries by saving this $db_version = get_option('bcn_version'); //If our version is not the same as in the db, time to update if($db_version !== $this->version) { //Split up the db version into it's components list($major, $minor, $release) = explode('.', $db_version); //For upgrading from 2.2.x betas if($major < 3 && $major > 1) { //Migrate over stuff $this->breadcrumb_trail->opt['home_display'] = str2bool(get_option('bcn_home_display')); $this->breadcrumb_trail->opt['home_title'] = get_option('bcn_home_title'); $this->breadcrumb_trail->opt['home_anchor'] = get_option('bcn_home_anchor'); $this->breadcrumb_trail->opt['blog_anchor'] = get_option('bcn_blog_anchor'); $this->breadcrumb_trail->opt['separator'] = get_option('bcn_separator'); $this->breadcrumb_trail->opt['max_title_length'] = get_option('bcn_max_title_length'); $this->breadcrumb_trail->opt['current_item_linked'] = str2bool(get_option('bcn_current_item_linked')); $this->breadcrumb_trail->opt['current_item_anchor'] = get_option('bcn_current_item_anchor'); $this->breadcrumb_trail->opt['current_item_prefix'] = get_option('bcn_current_item_prefix'); $this->breadcrumb_trail->opt['current_item_suffix'] = get_option('bcn_current_item_suffix'); $this->breadcrumb_trail->opt['paged_prefix'] = get_option('bcn_paged_prefix'); $this->breadcrumb_trail->opt['paged_suffix'] = get_option('bcn_paged_suffix'); $this->breadcrumb_trail->opt['paged_display'] = str2bool(get_option('bcn_paged_display')); $this->breadcrumb_trail->opt['page_prefix'] = get_option('bcn_page_prefix'); $this->breadcrumb_trail->opt['page_suffix'] = get_option('bcn_page_suffix'); $this->breadcrumb_trail->opt['page_anchor'] = get_option('bcn_page_anchor'); $this->breadcrumb_trail->opt['post_prefix'] = get_option('bcn_post_prefix'); $this->breadcrumb_trail->opt['post_suffix'] = get_option('bcn_post_suffix'); $this->breadcrumb_trail->opt['post_anchor'] = get_option('bcn_post_anchor'); $this->breadcrumb_trail->opt['post_taxonomy_display'] = str2bool(get_option('bcn_post_taxonomy_display')); $this->breadcrumb_trail->opt['post_taxonomy_type'] = get_option('bcn_post_taxonomy_type'); $this->breadcrumb_trail->opt['attachment_prefix'] = get_option('bcn_attachment_prefix'); $this->breadcrumb_trail->opt['attachment_suffix'] = get_option('bcn_attachment_suffix'); $this->breadcrumb_trail->opt['404_prefix'] = get_option('bcn_404_prefix'); $this->breadcrumb_trail->opt['404_suffix'] = get_option('bcn_404_suffix'); $this->breadcrumb_trail->opt['404_title'] = get_option('bcn_404_title'); $this->breadcrumb_trail->opt['search_prefix'] = get_option('bcn_search_prefix'); $this->breadcrumb_trail->opt['search_suffix'] = get_option('bcn_search_suffix'); $this->breadcrumb_trail->opt['tag_prefix'] = get_option('bcn_tag_prefix'); $this->breadcrumb_trail->opt['tag_suffix'] = get_option('bcn_tag_suffix'); $this->breadcrumb_trail->opt['tag_anchor'] = get_option('bcn_tag_anchor'); $this->breadcrumb_trail->opt['author_prefix'] = get_option('bcn_author_prefix'); $this->breadcrumb_trail->opt['author_suffix'] = get_option('bcn_author_suffix'); $this->breadcrumb_trail->opt['author_display'] = get_option('bcn_author_display'); $this->breadcrumb_trail->opt['category_prefix'] = get_option('bcn_category_prefix'); $this->breadcrumb_trail->opt['category_suffix'] = get_option('bcn_category_suffix'); $this->breadcrumb_trail->opt['category_anchor'] = get_option('bcn_category_anchor'); $this->breadcrumb_trail->opt['archive_category_prefix'] = get_option('bcn_archive_category_prefix'); $this->breadcrumb_trail->opt['archive_category_suffix'] = get_option('bcn_archive_category_suffix'); $this->breadcrumb_trail->opt['archive_tag_prefix'] = get_option('bcn_archive_tag_prefix'); $this->breadcrumb_trail->opt['archive_tag_suffix'] = get_option('bcn_archive_tag_suffix'); $this->breadcrumb_trail->opt['date_anchor'] = get_option('bcn_date_anchor'); $this->breadcrumb_trail->opt['archive_date_prefix'] = get_option('bcn_archive_date_prefix'); $this->breadcrumb_trail->opt['archive_date_suffix'] = get_option('bcn_archive_date_suffix'); //Now remove the old options delete_option('bcn_trail_linked'); delete_option('bcn_home_display'); delete_option('bcn_home_title'); delete_option('bcn_home_anchor'); delete_option('bcn_blog_anchor'); delete_option('bcn_max_title_length'); delete_option('bcn_separator'); delete_option('bcn_search_prefix'); delete_option('bcn_search_suffix'); delete_option('bcn_author_prefix'); delete_option('bcn_author_suffix'); delete_option('bcn_author_display'); delete_option('bcn_page_prefix'); delete_option('bcn_page_suffix'); delete_option('bcn_page_anchor'); delete_option('bcn_archive_category_prefix'); delete_option('bcn_archive_category_suffix'); delete_option('bcn_archive_tag_prefix'); delete_option('bcn_archive_tag_suffix'); delete_option('bcn_attachment_prefix'); delete_option('bcn_attachment_suffix'); delete_option('bcn_404_prefix'); delete_option('bcn_404_suffix'); delete_option('bcn_404_title'); delete_option('bcn_current_item_linked'); delete_option('bcn_current_item_anchor'); delete_option('bcn_current_item_prefix'); delete_option('bcn_current_item_suffix'); delete_option('bcn_paged_display'); delete_option('bcn_paged_prefix'); delete_option('bcn_paged_suffix'); delete_option('bcn_post_prefix'); delete_option('bcn_post_suffix'); delete_option('bcn_post_taxonomy_type'); delete_option('bcn_post_taxonomy_display'); delete_option('bcn_post_anchor'); delete_option('bcn_category_prefix'); delete_option('bcn_category_suffix'); delete_option('bcn_category_anchor'); delete_option('bcn_tag_prefix'); delete_option('bcn_tag_suffix'); delete_option('bcn_tag_anchor'); delete_option('bcn_archive_date_prefix'); delete_option('bcn_archive_date_suffix'); delete_option('bcn_date_anchor'); } //For upgrading from 2.1.x if($major <= 2 && $minor <= 1 && $release <= 4) { //Upgrade to a current option $this->breadcrumb_trail->opt['home_title'] = get_option('bcn_title_blog'); $this->breadcrumb_trail->opt['home_display'] = get_option('bcn_home_display'); $this->breadcrumb_trail->opt['404_title'] = get_option('bcn_title_404'); $this->breadcrumb_trail->opt['post_taxonomy_type'] = get_option('bcn_singleblogpost_taxonomy'); $this->breadcrumb_trail->opt['post_taxonomy_display'] = get_option('bcn_singleblogpost_taxonomy_display'); $this->breadcrumb_trail->opt['category_prefix'] = get_option('bcn_singleblogpost_category_prefix'); $this->breadcrumb_trail->opt['category_suffix'] = get_option('bcn_singleblogpost_category_suffix'); $this->breadcrumb_trail->opt['tag_prefix'] = get_option('bcn_singleblogpost_tag_prefix'); $this->breadcrumb_trail->opt['tag_suffix'] = get_option('bcn_singleblogpost_tag_suffix'); $this->breadcrumb_trail->opt['current_item_linked'] = get_option('bcn_link_current_item'); $this->breadcrumb_trail->opt['post_prefix'] = get_option('bcn_singleblogpost_prefix'); $this->breadcrumb_trail->opt['post_suffix'] = get_option('bcn_singleblogpost_suffix'); $this->breadcrumb_trail->opt['current_item_prefix'] = get_option('bcn_singleblogpost_style_prefix'); $this->breadcrumb_trail->opt['current_item_suffix'] = get_option('bcn_singleblogpost_style_suffix'); $this->breadcrumb_trail->opt['max_title_length'] = get_option('bcn_posttitle_maxlen'); delete_option('bcn_preserve'); delete_option('bcn_static_frontpage'); delete_option('bcn_url_blog'); delete_option('bcn_home_display'); delete_option('bcn_home_link'); delete_option('bcn_title_home'); delete_option('bcn_title_blog'); delete_option('bcn_separator'); delete_option('bcn_search_prefix'); delete_option('bcn_search_suffix'); delete_option('bcn_author_prefix'); delete_option('bcn_author_suffix'); delete_option('bcn_author_display'); delete_option('bcn_singleblogpost_prefix'); delete_option('bcn_singleblogpost_suffix'); delete_option('bcn_page_prefix'); delete_option('bcn_page_suffix'); delete_option('bcn_urltitle_prefix'); delete_option('bcn_urltitle_suffix'); delete_option('bcn_archive_category_prefix'); delete_option('bcn_archive_category_suffix'); delete_option('bcn_archive_date_prefix'); delete_option('bcn_archive_date_suffix'); delete_option('bcn_archive_date_format'); delete_option('bcn_attachment_prefix'); delete_option('bcn_attachment_suffix'); delete_option('bcn_archive_tag_prefix'); delete_option('bcn_archive_tag_suffix'); delete_option('bcn_title_404'); delete_option('bcn_link_current_item'); delete_option('bcn_current_item_urltitle'); delete_option('bcn_current_item_style_prefix'); delete_option('bcn_current_item_style_suffix'); delete_option('bcn_posttitle_maxlen'); delete_option('bcn_paged_display'); delete_option('bcn_paged_prefix'); delete_option('bcn_paged_suffix'); delete_option('bcn_singleblogpost_taxonomy'); delete_option('bcn_singleblogpost_taxonomy_display'); delete_option('bcn_singleblogpost_category_prefix'); delete_option('bcn_singleblogpost_category_suffix'); delete_option('bcn_singleblogpost_tag_prefix'); delete_option('bcn_singleblogpost_tag_suffix'); } //Always have to update the version update_option('bcn_version', $this->version); //Store the options add_option('bcn_options', $this->breadcrumb_trail->opt); } } /** * update * * Updates the database settings from the webform */ function update() { $this->security(); //Do a nonce check, prevent malicious link/form problems check_admin_referer('bcn_admin_options'); //Grab the options from the from post //Home page settings $this->breadcrumb_trail->opt['home_display'] = str2bool(bcn_get('home_display', 'false')); $this->breadcrumb_trail->opt['home_title'] = bcn_get('home_title'); $this->breadcrumb_trail->opt['home_anchor'] = bcn_get('home_anchor'); $this->breadcrumb_trail->opt['blog_anchor'] = bcn_get('blog_anchor'); $this->breadcrumb_trail->opt['separator'] = bcn_get('separator'); $this->breadcrumb_trail->opt['max_title_length'] = bcn_get('max_title_length'); //Current item settings $this->breadcrumb_trail->opt['current_item_linked'] = str2bool(bcn_get('current_item_linked', 'false')); $this->breadcrumb_trail->opt['current_item_anchor'] = bcn_get('current_item_anchor'); $this->breadcrumb_trail->opt['current_item_prefix'] = bcn_get('current_item_prefix'); $this->breadcrumb_trail->opt['current_item_suffix'] = bcn_get('current_item_suffix'); //Paged settings $this->breadcrumb_trail->opt['paged_prefix'] = bcn_get('paged_prefix'); $this->breadcrumb_trail->opt['paged_suffix'] = bcn_get('paged_suffix'); $this->breadcrumb_trail->opt['paged_display'] = str2bool(bcn_get('paged_display', 'false')); //Page settings $this->breadcrumb_trail->opt['page_prefix'] = bcn_get('page_prefix'); $this->breadcrumb_trail->opt['page_suffix'] = bcn_get('page_suffix'); $this->breadcrumb_trail->opt['page_anchor'] = bcn_get('page_anchor'); //Post related options $this->breadcrumb_trail->opt['post_prefix'] = bcn_get('post_prefix'); $this->breadcrumb_trail->opt['post_suffix'] = bcn_get('post_suffix'); $this->breadcrumb_trail->opt['post_anchor'] = bcn_get('post_anchor'); $this->breadcrumb_trail->opt['post_taxonomy_display'] = str2bool(bcn_get('post_taxonomy_display', 'false')); $this->breadcrumb_trail->opt['post_taxonomy_type'] = bcn_get('post_taxonomy_type'); //Attachment settings $this->breadcrumb_trail->opt['attachment_prefix'] = bcn_get('attachment_prefix'); $this->breadcrumb_trail->opt['attachment_suffix'] = bcn_get('attachment_suffix'); //404 page settings $this->breadcrumb_trail->opt['404_prefix'] = bcn_get('404_prefix'); $this->breadcrumb_trail->opt['404_suffix'] = bcn_get('404_suffix'); $this->breadcrumb_trail->opt['404_title'] = bcn_get('404_title'); //Search page settings $this->breadcrumb_trail->opt['search_prefix'] = bcn_get('search_prefix'); $this->breadcrumb_trail->opt['search_suffix'] = bcn_get('search_suffix'); //Tag settings $this->breadcrumb_trail->opt['tag_prefix'] = bcn_get('tag_prefix'); $this->breadcrumb_trail->opt['tag_suffix'] = bcn_get('tag_suffix'); $this->breadcrumb_trail->opt['tag_anchor'] = bcn_get('tag_anchor'); //Author page settings $this->breadcrumb_trail->opt['author_prefix'] = bcn_get('author_prefix'); $this->breadcrumb_trail->opt['author_suffix'] = bcn_get('author_suffix'); $this->breadcrumb_trail->opt['author_display'] = bcn_get('author_display'); //Category settings $this->breadcrumb_trail->opt['category_prefix'] = bcn_get('category_prefix'); $this->breadcrumb_trail->opt['category_suffix'] = bcn_get('category_suffix'); $this->breadcrumb_trail->opt['category_anchor'] = bcn_get('category_anchor'); //Archive settings $this->breadcrumb_trail->opt['archive_category_prefix'] = bcn_get('archive_category_prefix'); $this->breadcrumb_trail->opt['archive_category_suffix'] = bcn_get('archive_category_suffix'); $this->breadcrumb_trail->opt['archive_tag_prefix'] = bcn_get('archive_tag_prefix'); $this->breadcrumb_trail->opt['archive_tag_suffix'] = bcn_get('archive_tag_suffix'); //Archive by date settings $this->breadcrumb_trail->opt['date_anchor'] = bcn_get('date_anchor'); $this->breadcrumb_trail->opt['archive_date_prefix'] = bcn_get('archive_date_prefix'); $this->breadcrumb_trail->opt['archive_date_suffix'] = bcn_get('archive_date_suffix'); //Commit the option changes update_option('bcn_options', $this->breadcrumb_trail->opt); } /** * display * * Outputs the breadcrumb trail * * @param (bool) $linked Whether to allow hyperlinks in the trail or not. */ function display($linked = true) { //Update our internal settings $this->breadcrumb_trail->opt = get_option('bcn_options'); //Generate the breadcrumb trail $this->breadcrumb_trail->fill(); //Display the breadcrumb trail $this->breadcrumb_trail->display(false, $linked); } /** * filter_plugin_actions * * Places in a link to the settings page on the plugins listing * * @param (array) $links An array of links that are output in the listing * @param (string) $file The file that is currently in processing */ function filter_plugin_actions($links, $file) { static $this_plugin; if(!$this_plugin) { $this_plugin = plugin_basename(__FILE__); } //Make sure we are adding only for Breadcrumb NavXT if($file == $this_plugin) { //Setup the link string $settings_link = '' . __('Settings') . ''; //Add it to the beginning of the array array_unshift($links, $settings_link); } return $links; } /** * add_page * * Adds the adminpage the menue and the nice little settings link * */ function add_page() { global $bcn_admin_req; //We did away with bcn_security in favor of this nice thing if(current_user_can('manage_options')) { //Add the submenu page to "settings", more robust than previous method add_submenu_page('options-general.php', 'Breadcrumb NavXT Settings', 'Breadcrumb NavXT', 'manage_options', 'breadcrumb-navxt', array(&$this, 'admin_panel')); //Add in the nice "settings" link to the plugins page add_filter('plugin_action_links', array(&$this, 'filter_plugin_actions'), 10, 2); } } /** * admin_panel * * The administrative panel for Breadcrumb NavXT * */ function admin_panel() { $this->security(); //Update our internal options array, use form safe function $this->breadcrumb_trail->opt = $this->get_option('bcn_options'); //var_dump($this->breadcrumb_trail->opt); //Initilizes l10n domain $this->local(); //See if the administrative interface matches versions with the class, if not then warn the user list($bcn_plugin_major, $bcn_plugin_minor, $bcn_plugin_bugfix) = explode('.', $this->breadcrumb_trail->version); list($bcn_admin_major, $bcn_admin_minor, $bcn_admin_bugfix) = explode('.', $this->version); if($bcn_plugin_major != $bcn_admin_major || $bcn_plugin_minor != $bcn_admin_minor) { ?>

version; ?>.

breadcrumb_trail->version; ?>.

', ''); ?>
























options defaults to true/false * * @param (string) optionname name of wordpress options store * @param (array) options array of options defaults to array('true','false') */ function select_options($optionname, $options = array('true','false')) { $value = $this->breadcrumb_trail->opt[$optionname]; //First output the current value if ($value) { printf('', $value); } //Now do the rest foreach($options as $option) { //Don't want multiple occurance of the current value if($option != $value) { printf('', $option); } } } /** * get_option * * This grabs the the data from the db and places it in a form safe manner * * @param (string) option name of wordpress option to get * @return (mixed) */ function get_option($option) { $db_data = get_option($option); //If we get an array, we should loop through all of its members if(is_array($db_data)) { //Loop through all the members foreach($db_data as $key=>$item) { //We ignore anything but strings if(is_string($item)) { $db_data[$key] = htmlentities($item); } } return $db_data; } else { return htmlentities($db_data); } } } //Let's make an instance of our object takes care of everything $bcn_admin = new bcn_admin; /** * Exists for legacy compatibility. Tells user to use bcn_display, function slated for removal in 3.1. */ function breadcrumb_nav_xt_display() { echo "Please use bcn_display instead of breadcrumb_nav_xt_display"; } /** * A wrapper for the internal function in the class, please directly acess the admin class instead * * @param (bool) $linked Whether to allow hyperlinks in the trail or not. */ function bcn_display($linked = true) { global $bcn_admin; $bcn_admin->display($linked); } ?>