diff --git a/css/d12brt-admin-style.css b/css/d12brt-admin-style.css
new file mode 100644
index 0000000..9c5b08e
--- /dev/null
+++ b/css/d12brt-admin-style.css
@@ -0,0 +1,8 @@
+i.d12br-pause {
+ background-image: url(../icons/pause.png);
+ margin: 2px 6px 0 0;
+}
+i.d12br-ebook {
+ background-image: url(../icons/ebook.png);
+ margin: 2px 6px 0 0;
+}
diff --git a/css/d12brt-style.css b/css/d12brt-style.css
new file mode 100644
index 0000000..1efb8cb
--- /dev/null
+++ b/css/d12brt-style.css
@@ -0,0 +1,20 @@
+.dbr {
+ border: solid 1px #222;
+ margin: 1em auto;
+ vertical-align: middle;
+}
+
+.dbr_icon {
+ float: left;
+ vertical-align: middle;
+}
+.post-content .dbr_icon img {
+ border: none;
+ padding: 0.7em;
+}
+.dbr_message {
+ font-size: 1.2em;
+ font-weight: bold;
+ vertical-align: middle;
+ padding: 0.7em;
+}
diff --git a/d12-book-review.php b/d12-book-review.php
index 4f88fd4..4868039 100644
--- a/d12-book-review.php
+++ b/d12-book-review.php
@@ -3,7 +3,7 @@
Plugin Name: d12 Book Review Tools
Plugin URI: https://github.com/kjodle/d12-Book-Review-Tools
Description: Adds several useful shortcodes for writing book reviews on WordPress
-Version: 1.1
+Version: 1.2
Author: Kenneth John Odle
Author URI: http://techblog.kjodle.net
License: GPL2
@@ -12,25 +12,34 @@ Domain Path: /lang
Text Domain: d12brt
*/
+// Let's add our front end stylesheets:
function d12brt_scripts() {
- wp_register_style( 'd12brt-styles', plugin_dir_url( __FILE__ ) . 'd12brt-style.css' );
+ wp_register_style( 'd12brt-styles', plugin_dir_url( __FILE__ ) . '/css/d12brt-style.css' );
wp_enqueue_style( 'd12brt-styles' );
}
add_action( 'wp_enqueue_scripts', 'd12brt_scripts' );
+// Let's add our back end stylesheets:
+function d12br_admin_styles() {
+ wp_enqueue_style( 'd12bradminstyle', plugins_url( '/css/d12brt-admin-style.css', __FILE__, '1.0', 'screen' ) );
+}
+add_action( 'admin_enqueue_scripts', 'd12br_admin_styles' );
+
+// Add our "Spoiler" shortcode:
function spoiler_shortcode_handler() {
$spoiler = __( 'Warning: The rest of this post contains spoilers.' , 'd12brt' );
- echo '
' .
- $spoiler .
- '
';
+ echo '' .
+ '
' . $spoiler . '
' .
+ '
';
}
add_shortcode( 'spoiler', 'spoiler_shortcode_handler' );
+// Add our "eBook" shortcode:
function ebook_shortcode_handler() {
$ebook = __( 'This review is based on the ebook version of this title. Page numbers are not available.' , 'd12brt' );
- echo '
' .
- $ebook .
- '
';
+ echo '' .
+ '
' . $ebook . '
' .
+ '
';
}
add_shortcode( 'ebook', 'ebook_shortcode_handler' );
@@ -41,3 +50,21 @@ $myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
__FILE__,
'atticus-finch'
);
+
+/* Register a TinyMCE button */
+add_action( 'init', 'd12_book_review_buttons' );
+function d12_book_review_buttons() {
+ if ( current_user_can('edit_posts') && current_user_can('edit_pages') )
+ {
+ add_filter( "mce_external_plugins", "d12_br_add_buttons" );
+ add_filter( 'mce_buttons_2', 'd12_br_register_buttons' );
+ }
+}
+function d12_br_add_buttons( $plugin_array ) {
+ $plugin_array['d12_br'] = plugins_url( 'js/d12_br.js', __FILE__ );
+ return $plugin_array;
+}
+function d12_br_register_buttons( $buttons ) {
+ array_push( $buttons, 'd12-br-button' );
+ return $buttons;
+}
diff --git a/icons/ebook.png b/icons/ebook.png
new file mode 100644
index 0000000..29395d7
Binary files /dev/null and b/icons/ebook.png differ
diff --git a/icons/pause.png b/icons/pause.png
new file mode 100644
index 0000000..0f0c9df
Binary files /dev/null and b/icons/pause.png differ
diff --git a/js/d12-br-mce-button.png b/js/d12-br-mce-button.png
new file mode 100644
index 0000000..02e34cb
Binary files /dev/null and b/js/d12-br-mce-button.png differ
diff --git a/js/d12_br.js b/js/d12_br.js
new file mode 100755
index 0000000..adc994a
--- /dev/null
+++ b/js/d12_br.js
@@ -0,0 +1,32 @@
+(function() {
+ tinymce.create('tinymce.plugins.d12_br', {
+ init : function (ed, url) {
+ ed.addButton('d12-br-button', {
+ title:'Book Review Tools',
+ type:'menubutton',
+ image: url + '/d12-br-mce-button.png',
+ menu: [
+ {
+ text: 'Add a Spoiler Alert',
+ value: 'spoiler',
+ icon : 'icon d12br-pause',
+ onclick: function() {
+ ed.selection.setContent('[spoiler]');
+ }
+ },
+ {
+ text: 'Add an eBook Notice',
+ value: 'ebook',
+ icon : 'icon d12br-ebook',
+ onclick: function() {
+ ed.selection.setContent('[ebook]');
+ }
+ },
+ ]}); // end of ed.addButton
+ },
+ createControl : function(n, cm) {
+ return null;
+ },
+ }); // end of tinymce.create()
+ tinymce.PluginManager.add( 'd12_br', tinymce.plugins.d12_br );
+})(); // closes the first line