Add [ogrealert] shortcode #2

Merged
ogrecooper merged 2 commits from shortcode into master 2025-12-22 21:00:42 +00:00
Showing only changes of commit e7f5108b76 - Show all commits

View File

@@ -2,7 +2,8 @@
/**
* @package CleverOgre
* @subpackage OgreAlert
* @since OgreAlert 0.1.9
* @version 0.2.2
* @since 0.1.9
*/
namespace OgreAlert;
@@ -15,6 +16,7 @@ class Display {
if (is_admin()) return;
add_action('wp', [__CLASS__, 'init']);
add_shortcode('ogrealert', [__CLASS__, 'shortcode']);
}
static function init() {
@@ -69,6 +71,13 @@ class Display {
return $classes;
}
static function shortcode($atts) {
$atts = shortcode_atts([], $atts, 'ogrealert');
ob_start();
do_action('display_alerts');
return ob_get_clean();
}
private static function load_template($filename, $filepart = '', $echo = true, $vars = []) {
$path = \OgreAlert\Settings::get('path') . 'templates/' . $filename . '-' . $filepart . '.php';
if (!file_exists($path)) {