Category: Code Snippets

  • How to customize WebPack config in modern WordPress block development

    I find myself continuing to dive deeper and deeper into WordPress block development, and the frustrating part is a lack of documentation. So here is a quick post on something I struggled with for a little a bit in the hopes it helps someone else. block.json has some pretty cool features like render, style, viewScript, […]

    Categories: , , ,
  • How to protect your WordPress site from problematic code in the_content

    By default, WordPress lets you write basically anything in the content of a page, post, or custom post type. When you write or see the_content like this in a WordPress template: That’s likely allowing any code through. Even content that could be problematic. Problematic code would include raw iframes and JavaScript scripts. For example, let’s […]

    Categories: ,
  • How to create unique widget areas for individual posts in WordPress

    Here’s a cool little trick for adding widget areas that are unique to posts, but without cluttering up Appearance->Widgets in the admin. Instead, we utilize the Customizer, which is perfect for this sort of thing. First thing, we need to hook a function into `init` where we register our widget area.

    Categories: ,
  • Use jQuery to center element in viewport

    I wrote this bit of code for a knock-off Google Image UI I’ve recently been working on. Like Google Image search, my UI opens the image details below the thumbnail on click. Within those image details are forward and back arrows to navigate previous and next images. This script adjusts the vertical scroll as I click […]

    Categories: , ,