Solution to “Font from origin ‘http://cdn.domain.com’ has been blocked from loading by Cross-Origin Resource Sharing policy”

I recently discovered icon fonts on the website of my ProfilePress WordPress plugin weren’t displaying. On viewing my browser console, i saw the following error notice logged.

Font from origin ‘http://d2hkd6cwxvu8h1.cloudfront.net’ has been blocked from loading by Cross-Origin Resource Sharing policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://profilepress.net’ is therefore not allowed access.

Apparently, the browser was blocking connection from profilepress.net to its cloudfront CDN because of the restriction of browser’s same origin policy whereby siteA cannot fetch content from siteB unless via Cross-Origin Resource Sharing (CORS) in which response from siteB include a Access-Control-Allow-Origin header granting permission to siteA.…

How to Make WordPress Admin Notices Actually Dismissible

WordPress 4.2 introduced a feature where admin notices can now be dismissed / removed from the admin page currently being viewed.

One caveat I discovered was, the dismissal do not persist across pages. That is, when you reload or navigate away from the current admin page to another, you will still see the notice.

I wrote a small library / plugin that elegantly solves this problem which i will be sharing to us.…

Signing Git Commits & Tags with GPG2 and Verified on GitHub

So i got myself a MacBook PRO and finally made the switch to Mac world after a long time being a Windows user.

One of the things i have been meaning to do was to GPG sign my git commits. Setting up my new MacBook proves to be the perfect time and finally, i did it.

The web has a number of tutorials that shows how to sign git commits with GnuPG (GPG) but none with GPG version 2.…

Dealing With “Detached HEAD” State in Git

When you pull in branches from your repository remote or upstream by running say git pull origin master (to pull changes from origin master branch) or git pull upstream non-breaking-space to pull in non-breaking-space branch from upstream; checking out any of these remote branch (e.g. git checkout upstream/non-breaking-space) will result in detached HEAD state because they aren’t proper branches as they do not (currently) exist locally.…

WordPress Customizer – Range Control with Selected Value Indicator

The WordPress customizer, formerly know as theme customizer allows administrator(s) and/or owner to customize and control the appearance of their WordPress powered website via an intuitive, click-and-drag interface.

The Customization API allows theme and plugin developers to customize and add controls to the “Appearance” → “Customize” admin screen.

In this tutorial, I won’t go over the steps on how to leverage or integrate customizer in your theme or plugin.…

Git: Merge a Specific Commit From One Branch to Another

While working on one of my side projects version controlled by Git, I needed to copy and merge a commit from say BranchB to BranchA. Scenarios like this is where git cherry-pick comes in handy.

A cherry-pick is like a rebase for a single commit. It takes the patch that was introduced in a commit and tries to reapply it on the branch you’re currently on.…