diff --git a/bootstrap-shortcodes.php b/bootstrap-shortcodes.php
index 913d2ba..ce8435b 100644
--- a/bootstrap-shortcodes.php
+++ b/bootstrap-shortcodes.php
@@ -41,6 +41,7 @@ public function __construct() {
register_activation_hook( __FILE__, array( &$this, 'add_options_defaults' ) );
add_action( 'admin_init', array( &$this, 'register_settings' ) );
add_action( 'admin_menu', array( &$this, 'register_settings_page' ) );
+ add_action( 'wp_ajax_bss_do_shortcode', array( &$this, 'bss_do_shortcode') );
}
function init() {
@@ -63,6 +64,7 @@ function init() {
if ( get_user_option( 'rich_editing' ) == 'true' ) {
add_filter( 'mce_external_plugins', array( &$this, 'regplugins' ) );
add_filter( 'mce_buttons_3', array( &$this, 'regbtns' ) );
+ add_filter( 'tiny_mce_before_init', array( &$this ,'register_tinymce_settings') );
}
}
@@ -83,6 +85,21 @@ function regplugins( $plgs) {
return $plgs;
}
+ function register_tinymce_settings( $settings ) {
+ $settings['ajaxurl'] = admin_url( 'admin-ajax.php' );
+ $settings['bss_nonce'] = wp_create_nonce( 'bss_ajax_do_shortcode' );
+ return $settings;
+ }
+
+ function bss_do_shortcode() {
+ if( false === check_ajax_referer('bss_ajax_do_shortcode', 'nonce', false) ) {
+ _e( 'Security Issue - No Preview', 'bsshortcodes');
+ } else {
+ echo do_shortcode( wp_unslash( $_POST['shortcode'] ) ) ;
+ }
+ wp_die(); // this is required to terminate immediately and return a proper response
+ }
+
function register_settings_page() {
add_options_page( __( 'BS Shortcodes', 'bsshortcodes' ), __( 'BS Shortcodes', 'bsshortcodes' ), 'manage_options', __FILE__, array( &$this, 'dw_render_form') );
}
@@ -162,4 +179,4 @@ function dw_render_form() {
}
}
-$bscodes = new BootstrapShortcodes();
+$bscodes = new BootstrapShortcodes();
\ No newline at end of file
diff --git a/inc/bs_alert.php b/inc/bs_alert.php
index 90dd401..6d4cc0f 100644
--- a/inc/bs_alert.php
+++ b/inc/bs_alert.php
@@ -1,11 +1,12 @@
'unknown'
+ 'type' => 'unknown',
+ 'dismissible' => 'true'
), $params ) );
$content = preg_replace( '/
/', '', $content );
- $result = '