inc2734/wp-share-buttons 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

inc2734/wp-share-buttons

Composer 安装命令:

composer require inc2734/wp-share-buttons

包简介

A library for WordPress theme that adds social share buttons.

README 文档

README

CI Latest Stable Version License

This library adds share button shortcodes for WordPress. This buttons display to sum http and https counts. And, It works lightly with asynchronous display and caching.

When SNS Count Cache plugin is activated WP Share Buttons uses that counts.

This buttons can use for singular pages.

Install

$ composer require inc2734/wp-share-buttons

How to use

<?php
new \Inc2734\WP_Share_Buttons\Bootstrap();

Shortcodes

All buttons

[wp_share_buttons type="(Optional)" title="(Optional)" post_id="(Required)"]

type:
Baloon, horizontal, icon, block, official
When type is not official, buttons sums http and https counts.

Facebook

[wp_share_buttons_facebook type="(Optional)" post_id="(Required)"]

Need App Token to get facebook share count.

/**
 * @see https://developers.facebook.com/tools/accesstoken
 */
add_filter(
  'inc2734_wp_share_buttons_facebook_app_token',
  function() {
    return 'Your App Token';
  }
);

Twitter

[wp_share_buttons_twitter type="(Optional)" title="(Optional)" post_id="(Required)"]

X

[wp_share_buttons_x type="(Optional)" title="(Optional)" post_id="(Required)"]

Threads

[wp_share_buttons_threads type="(Optional)" title="(Optional)" post_id="(Required)"]

Hatna Bookmark

[wp_share_buttons_hatena type="(Optional)" post_id="(Required)"]

Feedly

[wp_share_buttons_feedly type="(Optional)" post_id="(Required)"]

Pocket

[wp_share_buttons_pocket type="(Optional)" title="(Optional)" post_id="(Required)"]

Pinterest

[wp_share_buttons_pinterest type="(Optional)" post_id="(Required)"]

Line

[wp_share_buttons_line type="(Optional)" post_id="(Required)"]

Feed

[wp_share_buttons_feed type="(Optional)" post_id="(Required)"]

Copy URL

[wp_share_buttons_copy type="(Optional)" title="(Optional)" post_id="(Required)"]

Filter hooks

inc2734_wp_share_buttons_count_cache_seconds

/**
 * Set count cache time
 *
 * @param  {int} $seconds
 * @return {int}
 */
add_filter(
	'inc2734_wp_share_buttons_count_cache_seconds',
	function( $seconds ) {
		return 300;
	}
);

inc2734_wp_share_buttons_apply_https_total_count

/**
 * When permalink is https, whether or not to sum http and https
 *
 * @param  {bool} $bool
 * @return {bool}
 */
add_filter(
	'inc2734_wp_share_buttons_apply_https_total_count',
	function( $bool ) {
		return true;
	}
);

inc2734_wp_share_buttons_localize_script_handle

/**
 * Set handle of localize_script
 *
 * @param  {string} $handle
 * @return {string}
 */
add_filter(
	'inc2734_wp_share_buttons_localize_script_handle',
	function( $handle ) {
		return $handle;
	}
);

inc2734_wp_share_buttons_facebook_official_button_share

/**
 * Add facebook sahre button when using official facebook like button
 *
 * @param  {boolean} $boolean
 * @return {boolean}
 */
add_filter(
	'inc2734_wp_share_buttons_facebook_official_button_share',
	function( $boolean ) {
		return $boolean;
	}
);

inc2734_wp_share_buttons_shared_title

/**
 * Customize shared title
 *
 * @param  {string} $title
 * @param  {string} $service twitter or copy
 * @return {string}
 */
add_filter(
	'inc2734_wp_share_buttons_shared_title',
	function( $title, $service ) {
		if ( 'twitter' === $service ) {
			return $title . ' #hashtag';
		}
		return $title;
	},
	10,
	2
);

inc2734_wp_share_buttons_shared_hashtags

/**
 * Customize shared title
 *
 * @param  {string} $title
 * @param  {string} $service twitter or copy
 * @return {string}
 */
add_filter(
	'inc2734_wp_share_buttons_shared_hashtags',
	function( $hashtags, $service ) {
		if ( 'twitter' === $service ) {
			return 'hashtagA,hashtagB';
		}
		return $title;
	},
	10,
	2
);

inc2734_wp_share_buttons_count_cache_seconds

/**
 * Customize share count caching time
 *
 * @param $seconds
 * @return $seconds
 */
add_filter(
	'inc2734_wp_share_buttons_count_cache_seconds',
	function( $seconds ) {
		return $seconds;
	},
	10
);

inc2734_wp_share_buttons_facebook_app_token

/**
 * Set Facebook app token.
 *
 * @param string|false
 * @return string|false
 */
add_filter(
	'inc2734_wp_share_buttons_facebook_app_token',
	function( $token ) {
		return $token;
	},
	10
);

inc2734/wp-share-buttons 适用场景与选型建议

inc2734/wp-share-buttons 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.26k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2017 年 07 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 inc2734/wp-share-buttons 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 inc2734/wp-share-buttons 我们能提供哪些服务?
定制开发 / 二次开发

基于 inc2734/wp-share-buttons 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 7.26k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 14
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2017-07-16