मैं कैसे TinyMCE के लिए एक कस्टम बटन जोड़ने के लिए पर Nettuts पर एक ट्यूटोरियल का पालन किया है (http://net.tutsplus.com/tutorials/wordpress/wordpress-shortcodes-the-right-way/)WP में TinyMCE में एकाधिक बटन कैसे जोड़ें?
यह बहुत अच्छा काम करता है और सभी, लेकिन मैं कई बटन जोड़ना चाहते हैं और मैं आश्चर्य हो, तो यह करने के लिए एक स्मार्ट तरीका सभी कोड को डुप्लिकेट किए बिना।
add_shortcode("quote", "quote");
function quote($atts, $content = null) {
return '<div class="right text">"'.$content.'"</div>';
}
add_action('init', 'add_button');
function add_button() {
if (current_user_can('edit_posts') && current_user_can('edit_pages'))
{
add_filter('mce_external_plugins', 'add_plugin');
add_filter('mce_buttons_3', 'register_button');
}
}
function register_button($buttons) {
array_push($buttons, "quote");
return $buttons;
}
function add_plugin($plugin_array) {
$plugin_array['quote'] = get_bloginfo('template_url').'/js/customcodes.js';
return $plugin_array;
}
और फिर मैं इस कोड के साथ एक customcodes.js फ़ाइल बनाने:
यहाँ कोड मैं एक बटन जोड़ने के लिए उपयोग करते हैं तो फिर
(function() {
tinymce.create('tinymce.plugins.quote', {
init : function(ed, url) {
ed.addButton('quote', {
title : 'Add a Quote',
image : url+'/image.png',
onclick : function() {
ed.selection.setContent('[quote]' + ed.selection.getContent() + '[/quote]');
}
});
},
createControl : function(n, cm) {
return null;
},
});
tinymce.PluginManager.add('quote', tinymce.plugins.quote);
})();
, मैं कैसे कई जोड़ सकते हैं प्रत्येक नए बटन के लिए यह सब कोड करने के बिना बटन?
धन्यवाद सेबस्टियन
प्रत्येक नए बटन में अलग-अलग कार्यक्षमता नहीं है? – Prashanth