September 16, 2011

WordPress Multiple Content Blocks: Remove WYSIWYG Editor

So I was looking for a plugin that would allow me to have multiple content blocks with the WordPress admin. If I couldn’t find one, I was going to create one myself. Fortunately for my upcoming work schedule, I found one by Trend Werk. I want to give them a special thanks because their plugin is AWESOME and provides exactly what I needed. I will definitely be looking into their other plugins because this one is great. You can download it through their website http://plugins.trendwerk.nl/documentation/multiple-content-blocks/.

So onto the reason for this blog post. The only thing that I didn’t like about the plugin was that their was no settings where I could disable the WYSIWYG. So I went dumpster diving into the code and made a few edits to fix this. Go in the plugin files and find “multiple_content.php”. Go to lines 134-149. Here is the original code:

  1.   if(get_usermeta($current_user->ID,'rich_editing') == 'true') {
  2.    //leave this away when wysigwyg is disabled
  3.    echo '<a id="edButtonHTML" class="hide-if-no-js" onclick="switchEditors.go(\'multiplecontent_box-'.$fieldName.'\', \'html\');">HTML</a><a id="edButtonPreview" class="active hide-if-no-js" onclick="switchEditors.go(\'multiplecontent_box-'.$fieldName.'\', \'tinymce\');">Wysiwyg</a>';
  4.   }
  5.  
  6.   echo '<input type="hidden" name="multiplecontent_box-'.$fieldName.'-nonce" id="multiplecontent_box-'.$fieldName.'-nonce" value="'.wp_create_nonce("multiplecontent_box-".$fieldName."-nonce").'" />'."\n";  //nonce
  7.   echo '<textarea id="multiplecontent_box-'.$fieldName.'" tabindex="2" name="multiplecontent_box-'.$fieldName.'" cols="158" class="theEditor" rows="15">';
  8.    $content = get_post_meta($post->ID, '_ot_multiplecontent_box-'.$fieldName , true);
  9.    echo apply_filters('the_editor_content', $content);
  10.   echo '</textarea>';
  11.   echo '<p>&nbsp;</p>';
  12.  }
  13.  
  14.  if($editors == 0) {
  15.   _e('There are no content blocks in this template.','cms');
  16.  }

Line 134 change from “True” to “False” like this

  1. if(get_usermeta($current_user->ID,'rich_editing') == 'false') {

Then on line 140 delete the class “theEditor” like this

  1. echo '<textarea id="multiplecontent_box-'.$fieldName.'" tabindex="2" name="multiplecontent_box-'.$fieldName.'" cols="158" rows="3">';

The final product looks like this:

WordPress Multiple Content Blocks: Remove WYSIWYG Editor