'2c-l',
);
$options = array_merge($defaults, (array) get_option('sandbox_options'));
if ( isset($options[$name]) )
return $options[$name];
return false;
}
// Andy really goes nuts with arrays, which has been a good thing. Very good.
function sandbox_set_options($new_options) {
$options = (array) get_option('sandbox_options');
$options = array_merge($options, (array) $new_options);
return update_option('sandbox_options', $options);
}
// Template tag: echoes a stylesheet link if one is selected
function sandbox_stylesheets() {
$skin = sandbox_get_option('skin');
if ( $skin != 'none' ) {
?>
" title="Sandbox" />
'.__('Skip navigation', 'sandbox').'
';
}
// Template tag: echoes a page list for navigation if the
// global_navigation option is set to "Y" in the skin file
function sandbox_globalnav() {
if ( !sandbox_get_option('globalnav') )
return;
echo "
function sandbox_comment_class( $print = true ) {
global $comment, $post, $sandbox_comment_alt;
$c = array($comment->comment_type, "c$sandbox_comment_alt");
if ( $comment->user_id > 0 ) {
$user = get_userdata($comment->user_id);
$c[] = "byuser commentauthor-$user->user_login";
if ( $comment->user_id === $post->post_author )
$c[] = 'bypostauthor';
}
sandbox_date_classes(mysql2date('U', $comment->comment_date), $c, 'c-');
if ( ++$sandbox_comment_alt % 2 )
$c[] = 'alt';
if ( is_trackback() ) {
$c[] = 'trackback';
}
$c = join(' ', apply_filters('comment_class', $c));
return $print ? print($c) : $c;
}
// Adds four time- and date-based classes to an array
// with all times relative to GMT (sometimes called UTC)
function sandbox_date_classes($t, &$c, $p = '') {
$t = $t + (get_settings('gmt_offset') * 3600);
$c[] = $p . 'y' . gmdate('Y', $t); // Year
$c[] = $p . 'm' . gmdate('m', $t); // Month
$c[] = $p . 'd' . gmdate('d', $t); // Day
$c[] = $p . 'h' . gmdate('h', $t); // Hour
}
// Returns a list of the post's categories, minus the queried one
function sandbox_cats_meow($glue) {
$current_cat = single_cat_title('', false);
$separator = "\n";
$cats = explode($separator, get_the_category_list($separator));
foreach ( $cats as $i => $str ) {
if ( strstr($str, ">$current_cat<") ) {
unset($cats[$i]);
break;
}
}
if ( empty($cats) )
return false;
return trim(join($glue, $cats));
}
// Sandbox widgets: Replaces the default search widget with one
// that matches what is in the Sandbox sidebar by default
function widget_sandbox_search($args) {
extract($args);
if ( empty($title) )
$title = __('Search', 'sandbox');
?>
except the home.', 'sandbox'); ?>
'
', 'title_after'=>'
', 'show_images'=>true));
} else {
// Queries db for links, gets stuff to display
global $wpdb;
// Results are for 2.0-style links
$cats = $wpdb->get_results("
SELECT DISTINCT link_category, cat_name, show_images,
show_description, show_rating, show_updated, sort_order,
sort_desc, list_limit
FROM `$wpdb->links`
LEFT JOIN `$wpdb->linkcategories` ON (link_category = cat_id)
WHERE link_visible = 'Y'
AND list_limit <> 0
ORDER BY cat_name ASC", ARRAY_A);
if ($cats) {
foreach ($cats as $cat) {
$orderby = $cat['sort_order'];
$orderby = (bool_from_yn($cat['sort_desc'])?'_':'') . $orderby;
// Display the category name
echo '
' . $cat['cat_name'] . "
\n\t
\n";
// Call get_links() with all the appropriate params
get_links($cat['link_category'],
'
',"
","\n",
bool_from_yn($cat['show_images']),
$orderby,
bool_from_yn($cat['show_description']),
bool_from_yn($cat['show_rating']),
$cat['list_limit'],
bool_from_yn($cat['show_updated']));
// Close the last category
echo "\n\t
\n
\n";
}
}
}
}
// Sandbox skins menu: creates the array to collect
// information from the skins currently installed
function sandbox_skin_info($skin) {
$info = array(
'skin_name' => $skin,
'skin_uri' => '',
'description' => '',
'version' => '1.0',
'author' => __('Anonymous', 'sandbox'),
'author_uri' => '',
'global_navigation' => 'Y',
);
if ( !file_exists(ABSPATH."wp-content/themes/sandbox/skins/$skin.css") )
return array();
$css = (array) file(ABSPATH."wp-content/themes/sandbox/skins/$skin.css");
foreach ( $css as $line ) {
if ( strstr($line, '*/') )
return $info;
if ( !strstr($line, ':') )
continue;
list ( $k, $v ) = explode(':', $line, 2);
$k = str_replace(' ', '_', strtolower(trim($k)));
if ( array_key_exists($k, $info) )
$info[$k] = stripslashes(wp_filter_kses(trim($v)));
}
}
// Sandbox skins menu: Registers the workings of the skins menu
function sandbox_admin_skins() {
$skins = array();
if ( isset ( $_GET['message'] ) ) {
switch ( $_GET['message'] ) {
case 'updated' :
echo "\n
documentation for help installing new skins and information on the rich semantic markup that makes the Sandbox unique.', 'sandbox'), get_template_directory_uri() . '/readme.html'); ?>
wp_filter_kses($_GET['skin']),
'globalnav' => bool_from_yn($info['global_navigation'])
));
wp_redirect('themes.php?page=skins&message=updated');
}
}
// Sandbox skins menu: tells WordPress (nicely) to load the skins menu
function sandbox_admin_menu() {
add_theme_page(__('Sandbox Skins', 'sandbox'), __('Sandbox Skins', 'sandbox'), 'switch_themes', 'skins', 'sandbox_admin_skins');
}
// Sandbox widgets: initializes Widgets for the Sandbox
function sandbox_widgets_init() {
if ( !function_exists('register_sidebars') )
return;
// Overrides the Widgets default and uses
's for sidebar headings
$p = array(
'before_title' => "
",
'after_title' => "
\n",
);
// How many? Two?! That's it?
register_sidebars(2, $p);
// Registers the widgets specific to the Sandbox, as set earlier
register_sidebar_widget(__('Search', 'sandbox'), 'widget_sandbox_search', null, 'search');
unregister_widget_control('search');
register_sidebar_widget(__('Meta', 'sandbox'), 'widget_sandbox_meta', null, 'meta');
unregister_widget_control('meta');
register_sidebar_widget(__('Links', 'sandbox'), 'widget_sandbox_links', null, 'links');
unregister_widget_control('links');
register_sidebar_widget(array('Home Link', 'widgets'), 'widget_sandbox_homelink');
register_widget_control(array('Home Link', 'widgets'), 'widget_sandbox_homelink_control', 300, 125);
register_sidebar_widget(array('RSS Links', 'widgets'), 'widget_sandbox_rsslinks');
register_widget_control(array('RSS Links', 'widgets'), 'widget_sandbox_rsslinks_control', 300, 90);
}
// Runs our code at the end to check that everything needed has loaded
add_action('init', 'sandbox_init', 1);
add_action('init', 'sandbox_widgets_init');
add_action('admin_menu', 'sandbox_admin_menu');
// Adds filters for greater compliance
add_filter('archive_meta', 'wptexturize');
add_filter('archive_meta', 'convert_smilies');
add_filter('archive_meta', 'convert_chars');
add_filter('archive_meta', 'wpautop');
?>