innocode-digital/wp-block-social-share

此包已被放弃,不再维护。作者建议使用 wp-digital/wp-block-social-share 包。

链接到分享当前帖子到常用的社交平台,如Facebook、Twitter、电子邮件、LinkedIn。

安装: 73

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 10

分支: 0

开放问题: 0

类型:wordpress-plugin

2.5.1 2023-06-21 11:54 UTC

This package is auto-updated.

Last update: 2023-06-21 11:54:51 UTC


README

描述

链接到分享当前帖子到常用的社交平台,如Facebook、Twitter、电子邮件、LinkedIn。

演示

社交分享块

安装

  • 首选方法是使用 Composer

    composer require wp-digital/wp-block-social-share
    
  • 另一种方法是克隆此仓库到 wp-content/plugins/

    cd wp-content/plugins/
    git clone git@github.com:wp-digital/wp-block-social-share.git
    

使用 WP-CLI 激活 社交分享块,命令为 wp plugin activate wp-block-social-share 或从 插件 页面激活。

文档

通过钩子 wpd-block-social-share-socials 添加、更改或删除社交。如果添加了新的社交平台,则需要通过 wpd-block-social-share-$social-url 过滤器实现其URL。 示例

add_filter( 'wpd-block-social-share-socials', function ( array $socials ) : array {
	unset( $socials['linkedin'] );

	$socials['pinterest'] = [
		'label' => esc_html__( 'Share on Pinterest', 'your-text-domain' ),
		'icon'  => '<svg viewBox="0 0 496 512" xmlns="http://www.w3.org/2000/svg" role="img" aria-hidden="false" focusable="false"><path d="M496 256c0 137-111 248-248 248-25.6 0-50.2-3.9-73.4-11.1 10.1-16.5 25.2-43.5 30.8-65 3-11.6 15.4-59 15.4-59 8.1 15.4 31.7 28.5 56.8 28.5 74.8 0 128.7-68.8 128.7-154.3 0-81.9-66.9-143.2-152.9-143.2-107 0-163.9 71.8-163.9 150.1 0 36.4 19.4 81.7 50.3 96.1 4.7 2.2 7.2 1.2 8.3-3.3.8-3.4 5-20.3 6.9-28.1.6-2.5.3-4.7-1.7-7.1-10.1-12.5-18.3-35.3-18.3-56.6 0-54.7 41.4-107.6 112-107.6 60.9 0 103.6 41.5 103.6 100.9 0 67.1-33.9 113.6-78 113.6-24.3 0-42.6-20.1-36.7-44.8 7-29.5 20.5-61.3 20.5-82.6 0-19-10.2-34.9-31.4-34.9-24.9 0-44.9 25.7-44.9 60.2 0 22 7.4 36.8 7.4 36.8s-24.5 103.8-29 123.2c-5 21.4-3 51.6-.9 71.2C65.4 450.9 0 361.1 0 256 0 119 111 8 248 8s248 111 248 248z" /></svg>',
	];

	return $socials;
} );
add_filter( 'wpd-block-social-share-pinterest-url', function ( string $url, int $post_id ) : string {
	return add_query_arg( [
		'url'  	      => get_the_permalink( $post_id ),
		'description' => get_the_title( $post_id ),
	], 'https://pinterest.com/pin/create/button/' );
}, 10, 2 );