Advertisement
Guest User

Untitled

a guest
Nov 8th, 2011
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 20.22 KB | None | 0 0
  1. <?php
  2.  
  3. if ( function_exists('register_sidebar') )
  4. register_sidebar(array(
  5. 'name' => 'Featured',
  6. 'before_widget' => '',
  7. 'after_widget' => '',
  8. 'before_title' => '<div style="display:none;">',
  9. '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>',
  10. ));
  11. if ( function_exists('register_sidebar') )
  12. register_sidebar(array(
  13. 'name' => 'Footer Left',
  14. 'before_widget' => '',
  15. 'after_widget' => '',
  16. 'before_title' => '<div id="footer_titles">',
  17. 'after_title' => '</div>',
  18. ));
  19. if ( function_exists('register_sidebar') )
  20. register_sidebar(array(
  21. 'name' => 'Footer Center',
  22. 'before_widget' => '',
  23. 'after_widget' => '',
  24. 'before_title' => '<div id="footer_titles">',
  25. 'after_title' => '</div>',
  26. ));
  27. if ( function_exists('register_sidebar') )
  28. register_sidebar(array(
  29. 'name' => 'Profile Groups Area',
  30. 'before_widget' => '',
  31. 'after_widget' => '',
  32. 'before_title' => '<div style="display:none;">',
  33. 'after_title' => '</div>',
  34. ));
  35. if ( function_exists('register_sidebar') )
  36. register_sidebar(array(
  37. 'name' => 'Sitewide Activity Area',
  38. 'before_widget' => '',
  39. 'after_widget' => '',
  40. 'before_title' => '<div style="display:none;">',
  41. 'after_title' => '</div>',
  42. ));
  43. if ( function_exists('register_sidebar') )
  44. register_sidebar(array(
  45. 'name' => 'New Index Recent Members Area',
  46. 'before_widget' => '',
  47. 'after_widget' => '',
  48. 'before_title' => '<div style="display:none;" valign="top">',
  49. 'after_title' => '</div>',
  50. ));
  51. register_sidebars( 1,
  52.     array(
  53.         'name' => 'left sidebar',
  54.         'before_widget' => '<div class="widgetbox"><div id="%1$s" class="widget %2$s">',
  55.         'after_widget' => '</div></div>',
  56.         'before_title' => '<h3 class="widgettitle1">',
  57.         'after_title' => '</h3><div class="underwidget"></div>',
  58.     )
  59. );
  60. // Right sidebar, as shipped with BP
  61. register_sidebars( 1,
  62.     array(
  63.         'name'          => 'Sidebar',
  64.         'before_widget' => '<div class="widgetbox"><div id="%1$s" class="widget %2$s">',
  65.         'after_widget' => '</div></div>',
  66.         'before_title' => '<h3 class="widgettitle1">',
  67.         'after_title' => '</h3><div class="underwidget"></div>',
  68.     )
  69. );
  70.  
  71. define( 'BP_DTHEME_DISABLE_CUSTOM_HEADER', true );
  72.  
  73. if ( function_exists( 'register_nav_menu' ) ) {
  74.     register_nav_menu( 'header_navigation', 'Header Navigation Menu' );
  75. }
  76.  
  77. /* Disable the Admin Bar. */
  78. add_filter( 'show_admin_bar', '__return_false' );
  79.  
  80. /* No one but moi can see edit-comments.php. */
  81. add_action( 'admin_init', 'check_auth' );
  82.  
  83. function check_auth() {
  84.  
  85.         if ( strpos($_SERVER['REQUEST_URI'], 'edit-comments') > 0 && !current_user_can( 'manage_options' ) ) {
  86.           wp_redirect( 'wp-admin/edit.php' );
  87.         }
  88.        
  89.  
  90. }
  91.  
  92.  
  93.  
  94.  
  95. /* Blog Topics Shizz */
  96.  
  97. function get_stores_in_category($category_id) {
  98.     global $wpdb;
  99.     $blogs = cets_get_blog_details_from_topic_id($category_id);
  100.     $i = 0;
  101.     if ($blogs) {
  102.     foreach ($blogs as $blog) {
  103.         $i++;
  104.         switch_to_blog($blog['id']);
  105.         $store_options = get_option('store_options');
  106.         $stores[$i] = array('store-name' => $blog['blogname'],
  107.                             'store-address' => $store_options['store-address'],
  108.                             'store-city' => $store_options['store-city'],
  109.                             'store-postal' => $store_options['store-postal'],
  110.                             'store-phone' => $store_options['store-phone'],
  111.                             'store-hours' => $store_options['store-hours'],
  112.                             'store-website' => get_bloginfo('url'),
  113.                             'google-map' => $store_options['google-map-code']);
  114.  
  115.         restore_current_blog();
  116.     }
  117.     }
  118.  
  119.     $users = $wpdb->get_results($wpdb->prepare("SELECT id FROM wp_users u INNER JOIN
  120. wp_usermeta um ON u.id = um.user_id where um.meta_key = 'listing-on' and um.meta_value =
  121. 'on'"));
  122.  
  123.     foreach ($users as $user) {
  124.         $i++;
  125.         $store_name = get_user_meta($user->id, 'store_name');
  126.         $store_address = get_user_meta($user->id, 'address');
  127.         $store_city = get_user_meta($user->id, 'city');
  128.         $store_postal = get_user_meta($user->id, 'postal_code');
  129.         $store_phone = get_user_meta($user->id, 'phone');
  130.         $store_hours = get_user_meta($user->id, 'hours');
  131.         $store_map = get_user_meta($user->id, 'google_code');
  132.         $store_website = $wpdb->get_var($wpdb->prepare("SELECT user_url FROM wp_users
  133. WHERE ID = %d", $user->id));
  134.  
  135.         $stores[$i] = array('store-name' => $store_name[0],
  136.                             'store-address' => $store_address[0],
  137.                             'store-city' => $store_city[0],
  138.                             'store-postal' => $store_postal[0],
  139.                             'store-phone' => $store_phone[0],
  140.                             'store-hours' => $store_hours[0],
  141.                             'store-website' => $store_website,
  142.                             'google-map' => $store_map[0]);
  143.  
  144.     }
  145.  
  146.  
  147.     sort($stores);
  148.     return $stores;
  149. }
  150.  
  151.  
  152.  
  153.  
  154. include_once dirname(__FILE__) . '/rewrites.php'; //include the rewrites
  155.  
  156. /* excerpt length for item posts on main site. */
  157. function new_excerpt_length($length) {
  158.     return 25;
  159. }
  160. add_filter('excerpt_length', 'new_excerpt_length');
  161.  
  162. function new_excerpt_more($more) {
  163.        global $post;
  164.     return '<a href="'. get_permalink($post->ID) . '">' . '...' . '</a>';
  165. }
  166. add_filter('excerpt_more', 'new_excerpt_more');
  167.  
  168. /* Flip PMs so newest is on top of convo thread. */
  169.  
  170. function flip_private_message() {
  171.         global $thread_template;
  172.         $flipped = array_reverse( $thread_template->thread->messages );
  173.         $thread_template->thread->messages = $flipped;
  174.         }
  175.        
  176. /* Post thumbs. */     
  177.  
  178. add_theme_support( 'post-thumbnails' );
  179. set_post_thumbnail_size( 125, 125 );
  180. add_image_size( 'features-thumbnail', 150, 9999 );
  181. add_image_size( 'archive-thumbnail', 125, 9999 );
  182.  
  183. /* something to do with getting rid of other contact methods on backend profile. */
  184.  
  185. function add_twitter_contactmethod( $contactmethods ) {
  186.   unset($contactmethods['aim']);
  187.   unset($contactmethods['jabber']);
  188.   unset($contactmethods['yim']);
  189.   return $contactmethods;
  190. }
  191. add_filter('user_contactmethods','add_twitter_contactmethod',10,1);
  192.  
  193. /* Start our truncated title recent posts widget */
  194.  
  195. function trim_title() {
  196. $title = get_the_title();
  197. $limit = "25";
  198. $pad="...";
  199.  
  200. if(strlen($title) <= $limit) {
  201. echo $title;
  202. } else {
  203. $title = substr($title, 0, $limit) . $pad;
  204. echo $title;
  205. }
  206. }
  207.  
  208. /* Add our function to the widgets_init hook. */
  209. add_action( 'widgets_init', 'example_load_widgets' );
  210. add_action( 'bp_register_widgets', 'groups_register_widgets' );
  211.  
  212. /* Function that registers our widget. */
  213. function example_load_widgets() {
  214.         register_widget( 'WP_Widget_Recent_Posts_Two' );
  215.         register_widget( 'WP_Widget_Featured_Shops' );
  216.         register_widget( 'profile_BP_Groups_Widget' );
  217. }
  218. class WP_Widget_Recent_Posts_Two extends WP_Widget {
  219.  
  220.         function WP_Widget_Recent_Posts_Two() {
  221.                 $widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( "The most recent posts on your site") );
  222.                 $this->WP_Widget('recent-posts', __('Recent Posts Two'), $widget_ops);
  223.                 $this->alt_option_name = 'widget_recent_entries';
  224.  
  225.                 add_action( 'save_post', array(&$this, 'flush_widget_cache') );
  226.                 add_action( 'deleted_post', array(&$this, 'flush_widget_cache') );
  227.                 add_action( 'switch_theme', array(&$this, 'flush_widget_cache') );
  228.         }
  229.  
  230.         function widget($args, $instance) {
  231.                 $cache = wp_cache_get('widget_recent_posts', 'widget');
  232.  
  233.                 if ( !is_array($cache) )
  234.                         $cache = array();
  235.  
  236.                 if ( isset($cache[$args['widget_id']]) ) {
  237.                         echo $cache[$args['widget_id']];
  238.                         return;
  239.                 }
  240.  
  241.                 ob_start();
  242.                 extract($args);
  243.  
  244.                 $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base);
  245.                 if ( !$number = (int) $instance['number'] )
  246.                         $number = 10;
  247.                 else if ( $number < 1 )
  248.                         $number = 1;
  249.                 else if ( $number > 15 )
  250.                         $number = 15;
  251.  
  252.                 $r = new WP_Query(array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'caller_get_posts' => 1));
  253.                 if ($r->have_posts()) :
  254. ?>
  255.                 <?php echo $before_widget; ?>
  256.                 <?php if ( $title ) echo $before_title . $title . $after_title; ?>
  257.                 <ul>
  258.                 <?php  while ($r->have_posts()) : $r->the_post(); ?>
  259.                 <li>
  260.                         <a href="<?php the_permalink() ?>" title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?>">
  261.                         <?php the_title() ?>
  262.                         </a>
  263.                 </li>
  264.                 <?php endwhile; ?>
  265.                 </ul>
  266.                 <?php echo $after_widget; ?>
  267. <?php
  268.                 // Reset the global $the_post as this query will have stomped on it
  269.                 wp_reset_postdata();
  270.  
  271.                 endif;
  272.  
  273.                 $cache[$args['widget_id']] = ob_get_flush();
  274.                 wp_cache_set('widget_recent_posts', $cache, 'widget');
  275.         }
  276.  
  277.         function update( $new_instance, $old_instance ) {
  278.                 $instance = $old_instance;
  279.                 $instance['title'] = strip_tags($new_instance['title']);
  280.                 $instance['number'] = (int) $new_instance['number'];
  281.                 $this->flush_widget_cache();
  282.  
  283.                 $alloptions = wp_cache_get( 'alloptions', 'options' );
  284.                 if ( isset($alloptions['widget_recent_entries']) )
  285.                         delete_option('widget_recent_entries');
  286.  
  287.                 return $instance;
  288.         }
  289.  
  290.         function flush_widget_cache() {
  291.                 wp_cache_delete('widget_recent_posts', 'widget');
  292.         }
  293.  
  294.         function form( $instance ) {
  295.                 $title = isset($instance['title']) ? esc_attr($instance['title']) : '';
  296.                 if ( !isset($instance['number']) || !$number = (int) $instance['number'] )
  297.                         $number = 5;
  298. ?>
  299.                 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
  300.                 <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>
  301.  
  302.                 <p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e('Number of posts to show:'); ?></label>
  303.                 <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>
  304. <?php
  305.         }
  306. }
  307.  
  308.  
  309. /* New Featured Shops Widget */
  310.  
  311. class WP_Widget_Featured_Shops extends WP_Widget {
  312.  
  313.     function WP_Widget_Featured_Shops() {
  314.         $widget_ops = array('description' => __( "Shows 5 random featured shops." ) );
  315.         $this->WP_Widget('links', __('Featured Shops'), $widget_ops);
  316.     }
  317.  
  318.     function widget( $args, $instance ) {
  319.         extract($args, EXTR_SKIP);
  320.  
  321.         $show_description = isset($instance['description']) ? $instance['description'] : false;
  322.         $show_name = isset($instance['name']) ? $instance['name'] : false;
  323.         $show_rating = isset($instance['rating']) ? $instance['rating'] : false;
  324.         $show_images = isset($instance['images']) ? $instance['images'] : true;
  325.         $category = isset($instance['category']) ? $instance['category'] : false;
  326.  
  327.         if ( is_admin() && !$category ) {
  328.             // Display All Links widget as such in the widgets screen
  329.             echo $before_widget . $before_title. __('All Links') . $after_title . $after_widget;
  330.             return;
  331.         }
  332.  
  333.         $before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget);
  334.         wp_list_bookmarks(apply_filters('widget_links_args', array(
  335.             'title_before' => $before_title, 'title_after' => $after_title,
  336.             'category_before' => $before_widget, 'category_after' => $after_widget,
  337.             'show_images' => $show_images, 'show_description' => $show_description,
  338.             'show_name' => $show_name, 'show_rating' => $show_rating,
  339.             'category' => $category, 'class' => 'linkcat widget',
  340.             'limit' => 5, 'orderby' => rand
  341.         )));
  342.     }
  343.  
  344.     function update( $new_instance, $old_instance ) {
  345.         $new_instance = (array) $new_instance;
  346.         $instance = array( 'images' => 0, 'name' => 0, 'description' => 0, 'rating' => 0);
  347.         foreach ( $instance as $field => $val ) {
  348.             if ( isset($new_instance[$field]) )
  349.                 $instance[$field] = 1;
  350.         }
  351.         $instance['category'] = intval($new_instance['category']);
  352.  
  353.         return $instance;
  354.     }
  355.  
  356.     function form( $instance ) {
  357.  
  358.         //Defaults
  359.         $instance = wp_parse_args( (array) $instance, array( 'images' => true, 'name' => true, 'description' => false, 'rating' => false, 'category' => false ) );
  360.         $link_cats = get_terms( 'link_category');
  361. ?>
  362.         <p>
  363.         <label for="<?php echo $this->get_field_id('category'); ?>" class="screen-reader-text"><?php _e('Select Link Category'); ?></label>
  364.         <select class="widefat" id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>">
  365.         <option value=""><?php _e('All Links'); ?></option>
  366.         <?php
  367.         foreach ( $link_cats as $link_cat ) {
  368.             echo '<option value="' . intval($link_cat->term_id) . '"'
  369.                 . ( $link_cat->term_id == $instance['category'] ? ' selected="selected"' : '' )
  370.                 . '>' . $link_cat->name . "</option>\n";
  371.         }
  372.         ?>
  373.         </select></p>
  374.         <p>
  375.         <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'); ?>" />
  376.         <label for="<?php echo $this->get_field_id('images'); ?>"><?php _e('Show Link Image'); ?></label><br />
  377.         <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'); ?>" />
  378.         <label for="<?php echo $this->get_field_id('name'); ?>"><?php _e('Show Link Name'); ?></label><br />
  379.         <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'); ?>" />
  380.         <label for="<?php echo $this->get_field_id('description'); ?>"><?php _e('Show Link Description'); ?></label><br />
  381.         <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'); ?>" />
  382.         <label for="<?php echo $this->get_field_id('rating'); ?>"><?php _e('Show Link Rating'); ?></label>
  383.         </p>
  384. <?php
  385.     }
  386. }
  387. ?>
  388. <?php
  389.  
  390. /*** PROFILE GROUPS WIDGET *****************/
  391.  
  392. class profile_BP_Groups_Widget extends WP_Widget {
  393.     function profile_bp_groups_widget() {
  394.         parent::WP_Widget( false, $name = __( 'Profile Groups', 'buddypress' ) );
  395.  
  396.         if ( is_active_widget( false, false, $this->id_base ) )
  397.             wp_enqueue_script( 'groups_widget_groups_list-js', BP_PLUGIN_URL . '/bp-groups/js/widget-groups.js', array('jquery') );
  398.     }
  399.  
  400.     function widget($args, $instance) {
  401.         global $bp;
  402.  
  403.         extract( $args );
  404.  
  405.         echo $before_widget;
  406.         echo $before_title
  407.            . $widget_name
  408.            . $after_title; ?>
  409.  
  410.         <?php if ( bp_has_groups( 'type=active&per_page=' . $instance['max_groups'] . '&max=' . $instance['max_groups'] ) ) : ?>
  411.            
  412.  
  413.            
  414.                 <?php while ( bp_groups() ) : bp_the_group(); if(bp_get_group_name() != 'Chit Chat' && bp_get_group_name() != 'Announcements') :?>
  415.  
  416.                             <a href="<?php bp_group_permalink() ?>" title="<?php bp_group_name() ?> (<?php bp_group_member_count() ?>)"><?php bp_group_avatar_thumb() ?></a>
  417.                         <?php endif; ?>
  418.                 <?php endwhile; ?>
  419.  
  420.             <?php wp_nonce_field( 'groups_widget_groups_list', '_wpnonce-groups' ); ?>
  421.             <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo attribute_escape( $instance['max_groups'] ); ?>" />
  422.  
  423.         <?php else: ?>
  424.  
  425.             <div class="widget-error">
  426.                 <?php _e('', 'buddypress') ?>
  427.             </div>
  428.  
  429.         <?php endif; ?>
  430.  
  431.         <?php echo $after_widget; ?>
  432.     <?php
  433.     }
  434.  
  435.     function update( $new_instance, $old_instance ) {
  436.         $instance = $old_instance;
  437.         $instance['max_groups'] = strip_tags( $new_instance['max_groups'] );
  438.  
  439.         return $instance;
  440.     }
  441.  
  442.     function form( $instance ) {
  443.         $instance = wp_parse_args( (array) $instance, array( 'max_groups' => 5 ) );
  444.         $max_groups = strip_tags( $instance['max_groups'] );
  445.         ?>
  446.  
  447.         <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>
  448.     <?php
  449.     }
  450. }
  451.  
  452.  
  453.    
  454. /* ****************************************************************************************************************************
  455. * Generate FYI Topics RSS feeds for browsers that support alternate feeds in the header
  456. * ****************************************************************************************************************************
  457. */
  458. function get_fyiTopicRSSforHead() {
  459. // check to see if there's content in a topic. If so, create an alternate rss view for that topic
  460.     if (function_exists('cets_get_used_topics')){
  461.         $topics = cets_get_used_topics();
  462.         if (sizeOf($topics) >= 1){
  463.             foreach($topics as $topic) {
  464.                 echo('<link rel="alternate" type="application/rss+xml" title="' . $topic->slug . ' RSS Feed" href="/topic/' . strtolower($topic->slug) . '/feed" />');
  465.             }
  466.           }
  467.         }
  468. }
  469.  
  470. /* ****************************************************************************************************************************
  471.  * Assign class names for the body tag of certain template pages.
  472.  * ****************************************************************************************************************************
  473.  */
  474. function get_fyiBodyClass() {
  475.     global $wp_query;
  476.     // find out what page template is being called
  477.     // and set class names to be displayed in the <body> tag
  478.    
  479.     if (isset($wp_query->query_vars['topic'])) {
  480.         echo "topic twoCol";
  481.     }  
  482.     else if (isset($wp_query->query_vars['sitelist'])) {
  483.         echo "sites oneCol";
  484.     }
  485.     else if (is_home()) {
  486.         echo "home twoCol";
  487.     }
  488. }
  489.  
  490. function truncate ($str, $length=10, $trailing='...')
  491. {
  492. /*
  493. ** $str -String to truncate
  494. ** $length - length to truncate
  495. ** $trailing - the trailing character, default: "..."
  496. */
  497.    
  498.       // strip tags so we don't blow up xhtml
  499.       $str = strip_tags($str); 
  500.       // take off chars for the trailing
  501.       $length-=strlen($trailing);
  502.       $length = checkForSpace($str, $length);
  503.       if (strlen($str)> $length)
  504.       {
  505.          // string exceeded length, truncate and add trailing dots
  506.          // find next space
  507.          
  508.          return substr($str,0,$length).$trailing;
  509.       }
  510.       else
  511.       {
  512.          // string was already short enough, return the string
  513.          $res = $str;
  514.       }
  515.       return $res;
  516. }
  517.  
  518. function checkForSpace($str, $pos) {
  519.     if (substr($str, $pos, 1) == ' '){
  520.         return $pos;
  521.     }
  522.     else {
  523.         if ($pos < strlen($str)){
  524.             return checkForSpace($str, $pos + 1);
  525.         }
  526.         else {
  527.             return $pos;
  528.         }
  529.        
  530.     }
  531. }
  532.  
  533. function add_image_page() {
  534. add_theme_page('Custom Images',  'Custom Images',  'edit_themes', 'customimages', 'custom_image_utility');
  535. }
  536. add_action('admin_menu', 'add_image_page');
  537.  
  538. function custom_image_utility(){
  539. // get the topics
  540. global $cets_wpmubt;
  541.  
  542. $topics = $cets_wpmubt->get_topics();
  543. foreach ($topics as $topic) {
  544. ?>
  545. <h1>Custom Images</h1>
  546. <div class="customimage_admin">
  547. <h2>Images for <?php echo $topic->topic_name; ?> </h2>
  548. <form name="photo" enctype="multipart/form-data" action="<?php echo $_SERVER['REQUEST_URI'] ?>" method="post">
  549. Header: <input type="file" name="banner" size="50" /> <br />
  550. Thumbnail: <input type="file" name="thumbnail" size="50" />
  551. <input type="submit" name="upload" value="Upload" />
  552. </form>
  553. <hr />
  554. </div>
  555.  
  556. <?php
  557.    
  558.     } // end foreach
  559.    
  560. } // end function
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570. ?>
  571.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement