Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save GaryJones/30f41acdf72f705ca61a to your computer and use it in GitHub Desktop.
Save GaryJones/30f41acdf72f705ca61a to your computer and use it in GitHub Desktop.
<?php
/* File level DocBlock here - includes/class-remove-h1-format.php */
/* Class level DocBlock here */
class Remove_H1_Format {
/*
* Modify TinyMCE editor to remove H1.
*/
public function remove( $init ) {
// GJ: No need for the filter - if they don't want it running, deactivate the plugin.
// Add block format elements you want to show in dropdown
// GJ: I'd probably go for str_replace() here, so that you don't trump over
// other filters modifying the same block_formats.
$init['block_formats'] = 'Paragraph=p;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Address=address;Pre=pre';
return $init;
}
}
<?php
/**
* Plugin Name: Remove H1 Format
* Plugin URI: http://calliaweb.co.uk/modify-tinymce-editor/
* Description: A simple plugin to remove the H1 format from the WordPress TinyMCE editor.
* Version: 1.0.0
* Author: Jo Waltham
* Author URI: http://calliaweb.co.uk/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
// Exit if accessed directly
defined( 'WPINC' ) or die;
include plugin_dir_path( __FILE__ ) . 'includes/class-remove-h1-format.php';
$remove_h1_format = new Remove_H1_Format;
add_filter( 'tiny_mce_before_init', array( $remove_h1_format, 'remove' ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment