Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

bbPress now allows posting Crayons for non-users

  • Loading branch information...
commit 459cd2ae07c9aee9258e79f02ce8c0893bd1d7b4 1 parent 9472f8a
@aramk authored
Showing with 18 additions and 3 deletions.
  1. +17 −3 crayon_wp.class.php
  2. +1 −0  readme.txt
View
20 crayon_wp.class.php
@@ -74,6 +74,7 @@ class CrayonWP {
private static $legacy_flags = NULL;
// Used to detect the shortcode
+ private static $allowed_atts = array('url' => NULL, 'lang' => NULL, 'title' => NULL, 'mark' => NULL, 'range' => NULL, 'inline' => NULL);
const REGEX_CLOSED = '(?:\[\s*crayon(?:-(\w+))?\b([^\]]*)/\s*\])'; // [crayon atts="" /]
const REGEX_TAG = '(?:\[\s*crayon(?:-(\w+))?\b([^\]]*)\](.*?)\[\s*/\s*crayon\s*\])'; // [crayon atts=""] ... [/crayon]
const REGEX_INLINE_CLASS = '\bcrayon-inline\b';
@@ -127,8 +128,7 @@ public static function shortcode($atts, $content = NULL, $id = NULL) {
CrayonLog::debug('shortcode');
// Load attributes from shortcode
- $allowed_atts = array('url' => NULL, 'lang' => NULL, 'title' => NULL, 'mark' => NULL, 'range' => NULL, 'inline' => NULL);
- $filtered_atts = shortcode_atts($allowed_atts, $atts);
+ $filtered_atts = shortcode_atts(self::$allowed_atts, $atts);
// Clean attributes
$keys = array_keys($filtered_atts);
@@ -143,7 +143,7 @@ public static function shortcode($atts, $content = NULL, $id = NULL) {
// Contains all other attributes not found in allowed, used to override global settings
$extra_attr = array();
if (!empty($atts)) {
- $extra_attr = array_diff_key($atts, $allowed_atts);
+ $extra_attr = array_diff_key($atts, self::$allowed_atts);
$extra_attr = CrayonSettings::smart_settings($extra_attr);
}
$url = $lang = $title = $mark = $range = $inline = '';
@@ -1229,6 +1229,17 @@ public static function tinymce_comment_enable($args) {
return $args;
}
+ public static function allowed_tags() {
+ global $allowedtags;
+ $tags = array('pre', 'span', 'code');
+ foreach ($tags as $tag) {
+ $current_atts = isset($allowedtags[$tag]) ? $allowedtags[$tag] : array();
+ // TODO data-url isn't recognised by WP
+ $new_atts = array('class' => TRUE, 'title' => TRUE, 'data-url' => TRUE);
+ $allowedtags[$tag] = array_merge($current_atts, $new_atts);
+ }
+ }
+
}
// Only if WP is loaded
@@ -1254,6 +1265,9 @@ public static function tinymce_comment_enable($args) {
add_filter('bbp_get_forum_content', 'CrayonWP::highlight', 100);
add_filter('bbp_get_topic_excerpt', 'CrayonWP::highlight', 100);
+ // Allow tags
+ add_action('init', 'CrayonWP::allowed_tags', 11);
+
if (CrayonGlobalSettings::val(CrayonSettings::COMMENTS)) {
/* XXX This is called first to match Crayons, then higher priority replaces after other filters.
Prevents Crayon from being formatted by the filters, and also keeps original comment formatting. */
View
1  readme.txt
@@ -252,6 +252,7 @@ Contact me at http://twitter.com/crayonsyntax or crayon.syntax@gmail.com.
* Comments now pass through filters before being checked for Crayons.
* JavaScript and CSS resources are minified into single files on the front-end to reduce HTTP requests.
* Toolbar buttons use a sprite sheet, not individual images.
+ * bbPress now allows posting Crayons for non-users
= 2.1.4 =
* ADDED:
Please sign in to comment.
Something went wrong with that request. Please try again.