Make WordPress Core

Ticket #24712: ticket-24712.php

File ticket-24712.php, 859 bytes (added by GunGeekATX, 10 years ago)

Sample plugin showing functionality of patch

Line 
1<?php
2/*
3Plugin Name: Ticket 24712 Test
4Description: https://core.trac.wordpress.org/ticket/24712
5Author: Pete Nelson
6Version: 1.0
7*/
8
9if (!defined( 'ABSPATH' )) exit('restricted access');
10
11add_shortcode( 'ticket-24712-test', 'ticket_24712_shortcode' );
12
13function ticket_24712_shortcode( $args ) {
14
15        $args = wp_parse_args( $args, array( 'url' => '' ) );
16
17        $results = wp_oembed_get( $args['url'] );
18        $oembed = _wp_oembed_get_object();
19
20        if ( empty ( $oembed->errors ) ) {
21                echo $results;
22        }
23        else {
24                ?>
25                        <p>
26                                <?php
27                                        if ( in_array('parse-json-failed', $oembed->errors ) ) echo 'Unable to parse JSON response';
28                                        if ( in_array('parse-xml-failed', $oembed->errors ) ) echo 'Unable to parse XML response';
29                                ?>
30                                <br/>
31                                Response Body: <?php echo esc_attr( $oembed->response_body ); ?>
32                        </p>
33                <?php
34        }
35
36}