Ticket #23570: 23570.diff

File 23570.diff, 4.4 KB (added by wonderboymusic, 3 months ago)
  • wp-includes/formatting.php

    diff --git wp-includes/formatting.php wp-includes/formatting.php
    index c162a35..acb2144 100644
    function convert_smilies($text) { 
    17991799} 
    18001800 
    18011801/** 
     1802 * Extract a URL from passed content, if possible 
     1803 * Checks for a URL on the first line of the content or the first encountered href attribute. 
     1804 * 
     1805 * @since 3.6.0 
     1806 * 
     1807 * @param string $content A string which might contain a URL. 
     1808 * @param boolean $remove Whether the remove the found URL from the passed content. 
     1809 * @return string The found URL. 
     1810 */ 
     1811function get_content_link( &$content, $remove = false ) { 
     1812        if ( empty( $content ) ) 
     1813                return; 
     1814 
     1815        // the content is a URL 
     1816        $trimmed = trim( $content ); 
     1817        if ( 0 === stripos( $trimmed, 'http' ) && ! preg_match( '#\s#', $trimmed ) ) { 
     1818                if ( $remove ) 
     1819                        $content = ''; 
     1820 
     1821                return $trimmed; 
     1822        // the content is HTML so we grab the first href 
     1823        } elseif ( preg_match( '/<a\s[^>]*?href=[\'"](.+?)[\'"]/is', $content, $matches ) ) { 
     1824                return esc_url_raw( $matches[1] ); 
     1825        } 
     1826 
     1827        $lines = explode( "\n", $trimmed ); 
     1828        $line = trim( array_shift( $lines ) ); 
     1829 
     1830        // the content is a URL followed by content 
     1831        if ( 0 === stripos( $line, 'http' ) ) { 
     1832                if ( $remove ) 
     1833                        $content = trim( join( "\n", $lines ) ); 
     1834 
     1835                return esc_url_raw( $line ); 
     1836        } 
     1837} 
     1838 
     1839/** 
     1840 * Attempt to retrieve a URL from a post's content 
     1841 * 
     1842 * @since 3.6.0 
     1843 * 
     1844 * @param int $id Optional. Post ID. 
     1845 * @return string A URL, if found. 
     1846 */ 
     1847function get_the_link( $id = 0 ) { 
     1848        $post = empty( $id ) ? get_post() : get_post( $id ); 
     1849 
     1850        if ( empty( $post ) ) 
     1851                return; 
     1852 
     1853        if ( has_post_format( 'link', $post ) ) { 
     1854                $meta = get_post_format_meta( $post->ID ); 
     1855                if ( ! empty( $meta['url'] ) ) 
     1856                        return esc_url_raw( $meta['url'] ); 
     1857        } 
     1858 
     1859        if ( ! empty( $post->post_content ) ) 
     1860                return get_content_link( $post->post_content ); 
     1861} 
     1862 
     1863/** 
     1864 * Attempt to output a URL from a post's content 
     1865 * 
     1866 * @since 3.6.0 
     1867 *. 
     1868 */ 
     1869function the_link() { 
     1870        echo get_the_link( 0 ); 
     1871} 
     1872 
     1873/** 
    18021874 * Return the class for a post format content wrapper 
    18031875 * 
    18041876 * @since 3.6.0 
    function post_formats_compat( $content, $id = 0 ) { 
    18641936                        if ( ! empty( $meta['url'] ) ) { 
    18651937                                $esc_url = preg_quote( $meta['url'], '#' ); 
    18661938                                // Make sure the same URL isn't in the post (modified/extended versions allowed) 
    1867                                 if ( ! preg_match( '#' . $esc_url . '[^/&\?]#', $content ) ) { 
    1868                                         $format_output .= sprintf( 
    1869                                                 '<a %shref="%s">%s</a>', 
    1870                                                 empty( $compat['link_class'] ) ? '' : sprintf( 'class="%s" ', esc_attr( $compat['link_class'] ) ), 
    1871                                                 esc_url( $meta['url'] ), 
    1872                                                 empty( $post->post_title ) ? esc_url( $meta['url'] ) : apply_filters( 'the_title', $post->post_title ) 
    1873                                         ); 
    1874                                 } 
     1939                                if ( ! preg_match( '#' . $esc_url . '[^/&\?]#', $content ) ) 
     1940                                        $url = $meta['url']; 
     1941                        } else { 
     1942                                $compat['position'] = 'before'; 
     1943                                $content_before = $content; 
     1944                                $url = get_content_link( $content, true ); 
     1945                                if ( $content_before == $content ) 
     1946                                        $url = ''; 
     1947                        } 
     1948 
     1949                        if ( ! empty( $url ) ) { 
     1950                                $format_output .= sprintf( 
     1951                                        '<a %shref="%s">%s</a>', 
     1952                                        empty( $compat['link_class'] ) ? '' : sprintf( 'class="%s" ', esc_attr( $compat['link_class'] ) ), 
     1953                                        esc_url( $url ), 
     1954                                        empty( $post->post_title ) ? esc_url( $meta['url'] ) : apply_filters( 'the_title', $post->post_title ) 
     1955                                ); 
    18751956                        } 
    18761957                        break; 
    18771958 
    function sanitize_trackback_urls( $to_ping ) { 
    35313612 * @return string|array Slashed $value 
    35323613 */ 
    35333614function wp_slash( $value ) { 
    3534         if ( is_array( $value ) ) {  
     3615        if ( is_array( $value ) ) { 
    35353616                foreach ( $value as $k => $v ) { 
    35363617                        if ( is_array( $v ) ) { 
    35373618                                $value[$k] = wp_slash( $v ); 
    function wp_slash( $value ) { 
    35403621                        } 
    35413622                } 
    35423623        } else { 
    3543                 $value = addslashes( $value );  
    3544         }  
     3624                $value = addslashes( $value ); 
     3625        } 
    35453626 
    3546         return $value;  
     3627        return $value; 
    35473628} 
    35483629 
    35493630/** 
    function wp_slash( $value ) { 
    35623643 * @return string|array Unslashed $value 
    35633644 */ 
    35643645function wp_unslash( $value ) { 
    3565         return stripslashes_deep( $value );  
     3646        return stripslashes_deep( $value ); 
    35663647} 
  • wp-includes/post.php

    diff --git wp-includes/post.php wp-includes/post.php
    index 14fbe75..1dd65ae 100644
    function get_post_format_meta( $post_id = 0 ) { 
    19681968                'media'        => '', 
    19691969        ); 
    19701970 
    1971         foreach ( $values as $key => $value ) 
     1971        foreach ( array_keys( $values ) as $key ) 
    19721972                $values[$key] = get_post_meta( $post_id, '_wp_format_' . $key, true ); 
    19731973 
    19741974        return $values;