Version Description
- Prevented Crayons from appearing as plain text in excerpts http://wordpress.org/support/topic/plugin-crayon-syntax-highlighter-this-plugin-breaks-the-tag
=
Download this release
Release Info
Developer | akarmenia |
Plugin | Crayon Syntax Highlighter |
Version | 1.2.3 |
Comparing to | |
See all releases |
Code changes from version 1.2.2 to 1.2.3
- crayon_wp.class.php +25 -6
- readme.txt +5 -1
crayon_wp.class.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Crayon Syntax Highlighter
|
4 |
Plugin URI: http://ak.net84.net/
|
5 |
Description: Supports multiple languages, themes, highlighting from a URL, local file or post text. <a href="options-general.php?page=crayon_settings">View Settings.</a>
|
6 |
-
Version: 1.2.
|
7 |
Author: Aram Kocharyan
|
8 |
Author URI: http://ak.net84.net/
|
9 |
License: GPL2
|
@@ -36,6 +36,8 @@ class CrayonWP {
|
|
36 |
|
37 |
// Associative array, keys are post IDs as strings and values are number of crayons parsed as ints
|
38 |
private static $post_queue = array();
|
|
|
|
|
39 |
// Whether we have added styles and scripts
|
40 |
private static $included = FALSE;
|
41 |
|
@@ -131,7 +133,7 @@ class CrayonWP {
|
|
131 |
return $crayon;
|
132 |
}
|
133 |
|
134 |
-
/*
|
135 |
public static function the_posts($posts) {
|
136 |
if (empty($posts)) {
|
137 |
return $posts;
|
@@ -175,7 +177,7 @@ class CrayonWP {
|
|
175 |
}
|
176 |
|
177 |
// Add array of atts and content to post queue with key as post ID
|
178 |
-
self::$post_queue[strval($post->ID)][] = array(
|
179 |
}
|
180 |
}
|
181 |
}
|
@@ -195,6 +197,7 @@ class CrayonWP {
|
|
195 |
self::$included = TRUE;
|
196 |
}
|
197 |
|
|
|
198 |
public static function the_content($the_content) {
|
199 |
global $post;
|
200 |
// Go through queued posts and find crayons
|
@@ -202,12 +205,15 @@ class CrayonWP {
|
|
202 |
// Find if this post has Crayons
|
203 |
if ( array_key_exists($post_id, self::$post_queue) ) {
|
204 |
// XXX We want the plain post content, no formatting
|
|
|
205 |
$the_content = $post->post_content;
|
206 |
// Loop through Crayons
|
207 |
$post_in_queue = self::$post_queue[$post_id];
|
208 |
foreach ($post_in_queue as $p) {
|
209 |
-
$atts = $p[
|
210 |
-
$content = $p[
|
|
|
|
|
211 |
|
212 |
// Remove '$' from $[crayon]...[/crayon]$ contained within [crayon] tag content
|
213 |
$content = self::crayon_remove_ignore($content);
|
@@ -219,9 +225,21 @@ class CrayonWP {
|
|
219 |
// Remove '$' from $[crayon]...[/crayon]$ in post body
|
220 |
// XXX Do this after applying shortcode to avoid matching
|
221 |
$the_content = self::crayon_remove_ignore($the_content);
|
|
|
222 |
return $the_content;
|
223 |
}
|
224 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
// Check if the $[crayon]...[/crayon]$ notation has been used to ignore [crayon] tags within posts
|
226 |
public static function crayon_remove_ignore($the_content) {
|
227 |
$the_content = preg_replace('#\$('. self::REGEX_CLOSED_NO_CAPTURE .')\$?#', '$1', $the_content);
|
@@ -243,9 +261,10 @@ class CrayonWP {
|
|
243 |
if (defined('ABSPATH')) {
|
244 |
register_activation_hook(__FILE__, 'CrayonWP::install');
|
245 |
register_deactivation_hook(__FILE__, 'CrayonWP::uninstall');
|
|
|
246 |
// Filters and Actions
|
247 |
-
|
248 |
add_filter('the_posts', 'CrayonWP::the_posts');
|
249 |
add_filter('the_content', 'CrayonWP::the_content');
|
|
|
250 |
}
|
251 |
?>
|
3 |
Plugin Name: Crayon Syntax Highlighter
|
4 |
Plugin URI: http://ak.net84.net/
|
5 |
Description: Supports multiple languages, themes, highlighting from a URL, local file or post text. <a href="options-general.php?page=crayon_settings">View Settings.</a>
|
6 |
+
Version: 1.2.3
|
7 |
Author: Aram Kocharyan
|
8 |
Author URI: http://ak.net84.net/
|
9 |
License: GPL2
|
36 |
|
37 |
// Associative array, keys are post IDs as strings and values are number of crayons parsed as ints
|
38 |
private static $post_queue = array();
|
39 |
+
// TODO Newer array, eventually will move all data here
|
40 |
+
private static $posts = array();
|
41 |
// Whether we have added styles and scripts
|
42 |
private static $included = FALSE;
|
43 |
|
133 |
return $crayon;
|
134 |
}
|
135 |
|
136 |
+
/* Search for Crayons in posts and queue them for creation */
|
137 |
public static function the_posts($posts) {
|
138 |
if (empty($posts)) {
|
139 |
return $posts;
|
177 |
}
|
178 |
|
179 |
// Add array of atts and content to post queue with key as post ID
|
180 |
+
self::$post_queue[strval($post->ID)][] = array('id'=>$post->ID, 'atts'=>$atts_array, 'contents'=>$contents[$i], 'index'=>$i);
|
181 |
}
|
182 |
}
|
183 |
}
|
197 |
self::$included = TRUE;
|
198 |
}
|
199 |
|
200 |
+
// Add Crayon into the_content
|
201 |
public static function the_content($the_content) {
|
202 |
global $post;
|
203 |
// Go through queued posts and find crayons
|
205 |
// Find if this post has Crayons
|
206 |
if ( array_key_exists($post_id, self::$post_queue) ) {
|
207 |
// XXX We want the plain post content, no formatting
|
208 |
+
$the_content_original = $the_content;
|
209 |
$the_content = $post->post_content;
|
210 |
// Loop through Crayons
|
211 |
$post_in_queue = self::$post_queue[$post_id];
|
212 |
foreach ($post_in_queue as $p) {
|
213 |
+
$atts = $p['atts'];
|
214 |
+
$content = $p['contents']; // The formatted crayon we replace post content with
|
215 |
+
|
216 |
+
self::$posts[$post_id] = array('content_raw'=>$post->post_content, 'content'=>$the_content_original);
|
217 |
|
218 |
// Remove '$' from $[crayon]...[/crayon]$ contained within [crayon] tag content
|
219 |
$content = self::crayon_remove_ignore($content);
|
225 |
// Remove '$' from $[crayon]...[/crayon]$ in post body
|
226 |
// XXX Do this after applying shortcode to avoid matching
|
227 |
$the_content = self::crayon_remove_ignore($the_content);
|
228 |
+
self::$posts[$post_id]['content_crayon'] = $the_content;
|
229 |
return $the_content;
|
230 |
}
|
231 |
|
232 |
+
// Remove Crayons from the_excerpt
|
233 |
+
public static function the_excerpt($the_excerpt) {
|
234 |
+
global $post;
|
235 |
+
$post_id = strval($post->ID);
|
236 |
+
$post->post_content = self::$posts[$post_id]['content'];
|
237 |
+
$post->post_content = preg_replace(self::regex_no_capture(), '', $post->post_content);
|
238 |
+
$the_excerpt = wpautop(wp_trim_excerpt(''));
|
239 |
+
$post->post_content = self::$posts[$post_id]['content_raw'];
|
240 |
+
return $the_excerpt;
|
241 |
+
}
|
242 |
+
|
243 |
// Check if the $[crayon]...[/crayon]$ notation has been used to ignore [crayon] tags within posts
|
244 |
public static function crayon_remove_ignore($the_content) {
|
245 |
$the_content = preg_replace('#\$('. self::REGEX_CLOSED_NO_CAPTURE .')\$?#', '$1', $the_content);
|
261 |
if (defined('ABSPATH')) {
|
262 |
register_activation_hook(__FILE__, 'CrayonWP::install');
|
263 |
register_deactivation_hook(__FILE__, 'CrayonWP::uninstall');
|
264 |
+
|
265 |
// Filters and Actions
|
|
|
266 |
add_filter('the_posts', 'CrayonWP::the_posts');
|
267 |
add_filter('the_content', 'CrayonWP::the_content');
|
268 |
+
add_filter('the_excerpt', 'CrayonWP::the_excerpt');
|
269 |
}
|
270 |
?>
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://ak.net84.net/
|
|
4 |
Tags: syntax highlighter, syntax, highlighter, highlighting, crayon, code highlighter
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.3
|
7 |
-
Stable tag: 1.2.
|
8 |
|
9 |
Syntax Highlighter supporting multiple languages, themes, highlighting from a URL, local file or post text.
|
10 |
|
@@ -85,6 +85,10 @@ Contact me at http://twitter.com/crayonsyntax or crayon.syntax@gmail.com.
|
|
85 |
* Fixed the regex for detecting python docstrings. It's a killer, but it works!
|
86 |
(?:(?<!\\)""".*?(?<!\\)""")|(?:(?<!\\)'''.*?(?<!\\)''')|((?<!\\)".*?(?<!\\)")|((?<!\\)'.*?(?<!\\)')
|
87 |
|
|
|
|
|
|
|
|
|
88 |
== Upgrade Notice ==
|
89 |
|
90 |
No issues upgrading.
|
4 |
Tags: syntax highlighter, syntax, highlighter, highlighting, crayon, code highlighter
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.3
|
7 |
+
Stable tag: 1.2.3
|
8 |
|
9 |
Syntax Highlighter supporting multiple languages, themes, highlighting from a URL, local file or post text.
|
10 |
|
85 |
* Fixed the regex for detecting python docstrings. It's a killer, but it works!
|
86 |
(?:(?<!\\)""".*?(?<!\\)""")|(?:(?<!\\)'''.*?(?<!\\)''')|((?<!\\)".*?(?<!\\)")|((?<!\\)'.*?(?<!\\)')
|
87 |
|
88 |
+
= 1.2.3 =
|
89 |
+
* Prevented Crayons from appearing as plain text in excerpts
|
90 |
+
http://wordpress.org/support/topic/plugin-crayon-syntax-highlighter-this-plugin-breaks-the-tag
|
91 |
+
|
92 |
== Upgrade Notice ==
|
93 |
|
94 |
No issues upgrading.
|