Skip to content

Instantly share code, notes, and snippets.

@dnaber-de
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnaber-de/9036520 to your computer and use it in GitHub Desktop.
Save dnaber-de/9036520 to your computer and use it in GitHub Desktop.
Hotfix Plugin for WP Colored Coding to disable the early shortcode handling, which can lead into trouble with some other plugins.

WP Colored Coding – Disable early shortcode

Issue #8 of WP Colored Coding describes a interoperability problem with another plugin which parses the_content and didn't expect the occurrence of source code in the text.

This can be fixed by handling the WP-CC Shortcode after the_content which is the normal way.

But this drops the support for in-text codes using the enclosing shortcode:

[cc lang="html"]
<strong>This will not longer be possible</strong>
[/cc]
<?php
/**
* Plugin Name: WP Colored Coding – Disable early shortcode
* Plugin URI:
* Author: David Naber
* Author URI: http://dnaber.de/
* Version: 2014.02.16
* Description: Disables the early shortcode handler of »WP Colored Coding«. May improve the interoperability (see <a href="https://github.com/dnaber-de/WP-Colored-Coding/issues/8">#8</a>) but breaks the enclosing (in-editor-code) shortcodes: <code>[cc] &lt;code&gt;[/cc]</code>, by displaying the &lt;p&gt;-tags injectet by <code>wpautop</code> around the shortcode.
* Textdomain: wp-cc
* License: Apache 2.0
* License URI: http://www.apache.org/licenses/LICENSE-2.0
*
* Copyright 2014 David Naber
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
add_action( 'plugins_loaded', 'wpcc_disable_early_shortcodes', 11 );
function wpcc_disable_early_shortcodes() {
if ( ! class_exists( 'WP_Colored_Coding' ) )
return;
$wpcc = WP_Colored_Coding::get_instance();
remove_filter( 'the_content', array( $wpcc, 'bypass_shortcodes' ), 5 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment