1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Ticket 24712 Test |
---|
4 | Description: https://core.trac.wordpress.org/ticket/24712 |
---|
5 | Author: Pete Nelson |
---|
6 | Version: 1.0 |
---|
7 | */ |
---|
8 | |
---|
9 | if (!defined( 'ABSPATH' )) exit('restricted access'); |
---|
10 | |
---|
11 | add_shortcode( 'ticket-24712-test', 'ticket_24712_shortcode' ); |
---|
12 | |
---|
13 | function 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 | } |
---|