mirror of
https://github.com/ulaulaman/book-template.git
synced 2025-01-03 16:09:20 +01:00
Prova aggiunta bottone
This commit is contained in:
parent
fcd4e36262
commit
9e5b4ac8f0
19
assets/js/tinymce-buttons.js
Normal file
19
assets/js/tinymce-buttons.js
Normal file
@ -0,0 +1,19 @@
|
||||
/**
|
||||
* TinyMCE buttons for custom shortcodes
|
||||
*/
|
||||
( function() {
|
||||
tinymce.create( 'tinymce.plugins.Bookdata', {
|
||||
init: function( ed, url ) {
|
||||
ed.addButton( 'bookdata', {
|
||||
title: 'Bookdata',
|
||||
/** image: url + '/img/tinymce-sample.png', */
|
||||
onclick: function() {
|
||||
title = prompt( "Enter title", "" );
|
||||
ed.execCommand( 'mceInsertContent', false, '[bookdata title="' + title + '"]' );
|
||||
}
|
||||
});
|
||||
},
|
||||
createControl: function( n, cm ) { return null; },
|
||||
});
|
||||
tinymce.PluginManager.add( 'bookdata', tinymce.plugins.PilauSample );
|
||||
})();
|
@ -2,7 +2,7 @@
|
||||
/*
|
||||
Plugin Name: Book Template
|
||||
Description: Plugin che aggiunge uno shortcode per la creazione di un box con i dati editoriali di un libro o di un fumetto.
|
||||
Version: 2020.0813
|
||||
Version: 2020.0814.dev
|
||||
Author: Gianluigi Filippelli
|
||||
Author URI: http://dropseaofulaula.blogspot.it/
|
||||
Plugin URI: https://ulaulaman.github.io/book-template/
|
||||
@ -116,5 +116,37 @@ add_shortcode( 'bookdata', 'bookdata' );
|
||||
return $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add TinyMCE buttons for shortcode
|
||||
*/
|
||||
|
||||
add_action( 'init', 'bookdata_tinymce_shortcode_buttons' );
|
||||
|
||||
add_filter( 'tiny_mce_version', 'bookdata_refresh_tinymce' );
|
||||
function pilau_tinymce_shortcode_buttons() {
|
||||
// Don't bother doing this stuff if the current user lacks permissions
|
||||
if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) )
|
||||
return;
|
||||
// Add only in Rich Editor mode
|
||||
//if ( get_user_option( 'rich_editing' ) == 'true' ) {
|
||||
// add_filter( 'mce_external_plugins', 'pilau_tinymce_plugins' );
|
||||
// add_filter( 'mce_buttons', 'pilau_register_tinymce_shortcode_buttons' );
|
||||
//}
|
||||
}
|
||||
|
||||
function bookdata_register_tinymce_shortcode_buttons( $buttons ) {
|
||||
array_push( $buttons, "|", "bookdata" );
|
||||
return $buttons;
|
||||
}
|
||||
function bookdata_tinymce_plugins( $plugin_array ) {
|
||||
$plugin_array['bookdata'] = get_template_directory_uri() . '/assets/js/tinymce-buttons.js';
|
||||
return $plugin_array;
|
||||
}
|
||||
|
||||
function bookdata_refresh_tinymce( $ver ) {
|
||||
$ver += 3;
|
||||
return $ver;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------ */
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user