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(); ?>
import_form(); ?>