Creating Your Own Theme Plugin
How to create your own theme for QuotesDLX.
Initializing the Theme
You'll want to create a custom plugin if you're creating a theme. You can then share the plugin if you'd like others to have your custom Quotes theme. If you want to sell your theme, please get in touch and we can work out an agreement.
The quotes_dlx_pre_themes_loaded Action
Before the themes are loaded in via code, the action quotes_dlx_pre_themes_loaded is triggered, which allows you to "hook" in and initialize your own themes.
From there, you can use the filter quotes_dlx_themes to add in your theme callback.
Here's a sample of how to do this using a composer autoloader with a PHP namespace:
<?php
/**
* Plugin Name: QuotesDLX Forest Theme
* Plugin URI: https://dlxplugins.com/plugins/quotesdlx/
* Description: Green forest theme for QuotesDLX.
* Version: 1.0.0
* Requires at least: 5.9
* Requires PHP: 7.2
* Author: MediaRon LLC
* Author URI: https://mediaron.com
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: quotes-dlx
* Domain Path: /languages
*
* @package QuotesDLX
*/
namespace MediaRonLLC\QuotesDLXThemes;
// Support for site-level autoloading.
if ( file_exists( __DIR__ . '/lib/autoload.php' ) ) {
require_once __DIR__ . '/lib/autoload.php';
}
/**
* Add your own theme to QuotesDLX.
*
* @param array $themes Existing themes that are to be registered.
*/
function add_themes( $themes ) {
$themes[] = __NAMESPACE__ . '\ForestTheme\Themes_Forest';
return $themes;
}
/**
* Theme initialization has begun.
*/
function theme_registration_init() {
// Init filter to add a theme to the defaults.
add_filter( 'quotes_dlx_themes', __NAMESPACE__ . '\add_themes' );
}
add_action( 'quotes_dlx_pre_themes_loaded', __NAMESPACE__ . '\theme_registration_init' );
One important note is when you use the quotes_dlx_themes filter callback, you must provide the class file of your theme initialization file (more on that in a bit).
You can expect the following if you inspect the $themes array, and you would add or subtract from this array depending on your needs.
After you've added in your own theme, it may look something like this:
The above expects the Themes_Forest class to be in a ForestTheme directory. Here's a snippet of the code for reference:
The Theme Initialization File
All of the themes extend a base class that assists in add-on registration. All you need is to extend the class and add in your own settings.
The Theme add-on class can be found here within the QuotesDLX plugin:
Your first task when creating the theme initialization file is to extend the Themes_Addon class.
In this case, you'd:
Set up a custom namespace for your file
Use the QuotesDLX Themes_Addon class as a reference
Extend the Themes_Addon class.
Here's the full code of the sample Forest theme as far as initialization.
Let's go over the important bits.
Theme Name/Label
This is the name or label of your theme. You can name your theme anything you like, but be mindful that you'll need a unique slug.
Theme Slug
This will be the slug you use in your stylesheet and also for saving theme options, so be sure it's unique.
Theme Category
Each theme can have a custom category. At the moment, there aren't enough themes to justify sorting, but this may be added in the future.
You can add your own custom categories by using the Themes_Addon_Categories class. For example, here is how the Core category is created.
And the location of the categories class.
Theme Version
Set your theme version here. This isn't being used at the moment, but it's a good practice to update your version with every theme update.
Theme Description
You would leave this empty and use a getter to return the theme's description.
Theme Author
Fill out your name here.
Theme Author URL
You can fill in your website domain here.
Preview Image Dimensions
For the preview that shows in the theme options, it is recommended to specify the exact size.
Preview Gradient
A preview gradient will show up in the block editor to showcase your primary and secondary colors.

Preview URL
You can leave this blank.
get_name
Use this to return a localized version of the name of the theme.
get_slug
This will return the slug for the theme.
get_preview_gradient
This will return the preview gradient set.
get_stylesheet_url
This will return the location to your CSS file for the theme.
get_preview_image_url
This will return the path to the image used in the theme preview.
get_theme_category
This will return the theme's category.
get_author
This will return the theme's author.
get_author_url
This will return the website for the theme's author.
get_description
Return a translatable theme description.
get_version
Return the theme's version.
get_image_width
Return the width of the image
get_image_height
Return the height of the image.
get_colors
Define your own colors, slugs, and labels for the theme.
You can add as little or as many colors as you would like. These colors will show up as swatches when customizing a theme's colors.

Last updated
Was this helpful?
