| [ Index ] |
PHP Cross Reference of BuddyPress SVN Code |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* Define the slug for the component */ 4 if ( !defined( 'BP_WIRE_SLUG' ) ) 5 define ( 'BP_WIRE_SLUG', 'wire' ); 6 7 require ( BP_PLUGIN_DIR . '/bp-wire/bp-wire-classes.php' ); 8 require ( BP_PLUGIN_DIR . '/bp-wire/bp-wire-templatetags.php' ); 9 require ( BP_PLUGIN_DIR . '/bp-wire/bp-wire-filters.php' ); 10 11 /* Include deprecated functions if settings allow */ 12 if ( !defined( 'BP_IGNORE_DEPRECATED' ) ) 13 require ( BP_PLUGIN_DIR . '/bp-wire/deprecated/bp-wire-deprecated.php' ); 14 15 function bp_wire_install() { 16 // Tables are installed on a per component basis, where needed. 17 } 18 19 function bp_wire_setup_globals() { 20 global $bp, $wpdb; 21 22 $bp->wire->image_base = BP_PLUGIN_URL . '/bp-wire/images'; 23 $bp->wire->slug = BP_WIRE_SLUG; 24 25 $bp->version_numbers->wire = BP_WIRE_VERSION; 26 } 27 add_action( 'plugins_loaded', 'bp_wire_setup_globals', 5 ); 28 add_action( 'admin_menu', 'bp_wire_setup_globals', 1 ); 29 30 function bp_wire_setup_nav() { 31 global $bp; 32 33 /* Add 'Wire' to the main navigation */ 34 bp_core_new_nav_item( array( 'name' => __('Wire', 'buddypress'), 'slug' => $bp->wire->slug, 'position' => 40, 'screen_function' => 'bp_wire_screen_latest', 'default_subnav_slug' => 'all-posts', '' ) ); 35 36 $wire_link = $bp->loggedin_user->domain . $bp->wire->slug . '/'; 37 38 /* Add the subnav items to the wire nav */ 39 bp_core_new_subnav_item( array( 'name' => __( 'All Posts', 'buddypress' ), 'slug' => 'all-posts', 'parent_url' => $wire_link, 'parent_slug' => $bp->wire->slug, 'screen_function' => 'bp_wire_screen_latest', 'position' => 10 ) ); 40 41 if ( $bp->current_component == $bp->wire->slug ) { 42 if ( bp_is_home() ) { 43 $bp->bp_options_title = __('My Wire', 'buddypress'); 44 } else { 45 $bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) ); 46 $bp->bp_options_title = $bp->displayed_user->fullname; 47 } 48 } 49 50 do_action( 'bp_wire_setup_nav' ); 51 } 52 add_action( 'wp', 'bp_wire_setup_nav', 2 ); 53 add_action( 'admin_menu', 'bp_wire_setup_nav', 2 ); 54 55 56 /******************************************************************************** 57 * Screen Functions 58 * 59 * Screen functions are the controllers of BuddyPress. They will execute when their 60 * specific URL is caught. They will first save or manipulate data using business 61 * functions, then pass on the user to a template file. 62 */ 63 64 function bp_wire_screen_latest() { 65 do_action( 'bp_wire_screen_latest' ); 66 bp_core_load_template( apply_filters( 'bp_wire_template_latest', 'wire/latest' ) ); 67 } 68 69 70 /******************************************************************************** 71 * Activity & Notification Functions 72 * 73 * These functions handle the recording, deleting and formatting of activity and 74 * notifications for the user and for this specific component. 75 */ 76 77 function bp_wire_record_activity( $args = true ) { 78 if ( function_exists('bp_activity_record') ) { 79 extract($args); 80 81 bp_activity_record( $item_id, $component_name, $component_action, $is_private, $secondary_item_id, $user_id, $secondary_user_id ); 82 } 83 } 84 85 function bp_wire_delete_activity( $args = true ) { 86 if ( function_exists('bp_activity_delete') ) { 87 extract($args); 88 bp_activity_delete( $item_id, $component_name, $component_action, $user_id, $secondary_item_id ); 89 } 90 } 91 92 93 /******************************************************************************** 94 * Business Functions 95 * 96 * Business functions are where all the magic happens in BuddyPress. They will 97 * handle the actual saving or manipulation of information. Usually they will 98 * hand off to a database class for data access, then return 99 * true or false on success or failure. 100 */ 101 102 function bp_wire_new_post( $item_id, $message, $component_name, $deprecated = false, $table_name = null ) { 103 global $bp; 104 105 if ( empty($message) || !is_user_logged_in() ) 106 return false; 107 108 if ( !$table_name ) 109 $table_name = $bp->{$component_name}->table_name_wire; 110 111 $wire_post = new BP_Wire_Post( $table_name ); 112 $wire_post->item_id = $item_id; 113 $wire_post->user_id = $bp->loggedin_user->id; 114 $wire_post->date_posted = time(); 115 116 $allowed_tags = apply_filters( 'bp_wire_post_allowed_tags', '<a><b><strong><i><em><img>' ); 117 118 $message = strip_tags( $message, $allowed_tags ); 119 $wire_post->content = apply_filters( 'bp_wire_post_content', $message ); 120 121 if ( !$wire_post->save() ) 122 return false; 123 124 do_action( 'bp_wire_post_posted', $wire_post->id, $wire_post->item_id, $wire_post->user_id ); 125 126 return $wire_post->id; 127 } 128 129 function bp_wire_delete_post( $wire_post_id, $component_name, $table_name = null ) { 130 global $bp; 131 132 if ( !is_user_logged_in() ) 133 return false; 134 135 if ( !$table_name ) 136 $table_name = $bp->{$component_name}->table_name_wire; 137 138 $wire_post = new BP_Wire_Post( $table_name, $wire_post_id ); 139 140 if ( !is_site_admin() ) { 141 if ( !$bp->is_item_admin ) { 142 if ( $wire_post->user_id != $bp->loggedin_user->id ) 143 return false; 144 } 145 } 146 147 if ( !$wire_post->delete() ) 148 return false; 149 150 do_action( 'bp_wire_post_deleted', $wire_post->id, $wire_post->item_id, $wire_post->user_id ); 151 152 return true; 153 } 154 155 // List actions to clear super cached pages on, if super cache is installed 156 add_action( 'bp_wire_post_deleted', 'bp_core_clear_cache' ); 157 add_action( 'bp_wire_post_posted', 'bp_core_clear_cache' ); 158 159 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat Aug 22 14:49:03 2009 | Cross-referenced by PHPXref 0.7 Thanks to |