Category: Code Snippets
-
Google Tag Manager Tips
Google Tag Manager (GTM) is a great tool for managing tags. Tags like Facebook pixel, Google analytics, TikTok tracking, and many more scripts can be managed and deployed in one place. Here I will be adding tips and tricks related to GTM. Trigger Configuration Matches RegEx Matches RegEx will match strings based on the input…
-
WordPress Block Variation: Unlocking it’s Power
The WordPress Block Variation API allows developers to create variations of existing blocks, maintaining core functionality and scalability. Learn to create a block variation in detail.
-
Create a tag in Git
Creating tags from the command line To create a tag on your current branch, run the following commands in your terminal: Add -a to generate an Β annotated tag if you want to include a description with your tag:: This will generate a local tag containing the current state of the branch you’re working on. Tags…
-
Disable Gutenberg (Block Editor)
Totally disable Gutenberg in whole site Disable Gutenberg in specific Post type.
-
Gutenberg List all Blocks
If you want to get list of all blocks then you can use getBlockTypes from block store. We can use @wordpress/blocks package to retrieve block store. useSelect hook from @wordpress/data package will be used to access getBlockTypes function from block store. It can only be used in a component. Here is an example
-
Regex to match any number of white spaces
Incase we need to find any number of white spaces like for following silly example Here I want to replace header with another selector for example “section{“. So we want to match “header” tag, white spaces and “{” so that we only replace header selector. This is how we do in JavaScript: This is how…