WordPress.org

Ready to get started?Download WordPress

Forums

Code Snippet Library
Auto Resize Snippet Height + Shortcode Title Attribute (1 post)

  1. Amber
    Member
    Posted 1 year ago #

    Hi Hugh,

    Thanks so much for releasing this plugin. :)

    I was wondering if you knew how to get the snippet box to auto resize it's height to fit the content and get rid of the vertical scroll bar. I tried via CSS but it didn't appear to have any effect.

    I also modified the plugin code for class-code-snippet-library (shame on me since it will break when you update) to allow a title attribute to be used in the shortcode. If anyone else wants to do the same below are the changes I made.

    On line 261 I added:
    'title' => ''

    On line 270 I modified:
    $html = $this->display_snippet( $id , $execute );

    to be

    $html = $this->display_snippet( $id , $execute, $title );

    On line 276 I modified:
    private function display_snippet( $id = 0 , $execute = false ) {

    to be

    private function display_snippet( $id = 0 , $execute = false, $title ) {

    On Line 299 I added (before <pre id="code_snippet_'):

    <div class="csl-tw"><span class="csl-dt">snippet : </span><span class="csl-ct">'.$title.'</span></div>

    I then styled my "csl-tw" and 'csl-title' in my stylesheet. The styles I chose look like this (modify as needed):

    .csl-tw {
    	background:#CCCCCC;
    	border-bottom:1px solid #B3B3B3;
    	padding:7px 12px 4px;
    }
    .csl-dt {
    	color:#9c9c9c;
    }

    Additionally, to remove the top margin (white gap) so my title box and snippet box touch, in my CSS I added:

    .entry-content pre.ace_editor{
    	margin-top:0;
    }

    Then end result looks something like this:
    CSL - With Title Img

    Future Feature Suggestions

    - Add title attribute to snippet shortcode.
    - It would be really neat when we create the snippet if we could have a "description field" which could be used as the shortcode title
    - Some kind of snippet categories (for organization); if this is possible maybe use the category instead of a description for the title

    http://wordpress.org/extend/plugins/code-snippet-library/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.