hemusyl / TinyMCE

TinyMCE
0 stars 0 forks source link

TinyMCE #1

Open hemusyl opened 8 years ago

hemusyl commented 8 years ago

http://www.wpexplorer.com/wordpress-tinymce-tweaks/ //tinymce-domain.php <?php // Hooks your functions into the correct filters function desparate_add_mce_button() { // check user permissions if ( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ) ) { return; } // check if WYSIWYG is enabled if ( 'true' == get_user_option( 'rich_editing' ) ) { add_filter( 'mce_external_plugins', 'hktuts_add_tinymce_plugin' ); add_filter( 'mce_buttons', 'my_register_mce_button' );

}

} add_action('admin_head', 'desparate_add_mce_button');

// Declare script for new button function hktuts_add_tinymce_plugin( $plugin_array ) { $plugin_array['desparate_mce_button'] = get_template_directory_uri() .'/js/desparate-button.js'; return $plugin_array; }

// Register new button in the editor function my_register_mce_button( $buttons ) { array_push( $buttons, 'desparate_mce_button' ); return $buttons; }


Ex1 //desparate-button.js

(function() { tinymce.PluginManager.add('desparate_mce_button', function( editor, url ) { editor.addButton('desparate_mce_button', { text: 'HK Button', icon: 'iconname', type: 'menubutton', menu: [ { text: 'Sub Item 1', onclick: function() { editor.insertContent('[fvideo id="Add your ID"]'); } }, { text: 'Sub Item 2', onclick: function() { editor.insertContent('WPExplorer.com is awesome!'); } } ] }); });

})();

Ex2 (function() { tinymce.PluginManager.add('desparate_mce_button', function( editor, url ) { editor.addButton('desparate_mce_button', { text: 'HK Button', icon: false, type: 'menubutton', menu: [ { text: 'Sub Item 1', onclick: function() { editor.insertContent('[fvideo id="Add your ID"]'); } },

                    {
                        text: 'Pop-Up',
                        onclick: function() {
                            editor.windowManager.open( {
                                title: 'Insert Random Shortcode',
                                body: [
                                    {
                                        type: 'textbox',
                                        name: 'textboxName',
                                        label: 'Text Box',
                                        value: '30'
                                    },

                                ],
                                onsubmit: function( e ) {
                                    editor.insertContent('[fvideo id="Add your ID"]');
                                }
                            });
                        }
                    }

                ]
    });
});

})();


Ex 3 (function() { tinymce.PluginManager.add('desparate_mce_button', function( editor, url ) { editor.addButton('desparate_mce_button', { text: 'HK Button', icon:'iconname', type: 'menubutton', menu: [ { text: 'Item 1', onclick: function() { editor.insertContent('[fvideo id="Add your ID"]'); },

                    },
                    {
                        text: 'Item 2',
                        onclick: function() {
                            editor.insertContent('[fvideo id="Add your ID"]');
                        },

                    },

                    {
                        text: 'Pop-Up',

                        onclick: function() {
                            editor.windowManager.open( {
                                title: 'Insert Random Shortcode',
                                body: [
                                    {
                                        type: 'textbox',
                                        name: 'textboxName',
                                        label: 'Text Box',
                                        value: '30'
                                    },

                                ],
                                onsubmit: function( e ) {
                                    editor.insertContent('[fvideo id="Add your ID"]');
                                }

                            });
                        },

                    },
                    {
                text: 'Item 1',
                menu: [
                    {
                        text: 'Sub Item 1',
                        onclick: function() {
                            editor.insertContent('WPExplorer.com is awesome!');
                        }
                    },
                    {
                        text: 'Sub Item 2',
                        onclick: function() {
                            editor.insertContent('WPExplorer.com is awesome!');
                        }
                    }
                ]
            },

            ]
    });
});

})();

Ex4 (function() { tinymce.PluginManager.add('my_mce_button', function( editor, url ) { editor.addButton( 'my_mce_button', { text: 'Sample Dropdown', icon: 'iconname', type: 'menubutton', menu: [ { text: 'Item 1', menu: [ { text: 'Pop-Up', onclick: function() { editor.windowManager.open( { title: 'Insert Random Shortcode', body: [ { type: 'textbox', name: 'textboxName', label: 'Text Box', value: '30' }, { type: 'textbox', name: 'multilineName', label: 'Multiline Text Box', value: 'You can say a lot of stuff in here', multiline: true, minWidth: 300, minHeight: 100 }, { type: 'listbox', name: 'listboxName', label: 'List Box', 'values': [ {text: 'Option 1', value: '1'}, {text: 'Option 2', value: '2'}, {text: 'Option 3', value: '3'} ] } ], onsubmit: function( e ) { editor.insertContent( '[random_shortcode textbox="' + e.data.textboxName + '" multiline="' + e.data.multilineName + '" listbox="' + e.data.listboxName + '"]'); } }); } } ] } ] }); }); })();


EX5 (function() { tinymce.PluginManager.add('my_mce_button', function( editor, url ) { editor.addButton( 'my_mce_button', { text: 'Sample Dropdown', icon: 'iconname', type: 'menubutton', menu: [ { text: 'Item 1', menu: [ { text: 'Sub Item 1', onclick: function() { editor.insertContent('WPExplorer.com is awesome!'); } }, { text: 'Sub Item 2', onclick: function() { editor.insertContent('WPExplorer.com is awesome!'); } } ] }, { text: 'Item 2', menu: [ { text: 'Sub Item 1', onclick: function() { editor.insertContent('WPExplorer.com is awesome!'); } }, { text: 'Sub Item 2', onclick: function() { editor.insertContent('WPExplorer.com is awesome!'); } } ] } ] }); });

})();

/**

hemusyl commented 8 years ago

Css er jnoo

i.mce-ico,.mce-i-iconname{ background-image: url('../images/desparate.png'); }