I wanted to output the current versions of specific plugins automatically and the parent theme (I am using a child theme), just to draw attention to what is…

I wanted to output the current versions of specific plugins automatically and the parent theme (I am using a child theme), just to draw attention to what is being used. Originally, I thought I would limit it to Bricks, but I immediately had a need to use it in Etch, so I opted for the shortcode approach.

The shortcode syntax

Here are examples of the shortcodes (you would wrap with brackets []). In Etch, you can add shortcodes in the builder without quotations (at least for now). If you are adding this in Core, you would need to wrap values in quotes (e.g., plugin_version slug=”automaticcss-plugin”).

  • Plugin
    • plugin_version slug=akismet/akismet.php
    • plugin_version slug=automaticcss-plugin
  • Theme
    • theme_version (active/child)
    • theme_version which=parent
    • theme_version which=twentytwentyfive

The Code

<?php
/**
 * Plugin Name: FW Versions (Themes & Plugins)
 * Description: Output current versions of selected plugins/themes via shortcodes & Bricks dynamic data/echo.
 * Version: 0.2.0
 * Requires at least: 6.0
 * Tested up to: 6.8.3
 */

// ---------- Helpers -----------------------------------------------------------

if ( ! function_exists( 'fw_get_plugin_version' ) ) 

if ( ! function_exists( 'fw_get_theme_version' ) ) 
if ( ! function_exists( 'fw_get_wp_version' ) ) 
// ---------- Shortcodes --------------------------------------------------------

/**
 * [plugin_version slug="akismet/akismet.php"] or [plugin_version slug="akismet"]
 */
add_shortcode( 'plugin_version', function( $atts ) );

/**
 * [theme_version] (active/child), [theme_version which="parent"], or [theme_version which="twentytwentyfive"]
 */
add_shortcode( 'theme_version', function( $atts ) );

/**
 * [wp_version] or [wp_version prefix="WordPress "]
 */
add_shortcode( 'wp_version', function( $atts ) );
<?php
/**
 * Plugin Name: FW Versions (Themes & Plugins)
 * Description: Output current versions of selected plugins/themes via shortcodes & Bricks dynamic data/echo.
 * Version: 0.2.0
 * Requires at least: 6.0
 * Tested up to: 6.8.3
 */

// ---------- Helpers -----------------------------------------------------------

if ( ! function_exists( 'fw_get_plugin_version' ) ) 

if ( ! function_exists( 'fw_get_theme_version' ) ) 
if ( ! function_exists( 'fw_get_wp_version' ) ) 
// ---------- Shortcodes --------------------------------------------------------

/**
 * [plugin_version slug="akismet/akismet.php"] or [plugin_version slug="akismet"]
 */
add_shortcode( 'plugin_version', function( $atts ) );

/**
 * [theme_version] (active/child), [theme_version which="parent"], or [theme_version which="twentytwentyfive"]
 */
add_shortcode( 'theme_version', function( $atts ) );

/**
 * [wp_version] or [wp_version prefix="WordPress "]
 */
add_shortcode( 'wp_version', function( $atts ) );