Dublin Library

The Publishing project

Implementing Quotebacks in WordPress

Quotebacks are an interesting way to cite content from other websites. They work in two stages. Installing the extension and getting the quotations The first one is HTML formatted with special data attributes, a footer and a link to the script. There are browser extensions to create this code, one for Chrome and one for Firefox currently under development. Once the extension is installed, go to a page, select text and press command + shift + S on Mac and control + shift + S on Windows !The result of highlighting text and pressing command/control + shift + S to...

Continue reading →

Building a Network Navigator

In 1987 Apple released this concept video of what they called a Network Navigator, an integrated agent to manage data from different sources, communicate with people across the network, and share information regardless of the source and its location. It may seem quaint to us now, 30 years later but the real question is whether the tools have evolved to the point where it is possible to build such technology. This post will explore some of the current technologies that would make such a project feasible and discuss potential future implementations. This is a theoretical exploration rather than a working...

Continue reading →

Reviewing Lazy Loading in WordPress

In the not too distant future, WordPress will have lazy loading by default in WordPress corehttps://make.wordpress.org/core/2020/01/29/lazy-loading-images-in-wordpress-core/ enabled by default. I believe that this will be merged into WordPress core for the 5.5 release; until then, development is done on a feature pluginhttps://wordpress.org/plugins/wp-lazy-loading/ for people to continue working on it. But the problem is that this is enabled by default. As with many of the later decisions by the WordPress core team, this is good for beginners but I can think of at least two instances where lazy loading is not what I want to use: - Header images at the...

Continue reading →

Inline scripts in WordPress

There are times when we need to add scripts to the page that will run only when there is a script already enqueued and loaded before it happens. I got bit by this when trying to use FontFaceObserver. For some reason, it worked fine in development but it would give a FontFaceObserver is not defined error when I moved the theme to production. The solution was hidden in some older documentation. As of version 4.5 there is an additional script loading function for loading inline scripts: wpaddinlinescript. This function allows adding inline scripts that depend on scripts The only important...

Continue reading →

Using ES modules in Node

Node has had experimental support for EcmaScript moduleshttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules for a while. Again, this is one thing I've wanted to explore for a while but have never felt the need to dig deeper. After all, it is experimental and it hasn't been approved for production use. But wit the release of Node 14 we're coming to the point when module support moved to stable. So let's explore what it takes to run ES Modules in Node on their own and together with current Node modules. What will Node consider an ES Module? There are certain file extensions and conditions that will...

Continue reading →

Internationalizing WordPress Themes and Plugins (part 2)

Internationalizing a plugin After setting up the text domain in your plugin metadata we need to load the translated files to use them. For plugins we use the load\plugin\textdomainhttps://developer.wordpress.org/reference/functions/loadplugintextdomain/ function; it takes 4 parameters: 1. The name of text domain 2. This parameter is deprecated so always use FALSE 3. The path to the directory where your plugin's translations are stored Then add an action for the pluginsloaded hook and call the function we just created. php { return { 'Hello World', 'myguten' } ; }, save: => { return { 'Hello World', 'myguten' } ; }, } ; This...

Continue reading →

Internationalizing WordPress Themes and Plugins (part 1)

According to GALA Globalization and Localization Alliancehttps://www.gala-global.org/language-industry/intro-language-industry/what-internationalization: > Internationalization is a design process that ensures a product usually a software application can be adapted to various languages and regions without requiring engineering changes to the source code. Think of internationalization as readiness for localization... Some practical examples of how internationalization is critical to multilingual products include: > > - Independence from a specific language/character set encoding > - Independence from specific cultural conventions > - Removal of hard-coded text > - Minimization of concatenated text strings > - Careful use of in-line variables > - Compatibility with third-party tools >...

Continue reading →

Security Hardening WordPress

WordPress security is as good as you make it and you can always make it better. This post will discuss tools and techniques for making your WordPress installation more secure. Some of these are default choices in WordPress but some are not only not the defaults but you have to manually add to configuration files or .htaccess files. Some of these rules will make local development harder as we expect constant change. However, these are excellent for production sites where we don't expect major changes and we expect them to be slower in adopting new code. This post links to...

Continue reading →

WordPress CMS CRUD (Part 5): Adding attributes to a REST API endpoint

When working with APIs we should never, under any circumstance, remove elements from the endpoint. Even if you're the owner there is no real way to know who's consuming your data and how they are doing it so removing elements of the API can cause unexpected and unpleasant problems down the road. However, there is no problem with adding attributes to your custom endpoints. This post will discuss how to do it using built-in WordPress functions and coding practices. Before we jump into adding attributes we need to ask ourselves if we need a new attribute or if we can...

Continue reading →

WordPress CMS CRUD (part 4): Creating custom post types and adding them to the REST API

One of the things I've always liked about WordPress is its flexibility. We can extend WordPress and create pretty much any type of content that we need for specific projects. We can choose whether to build it inside a theme or a plugin. For the most part I would recommend building it in a plugin so that we will retain the capability even if we switch themes. Like all plugins we first declare a preamble that looks like this. This is the block that makes it a plugin that we can load and use. php The actual meat of the...

Continue reading →