Add [ogrealert] shortcode
#2
@@ -2,7 +2,8 @@
|
|||||||
/**
|
/**
|
||||||
* @package CleverOgre
|
* @package CleverOgre
|
||||||
* @subpackage OgreAlert
|
* @subpackage OgreAlert
|
||||||
* @since OgreAlert 0.1.9
|
* @version 0.2.2
|
||||||
|
* @since 0.1.9
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace OgreAlert;
|
namespace OgreAlert;
|
||||||
@@ -15,6 +16,7 @@ class Display {
|
|||||||
if (is_admin()) return;
|
if (is_admin()) return;
|
||||||
|
|
||||||
add_action('wp', [__CLASS__, 'init']);
|
add_action('wp', [__CLASS__, 'init']);
|
||||||
|
add_shortcode('ogrealert', [__CLASS__, 'shortcode']);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function init() {
|
static function init() {
|
||||||
@@ -69,6 +71,13 @@ class Display {
|
|||||||
return $classes;
|
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 = []) {
|
private static function load_template($filename, $filepart = '', $echo = true, $vars = []) {
|
||||||
$path = \OgreAlert\Settings::get('path') . 'templates/' . $filename . '-' . $filepart . '.php';
|
$path = \OgreAlert\Settings::get('path') . 'templates/' . $filename . '-' . $filepart . '.php';
|
||||||
if (!file_exists($path)) {
|
if (!file_exists($path)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user