Plugin Directory

Changeset 854464


Ignore:
Timestamp:
02/09/2014 11:54:08 PM (12 years ago)
Author:
rydurham
Message:

Updated for laravel.io/bin

Location:
laravel-paste-embed/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • laravel-paste-embed/trunk/laravel-paste-embed.php

    r825729 r854464  
    22/**
    33 * @package LaravePasteEmbed
    4  * @version 1.2.1
     4 * @version 1.4
    55 */
    66/*
    77Plugin Name: Laravel Paste Embed
    8 Plugin URI: http://www.ryandurham.com/2013/04/06/laravel-paste-embed/
    9 Description: A plugin to embed pages & snippets from paste.laravel.com into a wordpress site.
     8Plugin URI: http://www.ryandurham.com/projects/laravel-paste-embed/
     9Description: A plugin to embed pages & snippets from laravel.io/bin into a wordpress site.
    1010Author: Ryan Durham
    11 Version: 1.3
    12 Author URI: http://rydurham.com
     11Version: 1.4
     12Author URI: http://www.ryandurham.com/projects
    1313License: GPL2
    1414
    15 Thanks to Dayle Rees & co. for the styles: http://paste.laravel.com/css/style.css
     15Thanks to Dayle Rees & co. for the styles: http://paste.laravel.com/css/style.css  (link no longer works)
    1616
    1717Thanks to Taylor Dewey (@tddewey) for the advice!
     
    5050   
    5151    //Pull data from paste.laravel.com
    52     $url = esc_url("http://paste.laravel.com/$paste");
    53     $response = wp_remote_get($url);
     52    $url = esc_url("http://laravel.io/bin/$paste");
     53    $response = wp_remote_get($url, array('timeout' => 30));
    5454    $response_code = wp_remote_retrieve_response_code( $response );
    5555
    5656    if ( $response_code != '200' ) {
    57         $error_message = "Paste Error: " .  $response['response']['message'];
    58         return $error_message;
     57        $error = $response->get_error_code();
     58        $message = "<b>Paste Bin Error:</b> " . $response->get_error_message($error);
     59
     60        return $message;
    5961    } else {
    6062        //Parse the body of the response to pull out the relevant content.
    6163        $dom = new DOMDocument();
    62         $html = $dom->loadHTML( wp_remote_retrieve_body( $response ) );
    63         $code = $dom->getElementsByTagName( 'code' )->item( 0 )->nodeValue;
     64        libxml_use_internal_errors(true);
     65        $html = @$dom->loadHTML( wp_remote_retrieve_body( $response ) );
     66       
     67        $code = $dom->getElementsByTagName( 'pre' )->item( 0 )->nodeValue;
    6468       
    6569        //Capture the paste output in an object buffer.
     
    6973                echo "<div class=\"lpe_title\">$caption</div>";
    7074            }
    71             echo "<div class=\"lpe_link\"><a href=\"$url\" target=\"_blank\">link</a> </div>";
     75            echo "<div class=\"lpe_link\"><a href=\"$url\" target=\"_blank\">bin/$paste</a> </div>";
    7276            echo "<pre class=\"prettyprint linenums \" style=\"height: $height;\">";
    7377            echo htmlentities($code);
  • laravel-paste-embed/trunk/readme.txt

    r825729 r854464  
    11=== Laravel-Paste-Embed ===
    22Contributors: rydurham
    3 Donate link: http://www.ryandurham.com/category/code/
    4 Tags: Laravel Paste
     3Donate link: http://www.ryandurham.com/projects
     4Tags: Laravel, Laravel.io, Paste, Bin
    55Requires at least: 3.3
    6 Tested up to: 3.6
    7 Stable tag: 1.3
     6Tested up to: 3.8.1
     7Stable tag: 1.4
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 A WordPress plugin for embedding text from paste.laravel.com.
     11A WordPress plugin for embedding text from laravel.io/bin.
    1212
    1313== Description ==
    1414
    15 A Wordpress plugin to embed code from paste.laravel.com. 
     15A Wordpress plugin to embed code from laravel.io/bin 
    1616
    1717== Installation ==
     
    19191. Upload the `laravel-paste-embed` folder to the `/wp-content/plugins/` directory
    20202. Activate the plugin through the 'Plugins' menu in WordPress
    21 3. Go to paste.laravel.com and create the paste you are going to embed in your page or post.
    22 4. Grab the identifying bit from the end of the URL. 'cJ9' in this case: http://paste.laravel.com/cJ9
    23 5. In your page or post add this shortcode, with the relevant part of the URL in question: [lpe paste='cJ9']
     213. Go to laravel.io/bin and create the paste you are going to embed in your page or post.
     224. Grab the identifying bit from the end of the URL. 'Q6a' in this case: http://laravel.io/bin/Q6a
     235. In your page or post add this shortcode, with the relevant part of the URL in question: [lpe paste='Q6a']
    2424
    2525
Note: See TracChangeset for help on using the changeset viewer.