WordPress.org

Ready to get started?Download WordPress

Plugin Directory

Pastacode

Use Pastacode to add code into your posts with the awesome PrismJs coloration library. So, past'a code!

How to setup a custom cache expiration ?

Paste these lines into your functions.php theme file :

add_filter( 'option_pastacode_cache_duration', 'my_pastacode_cache_duration' );
function my_pastacode_cache_duration( $duration ) {
    $duration = DAY_IN_SECOND*3; // 3 days
    return $duration;
}

How define a custom color scheme ?

Paste these lines into your functions.php theme file :

add_filter( 'option_pastacode_style', 'my_pastacode_style' );
function my_pastacode_style( $scheme ) {
    $scheme = 'my_awesome_style'; //CSS filename into the plugin css directory
    return $scheme;
}

Get inspired of the default scheme to build your schemes

How to filter supported languages ?

Paste these lines into your functions.php theme file :

//If you just want php, html, css and javascript support
add_filter( 'pastacode_langs', '_pastacode_langs' );
function _pastacode_langs( $langs ) {
    $langs  = array(
        'php'          => 'PHP',
        'markup'       => 'HTML',
        'css'          => 'CSS',
        'javascript'   => 'JavaScript', );
    return $langs;
}

How to add a new provider ?

Paste these lines into your functions.php theme file :

//Take WordPress SVN, for example
//register a provider
add_filter( 'pastacode_services', '_pastacode_services' );
function _pastacode_services( $services ) {
    $services['wordpress'] = 'core.svn.wordpress.org';
    return $services;
}

//Define pastabox lightbox inputs
add_action( 'pastacode_fields', '_pastacode_fields' );
function _pastacode_fields( $fields ) { 
    $fields['wordpress'] = array(  // 'wordpress' or 'whatever'
        'classes'     => array( 'wordpress' ), // same value as the key
        'label'       => sprintf( __('File path relative to %s', 'pastacode'), 'http://core.svn.wordpress.org/' ), 
        'placeholder' =>'trunk/wp-config-sample.php', //if placeholder isn't defined, it will be a textarea
        'name'        => 'path_id' //these value return shortcode attribute (path_id, repos, name, user, version)
        );
    return $fields;
}

//Build the function to retrieve the code
// "pastacode_wordpress" hook name (1st param) = "pastacode_" + "wordpress" or "whatever"
add_action( 'pastacode_wordpress', '_pastacode_wordpress', 10, 2 );
function _pastacode_wordpress( $source, $atts ) {
    extract( $atts );
    if( $path_id ) {
        $req  = wp_sprintf( 'http://core.svn.wordpress.org/%s', str_replace( 'http://core.svn.wordpress.org/', '', $path_id ) );
        $code = wp_remote_get( $req );
        if( ! is_wp_error( $code ) && 200 == wp_remote_retrieve_response_code( $code ) ) {
            $data = wp_remote_retrieve_body( $code );
            $source[ 'url' ]  = $req; //url to view source
            $source[ 'name' ] = basename( $req ); //filename
            $source[ 'code' ] = esc_html( $data ); //the code !!   
            //$source[ 'raw' ] contain raw source code. But there are no raw source code delivered by WordPress SVN             
        }
    }
    return $source;
}

Do not add you root website!! A contributor can add the shortcode to point your "wp-config.php" to read it!!

Requires: 3.1 or higher
Compatible up to: 3.9.1
Last Updated: 2014-5-5
Downloads: 1,734

Ratings

5 stars
5 out of 5 stars

Support

0 of 2 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1 100,1,1 100,3,3
100,1,1