More Related Content More from Tomasz Dziuda (20) Tworzenie wtyczek dla TinyMCE 4.* - WordUp Wrocław5. • W WordPressie 3.9 zawarto TinyMCE 4.*
• TinyMCE posiada tryb “teeny”
• Łatwo go rozbudować o własne przyciski
6. • W WordPressie 3.9 zawarto TinyMCE 4.*
• TinyMCE posiada tryb “teeny”
• Łatwo go rozbudować o własne przyciski
• WordPress posiada sporo filtrów dedykowanych
TinyMCE
7. • W WordPressie 3.9 zawarto TinyMCE 4.*
• TinyMCE posiada tryb “teeny”
• Łatwo go rozbudować o własne przyciski
• WordPress posiada sporo filtrów dedykowanych
TinyMCE
• Dokumentacja TinyMCE ssie ;)
20. function wordup_add_button() {
global $typenow;
if (
!current_user_can('edit_posts') &&
!current_user_can(‘edit_pages’)
)
return;
if(!in_array($typenow, array('post', 'page')))
return;
!
!
!
!
}
*.php
21. function wordup_add_button() {
global $typenow;
if (
!current_user_can('edit_posts') &&
!current_user_can(‘edit_pages’)
)
return;
if(!in_array($typenow, array('post', 'page')))
return;
if (get_user_option('rich_editing') == 'true') {
add_filter(‘mce_external_plugins’, ‘wordup_add_plugin’);
add_filter('mce_buttons', 'wordup_register_button');
}
}
*.php
28. icon: ‘wp-media-library’ => .mce-i-wp-media-library
( http://wp.dziudek.pl/dev/dodawanie-wlasnych-przyciskow-w-edytorze-tinymce-4 )
36. i.mce-i-icon {
font: 400 20px/1 dashicons;
padding: 0;
vertical-align: top;
speak: none;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
margin-left: -2px;
padding-right: 2px
}
style.css
40. (function() {
tinymce.PluginManager.add(
'wordup_button',
function( ed, url ) {
ed.addButton( 'wordup_button', {
title: 'My test button',
type: 'menubutton',
icon: 'icon dashicons-dashboard',
menu: [{
text: 'Menu item I',
value: 'Text from menu item I',
icon: 'icon dashicons-wordpress',
onclick: function() {
ed.insertContent(this.value());
}
// ..
}]
});
});
})();
43. (function() {
tinymce.PluginManager.add('wordup_button', function(editor, url){
editor.addButton( 'wordup_button', {
title: 'Własny nagłówek',
icon: 'icon dashicons-dashboard',
onclick: function() {
editor.windowManager.open( {
title: 'Wstaw nagłówek',
body: [{
type: 'textbox',
name: 'title',
label: 'Tytuł'
}],
onsubmit: function( e ) {
editor.insertContent( '<h3>' + e.data.title + '</h3>');
}
});
}
});
});
})();
48. editor.windowManager.open( {
title: 'Wstaw nagłówek',
body: [{
type: 'textbox',
name: 'title',
label: 'Tytuł',
}, {
type: 'textbox',
name: 'id',
label: 'Nazwa kotwicy'
}, {
type: 'listbox',
name: 'level',
label: 'Poziom nagłówka',
'values': [
{text: '<h3>', value: '3'},
{text: '<h4>', value: '4'},
{text: '<h5>', value: '5'},
{text: '<h6>', value: '6'}
]
}]
!
!
!
!
});
49. editor.windowManager.open( {
title: 'Wstaw nagłówek',
body: [{
type: 'textbox',
name: 'title',
label: 'Tytuł',
}, {
type: 'textbox',
name: 'id',
label: 'Nazwa kotwicy'
}, {
type: 'listbox',
name: 'level',
label: 'Poziom nagłówka',
'values': [
{text: '<h3>', value: '3'},
{text: '<h4>', value: '4'},
{text: '<h5>', value: '5'},
{text: '<h6>', value: '6'}
]
}],
onsubmit: function( e ) {
editor.insertContent( '<h' + e.data.level + ' id="' + e.data.id + '">' +
e.data.title + '</h' + e.data.level + '>');
}
});
58. <?php
!
if (!defined('ABSPATH')) exit;
!
if (!class_exists( '_WP_Editors' ))
require( ABSPATH . WPINC . '/class-wp-editor.php' );
!
function wordup_button_translation() {
$strings = array(
'label' => __('My test’, 'wordup_button'),
'msg' => __('Hello World!!!!', 'wordup_button')
);
!
!
!
!
}
!
59. <?php
!
if (!defined('ABSPATH')) exit;
!
if (!class_exists( '_WP_Editors' ))
require( ABSPATH . WPINC . '/class-wp-editor.php' );
!
function wordup_button_translation() {
$strings = array(
'label' => __('My test’, 'wordup_button'),
'msg' => __('Hello World!!!!', 'wordup_button')
);
!
$locale = _WP_Editors::$mce_locale;
$translated = 'tinyMCE.addI18n("' . $locale .
'.wordup_button", ' . json_encode( $strings ) . ");n";
!
return $translated;
}
!
60. <?php
!
if (!defined('ABSPATH')) exit;
!
if (!class_exists( '_WP_Editors' ))
require( ABSPATH . WPINC . '/class-wp-editor.php' );
!
function wordup_button_translation() {
$strings = array(
'label' => __('My test’, 'wordup_button'),
'msg' => __('Hello World!!!!', 'wordup_button')
);
!
$locale = _WP_Editors::$mce_locale;
$translated = 'tinyMCE.addI18n("' . $locale .
'.wordup_button", ' . json_encode( $strings ) . ");n";
!
return $translated;
}
!
$strings = wordup_button_translation();