From d2c08f0550d67124305b4a0efc768731eccaab14 Mon Sep 17 00:00:00 2001 From: kjodle Date: Mon, 29 May 2017 19:43:08 -0400 Subject: [PATCH] Committing version 1.2 --- css/d12brt-admin-style.css | 8 +++++++ css/d12brt-style.css | 20 +++++++++++++++++ d12-book-review.php | 43 ++++++++++++++++++++++++++++++------- icons/ebook.png | Bin 0 -> 424 bytes icons/pause.png | Bin 0 -> 723 bytes js/d12-br-mce-button.png | Bin 0 -> 1135 bytes js/d12_br.js | 32 +++++++++++++++++++++++++++ 7 files changed, 95 insertions(+), 8 deletions(-) create mode 100644 css/d12brt-admin-style.css create mode 100644 css/d12brt-style.css create mode 100644 icons/ebook.png create mode 100644 icons/pause.png create mode 100644 js/d12-br-mce-button.png create mode 100755 js/d12_br.js 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 '

pause button' . - $spoiler . - '

'; + echo '
pause button
' . + '
' . $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 button' . - $ebook . - '

'; + echo '
ebook button
' . + '
' . $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 0000000000000000000000000000000000000000..29395d741ffe2e19e0181509164be05a42bbec6d GIT binary patch literal 424 zcmV;Z0ayNsP)G`zkapg8M^xUOFz7Sw*!zilY7hM z;^_ENa;SJl^Lpvx>G2GRxGF)$vgV4lssL3Mk;ys8TiOtjv8OD&py2Lo z?IWdb!Oi%7evXHeqfSVT@Z;+@`nIdTV4fyk_WjluT;5HjT`B-o3UGGzW$QmE>%G+w zB_+DH*_f>!pGv8RcsEV7O~da8i#6q(@reI(9fqM9$8jI%d7f6oFkFq}7=HlJ6xq#| S!^D380000*yrH3?uby}R1iamd7aN^C3?**fJYyd? zfO_{1=I3=F7DKeQQpx3*xp8B7FPz;%Fc}JsH9dK9Ol7lBt%8)BrFkA$7UJkpzNAvG znpReh|0Q?>SB?w}+*O}HgJ~in5iktY;-bzH3W4jQ%4KjI#J+uu_4HirfO`U9_T)*m ztE&r&MMOAE{`PH*wl*S;14{8zDVUsOPhTHuVFBWC=7xt!WHLfNhjcudghBy)KCo?! z#zw3cFIWl$C;_`%m(?FXz_vAJW`??ClIM_?emF==3)Ix;plPC(m)R`@o)F;kQR_I^ z0G6dO!5}m@W5Yr7H-J*$_k$4nUR{M)O!q@6-47`>fn{lYBtjK14G^pc*9odsh{v@8 zDZ%GM+4g3FQVA1;{0^UZ{~kZhT&FsfB!YLR)&a1x1WPj zN&AHY4|{v>T!ia-5>3+{4~NGOJ$kfXRVup1?MzC9>yk^SKeQ`#7^vuZb)3rKrKOH+ zXXi^bF@b1k&|l^E>k|wj>g#c`Szf17FWaT;04iIS2?$?;Q|F~TSAY8S2^9`&$;Bd5 z&z@x-L;nMK3M_29jQ|o14{CuOfVuYU0KX(GdEjou{{hEp;-n9Q-M|0<002ovPDHLk FV1mHdL!kfw literal 0 HcmV?d00001 diff --git a/js/d12-br-mce-button.png b/js/d12-br-mce-button.png new file mode 100644 index 0000000000000000000000000000000000000000..02e34cb1971e70dd06e395d5c73dab6d2d0a864a GIT binary patch literal 1135 zcmV-#1d#iQP)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+++ 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