diff --git a/theme-shortcode.php b/theme-shortcode.php new file mode 100644 index 0000000..b5a8626 --- /dev/null +++ b/theme-shortcode.php @@ -0,0 +1,40 @@ +'; + + public function __construct() { + add_shortcode( self::SHORTCODE, [ &$this, 'shortcode' ] ); + } + + public function shortcode( $attrs = [], $content = null ) { + $inp = (object) shortcode_atts( [ + 'src' => null, + 'alt' => null, + ], $attrs ); + + $theme_uri = is_child_theme() + ? get_stylesheet_directory_uri() + : get_template_directory_uri(); + + return sprintf( self::TPL_IMAGE, $theme_uri, $inp->src, $inp->alt ); + } +} +$plugin = new Theme_Shortcode_Plugin();