' . sprintf(__('Parent theme %1$s not found! You have to have parent AND child-theme installed!', 'theme-check'), '' . $data[ 'Template' ] . '' ) . ''; return; } $parent_data = tc_get_theme_data( $parent . '/style.css' ); $themename = basename( $parent ); $files = array_merge( listdir( $parent ), $files ); } if ( $files ) { foreach( $files as $key => $filename ) { if ( substr( $filename, -4 ) == '.php' && ! is_dir( $filename ) ) { $php[$filename] = file_get_contents( $filename ); $php[$filename] = tc_strip_comments( $php[$filename] ); } else if ( substr( $filename, -4 ) == '.css' && ! is_dir( $filename ) ) { $css[$filename] = file_get_contents( $filename ); } else { $other[$filename] = ( ! is_dir($filename) ) ? file_get_contents( $filename ) : ''; } } // run the checks $success = run_themechecks($php, $css, $other); global $checkcount; // second loop, to display the errors echo '

' . __( 'Theme Info', 'theme-check' ) . ':

'; echo '
'; if (file_exists( trailingslashit( WP_CONTENT_DIR . '/themes' ) . trailingslashit( basename( $theme ) ) . 'screenshot.png' ) ) { $image = getimagesize( $theme . '/screenshot.png' ); echo '
'; echo '
' . $image[0] . 'x' . $image[1] . ' ' . round( filesize( $theme . '/screenshot.png' )/1024 ) . 'k
'; } echo ( !empty( $data[ 'Title' ] ) ) ? '

' . $data[ 'Title' ] . '

' : ''; echo ( !empty( $data[ 'Version' ] ) ) ? '

' . $data[ 'Version' ] . '

' : ''; echo ( !empty( $data[ 'AuthorName' ] ) ) ? '

' . $data[ 'AuthorName' ] . '

' : ''; echo ( !empty( $data[ 'AuthorURI' ] ) ) ? '

' . $data[ 'AuthorURI' ] . '' . '

' : ''; echo ( !empty( $data[ 'URI' ] ) ) ? '

' . $data[ 'URI' ] . '' . '

' : ''; echo ( !empty( $data[ 'License' ] ) ) ? '

' . $data[ 'License' ] . '

' : ''; echo ( !empty( $data[ 'License URI' ] ) ) ? '

' . $data[ 'License URI' ] . '

' : ''; echo ( !empty( $data[ 'Tags' ] ) ) ? '

' . implode( $data[ 'Tags' ], ', ') . '

' : ''; echo ( !empty( $data[ 'Description' ] ) ) ? '

' . $data[ 'Description' ] . '

' : ''; if ( $data[ 'Template' ] ) { if ( $data['Template Version'] > $parent_data['Version'] ) { echo '

' . sprintf( __('This child theme requires at least version %1$s of theme %2$s to be installed. You only have %3$s please update the parent theme.', 'theme-check'), '' . $data['Template Version'] . '', '' . $parent_data['Title'] . '', '' . $parent_data['Version'] . '' ) . '

'; } echo '

' . sprintf( __( 'This is a child theme. The parent theme is: %s. These files have been included automatically!', 'theme-check'), '' . $data[ 'Template' ] . '' ) . '

'; if ( empty( $data['Template Version'] ) ) { echo '

' . __('Child theme does not have the Template Version tag in style.css.', 'theme-check') . '

'; } else { echo ( $data['Template Version'] < $parent_data['Version'] ) ? '

' . sprintf(__('Child theme is only tested up to version %1$s of %2$s breakage may occur! %3$s installed version is %4$s', 'theme-check'), $data['Template Version'], $parent_data['Title'], $parent_data['Title'], $parent_data['Version'] ) . '

' : ''; } } echo '
'; $plugins = get_plugins( '/theme-check' ); $version = explode( '.', $plugins['theme-check.php']['Version'] ); echo '

' . sprintf( __(' Running %1$s tests against %2$s using Guidelines Version: %3$s Plugin revision: %4$s', 'theme-check'), '' . $checkcount . '', '' . $data[ 'Title' ] . '', '' . $version[0] . '', '' . $version[1] . '' ) . '

'; $results = display_themechecks(); if ( !$success ) { echo '

' . sprintf(__('One or more errors were found for %1$s.', 'theme-check'), $data[ 'Title' ] ) . '

'; } else { echo '

' . sprintf(__('%1$s passed the tests', 'theme-check'), $data[ 'Title' ] ) . '

'; tc_success(); } if ( !defined( 'WP_DEBUG' ) || WP_DEBUG == false ) echo '
' . __('WARNING','theme-check') . ' ' . __( 'WP_DEBUG is not enabled! Please test your theme with debug enabled before you upload!', 'theme-check' ) . '
'; echo '
'; echo '
'; } } // strip comments from a PHP file in a way that will not change the underlying structure of the file function tc_strip_comments( $code ) { $strip = array( T_COMMENT => true, T_DOC_COMMENT => true); $newlines = array( "\n" => true, "\r" => true ); $tokens = token_get_all($code); reset($tokens); $return = ''; $token = current($tokens); while( $token ) { if( !is_array($token) ) { $return.= $token; } elseif( !isset( $strip[ $token[0] ] ) ) { $return.= $token[1]; } else { for( $i = 0, $token_length = strlen($token[1]); $i < $token_length; ++$i ) if( isset($newlines[ $token[1][$i] ]) ) $return.= $token[1][$i]; } $token = next($tokens); } return $return; } function tc_intro() { ?>

Otto42', 'Pross' ); ?>

WordPress forums, or talk about it with the theme review team on Make WordPress Themes site.', 'theme-check' ), 'https://wordpress.org/tags/theme-check?forum_id=10', 'https://make.wordpress.org/themes/') ; ?>

GitHub.', 'theme-check' ), 'https://github.com/Otto42/theme-check'); ?>

Theme Review before uploading a Theme.', 'theme-check' ); ?>

'; echo ''; echo ''; if ( defined( 'TC_PRE' ) || defined( 'TC_POST' ) ) echo ' ' . __( 'Output in Trac format.', 'theme-check' ); echo ' ' . __( 'Suppress INFO.', 'theme-check' ); echo ''; }