function tpicker_shortcode_version($atts)
{
    include_once silverghyll_include_best_library('silverghyll-read-plugins.php');
    $tpicker_options = get_option('taxonomy-picker-options');
    $plugin = silverghyll_read_readme(TPICKER_DIR . 'readme.txt');
    $version = $plugin['version'];
    return $version .= array_key_exists('premium-widget', $tpicker_options) ? ' (Premium)' : '';
}
function silverghyll_check_foundation($echo = true)
{
    // Check we are using lastest version of silverghyll-foundation.php which is not loaded using best-library
    $best_ver = silverghyll_include_best_library('silverghyll-foundation.php', 'version');
    // Best version
    $num_ver = silverghyll_numver(silverghyll_versioneer('__FILE__'));
    // Version in use
    if ($best_ver > $num_ver) {
        // We are not using the most recent silverghyll-foundation.php - check failed
        if (defined(SILVERGHYLL_READY)) {
            // If defined we have the name of the host package for silverghyll-foundation.php
            $problem_name = SILVERGHYLL_READY;
        } else {
            $parent_dir = dirname(dirname(__FILE__));
            $key_file = file_exists($parent_dir . '/readme.txt') ? $parent_dir . '/readme.txt' : $parent_dir . '/styles.css';
            // Readme for plugins; stylesheet for themes
            $key_file_vars = silverghyll_versioneer_read_vars($key_file);
            // Parse the markdown
            $problem_name = $key_file_vars['plugin name'] . $key_file_vars['theme name'];
        }
        if ($echo !== false) {
            echo is_string($echo) ? str_replace('[name]', $problem_name, $echo) : "<p class='silverghyll-warning'><strong>Outdated Silverghyll Foundation Library:</strong>  {$problem_name} needs updating</p>";
        }
        return false;
    } else {
        $problem_name = '_N/A_';
        // No problem, check passed
        return true;
    }
}
function scolophon_plugins_shortcode_inner(&$plugin_count, $preamble, $voice)
{
    require_once silverghyll_include_best_library('silverghyll-read-plugins.php');
    // We need silvergyll_read_plugins()
    $plugin_dir = dirname(dirname(dirname(__FILE__)));
    $plugins = silverghyll_read_plugins($plugin_dir);
    // Cannot use get_plugins in the front end
    $mu_plugins = silverghyll_read_plugins(!defined(WPMU_PLUGIN_DIR) ? WPMU_PLUGIN_DIR : dirname($plugin_dir) . '/mu-plugins/');
    // Look in MU plugins as well
    $plugins = array_merge((array) $plugins, (array) $mu_plugins);
    // Consolidate the list of plugins
    uasort($plugins, create_function('$a,$b', 'return strcmp( $a[\'author\'], $b[\'author\'] );'));
    // Sort by author
    $plugin_count = 0;
    // Build headers for table
    $results = '<style type="text/css">.colophon-plugins td{padding:1em} .colophon-plugins h4 {font-weight:bold;}</style>';
    $results .= "<table id='colophon-plugins' class='colophon-plugins'><thead><tr>";
    $results .= "<td><h4>" . __('Author') . "</h4></td>";
    $results .= "<td><h4>" . __('Contributors') . "</h4></td>";
    $results .= "<td><h4>" . __('Plugin') . "</h4></td>";
    $results .= "</tr></thead><tbody>";
    foreach ($plugins as $name => $p) {
        // Iterate through the array of all plugins and build up a table of results
        if (!empty($name)) {
            $uri = $p['plugin uri'];
            $author = $p['author'];
            $author_uri = $p['author uri'];
            if (empty($author)) {
                $author_linked = 'N/K';
            } elseif (empty($author_uri)) {
                $author_linked = "{$author}";
            } else {
                $author_linked = "<a href='{$author_uri}' target='_blank' title='Author of {$name} WordPress plugin'  class='author'>{$author}</a>";
            }
            $contributors = $p['contributors'];
            $results .= "<tr>";
            $results .= "<td>{$author_linked}</td><td>{$contributors}</td>";
            if (empty($uri)) {
                $results .= "<td>{$name}</td>";
            } else {
                $results .= "<td><a href='{$uri}' target='_blank' title='{$name} WordPress plugin'  class='name'>{$name}</a></td>";
            }
            $results .= "</tr>";
            $plugin_count++;
        }
    }
    $results .= "</tbody></table>";
    return "<p>" . scolophon_pluralise($preamble, $plugin_count, $voice) . "</p>" . $results;
}
/**
 * Return list of the best version of all files in the silverghyll Admin library, with path
 * 
 * @return array key => string, DIR of file 	data => version
 */
function silverghyll_admin_library_versions()
{
    $lib = trailingslashit(dirname(__FILE__));
    foreach (new DirectoryIterator($lib) as $file) {
        if (!$file->isDot() && $file->getFilename() != basename($_SERVER['PHP_SELF'])) {
            if (!$file->isDir() and ($fname = $file->getFilename()) != 'bare.php') {
                $library_versions[$fname] = silverghyll_include_best_library($fname, 'dir');
            }
        }
    }
    return $library_versions;
}
    // Process any previous use of the widget
    add_action('init', 'taxonomy_picker_process', 1);
    // Hook in our form handler
    // Add optional colohon support
    if (!empty($tpicker_options) and array_key_exists('colophon', $tpicker_options)) {
        include_once silverghyll_include_best_library('silverghyll-shortcodes.php');
        // Silverghyll shortcodes needed to add [colophon]
    }
    // Add shortcodes
    include_once TPICKER_DIR . 'taxonomy-picker-shortcode.php';
    /*	Defer shortcode implementation to v1.6	
    		require_once(TPICKER_DIR.'/taxonomy-picker-shortcode.php');  // Add shortcode equivalent
    	*/
    // add_action('init', create_function('' , "wp_enqueue_script('jquery');"), 1); // Activate JQuery
} else {
    require_once silverghyll_include_best_library('silverghyll-admin-menu.php');
    // silverghyll admin menu extensions - include most recent in any plugin
    require_once TPICKER_DIR . 'taxonomy-picker-admin.php';
    // Admin panel extensions for Taxonomy Picker
    register_activation_hook(__FILE__, 'taxonomy_picker_default');
    // Plugin activation
}
unset($tpicker_options);
// Avoid hanging around in global scope
/** Activation and Deactivation **
**********************************/
function taxonomy_picker_default()
{
    /* Main plugin activation function  - doubles as restore defaults */
    $default = array('remember' => 'on', 'auto-help' => 'on', 'all-format' => '** All **', 'miss-url' => home_url());
    add_option('taxonomy-picker-options', $default, '', true);