Dublin Library

The Publishing project

Revisiting multi-column text

This set of features related to multi-column text is near and dear to my heart. I first researched this feature when I wrote about it for the Web Platform Documentation Project since retired. The idea is to let the browser take care of creating the columns and the details about the columns, the gap, and other elements. We can also play with headers and how they span across the columns. Browser support, as always, is the stumbling block for using columns across browsers but it appears to be better than when I first tried it. I searched caniuse.com for column-...

Using gulp-libsquoosh to replace Imagemin

All my Javascript projects include imageminhttps://github.com/imagemin/imagemin/, a tool that allows you to convert images between different formats and do some level of processing to the images as it converts them. Unfortunately, the project is in life support mode and the original maintainer stopped working on it years ago according to the pinned issuehttps://github.com/imagemin/imagemin/issues/385 in the repository issue tracker. So it's time to take a look at the alternatives and see how well they work in a Gulphttps://gulpjs.com/\-based Javascript project. Squooshhttps://squoosh.app/ is an image compression and manipulation tool. The main difference between Squoosh and Imagemin is that Squoosh has created WebAssemblyhttps://webassembly.org/...

Creating epub3 content.opf file

One of the hardest files in an epub book is the content.opf manifest file. This file tells an epub reader what files are in a specific rendition of an ebook. There are three components to a content.opf file: Metadata : Provides information about the book using a combination of meta tags and Dublin Core metadata elements : The normative reference is in the EPUB 3.2 package specification metadata sectionhttps://www.w3.org/publishing/epub3/epub-packages.htmlsec-pkg-metadata Manifest : The manifest element provides an exhaustive list of the Publication Resources that constitute the given Rendition, including the media type, the file path and the media encoding : See...

Plugin Topics: JSON Block Configuration

Starting in WordPress 5.8, there is a JSON metadata file we can use to register blocks. The block.json file is the block-level equivalent to theme.json and is now the preferred way to register blocks. The following example contains a block.json definition for a fictional my-plugin/notice block. json { "apiVersion": 2, "name": "my-plugin/notice", "title": "Notice", "category": "text", "parent": "core/group" , "icon": "star", "description": "Shows warning, error or success notices…", "keywords": "alert", "message" , "version": "1.0.3", "textdomain": "my-plugin", "attributes": { "message": { "type": "string", "source": "html", "selector": ".message" } }, "providesContext": { "my-plugin/message": "message" }, "usesContext": "groupId" , "supports": { "align": true...

Plugin Topics: Meta boxes in the Block Editor

Meta boxes work in Gutenberg but they may not do so for a while or be the best solution for your needs. During the full migration to the Block Editor, WordPress Provides two compatibility flagshttps://make.wordpress.org/core/2018/11/07/meta-box-compatibility-flags/. Most of the time the compatibility setup works out of the box. However, you must test the meta boxes on Gutenberg to make sure the code will still work and that you won't need to write new blocks to handle the meta box data. You also need to modify the addmetabox function to look like the example that follows: php true, 'backcompatmetabox' => false, ;...

Color.js A CSS Color Tool in Javascript

CSS Color Module Level 4https://drafts.csswg.org/css-color-4/ and level 5https://drafts.csswg.org/css-color-5/ introduce a lot of new color features but unless you're really into the guts of working with colors on computers you probably wouldn't know how to use them. There is also an issue of browser uneven support for colors on the web, which is a large problem for developers. When the graphical web first came online it was in low-resolution monitors, 640 x 480 was the norm and RGB was the only color space that we had to worry about. As technology improved, displays got bigger and grew beyond RGB and what...

Plugin Topics: Thinking about privacy

Privacy in the context of a web application like WordPress goes beyond legal requirements. It's also answering the following questions: What information we collect Why we collect it How we use it How we protect it Taken from ISO 29100/Privacy Framework standardhttps://www.iso.org/standard/45123.html, the following checklist provides a good starting point for thinking about privacy in general but more applicable in the context of a WordPress plugin that collects data from users and uses that data to create a service or site: Consent and choice: giving users and site visitors choices and options over the uses of their data, and requiring...

Plugin Topics: Adding Plugin Admin Pages

If we want to allow users to configure our plugin, we can add menus to the admin pages either as a top-level menu or a submenu of an existing menu. When used with the settings and options APIs we get control of how users configure the plugin from the admin area, assuming that they have permission to do so. Top Level Menus Top-Level Menushttps://developer.wordpress.org/plugins/administration-menus/top-level-menus/ are what people see when they first view the admin area. This means that our admin page has more visibility but, depending on the plugin, it may be better to use a submenu The first step...

Plugin Topics: Meta Boxes and Cron

The next few items Meta Boxes, and Cron are nice to have, require a lot more work, and are not necessary for the majority of plugin projects. I include them here because I'm interested in what they do and can think of a few projects that would benefit from one or more of them. Custom Meta Boxes Custom Meta Boxeshttps://developer.wordpress.org/plugins/metadata/custom-meta-boxes/ allows you to create custom sections of the editor screen where users can enter custom data and you can then sanitize it and save it to the database. Because they allow custom data we need to follow all the security...

Additional considerations for OOP plugin development

Rather than writing plugins or any PHP code procedurally, we can leverage Object-Oriented Programming OOP to write our plugins. OOP is easier to maintain and extend as the needs of the plugin increase. The code below is a good starting point for class-based plugins. It doesn't have the full plugin comment but the code should still work even if it does nothing yet. php setupactions; } / Setting up Hooks / public function setupactions { //Main plugin hooks registeractivationhook FILE, array 'AwesomePlugin', 'activate' ; registerdeactivationhook FILE, array 'AwesomePlugin', 'deactivate' ; } / Activate callback / public static function activate {...