For a specific condition I needed to customize the result set of WordPress’ get_posts
function. Since I struggled a bit with it, I want to make sure that never happens again with this post.
Blog
Last week, I published a SCSS code to fix inaccurate color contrast calculations. It is a Dart Sass implementation and based on an older implementation. However, for another project I needed yet another implementation that was built with scssphp, which has an own implementation.
Continue reading WCAG 2 compliant SCSS color contrast function with scssphpWhen it comes to accessibility, the most common errors are contrast errors. And with an auto-contrast function in SCSS they seem to be fixed easily. But unfortunately, the vast majority of color contrast functions don’t work they way they should. At least not according to the WCAG 2 specifications.
Continue reading Fix your SCSS color contrast functionI’m glad to announce the release of Form Block, a dedicated block for the WordPress block editor to create highly customizable (contact) forms with ease.
Continue reading Release of Form Block v1.0.0While there is a did_action
and did_filter
to determine how often an action or a filter has been called, it works different then you might expect. Both work similar and only count whether do_action
or apply_filters
have been executed. They don’t check whether they have been actually used.
In your Mastodon profile, you can define up to four links individually. These links can be verified that they belong to you. So instead of using just plain links that look boring on your Mastodon profile, add them with the proper attribute to your website to get verified links.
Continue reading Properly add a Mastodon link to your WordPress siteWordPress websites typically have a specific purpose, which also means that there are some legal requirements in what you need to run the website. One of them is an imprint or at least a provider identification. But when do you need one of those and what information must it contain?
Continue reading Do I need an imprint on my WordPress website?Sometimes, you need to store unique data to a block to identify it later on. So you need to prevent having duplicate block attributes. In my case, I want to store a unique block ID. For this the clientId
is useful as it’s already unique per definition (it’s a universally unique identifier generated on every editor load for every block).
Since WordPress 5.9, there is the new function wp_enqueue_block_style
to enqueue block styles only if necessary, which means only if the associated block is rendered on the current page. While this is a huge benefit, there is no support for scripts. So if your block requires certain JavaScript only for the frontend, there’s no ready-to-use function within WordPress.
While adjusting color values in PHP, I searched for a way to transform rgb()
and rgba()
to its hex code equivalents since I like those more. And since the hex notation in CSS allows defining an alpha channel for this since quite some time, there’s no showstopper to build a solution for this. But since this alpha channel notation is relatively new, I couldn’t find any code snippet in the wild that does what I like to. So I wrote it myself.