function bplike_activity_update_button() { $liked_count = 0; if (is_user_logged_in() && bp_get_activity_type() !== 'activity_liked') { if (bp_activity_get_meta(bp_get_activity_id(), 'liked_count', true)) { $users_who_like = array_keys(bp_activity_get_meta(bp_get_activity_id(), 'liked_count', true)); $liked_count = count($users_who_like); } if (!bp_like_is_liked(bp_get_activity_id(), 'activity_update', get_current_user_id())) { ?> <a href="#" class="button bp-primary-action like" id="like-activity-<?php echo bp_get_activity_id(); ?> " title="<?php echo bp_like_get_text('like_this_item'); ?> "> <?php echo bp_like_get_text('like'); if ($liked_count) { echo ' <span>' . $liked_count . '</span>'; } ?> </a> <?php } else { ?> <a href="#" class="button bp-primary-action unlike" id="unlike-activity-<?php echo bp_get_activity_id(); ?> " title="<?php echo bp_like_get_text('unlike_this_item'); ?> "> <?php echo bp_like_get_text('unlike'); if ($liked_count) { echo '<span>' . $liked_count . '</span>'; } ?> </a> <?php } // Checking if there are users who like item. if (isset($users_who_like)) { view_who_likes(bp_get_activity_id(), 'activity_update'); } } }
/** * bp_like_post_to_stream() * * Posts to stream, depending on settings * * TODO, Should we be posted that people like comments to the feed? This can get messy.. * Also no point having 20 posts saying people liked the same status.. * */ function bp_like_post_to_stream($item_id, $user_id) { if (bp_like_get_settings('post_to_activity_stream') == 1) { $activity = bp_activity_get_specific(array('activity_ids' => $item_id, 'component' => 'buddypress-like')); $author_id = $activity['activities'][0]->user_id; if ($user_id == $author_id) { $action = bp_like_get_text('record_activity_likes_own'); } elseif ($user_id == 0) { $action = bp_like_get_text('record_activity_likes_an'); } else { $action = bp_like_get_text('record_activity_likes_users'); } $liker = bp_core_get_userlink($user_id); $author = bp_core_get_userlink($author_id); $activity_url = bp_activity_get_permalink($item_id); $content = ''; //content must be defined... /* Grab the content and make it into an excerpt of 140 chars if we're allowed */ if (bp_like_get_settings('show_excerpt') == 1) { $content = $activity['activities'][0]->content; if (strlen($content) > bp_like_get_settings('excerpt_length')) { $content = substr($content, 0, bp_like_get_settings('excerpt_length')); $content = strip_tags($content); $content = $content . '...'; } } /* Filter out the placeholders */ $action = str_replace('%user%', $liker, $action); $action = str_replace('%permalink%', $activity_url, $action); $action = str_replace('%author%', $author, $action); bp_activity_add(array('action' => $action, 'content' => $content, 'primary_link' => $activity_url, 'component' => 'bp-like', 'type' => 'activity_liked', 'user_id' => $user_id, 'item_id' => $item_id)); } }
function bplike_blog_post_button($content) { $liked_count = 0; if (is_user_logged_in()) { if (get_post_meta(get_the_ID(), 'liked_count', true)) { $users_who_like = array_keys(get_post_meta(get_the_ID(), 'liked_count', true)); $liked_count = count($users_who_like); // print_r($users_who_like); } ob_start(); if (!bp_like_is_liked(get_the_ID(), 'blog_post', get_current_user_id())) { ?> <a href="#" class="blogpost like" id="like-blogpost-<?php echo get_the_ID(); ?> " title="<?php echo bp_like_get_text('like_this_item'); ?> "> <?php echo bp_like_get_text('like'); if ($liked_count) { echo ' <span>' . $liked_count . '</span>'; } ?> </a> <?php } else { ?> <a href="#" class="blogpost unlike" id="unlike-blogpost-<?php echo get_the_ID(); ?> " title="<?php echo bp_like_get_text('unlike_this_item'); ?> "> <?php echo bp_like_get_text('unlike'); if ($liked_count) { echo '<span>' . $liked_count . '</span>'; } ?> </a> <?php } if (isset($users_who_like)) { view_who_likes('blog_post'); // may need to add params here } $content .= ob_get_clean(); } return $content; }
/** * bp_like_insert_head() * * Includes JavaScript variables needed in the <head>. * */ function bp_like_insert_head() { // Only load if the user is logged in and if they aren't in the dashboard if (!is_user_logged_in() && !is_admin()) { return; } ?> <script type="text/javascript"> /* <![CDATA[ */ var bp_like_terms_like = '<?php echo bp_like_get_text('like'); ?> '; var bp_like_terms_like_message = '<?php echo bp_like_get_text('like_this_item'); ?> '; var bp_like_terms_unlike_message = '<?php echo bp_like_get_text('unlike_this_item'); ?> '; var bp_like_terms_view_likes = '<?php echo bp_like_get_text('view_likes'); ?> '; var bp_like_terms_hide_likes = '<?php echo bp_like_get_text('hide_likes'); ?> '; var bp_like_terms_unlike_1 = '<?php echo bp_like_get_text('unlike'); ?> (1)'; /* ]]> */ <?php if (bp_like_get_settings('remove_fav_button') == 1) { ?> jQuery(document).ready(function($) { jQuery(".fav").remove(); jQuery(".unfav").remove(); }); <?php } ?> </script> <?php }
/** * bp_like_insert_head() * * Includes JavaScript variables needed in the <head>. * */ function bp_like_insert_head() { ?> <script type="text/javascript"> /* <![CDATA[ */ var bp_like_terms_like = '<?php echo bp_like_get_text('like'); ?> '; var bp_like_terms_like_message = '<?php echo bp_like_get_text('like_this_item'); ?> '; var bp_like_terms_unlike_message = '<?php echo bp_like_get_text('unlike_this_item'); ?> '; var bp_like_terms_view_likes = '<?php echo bp_like_get_text('view_likes'); ?> '; var bp_like_terms_hide_likes = '<?php echo bp_like_get_text('hide_likes'); ?> '; var bp_like_terms_unlike_1 = '<?php echo bp_like_get_text('unlike'); ?> (1)'; /* ]]> */ <?php if (bp_like_get_settings('remove_fav_button') == 1) { ?> jQuery(document).ready(function($) { jQuery(".fav").remove(); jQuery(".unfav").remove(); }); <?php } ?> </script> <?php }
function bplike_blog_button() { global $post; if (!$id && is_single()) { $id = $post->ID; } if (is_user_logged_in() && get_post_meta($id, 'liked_count', true)) { $liked_count = count(get_post_meta($id, 'liked_count', true)); } if (!bp_like_is_liked($id, 'blogpost')) { ?> <div class="like-box"><a href="#" class="like_blogpost" id="like-blogpost-<?php echo $id; ?> " title="<?php echo bp_like_get_text('like_this_item'); ?> "><?php echo bp_like_get_text('like'); if ($liked_count) { echo ' (' . $liked_count . ')'; } ?> </a></div> <?php } else { ?> <div class="like-box"><a href="#" class="unlike_blogpost" id="unlike-blogpost-<?php echo $id; ?> " title="<?php echo bp_like_get_text('unlike_this_item'); ?> "><?php echo bp_like_get_text('unlike'); if ($liked_count) { echo ' (' . $liked_count . ')'; } ?> </a></div> <?php } }
function bplike_activity_comment_button() { $liked_count = 0; if (is_user_logged_in()) { if (bp_activity_get_meta(bp_get_activity_comment_id(), 'liked_count', true)) { $users_who_like = array_keys(bp_activity_get_meta(bp_get_activity_comment_id(), 'liked_count', true)); $liked_count = count($users_who_like); } if (!bp_like_is_liked(bp_get_activity_comment_id(), 'activity_comment', get_current_user_id())) { ?> <a href="#" class="acomment-reply bp-primary-action like" id="like-activity-<?php echo bp_get_activity_comment_id(); ?> " title="<?php echo bp_like_get_text('like_this_item'); ?> "><?php echo bp_like_get_text('like'); if ($liked_count) { echo ' <span><small>' . $liked_count . '</small></span>'; } ?> </a> <?php } else { ?> <a href="#" class="acomment-reply bp-primary-action unlike" id="unlike-activity-<?php echo bp_get_activity_comment_id(); ?> " title="<?php echo bp_like_get_text('unlike_this_item'); ?> "><?php echo bp_like_get_text('unlike'); if ($liked_count) { echo ' <span><small>' . $liked_count . '</small></span>'; } ?> </a> <?php } } }
/** * bp_like_get_likes() * * Outputs a list of users who have liked a given item. * */ function bp_like_get_likes($item_id = '', $type = '', $user_id = '') { global $bp; if (!$type || !$item_id) { return false; } if (!$user_id) { $user_id = $bp->loggedin_user->id; } if ($type == 'activity') { /* Grab some core data we will need later on, specific to activities */ $users_who_like = array_keys(bp_activity_get_meta($item_id, 'liked_count')); $liked_count = count(bp_activity_get_meta($item_id, 'liked_count')); $output = ''; /* Intercept any messages if nobody likes it, just incase the button was clicked when it shouldn't be */ if ($liked_count == 0) { $output .= bp_like_get_text('get_likes_no_likes'); } elseif (bp_like_get_settings('likers_visibility') == 'show_all') { /* Settings say we should show their name. */ if (bp_like_get_settings('name_or_avatar') == 'name') { /* Current user likes it too, remove them from the liked count and output appropriate message */ if (bp_like_is_liked($item_id, 'activity', $user_id)) { // remove current user from liked count. $liked_count = $liked_count - 1; if ($liked_count == 1) { //only current user and 1 other person likes this. $output .= bp_like_get_text('get_likes_you_and_singular'); $other = $users_who_like[count($users_who_like)]; $output .= 'You and ' . bp_core_get_userlink($other) . ' liked this.'; } elseif ($liked_count == 0) { //current user is the only person to like this. $output .= bp_like_get_text('get_likes_only_liker'); } else { $output .= bp_like_get_text('get_likes_you_and_plural'); } } else { if ($liked_count == 1) { $output .= bp_like_get_text('get_likes_count_people_singular'); } else { $output .= bp_like_get_text('get_likes_count_people_plural'); } } /* Now output the name of each person who has liked it (except the current user obviously) */ foreach ($users_who_like as $id) { if ($id != $user_id) { $output .= ' · <a href="' . bp_core_get_user_domain($id) . '" title="' . bp_core_get_user_displayname($id) . '">' . bp_core_get_user_displayname($id) . '</a>'; } } } elseif (bp_like_get_settings('name_or_avatar') == 'avatar') { /* Output the avatar of each person who has liked it. */ foreach ($users_who_like as $id) { $output .= '<a href="' . bp_core_get_user_domain($id) . '" title="' . bp_core_get_user_displayname($id) . '">' . bp_core_fetch_avatar(array('item_id' => $id, 'object' => 'user', 'type' => 'thumb', 'width' => 30, 'height' => 30)) . '</a> '; } } } elseif (bp_like_get_settings('likers_visibility') == 'friends_names_others_numbers' && bp_is_active('friends')) { /* Grab some information about their friends. */ $users_friends = friends_get_friend_user_ids($user_id); if (!empty($users_friends)) { $friends_who_like = array_intersect($users_who_like, $users_friends); } /* Current user likes it, so reduce the liked count by 1, to get the number of other people who like it. */ if (bp_like_is_liked($item_id, 'activity', $user_id)) { $liked_count = $liked_count - 1; } /* Settings say we should show their names. */ if (bp_like_get_settings('name_or_avatar') == 'name') { /* Current user likes it too, tell them. */ if (bp_like_is_liked($item_id, 'activity', $user_id)) { $output .= 'You '; } /* Output the name of each friend who has liked it. */ foreach ($users_who_like as $id) { if (in_array($id, $friends_who_like)) { //$output .= ' · <a href="' . bp_core_get_user_domain( $id ) . '" title="' . bp_core_get_user_displayname( $id ) . '">' . bp_core_get_user_displayname( $id ) . '</a> '; $output .= bp_core_get_userlink($id); $liked_count = $liked_count - 1; } } /* If non-friends like it, say so. */ if ($liked_count == 1) { $output .= bp_like_get_text('get_likes_and_people_singular'); } elseif ($liked_count > 1) { $output .= bp_like_get_text('get_likes_and_people_plural'); } else { $output .= bp_like_get_text('get_likes_like_this'); } } elseif (bp_like_get_settings('name_or_avatar') == 'avatar') { /* Output the avatar of each friend who has liked it, as well as the current users' if they have. */ if (!empty($friends_who_like)) { foreach ($users_who_like as $id) { if ($id == $user_id || in_array($id, $friends_who_like)) { $user_info = get_userdata($id); $output .= '<a href="' . bp_core_get_user_domain($id) . '" title="' . bp_core_get_user_displayname($id) . '">' . get_avatar($user_info->user_email, 30) . '</a> '; } } } } elseif (bp_like_get_settings('likers_visibility') == 'friends_names_others_numbers' && !bp_is_active('friends') || bp_like_get_settings('likers_visibility') == 'just_numbers') { /* Current user likes it too, remove them from the liked count and output appropriate message */ if (bp_like_is_liked($item_id, 'activity', $user_id)) { $liked_count = $liked_count - 1; if ($liked_count == 1) { $output .= bp_like_get_text('get_likes_you_and_singular'); } elseif ($liked_count == 0) { $output .= bp_like_get_text('get_likes_only_liker'); } else { $output .= bp_like_get_text('get_likes_you_and_plural'); } } else { if ($liked_count == 1) { $output .= bp_like_get_text('get_likes_count_people_singular'); } else { $output .= bp_like_get_text('get_likes_count_people_plural'); } } } } } /* Filter out the placeholder. */ $output = str_replace('%count%', $liked_count, $output); echo $output; }
/** * bp_like_admin_page() * * Outputs the admin settings page. * */ function bp_like_admin_page() { global $current_user; wp_get_current_user(); /* Update our options if the form has been submitted */ if (isset($_POST['_wpnonce']) && isset($_POST['bp_like_updated'])) { /* Add each text string to the $strings_to_save array */ foreach ($_POST as $key => $value) { if (preg_match("/text_string_/i", $key)) { $default = bp_like_get_text(str_replace('bp_like_admin_text_string_', '', $key), 'default'); $strings_to_save[str_replace('bp_like_admin_text_string_', '', $key)] = array('default' => $default, 'custom' => stripslashes($value)); } } /* Now actually save the data to the options table */ update_site_option('bp_like_settings', array('likers_visibility' => $_POST['bp_like_admin_likers_visibility'], 'post_to_activity_stream' => $_POST['bp_like_admin_post_to_activity_stream'], 'show_excerpt' => $_POST['bp_like_admin_show_excerpt'], 'excerpt_length' => $_POST['bp_like_admin_excerpt_length'], 'text_strings' => $strings_to_save, 'translate_nag' => bp_like_get_settings('translate_nag'), 'name_or_avatar' => $_POST['name_or_avatar'], 'remove_fav_button' => $_POST['bp_like_remove_fav_button'])); /* Let the user know everything's cool */ echo '<div class="updated"><p><strong>'; _e('Settings saved.', 'wordpress'); echo '</strong></p></div>'; } $text_strings = bp_like_get_settings('text_strings'); $title = __('BuddyPress Like'); ?> <style type="text/css"> table input { width: 100%; } table label { display: block; } </style> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('select.name-or-avatar').change(function() { var value = jQuery(this).val(); jQuery('select.name-or-avatar').val(value); }); }); </script> <div class="wrap"> <h1><?php echo esc_html($title); ?> </h1> <form action="" method="post"> <input type="hidden" name="bp_like_updated" value="updated"> <table class="form-table" id="bp-like-admin" style="max-width:650px;float:left;"> <tr valign="top"> <th scope="row"><?php _e('Posting Settings', 'buddypress-like'); ?> </th> <td> <fieldset> <legend class="screen-reader-text"> <span><?php _e('Posting Settings', 'buddypress-like'); ?> </span> </legend> <input type="checkbox" id="bp_like_admin_post_to_activity_stream" name="bp_like_admin_post_to_activity_stream" value="1"<?php if (bp_like_get_settings('post_to_activity_stream') == 1) { echo ' checked="checked"'; } ?> > <label for="bp_like_admin_post_activity_updates"> <?php _e("Post an activity update when something is liked", 'buddypress-like'); ?> </label> <p class="description"><?php echo __('e.g. ') . $current_user->display_name . __(" liked Darren's activity. "); ?> </p> <br /> <input type="checkbox" id="bp_like_admin_show_excerpt" name="bp_like_admin_show_excerpt" value="1"<?php if (bp_like_get_settings('show_excerpt') == 1) { echo ' checked="checked"'; } ?> > <label for="bp_like_admin_show_excerpt"><?php _e("Show a short excerpt of the activity that has been liked.", 'buddypress-like'); ?> </label> <p>Limit to <input type="text" maxlength="3" style="width: 40px" value="<?php echo bp_like_get_settings('excerpt_length'); ?> " name="bp_like_admin_excerpt_length" /> characters.</p> </fieldset> </td> </tr> <tr valign="top"> <th scope="row"><?php _e('Remove Favorite Button', 'buddypress-like'); ?> </th> <td> <fieldset> <legend class="screen-reader-text"> <span><?php _e('Remove Favorite Button', 'buddypress-like'); ?> </span> </legend> <input type="checkbox" id="bp_like_remove_fav_button" name="bp_like_remove_fav_button" value="1" <?php if (bp_like_get_settings('remove_fav_button') == 1) { echo ' checked="checked" '; } ?> > <label for="bp_like_remove_fav_button"> <?php _e("Remove the BuddyPress favorite button from activity.", 'buddypress-like'); ?> </label> <p class="description"><?php echo __(" Currently only uses jQuery to remove the buttons.", "buddypress-like"); ?> </p> <br /> </fieldset> </td> </tr> </table> <div id="bplike-about" style="float:right; background:#fff;max-width:300px;padding:20px;margin-bottom:30px;"> <h3>About</h3> <p><strong>Version: <?php echo BP_LIKE_VERSION; ?> </strong></p> <div class="inside"> <p>Gives users the ability to 'like' content across your BuddyPress enabled site.</p> <p>Available for free on <a href="http://wordpress.org/plugins/buddypress-like/">WordPress.org</a>.</p> <h4>Want to help?</h4> <ul> <li><a href="https://wordpress.org/support/view/plugin-reviews/buddypress-like?filter=5">Give 5 stars on WordPress.org</a></li> <li>Development takes place publicly on <a href="https://github.com/Darrenmeehan/BuddyPress-Like">Github</a>. Is there any issues or bugs you have?</li> <li><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZAJLLEJDBHAWL"><strong>Donate</strong></a></li> </ul> <h4>Need help?</h4> <ul><li>Ask on the <a href="http://wordpress.org/support/plugin/buddypress-like">WordPress.org forum</a></li></ul> </div> </div> <table class="form-table"> <tr valign="top"> <th scope="row"><?php _e('Custom Messages', 'buddypress-like'); ?> </th> <td> <fieldset> <legend class="screen-reader-text"> <span><?php _e('Custom Messages', 'buddypress-like'); ?> </span> </legend> <label for="bp_like_admin_post_activity_updates"> <?php _e("Change what messages are shown to users. For example, they can 'love' or 'dig' items instead of liking them.", "buddypress-like"); ?> </label> </fieldset> </td> </tr> </table> <table class="widefat fixed" cellspacing="0"> <thead> <tr> <th scope="col" id="default" class="column-name" style="width: 43%;"><?php _e('Default', 'buddypress-like'); ?> </th> <th scope="col" id="custom" class="column-name" style=""><?php _e('Custom', 'buddypress-like'); ?> </th> </tr> </thead> <tfoot> <tr> <th colspan="2" id="default" class="column-name"></th> </tr> </tfoot> <?php foreach ($text_strings as $key => $string) { ?> <tr valign="top"> <th scope="row" style="width:400px;"><label for="bp_like_admin_text_string_<?php echo $key; ?> "><?php echo htmlspecialchars($string['default']); ?> </label></th> <td><input name="bp_like_admin_text_string_<?php echo $key; ?> " id="bp_like_admin_text_string_<?php echo $key; ?> " value="<?php echo htmlspecialchars($string['custom']); ?> " class="regular-text" type="text"></td> </tr> <?php } ?> </tbody> </table> <p class="submit"> <input class="button-primary" type="submit" name="bp-like-admin-submit" id="bp-like-admin-submit" value="<?php _e('Save Changes', 'wordpress'); ?> "/> </p> <?php wp_nonce_field('bp-like-admin'); ?> </form> </div> <?php }
/** * bp_like_admin_page() * * Outputs the admin settings page. * */ function bp_like_admin_page() { global $current_user; wp_get_current_user(); /* Update our options if the form has been submitted */ if (isset($_POST['_wpnonce']) && isset($_POST['bp_like_updated'])) { /* Add each text string to the $strings_to_save array */ foreach ($_POST as $key => $value) { if (preg_match("/text_string_/i", $key)) { $default = bp_like_get_text(str_replace('bp_like_admin_text_string_', '', $key), 'default'); $strings_to_save[str_replace('bp_like_admin_text_string_', '', $key)] = array('default' => $default, 'custom' => stripslashes($value)); } } /* Now actually save the data to the options table */ update_site_option('bp_like_settings', array('likers_visibility' => $_POST['bp_like_admin_likers_visibility'], 'post_to_activity_stream' => $_POST['bp_like_admin_post_to_activity_stream'], 'show_excerpt' => $_POST['bp_like_admin_show_excerpt'], 'excerpt_length' => $_POST['bp_like_admin_excerpt_length'], 'text_strings' => $strings_to_save, 'translate_nag' => bp_like_get_settings('translate_nag'), 'name_or_avatar' => $_POST['name_or_avatar'])); /* Let the user know everything's cool */ echo '<div class="updated"><p><strong>'; _e('Settings saved.', 'wordpress'); echo '</strong></p></div>'; } $text_strings = bp_like_get_settings('text_strings'); ?> <style type="text/css"> #icon-bp-like-settings { background: url('<?php echo plugins_url('/_inc/img/bp-like-icon32.png', __FILE__); ?> ') no-repeat top left; } table input { width: 100%; } table label { display: block; } </style> <script type="text/javascript"> jQuery(document).ready( function() { jQuery('select.name-or-avatar').change(function(){ var value = jQuery(this).val(); jQuery('select.name-or-avatar').val(value); }); }); </script> <div class="wrap"> <div id="icon-bp-like-settings" class="icon32"><br /></div> <h2><?php _e('BuddyPress Like Settings', 'buddypress-like'); ?> </h2> <form action="" method="post" id="bp-like-admin-form"> <input type="hidden" name="bp_like_updated" value="updated"> <h3><?php _e('General Settings', 'buddypress-like'); ?> </h3> <p><input type="checkbox" id="bp_like_admin_post_to_activity_stream" name="bp_like_admin_post_to_activity_stream" value="1"<?php if (bp_like_get_settings('post_to_activity_stream') == 1) { echo ' checked="checked"'; } ?> > <label for="bp_like_admin_post_activity_updates"><?php _e("Post an activity update when something is liked", 'buddypress-like'); ?> , (e.g. "<?php echo $current_user->display_name; ?> likes Bob's activity")</label></p> <p><input type="checkbox" id="bp_like_admin_show_excerpt" name="bp_like_admin_show_excerpt" value="1"<?php if (bp_like_get_settings('show_excerpt') == 1) { echo ' checked="checked"'; } ?> > <label for="bp_like_admin_show_excerpt"><?php _e("Show a short excerpt of the activity that has been liked", 'buddypress-like'); ?> </label>; limit to <input type="text" maxlength="3" style="width: 40px" value="<?php echo bp_like_get_settings('excerpt_length'); ?> " name="bp_like_admin_excerpt_length" /> characters.</p> <h3><?php _e("'View Likes' Visibility", "buddypress-like"); ?> </h3> <p><?php _e("Choose how much information about the 'likers' of a particular item is shown;", "buddypress-like"); ?> </p> <p style="line-height: 200%;"> <input type="radio" name="bp_like_admin_likers_visibility" value="show_all"<?php if (bp_like_get_settings('likers_visibility') == 'show_all') { echo ' checked="checked""'; } ?> /> Show <select name="name_or_avatar" class="name-or-avatar"><option value="name"<?php if (bp_like_get_settings('name_or_avatar') == 'name') { echo ' selected="selected""'; } ?> >names</option><option value="avatar"<?php if (bp_like_get_settings('name_or_avatar') == 'avatar') { echo ' selected="selected""'; } ?> >avatars</option></select> of all likers<br /> <?php if (bp_is_active('friends')) { ?> <input type="radio" name="bp_like_admin_likers_visibility" value="friends_names_others_numbers"<?php if (bp_like_get_settings('likers_visibility') == 'friends_names_others_numbers') { echo ' checked="checked""'; } ?> /> Show <select name="name_or_avatar" class="name-or-avatar"><option value="name"<?php if (bp_like_get_settings('name_or_avatar') == 'name') { echo ' selected="selected""'; } ?> >names</option><option value="avatar"<?php if (bp_like_get_settings('name_or_avatar') == 'avatar') { echo ' selected="selected""'; } ?> >avatars</option></select> of friends, and the number of non-friends<br /> <?php } ?> <input type="radio" name="bp_like_admin_likers_visibility" value="just_numbers"<?php if (bp_like_get_settings('likers_visibility') == 'just_numbers') { echo ' checked="checked""'; } ?> /> <?php _e('Show only the number of likers', 'buddypress-like'); ?> </p> <h3><?php _e('Custom Messages', 'buddypress-like'); ?> </h3> <p><?php _e("Change what messages are shown to users. For example, they can 'love' or 'dig' items instead of liking them.", "buddypress-like"); ?> <br /><br /></p> <table class="widefat fixed" cellspacing="0"> <thead> <tr> <th scope="col" id="default" class="column-name" style="width: 43%;"><?php _e('Default', 'buddypress-like'); ?> </th> <th scope="col" id="custom" class="column-name" style=""><?php _e('Custom', 'buddypress-like'); ?> </th> </tr> </thead> <tfoot> <tr> <th colspan="2" id="default" class="column-name"></th> </tr> </tfoot> <?php foreach ($text_strings as $key => $string) { ?> <tr valign="top"> <th scope="row" style="width:400px;"><label for="bp_like_admin_text_string_<?php echo $key; ?> "><?php echo htmlspecialchars($string['default']); ?> </label></th> <td><input name="bp_like_admin_text_string_<?php echo $key; ?> " id="bp_like_admin_text_string_<?php echo $key; ?> " value="<?php echo htmlspecialchars($string['custom']); ?> " class="regular-text" type="text"></td> </tr> <?php } ?> </tbody> </table> <p class="submit"> <input class="button-primary" type="submit" name="bp-like-admin-submit" id="bp-like-admin-submit" value="<?php _e('Save Changes', 'wordpress'); ?> "/> </p> <?php wp_nonce_field('bp-like-admin'); ?> </form> </div> <?php }
function bplike_activity_button() { // Debugging. // echo bp_get_activity_type(); $liked_count = 0; $bp_like_comment_id = bp_get_activity_comment_id(); if (empty($bp_like_comment_id)) { $bp_like_id = bp_get_activity_id(); $bp_like_view = 'button view-likes'; if (bp_like_is_liked($bp_like_id, 'activity')) { $bp_like_css = 'button unlike'; } else { $bp_like_css = 'button like'; } } else { $bp_like_id = bp_get_activity_comment_id(); $bp_like_view = 'acomment-reply bp-primary-action view-likes'; if (bp_like_is_liked($bp_like_id, 'activity')) { $bp_like_css = 'acomment-reply bp-primary-action unlike'; } else { $bp_like_css = 'acomment-reply bp-primary-action like'; } } // Debugging. //print_r( bp_activity_get_meta( $bp_like_id , 'liked_count' , true )); $activity = bp_activity_get_specific(array('activity_ids' => $bp_like_id)); $activity_type = $activity['activities'][0]->type; // Debugging. //print_r($activity); if ($activity_type === null) { $activity_type = 'activity_update'; } if (is_user_logged_in() && $activity_type !== 'activity_liked') { if (bp_activity_get_meta($bp_like_id, 'liked_count', true)) { $users_who_like = array_keys(bp_activity_get_meta($bp_like_id, 'liked_count', true)); $liked_count = count($users_who_like); } if (!bp_like_is_liked($bp_like_id, 'activity')) { ?> <a href="#" class="<?php echo $bp_like_css; ?> " id="like-activity-<?php echo $bp_like_id; ?> " title="<?php echo bp_like_get_text('like_this_item'); ?> "><?php echo bp_like_get_text('like'); if ($liked_count) { echo ' (' . $liked_count . ')'; } ?> </a> <?php } else { ?> <a href="#" class="<?php echo $bp_like_css; ?> " id="unlike-activity-<?php echo $bp_like_id; ?> " title="<?php echo bp_like_get_text('unlike_this_item'); ?> "><?php echo bp_like_get_text('unlike'); if ($liked_count) { echo ' (' . $liked_count . ')'; } ?> </a> <?php } // Checking if there are users who like item. if (isset($users_who_like)) { view_who_likes(); } } }