check($php, $css, $other); } } return $pass; } function display_themechecks() { $results = ''; global $themechecks; $errors = array(); foreach ($themechecks as $check) { if ($check instanceof themecheck) { $error = $check->getError(); $error = (array) $error; if (!empty($error)) { $errors = array_unique( array_merge( $error, $errors ) ); } } } if (!empty($errors)) { rsort($errors); foreach ($errors as $e) { if ( defined( 'TC_TRAC' ) ) { $results .= ( isset( $_POST['s_info'] ) && preg_match( '/INFO/', $e ) ) ? '' : '* ' . tc_trac( $e ) . "\r\n"; } else { $results .= ( isset( $_POST['s_info'] ) && preg_match( '/INFO/', $e ) ) ? '' : '
Line ", "themecheck") . ( $line_index+1 ) . ": " . $pre . htmlspecialchars( substr( stristr( $this_line, $error ), 0, 75 ) ) . ""; } $line_index++; } return str_replace( $error, '' . $error . '', $bad_lines ); } function tc_preg( $preg, $file ) { $lines = file( $file, FILE_IGNORE_NEW_LINES ); // Read the theme file into an array $line_index = 0; $bad_lines = ''; foreach( $lines as $this_line ) { if ( preg_match( $preg, $this_line, $matches ) ) { $error = $matches[0]; $this_line = str_replace( '"', "'", $this_line ); $error = ltrim( $error ); $pre = ( FALSE !== ( $pos = strpos( $this_line, $error ) ) ? substr( $this_line, 0, $pos ) : FALSE ); $pre = ltrim( htmlspecialchars( $pre ) ); $bad_lines .= __("
Line ", "themecheck") . ( $line_index+1 ) . ": " . $pre . htmlspecialchars( substr( stristr( $this_line, $error ), 0, 75 ) ) . ""; } $line_index++; } return str_replace( $error, '' . $error . '', $bad_lines ); } function tc_strxchr($haystack, $needle, $l_inclusive = 0, $r_inclusive = 0){ if(strrpos($haystack, $needle)){ //Everything before last $needle in $haystack. $left = substr($haystack, 0, strrpos($haystack, $needle) + $l_inclusive); //Switch value of $r_inclusive from 0 to 1 and viceversa. $r_inclusive = ($r_inclusive == 0) ? 1 : 0; //Everything after last $needle in $haystack. $right = substr(strrchr($haystack, $needle), $r_inclusive); //Return $left and $right into an array. return array($left, $right); } else { if(strrchr($haystack, $needle)) return array('', substr(strrchr($haystack, $needle), $r_inclusive)); else return false; } } function tc_filename( $file ) { $filename = ( preg_match( '/plugins\/(.*)/', $file, $out ) ) ? $out[1] : basename( $file ); return $filename; } function tc_trac( $e ) { $trac_left = array( '', '' ); $trac_right= array( "'''", "'''" ); $html_link = '/([^<]*)<\/a>/i'; $html_new = '[$1 $2]'; if ( defined( 'TC_TRAC' ) ) { $e = preg_replace( $html_link, $html_new, $e ); $e = str_replace( $trac_left, $trac_right, $e ); $e = preg_replace( '/
array(
'href' => array(),'title' => array()
),
'abbr' => array(
'title' => array()
),
'acronym' => array(
'title' => array()
),
'code' => array(),
'em' => array(),
'strong' => array()
);
$theme_data = str_replace ( '\r', '\n', $theme_data );
preg_match( '|Theme Name:(.*)$|mi', $theme_data, $theme_name );
preg_match( '|Theme URI:(.*)$|mi', $theme_data, $theme_uri );
preg_match( '|Description:(.*)$|mi', $theme_data, $description );
if ( preg_match( '|Author URI:(.*)$|mi', $theme_data, $author_uri ) )
$author_uri = esc_url( trim( $author_uri[1]) );
else
$author_uri = '';
if ( preg_match( '|Template:(.*)$|mi', $theme_data, $template ) )
$template = wp_kses( trim( $template[1] ), $themes_allowed_tags );
else
$template = '';
if ( preg_match( '|Version:(.*)|i', $theme_data, $version ) )
$version = wp_kses( trim( $version[1] ), $themes_allowed_tags );
else
$version = '';
if ( preg_match('|Status:(.*)|i', $theme_data, $status) )
$status = wp_kses( trim( $status[1] ), $themes_allowed_tags );
else
$status = 'publish';
if ( preg_match('|Tags:(.*)|i', $theme_data, $tags) )
$tags = array_map( 'trim', explode( ',', wp_kses( trim( $tags[1] ), array() ) ) );
else
$tags = array();
$name = $theme = wp_kses( trim( $theme_name[1] ), $themes_allowed_tags );
$theme_uri = esc_url( trim( $theme_uri[1] ) );
$description = wp_kses( trim( $description[1] ), $themes_allowed_tags );
if ( preg_match( '|Author:(.*)$|mi', $theme_data, $author_name ) ) {
if ( empty( $author_uri ) ) {
$author = wp_kses( trim( $author_name[1] ), $themes_allowed_tags );
} else {
$author = sprintf( '%3$s', $author_uri, __( 'Visit author homepage' ), wp_kses( trim( $author_name[1] ), $themes_allowed_tags ) );
}
} else {
$author = __('Anonymous');
}
return array( 'Name' => $name, 'Title' => $theme, 'URI' => $theme_uri, 'Description' => $description, 'Author' => $author, 'Author_URI' => $author_uri, 'Version' => $version, 'Template' => $template, 'Status' => $status, 'Tags' => $tags );
}