Breadcrumb NavXT. Version: 3.4.90 Author: John Havlik Author URI: http://mtekk.weblogs.us/ */ /* Copyright 2007-2010 John Havlik (email : mtekkmonkey@gmail.com) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ //Include the breadcrumb class require_once(dirname(__FILE__) . '/breadcrumb_navxt_class.php'); //Include the WP 2.8+ widget class require_once(dirname(__FILE__) . '/breadcrumb_navxt_widget.php'); //Include admin base class if(!class_exists('mtekk_admin')) { require_once(dirname(__FILE__) . '/mtekk_admin_class.php'); } /** * The administrative interface class * */ class bcn_admin extends mtekk_admin { /** * local store for breadcrumb version * * @var string */ protected $version = '3.4.90'; protected $full_name = 'Breadcrumb NavXT Settings'; protected $short_name = 'Breadcrumb NavXT'; protected $access_level = 'manage_options'; protected $identifier = 'breadcrumb_navxt'; protected $unique_prefix = 'bcn'; protected $plugin_basename = 'breadcrumb-navxt/breadcrumb_navxt_admin.php'; /** * local store for the breadcrumb object * * @see bcn_admin() * @var bcn_breadcrumb */ public $breadcrumb_trail; /** * bcn_admin * * Administrative interface class default constructor */ function bcn_admin() { //We'll let it fail fataly if the class isn't there as we depend on it $this->breadcrumb_trail = new bcn_breadcrumb_trail; $this->opt = $this->breadcrumb_trail->opt; $this->opt = $this->get_option('bcn_options'); //We set the plugin basename here, could manually set it, but this is for demonstration purposes //$this->plugin_base = plugin_basename(__FILE__); //Register the WordPress 2.8 Widget add_action('widgets_init', create_function('', 'return register_widget("'. $this->unique_prefix . '_widget");')); //We're going to make sure we load the parent's constructor parent::__construct(); } /** * admin initialisation callback function * * is bound to wpordpress action 'admin_init' on instantiation * * @since 3.2.0 * @return void */ function init() { //We're going to make sure we run the parent's version of this function as well parent::init(); //Add javascript enqeueing callback add_action('wp_print_scripts', array($this, 'javascript')); } /** * 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($this->access_level)) { _e('Insufficient privileges to proceed.', 'breadcrumb_navxt'); die(); } } /** * install * * This sets up and upgrades the database settings, runs on every activation */ function install() { global $wp_taxonomies; //Call our little security function $this->security(); //Initilize the options $this->breadcrumb_trail = new bcn_breadcrumb_trail; //Reduce db queries by saving this $db_version = $this->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.x.x if($major == 2) { //Delete old options $delete_options = array ( 'bcn_preserve', 'bcn_static_frontpage', 'bcn_url_blog', 'bcn_home_display', 'bcn_home_link', 'bcn_title_home', 'bcn_title_blog', 'bcn_separator', 'bcn_search_prefix', 'bcn_search_suffix', 'bcn_author_prefix', 'bcn_author_suffix', 'bcn_author_display', 'bcn_singleblogpost_prefix', 'bcn_singleblogpost_suffix', 'bcn_page_prefix', 'bcn_page_suffix', 'bcn_urltitle_prefix', 'bcn_urltitle_suffix', 'bcn_archive_category_prefix', 'bcn_archive_category_suffix', 'bcn_archive_date_prefix', 'bcn_archive_date_suffix', 'bcn_archive_date_format', 'bcn_attachment_prefix', 'bcn_attachment_suffix', 'bcn_archive_tag_prefix', 'bcn_archive_tag_suffix', 'bcn_title_404', 'bcn_link_current_item', 'bcn_current_item_urltitle', 'bcn_current_item_style_prefix', 'bcn_current_item_style_suffix', 'bcn_posttitle_maxlen', 'bcn_paged_display', 'bcn_paged_prefix', 'bcn_paged_suffix', 'bcn_singleblogpost_taxonomy', 'bcn_singleblogpost_taxonomy_display', 'bcn_singleblogpost_category_prefix', 'bcn_singleblogpost_category_suffix', 'bcn_singleblogpost_tag_prefix', 'bcn_singleblogpost_tag_suffix' ); foreach ($delete_options as $option) { $this->delete_option($option); } } else if($major == 3 && $minor == 0) { //Update our internal settings $this->breadcrumb_trail->opt = $this->get_option('bcn_options'); $this->breadcrumb_trail->opt['search_anchor'] = __('','breadcrumb_navxt'); } else if($major == 3 && $minor < 3) { //Update our internal settings $this->breadcrumb_trail->opt = $this->get_option('bcn_options'); $this->breadcrumb_trail->opt['blog_display'] = true; } else if($major == 3 && $minor < 4) { //Inline upgrade of the tag setting if($this->breadcrumb_trail->opt['post_taxonomy_type'] === 'tag') { $this->breadcrumb_trail->opt['post_taxonomy_type'] = 'post_tag'; } //Fix our tag settings $this->breadcrumb_trail->opt['archive_post_tag_prefix'] = $this->breadcrumb_trail->opt['archive_tag_prefix']; $this->breadcrumb_trail->opt['archive_post_tag_suffix'] = $this->breadcrumb_trail->opt['archive_tag_suffix']; $this->breadcrumb_trail->opt['post_tag_prefix'] = $this->breadcrumb_trail->opt['tag_prefix']; $this->breadcrumb_trail->opt['post_tag_suffix'] = $this->breadcrumb_trail->opt['tag_suffix']; $this->breadcrumb_trail->opt['post_tag_anchor'] = $this->breadcrumb_trail->opt['tag_anchor']; } else if($major == 3 && $minor < 5) { } //We'll add our custom taxonomy stuff at this time foreach($wp_taxonomies as $taxonomy) { //We only want custom taxonomies if(($taxonomy->object_type == 'post' || is_array($taxonomy->object_type) && in_array('post', $taxonomy->object_type)) && ($taxonomy->name != 'post_tag' && $taxonomy->name != 'category')) { //If the taxonomy does not have settings in the options array yet, we need to load some defaults if(!array_key_exists($taxonomy->name . '_anchor', $this->opt)) { $this->breadcrumb_trail->opt[$taxonomy->name . '_prefix'] = ''; $this->breadcrumb_trail->opt[$taxonomy->name . '_suffix'] = ''; $this->breadcrumb_trail->opt[$taxonomy->name . '_anchor'] = __(sprintf(''), 'breadcrumb_navxt'); $this->breadcrumb_trail->opt['archive_' . $taxonomy->name . '_prefix'] = ''; $this->breadcrumb_trail->opt['archive_' . $taxonomy->name . '_suffix'] = ''; } } } //Always have to update the version $this->update_option('bcn_version', $this->version); //Store the options $this->add_option('bcn_options', $this->breadcrumb_trail->opt); } //Check if we have valid anchors if($temp = $this->get_option('bcn_options')) { //Missing the blog anchor is a bug from 3.0.0/3.0.1 so we soft error that one if(strlen($temp['blog_anchor']) == 0) { $temp['blog_anchor'] = $this->breadcrumb_trail->opt['blog_anchor']; $this->update_option('bcn_options', $temp); } else if(strlen($temp['home_anchor']) == 0 || strlen($temp['blog_anchor']) == 0 || strlen($temp['page_anchor']) == 0 || strlen($temp['post_anchor']) == 0 || strlen($temp['tag_anchor']) == 0 || strlen($temp['date_anchor']) == 0 || strlen($temp['category_anchor']) == 0) { $this->delete_option('bcn_options'); $this->add_option('bcn_options', $this->breadcrumb_trail->opt); } } } /** * ops_update * * Updates the database settings from the webform */ function opts_update() { global $wp_taxonomies; //Do some security related thigns as we are not using the normal WP settings API $this->security(); //Do a nonce check, prevent malicious link/form problems check_admin_referer('bcn_options-options'); //Grab our incomming array (the data is dirty) $input = $_POST['bcn_options']; //Loop through all of the existing options (avoids random setting injection) foreach($this->opt as $option => $value) { //Handle all of our boolean options first if(strpos($option, 'display') > 0 || $option == 'current_item_linked') { $this->opt[$option] = isset($input[$option]); } //Now handle anything that can't be blank else if(strpos($option, 'anchor') > 0) { //Only save a new anchor if not blank if(isset($input[$option])) { //Do excess slash removal sanitation $this->opt[$option] = stripslashes($input[$option]); } } //Now everything else else { $this->opt[$option] = stripslashes($input[$option]); } } //Commit the option changes $this->update_option('bcn_options', $this->opt); //Let the user know everything went ok $this->message['updated fade'][] = __('Settings successfully saved.', $this->identifier); add_action('admin_notices', array($this, 'message')); } /** * javascript * * Enqueues JS dependencies (jquery) for the tabs * * @see admin_init() * @return void */ function javascript() { //Enqueue ui-tabs wp_enqueue_script('jquery-ui-tabs'); } /** * get help text * * @return string */ protected function _get_help_text() { return sprintf(__('Tips for the settings are located below select options. Please refer to the %sdocumentation%s for more information.', 'breadcrumb_navxt'), '', ''); } /** * admin_head * * Adds in the JavaScript and CSS for the tabs in the adminsitrative * interface * */ function admin_head() { // print style and script element (should go into head element) ?> security();?>

_has_contextual_help): ?> class="hide-if-js">_get_help_text(); ?>

input_text(__('Breadcrumb Separator', 'breadcrumb_navxt'), 'separator', '32', false, __('Placed in between each breadcrumb.', 'breadcrumb_navxt')); $this->input_text(__('Breadcrumb Max Title Length', 'breadcrumb_navxt'), 'max_title_length', '10'); ?> input_check(__('Blog Breadcrumb', 'breadcrumb_navxt'), 'blog_display', __('Place the blog breadcrumb in the trail.', 'breadcrumb_navxt'), ($this->get_option('show_on_front') !== "page")); $this->input_text(__('Home Prefix', 'breadcrumb_navxt'), 'home_prefix', '32'); $this->input_text(__('Home Suffix', 'breadcrumb_navxt'), 'home_suffix', '32'); $this->input_text(__('Home Anchor', 'breadcrumb_navxt'), 'home_anchor', '64', false, __('The anchor template for the home breadcrumb.', 'breadcrumb_navxt')); $this->input_text(__('Blog Anchor', 'breadcrumb_navxt'), 'blog_anchor', '64', ($this->get_option('show_on_front') !== "page"), __('The anchor template for the blog breadcrumb, used only in static front page environments.', 'breadcrumb_navxt')); ?>

input_check(__('Link Current Item', 'breadcrumb_navxt'), 'current_item_linked', __('Yes')); $this->input_text(__('Current Item Prefix', 'breadcrumb_navxt'), 'current_item_prefix', '32', false, __('This is always placed in front of the last breadcrumb in the trail, before any other prefixes for that breadcrumb.', 'breadcrumb_navxt')); $this->input_text(__('Current Item Suffix', 'breadcrumb_navxt'), 'current_item_suffix', '32', false, __('This is always placed after the last breadcrumb in the trail, and after any other prefixes for that breadcrumb.', 'breadcrumb_navxt')); $this->input_text(__('Current Item Anchor', 'breadcrumb_navxt'), 'current_item_anchor', '64', false, __('The anchor template for current item breadcrumbs.', 'breadcrumb_navxt')); $this->input_check(__('Paged Breadcrumb', 'breadcrumb_navxt'), 'paged_display', __('Include the paged breadcrumb in the breadcrumb trail.', 'breadcrumb_navxt'), false, __('Indicates that the user is on a page other than the first on paginated posts/pages.', 'breadcrumb_navxt')); $this->input_text(__('Paged Prefix', 'breadcrumb_navxt'), 'paged_prefix', '32'); $this->input_text(__('Paged Suffix', 'breadcrumb_navxt'), 'paged_suffix', '32'); ?>

input_text(__('Post Prefix', 'breadcrumb_navxt'), 'post_prefix', '32'); $this->input_text(__('Post Suffix', 'breadcrumb_navxt'), 'post_suffix', '32'); $this->input_text(__('Post Anchor', 'breadcrumb_navxt'), 'post_anchor', '64', false, __('The anchor template for post breadcrumbs.', 'breadcrumb_navxt')); $this->input_check(__('Post Taxonomy Display', 'breadcrumb_navxt'), 'post_taxonomy_display', __('Show the taxonomy leading to a post in the breadcrumb trail.', 'breadcrumb_navxt')); ?> input_text(__('Page Prefix', 'breadcrumb_navxt'), 'page_prefix', '32'); $this->input_text(__('Page Suffix', 'breadcrumb_navxt'), 'page_suffix', '32'); $this->input_text(__('Page Anchor', 'breadcrumb_navxt'), 'page_anchor', '64', false, __('The anchor template for page breadcrumbs.', 'breadcrumb_navxt')); $this->input_text(__('Attachment Prefix', 'breadcrumb_navxt'), 'attachment_prefix', '32'); $this->input_text(__('Attachment Suffix', 'breadcrumb_navxt'), 'attachment_suffix', '32'); ?>
input_radio('post_taxonomy_type', 'category', __('Categories')); $this->input_radio('post_taxonomy_type', 'date', __('Dates')); $this->input_radio('post_taxonomy_type', 'post_tag', __('Tags')); $this->input_radio('post_taxonomy_type', 'page', __('Pages')); //Loop through all of the taxonomies in the array foreach($wp_taxonomies as $taxonomy) { //We only want custom taxonomies if(($taxonomy->object_type == 'post' || is_array($taxonomy->object_type) && in_array('post', $taxonomy->object_type)) && ($taxonomy->name != 'post_tag' && $taxonomy->name != 'category')) { $this->input_radio('post_taxonomy_type', $taxonomy->name, ucwords(__($taxonomy->label))); } } ?>

input_text(__('Category Prefix', 'breadcrumb_navxt'), 'category_prefix', '32', false, __('Applied before the anchor on all category breadcrumbs.', 'breadcrumb_navxt')); $this->input_text(__('Category Suffix', 'breadcrumb_navxt'), 'category_suffix', '32', false, __('Applied after the anchor on all category breadcrumbs.', 'breadcrumb_navxt')); $this->input_text(__('Category Anchor', 'breadcrumb_navxt'), 'category_anchor', '64', false, __('The anchor template for category breadcrumbs.', 'breadcrumb_navxt')); $this->input_text(__('Archive by Category Prefix', 'breadcrumb_navxt'), 'archive_category_prefix', '32', false, __('Applied before the title of the current item breadcrumb on an archive by cateogry page.', 'breadcrumb_navxt')); $this->input_text(__('Archive by Category Suffix', 'breadcrumb_navxt'), 'archive_category_suffix', '32', false, __('Applied after the title of the current item breadcrumb on an archive by cateogry page.', 'breadcrumb_navxt')); ?>

input_text(__('Tag Prefix', 'breadcrumb_navxt'), 'post_tag_prefix', '32', false, __('Applied before the anchor on all tag breadcrumbs.', 'breadcrumb_navxt')); $this->input_text(__('Tag Suffix', 'breadcrumb_navxt'), 'post_tag_suffix', '32', false, __('Applied after the anchor on all tag breadcrumbs.', 'breadcrumb_navxt')); $this->input_text(__('Tag Anchor', 'breadcrumb_navxt'), 'post_tag_anchor', '64', false, __('The anchor template for tag breadcrumbs.', 'breadcrumb_navxt')); $this->input_text(__('Archive by Tag Prefix', 'breadcrumb_navxt'), 'archive_post_tag_prefix', '32', false, __('Applied before the title of the current item breadcrumb on an archive by tag page.', 'breadcrumb_navxt')); $this->input_text(__('Archive by Tag Suffix', 'breadcrumb_navxt'), 'archive_post_tag_suffix', '32', false, __('Applied after the title of the current item breadcrumb on an archive by tag page.', 'breadcrumb_navxt')); ?>
object_type == 'post' || is_array($taxonomy->object_type) && in_array('post', $taxonomy->object_type)) && ($taxonomy->name != 'post_tag' && $taxonomy->name != 'category')) { //If the taxonomy does not have settings in the options array yet, we need to load some defaults if(!array_key_exists($taxonomy->name . '_anchor', $this->opt)) { //Add the necessary option array members $this->opt[$taxonomy->name . '_prefix'] = ''; $this->opt[$taxonomy->name . '_suffix'] = ''; $this->opt[$taxonomy->name . '_anchor'] = __(sprintf('', ucwords(__($taxonomy->label))), 'breadcrumb_navxt'); $this->opt['archive_' . $taxonomy->name . '_prefix'] = ''; $this->opt['archive_' . $taxonomy->name . '_suffix'] = ''; //Let's make sure that the newly available options are "registered" in our db $this->update_option('bcn_options', $this->opt); } ?>

label)); ?>

input_text(sprintf(__('%s Prefix', 'breadcrumb_navxt'), ucwords(__($taxonomy->label))), $taxonomy->name . '_prefix', '32', false, sprintf(__('Applied before the anchor on all %s breadcrumbs.', 'breadcrumb_navxt'), strtolower(__($taxonomy->label)))); $this->input_text(sprintf(__('%s Suffix', 'breadcrumb_navxt'), ucwords(__($taxonomy->label))), $taxonomy->name . '_suffix', '32', false, sprintf(__('Applied after the anchor on all %s breadcrumbs.', 'breadcrumb_navxt'), strtolower(__($taxonomy->label)))); $this->input_text(sprintf(__('%s Anchor', 'breadcrumb_navxt'), ucwords(__($taxonomy->label))), $taxonomy->name . '_anchor', '64', false, sprintf(__('The anchor template for %s breadcrumbs.', 'breadcrumb_navxt'), strtolower(__($taxonomy->label)))); $this->input_text(sprintf(__('Archive by %s Prefix', 'breadcrumb_navxt'), ucwords(__($taxonomy->label))), 'archive_' . $taxonomy->name . '_prefix', '32', false, sprintf(__('Applied before the title of the current item breadcrumb on an archive by %s page.', 'breadcrumb_navxt'), strtolower(__($taxonomy->label)))); $this->input_text(sprintf(__('Archive by %s Suffix', 'breadcrumb_navxt'), ucwords(__($taxonomy->label))), 'archive_' . $taxonomy->name . '_suffix', '32', false, sprintf(__('Applied after the title of the current item breadcrumb on an archive by %s page.', 'breadcrumb_navxt'), strtolower(__($taxonomy->label)))); ?>

input_text(__('Date Anchor', 'breadcrumb_navxt'), 'date_anchor', '64', false, __('The anchor template for date breadcrumbs.', 'breadcrumb_navxt')); $this->input_text(__('Archive by Date Prefix', 'breadcrumb_navxt'), 'archive_date_prefix', '32', false, __('Applied before the anchor on all date breadcrumbs.', 'breadcrumb_navxt')); $this->input_text(__('Archive by Date Suffix', 'breadcrumb_navxt'), 'archive_date_suffix', '32', false, __('Applied after the anchor on all date breadcrumbs.', 'breadcrumb_navxt')); ?>

input_text(__('Author Prefix', 'breadcrumb_navxt'), 'author_prefix', '32'); $this->input_text(__('Author Suffix', 'breadcrumb_navxt'), 'author_suffix', '32'); $this->input_text(__('Archive by Date Suffix', 'breadcrumb_navxt'), 'archive_date_suffix', '32', false, __('Applied after the anchor on all date breadcrumbs.', 'breadcrumb_navxt')); $this->input_select(__('Author Display Format', 'breadcrumb_navxt'), 'author_name', array("display_name", "nickname", "first_name", "last_name"), false, __('display_name uses the name specified in "Display name publicly as" under the user profile the others correspond to options in the user profile.', 'breadcrumb_navxt')); $this->input_text(__('Search Prefix', 'breadcrumb_navxt'), 'search_prefix', '32'); $this->input_text(__('Search Suffix', 'breadcrumb_navxt'), 'search_suffix', '32'); $this->input_text(__('Search Anchor', 'breadcrumb_navxt'), 'search_anchor', '64', false, __('The anchor template for search breadcrumbs, used only when the search results span several pages.', 'breadcrumb_navxt')); $this->input_text(__('404 Title', 'breadcrumb_navxt'), '404_title', '32'); $this->input_text(__('404 Prefix', 'breadcrumb_navxt'), '404_prefix', '32'); $this->input_text(__('404 Suffix', 'breadcrumb_navxt'), '404_suffix', '32'); ?>

import_form(); ?>
breadcrumb_trail->fill(); return $this->breadcrumb_trail->display($return, $linked, $reverse); } /** * display_list * * Outputs the breadcrumb trail * * @since 3.2.0 * @param (bool) $return Whether to return or echo the trail. * @param (bool) $linked Whether to allow hyperlinks in the trail or not. * @param (bool) $reverse Whether to reverse the output or not. */ function display_list($return = false, $linked = true, $reverse = false) { //Generate the breadcrumb trail $this->breadcrumb_trail->fill(); return $this->breadcrumb_trail->display_list($return, $linked, $reverse); } } //Let's make an instance of our object takes care of everything $bcn_admin = new bcn_admin; /** * A wrapper for the internal function in the class * * @param bool $return Whether to return or echo the trail. (optional) * @param bool $linked Whether to allow hyperlinks in the trail or not. (optional) * @param bool $reverse Whether to reverse the output or not. (optional) */ function bcn_display($return = false, $linked = true, $reverse = false) { global $bcn_admin; return $bcn_admin->display($return, $linked, $reverse); } /** * A wrapper for the internal function in the class * * @param bool $return Whether to return or echo the trail. (optional) * @param bool $linked Whether to allow hyperlinks in the trail or not. (optional) * @param bool $reverse Whether to reverse the output or not. (optional) */ function bcn_display_list($return = false, $linked = true, $reverse = false) { global $bcn_admin; return $bcn_admin->display_list($return, $linked, $reverse); }