Skip to content

Commit

Permalink
Tagging 2.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenkword committed Feb 27, 2016
1 parent 4f6182d commit cf331fd
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 43 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ BuddyPress Automatic Friends
* Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DWK9EXNAHLZ42
* Tags: buddypress, plugin, admin, automatic, friends, instant friends, automatic friends, registration, new members
* Requires at least: 3.5
* Tested up to: 4.2
* Stable tag: 2.0.5
* Tested up to: 4.5
* Stable tag: 2.0.7

Automatically create and accept friendships for specified users upon new user registration. * Requires BuddyPress

Expand Down Expand Up @@ -47,6 +47,15 @@ No notices.

## Changelog ##

= 2.0.7 =

* Resolves PHP strict error when calling `get_global_friends()`
* Bumps version compatibilty for WordPress 4.5

= 2.0.6 =

* Bumps version compatibilty for WordPress 4.4.2

= 2.0.5 =

* Disables email notifications. In situations with hundreds of users, this can get SPAMMY fast
Expand Down
12 changes: 6 additions & 6 deletions bp-automatic-friends.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Plugin URI: http://www.stevenword.com/bp-automatic-friends/
Description: Automatically create and accept friendships for specified users upon new user registration. * Requires BuddyPress
Text Domain: bp-automatic-friends
Version: 2.0.5
Version: 2.0.7
Author: Steven Word
Author URI: http://stevenword.com/
License: GPLv2 or later
Expand Down Expand Up @@ -34,7 +34,7 @@
*/
class BPAF_Core {

const VERSION = '2.0.5';
const VERSION = '2.0.7';
const REVISION = '20141120';
const METAKEY = 'bpaf_global_friend';
const LEGACY_OPTION = 'skw_bpaf_options';
Expand Down Expand Up @@ -133,7 +133,7 @@ function first_login() {
*
* @return array|bool
*/
function get_global_friends() {
public static function get_global_friends() {
global $bp;

// The Query
Expand All @@ -159,7 +159,7 @@ function get_global_friends() {
* @uses get_userdata, get_option, explode, friends_add_friend, get_friend_user_ids, total_friend_count
* @return null
*/
function create_friendships( $initiator_user_id ) {
public static function create_friendships( $initiator_user_id ) {

global $bp;

Expand Down Expand Up @@ -205,7 +205,7 @@ function create_friendships( $initiator_user_id ) {
* @uses get_userdata, get_option, explode, friends_add_friend, get_friend_user_ids, total_friend_count
* @return null
*/
function destroy_friendships( $initiator_user_id ) {
public static function destroy_friendships( $initiator_user_id ) {
BP_Friends_Friendship::delete_all_for_user( $initiator_user_id );
self::update_friendship_counts( $initiator_user_id );
}
Expand All @@ -215,7 +215,7 @@ function destroy_friendships( $initiator_user_id ) {
*
* @return null
*/
function update_friendship_counts( $initiator_user_id ) {
public static function update_friendship_counts( $initiator_user_id ) {
/* Get friends of $user_id */
$friend_ids = BP_Friends_Friendship::get_friend_user_ids( $initiator_user_id );

Expand Down
66 changes: 33 additions & 33 deletions inc/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class BPAF_Admin {
/* Define and register singleton */
private static $instance = false;
public static function instance() {
if( ! self::$instance ) {
if ( ! self::$instance ) {
self::$instance = new self;
self::$instance->setup();
}
Expand Down Expand Up @@ -68,7 +68,7 @@ function setup() {
add_action( 'edit_user_profile_update', array( $this, 'action_personal_options_update' ) );

/* We don't need any of these things in other places */
if( 'users.php' != $pagenow || ! isset( $_REQUEST['page'] ) || 's8d-bpaf-settings' != $_REQUEST['page'] ) {
if ( 'users.php' != $pagenow || ! isset( $_REQUEST['page'] ) || 's8d-bpaf-settings' != $_REQUEST['page'] ) {
return;
}

Expand Down Expand Up @@ -129,9 +129,9 @@ function render_global_friend_table() {
// Legacy Support

$options = get_option( BPAF_Core::LEGACY_OPTION );
if( isset( $options[ BPAF_Core::LEGACY_OPTION . '_ids'] ) ) {
if ( isset( $options[ BPAF_Core::LEGACY_OPTION . '_ids'] ) ) {
$s8d_bpaf_user_ids = $options[ BPAF_Core::LEGACY_OPTION . '_ids'];
$friend_user_ids = explode(',', $s8d_bpaf_user_ids);
$friend_user_ids = explode( ',', $s8d_bpaf_user_ids );
}

// Modern
Expand All @@ -148,17 +148,17 @@ function render_global_friend_table() {
</tr>
</thead>
<?php
if( is_array( $friend_user_ids ) && 0 < count( $friend_user_ids ) ) {
foreach( $friend_user_ids as $i => $friend_user_id ) {
if ( is_array( $friend_user_ids ) && 0 < count( $friend_user_ids ) ) {
foreach ( $friend_user_ids as $i => $friend_user_id ) {
$friend_userdata = get_userdata( $friend_user_id );
if( $friend_userdata ) {
if ( $friend_userdata ) {
// Add a row to the table
$this->render_global_friend_table_row( $friend_user_id, $i + 2 ); // Because i%2 of i=0 and i=1 is the same
}
}// foreach
unset( $i );
} else { ?>
<tr class="bpaf-empty-table-row"><td colspan="3"><?php _e('No Global Friends found.', BPAF_Core::TEXT_DOMAIN ); ?></td></tr>;
<tr class="bpaf-empty-table-row"><td colspan="3"><?php _e( 'No Global Friends found.', BPAF_Core::TEXT_DOMAIN ); ?></td></tr>;
<?php
}
?>
Expand Down Expand Up @@ -272,7 +272,7 @@ function action_personal_options_update( $user_id ) {
}

$meta_value = isset( $_REQUEST['global-friend'] ) ? true : false;
update_usermeta( $user_id, BPAF_Core::METAKEY, $meta_value );
update_user_meta( $user_id, BPAF_Core::METAKEY, $meta_value );

// Update the friend counts
BP_Friends_Friendship::total_friend_count( $user_id );
Expand Down Expand Up @@ -301,15 +301,15 @@ function action_ajax_bpaf_suggest_global_friend() {
$users = $user_query->get_results();

$user_ids = array();
foreach( $users as $user ) {
foreach ( $users as $user ) {
$user_ids[] = array(
'ID' => $user->data->ID,
'label' => $user->data->user_login,
'display_name' => $user->data->display_name
);
}

header('Content-Type: application/x-json');
header( 'Content-Type: application/x-json' );
echo $json = json_encode( $user_ids );
die;
}
Expand All @@ -325,15 +325,15 @@ function action_ajax_bpaf_add_global_friend() {
wp_die( BPAF_Core::NONCE_FAIL_MSG );
}

if( ! isset( $_REQUEST['username'] ) && empty( $_REQUEST['username'] ) ) {
if ( ! isset( $_REQUEST['username'] ) && empty( $_REQUEST['username'] ) ) {
die;
}

// Add Global Friend status
$user = get_user_by( 'login', $_REQUEST['username'] );
if( isset( $user->data->ID ) ) {
if ( isset( $user->data->ID ) ) {
// Update the user and related friendships
update_usermeta( $user->data->ID, BPAF_Core::METAKEY, true );
update_user_meta( $user->data->ID, BPAF_Core::METAKEY, true );

// This is wrong MMMMMKay! This is looking for a newly registred user, not a global friend
bpaf_create_friendships( $user->data->ID );
Expand Down Expand Up @@ -361,24 +361,24 @@ function render_global_friend_table_row( $friend_user_id, $i = '' ) {
$friend_userdata = get_userdata( $friend_user_id );
?>
<tr <?php if( 0 == $i % 2 ) echo 'class="alternate"'; ?>>
<td class="username column-username">
<input class="bpaf-user-id" id="bpaf-user-<?php echo $friend_user_id;?>" type="hidden" value="<?php echo $friend_user_id; ?>"></input>
<?php echo get_avatar( $friend_user_id, 32 ); ?>
<strong><?php echo $friend_userdata->user_login;?></strong>
<br>
<div class="row-actions">
<span class="edit"><a href="<?php echo get_edit_user_link( $friend_user_id ); ?>" title="Edit this item"><?php _e( 'Edit', BPAF_Core::TEXT_DOMAIN );?></a> | </span>
<span id="remove-<?php echo $friend_userdata->user_login;?>" class="trash"><a class="submitdelete" title="Move this item to the Trash" href="javascript:void(0);"><?php _e( 'Remove', BPAF_Core::TEXT_DOMAIN );?></a></span>
</div>
</td>
<td class="username column-username">
<input class="bpaf-user-id" id="bpaf-user-<?php echo $friend_user_id;?>" type="hidden" value="<?php echo $friend_user_id; ?>"></input>
<?php echo get_avatar( $friend_user_id, 32 ); ?>
<strong><?php echo $friend_userdata->user_login;?></strong>
<br>
<div class="row-actions">
<span class="edit"><a href="<?php echo get_edit_user_link( $friend_user_id ); ?>" title="Edit this item"><?php _e( 'Edit', BPAF_Core::TEXT_DOMAIN );?></a> | </span>
<span id="remove-<?php echo $friend_userdata->user_login;?>" class="trash"><a class="submitdelete" title="Move this item to the Trash" href="javascript:void(0);"><?php _e( 'Remove', BPAF_Core::TEXT_DOMAIN );?></a></span>
</div>
</td>

<td class="name column-name">
<?php echo $friend_userdata->display_name;?>
</td>
<td class="name column-name">
<?php echo $friend_userdata->display_name; ?>
</td>

<td class="friends column-friends">
<?php echo BP_Friends_Friendship::total_friend_count( $friend_user_id );?>
</td>
<td class="friends column-friends">
<?php echo BP_Friends_Friendship::total_friend_count( $friend_user_id );?>
</td>
</tr>
<?php
}
Expand All @@ -394,12 +394,12 @@ function action_ajax_bpaf_delete_global_friend() {
wp_die( BPAF_Core::NONCE_FAIL_MSG );
}

if( ! isset( $_REQUEST['ID'] ) && empty( $_REQUEST['ID'] ) ) {
if ( ! isset( $_REQUEST['ID'] ) && empty( $_REQUEST['ID'] ) ) {
die;
}

// Remove Global Friend status
update_usermeta( $_REQUEST['ID'], BPAF_Core::METAKEY, false );
update_user_meta( $_REQUEST['ID'], BPAF_Core::METAKEY, false );
bpaf_destroy_friendships( $_REQUEST['ID'] );

// Return the number of friends remaning
Expand All @@ -411,4 +411,4 @@ function action_ajax_bpaf_delete_global_friend() {
}

} // Class
BPAF_Admin::instance();
BPAF_Admin::instance();
13 changes: 11 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Contributors: stevenkword
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DWK9EXNAHLZ42
Tags: buddypress, plugin, admin, automatic, friends, instant friends, automatic friends, registration, new members
Requires at least: 3.5
Tested up to: 4.2
Stable tag: 2.0.5
Tested up to: 4.5
Stable tag: 2.0.7

Automatically create and accept friendships for specified users upon new user registration. * Requires BuddyPress

Expand All @@ -20,6 +20,15 @@ Automatically create and accept friendships for specified users upon new user re

== Changelog ==

= 2.0.7 =

* Resolves PHP strict error when calling `get_global_friends()`
* Bumps version compatibilty for WordPress 4.5

= 2.0.6 =

* Bumps version compatibilty for WordPress 4.4.2

= 2.0.5 =

* Disables email notifications. In situations with hundreds of users, this can get SPAMMY fast
Expand Down

0 comments on commit cf331fd

Please sign in to comment.