Crayon Syntax Highlighter - Version 1.0.1

Version Description

  • Fixed a bug that caused Themes not to load for some Crayons due to Wordpress content formatting.

=

Download this release

Release Info

Developer akarmenia
Plugin Icon wp plugin Crayon Syntax Highlighter
Version 1.0.1
Comparing to
See all releases

Code changes from version 1.0.0 to 1.0.1

crayon_fonts.class.php CHANGED
@@ -3,7 +3,7 @@ require_once ('global.php');
3
  require_once (CRAYON_RESOURCE_PHP);
4
 
5
  /* Manages fonts once they are loaded. */
6
- class CrayonFonts extends CrayonResourceCollection {
7
  // Properties and Constants ===============================================
8
 
9
  const DEFAULT_FONT = 'theme-font';
3
  require_once (CRAYON_RESOURCE_PHP);
4
 
5
  /* Manages fonts once they are loaded. */
6
+ class CrayonFonts extends CrayonUsedResourceCollection {
7
  // Properties and Constants ===============================================
8
 
9
  const DEFAULT_FONT = 'theme-font';
crayon_formatter.class.php CHANGED
@@ -15,6 +15,8 @@ class CrayonFormatter {
15
 
16
  // Methods ================================================================
17
  private function __construct() {}
 
 
18
 
19
  /* Formats the code using the regex and stores the elements for later use. */
20
  public static function format_code($code, $language, $highlight = TRUE, $hl = NULL) {
15
 
16
  // Methods ================================================================
17
  private function __construct() {}
18
+
19
+ private static $test = 0;
20
 
21
  /* Formats the code using the regex and stores the elements for later use. */
22
  public static function format_code($code, $language, $highlight = TRUE, $hl = NULL) {
crayon_resource.class.php CHANGED
@@ -151,7 +151,7 @@ class CrayonResourceCollection {
151
 
152
  /* Override in subclasses */
153
  public function resource_instance($id, $name = NULL) {
154
- return new CrayonUsedResource($id, $name);
155
  }
156
 
157
  public function add($name, $object) {
@@ -216,7 +216,6 @@ class CrayonResourceCollection {
216
  class CrayonUsedResourceCollection extends CrayonResourceCollection {
217
 
218
  // Checks if any of the themes are being used
219
-
220
  public function is_used($id = NULL) {
221
  if ($id === NULL) {
222
  foreach ($this->get() as $resource) {
@@ -234,12 +233,16 @@ class CrayonUsedResourceCollection extends CrayonResourceCollection {
234
  }
235
  }
236
  }
 
 
 
 
 
237
  }
238
 
239
  class CrayonResource {
240
  private $id = '';
241
  private $name = '';
242
- private $used = FALSE;
243
 
244
  function __construct($id, $name = NULL) {
245
  CrayonUtil::str($this->id, $id);
@@ -259,14 +262,6 @@ class CrayonResource {
259
  return $this->name;
260
  }
261
  }
262
-
263
- function used($used = NULL) {
264
- if ($used === NULL) {
265
- return $this->used;
266
- } else {
267
- $this->used = ($used ? TRUE : FALSE);
268
- }
269
- }
270
  }
271
 
272
  /* Keeps track of usage */
151
 
152
  /* Override in subclasses */
153
  public function resource_instance($id, $name = NULL) {
154
+ return new CrayonResource($id, $name);
155
  }
156
 
157
  public function add($name, $object) {
216
  class CrayonUsedResourceCollection extends CrayonResourceCollection {
217
 
218
  // Checks if any of the themes are being used
 
219
  public function is_used($id = NULL) {
220
  if ($id === NULL) {
221
  foreach ($this->get() as $resource) {
233
  }
234
  }
235
  }
236
+
237
+ // XXX Override
238
+ public function resource_instance($id, $name = NULL) {
239
+ return new CrayonUsedResource($id, $name);
240
+ }
241
  }
242
 
243
  class CrayonResource {
244
  private $id = '';
245
  private $name = '';
 
246
 
247
  function __construct($id, $name = NULL) {
248
  CrayonUtil::str($this->id, $id);
262
  return $this->name;
263
  }
264
  }
 
 
 
 
 
 
 
 
265
  }
266
 
267
  /* Keeps track of usage */
crayon_themes.class.php CHANGED
@@ -3,7 +3,7 @@ require_once ('global.php');
3
  require_once (CRAYON_RESOURCE_PHP);
4
 
5
  /* Manages themes once they are loaded. */
6
- class CrayonThemes extends CrayonResourceCollection {
7
  // Properties and Constants ===============================================
8
 
9
  const DEFAULT_THEME = 'classic';
3
  require_once (CRAYON_RESOURCE_PHP);
4
 
5
  /* Manages themes once they are loaded. */
6
+ class CrayonThemes extends CrayonUsedResourceCollection {
7
  // Properties and Constants ===============================================
8
 
9
  const DEFAULT_THEME = 'classic';
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.0
7
  Author: Aram Kocharyan
8
  Author URI: http://ak.net84.net/
9
  License: GPL2
@@ -91,7 +91,6 @@ class CrayonWP {
91
  $crayon->url($url);
92
  }
93
  if (!empty($content)) {
94
-
95
  $crayon->code($content);
96
  }
97
  // Set attributes, should be set after URL to allow language auto detection
@@ -133,6 +132,7 @@ class CrayonWP {
133
  $closed_atts = $matches[1];
134
  $open_atts = $matches[2];
135
  $contents = $matches[3];
 
136
  // Make sure we enqueue the styles/scripts
137
  $enqueue = TRUE;
138
 
@@ -175,17 +175,20 @@ class CrayonWP {
175
  self::$included = TRUE;
176
  }
177
 
178
- public static function the_content($the_content) {
179
  global $post;
180
  // Go through queued posts and find crayons
181
  $post_id = strval($post->ID);
182
  // Find if this post has Crayons
183
  if ( array_key_exists($post_id, self::$post_queue) ) {
 
 
184
  // Loop through Crayons
185
  $post_in_queue = self::$post_queue[$post_id];
186
  foreach ($post_in_queue as $p) {
187
  $atts = $p[1];
188
- $content = $p[2];
 
189
  // Remove '$' from $[crayon]...[/crayon]$ contained within [crayon] tag content
190
  $content = self::crayon_remove_ignore($content);
191
  // Apply shortcode to the content
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.0.1
7
  Author: Aram Kocharyan
8
  Author URI: http://ak.net84.net/
9
  License: GPL2
91
  $crayon->url($url);
92
  }
93
  if (!empty($content)) {
 
94
  $crayon->code($content);
95
  }
96
  // Set attributes, should be set after URL to allow language auto detection
132
  $closed_atts = $matches[1];
133
  $open_atts = $matches[2];
134
  $contents = $matches[3];
135
+
136
  // Make sure we enqueue the styles/scripts
137
  $enqueue = TRUE;
138
 
175
  self::$included = TRUE;
176
  }
177
 
178
+ public static function the_content($the_content) {
179
  global $post;
180
  // Go through queued posts and find crayons
181
  $post_id = strval($post->ID);
182
  // Find if this post has Crayons
183
  if ( array_key_exists($post_id, self::$post_queue) ) {
184
+ // XXX We want the plain post content, no formatting
185
+ $the_content = $post->post_content;
186
  // Loop through Crayons
187
  $post_in_queue = self::$post_queue[$post_id];
188
  foreach ($post_in_queue as $p) {
189
  $atts = $p[1];
190
+ $content = $p[2]; // The formatted crayon we replace post content with
191
+
192
  // Remove '$' from $[crayon]...[/crayon]$ contained within [crayon] tag content
193
  $content = self::crayon_remove_ignore($content);
194
  // Apply shortcode to the content
css/admin_style.css CHANGED
@@ -64,7 +64,7 @@
64
  }
65
 
66
  .crayon-help {
67
- height: 30px;
68
  }
69
 
70
  .crayon-help .crayon-help-close,
64
  }
65
 
66
  .crayon-help {
67
+ min-height: 30px;
68
  }
69
 
70
  .crayon-help .crayon-help-close,
global.php CHANGED
@@ -8,7 +8,7 @@ define('CRAYON_DEBUG', FALSE); // Enable to show exceptions on screen
8
 
9
  $uid = CRAYON_DEBUG ? uniqid() : ''; // Prevent caching in debug mode
10
 
11
- define('CRAYON_VERSION', '1.0.0' . $uid);
12
  define('CRAYON_DATE', '10th August, 2011');
13
  define('CRAYON_AUTHOR', 'Aram Kocharyan');
14
  // TODO These will be changed once I set up a site for docs
8
 
9
  $uid = CRAYON_DEBUG ? uniqid() : ''; // Prevent caching in debug mode
10
 
11
+ define('CRAYON_VERSION', '1.0.1' . $uid);
12
  define('CRAYON_DATE', '10th August, 2011');
13
  define('CRAYON_AUTHOR', 'Aram Kocharyan');
14
  // TODO These will be changed once I set up a site for docs
log.txt CHANGED
@@ -1,6 +0,0 @@
1
- ==============================================================================
2
- Crayon Syntax Highlighter Log Entry
3
- ==============================================================================
4
- 10:41:38 AM - 10 Aug 2011
5
- string(106) "The provided URL ('/Users/Aram/Development/Web/crayon/fwfwewf') could not be accessed locally or remotely."
6
- ------------------------------------------------------------------------------
 
 
 
 
 
 
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.2.1
7
- Stable tag: 1.0.0
8
 
9
  Syntax Highlighter supporting multiple languages, themes, highlighting from a URL, local file or post text.
10
 
@@ -36,13 +36,16 @@ Contact me at http://twitter.com/crayonsyntax or crayon.syntax@gmail.com.
36
 
37
  == Screenshots ==
38
 
39
- Coming soon.
40
 
41
  == Changelog ==
42
 
43
  = 1.0 =
44
  * Initial Release. Huzzah!
45
 
 
 
 
46
  == Upgrade Notice ==
47
 
48
  None yet.
4
  Tags: syntax highlighter, syntax, highlighter, highlighting, crayon, code highlighter
5
  Requires at least: 3.0
6
  Tested up to: 3.2.1
7
+ Stable tag: 1.0.1
8
 
9
  Syntax Highlighter supporting multiple languages, themes, highlighting from a URL, local file or post text.
10
 
36
 
37
  == Screenshots ==
38
 
39
+ 1. Different themes and Live Preview under Settings > Crayon.
40
 
41
  == Changelog ==
42
 
43
  = 1.0 =
44
  * Initial Release. Huzzah!
45
 
46
+ = 1.0.1 =
47
+ * Fixed a bug that caused Themes not to load for some Crayons due to Wordpress content formatting.
48
+
49
  == Upgrade Notice ==
50
 
51
  None yet.
screenshot-1.png ADDED
Binary file