Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable table option in wordpress editor without using plugin

Tags:

php

wordpress

Can anybody tell me that how can I enable the option of table in wordpress editor?

I used below code which help me to enable other option, but not for the table.

My function.php

  <?php

      function add_more_buttons($buttons) {
       $buttons[] = 'hr';
       $buttons[] = 'del';
       $buttons[] = 'sub';
       $buttons[] = 'sup';
       $buttons[] = 'fontselect';
       $buttons[] = 'fontsizeselect';
       $buttons[] = 'cleanup';
       $buttons[] = 'tablecontrols';
       return $buttons;
 }
 add_filter("mce_buttons_3", "add_more_buttons");

 ?>
like image 629
Akshay Shah Avatar asked Jul 18 '14 14:07

Akshay Shah


Video Answer


1 Answers

Without a Plugin

You need to download the "table" folder from the TinyMCE editor package

https://www.tinymce.com/download/

tinymce -> js -> tinymce -> plugins

And copy it into your own folder called 'tinymce-plugins'

Then register the js by adding the folder to your wp-content

enter image description here

Then in your function.php register the button

function add_the_table_button( $buttons ) {
    array_push( $buttons, 'separator', 'table' );
    return $buttons;
}
add_filter( 'mce_buttons', 'add_the_table_button' );

function add_the_table_plugin( $plugins ) {
      $plugins['table'] = content_url() . '/tinymce-plugins/table/plugin.min.js';
      return $plugins;
}
add_filter( 'mce_external_plugins', 'add_the_table_plugin' );

Then BOOM! the table functionality is activated

enter image description here

like image 157
Jim-miraidev Avatar answered Oct 19 '22 07:10

Jim-miraidev