Applying the DRY Principle to the eCards Plugin

on in Blog
Last modified on

As part of a massive code cleanup, I am applying the DRY principle to the eCards plugin:

Don’t repeat yourself (DRY, or sometimes do not repeat yourself) is a principle of software development aimed at reducing repetition of software patterns, replacing it with abstractions or using data normalization to avoid redundancy.

The first candidate for this cleanup was the image attachment feature, custom coded as a metabox.

Attaching images like this is/was dangerous as images could get unattached from other posts or pages.

Attaching images is already possible in WordPress Media Library, using the list view. Also, metaboxes have been like second-class citizens since the block editor landed, and coding a Gutenberg-compatible inspector panel requires JavaScript, which, in my opinion, adds zero value for the eCards plugin.

So, we now have a bit of back-end performance gain by removing 2 JavaScript files and dequeuing the media/upload classes.


Related posts