Commit c7aa991d authored by lechuck's avatar lechuck Committed by lechuck

Upgrade buddypress 1.6.2

parent db767f88
.akismet-status{float:right}.akismet-status a{color:#AAA;font-style:italic}.akismet-history{margin:13px}.akismet-history div{margin-bottom:13px}.akismet-history span{color:#999}#wp-bp-activities-wrap{padding:5px 0}#bp-activities{height:120px}#bp-replyhead{font-size:1em;line-height:1.4em;margin:0}#bp-replysubmit{margin:0;padding:0 0 3px;text-align:center}#bp-replysubmit .error{color:red;line-height:21px;text-align:center;vertical-align:center}#bp-replysubmit img.waiting{float:right;padding:4px 10px 0;vertical-align:top}#bp-activities-form .column-response img{float:left;margin-right:10px;margin-top:1px}.activity-errors{list-style-type:disc;margin-left:2em}#bp_activity_action div.inside,#bp_activity_content div.inside{line-height:0}#bp_activity_action h3,#bp_activity_content h3{cursor:auto}#bp_activity_action td.mceIframeContainer,#bp_activity_content td.mceIframeContainer{background-color:white}#post-body #bp-activities-action_resize,#post-body #bp-activities-content_resize{position:inherit;margin-top:-2px}#bp_activity_link input{width:99%}#bp-activities-primaryid{margin-bottom:1em}
\ No newline at end of file
.akismet-status {
float: right;
}
.akismet-status a {
color: #AAA;
font-style: italic;
}
.akismet-history {
margin: 13px;
}
.akismet-history div {
margin-bottom: 13px;
}
.akismet-history span {
color: #999;
}
#wp-bp-activities-wrap {
padding: 5px 0;
}
#bp-activities {
height: 120px;
}
#bp-replyhead {
font-size: 1em;
line-height: 1.4em;
margin: 0;
}
#bp-replysubmit {
margin: 0;
padding: 0 0 3px;
text-align: center;
}
#bp-replysubmit .error {
color: red;
line-height: 21px;
text-align: center;
vertical-align: center;
}
#bp-replysubmit img.waiting {
float: right;
padding: 4px 10px 0;
vertical-align: top;
}
#bp-activities-form .column-response img {
float: left;
margin-right: 10px;
margin-top: 1px;
}
.activity-errors {
list-style-type: disc;
margin-left: 2em;
}
#bp_activity_action div.inside,
#bp_activity_content div.inside {
line-height: 0;
}
#bp_activity_action h3,
#bp_activity_content h3 {
cursor: auto;
}
#bp_activity_action td.mceIframeContainer,
#bp_activity_content td.mceIframeContainer {
background-color: white;
}
#post-body #bp-activities-action_resize,
#post-body #bp-activities-content_resize {
position: inherit;
margin-top: -2px;
}
#bp_activity_link input {
width: 99%;
}
#bp-activities-primaryid {
margin-bottom: 1em;
}
\ No newline at end of file
(function( $ ) {
/**
* Activity reply object for the activity index screen
*
* @since 1.6
*/
var activityReply = {
/**
* Attach event handler functions to the relevant elements.
*
* @since 1.6
*/
init : function() {
$(document).on( 'click', '.row-actions a.reply', activityReply.open );
$(document).on( 'click', '#bp-activities-container a.cancel', activityReply.close );
$(document).on( 'click', '#bp-activities-container a.save', activityReply.send );
// Close textarea on escape
$(document).on( 'keyup', '#bp-activities:visible', function( e ) {
if ( 27 == e.which ) {
activityReply.close();
}
});
},
/**
* Reveals the entire row when "reply" is pressed.
*
* @since 1.6
*/
open : function( e ) {
// Hide the container row, and move it to the new location
var box = $( '#bp-activities-container' ).hide();
$( this ).parents( 'tr' ).after( box );
// Fade the whole row in, and set focus on the text area.
box.fadeIn( '300' );
$( '#bp-activities' ).focus();
return false;
},
/**
* Hide and reset the entire row when "cancel", or escape, are pressed.
*
* @since 1.6
*/
close : function( e ) {
// Hide the container row
$('#bp-activities-container').fadeOut( '200', function () {
// Empty and unfocus the text area
$( '#bp-activities' ).val( '' ).blur();
// Remove any error message and disable the spinner
$( '#bp-replysubmit .error' ).html( '' ).hide();
$( '#bp-replysubmit .waiting' ).hide();
});
return false;
},
/**
* Submits "form" via AJAX back to WordPress.
*
* @since 1.6
*/
send : function( e ) {
// Hide any existing error message, and show the loading spinner
$( '#bp-replysubmit .error' ).hide();
$( '#bp-replysubmit .waiting' ).show();
// Grab the nonce
var reply = {};
reply['_ajax_nonce-bp-activity-admin-reply'] = $( '#bp-activities-container input[name="_ajax_nonce-bp-activity-admin-reply"]' ).val();
// Get the rest of the data
reply.action = 'bp-activity-admin-reply';
reply.content = $( '#bp-activities' ).val();
reply.parent_id = $( '#bp-activities-container' ).prev().data( 'parent_id' );
reply.root_id = $( '#bp-activities-container' ).prev().data( 'root_id' );
// Make the AJAX call
$.ajax({
data : reply,
type : 'POST',
url : ajaxurl,
// Callbacks
error : function( r ) { activityReply.error( r ); },
success : function( r ) { activityReply.show( r ); }
});
return false;
},
/**
* send() error message handler
*
* @since 1.6
*/
error : function( r ) {
var er = r.statusText;
$('#bp-replysubmit .waiting').hide();
if ( r.responseText ) {
er = r.responseText.replace( /<.[^<>]*?>/g, '' );
}
if ( er ) {
$('#bp-replysubmit .error').html( er ).show();
}
},
/**
* send() success handler
*
* @since 1.6
*/
show : function ( xml ) {
var bg, id, response;
// Handle any errors in the response
if ( typeof( xml ) == 'string' ) {
activityReply.error( { 'responseText': xml } );
return false;
}
response = wpAjax.parseAjaxResponse( xml );
if ( response.errors ) {
activityReply.error( { 'responseText': wpAjax.broken } );
return false;
}
response = response.responses[0];
// Close and reset the reply row, and add the new Activity item into the list.
$('#bp-activities-container').fadeOut( '200', function () {
// Empty and unfocus the text area
$( '#bp-activities' ).val( '' ).blur();
// Remove any error message and disable the spinner
$( '#bp-replysubmit .error' ).html( '' ).hide();
$( '#bp-replysubmit .waiting' ).hide();
// Insert new activity item
$( '#bp-activities-container' ).before( response.data );
// Get background colour and animate the flash
id = $( '#activity-' + response.id );
bg = id.closest( '.widefat' ).css( 'backgroundColor' );
id.animate( { 'backgroundColor': '#CEB' }, 300 ).animate( { 'backgroundColor': bg }, 300 );
});
}
};
$(document).ready( function () {
// Create the Activity reply object after domready event
activityReply.init();
// On the edit screen, unload the close/open toggle js for the action & content metaboxes
$( '#bp_activity_action h3, #bp_activity_content h3' ).unbind( 'click' );
});
})(jQuery);
\ No newline at end of file
(function(b){var a={init:function(){b(document).on("click",".row-actions a.reply",a.open);b(document).on("click","#bp-activities-container a.cancel",a.close);b(document).on("click","#bp-activities-container a.save",a.send);b(document).on("keyup","#bp-activities:visible",function(c){if(27==c.which){a.close()}})},open:function(d){var c=b("#bp-activities-container").hide();b(this).parents("tr").after(c);c.fadeIn("300");b("#bp-activities").focus();return false},close:function(c){b("#bp-activities-container").fadeOut("200",function(){b("#bp-activities").val("").blur();b("#bp-replysubmit .error").html("").hide();b("#bp-replysubmit .waiting").hide()});return false},send:function(d){b("#bp-replysubmit .error").hide();b("#bp-replysubmit .waiting").show();var c={};c["_ajax_nonce-bp-activity-admin-reply"]=b('#bp-activities-container input[name="_ajax_nonce-bp-activity-admin-reply"]').val();c.action="bp-activity-admin-reply";c.content=b("#bp-activities").val();c.parent_id=b("#bp-activities-container").prev().data("parent_id");c.root_id=b("#bp-activities-container").prev().data("root_id");b.ajax({data:c,type:"POST",url:ajaxurl,error:function(e){a.error(e)},success:function(e){a.show(e)}});return false},error:function(c){var d=c.statusText;b("#bp-replysubmit .waiting").hide();if(c.responseText){d=c.responseText.replace(/<.[^<>]*?>/g,"")}if(d){b("#bp-replysubmit .error").html(d).show()}},show:function(d){var e,f,c;if(typeof(d)=="string"){a.error({responseText:d});return false}c=wpAjax.parseAjaxResponse(d);if(c.errors){a.error({responseText:wpAjax.broken});return false}c=c.responses[0];b("#bp-activities-container").fadeOut("200",function(){b("#bp-activities").val("").blur();b("#bp-replysubmit .error").html("").hide();b("#bp-replysubmit .waiting").hide();b("#bp-activities-container").before(c.data);f=b("#activity-"+c.id);e=f.closest(".widefat").css("backgroundColor");f.animate({backgroundColor:"#CEB"},300).animate({backgroundColor:e},300)})}};b(document).ready(function(){a.init();b("#bp_activity_action h3, #bp_activity_content h3").unbind("click")})})(jQuery);
\ No newline at end of file
......@@ -15,7 +15,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
/**
* Allow core components and dependent plugins to register activity actions
*
* @since 1.2.0
* @since BuddyPress (1.2)
*
* @uses do_action() To call 'bp_register_activity_actions' hook.
*/
......@@ -27,7 +27,7 @@ add_action( 'bp_init', 'bp_register_activity_actions', 8 );
/**
* Allow core components and dependent plugins to register activity actions
*
* @since 1.2.0
* @since BuddyPress (1.2)
*
* @global object $bp BuddyPress global settings
* @uses bp_is_activity_component()
......@@ -88,7 +88,14 @@ function bp_activity_action_permalink_router() {
// Set redirect to users' activity stream
} else {
$redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id;
$redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id . '/';
}
// If set, add the original query string back onto the redirect URL
if ( !empty( $_SERVER['QUERY_STRING'] ) ) {
$query_frags = array();
wp_parse_str( $_SERVER['QUERY_STRING'], $query_frags );
$redirect = add_query_arg( urlencode_deep( $query_frags ), $redirect );
}
// Allow redirect to be filtered
......@@ -103,11 +110,10 @@ add_action( 'bp_actions', 'bp_activity_action_permalink_router' );
/**
* Delete specific activity item and redirect to previous page.
*
* @since 1.1.0
* @since BuddyPress (1.1)
*
* @param int $activity_id Activity id to be deleted. Defaults to 0.
*
* @global object $bp BuddyPress global settings
* @uses bp_is_activity_component()
* @uses bp_is_current_action()
* @uses bp_action_variable()
......@@ -122,7 +128,6 @@ add_action( 'bp_actions', 'bp_activity_action_permalink_router' );
* @return bool False on failure
*/
function bp_activity_action_delete_activity( $activity_id = 0 ) {
global $bp;
// Not viewing activity or action is not delete
if ( !bp_is_activity_component() || !bp_is_current_action( 'delete' ) )
......@@ -164,12 +169,65 @@ function bp_activity_action_delete_activity( $activity_id = 0 ) {
}
add_action( 'bp_actions', 'bp_activity_action_delete_activity' );
/**
* Mark specific activity item as spam and redirect to previous page
*
* @global object $bp BuddyPress global settings
* @param int $activity_id Activity id to be deleted. Defaults to 0.
* @return bool False on failure
* @since 1.6
*/
function bp_activity_action_spam_activity( $activity_id = 0 ) {
global $bp;
// Not viewing activity, or action is not spam, or Akismet isn't present
if ( !bp_is_activity_component() || !bp_is_current_action( 'spam' ) || empty( $bp->activity->akismet ) )
return false;
if ( empty( $activity_id ) && bp_action_variable( 0 ) )
$activity_id = (int) bp_action_variable( 0 );
// Not viewing a specific activity item
if ( empty( $activity_id ) )
return false;
// Is the current user allowed to spam items?
if ( !bp_activity_user_can_mark_spam() )
return false;
// Load up the activity item
$activity = new BP_Activity_Activity( $activity_id );
if ( empty( $activity->id ) )
return false;
// Check nonce
check_admin_referer( 'bp_activity_akismet_spam_' . $activity->id );
// Call an action before the spamming so plugins can modify things if they want to
do_action( 'bp_activity_before_action_spam_activity', $activity->id, $activity );
// Mark as spam
bp_activity_mark_as_spam( $activity );
$activity->save();
// Tell the user the spamming has been succesful
bp_core_add_message( __( 'The activity item has been marked as spam and is no longer visible.', 'buddypress' ) );
do_action( 'bp_activity_action_spam_activity', $activity_id, $activity->user_id );
// Check for the redirect query arg, otherwise let WP handle things
if ( !empty( $_GET['redirect_to'] ) )
bp_core_redirect( esc_url( $_GET['redirect_to'] ) );
else
bp_core_redirect( wp_get_referer() );
}
add_action( 'bp_actions', 'bp_activity_action_spam_activity' );
/**
* Post user/group activity update.
*
* @since 1.2.0
* @since BuddyPress (1.2)
*
* @global object $bp BuddyPress global settings
* @uses is_user_logged_in()
* @uses bp_is_activity_component()
* @uses bp_is_current_action()
......@@ -187,7 +245,6 @@ add_action( 'bp_actions', 'bp_activity_action_delete_activity' );
* @return bool False on failure
*/
function bp_activity_action_post_update() {
global $bp;
// Do not proceed if user is not logged in, not viewing activity, or not posting
if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'post' ) )
......@@ -213,7 +270,7 @@ function bp_activity_action_post_update() {
// Post to groups object
} else if ( 'groups' == $object && bp_is_active( 'groups' ) ) {
if ( (int)$item_id ) {
if ( (int) $item_id ) {
$activity_id = groups_post_update( array( 'content' => $content, 'group_id' => $item_id ) );
}
......@@ -236,9 +293,8 @@ add_action( 'bp_actions', 'bp_activity_action_post_update' );
/**
* Post new activity comment.
*
* @since 1.2.0
* @since BuddyPress (1.2)
*
* @global object $bp BuddyPress global settings
* @uses is_user_logged_in()
* @uses bp_is_activity_component()
* @uses bp_is_current_action()
......@@ -253,9 +309,8 @@ add_action( 'bp_actions', 'bp_activity_action_post_update' );
* @return bool False on failure
*/
function bp_activity_action_post_comment() {
global $bp;
if ( !is_user_logged_in() || ( bp_is_activity_component() ) || !bp_is_current_action( 'reply' ) )
if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'reply' ) )
return false;
// Check the nonce
......@@ -287,9 +342,8 @@ add_action( 'bp_actions', 'bp_activity_action_post_comment' );
/**
* Mark activity as favorite.
*
* @since 1.2.0
* @since BuddyPress (1.2)
*
* @global object $bp BuddyPress global settings
* @uses is_user_logged_in()
* @uses bp_is_activity_component()
* @uses bp_is_current_action()
......@@ -303,9 +357,8 @@ add_action( 'bp_actions', 'bp_activity_action_post_comment' );
* @return bool False on failure
*/
function bp_activity_action_mark_favorite() {
global $bp;
if ( !is_user_logged_in() || ( bp_is_activity_component() ) || !bp_is_current_action( 'favorite' ) )
if ( !is_user_logged_in() || !bp_is_activity_component() || !bp_is_current_action( 'favorite' ) )
return false;
// Check the nonce
......@@ -323,9 +376,8 @@ add_action( 'bp_actions', 'bp_activity_action_mark_favorite' );
/**
* Remove activity from favorites.
*
* @since 1.2.0
* @since BuddyPress (1.2)
*
* @global object $bp BuddyPress global settings
* @uses is_user_logged_in()
* @uses bp_is_activity_component()
* @uses bp_is_current_action()
......@@ -339,9 +391,8 @@ add_action( 'bp_actions', 'bp_activity_action_mark_favorite' );
* @return bool False on failure
*/
function bp_activity_action_remove_favorite() {
global $bp;
if ( !is_user_logged_in() || ( bp_is_activity_component() ) || !bp_is_current_action( 'unfavorite' ) )
if ( ! is_user_logged_in() || ! bp_is_activity_component() || ! bp_is_current_action( 'unfavorite' ) )
return false;
// Check the nonce
......@@ -359,7 +410,7 @@ add_action( 'bp_actions', 'bp_activity_action_remove_favorite' );
/**
* Load the sitewide feed.
*
* @since 1.0.0
* @since BuddyPress (1.0)
*
* @global object $bp BuddyPress global settings
* @global object $wp_query
......@@ -387,9 +438,8 @@ add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
/**
* Load a user's personal feed.
*
* @since 1.0.0
* @since BuddyPress (1.0)
*
* @global object $bp BuddyPress global settings
* @global object $wp_query
* @uses bp_is_user_activity()
* @uses bp_is_current_action()
......@@ -398,7 +448,7 @@ add_action( 'bp_actions', 'bp_activity_action_sitewide_feed' );
* @return bool False on failure
*/
function bp_activity_action_personal_feed() {
global $bp, $wp_query;
global $wp_query;
if ( !bp_is_user_activity() || !bp_is_current_action( 'feed' ) )
return false;
......@@ -414,9 +464,8 @@ add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
/**
* Load a user's friends feed.
*
* @since 1.0.0
* @since BuddyPress (1.0)
*
* @global object $bp BuddyPress global settings
* @global object $wp_query
* @uses bp_is_active()
* @uses bp_is_user_activity()
......@@ -428,7 +477,7 @@ add_action( 'bp_actions', 'bp_activity_action_personal_feed' );
* @return bool False on failure
*/
function bp_activity_action_friends_feed() {
global $bp, $wp_query;
global $wp_query;
if ( !bp_is_active( 'friends' ) || !bp_is_user_activity() || !bp_is_current_action( bp_get_friends_slug() ) || !bp_is_action_variable( 'feed', 0 ) )
return false;
......@@ -444,9 +493,8 @@ add_action( 'bp_actions', 'bp_activity_action_friends_feed' );
/**
* Load a user's my groups feed.
*
* @since 1.2.0
* @since BuddyPress (1.2)
*
* @global object $bp BuddyPress global settings
* @global object $wp_query