WordPress.org

Plugin Directory

Changeset 415480


Ignore:
Timestamp:
07/26/11 16:17:29 (3 years ago)
Author:
pross
Message:

new regex checking for _x() props Vicky. (refined)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • theme-check/trunk/checks/textdomain.php

    r415475 r415480  
    1313 
    1414        $checks = array( 
    15         '/_[e|_]\(\s?[\'|"][^\'|"]*[\'|"]\s?\);/' => __( 'You have not included a text domain!', 'themecheck' ) ); 
     15        '/[\s|\(]_[e|_]\s?\(\s?[\'|"][^\'|"]*[\'|"]\s?\)/' => __( 'You have not included a text domain!', 'themecheck' ), 
     16        '/[\s|\(]_x\s?\(\s?[\'|"][^\'|"]*[\'|"]\s?,\s?[\'|"][^\'|"]*[\'|"]\s?\)/' => __( 'You have not included a text domain!', 'themecheck' ) 
     17         ); 
    1618 
    1719        foreach ( $php_files as $php_key => $phpfile ) { 
     
    2325                     
    2426                    foreach ($matches[0] as $match ) {           
    25                         $error .= tc_grep( $match, $php_key ); 
     27                        $error .= tc_grep( ltrim( $match ), $php_key ); 
    2628                    } 
    2729                    $this->error[] = __( "<span class='tc-lead tc-recommended'>RECOMMENDED</span>: Text domain problems in <strong>{$filename}</strong>. {$check}{$error}", "themecheck" ); 
     
    3133 
    3234        $checks = array( 
    33         '/_[e|_]\([^,|;]*,\s?[\'|"]([^\'|"]*)[\'|"]\s?\)/' => __( 'Text domain should match theme slug: <strong>' . $themename . '</strong>', 'themecheck' ), 
    34         '/_x\s?\([^,]*,\s[^\'|"]*[\'|"][^\'|"]*[\'|"],\s?[\'|"]([^\'|"]*)[\'|"]\s?\)/' => __( 'Text domain should match theme slug: <strong>' . $themename . '</strong>', 'themecheck' ) 
     35        '/[\s|\(]_[e|_]\s?\([^,|;]*\s?,\s?[\'|"]([^\'|"]*)[\'|"]\s?\)/' => __( 'Text domain should match theme slug: <strong>' . $themename . '</strong>', 'themecheck' ), 
     36        '/[\s|\(]_x\s?\([^,]*\s?,\s[^\'|"]*[\'|"][^\'|"]*[\'|"],\s?[\'|"]([^\'|"]*)[\'|"]\s?\)/' => __( 'Text domain should match theme slug: <strong>' . $themename . '</strong>', 'themecheck' ) 
    3537         ); 
    3638        foreach ( $php_files as $php_key => $phpfile ) { 
     
    3941                if ( preg_match_all( $key, $phpfile, $matches ) ) { 
    4042                    foreach ($matches[0] as $count => $domaincheck) { 
    41                         if ( preg_match( '/_[e|_]\(\s?[\'|"][^\'|"]*[\'|"]\s?\)/', $domaincheck ) ) 
     43                        if ( preg_match( '/[\s|\(]_[e|_]\s?\(\s?[\'|"][^\'|"]*[\'|"]\s?\)/', $domaincheck ) ) 
    4244                            unset( $matches[1][$count] ); //filter out false positives 
    4345                    } 
Note: See TracChangeset for help on using the changeset viewer.