
Copy-paste snippets for blocks, block themes, security, performance, Tailwind CSS, PHP and React. New snippets every Monday, Wednesday and Friday, each one run in a real WordPress before it is published.

YOURSERVER = Example (ftp.markokrstic.com) Navigate to the settings > Secrets Add your secrets Get more actions examples https://github.com/marketplace/actions/sftp-deploy

Print the server port and http/https in the WordPress footer, visible to administrators only, escaped and safe to leave on while debugging.

Code Snippet Creating a custom webpack configuration file for @WordPress/Scripts Create “webpack.config.js” in the plugn root

As I never menaged to set up WordPress/Scripts –hot I prefer to use Browser Sync Install NPM After instaling NPX Create block run: Then in the package.json update scripts section Replace ‘dev-wordpress.local’ with your local websute URL

With this workflow in place, creating a new release is as simple as pushing a version tag to your repository. The GitHub Action takes care of everything else for you. It checks out your code, sets up Node.js (using the latest LTS version), and installs your project’s dependencies if a package.json file is present. Once…

Deleting the .git folder may cause problems in your git repository. If you want to delete all your commit history but keep the code in its current state, it is very safe to do it as in the following: Checkout/create orphan branch (this branch won’t show in git branch command): Add all the files to…

Add a private Dev Notes page to the WordPress admin for administrators: rich text, tables, images, autosave and an HTML view, no plugin.

Place this in function.php or use Scripts Organizer Code Snippet. We’ll let WordPress think it’s a block theme so the Editor shows up, but we’ll override template loading to use PHP templates like index.php. In your functions.php, override the block template resolution like this: This forces WordPress to always use index.php for rendering the front-end…

Disable the default WordPress core block patterns and the Pattern Directory patterns so the inserter only shows your theme’s own patterns.

A WordPress countdown timer shortcode: days, hours, minutes and seconds to a date in your site’s timezone, styled with Tailwind CSS classes.

Make @wordpress/components on a WordPress plugin settings page look like in the block editor by loading the core component styles on that page only.

Limit WordPress wp-admin and wp-login.php to an IP allowlist with PHP, keep AJAX, REST and cron working, with a wp-config off switch.

One of our customer requested a code snippet to write a function which will check that if current post or page has a specific Oxygen template assigned.

Disable emojis in WordPress: remove the emoji script and styles on the front end and in wp-admin, plus the feed, email and TinyMCE emoji handling.

When a WordPress search finds exactly one post, page or product, send the visitor straight to it instead of a results page with one item.

Hide the WordPress admin bar on the front end for subscribers, customers or any role you list, or for everyone, without a fatal error.

This code allows you to blur the background when someone triggers a modal, it helps put focus on the modal and not the background. The blur strength can be adjusted as needed. Add this to the main style sheet.

Here’s a PHP snippet that you can use to return a custom link to a specific language for the current page using WPML. This will output the custom link for the specified language code and can be used on any page. Example 1: This will output a link that says “Switch to French” and links…
3rd party plugins actions admin archive block-themes block editor Blocks block theme build capabilities core CSS Custom Post custom post types Developer development filters full site editing gutenberg hook hooks Image img load styles maintenance media mu-plugin Must Have npm Oxygen performance php plugins rest api scripts organizer security single product theme.json Tips updates users WooCommerce wordpress wp-cli WP Admin