[WordPress] 外掛分享: BuddyPig

前言介紹

  • 這款 WordPress 外掛「BuddyPig」是 2012-08-12 上架。 目前已經下架不再更新,不建議安裝使用。
  • 目前尚無安裝啟用數,是個很新的外掛。如有要安裝使用,建議多測試確保功能沒問題!
  • 上一次更新是 2012-12-20,距離現在已有 4518 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 3.4 以上版本才可以安裝。
  • 有 2 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

beaulebens | evansolomon |

外掛標籤

game | buddypress |

內容簡介

BuddyPig 是一個遊戲,旨在幫助 BuddyPress 群組成員更好地認識彼此。這個項目是在 Automattic 的一個 Hack Day 活動中開發的。由於我們是一個遠程公司,與某些同事幾個月沒有交談是很常見的。因此,我們想出了 BuddyPig 作為一種有趣的方式來對抗這個問題。

如果你好奇,PIG 是個人資訊遊戲的縮寫。

要使用這個外掛,您需要撰寫一個小型外掛來創建問題,並選擇要使用的 BuddyPress 群組。PIG 可以通過非常易於操作的 Hook 進行自定義,如果有需要的話。下面,我們將會提供一個示範外掛,以設置 PIG。

要運行 PIG,需要事先安裝 BuddyPress 和其活動流特性。此外,還需要 PHP 5.3,略高於 WordPress 的默認需求。

設置示範

您需要告訴 PIG 使用哪些個人資訊項目以及問題的提法。我們提供了一個名為 pig_register_question() 的方程式來完成這些。默認情況下,pig_register_question() 接受兩個引數:BuddyPress 個人資訊欄位名稱以及問題的格式。以下為一個示例:

pig_register_question( 'Address', 'Where does %s live?' );

您會注意到問題格式中的 %s,這是我們插入問題版面時放入的用戶名稱。如果您之前曾經編寫過 PHP,您可能會認出這個語法是後台使用的 sprintf() 函數。

還需要告訴 PIG 要使用哪個 BuddyPress 群組,可以使用 pig_set_group(),並傳遞群組的 ID。以下為一個範例:

pig_set_group( 1 );

pig_register_question() 可以接受另外兩個參數。第一個參數用於指示 PIG 是否在問題中使用名詞所有格。例如,“ Beau出生在哪裡?”不使用名詞所有格,但是“Beau的房子在哪裡?”是使用。如果要使用名詞所有格,則可以將“true”添加為第三個參數,如下所示:

pig_register_question( 'Address', 'Where is %s house?', true );

最後一個可選參數是回撥函數(Callback)。PIG 可以在顯示答案之前為您格式化答案。其中一種使用方法是刪除具有相同意義的重復詞組,例如美國和美利堅合眾國。如果使用這個回撥函數,您還必須確保此功能存在以供 PIG 調用。以下為一個範例:

pig_register_question( 'Address', 'Where is %s house?', 'a8c_dedupe_countries' );
function a8c_pig_dedupe_countries( $country ) {
$usa_versions = array( 'US', 'USA', 'United States', 'U.S.A', 'U.S.', 'America', 'United States of America' );
$uk_versions = array( 'UK', 'U.K.', 'United Kingdom' );
foreach ( $usa_versions as $usa_version ) {
if ( strtolower( $country ) == strtolower( $usa_version ) )
return 'United States';
}

foreach ( $uk_versions as $uk_version ) {
if ( strtolower( $country ) == strtolower( $uk_version ) )
return 'United Kingdom';
}

return $country;
}

您可以將這些設置調用放入自己的外掛中,並像任何其他外掛一樣啟用它。不過,如果您堅持使用主題的 functions.php 文件,也可以將做法套用到主題上。為了確保這些所有數據在 PIG 設置完成後再載入,可以使用 pig_loaded 事件進行回呼(Hook)。

原文外掛簡介

BuddyPig is a game meant to help BuddyPress group members get to know each other better. It was built during a hack day at Automattic. Since we’re a distributed company, it’s not uncommon to go months without talking to certain colleagues. We came up with BuddyPig as a fun way to work around that.
PIG, in case you’re curious, is an acronym for Personal Information Game.
To use it you’ll have to write a small plugin to create questions and choose the BuddyPress group you’d like to use. PIG is very hook-able, so there’s lots of other stuff you can customize if you’re so inclined. We’ll include an example plugin to setup PIG below.
PIG requires BuddyPress and its Activity Streams feature to be running. It also requires PHP 5.3, which is slightly higher than the default requirement for WordPress.
Example setup
You have to tell PIG what profile items to use and how to ask the questions. We gave you a function called pig_register_question() to do just that. By default, pig_register_question() takes 2 arguments, the BuddyPress profile field name and a format to use to ask the question. Here’s an example:
pig_register_question( 'Address', 'Where does %s live?' );

You’ll notice the %s in the question format, which is where we drop in the user’s name that the question is about. If you’ve written PHP before, you may recognize this syntax from the sprintf() function, which is what is used behind the scenes.
You’ll also have to tell PIG what BuddyPress group to use, which can be done with pig_set_group() by passing the group’s ID. Here’s an example:
pig_set_group( 1 );

pig_register_question() can take two additional arguments. The first one tells PIG whether to make the name possessive when it asks the question. For example, "Where was Beau born?" would not be possessive, but "Where is Beau's house?" would be. If you want PIG to make the name possessive, you can add `true` as the third argument, like this:

pig_register_question( 'Address', 'Where is %s house?', true );

The last optional argument is a callback. PIG can format answers for you before displaying them. One use case of this is deduplicating multiple phrases that mean the same thing, like “United States” and “USA”. If you use this callback, you must also make sure the function exists for PIG to call. Here’s an example:
pig_register_question( 'Address', 'Where is %s house?', 'a8c_dedupe_countries' );
function a8c_pig_dedupe_countries( $country ) {
$usa_versions = array( 'US', 'USA', 'United States', 'U.S.A', 'U.S.', 'America', 'United States of America' );
$uk_versions = array( 'UK', 'U.K.', 'United Kingdom' );
foreach ( $usa_versions as $usa_version ) {
if ( strtolower( $country ) == strtolower( $usa_version ) )
return 'United States';
}

foreach ( $uk_versions as $uk_version ) {
if ( strtolower( $country ) == strtolower( $uk_version ) )
return 'United Kingdom';
}

return $country;
}

You can put these setup calls into your own plugin and activate it just like any other. If you insist, you could also put them into your theme’s functions.php file. To make sure they’re loaded after PIG is setup, you can hook them to the pig_loaded action.

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「BuddyPig」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


1.0 | 1.1 | 1.1.1 | 1.1.2 | trunk |

延伸相關外掛(你可能也想知道)

  • Dinosaur Game 》這個外掛讓您可以在 WordPress 網站上新增 Google Chrome 的恐龍遊戲。, 安裝外掛後,只需要在您想要遊戲出現的地方使用 [dinosaur-game] 短碼即可使用。, 遊...。
  • Football Pool 》此外掛可在您的部落格中新增一個 Fantasy Sports 池。您的網站訪客可以預測比賽結果,並回答額外的問題以獲得額外積分。每個參賽者都可以查看其他池中競爭對...。
  • WHA Puzzle 》Puzzle(拼圖遊戲)是一個將不同形狀的碎片拼湊成圖案的拼圖遊戲。, 它是最實惠的玩具之一,能夠培養邏輯思維、注意力、記憶和想像力。, 影片, 。
  • Scratch & Win – Giveaways and Contests. Boost subscribers, traffic, repeat visits, referrals, sales and more 》免費!, , 購買我們的Social Boost或Gratisfaction應用程式中的任何年費付費方案,均可免費獲得此應用程式。, , 想實現您的行銷目標嗎?, 節日和熱門活動模板...。
  • Retro Game Emulator 》此外掛可透過簡碼 [nes] 在任何文章或頁面上,在您的網站中加入 NES 玩家。請注意,此外掛不含 ROM,您需要在設定頁面上上傳 ROM,才能播放。, 此外掛實現了...。
  • Dino Game – Embed Google Chrome Dinosaur Game in your website 》您可以使用短碼 [dino-game] 在任何地方添加 Google Chrome 恐龍遊戲,也可以使用 Gutenberg 區塊在文章或頁面中添加。, 您可以控制遊戲的速度和靜音。如果使...。
  • YMC Crossword 》* 英文為Crossword的遊戲是根據定義猜測單詞的遊戲。, * 填字遊戲的形式是方形或矩形的格子。, * 遊戲的目標是通過解答含有答案的提示來填寫白色的格子,組成...。
  • Solitaire Card Game – Embed Klondike Solitaire for Free – Ad-free Solitaire Puzzle game 》這個外掛可以讓你使用簡碼,在你的 WordPress 網站中任何地方(包括頁面和文章)免費嵌入無廣告的Klondike 接龍遊戲。, 只需在想要出現遊戲的位置加入簡碼 [&...。
  • GeeK! – Movie & Game Database 》總結:GeeK 外掛是 WordPress 生態系統中不可或缺的資產,專為影迷和遊戲玩家設計,提供豐富的功能套件。從 IMDb 電影平台和 IGDB 遊戲數據庫汲取靈感,GeeK ...。
  • WP Sudoku Plus 》這個外掛可以在你的網站上顯示數獨拼圖。, 它附帶了7個不同難度等級、20萬個獨特拼圖。, 這個外掛會記錄每個拼圖成功或失敗的次數。, 前端提供簡單的幫助和統...。
  • Slide Puzzle 》, 這個外掛可以增加更多互動性,讓網站更有趣。 🙂, , , 觀看這個影片 安裝和使用影片,指導我們如何安裝和使用這個外掛。, , , 欲了解更多詳細資訊和範例,...。
  • MorePuzzles 》morepuzzles 外掛是一款完美的選擇,適合那些想在他們的網頁上張貼填字或字搜遊戲的人。, 這個外掛是為第三方 morepuzzles.com 網站而設計,您可以在該網站上...。
  • Hangman 》這是傳統猜單詞遊戲的煥然一新版本,字典包含14000個英文單詞。運行基於jQuery庫、AJAX和PHP。, 演示, 您可以在這裡玩猜單詞遊戲的演示, 使用方法, , 安裝這...。
  • crosswordsearch 》Crosswordsearch 是一個 WordPress 的外掛程式,基於 AngularJs Javascript 框架,可設計和玩字搜尋式的填字遊戲。原始開發是為了 RadiJojo.de 國際兒童媒體...。
  • Block-a-saurus 》使用 Block-a-saurus 嵌入文章中,您的用戶將能夠點擊並播放原先由 Google Chrome 流行化的跳躍 T-Rex 遊戲的嵌入版本。此區塊適用於所有螢幕大小,甚至允許...。

文章
Filter
Mastodon