Title: Topic Like Button for bbPress
Author: dahousecatz
Published: <strong>2018 年 10 月 25 日</strong>
Last modified: 2018 年 10 月 25 日

---

搜索插件

![](https://ps.w.org/bbp-topic-like-button/assets/banner-772x250.png?rev=1962942)

**该插件尚未通过WordPress的最新3个主要版本进行测试**。 当与较新版本的WordPress一起
使用时，可能不再受到维护或支持，并且可能会存在兼容性问题。

![](https://ps.w.org/bbp-topic-like-button/assets/icon-256x256.png?rev=1962942)

# Topic Like Button for bbPress

 作者：[dahousecatz](https://profiles.wordpress.org/dahousecatz/)

[下载](https://downloads.wordpress.org/plugin/bbp-topic-like-button.1.0.zip)

 * [详情](https://cn.wordpress.org/plugins/bbp-topic-like-button/#description)
 * [评价](https://cn.wordpress.org/plugins/bbp-topic-like-button/#reviews)
 *  [安装](https://cn.wordpress.org/plugins/bbp-topic-like-button/#installation)
 * [开发进展](https://cn.wordpress.org/plugins/bbp-topic-like-button/#developers)

 [支持](https://wordpress.org/support/plugin/bbp-topic-like-button/)

## 描述

Once the function bbp_topic_like_button() is placed in your bbPress topic template
file it creates a div placeholder.
 This is the same for every user so the initial
page build can be globally cached. Once the document is ready an ajax request checks
if the current user has liked the current topic and then displays a like or unlike
button. Upon clicking the button a ajax request is sent to save the updated topic
likes. Topic likes are stored as post meta attached to the topic.

### Additional Info

The plugin cannot be activated without bbPress first being activated.
 If bbPress
is deactivated then this plugin will deactivate itself.

### Credits

Thanks to elhardoum author of bbp-messages for inspiration for the CheckReady class.

## 安装

The easiest way to install this plugin is to go to Add New in the Plugins section
of your blog admin and search for
 “bbPress Topic Like Button.” On the far right
side of the search results, click “Install.”

If the automatic process above fails, follow these simple steps to do a manual install:

 1. Extract the contents of the zip file into your `/wp-content/plugins/` directory
 2. Activate the plugin through the ‘Plugins’ menu in WordPress

## 常见问题

  Can I customise the button?

Yes. The easiest way to do this is to pass in attributes when initially calling 
bbp_topic_like_button().

You can pass in attributes to set a custom user_id or topic_id, set before or after
html, customise the button text
 or add custom classes to the button.

Here is an example setting all possible custom options:

    ```
    $args = [
        'user_id'  => get_current_user_id(),
        'topic_id' => bbp_get_topic_id(),
        'before'   => '',
        'after'    => '',
        'like'     => __('Like', 'your-domain'),
        'unlike'   => __('Unlike', 'your-domain'),
        'class'    => ['my-custom-class', 'another-custom-class'],
    ];
    bbp_topic_like_button($args);
    ```

It is also possible to implement the filter get_bbp_topic_like_button to make any
final changes to the rendered html.

  Can I trigger a custom event when the like button is clicked

Yes, the action bbp_topic_like_button_clicked is fired on every button press.

E.g. implement like this:

    ```
    add_action('bbp_topic_like_button_clicked', 'my_plugin_bbp_topic_like_button_clicked', 10, 3);
    function my_plugin_bbp_topic_like_button_clicked($res, $user_id, $topic_id) {
        // Add code here to do something.
    }
    ```

## 评价

此插件暂无评价。

## 贡献者及开发者

「Topic Like Button for bbPress」是开源软件。 以下人员对此插件做出了贡献。

贡献者

 *   [ dahousecatz ](https://profiles.wordpress.org/dahousecatz/)

[帮助将「Topic Like Button for bbPress」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/bbp-topic-like-button)

### 对开发感兴趣吗?

您可以[浏览代码](https://plugins.trac.wordpress.org/browser/bbp-topic-like-button/)，
查看[SVN仓库](https://plugins.svn.wordpress.org/bbp-topic-like-button/)，或通过[RSS](https://plugins.trac.wordpress.org/log/bbp-topic-like-button/?limit=100&mode=stop_on_copy&format=rss)
订阅[开发日志](https://plugins.trac.wordpress.org/log/bbp-topic-like-button/)。

## 更新日志

#### 1.0

 * First version released.

## 额外信息

 *  版本 **1.0**
 *  最后更新：**8 年前**
 *  活跃安装数量 **10+**
 *  WordPress 版本 ** 4.7 或更高版本 **
 *  已测试的最高版本为 **4.9.29**
 *  PHP 版本 ** 5.6 或更高版本 **
 *  语言
 * [English (US)](https://wordpress.org/plugins/bbp-topic-like-button/)
 * 标签
 * [bbPress](https://cn.wordpress.org/plugins/tags/bbpress/)[like](https://cn.wordpress.org/plugins/tags/like/)
   [like button](https://cn.wordpress.org/plugins/tags/like-button/)[topic](https://cn.wordpress.org/plugins/tags/topic/)
 *  [高级视图](https://cn.wordpress.org/plugins/bbp-topic-like-button/advanced/)

## 评级

尚未提交反馈。

[Your review](https://wordpress.org/support/plugin/bbp-topic-like-button/reviews/#new-post)

[查看全部评论](https://wordpress.org/support/plugin/bbp-topic-like-button/reviews/)

## 贡献者

 *   [ dahousecatz ](https://profiles.wordpress.org/dahousecatz/)

## 支持

有话要说吗？是否需要帮助？

 [查看支持论坛](https://wordpress.org/support/plugin/bbp-topic-like-button/)