WordPress用 Twitter プラグインは、twitter_followWordPress ショートコードを使ったあなたのサイトへのフォローボタン追加をサポートしています。
あなたが投稿しするコンテンツのエリアにショートコードを含めるか、do_shortcode WordPress functionを使用してPHP でショートコード を精査することによって、WordPress の投稿にフォローボタンを追加します。
例:
Twitterで私たちをフォローします: [twitter_follow screen_name="TwitterDev"]
ショートコードの結果:
Follow ButtonThe Twitter plugin for WordPress supports adding a Follow button to your site through the Example: Follow us on Twitter: [twitter_follow screen_name="TwitterDev"] Shortcode result: |
フォローするアカウントのTwitter ユーザー名。
the loop内でショートコードが呼び出される時、
このプラグインは自動的にscreen_nameパラメータを、保存される投稿者のTwitter ユーザー名に設定します。
サンプル値: TwitterDev
表示されるボタンからTwitter ユーザー名を取り除くには falseか 0か noか off を設定します。
サンプル値: false
ボタンの横に表示される、指定したアカウントのフォロワー数を取り除くには、falseか 0か noか offを設定します。
サンプル値: true
大きめのフォローボタンを表示するには、 large を設定します。
サンプル値: large
Supported shortcode parameters
screen_name
required
Twitter username of the account to follow. The plugin will automatically set the Example Value:
show_screen_name
optional
Set to Example Value:
show_count
optional
Set to Example Value:
size
optional
Set to Example Value: |
WordPress フィルターのshortcode_atts_twitter_followに渡された連想配列にしたがって動作することで、ウェブサイトはサイト全体のフォローボタンに関する設定を設定できます。
このフィルターにしたがって動作するFunctions では、show_countやshow_screen_name の値を変更する場合にはboolean 型を設定しなければなりません。
例:
/**
* Always show large button
*
* @param array $options parsed options with defaults applied
* @param array $defaults default values of a Follow button
* @param array $attributes user-defined shortcode attributes
*
* @return array options array with our customization applied
*/
function twitter_follow_custom_options( $options, $defaults, $attributes )
{
$options['size'] = 'large';
return $options;
}
add_filter( 'shortcode_atts_twitter_follow', 'twitter_follow_custom_options', 10, 3 );
Site-wide customization using a filterA website may set site-wide preferences for Follow buttons by acting on the associative array passed to the Example:
/**
* Always show large button
*
* @param array $options parsed options with defaults applied
* @param array $defaults default values of a Follow button
* @param array $attributes user-defined shortcode attributes
*
* @return array options array with our customization applied
*/
function twitter_follow_custom_options( $options, $defaults, $attributes )
{
$options['size'] = 'large';
return $options;
}
add_filter( 'shortcode_atts_twitter_follow', 'twitter_follow_custom_options', 10, 3 );
|