Make WordPress Core


Ignore:
Timestamp:
03/19/2015 12:51:43 AM (11 years ago)
Author:
azaozz
Message:

Press This: check if the URL is to embeddable content on a site that supports oEmbed. Then insert only the URL in the editor. It will trigger a wpView with the embedded content.
Fixes #31637.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-press-this.php

    r31818 r31827  
    779779                                <button type="button" class="add-cat-submit"><?php _e( 'Add' ); ?></button>
    780780                        </div>
    781                 <?php } ?>
     781                        <?php
     782
     783                }
     784                ?>
    782785                <div class="categories-search-wrapper">
    783786                        <input id="categories-search" type="search" class="categories-search" placeholder="<?php esc_attr_e( 'Search categories by name' ) ?>">
     
    810813                        $esc_tags = '';
    811814                }
     815
    812816                ?>
    813817                <div class="tagsdiv" id="post_tag">
    814818                        <div class="jaxtag">
    815819                        <input type="hidden" name="tax_input[post_tag]" class="the-tags" value="<?php echo $esc_tags; // escaped in get_terms_to_edit() ?>">
    816 
    817820                        <?php
     821
    818822                        if ( $user_can_assign_terms ) {
    819823                                ?>
     
    828832                                        <?php echo $taxonomy->labels->separate_items_with_commas; ?>
    829833                                </p>
    830                         <?php } ?>
     834                                <?php
     835                        }
     836
     837                        ?>
    831838                        </div>
    832839                        <div class="tagchecklist"></div>
    833840                </div>
    834841                <?php
     842
    835843                if ( $user_can_assign_terms ) {
    836844                        ?>
     
    9951003                }
    9961004
    997                 $default_html = array(
    998                         'quote' => '<blockquote>%1$s</blockquote>',
    999                         'link' => '<p>' . _x( 'Source:', 'Used in Press This to indicate where the content comes from.' ) .
    1000                                 ' <em><a href="%1$s">%2$s</a></em></p>',
    1001                 );
     1005                require_once( ABSPATH . WPINC . '/class-oembed.php' );
     1006                $oembed = _wp_oembed_get_object();
     1007
     1008                if ( ! empty( $data['u'] ) && $oembed->get_provider( $data['u'], array( 'discover' => false ) ) ) {
     1009                        $default_html = array(
     1010                                'quote' => '',
     1011                                'link' => '',
     1012                                'embed' => '<p>[embed]' . $data['u'] . '[/embed]</p>',
     1013                        );
     1014                } else {
     1015                        $default_html = array(
     1016                                'quote' => '<blockquote>%1$s</blockquote>',
     1017                                'link' => '<p>' . _x( 'Source:', 'Used in Press This to indicate where the content comes from.' ) .
     1018                                        ' <em><a href="%1$s">%2$s</a></em></p>',
     1019                        );
     1020                }
    10021021
    10031022                /**
     
    10111030                $default_html = apply_filters( 'press_this_suggested_html', $default_html, $data );
    10121031
     1032                if ( ! empty( $default_html['embed'] ) ) {
     1033                        $content .= $default_html['embed'];
     1034                }
     1035
    10131036                // Wrap suggested content in the specified HTML.
    10141037                if ( ! empty( $default_html['quote'] ) ) {
    1015                         $content = sprintf( $default_html['quote'], $text );
     1038                        $content .= sprintf( $default_html['quote'], $text );
    10161039                }
    10171040
Note: See TracChangeset for help on using the changeset viewer.