Custom Gutenberg Block (CGB) for the Ko-fi donation button.
Add your customised official Ko-fi button to your posts and pages.
This custom Gutenberg Block (CGB) for the Ko-fi donation button allows you to:
- Create an optional heading
- Add a short call-to-action prompt
- Insert your custom button text
- Choose a background colour using a built-in colour picker
- And of course, add your Ko-fi code or username
- Upload the contents of plugin zip file to the
/wp-content/plugins/will-work-for-ko-fi
directory, or install the plugin through the WordPress plugins page directly (wp-admin > Plugins > Add New > Upload Plugin). - Activate the plugin through the 'Plugins' page.
Edit: Will Work for Ko-fi_ needs the Lazy Blocks plugin to run properly. Please install Lazy Blocks.
- Open a page or post in Gutenberg.
- Click on the
+
to add a block. - Start typing "Will Work for Ko-fi" until you see the block appear, then select it.
- Inside the block, enter an optional heading or short description into the respective input fields.
- In the settings sidebar, enter the text you want on your button. This is important! Keep it short.
- In the settings sidebar, use the colour picker for the button's background.
- Remember to enter your Ko-fi code or username. This is also in the settings sidebar.
- Preview, Update, or Publish your page or post and enjoy ;-)
Live button preview in the block editor.
Check out the video of the new live button preview in the block editor.
Yes. It's only 47 KB zipped. And, it uses its' own local copy of the official Ko-fi widget JavaScript library.
It sure is. The Ko-fi button widget code comes from https://ko-fi.com/manage/widgets and it looks like this.
<script type='text/javascript' src='https://ko-fi.com/widgets/widget_2.js'></script>
<script type='text/javascript'>
kofiwidget2.init('Support Me on Ko-fi', '#29abe0', 'D1D7YARD');kofiwidget2.getHTML();
</script>
You can change the content alignment by using additional CSS. The additional CSS below will centre justify the WW4KOFI block contents.
.centre-this-block {
text-align: center;
width: 50%;
margin: 0 auto;
}
You can change the content alignment by using additional CSS. The additional CSS below will add slight padding to the contents and create a drop shadow effect.
.style-this-block {
padding: 1.5%;
border-radius: 10px;
box-shadow: 5px 20px 12px rgba(0,0,0,.2);
}
Version 2.1.0 introduced the .section__kofi
CSS class that controls the top/bottom padding for the widget's heading, description, and button.
.section__kofi {
padding-top: 0;
padding-bottom: 0;
}
No. Version 2.0.0 does not rely on any third-party plugins. Lazy Blocks is deprecated in v2.0.0.
I'm seeing a "This block contains invalid or unexpected content" error message. What must I do to fix it?
Click on the horizontal ellipses (...) on the right, then select Attempt Block Recovery.
See the screengrab below.
Built with Create Guten Block.
Will Work for Ko-fi coffee logo by walkerstudio13 from the Noun Project.