From f2be2a98283289f93e4593078ab388f8fc64bebb Mon Sep 17 00:00:00 2001 From: Jesse A Janowiak Date: Fri, 31 Aug 2018 12:10:56 -0400 Subject: [PATCH] Format menu actually being removed now --- Release-Notes.md | 3 +++ class-newcity-toolbars.php | 54 +++++++++++++++++--------------------- newcity-wysiwyg.php | 2 +- 3 files changed, 28 insertions(+), 31 deletions(-) diff --git a/Release-Notes.md b/Release-Notes.md index 11d2bb5..fe434bb 100644 --- a/Release-Notes.md +++ b/Release-Notes.md @@ -1,5 +1,8 @@ # Release Notes for NewCity Shortcodes plugin +## 0.2.1 -- Aug. 31, 2018 +New code was changing format menu contents, but not removing it. + ## 0.2.0-dev -- Aug. 31, 2018 Breaking change: "Format" menu now only appears if `newcity_wysiwyg_toolbar_format_dropdown` option exists and is truthy diff --git a/class-newcity-toolbars.php b/class-newcity-toolbars.php index 32b1871..13d0d48 100644 --- a/class-newcity-toolbars.php +++ b/class-newcity-toolbars.php @@ -20,8 +20,6 @@ public function __construct() { } public function modify_tiny_mce( $settings ) { - // Set dropdown formatting options in WYSIWYG Editor - // {Display Name}={html tag} $settings['block_formats'] = 'Paragraph=p;Heading 2=h2;Heading 3=h3;Heading 4=h4;'; if (get_option('newcity_wysiwyg_toolbar_format_dropdown')) { @@ -58,23 +56,25 @@ private function blockquote_name() { } private function custom_styles( $init_array ) { - $style_formats = array( - array( - 'title' => 'Intro Paragraph', - 'block' => 'p', - 'classes' => 'intro', - 'wrapper' => false, - ), - array( - 'title' => 'Featured Link', - 'selector' => 'a', - 'block' => 'a', - 'classes' => 'large-arrow', - 'wrapper' => false, - ), - ); - - $init_array['style_formats'] = json_encode( $style_formats ); + if (get_option('newcity_wysiwyg_toolbar_format_dropdown')) { + $style_formats = array( + array( + 'title' => 'Intro Paragraph', + 'block' => 'p', + 'classes' => 'intro', + 'wrapper' => false, + ), + array( + 'title' => 'Featured Link', + 'selector' => 'a', + 'block' => 'a', + 'classes' => 'large-arrow', + 'wrapper' => false, + ), + ); + + $init_array['style_formats'] = json_encode( $style_formats ); + } return $init_array; } @@ -84,8 +84,6 @@ function add_style_select_buttons( $buttons ) { } function my_toolbars( $toolbars ) { - // Add new WYSIWYG toolbar sets - $toolbars['Minimum'] = array(); $toolbars['Minimum'][1] = array( 'bold', 'italic', '|', 'removeformat' ); @@ -100,22 +98,18 @@ function my_toolbars( $toolbars ) { $toolbars['Simple'][1] = array( 'bold', 'italic', 'link', 'unlink', 'bullist', 'numlist', $this->blockquote_name(), '|', 'removeformat' ); $toolbars['Simple with Headers'] = array(); - $toolbars['Simple with Headers'][1] = array( 'bold', 'italic', 'link', 'unlink', 'bullist', 'numlist', $this->blockquote_name(), 'formatselect', 'styleselect', '|', 'removeformat' ); - - // Edit the "Full" toolbar and remove 'code' - // if (($key = array_search('code', $toolbars['Full' ][2])) !== false) { - // unset($toolbars['Full' ][2][$key]); - // } + $toolbars['Simple with Headers'][1] = array( 'bold', 'italic', 'link', 'unlink', 'bullist', 'numlist', 'formatselect', '|', 'removeformat' ); + if (get_option('newcity_wysiwyg_toolbar_format_dropdown')) { + array_splice($toolbars['Simple with Headers'][1], 6, 0, 'styleselect'); + } - // remove the 'Basic' toolbar completely unset( $toolbars['Basic'] ); - // return $toolbars - IMPORTANT! return $toolbars; } public function default_mce_toolbar( $buttons ) { - $buttons = array( 'bold', 'italic', 'link', 'unlink', 'bullist', 'numlist', $this->blockquote_name(), 'formatselect', '|', 'removeformat' ); + $buttons = array( 'bold', 'italic', 'link', 'unlink', 'bullist', 'numlist', 'formatselect', '|', 'removeformat' ); return $buttons; } public function extra_mce_toolbar( $buttons ) { diff --git a/newcity-wysiwyg.php b/newcity-wysiwyg.php index ca71d06..d61ce96 100644 --- a/newcity-wysiwyg.php +++ b/newcity-wysiwyg.php @@ -10,7 +10,7 @@ * Plugin Name: NewCity Custom WYSIWYG tools * * Plugin URI: https://github.com/newcity/newcity-wp-wysiwyg * Description: Custom toolbars and modifications to TinyMCE - * Version: 0.2.0-dev + * Version: 0.2.1 * Author: NewCity * Author URI: http://insidenewcity.com * License: NONE