1

I want to use bootstrap table in my site without any mess up class, style. I just want to add bootstrap class. I can add these class in table properties general settings as follows:

function bootstrap_classes_tinymce($settings)
{
    $styles = array(
        array(
            'title' => 'None',
            'value' => ''
        ),
        array(
            'title' => 'Table',
            'value' => 'table',
        ),
        array(
            'title' => 'Striped',
            'value' => 'table table-striped table-hover',
        ),
        array(
            'title' => 'Bordered',
            'value' => 'table table-bordered table-hover',
        ),
    );

    $settings['table_class_list'] = json_encode($styles);

    return $settings;
}

add_filter('tiny_mce_before_init', 'bootstrap_classes_tinymce'); 

Now I want to remove additional style like this default value: enter image description here

Any idea?

1

To customize default styles:

$styles = array('width'=>'100%');
$settings['table_default_styles'] = json_encode($styles);

To disable advance tab:

$settings['table_advtab'] = false;

Complete code at functions.php:

function bootstrap_classes_tinymce($settings)
{
     // to customize more please visit: https://www.tiny.cloud/docs/plugins/table/#table_default_styles
     // Add bootstrap class inside <table> tag
    $classes = array(
        array(
            'title' => 'None',
            'value' => ''
        ),
        array(
            'title' => 'Table',
            'value' => 'table',
        ),
        array(
            'title' => 'Striped',
            'value' => 'table table-striped table-hover',
        ),
        array(
            'title' => 'Bordered',
            'value' => 'table table-bordered table-hover',
        ),
    );

    $settings['table_class_list'] = json_encode($classes);

   // remove default style
    $styles = array('width'=>'100%');
    $settings['table_default_styles'] = json_encode($styles);

    $settings['table_advtab'] = false;
        // echo'<pre>'; print_r($settings); echo '</pre>';

    return $settings;
}

add_filter('tiny_mce_before_init', 'bootstrap_classes_tinymce');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.