Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( function_exists('register_sidebar') )
- register_sidebar(array(
- 'name' => 'Featured',
- 'before_widget' => '',
- 'after_widget' => '',
- 'before_title' => '<div style="display:none;">',
- 'after_title' => '</div><a href="http://www.clothunderground.com/featured-shops"><img src="http://www.clothunderground.com/wp-content/uploads/2010/08/Image7.gif" width="25px" height="196px" title="Click for complete list of Featured Shops"></a>',
- ));
- if ( function_exists('register_sidebar') )
- register_sidebar(array(
- 'name' => 'Footer Left',
- 'before_widget' => '',
- 'after_widget' => '',
- 'before_title' => '<div id="footer_titles">',
- 'after_title' => '</div>',
- ));
- if ( function_exists('register_sidebar') )
- register_sidebar(array(
- 'name' => 'Footer Center',
- 'before_widget' => '',
- 'after_widget' => '',
- 'before_title' => '<div id="footer_titles">',
- 'after_title' => '</div>',
- ));
- if ( function_exists('register_sidebar') )
- register_sidebar(array(
- 'name' => 'Profile Groups Area',
- 'before_widget' => '',
- 'after_widget' => '',
- 'before_title' => '<div style="display:none;">',
- 'after_title' => '</div>',
- ));
- if ( function_exists('register_sidebar') )
- register_sidebar(array(
- 'name' => 'Sitewide Activity Area',
- 'before_widget' => '',
- 'after_widget' => '',
- 'before_title' => '<div style="display:none;">',
- 'after_title' => '</div>',
- ));
- if ( function_exists('register_sidebar') )
- register_sidebar(array(
- 'name' => 'New Index Recent Members Area',
- 'before_widget' => '',
- 'after_widget' => '',
- 'before_title' => '<div style="display:none;" valign="top">',
- 'after_title' => '</div>',
- ));
- register_sidebars( 1,
- array(
- 'name' => 'left sidebar',
- 'before_widget' => '<div class="widgetbox"><div id="%1$s" class="widget %2$s">',
- 'after_widget' => '</div></div>',
- 'before_title' => '<h3 class="widgettitle1">',
- 'after_title' => '</h3><div class="underwidget"></div>',
- )
- );
- // Right sidebar, as shipped with BP
- register_sidebars( 1,
- array(
- 'name' => 'Sidebar',
- 'before_widget' => '<div class="widgetbox"><div id="%1$s" class="widget %2$s">',
- 'after_widget' => '</div></div>',
- 'before_title' => '<h3 class="widgettitle1">',
- 'after_title' => '</h3><div class="underwidget"></div>',
- )
- );
- define( 'BP_DTHEME_DISABLE_CUSTOM_HEADER', true );
- if ( function_exists( 'register_nav_menu' ) ) {
- register_nav_menu( 'header_navigation', 'Header Navigation Menu' );
- }
- /* Disable the Admin Bar. */
- add_filter( 'show_admin_bar', '__return_false' );
- /* No one but moi can see edit-comments.php. */
- add_action( 'admin_init', 'check_auth' );
- function check_auth() {
- if ( strpos($_SERVER['REQUEST_URI'], 'edit-comments') > 0 && !current_user_can( 'manage_options' ) ) {
- wp_redirect( 'wp-admin/edit.php' );
- }
- }
- /* Blog Topics Shizz */
- function get_stores_in_category($category_id) {
- global $wpdb;
- $blogs = cets_get_blog_details_from_topic_id($category_id);
- $i = 0;
- if ($blogs) {
- foreach ($blogs as $blog) {
- $i++;
- switch_to_blog($blog['id']);
- $store_options = get_option('store_options');
- $stores[$i] = array('store-name' => $blog['blogname'],
- 'store-address' => $store_options['store-address'],
- 'store-city' => $store_options['store-city'],
- 'store-postal' => $store_options['store-postal'],
- 'store-phone' => $store_options['store-phone'],
- 'store-hours' => $store_options['store-hours'],
- 'store-website' => get_bloginfo('url'),
- 'google-map' => $store_options['google-map-code']);
- restore_current_blog();
- }
- }
- $users = $wpdb->get_results($wpdb->prepare("SELECT id FROM wp_users u INNER JOIN
- wp_usermeta um ON u.id = um.user_id where um.meta_key = 'listing-on' and um.meta_value =
- 'on'"));
- foreach ($users as $user) {
- $i++;
- $store_name = get_user_meta($user->id, 'store_name');
- $store_address = get_user_meta($user->id, 'address');
- $store_city = get_user_meta($user->id, 'city');
- $store_postal = get_user_meta($user->id, 'postal_code');
- $store_phone = get_user_meta($user->id, 'phone');
- $store_hours = get_user_meta($user->id, 'hours');
- $store_map = get_user_meta($user->id, 'google_code');
- $store_website = $wpdb->get_var($wpdb->prepare("SELECT user_url FROM wp_users
- WHERE ID = %d", $user->id));
- $stores[$i] = array('store-name' => $store_name[0],
- 'store-address' => $store_address[0],
- 'store-city' => $store_city[0],
- 'store-postal' => $store_postal[0],
- 'store-phone' => $store_phone[0],
- 'store-hours' => $store_hours[0],
- 'store-website' => $store_website,
- 'google-map' => $store_map[0]);
- }
- sort($stores);
- return $stores;
- }
- include_once dirname(__FILE__) . '/rewrites.php'; //include the rewrites
- /* excerpt length for item posts on main site. */
- function new_excerpt_length($length) {
- return 25;
- }
- add_filter('excerpt_length', 'new_excerpt_length');
- function new_excerpt_more($more) {
- global $post;
- return '<a href="'. get_permalink($post->ID) . '">' . '...' . '</a>';
- }
- add_filter('excerpt_more', 'new_excerpt_more');
- /* Flip PMs so newest is on top of convo thread. */
- function flip_private_message() {
- global $thread_template;
- $flipped = array_reverse( $thread_template->thread->messages );
- $thread_template->thread->messages = $flipped;
- }
- /* Post thumbs. */
- add_theme_support( 'post-thumbnails' );
- set_post_thumbnail_size( 125, 125 );
- add_image_size( 'features-thumbnail', 150, 9999 );
- add_image_size( 'archive-thumbnail', 125, 9999 );
- /* something to do with getting rid of other contact methods on backend profile. */
- function add_twitter_contactmethod( $contactmethods ) {
- unset($contactmethods['aim']);
- unset($contactmethods['jabber']);
- unset($contactmethods['yim']);
- return $contactmethods;
- }
- add_filter('user_contactmethods','add_twitter_contactmethod',10,1);
- /* Start our truncated title recent posts widget */
- function trim_title() {
- $title = get_the_title();
- $limit = "25";
- $pad="...";
- if(strlen($title) <= $limit) {
- echo $title;
- } else {
- $title = substr($title, 0, $limit) . $pad;
- echo $title;
- }
- }
- /* Add our function to the widgets_init hook. */
- add_action( 'widgets_init', 'example_load_widgets' );
- add_action( 'bp_register_widgets', 'groups_register_widgets' );
- /* Function that registers our widget. */
- function example_load_widgets() {
- register_widget( 'WP_Widget_Recent_Posts_Two' );
- register_widget( 'WP_Widget_Featured_Shops' );
- register_widget( 'profile_BP_Groups_Widget' );
- }
- class WP_Widget_Recent_Posts_Two extends WP_Widget {
- function WP_Widget_Recent_Posts_Two() {
- $widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( "The most recent posts on your site") );
- $this->WP_Widget('recent-posts', __('Recent Posts Two'), $widget_ops);
- $this->alt_option_name = 'widget_recent_entries';
- add_action( 'save_post', array(&$this, 'flush_widget_cache') );
- add_action( 'deleted_post', array(&$this, 'flush_widget_cache') );
- add_action( 'switch_theme', array(&$this, 'flush_widget_cache') );
- }
- function widget($args, $instance) {
- $cache = wp_cache_get('widget_recent_posts', 'widget');
- if ( !is_array($cache) )
- $cache = array();
- if ( isset($cache[$args['widget_id']]) ) {
- echo $cache[$args['widget_id']];
- return;
- }
- ob_start();
- extract($args);
- $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base);
- if ( !$number = (int) $instance['number'] )
- $number = 10;
- else if ( $number < 1 )
- $number = 1;
- else if ( $number > 15 )
- $number = 15;
- $r = new WP_Query(array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'caller_get_posts' => 1));
- if ($r->have_posts()) :
- ?>
- <?php echo $before_widget; ?>
- <?php if ( $title ) echo $before_title . $title . $after_title; ?>
- <ul>
- <?php while ($r->have_posts()) : $r->the_post(); ?>
- <li>
- <a href="<?php the_permalink() ?>" title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?>">
- <?php the_title() ?>
- </a>
- </li>
- <?php endwhile; ?>
- </ul>
- <?php echo $after_widget; ?>
- <?php
- // Reset the global $the_post as this query will have stomped on it
- wp_reset_postdata();
- endif;
- $cache[$args['widget_id']] = ob_get_flush();
- wp_cache_set('widget_recent_posts', $cache, 'widget');
- }
- function update( $new_instance, $old_instance ) {
- $instance = $old_instance;
- $instance['title'] = strip_tags($new_instance['title']);
- $instance['number'] = (int) $new_instance['number'];
- $this->flush_widget_cache();
- $alloptions = wp_cache_get( 'alloptions', 'options' );
- if ( isset($alloptions['widget_recent_entries']) )
- delete_option('widget_recent_entries');
- return $instance;
- }
- function flush_widget_cache() {
- wp_cache_delete('widget_recent_posts', 'widget');
- }
- function form( $instance ) {
- $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
- if ( !isset($instance['number']) || !$number = (int) $instance['number'] )
- $number = 5;
- ?>
- <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></p>
- <p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of posts to show:'); ?></label>
- <input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
- <?php
- }
- }
- /* New Featured Shops Widget */
- class WP_Widget_Featured_Shops extends WP_Widget {
- function WP_Widget_Featured_Shops() {
- $widget_ops = array('description' => __( "Shows 5 random featured shops." ) );
- $this->WP_Widget('links', __('Featured Shops'), $widget_ops);
- }
- function widget( $args, $instance ) {
- extract($args, EXTR_SKIP);
- $show_description = isset($instance['description']) ? $instance['description'] : false;
- $show_name = isset($instance['name']) ? $instance['name'] : false;
- $show_rating = isset($instance['rating']) ? $instance['rating'] : false;
- $show_images = isset($instance['images']) ? $instance['images'] : true;
- $category = isset($instance['category']) ? $instance['category'] : false;
- if ( is_admin() && !$category ) {
- // Display All Links widget as such in the widgets screen
- echo $before_widget . $before_title. __('All Links') . $after_title . $after_widget;
- return;
- }
- $before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget);
- wp_list_bookmarks(apply_filters('widget_links_args', array(
- 'title_before' => $before_title, 'title_after' => $after_title,
- 'category_before' => $before_widget, 'category_after' => $after_widget,
- 'show_images' => $show_images, 'show_description' => $show_description,
- 'show_name' => $show_name, 'show_rating' => $show_rating,
- 'category' => $category, 'class' => 'linkcat widget',
- 'limit' => 5, 'orderby' => rand
- )));
- }
- function update( $new_instance, $old_instance ) {
- $new_instance = (array) $new_instance;
- $instance = array( 'images' => 0, 'name' => 0, 'description' => 0, 'rating' => 0);
- foreach ( $instance as $field => $val ) {
- if ( isset($new_instance[$field]) )
- $instance[$field] = 1;
- }
- $instance['category'] = intval($new_instance['category']);
- return $instance;
- }
- function form( $instance ) {
- //Defaults
- $instance = wp_parse_args( (array) $instance, array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false, 'category' => false ) );
- $link_cats = get_terms( 'link_category');
- ?>
- <p>
- <label for="<?php echo $this->get_field_id('category'); ?>" class="screen-reader-text"><?php _e('Select Link Category'); ?></label>
- <select class="widefat" id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>">
- <option value=""><?php _e('All Links'); ?></option>
- <?php
- foreach ( $link_cats as $link_cat ) {
- echo '<option value="' . intval($link_cat->term_id) . '"'
- . ( $link_cat->term_id == $instance['category'] ? ' selected="selected"' : '' )
- . '>' . $link_cat->name . "</option>\n";
- }
- ?>
- </select></p>
- <p>
- <input class="checkbox" type="checkbox" <?php checked($instance['images'], true) ?> id="<?php echo $this->get_field_id('images'); ?>" name="<?php echo $this->get_field_name('images'); ?>" />
- <label for="<?php echo $this->get_field_id('images'); ?>"><?php _e('Show Link Image'); ?></label><br />
- <input class="checkbox" type="checkbox" <?php checked($instance['name'], true) ?> id="<?php echo $this->get_field_id('name'); ?>" name="<?php echo $this->get_field_name('name'); ?>" />
- <label for="<?php echo $this->get_field_id('name'); ?>"><?php _e('Show Link Name'); ?></label><br />
- <input class="checkbox" type="checkbox" <?php checked($instance['description'], true) ?> id="<?php echo $this->get_field_id('description'); ?>" name="<?php echo $this->get_field_name('description'); ?>" />
- <label for="<?php echo $this->get_field_id('description'); ?>"><?php _e('Show Link Description'); ?></label><br />
- <input class="checkbox" type="checkbox" <?php checked($instance['rating'], true) ?> id="<?php echo $this->get_field_id('rating'); ?>" name="<?php echo $this->get_field_name('rating'); ?>" />
- <label for="<?php echo $this->get_field_id('rating'); ?>"><?php _e('Show Link Rating'); ?></label>
- </p>
- <?php
- }
- }
- ?>
- <?php
- /*** PROFILE GROUPS WIDGET *****************/
- class profile_BP_Groups_Widget extends WP_Widget {
- function profile_bp_groups_widget() {
- parent::WP_Widget( false, $name = __( 'Profile Groups', 'buddypress' ) );
- if ( is_active_widget( false, false, $this->id_base ) )
- wp_enqueue_script( 'groups_widget_groups_list-js', BP_PLUGIN_URL . '/bp-groups/js/widget-groups.js', array('jquery') );
- }
- function widget($args, $instance) {
- global $bp;
- extract( $args );
- echo $before_widget;
- echo $before_title
- . $widget_name
- . $after_title; ?>
- <?php if ( bp_has_groups( 'type=active&per_page=' . $instance['max_groups'] . '&max=' . $instance['max_groups'] ) ) : ?>
- <?php while ( bp_groups() ) : bp_the_group(); if(bp_get_group_name() != 'Chit Chat' && bp_get_group_name() != 'Announcements') :?>
- <a href="<?php bp_group_permalink() ?>" title="<?php bp_group_name() ?> (<?php bp_group_member_count() ?>)"><?php bp_group_avatar_thumb() ?></a>
- <?php endif; ?>
- <?php endwhile; ?>
- <?php wp_nonce_field( 'groups_widget_groups_list', '_wpnonce-groups' ); ?>
- <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo attribute_escape( $instance['max_groups'] ); ?>" />
- <?php else: ?>
- <div class="widget-error">
- <?php _e('', 'buddypress') ?>
- </div>
- <?php endif; ?>
- <?php echo $after_widget; ?>
- <?php
- }
- function update( $new_instance, $old_instance ) {
- $instance = $old_instance;
- $instance['max_groups'] = strip_tags( $new_instance['max_groups'] );
- return $instance;
- }
- function form( $instance ) {
- $instance = wp_parse_args( (array) $instance, array( 'max_groups' => 5 ) );
- $max_groups = strip_tags( $instance['max_groups'] );
- ?>
- <p><label for="bp-groups-widget-groups-max"><?php _e('Max groups to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_groups' ); ?>" name="<?php echo $this->get_field_name( 'max_groups' ); ?>" type="text" value="<?php echo attribute_escape( $max_groups ); ?>" style="width: 30%" /></label></p>
- <?php
- }
- }
- /* ****************************************************************************************************************************
- * Generate FYI Topics RSS feeds for browsers that support alternate feeds in the header
- * ****************************************************************************************************************************
- */
- function get_fyiTopicRSSforHead() {
- // check to see if there's content in a topic. If so, create an alternate rss view for that topic
- if (function_exists('cets_get_used_topics')){
- $topics = cets_get_used_topics();
- if (sizeOf($topics) >= 1){
- foreach($topics as $topic) {
- echo('<link rel="alternate" type="application/rss+xml" title="' . $topic->slug . ' RSS Feed" href="/topic/' . strtolower($topic->slug) . '/feed" />');
- }
- }
- }
- }
- /* ****************************************************************************************************************************
- * Assign class names for the body tag of certain template pages.
- * ****************************************************************************************************************************
- */
- function get_fyiBodyClass() {
- global $wp_query;
- // find out what page template is being called
- // and set class names to be displayed in the <body> tag
- if (isset($wp_query->query_vars['topic'])) {
- echo "topic twoCol";
- }
- else if (isset($wp_query->query_vars['sitelist'])) {
- echo "sites oneCol";
- }
- else if (is_home()) {
- echo "home twoCol";
- }
- }
- function truncate ($str, $length=10, $trailing='...')
- {
- /*
- ** $str -String to truncate
- ** $length - length to truncate
- ** $trailing - the trailing character, default: "..."
- */
- // strip tags so we don't blow up xhtml
- $str = strip_tags($str);
- // take off chars for the trailing
- $length-=strlen($trailing);
- $length = checkForSpace($str, $length);
- if (strlen($str)> $length)
- {
- // string exceeded length, truncate and add trailing dots
- // find next space
- return substr($str,0,$length).$trailing;
- }
- else
- {
- // string was already short enough, return the string
- $res = $str;
- }
- return $res;
- }
- function checkForSpace($str, $pos) {
- if (substr($str, $pos, 1) == ' '){
- return $pos;
- }
- else {
- if ($pos < strlen($str)){
- return checkForSpace($str, $pos + 1);
- }
- else {
- return $pos;
- }
- }
- }
- function add_image_page() {
- add_theme_page('Custom Images', 'Custom Images', 'edit_themes', 'customimages', 'custom_image_utility');
- }
- add_action('admin_menu', 'add_image_page');
- function custom_image_utility(){
- // get the topics
- global $cets_wpmubt;
- $topics = $cets_wpmubt->get_topics();
- foreach ($topics as $topic) {
- ?>
- <h1>Custom Images</h1>
- <div class="customimage_admin">
- <h2>Images for <?php echo $topic->topic_name; ?> </h2>
- <form name="photo" enctype="multipart/form-data" action="<?php echo $_SERVER['REQUEST_URI'] ?>" method="post">
- Header: <input type="file" name="banner" size="50" /> <br />
- Thumbnail: <input type="file" name="thumbnail" size="50" />
- <input type="submit" name="upload" value="Upload" />
- </form>
- <hr />
- </div>
- <?php
- } // end foreach
- } // end function
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement