Add shortcode
This commit is contained in:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user