clubdeuce/wp-share-this
Composer 安装命令:
composer require clubdeuce/wp-share-this
包简介
An Share This library for WordPress.
README 文档
README
WP Share-This
This library allows for easy implementation of sharing links using the ShareThis. Please note, this library is in no way affiliated with ShareThis or its subsidiaries.
Installation
The easiest method for including this library is via Composer. Simply run the follow command
in your project root (assuming that is where your composer.json is located):
composer require clubdeuce/wp-share-this
This library will be autoloaded, assuming you include vendor/autoload.php in your project.
You can also download this library and include it manually.
Usage
- Register service(s):
WP_Share_This::register_service( 'twitter' ). The full list of supported services can be found here. - Initialize the library:
WP_Share_This::initialize(). - Render the links:
WP_Share_This::the_sharing_links().
Methods
| Method | Description | Since |
|---|---|---|
| register_id( string $share_this_id ) | Specify the ShareThis user id for tracking | 0.0.1 |
| register_service( string $service_name, array $params ) | Specify a service to be included. You can pass parameters specific to this service (see below for a list of parameters). | 0.0.1 |
| the_sharing_links( null/array $params ) | Output the sharing links. You can pass parameters specific to this block of links (see below for a list of parameters). | 0.0.1 |
| use_og( bool $use ) | Specify whether to include the OpenGraph information in the <head> of the document. Default: true. |
0.0.2 |
Parameters
The following parameters can be specified for the sharing links on a per-service basis (not all items apply to every service):
| Name | Description |
|---|---|
| url | Specifies URL (can be shortened URL) that you would like shared. Default: current global $post permalink. |
| short_url | Specifies a shortened URL that can be used in conjunction with the data-url. Default: null |
| title | Specifies title that you would like shared. Defaults to current global $post title. |
| image | Specifies link to image you would like displayed in the shared content. Default: current global $post featured image if present. |
| description | Specifies summary text/description you wish to share. Default: current global $post excerpt. |
| username | Specifies your Twitter username. |
| message | Specifies the body copy of e-mail shares. Default: current global $post excerpt. |
| share_count | Specify whether to include the share count for this individual link item. Default: true. |
Examples:
To register services with unique parameters:
WP_Share_This::register_service( 'twitter', array(
'username' => 'myTwitterHandle',
'share_count' => false,
) );
WP_Share_This::register_service( 'facebook', array(
'image' => 'https://example.com/image.png',
);
WP_Share_This::register_service( 'email', array(
'message' => __( 'Look at this really interesting article I found!', 'txt_domain' ),
) );
To render the links with overrides to the defaults:
WP_Share_This::the_sharing_links( array(
'share_count' => false,
) );
To render sharing links for a post other than the current global $post item:
WP_Share_This::the_sharing_links( array(
'post' => get_post( $post_id ),
) );
Filters
This library exposes a number of filters:
| Filter | Description | Parameters | Since |
|---|---|---|---|
wpst_link_classes_$service |
This filter allows you to specify classes for each service link, _e.g. add_filter( 'wpst_classes_twitter', 'my_function' ) |
array classnames | 0.0.1 |
wpst_og_url |
Allows you to filter the URL exposed via OpenGraph | string URL | 0.0.1 |
wpst_og_title |
Allows you to filter the title exposed via OpenGraph | string title | 0.0.1 |
wpst_og_description |
Allows you to filter the description exposed via OpenGraph | string description | 0.0.1 |
wpst_og_image |
Allows you to filter the image exposed via OpenGraph | string image URL | 0.0.1 |
wpst_link_text |
Allows you to filter the text displayed for the sharing link (defaults to the service name) | string text | 0.0.1 |
clubdeuce/wp-share-this 适用场景与选型建议
clubdeuce/wp-share-this 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.45k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 12 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「library」 「wordpress」 「maps」 「sharethis」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 clubdeuce/wp-share-this 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 clubdeuce/wp-share-this 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 clubdeuce/wp-share-this 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Inbox pattern process implementation for your Laravel Applications
Core library that defines common interfaces used by the rest of the intahwebz..
Amqp classes
Provides command to manage a web library directory
Alfabank REST API integration
CakePHP Bitly Plugin
统计信息
- 总下载量: 2.45k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0
- 更新时间: 2019-12-16