function wp_css_files($id, $meta = TRUE)
{
    if ($meta == TRUE) {
        $meta = get_post_meta($id, 'wp_css_file');
        if (!empty($meta) && count($meta) > 0) {
            echo '<div id="wp_css_course_dates_list"><ul>';
            foreach ($meta as $value) {
                $remove_string = 'delete=true&amp;' . 'id=' . $id . '&amp;string=' . $value;
                echo '<li><a href="' . WP_CSS_URL . '/wp-css-ajax.php?' . $remove_string . '" class="remove-file" onclick="wp_css.remove(this);return false;">' . $value . '</a></li>';
            }
            echo '</ul></div>';
        } else {
            echo '<div id="wp_css_files_list">No CSS files.</div>';
        }
    } else {
        $files = wp_css_directory_map(TEMPLATEPATH . '/', '.css$', FALSE);
        ?>
		<?php 
        if (count($files) > 0) {
            ?>
			<div id="wp_css_files_list">
				<?php 
            wp_css_list($id, $files);
            ?>
			</div>
		<?php 
        }
        ?>
	
	<?php 
    }
}
Beispiel #2
0
function wp_css_cached_file_structure()
{
    $css_files = wp_css_directory_map(WP_CSS_CACHE_PATH);
    if (count($css_files) > 0) {
        ?>
<p>CSS files cached (/wp-content/themes/<?php 
        echo get_stylesheet();
        ?>
):</p>
<ul>
		<?php 
        foreach ($css_files as $file) {
            ?>
		<?php 
            $file = urldecode($file);
            $array = unserialize(file_get_contents(WP_CSS_CACHE_PATH . $file));
            ?>
			<li>
				<strong><?php 
            echo $array['file'];
            ?>
</strong>
				<?php 
            if (count($array['imports']) > 0) {
                ?>
					<ul>
						<?php 
                foreach ($array['imports'] as $file_within) {
                    ?>
							<li>(@import) <?php 
                    echo $file_within[1];
                    ?>
</li>
						<?php 
                }
                ?>
					</ul>
				<?php 
            }
            ?>
			</li>
		<?php 
        }
        ?>
</ul>
<?php 
    } else {
        echo "<p><strong>No CSS files are cached.</strong></p>";
    }
}
function wp_css_directory_map($source, $needle = '.txt$', $top_level_only = TRUE)
{
    $file_array = array();
    if ($fp = @opendir($source)) {
        while (FALSE !== ($file = readdir($fp))) {
            if (is_dir($source . $file) && substr($file, 0, 1) != '.' && $top_level_only == FALSE) {
                $temp_array = array();
                $temp_array = wp_css_directory_map($source . $file . "/", $needle);
                $file_array[$file] = $temp_array;
            } else {
                if (substr($file, 0, 1) != "." && eregi($needle, $file) && !eregi('wp-css-settings.txt', $file)) {
                    $file_array[] = $file;
                }
            }
        }
        return $file_array;
    }
}