Changeset 17460
- Timestamp:
- 02/16/2011 07:24:45 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.1/wp-includes/formatting.php
r17228 r17460 2735 2735 */ 2736 2736 function links_add_base_url( $content, $base, $attrs = array('src', 'href') ) { 2737 global $_links_add_base; 2738 $_links_add_base = $base; 2737 2739 $attrs = implode('|', (array)$attrs); 2738 return preg_replace_callback("!($attrs)=(['\"])(.+?)\\2!i", 2739 create_function('$m', 'return _links_add_base($m, "' . $base . '");'), 2740 $content); 2740 return preg_replace_callback( "!($attrs)=(['\"])(.+?)\\2!i", '_links_add_base', $content ); 2741 2741 } 2742 2742 … … 2748 2748 * 2749 2749 * @param string $m The matched link. 2750 * @param string $base The base URL to prefix to links.2751 2750 * @return string The processed link. 2752 2751 */ 2753 function _links_add_base($m, $base) { 2752 function _links_add_base($m) { 2753 global $_links_add_base; 2754 2754 //1 = attribute name 2 = quotation mark 3 = URL 2755 2755 return $m[1] . '=' . $m[2] . 2756 2756 (strpos($m[3], 'http://') === false ? 2757 path_join($ base, $m[3]) :2757 path_join($_links_add_base, $m[3]) : 2758 2758 $m[3]) 2759 2759 . $m[2]; … … 2776 2776 */ 2777 2777 function links_add_target( $content, $target = '_blank', $tags = array('a') ) { 2778 global $_links_add_target; 2779 $_links_add_target = $target; 2778 2780 $tags = implode('|', (array)$tags); 2779 return preg_replace_callback("!<($tags)(.+?)>!i", 2780 create_function('$m', 'return _links_add_target($m, "' . $target . '");'), 2781 $content); 2781 return preg_replace_callback( "!<($tags)(.+?)>!i", '_links_add_target', $content ); 2782 2782 } 2783 2783 … … 2789 2789 * 2790 2790 * @param string $m The matched link. 2791 * @param string $target The Target to add to the links.2792 2791 * @return string The processed link. 2793 2792 */ 2794 function _links_add_target( $m, $target ) { 2793 function _links_add_target( $m ) { 2794 global $_links_add_target; 2795 2795 $tag = $m[1]; 2796 2796 $link = preg_replace('|(target=[\'"](.*?)[\'"])|i', '', $m[2]); 2797 return '<' . $tag . $link . ' target="' . $target. '">';2797 return '<' . $tag . $link . ' target="' . esc_attr( $_links_add_target ) . '">'; 2798 2798 } 2799 2799
Note: See TracChangeset
for help on using the changeset viewer.