Skip to content

Instantly share code, notes, and snippets.

@borkweb
Last active August 29, 2015 13:57
Show Gist options
  • Save borkweb/9899681 to your computer and use it in GitHub Desktop.
Save borkweb/9899681 to your computer and use it in GitHub Desktop.
<?php
set_time_limit( -1 );
error_reporting( E_ERROR );
if ( function_exists( 'xdebug_disable' ) ) {
xdebug_disable();
}//end if
$dir_child = '/var/www/wp/wp-content/themes/vip/gigaom5';
$plugins = '/var/www/pro/application/content/plugins';
$icon_file = $dir_child . '/sass/_icons.scss';
$rows = file( $icon_file );
$current_icon = FALSE;
$icons = array(
'icon-share' => array( 'class' => '.icon-share', 'contents' => '\e003', 'count' => 0 ),
'icon-info' => array( 'class' => '.icon-info', 'contents' => '\e004', 'count' => 0 ),
'icon-wordpress' => array( 'class' => '.icon-wordpress', 'contents' => '\e009', 'count' => 0 ),
'icon-comment' => array( 'class' => '.icon-comment', 'contents' => '\e016', 'count' => 0 ),
'icon-reply' => array( 'class' => '.icon-reply', 'contents' => '\e017', 'count' => 0 ),
'icon-video' => array( 'class' => '.icon-video', 'contents' => '\e019', 'count' => 0 ),
'icon-circle' => array( 'class' => '.icon-circle', 'contents' => '\e024', 'count' => 0 ),
'icon-cloud' => array( 'class' => '.icon-cloud', 'contents' => '\e026', 'count' => 0 ),
'icon-website' => array( 'class' => '.icon-website', 'contents' => '\e033', 'count' => 0 ),
'icon-comments-off' => array( 'class' => '.icon-comments-off', 'contents' => '\e048', 'count' => 0 ),
'icon-arrow-down' => array( 'class' => '.icon-arrow-down', 'contents' => '\e052', 'count' => 0 ),
'icon-arrow-up' => array( 'class' => '.icon-arrow-up', 'contents' => '\e053', 'count' => 0 ),
'icon-arrow-left' => array( 'class' => '.icon-arrow-left', 'contents' => '\e054', 'count' => 0 ),
'icon-arrow-right' => array( 'class' => '.icon-arrow-right', 'contents' => '\e055', 'count' => 0 ),
'icon-external-link-after' => array( 'class' => '.icon-external-link-after', 'contents' => '\e058', 'count' => 0 ),
);
/*
foreach ( $rows as $row ) {
if ( preg_match( '#\.(((icon)|(logo))-[^:]+)#', $row, $matches ) ) {
$current_icon = $matches[1];
$icons[ $current_icon ] = array();
} elseif ( $current_icon && preg_match( '#content: "([^"]+)#', $row, $matches ) ) {
$icons[ $current_icon ] = array(
'class' => $current_icon,
'contents' => $matches[1],
'count' => 0,
);
$current_icon = FALSE;
}//end elseif
}//end foreach
$pieces = array(
'-circled',
'-left',
'-right',
'-up',
'-down',
'-checked',
'-unchecked',
);
*/
function find_icons( $dir, $icons, $pieces ) {
$rit = new RecursiveDirectoryIterator( $dir, FilesystemIterator::SKIP_DOTS );
$it = new RecursiveIteratorIterator( $rit );
$reg = new RegexIterator( $it, '/^.+\.((html)|(php)|(js)|(scss))$/i', RecursiveRegexIterator::GET_MATCH );
foreach ( $reg as $file ) {
if ( preg_match( '#((no-font-face)|(_icons))\.scss$#', $file[0] ) ) {
continue;
}//end if
$contents = file_get_contents( $file[0] );
foreach ( $icons as $icon => $data ) {
$match = "/" . str_replace( '-', '\-', $data['class'] ) ."/i";
$found = preg_match_all( $match, $contents, $m );
$icons[ $icon ]['count'] += $found;
$match = "/\\" . $data['contents'] ."/i";
$found = preg_match_all( $match, $contents, $m );
$icons[ $icon ]['count'] += $found;
}//end foreach
}//end foreach
return $icons;
}//end find_icons
$icons = find_icons( $dir_child, $icons );
$icons = find_icons( $plugins, $icons );
?>
<table>
<thead>
<tr>
<th>Class</th>
<th>Code</th>
<th>Count</th>
</tr>
</thead>
<tbody>
<?php
foreach ( $icons as $icon) {
if ( $icon['count'] ) {
continue;
}//end if
?>
<tr>
<td><code><?php echo $icon['class']; ?></code></td>
<td><code><?php echo $icon['contents']; ?></code></td>
<td><code><?php echo $icon['count']; ?></code></td>
</tr>
<?php
}//end foreach
?>
</tbody>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment