Last active
January 31, 2018 17:17
Star
You must be signed in to star a gist
Stop NextGEN Gallery from breaking the Visual Editor in IE11 (which it does by switching it to IE10 emulation) Raw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Visual Editor Fix for NGG | |
Plugin URI: https://gist.github.com/webaware/66abf3366aae6f86db8770c4ec7ddd16 | |
Description: Stop NextGEN Gallery from breaking the Visual Editor in IE11 | |
Version: 1 | |
Author: WebAware | |
Author URI: https://shop.webaware.com.au/ | |
*/ | |
/* | |
copyright (c) 2017 WebAware Pty Ltd (email : support@webaware.com.au) | |
This program is free software; you can redistribute it and/or | |
modify it under the terms of the GNU General Public License | |
as published by the Free Software Foundation; either version 2 | |
of the License, or (at your option) any later version. | |
This program is distributed in the hope that it will be useful, | |
but WITHOUT ANY WARRANTY; without even the implied warranty of | |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
GNU General Public License for more details. | |
You should have received a copy of the GNU General Public License | |
along with this program; if not, write to the Free Software | |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
*/ | |
if (!defined('ABSPATH')) { | |
exit; | |
} | |
add_action('plugins_loaded', function() { | |
// only fixing for NextGEN Gallery attach-to-post module | |
if (!defined('NGG_ATTACH_TO_POST_SLUG')) { | |
return; | |
} | |
// only when browser is detected as IE by WordPress admin | |
global $is_IE; | |
if (!$is_IE || !is_admin()) { | |
return; | |
} | |
// only on the post editor (new/edit posts, pages, etc.) | |
global $pagenow; | |
if ($pagenow !== 'post.php' && $pagenow !== 'post-new.php') { | |
return; | |
} | |
visual_editor_ngg_fix(); | |
add_action('admin_init', 'visual_editor_ngg_fix', PHP_INT_MAX-1); | |
add_action('admin_print_styles', 'visual_editor_ngg_fix', 2); | |
add_action('admin_print_styles', 'visual_editor_ngg_fix', PHP_INT_MAX-1); | |
}, 100); | |
/** | |
* if headers haven't been sent, (re)set the X-UA-Compatible header | |
*/ | |
function visual_editor_ngg_fix() { | |
if (!headers_sent()) { | |
@header('X-UA-Compatible: IE=edge'); | |
} | |
} |
Hey @boatescape, click Download ZIP in the upper right corner of this page, then upload that zip file as a plugin. This will install as Visual Editor Fix for NGG.
Worked perfect Blackbaud! Thanks for the assistance!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the code. Is there a plugin I can just download? (similar to what I did for Nextgen itself?) Not too comfortable with adding code snippets. Or is there someplace I could find out how to add this code and where to place it?? Using Twenty-Eleven, IE 11 and up-to-date on WP updates. Thanks for your help.