Crayon Syntax Highlighter - Version 1.1.1

Version Description

  • Plugin version information is updated automatically

=

Download this release

Release Info

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

Code changes from version 1.1.0 to 1.1.1

crayon_formatter.class.php CHANGED
@@ -64,6 +64,8 @@ class CrayonFormatter {
64
  return;
65
  }
66
 
 
 
67
  // Generate the code lines and separate each line as a div
68
  $print_code = '';
69
  $print_nums = '';
@@ -230,7 +232,7 @@ EOT;
230
  // Record usage
231
  $theme->used(TRUE);
232
  // Add style
233
- $url = CrayonGlobalSettings::plugin_path() . CrayonUtil::path_f_slash(CRAYON_THEME_DIR) . $theme_id . '/' . $theme_id . '.css?ver' . CRAYON_VERSION;
234
  $output .= '<link rel="stylesheet" type="text/css" href="' . $url . '" />' . CRAYON_NL;
235
  }
236
 
@@ -239,7 +241,7 @@ EOT;
239
  $font_id_dashed = '';
240
  $font = CrayonResources::fonts()->get($font_id);
241
  if ($hl->setting_val(CrayonSettings::FONT) != CrayonFonts::DEFAULT_FONT && !empty($font_id) && $font != NULL && !$font->used()) {
242
- $url = CrayonGlobalSettings::plugin_path() . CrayonUtil::path_f_slash(CRAYON_FONT_DIR) . $font_id . '.css?ver' . CRAYON_VERSION;
243
  $output .= '<link rel="stylesheet" type="text/css" href="' . $url . '" />' . CRAYON_NL;
244
  $font_id_dashed = ' crayon-font-' . CrayonUtil::clean_css_name($font_id);
245
  }
@@ -357,7 +359,7 @@ EOT;
357
  // Debugging stats
358
  $runtime = $hl->runtime();
359
  if (!$hl->setting_val(CrayonSettings::DISABLE_RUNTIME) && is_array($runtime) && !empty($runtime)) {
360
- $output = CRAYON_NL . CRAYON_NL . '<!-- Crayon Syntax Highlighter v' . CRAYON_VERSION . ' -->'
361
  . CRAYON_NL . $output . CRAYON_NL . '<!-- ';
362
  foreach ($hl->runtime() as $type => $time) {
363
  $output .= '[' . $type . ': ' . sprintf('%.4f seconds', $time) . '] ';
64
  return;
65
  }
66
 
67
+ global $CRAYON_VERSION;
68
+
69
  // Generate the code lines and separate each line as a div
70
  $print_code = '';
71
  $print_nums = '';
232
  // Record usage
233
  $theme->used(TRUE);
234
  // Add style
235
+ $url = CrayonGlobalSettings::plugin_path() . CrayonUtil::path_f_slash(CRAYON_THEME_DIR) . $theme_id . '/' . $theme_id . '.css?ver' . $CRAYON_VERSION;
236
  $output .= '<link rel="stylesheet" type="text/css" href="' . $url . '" />' . CRAYON_NL;
237
  }
238
 
241
  $font_id_dashed = '';
242
  $font = CrayonResources::fonts()->get($font_id);
243
  if ($hl->setting_val(CrayonSettings::FONT) != CrayonFonts::DEFAULT_FONT && !empty($font_id) && $font != NULL && !$font->used()) {
244
+ $url = CrayonGlobalSettings::plugin_path() . CrayonUtil::path_f_slash(CRAYON_FONT_DIR) . $font_id . '.css?ver' . $CRAYON_VERSION;
245
  $output .= '<link rel="stylesheet" type="text/css" href="' . $url . '" />' . CRAYON_NL;
246
  $font_id_dashed = ' crayon-font-' . CrayonUtil::clean_css_name($font_id);
247
  }
359
  // Debugging stats
360
  $runtime = $hl->runtime();
361
  if (!$hl->setting_val(CrayonSettings::DISABLE_RUNTIME) && is_array($runtime) && !empty($runtime)) {
362
+ $output = CRAYON_NL . CRAYON_NL . '<!-- Crayon Syntax Highlighter v' . $CRAYON_VERSION . ' -->'
363
  . CRAYON_NL . $output . CRAYON_NL . '<!-- ';
364
  foreach ($hl->runtime() as $type => $time) {
365
  $output .= '[' . $type . ': ' . sprintf('%.4f seconds', $time) . '] ';
crayon_settings.class.php CHANGED
@@ -85,8 +85,9 @@ class CrayonSettings {
85
  // Methods ================================================================
86
 
87
  private function init() {
 
88
  $settings = array(
89
- new CrayonSetting(self::VERSION, CRAYON_VERSION, NULL, TRUE),
90
 
91
  new CrayonSetting(self::THEME, CrayonThemes::DEFAULT_THEME),
92
  new CrayonSetting(self::FONT, CrayonFonts::DEFAULT_FONT),
85
  // Methods ================================================================
86
 
87
  private function init() {
88
+ global $CRAYON_VERSION;
89
  $settings = array(
90
+ new CrayonSetting(self::VERSION, $CRAYON_VERSION, NULL, TRUE),
91
 
92
  new CrayonSetting(self::THEME, CrayonThemes::DEFAULT_THEME),
93
  new CrayonSetting(self::FONT, CrayonFonts::DEFAULT_FONT),
crayon_settings_wp.class.php CHANGED
@@ -43,13 +43,15 @@ class CrayonSettingsWP {
43
  }
44
 
45
  public static function admin_styles() {
46
- wp_enqueue_style('crayon_admin_style', plugins_url(CRAYON_STYLE_ADMIN, __FILE__), array(), CRAYON_VERSION);
 
47
  }
48
 
49
  public static function admin_scripts() {
50
- wp_enqueue_script('crayon_jquery', plugins_url(CRAYON_JQUERY, __FILE__), array(), CRAYON_VERSION);
51
- wp_enqueue_script('crayon_admin_js', plugins_url(CRAYON_JS_ADMIN, __FILE__), array('crayon_jquery'), CRAYON_VERSION);
52
- wp_enqueue_script('crayon_js', plugins_url(CRAYON_JS, __FILE__), array('crayon_jquery'), CRAYON_VERSION);
 
53
  }
54
 
55
  public static function settings() {
@@ -185,6 +187,7 @@ class CrayonSettingsWP {
185
  // Validates all the settings passed from the form in $inputs
186
 
187
  public static function settings_validate($inputs) {
 
188
  // When reset button is pressed, remove settings so default loads next time
189
  if (array_key_exists('reset', $inputs)) {
190
  // Hide the help so we don't annoy them
@@ -200,7 +203,7 @@ class CrayonSettingsWP {
200
  }
201
  // Send to developer
202
  if (array_key_exists(self::LOG_EMAIL_DEV, $_POST)) {
203
- CrayonLog::email(CRAYON_EMAIL);
204
  }
205
 
206
  // Validate inputs
@@ -295,11 +298,12 @@ class CrayonSettingsWP {
295
 
296
  // General Fields =========================================================
297
  public static function help() {
 
298
  if (CrayonGlobalSettings::val(CrayonSettings::HIDE_HELP)) {
299
  return;
300
  }
301
  $url = plugins_url(CRAYON_AJAX_PHP, __FILE__) . '?' . CrayonSettings::HIDE_HELP . '=1';
302
- $web = CRAYON_WEBSITE;
303
  echo <<<EOT
304
  <div id="crayon-help" class="updated settings-error crayon-help">
305
  <span><strong>Howdy, coder!</strong> Thanks for using Crayon. Use <strong>help</strong> on the top-right to learn how to use the shortcode and basic features, or check out my <a href="#info">Twitter & Email</a>. For online help and info, visit <a target="_blank" href="{$web}">here</a>.</span>
@@ -510,12 +514,13 @@ EOT;
510
  // About Fields ===========================================================
511
 
512
  public static function info() {
 
513
  echo '<a name="info"></a>';
514
- $version = '<b>Version:</b> ' . CRAYON_VERSION . '<span class="crayon-span" style="width: 40px"></span>';
515
- $date = '<b>Build Date:</b> ' . CRAYON_DATE;
516
- $developer = '<b>Developer:</b> ' . CRAYON_AUTHOR;
517
- $links = '<a id="twitter-icon" href="' . CRAYON_TWITTER . '" target="_blank"></a>
518
- <a id="gmail-icon" href="mailto:' . CRAYON_EMAIL . '" target="_blank"></a>';
519
  echo <<<EOT
520
  <table id="crayon-info" border="0">
521
  <tr>
43
  }
44
 
45
  public static function admin_styles() {
46
+ global $CRAYON_VERSION;
47
+ wp_enqueue_style('crayon_admin_style', plugins_url(CRAYON_STYLE_ADMIN, __FILE__), array(), $CRAYON_VERSION);
48
  }
49
 
50
  public static function admin_scripts() {
51
+ global $CRAYON_VERSION;
52
+ wp_enqueue_script('crayon_jquery', plugins_url(CRAYON_JQUERY, __FILE__), array(), $CRAYON_VERSION);
53
+ wp_enqueue_script('crayon_admin_js', plugins_url(CRAYON_JS_ADMIN, __FILE__), array('crayon_jquery'), $CRAYON_VERSION);
54
+ wp_enqueue_script('crayon_js', plugins_url(CRAYON_JS, __FILE__), array('crayon_jquery'), $CRAYON_VERSION);
55
  }
56
 
57
  public static function settings() {
187
  // Validates all the settings passed from the form in $inputs
188
 
189
  public static function settings_validate($inputs) {
190
+ global $CRAYON_EMAIL;
191
  // When reset button is pressed, remove settings so default loads next time
192
  if (array_key_exists('reset', $inputs)) {
193
  // Hide the help so we don't annoy them
203
  }
204
  // Send to developer
205
  if (array_key_exists(self::LOG_EMAIL_DEV, $_POST)) {
206
+ CrayonLog::email($CRAYON_EMAIL);
207
  }
208
 
209
  // Validate inputs
298
 
299
  // General Fields =========================================================
300
  public static function help() {
301
+ global $CRAYON_WEBSITE;
302
  if (CrayonGlobalSettings::val(CrayonSettings::HIDE_HELP)) {
303
  return;
304
  }
305
  $url = plugins_url(CRAYON_AJAX_PHP, __FILE__) . '?' . CrayonSettings::HIDE_HELP . '=1';
306
+ $web = $CRAYON_WEBSITE;
307
  echo <<<EOT
308
  <div id="crayon-help" class="updated settings-error crayon-help">
309
  <span><strong>Howdy, coder!</strong> Thanks for using Crayon. Use <strong>help</strong> on the top-right to learn how to use the shortcode and basic features, or check out my <a href="#info">Twitter & Email</a>. For online help and info, visit <a target="_blank" href="{$web}">here</a>.</span>
514
  // About Fields ===========================================================
515
 
516
  public static function info() {
517
+ global $CRAYON_VERSION, $CRAYON_DATE, $CRAYON_AUTHOR, $CRAYON_TWITTER, $CRAYON_EMAIL;
518
  echo '<a name="info"></a>';
519
+ $version = '<b>Version:</b> ' . $CRAYON_VERSION . '<span class="crayon-span" style="width: 40px"></span>';
520
+ $date = '<b>Build Date:</b> ' . $CRAYON_DATE;
521
+ $developer = '<b>Developer:</b> ' . $CRAYON_AUTHOR;
522
+ $links = '<a id="twitter-icon" href="' . $CRAYON_TWITTER . '" target="_blank"></a>
523
+ <a id="gmail-icon" href="mailto:' . $CRAYON_EMAIL . '" target="_blank"></a>';
524
  echo <<<EOT
525
  <table id="crayon-info" border="0">
526
  <tr>
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.1
7
  Author: Aram Kocharyan
8
  Author URI: http://ak.net84.net/
9
  License: GPL2
@@ -25,6 +25,11 @@ require_once ('global.php');
25
  require_once (CRAYON_HIGHLIGHTER_PHP);
26
  require_once ('crayon_settings_wp.class.php');
27
 
 
 
 
 
 
28
  /* The plugin class that manages all other classes and integrates Crayon with WP */
29
  class CrayonWP {
30
  // Properties and Constants ===============================================
@@ -183,9 +188,10 @@ class CrayonWP {
183
  }
184
 
185
  private static function enqueue_resources() {
186
- wp_enqueue_style('crayon-style', plugins_url(CRAYON_STYLE, __FILE__), array(), CRAYON_VERSION);
187
- wp_enqueue_script('crayon-jquery', plugins_url(CRAYON_JQUERY, __FILE__), array(), CRAYON_VERSION);
188
- wp_enqueue_script('crayon-js', plugins_url(CRAYON_JS, __FILE__), array('crayon-jquery'), CRAYON_VERSION);
 
189
  self::$included = TRUE;
190
  }
191
 
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.1.1
7
  Author: Aram Kocharyan
8
  Author URI: http://ak.net84.net/
9
  License: GPL2
25
  require_once (CRAYON_HIGHLIGHTER_PHP);
26
  require_once ('crayon_settings_wp.class.php');
27
 
28
+ if (defined('ABSPATH')) {
29
+ require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
30
+ set_crayon_info(get_plugin_data( __FILE__ ));
31
+ }
32
+
33
  /* The plugin class that manages all other classes and integrates Crayon with WP */
34
  class CrayonWP {
35
  // Properties and Constants ===============================================
188
  }
189
 
190
  private static function enqueue_resources() {
191
+ global $CRAYON_VERSION;
192
+ wp_enqueue_style('crayon-style', plugins_url(CRAYON_STYLE, __FILE__), array(), $CRAYON_VERSION);
193
+ wp_enqueue_script('crayon-jquery', plugins_url(CRAYON_JQUERY, __FILE__), array(), $CRAYON_VERSION);
194
+ wp_enqueue_script('crayon-js', plugins_url(CRAYON_JS, __FILE__), array('crayon-jquery'), $CRAYON_VERSION);
195
  self::$included = TRUE;
196
  }
197
 
global.php CHANGED
@@ -8,14 +8,14 @@ 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.1.0' . $uid);
12
- define('CRAYON_DATE', '27rd September, 2011');
13
- define('CRAYON_AUTHOR', 'Aram Kocharyan');
14
- // TODO These will be changed once I set up a site for docs
15
- define('CRAYON_WEBSITE', 'http://ak.net84.net/?go=crayon');
16
- define('CRAYON_WEBSITE_DOCS', 'http://ak.net84.net/?go=crayondocs');
17
- define('CRAYON_EMAIL', 'crayon.syntax@gmail.com');
18
- define('CRAYON_TWITTER', 'http://twitter.com/crayonsyntax');
19
 
20
  // XXX Used to name the class
21
 
@@ -47,6 +47,7 @@ define('CRAYON_LOG_FILE', CRAYON_ROOT_PATH . 'log.txt');
47
  define('CRAYON_TOUCH_FILE', CRAYON_UTIL_PATH . 'touch.txt');
48
  define('CRAYON_LOG_MAX_SIZE', 50000); // Bytes
49
 
 
50
  define('CRAYON_LANG_EXT', CRAYON_LANG_PATH . 'extensions.txt');
51
  define('CRAYON_HELP_FILE', CRAYON_UTIL_PATH . 'help.htm');
52
  define('CRAYON_JQUERY', CRAYON_JS_DIR . 'jquery-1.5.min.js');
@@ -95,41 +96,33 @@ require_once (CRAYON_TIMER_PHP);
95
  require_once (CRAYON_LOG_PHP);
96
 
97
  // Turn on the error & exception handlers
98
-
99
  crayon_handler_on();
100
- // Check current version from given file, not used, realised I was losing my mind
101
-
102
- $crayon_version = NULL;
103
-
104
- function crayon_version($file = NULL) {
105
- global $crayon_version, $uid;
106
- if ($file == NULL) {
107
- // Return current version
108
 
109
- if ($crayon_version == NULL) {
110
- // Fallback to unknown version
 
 
 
 
 
 
 
 
 
 
 
 
111
 
112
- $crayon_version = 'X' . $uid;
113
- }
114
- } else if (is_string($file) && file_exists($file)) {
115
- // Extract version from file
116
-
117
- $contents = @file_get_contents($file);
118
- if ($contents !== FALSE) {
119
- $pattern = '#<\\?php\\s*\\/\\*.*Version:\\s*([^\\s]*)\\r?\\n#smi';
120
- preg_match($pattern, $contents, $match);
121
- if (count($match) > 1) {
122
- $crayon_version = $match[1] . $uid;
123
- }
124
- }
125
  }
126
- return $crayon_version;
127
  }
128
 
129
  // Check for forwardslash/backslash in folder path to structure paths
130
-
131
  $crayon_slash = NULL;
132
-
133
  function crayon_slash($url = '') {
134
  global $crayon_slash;
135
  if ($crayon_slash == NULL) {
8
 
9
  $uid = CRAYON_DEBUG ? uniqid() : ''; // Prevent caching in debug mode
10
 
11
+ // These are overriden by functions since v1.1.1
12
+ $CRAYON_VERSION = '1.1.1' . $uid;
13
+ $CRAYON_DATE = '27th September, 2011';
14
+ $CRAYON_AUTHOR = 'Aram Kocharyan';
15
+ $CRAYON_WEBSITE = 'http://ak.net84.net/?go=crayon';
16
+ $CRAYON_WEBSITE_DOCS = 'http://ak.net84.net/?go=crayondocs';
17
+ $CRAYON_EMAIL = 'crayon.syntax@gmail.com';
18
+ $CRAYON_TWITTER = 'http://twitter.com/crayonsyntax';
19
 
20
  // XXX Used to name the class
21
 
47
  define('CRAYON_TOUCH_FILE', CRAYON_UTIL_PATH . 'touch.txt');
48
  define('CRAYON_LOG_MAX_SIZE', 50000); // Bytes
49
 
50
+ define('CRAYON_README_FILE', CRAYON_ROOT_PATH . 'readme.txt');
51
  define('CRAYON_LANG_EXT', CRAYON_LANG_PATH . 'extensions.txt');
52
  define('CRAYON_HELP_FILE', CRAYON_UTIL_PATH . 'help.htm');
53
  define('CRAYON_JQUERY', CRAYON_JS_DIR . 'jquery-1.5.min.js');
96
  require_once (CRAYON_LOG_PHP);
97
 
98
  // Turn on the error & exception handlers
 
99
  crayon_handler_on();
 
 
 
 
 
 
 
 
100
 
101
+ // Get/Set plugin information
102
+ function set_crayon_info($info_array) {
103
+ global $CRAYON_VERSION, $CRAYON_DATE, $CRAYON_AUTHOR, $CRAYON_WEBSITE, $uid;
104
+ if (!is_array($info_array)) {
105
+ return;
106
+ }
107
+ set_info('Version', $info_array, $CRAYON_VERSION);
108
+ $CRAYON_VERSION .= $uid;
109
+ if (($date = @filemtime(CRAYON_README_FILE)) !== FALSE) {
110
+ $CRAYON_DATE = date("jS F, Y", $date);
111
+ }
112
+ set_info('AuthorName', $info_array, $CRAYON_A);
113
+ set_info('PluginURI', $info_array, $CRAYON_WEBSITE);
114
+ }
115
 
116
+ function set_info($key, $array, &$info) {
117
+ if (array_key_exists($key, $array)) {
118
+ $info = $array[$key];
119
+ } else {
120
+ return FALSE;
 
 
 
 
 
 
 
 
121
  }
 
122
  }
123
 
124
  // Check for forwardslash/backslash in folder path to structure paths
 
125
  $crayon_slash = NULL;
 
126
  function crayon_slash($url = '') {
127
  global $crayon_slash;
128
  if ($crayon_slash == NULL) {
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.1.0
8
 
9
  Syntax Highlighter supporting multiple languages, themes, highlighting from a URL, local file or post text.
10
 
@@ -17,6 +17,8 @@ It also supports some neat features like mobile/touchscreen device detection, mo
17
 
18
  Live Demo: <a href="http://bit.ly/poKNqs" target="_blank">http://bit.ly/poKNqs</a>
19
 
 
 
20
  == Installation ==
21
 
22
  Download the .zip of the plugin and extract the contents. Upload it to the Wordpress plugin directory and activate the plugin.
@@ -62,6 +64,9 @@ Contact me at http://twitter.com/crayonsyntax or crayon.syntax@gmail.com.
62
  * Fixes settings bug regarding copy constructor for locked settings
63
  * Minor bug fixes and cleanups
64
 
 
 
 
65
  == Upgrade Notice ==
66
 
67
  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.1.1
8
 
9
  Syntax Highlighter supporting multiple languages, themes, highlighting from a URL, local file or post text.
10
 
17
 
18
  Live Demo: <a href="http://bit.ly/poKNqs" target="_blank">http://bit.ly/poKNqs</a>
19
 
20
+ Short How-To: <a href="http://ak.net84.net/projects/crayon-syntax-highlighter/" target="_blank">http://ak.net84.net/projects/crayon-syntax-highlighter/</a>
21
+
22
  == Installation ==
23
 
24
  Download the .zip of the plugin and extract the contents. Upload it to the Wordpress plugin directory and activate the plugin.
64
  * Fixes settings bug regarding copy constructor for locked settings
65
  * Minor bug fixes and cleanups
66
 
67
+ = 1.1.1 =
68
+ * Plugin version information is updated automatically
69
+
70
  == Upgrade Notice ==
71
 
72
  No issues upgrading.
util/preview.php CHANGED
@@ -5,7 +5,7 @@ $remove = CrayonUtil::path('wp-content/plugins/' . CRAYON_DIR, CRAYON_DIR);
5
  $wp_root_path = str_replace($remove, '', CRAYON_ROOT_PATH);
6
  require_once ($wp_root_path . 'wp-load.php');
7
  echo '<link rel="stylesheet" href="', plugins_url(CRAYON_STYLE, dirname(__FILE__)),
8
- '?ver=', CRAYON_VERSION, '" type="text/css" media="all" />';
9
  echo '<script type="text/javascript">init();</script>';
10
  echo '<div id="content">';
11
  CrayonSettingsWP::load_settings(); // Run first to ensure global settings loaded
5
  $wp_root_path = str_replace($remove, '', CRAYON_ROOT_PATH);
6
  require_once ($wp_root_path . 'wp-load.php');
7
  echo '<link rel="stylesheet" href="', plugins_url(CRAYON_STYLE, dirname(__FILE__)),
8
+ '?ver=', $CRAYON_VERSION, '" type="text/css" media="all" />';
9
  echo '<script type="text/javascript">init();</script>';
10
  echo '<div id="content">';
11
  CrayonSettingsWP::load_settings(); // Run first to ensure global settings loaded