Plugin Directory

Changeset 661663


Ignore:
Timestamp:
01/31/2013 01:54:16 PM (13 years ago)
Author:
amit
Message:

added v4.1

Location:
igsyntax-hiliter/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • igsyntax-hiliter/trunk/MANUAL.txt

    r660827 r661663  
    44
    55
    6 Version: 4.0
     6Version: 4.1
    77Author: Amit Gupta
    88Plugin URI: http://blog.igeek.info/wp-plugins/igsyntax-hiliter/
     
    43432. WHAT's NEW
    4444-----------------------------------------------------------------------------------------
     45v4.1
     46-------------
     47BUGFIX: Github Gist URL XSS security hole
     48BUGFIX: __dir__ doesn't work below PHP 5.3 - props to Karol Kuczmarski for spotting it
     49NEW: Added "lang" as shorthand for "language" attribute
     50NEW: Additional GeSHi language files can be put in "geshi" directory in theme, which will prevent their deletion on plugin upgrade
     51IMPROVED: If a code block is repeated with same attributes then its parsed only once and output is reused
     52
     53
    4554v4.0
    4655-------------
     
    5766v3.5
    5867-------------
    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.
     68BUGFIX: 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.
     69BUGFIX: 'C' code hiliting is now fixed.
     70BUGFIX: 'Plain Text' has been improved to strip the extra blank lines and spaces in Opera and FireFox.
    6271The 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.
     72NEW: 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.
     73NEW: 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.
     74NEW: 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.
    6675The 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.
    6776
     
    6978v3.1
    7079-------------
    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.
     80BUGFIX: Critical bug, which broke the plugin when the square brackets([ & ]) were used in the posts in places other than tags, has been fixed.
     81BUGFIX: 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.
     82BUGFIX: Fixed the unclosed <select> tags in the Plugin GUI code.
     83GeSHi 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.
    7584There'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.
    7685
     
    7887v3.0
    7988-------------
    80 NEW LICENSE:-- iG:Syntax Hiliter is now licensed under GNU GPL.
     89NEW LICENSE: iG:Syntax Hiliter is now licensed under GNU GPL.
    8190Complete re-write of the plugin resulting in reduction of code from 750+ lines to about 400 Lines.
    8291New GeSHi Core(v1.0.7) which has some bug-fixes, please see GeSHi Website for its changelog.
     
    92101v2.01
    93102-------------
    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).
     103BUGFIX: 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).
    95104
    96105
     
    101110iG:Syntax Hiliter now also supports ActionScript, C, C++, JavaScript, Perl, Python, Visual Basic & XML.
    102111The 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.
     112BUGFIX: The issue of multi-line comments not being hilited properly in v2.0 Preview has been sorted out.
    104113
    105114
     
    129138-----------------------------------------------------------------------------------------
    130139
    131 Installation is fairly easy. Just follow the steps:-
     140Installation is fairly easy. Just follow the steps:
    132141
    133142Extract 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.
     
    1411504. UPGRADING
    142151-----------------------------------------------------------------------------------------
    143 Note: One click upgrades will be supported from this release onwards.
     152Note: One click upgrades are supported from v4.0 onwards.
    144153
    145154Upgrading from an old version? No problem, its as easy as popping a candy in your mouth.
     155
     156
     157UPGRADING from v4.0 or later
     158---------------------------------
     159Just deactivate plugin in WordPress admin, delete the "ig-syntax-hiliter" directory from plugins folder and follow the INSTALLATION process again. That's quite easy!!
    146160
    147161
    148162UPGRADING from v3.x
    149163---------------------------------
    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!!
     164Just 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!!
    151165
    152166
     
    188202Following are the (optional) attributes:
    189203
    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.
     204language    => 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.
    191205
    192206firstline   => Use this to start line numbering from a number greater than 1
     
    208222The plugin also supports shorthand tags. So something like this:
    209223
     224[sourcecode language="php" highlight="5,11"]
     225//some code here
     226[/sourcecode]
     227
     228can also be written as:
     229
    210230[php highlight="5,11"]
    211231//some code here
    212232[/php]
    213233
    214 would be like using:
    215 
    216 [sourcecode language="php" highlight="5,11"]
    217 //some code here
    218 [/sourcecode]
    219 
    220234Its 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.
    221235
  • igsyntax-hiliter/trunk/class-ig-syntax-hiliter-frontend.php

    r660809 r661663  
    258258
    259259        extract( shortcode_atts( array(
    260             'language' => 'code',
     260            'language' => '',
    261261            'firstline' => 1,
    262262            'highlight' => 0,
     
    265265            'plaintext' => '',
    266266            'toolbar' => '',
     267            'lang' => 'code',
    267268            'num' => 1,
    268269        ), $attrs ) );
     
    271272        $firstline = ( intval( $firstline ) < 1 ) ? 1 : intval( $firstline );
    272273        $firstline = ( $num > $firstline ) ? $num : $firstline;
     274
     275        $language = ( empty( $language ) ) ? $lang : $language;
     276        unset( $lang );
    273277
    274278        $language = sanitize_title( $language );
     
    323327                $is_language = false;   //language file doesn't exist
    324328            }
     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            }
    325349        }
    326350
     
    329353            //set the code block to be hilited using the 'code' lang file
    330354            $language = 'code';
     355            $language_display = $language;
    331356        }
    332357
     
    371396
    372397        $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        }
    373403
    374404        $geshi_error = $geshi->error();
     
    437467        }
    438468
    439         $shortcode_md5 = md5( microtime( true ) . '-' . serialize( array(
     469        ksort( $atts ); //sort attribute array on keys
     470
     471        $shortcode_md5 = md5( serialize( array(
    440472            'text' => $code,
    441473            '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            }
    448484        }
    449485
     
    543579        ), $attrs ) );
    544580
     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
    545601        $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 );
    557603
    558604        $returnable = '<script src="' . $gist . '.js"></script>';
  • igsyntax-hiliter/trunk/ig-syntax-hiliter.php

    r660809 r661663  
    44Plugin URI: http://blog.igeek.info/wp-plugins/igsyntax-hiliter/
    55Description: Syntax Highlighter plugin to colourize source code for various supported programming languages. See the MANUAL for more instructions.
    6 Version: 4.0
     6Version: 4.1
    77Author: Amit Gupta
    88Author URI: http://blog.igeek.info/
     
    1010
    1111if( ! defined('IG_SYNTAX_HILITER_VERSION') ) {
    12     define( 'IG_SYNTAX_HILITER_VERSION', 4.0 );
     12    define( 'IG_SYNTAX_HILITER_VERSION', 4.1 );
    1313}
    14 
    15 //load up the plugin base abstract class
    16 require_once( __DIR__ . "/class-ig-syntax-hiliter.php" );
    17 //load up the plugin admin class
    18 require_once( __DIR__ . "/class-ig-syntax-hiliter-admin.php" );
    19 //load up the plugin front-end class
    20 require_once( __DIR__ . "/class-ig-syntax-hiliter-frontend.php" );
    21 
    22 //load up GeSHi
    23 require_once( __DIR__ . "/geshi.php" );
    2414
    2515//set loader to execute on WP init
     
    2717
    2818function 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        }
    3134    }
    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        }
    3443    }
     44
     45    unset( $igsh_plugin_dir );
    3546}
    3647
  • igsyntax-hiliter/trunk/readme.txt

    r661044 r661663  
    1818
    1919== Installation ==
     20
     21###UPGRADING from v4.0 or later###
     22
     23Just deactivate plugin in WordPress admin, delete the "ig-syntax-hiliter" directory from plugins folder and follow the INSTALLATION process again. That's quite easy!!
    2024
    2125###UPGRADING from v3.x###
     
    8286== ChangeLog ==
    8387
     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
    8496= v4.0 =
    8597
Note: See TracChangeset for help on using the changeset viewer.