and like us on FB

While the term ‘pastebin’ has found its place in everyday geek vernacular, it was Pastebin.com that effectively pioneered the service. Created it 2002, Pastebin took nearly 8 years to reach the first million pastes, however, the service now boasts nearly 70 million pastes with over 75 percent marked as private or unlisted. Because Pastebin allows anonymous text (and code) to be posted online it has become a defacto destination for those pasting anonymous news, text, and hacks (for example, during the 2014 Venezuelan protests, Pastebin was blocked by the government as one of the sites where activists were sharing information). The hacker group Anonymous are also known to use the service to paste hacked usernames and passwords. That dark usage aside, the site is an excellent means of quickly sharing information.

Services such as Github (and in particular Gists) have become more popular because of the versioning control and other advanced features that other earlier services often lack. Github is almost certainly a more reliable, feature-rich, and cosmetically appealing location to store more permanent code.

The shortcode on this page will permit you to embed Pastebin snippets to your WordPress website with their JavaScript or iframe embed code. There’s also a PHP function for use outside of WordPress.

The Result

Using the shortcode of [pastebin id="http://pastebin.com/vQrmq3HV"] the following paste will be posted into your WordPress post or page.

By default we’ll use the JavaScript embed option. You can, however, if the code is extremely long or you don’t want it to occupy screen real-estate, use an iframe where you may specify the height. For example, if we were to link to the controversial and long text showcasing YouP*rn’s password statistics , we could use [pastebin id="prUbcTmh" js="0" height="300"]. The result:

You should set a default height in the shortcode function to negate the need to define it every time you use the iframe feature.

Shortcode Parameters

id

The id is either the pastebin ID or the full paste URL.

js

The JavaScript embed code is used by default. For longer code you may want to use an iframe to preserve space on your page. Use js="0".

height

If the iframe embed code is used (js="0") you should specify the iframe height as height="400". You can set the default height in the shortcode function.

The Shortcode Function

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin. You may optionally download and install our plugin from the bottom of of the page.

If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.

Function to be used outside WordPress

Used outside WordPress, the following PHP function should be used:

Download

Title: Embed Pastebin Pastes
Description: Embed Pastebin Pastes in WordPress with Shortcode (or With a PHP Function).
Download: Shortcode (V0.2) | WP Plugin (V0.2) | PHP Code (V0.2)

Shortt URL for this post: http://shor.tt/35JB