承接 aristath/gh-sponsors-list 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

aristath/gh-sponsors-list

Composer 安装命令:

composer require aristath/gh-sponsors-list

包简介

Show a list of your GitHub Sponsors in your plugins and themes.

README 文档

README

So, you're a WordPress developer and you have a GitHub Sponsors account? Great. If you don't already have one, you can create it on github.com/sponsors.
Now that you have your account and a few sponsors, you want to show your appreciation and include them as sponsors in all your open-source projects.
This is where this simple class comes in. It retrieves your sponsors from the GitHub Sponsors API, and prints them wherever you want.

Step 1: Create a new Github token.

First of all you're going to need a new Personal Access Token on GitHub. To create one, go to github.com/settings/tokens and create a new token.
IMPORTANT: Do not add any permissions to your token. The token you create will be used for API authentication and doesn't serve any other purpose. As such, it does not require any permissions. I'd advise you not to add any permissions to your token.

Copy this token, we'll need it later.

Step 2: Encode the token if your plugin/theme is on GitHub

As a security precaution, GitHub automatically revokes tokens if they are found in a public repository. You will therefore need to encode it so you can add it to your product without GitHub complaining.
To do that, open the console in your browser and paste the following inside it, replacing 'YOUR_TOKEN_HERE' with your actual token:

function convert_token( token ) {
  let result = '';
  token.split( '' ).forEach( function( char ) {
		let charHex = parseInt( char, 16 ).toString();
		charHex = 1 === charHex.length ? '0' + charHex : charHex;
		result += charHex;
	});
	console.log( result );
}
convert_token( 'YOUR_TOKEN_HERE' );

Once you do that, you'll see your encoded token printed in the console. Got it? Great. Copy it, we'll need it later.

Step 3: Add a function to print the sponsors

We'll now create a new function to print the sponsors.

/**
 * Print GitHub Sponsors.
 *
 * @return void
 */
function my_plugin_or_theme_the_github_sponsors() {

	// Require the class.
	if ( ! class_exists( '\Aristath\GHSponsors' ) ) {
		require_once 'gh-sponsors-dashboard/Sponsors.php';
	}

	// Init the object.
	$sponsors = new \Aristath\GHSponsors();

	// Set the token.
	$sponsors->set_token( 'MY_ENCODED_TOKEN', true );

	// Set the username.
	$sponsors->set_gh_username( 'aristath' );

	// Uncomment this line to not add CSS.
	/* $sponsors->add_styles = true; */

	// Manually inject a sponsor.
	$sponsors->add_sponsor(
		[
			'name'    => 'aristath',
			'url'     => 'https://aristath.github.io',
			'img'     => 'https://avatars0.githubusercontent.com/u/588688?s=460&u=b2865bad64212673fc4ab425231e0a61aa9a2193&v=4',
			'classes' => 'round',
		]
	);

	// Get GitHub Sponsors from the API.
	$sponsors->add_sponsors_from_api();

	// Print the sponsors.
	$sponsors->the_sponsors_details();	
}

Things to note:

  • Obviously my_plugin_or_theme_the_github_sponsors is a bad name for a function, choose something nice.
  • In the $sponsors->set_token() call, replace MY_ENCODED_TOKEN with the encoded token you got in step 2.
  • The $sponsirs->add_sponsor() call can be used to manually inject a sponsor. Perhaps your company or a cousin is sponsoring you, but not via GitHub Sponsors. It's cool if you show your appreciation, this is how you do it.

Step 4:

Call the function you created anywhere. You can add it in your plugin or theme's admin page, its about page or anywhere else you want.

Everything I build is open-source (see pledge). If you like this project, it helps you out in any way and want to support me, you can become a sponsor. Every little bit helps, you can visit github.com/sponsors/aristath to help out and show your appreciation.

aristath/gh-sponsors-list 适用场景与选型建议

aristath/gh-sponsors-list 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 10 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 aristath/gh-sponsors-list 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-03