Title: Pastacode
Author: Willy Bahuaud
Published: <strong>Ọ̀wàrà 10, 2013</strong>
Last modified: Ẹrẹ́nà 12, 2026

---

Ṣàwárí àwọn plugin

![](https://ps.w.org/pastacode/assets/banner-772x250.png?rev=2819165)

![](https://ps.w.org/pastacode/assets/icon-256x256.png?rev=2819151)

# Pastacode

 Láti ọwọ́ [Willy Bahuaud](https://profiles.wordpress.org/willybahuaud/)

[Ṣe ìgbàsílẹ̀](https://downloads.wordpress.org/plugin/pastacode.3.0.1.zip)

 * [Àwọn àlàyé](https://yor.wordpress.org/plugins/pastacode/#description)
 * [Àwọn àgbéyẹ̀wò](https://yor.wordpress.org/plugins/pastacode/#reviews)
 *  [Ìgbéwọlẹ̀](https://yor.wordpress.org/plugins/pastacode/#installation)
 * [Ìdàgbàsókè](https://yor.wordpress.org/plugins/pastacode/#developers)

 [Ìrànlọ́wọ́](https://wordpress.org/support/plugin/pastacode/)

## Àpèjúwe

With Pastacode, you can easily add code into your posts with the awesome PrismJs
coloration library.
 You can insert source code into the post editor, wrinting it
directly in the editor (using a gutenberg bloc or classic editor), from a file, 
or from webservices like GitHub, Gitlab, Gist, Pastebin, BitBucket or BitBucket 
snippets. Webservices responses are cached in order to avoid too many HTTP requests.
It also work in comments and bbPress topics and replies.

DonÌtumọ̀ Yorùbá: ’t worry about posts updates while upgrading codes!

Pastacode allows to enhance your snippets using PrismJs plugins (highlightning lines,
link functions…).

### Third Party

Pastacode use some third party components

 * [PrismJS Ìtumọ̀ Yorùbá: – by Lea Verou, Golmote, James DiGioia, Michael Schmidt & other contributors](https://github.com/PrismJS/prism/graphs/contributors)
 * [WordPress create-block](https://www.npmjs.com/package/@wordpress/create-block)
 * [CodeMirror 6](https://github.com/codemirror/CodeMirror)
 * [CodeMirror6 Component for React](https://uiwjs.github.io/react-codemirror/)
 * [He.js Ìtumọ̀ Yorùbá: – by Mathias Bynens](https://github.com/mathiasbynens/he)

## Àwọn àwòrán ìbòjú

[⌊Edit your code with the Pastacode block⌉⌊Edit your code with the Pastacode block⌉[

Edit your code with the Pastacode block

[⌊How it's renderer in editor (highlighted by Prism)⌉⌊How it's renderer in editor(
highlighted by Prism)⌉[

How itÌtumọ̀ Yorùbá: ’s renderer in editor (highlighted by Prism)

[⌊You can import a snippets hosted on many providers (gitlab, github…)⌉⌊You can 
import a snippets hosted on many providers (gitlab, github…)⌉[

You can import a snippets hosted on many providers (gitlab, github…)

[⌊If you don't use block editor, you can use another UI, base on a tinyMCE plugin(
work in the classic block, or with classic editor)⌉⌊If you don't use block editor,
you can use another UI, base on a tinyMCE plugin (work in the classic block, or 
with classic editor)⌉[

If you donÌtumọ̀ Yorùbá: ’t use block editor, you can use another UI, base on a 
tinyMCE plugin (work in the classic block, or with classic editor)

[⌊Here the Treeview lang, to share directory structure⌉⌊Here the Treeview lang, 
to share directory structure⌉[

Here the Treeview lang, to share directory structure

## Àwọn ìdí

Plugin yìí pèsè 1 ìdí.

 *   Pastacode Paste a code from github, bitbucket, gitlab, or write it here!

## Ìgbéwọlẹ̀

 1. Unzip Pastacode into your plugin folder
 2. Go to Pastacode settings, and configure your color scheme and cache expiration
 3. Host your snippets on repositories (or localy)
 4. To use:
 5.  * With the block editor, use the Pastacode block
     * With classic-editor, use _PastÌtumọ̀ Yorùbá: ’a code_ button to embed your source
       code into articles

## FAQ

_For more information, please visit [Pastacode Wiki](http://pastacode.wabeo.fr/personnaliser-pastacode/)_

### Which programming languages are available?

 * HTML
 * CSS
 * JavaScript
 * PHP
 * C
 * C#
 * C++
 * Java
 * Sass
 * Python
 * SQL
 * Ruby
 * CoffeeScript
 * Bash
 * Apache
 * Less
 * HAML
 * Git command line
 * Haskell
 * Markdown
 * Typescript
 * Treeview (directory structure)

If you use another syntax highligther plugins, migration scripts are available 🙂

### What is the Treeview language?

You can use it to display a directory structure. Use pipes, backticks and hyphens
like this:

    ```
    root_folder/
    |-- a first folder/ 
    |   |-- holidays.mov
    |   |-- javascript-file.js
    |   &#96;-- some_picture.jpg
    |-- documents/
    |   |-- spreadsheet.xls
    |   |-- manual.pdf
    |   |-- document.docx
    |   &#96;-- presentation.ppt
    |         &#96;-- test
    &#96;-- README.md
    ```

### 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 to change the color scheme ?

7 different color schemes are included, you can switch theme under Settings > Pastacode.

You can also build yours:

Paste these lines into your functions.php theme file:

    ```
    add_action( 'wp_enqueue_scripts', 'custom_enqueue_script', 11 );
    function custom_enqueue_script() {
        $urlofmynewscheme = get_stylesheet_directory_uri() . '/prism-okaida-willy.css'; //this is an example
        wp_deregister_style( 'prismcss' );
        wp_register_style( 'prismcss', $urlofmynewscheme, false, '1', 'all' );
    }
    ```

Get inspired of [the default scheme](https://raw.githubusercontent.com/willybahuaud/pastacode-samples/master/default-style.css)
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;
    }
    ```

### Ajax compatibility

To enable Pastacode on ajax based websites, it need two steps:

 1. Turn on Legacy support in the settings panel
 2. Paste this line into your functions.php theme file: `add_filter( 'pastacode_ajax','
    __return_true' );`
 3. After each change on your DOM, you will have to run this javascript function: `
    Prism.highlightAll();`

### 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'), 'https://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)
            );
        $fields['pastacode-lines']['classes'][] = 'wordpress'; // Add ability to select lines
        $fields['pastacode-highlight']['classes'][] = 'wordpress'; // Add ability to highlight somes

        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( 'https://core.svn.wordpress.org/%s', str_replace( 'https://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!!

## Àwọn àgbéyẹ̀wò

![](https://secure.gravatar.com/avatar/42e644c484cda431a4c9b0f20d86035d8898f9ae63887a411e03becb5e202e68?
s=60&d=retro&r=g)

### 󠀁[Perfect Plugin](https://wordpress.org/support/topic/perfect-plugin-741/)󠁿

 [tech0925](https://profiles.wordpress.org/tech0925/) Ọwẹ́wẹ̀ 13, 2019

This plugin really should have hundreds of 5 star reviews! I have been using it 
a long time and it works and looks great!

![](https://secure.gravatar.com/avatar/18fea1b59bbb685742391938623eda48915f357af77e0f54094ed38831e58145?
s=60&d=retro&r=g)

### 󠀁[best plugin ever](https://wordpress.org/support/topic/best-plugin-ever-237/)󠁿

 [mo7md5aled](https://profiles.wordpress.org/mo7md5aled/) Ògún 16, 2018

nice and easy

![](https://secure.gravatar.com/avatar/bbcfc413b36dfbc96abbfb1b53ad7b8188b8b8b95cbee8634c9bd94b826c1d14?
s=60&d=retro&r=g)

### 󠀁[Great](https://wordpress.org/support/topic/great-7972/)󠁿

 [CodingStuff](https://profiles.wordpress.org/codingstuff/) Ẹrẹ́nà 29, 2018

For creating in page code snippets this is just awesome

![](https://secure.gravatar.com/avatar/40e6e1b4e08e74f3307921a16c95af10efa1b7221e9b9a634b4cbaa0c593938a?
s=60&d=retro&r=g)

### 󠀁[Great code embed & syntax highlighting plugin](https://wordpress.org/support/topic/great-code-embed-syntax-highlighting-plugin/)󠁿

 [Jonathan Daggerhart](https://profiles.wordpress.org/daggerhart/) Ògún 14, 2017

Just started using this plugin, but IÌtumọ̀ Yorùbá: ’m quickly becoming a big fan.
Not only does this allow you to embed & highlight the normal stuff, but it will 
also fetch and embed directly from a github/bitbucket repo. Awesome work!

![](https://secure.gravatar.com/avatar/b7a012092ab8958977998298ca9567475f87efbaf0ad57256943390ca05812c3?
s=60&d=retro&r=g)

### 󠀁[Best plugin to embed code](https://wordpress.org/support/topic/best-plugin-to-embed-code/)󠁿

 [Aurélien Denis](https://profiles.wordpress.org/maigret/) Ọwẹ́wẹ̀ 3, 2016

IÌtumọ̀ Yorùbá: ’ve been waiting for years for such a plugin! Pastacode is easy 
to use, well coded and looks gorgeous with any WordPress theme. Keep going!

![](https://secure.gravatar.com/avatar/238b3edd28c53bd309f67970f9dd010818a7b6fd67603cf66365700d8e8496f1?
s=60&d=retro&r=g)

### 󠀁[Love it but it's missing bitbucket snippets](https://wordpress.org/support/topic/love-it-but-its-missing-bitbucket-snippets/)󠁿

 [Anonymous User](https://profiles.wordpress.org/anonymized-2514315/) Ọwẹ́wẹ̀ 3,
2016 1 ìdáhùn

I love this plugin but it lacks the bitbucket snippets part.

 [ Ka gbogbo àwọn àgbéyẹ̀wò 14 ](https://wordpress.org/support/plugin/pastacode/reviews/)

## Àwọn Olùkópa & Olùgbéejáde

“Pastacode” jẹ́ ètò ìṣàmúlò orísun ṣíṣí sílẹ̀. Àwọn ènìyàn wọ̀nyí ti ṣe ìkópa sí
plugin yìí.

Àwọn Olùkópa

 *   [ Willy Bahuaud ](https://profiles.wordpress.org/willybahuaud/)
 *   [ Julio Potier ](https://profiles.wordpress.org/juliobox/)

A ti túmọ̀ “Pastacode” sí èdè agbègbè 1 kan. Ọpẹ́lọpẹ́ fún [àwọn atúmọ̀ èdè](https://translate.wordpress.org/projects/wp-plugins/pastacode/contributors)
fún àwọn ìkópa wọn.

[Túmọ̀ “Pastacode” sí èdè rẹ.](https://translate.wordpress.org/projects/wp-plugins/pastacode)

### Ṣe o nífẹ̀ẹ́ sí ìdàgbàsókè?

[Ṣàwárí koodu](https://plugins.trac.wordpress.org/browser/pastacode/), ṣàyẹ̀wò [ibi ìpamọ́ SVN](https://plugins.svn.wordpress.org/pastacode/),
tàbí ṣe àgbékalẹ̀ sí [àkọsílẹ̀ ìdàgbàsókè](https://plugins.trac.wordpress.org/log/pastacode/)
nípasẹ̀ [RSS](https://plugins.trac.wordpress.org/log/pastacode/?limit=100&mode=stop_on_copy&format=rss).

## Àkọsílẹ̀ àwọn àyípadà

#### 3.0.1

 * 24 november 2022
 * Fix: improve compatibility with html minifier, where line breaks are stripped
   from codes snippets
 * Fix: bug with apachconf language in legacy mod (shortcode)
 * Thanks to WP marmite for notifying me these bugs

#### 3.0

 * 15 november 2022
 * Gutenberg support! 🎉 Use the new shinny block to write/insert your code snippets
 * Migrate automatically from the old shortcode to Gutenberg
 * Support legacy if you use classic editor or classic block

#### 2.1

 * 9 august 2019
 * fix issue with bitbucket api 1.0 depreciation
 * gutenberg compatibility is coming soon . . .

#### 2.0

 * 15 december 2016
 * compatibility with WordPress comments
 * normalize withespace in PrismJs
 * hide empty titles in manual snippets
 * codemirror editing improvments
 * hdpi icons
 * TinyMCE smartphone compatibility
 * PrismJS stylesheets and TinyMCE improvments
 * new method to retrieve GitHub snippets (without base 64 encryption)
 * fancy new website for demos
 * fix: resolve bug while old shortcode conversion
 * fix: conflict between manual code and `%`

#### 1.8

 * 22 august 2016
 * Pastacode preview mode on tinyMCE views

#### 1.7

 * 19 august 2016
 * Pastacode now compatible with bbPress

#### 1.6

 * 27 may 2016
 * [CodeMirror](http://codemirror.net) is now used for editing manual code on backend
 * manual shortcode improvements (this version will converts old « manual code »
   shortcodes to new ones. You’re invited to save your database before upgrade).
   
   This solves [problem reported by users with new lines feeds](https://wordpress.org/support/topic/pastacode-introducing-extra-line-feeds).
 * support [Bitbucket snippets](https://confluence.atlassian.com/bitbucket/snippets-719095082.html)
   as a provider
 * line-numbers css improvements
 * fix bug with empty lines at the end of a snippet.

#### 1.5.1

 * 24 july 2015
 * fix bug of code wrapper not removed [support](https://wordpress.org/support/topic/not-removed)

#### 1.5

 * 23 july 2015
 * API views implementation.
 * fix bug when creating new shortcodes (persistent values)

#### 1.4.2

 * 21 january 2015
 * can target a specific file inside a gist
 * remove prismJS plugin demo file (index.html, inside the plugin rep)

#### 1.4.1

 * 20 january 2015
 * Color Scheme optimisation (line number compatibility, space above and below…)
 * You can select to [display only 1 line of code](https://wordpress.org/support/topic/unique-line-number?replies=1)
 * New [website for documentation](http://pastacode.wabeo.fr) !

#### 1.4

 * 16 january 2015
 * New feature: you can now edit your manual code into a full screen window
 * update prism.js and prism plugins
 * New option for display code description above or below code

#### 1.3

 * 5 may 2014
 * TinyMCE Editor support improvment (visual placeholder on editor mode, new tinyMCE
   button…)
 * Github API restriction fallback (support now more than 30 requests / hour)
 * New ajax compatibility (using hook pastacode_ajax)
 * Fix bug: No more disgracefull linebreaks on code view.

#### 1.2.1

 * 21 nov 2013
 * Fix bug: when manual provider is selected, no cache.

#### 1.2

 * 15 oct 2013
 * The modification of the cache duration do not purge cache anymore
 * New button “Purge Cache” in option page, use it to delete all transients (they
   contains the responded source codes)
 * Fix bug when updating option

#### 1.1

 * 12 oct 2013
 * Hooks, hooks and hooks.
 * Update shortcode format (“type” became “provider”, and add “/” before the closing
   tag)

#### 1.0

 * 10 oct 2013
 * Initial release
 * Insert codes using a nice lightbox
 * Import codes from file, Github, Gist, Pastebin or BitBucket
 * 13 languages available
 * 6 color schemes
 * Cache support for webservices (default duration: 1 week)

## Àkójọpọ̀ Meta

 *  Ẹ̀yà **3.0.1**
 *  Ìgbàgbọ́hùn tó kẹ́yìn **oṣù 3 sẹ́yìn**
 *  Àwọn ìgbéwọlẹ̀ tó ṣiṣẹ́ **400+**
 *  Ẹ̀yà WordPress ** 4.0 tàbí ju bẹ́ẹ̀ lọ **
 *  Dánwò dé **6.9.4**
 *  Ẹ̀yà PHP ** 7.0 tàbí ju bẹ́ẹ̀ lọ **
 *  Àwọn èdè
 * [English (US)](https://wordpress.org/plugins/pastacode/) àti [French (France)](https://fr.wordpress.org/plugins/pastacode/).
 *  [Túmọ̀ sí èdè rẹ](https://translate.wordpress.org/projects/wp-plugins/pastacode)
 * Àwọn àmì
 * [block](https://yor.wordpress.org/plugins/tags/block/)[code](https://yor.wordpress.org/plugins/tags/code/)
   [Github](https://yor.wordpress.org/plugins/tags/github/)[sourcecode](https://yor.wordpress.org/plugins/tags/sourcecode/)
   [syntax](https://yor.wordpress.org/plugins/tags/syntax/)
 *  [Ìwòye Tó Péye](https://yor.wordpress.org/plugins/pastacode/advanced/)

## Àwọn ìbò

 4.9 lára àwọn ìràwọ̀ 5.

 *  [  13 5-star reviews     ](https://wordpress.org/support/plugin/pastacode/reviews/?filter=5)
 *  [  1 4-star review     ](https://wordpress.org/support/plugin/pastacode/reviews/?filter=4)
 *  [  0 3-star reviews     ](https://wordpress.org/support/plugin/pastacode/reviews/?filter=3)
 *  [  0 2-star reviews     ](https://wordpress.org/support/plugin/pastacode/reviews/?filter=2)
 *  [  0 1-star reviews     ](https://wordpress.org/support/plugin/pastacode/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/pastacode/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/pastacode/reviews/)

## Àwọn Olùkópa

 *   [ Willy Bahuaud ](https://profiles.wordpress.org/willybahuaud/)
 *   [ Julio Potier ](https://profiles.wordpress.org/juliobox/)

## Ìrànlọ́wọ́

Nǹkan wà tí o fẹ́ sọ? Ṣé o nílò ìrànlọ́wọ́?

 [Wo àpéjọ ìrànlọ́wọ́](https://wordpress.org/support/plugin/pastacode/)

## Ṣe ìtọrẹ

Ṣé o fẹ́ ṣe àtìlẹ́yìn fún ìlọsíwájú plugin yìí?

 [ Ṣe ìtọrẹ sí plugin yìí ](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RP2CK8K32JDPE)