how to make stylesheet appear in theme editor?

I’d say it’s impossible…

For one, there’s no hook inside the file /wp-admin/theme-editor.php.

And last but not least, if you try one of this, it dumps an error:

  • /wp-admin/theme-editor.php?file=css%2Fstyle.css&theme=twentyeleven
  • /wp-admin/theme-editor.php?file=css/style.css&theme=twentyeleven

Case you find a workaround, this code injects a link to the desired file:

/**
 * Adjust the if('Twenty Eleven' == sel) to your theme name
 */
add_action('admin_head-theme-editor.php', 'wpse_55949_script_enqueuer');

function wpse_55949_script_enqueuer(){
    echo <<<HTML
    <script type="text/javascript">
    jQuery(document).ready( function($) {
        var sel = $("#theme option:selected").text();
        if('Twenty Eleven' == sel) 
        {
            $('<li><a href="https://wordpress.stackexchange.com/questions/55949/theme-editor.php?file=css/style.css&amp;theme=twentyeleven">Subfolder Stylesheet<br><span class="nonessential">(css/style.css)</span></a></li>').appendTo('#templateside ul:last');
        }
    });     
    </script>
HTML;
}

[update]

An alternate approach would be to create an options page where the client can write/manipulate the CSS.

Leave a Comment