Committing version 1.2

This commit is contained in:
kjodle 2017-05-29 19:43:08 -04:00
parent dda7a51696
commit d2c08f0550
7 changed files with 95 additions and 8 deletions

View File

@ -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;
}

20
css/d12brt-style.css Normal file
View File

@ -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;
}

View File

@ -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 '<div><p id="spoiler_notice"><img id="d12brtspoil" src="' . plugin_dir_url( __FILE__ ) . 'images/pause.png" alt="pause button" />' .
$spoiler .
'</p></div><div style="clear:both;"></div>';
echo '<div class="dbr"><div class="dbr_icon"><img src="' . plugin_dir_url( __FILE__ ) . 'images/pause.png" alt="pause button" /></div>' .
'<div class="dbr_message">' . $spoiler . '</div>' .
'<div style="clear:both;"></div></div>';
}
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 '<div><p id="ebook_notice"><img id="d12brtebook" src="' . plugin_dir_url( __FILE__ ) . 'images/ebook.png" alt="ebook button" />' .
$ebook .
'</p></div><div style="clear:both;"></div>';
echo '<div class="dbr"><div class="dbr_icon"><img src="' . plugin_dir_url( __FILE__ ) . 'images/ebook.png" alt="ebook button" /></div>' .
'<div class="dbr_message">' . $ebook . '</div>' .
'<div style="clear:both;"></div></div>';
}
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;
}

BIN
icons/ebook.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 424 B

BIN
icons/pause.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 723 B

BIN
js/d12-br-mce-button.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

32
js/d12_br.js Executable file
View File

@ -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