Changeset 661663
- Timestamp:
- 01/31/2013 01:54:16 PM (13 years ago)
- Location:
- igsyntax-hiliter/trunk
- Files:
-
- 4 edited
-
MANUAL.txt (modified) (11 diffs)
-
class-ig-syntax-hiliter-frontend.php (modified) (8 diffs)
-
ig-syntax-hiliter.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
igsyntax-hiliter/trunk/MANUAL.txt
r660827 r661663 4 4 5 5 6 Version: 4. 06 Version: 4.1 7 7 Author: Amit Gupta 8 8 Plugin URI: http://blog.igeek.info/wp-plugins/igsyntax-hiliter/ … … 43 43 2. WHAT's NEW 44 44 ----------------------------------------------------------------------------------------- 45 v4.1 46 ------------- 47 BUGFIX: Github Gist URL XSS security hole 48 BUGFIX: __dir__ doesn't work below PHP 5.3 - props to Karol Kuczmarski for spotting it 49 NEW: Added "lang" as shorthand for "language" attribute 50 NEW: Additional GeSHi language files can be put in "geshi" directory in theme, which will prevent their deletion on plugin upgrade 51 IMPROVED: If a code block is repeated with same attributes then its parsed only once and output is reused 52 53 45 54 v4.0 46 55 ------------- … … 57 66 v3.5 58 67 ------------- 59 BUGFIX: -BB Tags except the ones of iG:Syntax Hiliter are allowed. The language file's existence is checked before parsing the code. If the language file does not exist then the code is not parsed.60 BUGFIX: -'C' code hiliting is now fixed.61 BUGFIX: -'Plain Text' has been improved to strip the extra blank lines and spaces in Opera and FireFox.68 BUGFIX: BB Tags except the ones of iG:Syntax Hiliter are allowed. The language file's existence is checked before parsing the code. If the language file does not exist then the code is not parsed. 69 BUGFIX: 'C' code hiliting is now fixed. 70 BUGFIX: 'Plain Text' has been improved to strip the extra blank lines and spaces in Opera and FireFox. 62 71 The latest stable GeSHi core(v1.0.7.6). 63 NEW: -Code Hiliting for Comments has been implemented. This feature can be Enabled/Disabled from the admin interface for iG:Syntax Hiliter. The tags are same for hiliting the code.64 NEW: -A cross-browser Colour Picker(tested in IE6, FireFox1.5 and Opera8.5) is now available to easily set the line colours displayed in the code box.65 NEW: -A new type of view implemented for seeing "Plain Text" code. Besides opening the plain text code in a new window, you can have it displayed in the code box itself with an option to display the hilited HTML code back again. The "Plain Text" view type can be set in the admin interface.72 NEW: Code Hiliting for Comments has been implemented. This feature can be Enabled/Disabled from the admin interface for iG:Syntax Hiliter. The tags are same for hiliting the code. 73 NEW: A cross-browser Colour Picker(tested in IE6, FireFox1.5 and Opera8.5) is now available to easily set the line colours displayed in the code box. 74 NEW: A new type of view implemented for seeing "Plain Text" code. Besides opening the plain text code in a new window, you can have it displayed in the code box itself with an option to display the hilited HTML code back again. The "Plain Text" view type can be set in the admin interface. 66 75 The language file for Ruby that I created a while back is now bundled with the plugin and its also a part of the default GeSHi package. 67 76 … … 69 78 v3.1 70 79 ------------- 71 BUGFIX: -Critical bug, which broke the plugin when the square brackets([ & ]) were used in the posts in places other than tags, has been fixed.72 BUGFIX: -Another bug, which allowed any attribute in the tags besides the 'num' and also allowed any attribute value for it, affecting the processing. Now only the 'num' attribute is accepted and if you specify the 'num' attribute then its value must be a positive number otherwise your code won't be hilited. The 'num' attribute is optional and you can leave it out without any problems.73 BUGFIX: -Fixed the unclosed <select> tags in the Plugin GUI code.74 GeSHi BUGFIX: -Fixed a bug in GeSHi where the first line colour was not used when using FANCY LINE NUMBERS thus resulting in just one colour being used for the alternate lines.80 BUGFIX: Critical bug, which broke the plugin when the square brackets([ & ]) were used in the posts in places other than tags, has been fixed. 81 BUGFIX: Another bug, which allowed any attribute in the tags besides the 'num' and also allowed any attribute value for it, affecting the processing. Now only the 'num' attribute is accepted and if you specify the 'num' attribute then its value must be a positive number otherwise your code won't be hilited. The 'num' attribute is optional and you can leave it out without any problems. 82 BUGFIX: Fixed the unclosed <select> tags in the Plugin GUI code. 83 GeSHi BUGFIX: Fixed a bug in GeSHi where the first line colour was not used when using FANCY LINE NUMBERS thus resulting in just one colour being used for the alternate lines. 75 84 There's a problem in WordPress due to which the starting delimiters of ASP, PHP were not displayed correctly, as whitespace was inserted between the '<' and the rest of the delimiter. This has been patched so that its displayed correctly, but its not saved in the database, so the database still contains the delimiters as formatted by WordPress. 76 85 … … 78 87 v3.0 79 88 ------------- 80 NEW LICENSE: --iG:Syntax Hiliter is now licensed under GNU GPL.89 NEW LICENSE: iG:Syntax Hiliter is now licensed under GNU GPL. 81 90 Complete re-write of the plugin resulting in reduction of code from 750+ lines to about 400 Lines. 82 91 New GeSHi Core(v1.0.7) which has some bug-fixes, please see GeSHi Website for its changelog. … … 92 101 v2.01 93 102 ------------- 94 BUGFIX: -Fixed a bug by removing a <br /> tag from the function pFix() which lead to closing of an unnecessary <p> tag making the code not xHTML valid(as per my desires).103 BUGFIX: Fixed a bug by removing a <br /> tag from the function pFix() which lead to closing of an unnecessary <p> tag making the code not xHTML valid(as per my desires). 95 104 96 105 … … 101 110 iG:Syntax Hiliter now also supports ActionScript, C, C++, JavaScript, Perl, Python, Visual Basic & XML. 102 111 The whole plugin has been re-written & all the hiliting code is now in a class. You can just use the class anywhere else too for hiliting the code. But to also use the Code Tags to wrap your code & then hilite them, you will need to use all other functions. You can remove the WordPress Filter calls at the end of the plugin & use the rest of the code as you want somewhere else. 103 BUGFIX: -The issue of multi-line comments not being hilited properly in v2.0 Preview has been sorted out.112 BUGFIX: The issue of multi-line comments not being hilited properly in v2.0 Preview has been sorted out. 104 113 105 114 … … 129 138 ----------------------------------------------------------------------------------------- 130 139 131 Installation is fairly easy. Just follow the steps: -140 Installation is fairly easy. Just follow the steps: 132 141 133 142 Extract the contents of zip file and upload its contents as they are to your WordPress plugins directory, or just install directly from WordPress plugins repository. … … 141 150 4. UPGRADING 142 151 ----------------------------------------------------------------------------------------- 143 Note: One click upgrades will be supported from this releaseonwards.152 Note: One click upgrades are supported from v4.0 onwards. 144 153 145 154 Upgrading from an old version? No problem, its as easy as popping a candy in your mouth. 155 156 157 UPGRADING from v4.0 or later 158 --------------------------------- 159 Just deactivate plugin in WordPress admin, delete the "ig-syntax-hiliter" directory from plugins folder and follow the INSTALLATION process again. That's quite easy!! 146 160 147 161 148 162 UPGRADING from v3.x 149 163 --------------------------------- 150 Just deactivate plugin in WordPress admin, delete the syntax_hilite.php file & "ig -syntax-hiliter" directory from plugins folder and follow the INSTALLATION process again. That's quite easy!!164 Just deactivate plugin in WordPress admin, delete the syntax_hilite.php file & "ig_syntax_hilite" directory from plugins folder and follow the INSTALLATION process again. That's quite easy!! 151 165 152 166 … … 188 202 Following are the (optional) attributes: 189 203 190 language => Use this to specify the programming language whose code you want to hilite. This language has to be present in 'geshi' directory inside plugin directory. If 'language' attribute is not specified or if a non-existant language is specified in it then a generic code box is rendered. 204 language => Use this to specify the programming language whose code you want to hilite. This language has to be present in 'geshi' directory inside plugin directory. If 'language' attribute is not specified or if a non-existant language is specified in it then a generic code box is rendered. 'lang' is the shorthand for 'language' attribute. 191 205 192 206 firstline => Use this to start line numbering from a number greater than 1 … … 208 222 The plugin also supports shorthand tags. So something like this: 209 223 224 [sourcecode language="php" highlight="5,11"] 225 //some code here 226 [/sourcecode] 227 228 can also be written as: 229 210 230 [php highlight="5,11"] 211 231 //some code here 212 232 [/php] 213 233 214 would be like using:215 216 [sourcecode language="php" highlight="5,11"]217 //some code here218 [/sourcecode]219 220 234 Its advised to use the full format of the tag for semantics, however its a personal choice and the plugin supports both full format and shorthand. 221 235 -
igsyntax-hiliter/trunk/class-ig-syntax-hiliter-frontend.php
r660809 r661663 258 258 259 259 extract( shortcode_atts( array( 260 'language' => ' code',260 'language' => '', 261 261 'firstline' => 1, 262 262 'highlight' => 0, … … 265 265 'plaintext' => '', 266 266 'toolbar' => '', 267 'lang' => 'code', 267 268 'num' => 1, 268 269 ), $attrs ) ); … … 271 272 $firstline = ( intval( $firstline ) < 1 ) ? 1 : intval( $firstline ); 272 273 $firstline = ( $num > $firstline ) ? $num : $firstline; 274 275 $language = ( empty( $language ) ) ? $lang : $language; 276 unset( $lang ); 273 277 274 278 $language = sanitize_title( $language ); … … 323 327 $is_language = false; //language file doesn't exist 324 328 } 329 330 //check for language file in theme directory 331 if( $is_language === false ) { 332 if( ! file_exists( get_template_directory() . '/geshi/' . $language . '.php' ) ) { 333 $is_language = false; //language file doesn't exist 334 } else { 335 $is_language = true; 336 $dir_path = get_template_directory() . '/geshi/'; 337 } 338 } 339 340 //check for language file in child theme directory 341 if( $is_language === false && get_template_directory() !== get_stylesheet_directory() ) { 342 if( ! file_exists( get_stylesheet_directory() . '/geshi/' . $language . '.php' ) ) { 343 $is_language = false; //language file doesn't exist 344 } else { 345 $is_language = true; 346 $dir_path = get_stylesheet_directory() . '/geshi/'; 347 } 348 } 325 349 } 326 350 … … 329 353 //set the code block to be hilited using the 'code' lang file 330 354 $language = 'code'; 355 $language_display = $language; 331 356 } 332 357 … … 371 396 372 397 $geshi = new GeSHi( $code, $language ); 398 399 if( isset($dir_path) && ! empty($dir_path) ) { 400 //language file is not in plugin folder, load from theme 401 $geshi->set_language_path( $dir_path ); 402 } 373 403 374 404 $geshi_error = $geshi->error(); … … 437 467 } 438 468 439 $shortcode_md5 = md5( microtime( true ) . '-' . serialize( array( 469 ksort( $atts ); //sort attribute array on keys 470 471 $shortcode_md5 = md5( serialize( array( 440 472 'text' => $code, 441 473 'atts' => $atts 442 ) ) ); //create unique token key for this code block 443 444 $this->__hilited_code[$shortcode_md5] = $this->_get_hilited_code( $atts, $code ); //save hilited code in array 445 if( empty( $this->__hilited_code[$shortcode_md5] ) ) { 446 unset( $this->__hilited_code[$shortcode_md5] ); 447 return; 474 ) ) ); //create unique token key for this code block with these attributes 475 476 if( ! array_key_exists( $shortcode_md5, $this->__hilited_code ) ) { 477 $this->__hilited_code[$shortcode_md5] = $this->_get_hilited_code( $atts, $code ); //save hilited code in array 478 479 if( empty( $this->__hilited_code[$shortcode_md5] ) ) { 480 //banged up somewhere, we didn't get anything, unset key in array & return empty 481 unset( $this->__hilited_code[$shortcode_md5] ); 482 return; 483 } 448 484 } 449 485 … … 543 579 ), $attrs ) ); 544 580 581 $gist = esc_url( $gist ); 582 583 if( ! empty( $gist ) ) { 584 //gist attr takes priority 585 $gist = rtrim( $gist, '/' ); 586 $arr_gist_url = explode( '/', $gist ); 587 588 $gist_id = array_pop( $arr_gist_url ); 589 590 if( ! empty( $gist_id ) ) { 591 $id = $gist_id; 592 } 593 594 unset( $gist_id, $arr_gist_url ); 595 } 596 597 if( empty( $id ) ) { 598 return; 599 } 600 545 601 $id = sanitize_user( $id, true ); //since ID can only be alphanumeric 546 $gist = esc_url( $gist ); 547 548 if( empty( $id ) && empty( $gist ) ) { 549 return; 550 } 551 552 if( ! empty( $gist ) ) { 553 $gist = rtrim( $gist, '/' ); //gist attr takes priority 554 } else { 555 $gist = esc_url( 'https://gist.github.com/' . $id ); 556 } 602 $gist = esc_url( 'https://gist.github.com/' . $id ); 557 603 558 604 $returnable = '<script src="' . $gist . '.js"></script>'; -
igsyntax-hiliter/trunk/ig-syntax-hiliter.php
r660809 r661663 4 4 Plugin URI: http://blog.igeek.info/wp-plugins/igsyntax-hiliter/ 5 5 Description: Syntax Highlighter plugin to colourize source code for various supported programming languages. See the MANUAL for more instructions. 6 Version: 4. 06 Version: 4.1 7 7 Author: Amit Gupta 8 8 Author URI: http://blog.igeek.info/ … … 10 10 11 11 if( ! defined('IG_SYNTAX_HILITER_VERSION') ) { 12 define( 'IG_SYNTAX_HILITER_VERSION', 4. 0);12 define( 'IG_SYNTAX_HILITER_VERSION', 4.1 ); 13 13 } 14 15 //load up the plugin base abstract class16 require_once( __DIR__ . "/class-ig-syntax-hiliter.php" );17 //load up the plugin admin class18 require_once( __DIR__ . "/class-ig-syntax-hiliter-admin.php" );19 //load up the plugin front-end class20 require_once( __DIR__ . "/class-ig-syntax-hiliter-frontend.php" );21 22 //load up GeSHi23 require_once( __DIR__ . "/geshi.php" );24 14 25 15 //set loader to execute on WP init … … 27 17 28 18 function ig_syntax_hiliter_loader() { 29 if( ! isset($GLOBALS['ig_syntax_hiliter_admin']) || ! is_a( $GLOBALS['ig_syntax_hiliter_admin'], 'iG_Syntax_Hiliter_Admin' ) ) { 30 $GLOBALS['ig_syntax_hiliter_admin'] = iG_Syntax_Hiliter_Admin::get_instance(); 19 $igsh_plugin_dir = dirname( __FILE__ ); 20 21 //load up GeSHi 22 require_once( $igsh_plugin_dir . "/geshi.php" ); 23 24 //load up the plugin base abstract class 25 require_once( $igsh_plugin_dir . "/class-ig-syntax-hiliter.php" ); 26 27 if( is_admin() ) { 28 //load up the plugin admin class 29 require_once( $igsh_plugin_dir . "/class-ig-syntax-hiliter-admin.php" ); 30 31 if( ! isset($GLOBALS['ig_syntax_hiliter_admin']) || ! is_a( $GLOBALS['ig_syntax_hiliter_admin'], 'iG_Syntax_Hiliter_Admin' ) ) { 32 $GLOBALS['ig_syntax_hiliter_admin'] = iG_Syntax_Hiliter_Admin::get_instance(); 33 } 31 34 } 32 if( ! isset($GLOBALS['ig_syntax_hiliter_frontend']) || ! is_a( $GLOBALS['ig_syntax_hiliter_frontend'], 'iG_Syntax_Hiliter_Frontend' ) ) { 33 $GLOBALS['ig_syntax_hiliter_frontend'] = iG_Syntax_Hiliter_Frontend::get_instance(); 35 36 if( ! is_admin() ) { 37 //load up the plugin front-end class 38 require_once( $igsh_plugin_dir . "/class-ig-syntax-hiliter-frontend.php" ); 39 40 if( ! isset($GLOBALS['ig_syntax_hiliter_frontend']) || ! is_a( $GLOBALS['ig_syntax_hiliter_frontend'], 'iG_Syntax_Hiliter_Frontend' ) ) { 41 $GLOBALS['ig_syntax_hiliter_frontend'] = iG_Syntax_Hiliter_Frontend::get_instance(); 42 } 34 43 } 44 45 unset( $igsh_plugin_dir ); 35 46 } 36 47 -
igsyntax-hiliter/trunk/readme.txt
r661044 r661663 18 18 19 19 == Installation == 20 21 ###UPGRADING from v4.0 or later### 22 23 Just deactivate plugin in WordPress admin, delete the "ig-syntax-hiliter" directory from plugins folder and follow the INSTALLATION process again. That's quite easy!! 20 24 21 25 ###UPGRADING from v3.x### … … 82 86 == ChangeLog == 83 87 88 = v4.1 = 89 90 * BUGFIX: Github Gist URL XSS security hole 91 * BUGFIX: __dir__ doesn't work below PHP 5.3 - props to Karol Kuczmarski for spotting it 92 * NEW: Added "lang" as shorthand for "language" attribute 93 * NEW: Additional GeSHi language files can be put in "geshi" directory in theme, which will prevent their deletion on plugin upgrade 94 * IMPROVED: If a code block is repeated with same attributes then its parsed only once and output is reused 95 84 96 = v4.0 = 85 97
Note: See TracChangeset
for help on using the changeset viewer.