diff --git wp-admin/js/post-formats.js wp-admin/js/post-formats.js
index 063af49..912f6e9 100644
|
|
window.wp = window.wp || {}; |
92 | 92 | |
93 | 93 | lastMimeType = mime; |
94 | 94 | |
95 | | // Create the media frame. |
96 | | mediaFrame = wp.media.frames.formatMedia = wp.media({ |
97 | | // Set the title of the modal. |
98 | | title: $el.data('choose'), |
99 | | |
100 | | // Tell the modal to show only items matching the current mime type. |
101 | | library: { |
102 | | type: mime |
103 | | }, |
104 | | |
105 | | // Customize the submit button. |
| 95 | mediaFrame = wp.media.frames.formatMedia = wp.media( { |
106 | 96 | button: { |
107 | | // Set the text of the button. |
108 | 97 | text: $el.data('update') |
109 | | } |
110 | | }); |
| 98 | }, |
| 99 | states: [ |
| 100 | new wp.media.controller.Library({ |
| 101 | library: wp.media.query( { type: mime } ), |
| 102 | title: $el.data('choose'), |
| 103 | displaySettings: 'image' === mime |
| 104 | }) |
| 105 | ] |
| 106 | } ); |
111 | 107 | |
112 | 108 | mediaPreview = function(attachment) { |
113 | 109 | var w, h, dimensions = '', url = attachment.url, mime = attachment.mime, format = attachment.type; |
… |
… |
window.wp = window.wp || {}; |
154 | 150 | // show one preview at a time |
155 | 151 | mediaPreview(attachment); |
156 | 152 | } else { |
157 | | html = wp.media.string.image({}, attachment); |
| 153 | html = wp.media.string.image({ |
| 154 | align : getUserSetting('align'), |
| 155 | size : getUserSetting('imgsize'), |
| 156 | link : getUserSetting('urlbutton') |
| 157 | }, attachment); |
158 | 158 | // set the hidden input's value |
159 | 159 | $field.val(html); |
160 | 160 | $('#image-preview').remove(); |
diff --git wp-includes/functions.php wp-includes/functions.php
index 0afa50b..c10709c 100644
|
|
function wp_auth_check( $response, $data ) { |
3985 | 3985 | function get_tag_regex( $tag ) { |
3986 | 3986 | if ( empty( $tag ) ) |
3987 | 3987 | return; |
3988 | | |
3989 | | return sprintf( '(<%1$s[^>]*(?:/?>$|>[\s\S]*?</%1$s>))', tag_escape( $tag ) ); |
| 3988 | return sprintf( '<%1$s[^<]*(?:>[\s\S]*<\/%1$s>|\s*\/>)', tag_escape( $tag ) ); |
3990 | 3989 | } |
diff --git wp-includes/media.php wp-includes/media.php
index bd52867..d8a954a 100644
|
|
function get_embedded_media( $type, &$content, $remove = false, $limit = 0 ) { |
1966 | 1966 | |
1967 | 1967 | foreach ( array( $type, 'object', 'embed', 'iframe' ) as $tag ) { |
1968 | 1968 | if ( preg_match( '#' . get_tag_regex( $tag ) . '#', $content, $matches ) ) { |
1969 | | $html[] = $matches[1]; |
| 1969 | $html[] = $matches[0]; |
1970 | 1970 | if ( $remove ) |
1971 | 1971 | $content = str_replace( $matches[0], '', $content ); |
1972 | 1972 | |
… |
… |
function get_content_images( &$content, $html = true, $remove = false, $limit = |
2209 | 2209 | $tags = array(); |
2210 | 2210 | $captions = array(); |
2211 | 2211 | |
2212 | | if ( $remove && preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) { |
| 2212 | if ( preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) { |
2213 | 2213 | foreach ( $matches as $shortcode ) { |
2214 | | if ( 'caption' === $shortcode[2] ) |
| 2214 | if ( 'caption' === $shortcode[2] ) { |
2215 | 2215 | $captions[] = $shortcode[0]; |
| 2216 | if ( $html ) |
| 2217 | $tags[] = do_shortcode( $shortcode[0] ); |
| 2218 | } |
| 2219 | |
| 2220 | if ( $limit > 0 && count( $tags ) >= $limit ) |
| 2221 | break; |
2216 | 2222 | } |
2217 | 2223 | } |
2218 | 2224 | |
2219 | | if ( preg_match_all( '#<img[^>]+/?>#i', $content, $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) { |
2220 | | foreach ( $matches as $tag ) { |
2221 | | $count = 1; |
2222 | | if ( $remove ) { |
| 2225 | foreach ( array( 'a', 'img' ) as $tag ) { |
| 2226 | if ( preg_match_all( '#' . get_tag_regex( $tag ) . '#i', $content, $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) { |
| 2227 | foreach ( $matches as $node ) { |
| 2228 | if ( ! strstr( $node[0], '<img ' ) ) |
| 2229 | continue; |
| 2230 | |
| 2231 | $count = 1; |
| 2232 | $found = false; |
| 2233 | |
2223 | 2234 | foreach ( $captions as $caption ) { |
2224 | | if ( strstr( $caption, $tag[0] ) ) { |
2225 | | $content = str_replace( $caption, '', $content, $count ); |
| 2235 | if ( strstr( $caption, $node[0] ) ) { |
| 2236 | $found = true; |
| 2237 | if ( $remove ) |
| 2238 | $content = str_replace( $caption, '', $content, $count ); |
2226 | 2239 | } |
2227 | 2240 | } |
2228 | 2241 | |
2229 | | $content = str_replace( $tag[0], '', $content, $count ); |
2230 | | } |
| 2242 | if ( $remove ) |
| 2243 | $content = str_replace( $node[0], '', $content, $count ); |
2231 | 2244 | |
2232 | | $tags[] = $tag[0]; |
| 2245 | if ( ! $found ) |
| 2246 | $tags[] = $node[0]; |
2233 | 2247 | |
2234 | | if ( $limit > 0 && count( $tags ) >= $limit ) |
2235 | | break; |
| 2248 | if ( $limit > 0 && count( $tags ) >= $limit ) |
| 2249 | break 2; |
| 2250 | } |
2236 | 2251 | } |
2237 | 2252 | } |
2238 | 2253 | |
… |
… |
function get_the_post_format_image( $attached_size = 'full', &$post = null ) { |
2400 | 2415 | if ( isset( $post->format_content ) ) |
2401 | 2416 | return $post->format_content; |
2402 | 2417 | |
| 2418 | $matched = false; |
2403 | 2419 | $meta = get_post_format_meta( $post->ID ); |
2404 | 2420 | |
2405 | 2421 | $link_fmt = '%s'; |
… |
… |
function get_the_post_format_image( $attached_size = 'full', &$post = null ) { |
2407 | 2423 | $link_fmt = '<a href="' . esc_url( $meta['url'] ) . '">%s</a>'; |
2408 | 2424 | |
2409 | 2425 | if ( ! empty( $meta['image'] ) ) { |
2410 | | if ( is_numeric( $meta['image'] ) ) |
| 2426 | if ( is_numeric( $meta['image'] ) ) { |
2411 | 2427 | $image = wp_get_attachment_image( absint( $meta['image'] ), $attached_size ); |
2412 | | elseif ( preg_match( '/' . get_shortcode_regex() . '/s', $meta['image'] ) ) |
| 2428 | // wrap image in <a> |
| 2429 | if ( ! empty( $meta['url'] ) ) |
| 2430 | $image = sprint( $link_fmt, $image ); |
| 2431 | } elseif ( has_shortcode( $meta['image'], 'gallery' ) ) { |
| 2432 | // wrap <img> in <a> |
| 2433 | if ( ! empty( $meta['url'] ) && false === strpos( $meta['image'], '<a ' ) ) { |
| 2434 | $meta['image'] = preg_replace( |
| 2435 | '#(<img[^>]+>)#', |
| 2436 | sprintf( '<a href="%s">$1</a>', esc_url( $meta['url'] ) ), |
| 2437 | $meta['image'] |
| 2438 | ); |
| 2439 | } |
2413 | 2440 | $image = do_shortcode( $meta['image'] ); |
2414 | | elseif ( ! preg_match( '#<[^>]+>#', $meta['image'] ) ) |
| 2441 | } elseif ( ! preg_match( '#<[^>]+>#', $meta['image'] ) ) { |
| 2442 | // not HTML, assume URL |
2415 | 2443 | $image = sprintf( '<img src="%s" alt="" />', esc_url( $meta['image'] ) ); |
2416 | | else |
| 2444 | } else { |
| 2445 | // assume HTML |
2417 | 2446 | $image = $meta['image']; |
| 2447 | } |
2418 | 2448 | |
2419 | | $post->format_content = sprintf( $link_fmt, $image ); |
| 2449 | if ( false === strpos( $image, '<a ' ) ) |
| 2450 | $post->format_content = sprintf( $link_fmt, $image ); |
| 2451 | else |
| 2452 | $post->format_content = $image; |
2420 | 2453 | return $post->format_content; |
2421 | 2454 | } |
2422 | 2455 | |
… |
… |
function get_the_post_format_image( $attached_size = 'full', &$post = null ) { |
2426 | 2459 | $sizes = get_intermediate_image_sizes(); |
2427 | 2460 | $sizes[] = 'full'; // Add original image source. |
2428 | 2461 | |
2429 | | $urls = array(); |
| 2462 | $urls = array( get_attachment_link( $media->ID ) ); |
2430 | 2463 | foreach ( $sizes as $size ) { |
2431 | 2464 | $image = wp_get_attachment_image_src( $media->ID, $size ); |
2432 | 2465 | if ( $image ) |
… |
… |
function get_the_post_format_image( $attached_size = 'full', &$post = null ) { |
2444 | 2477 | foreach ( $matches as $shortcode ) { |
2445 | 2478 | if ( 'caption' === $shortcode[2] ) { |
2446 | 2479 | foreach ( $urls as $url ) { |
2447 | | if ( strstr( $shortcode[0], $url ) ) |
| 2480 | if ( strstr( $shortcode[0], $url ) ) { |
| 2481 | if ( ! $matched ) |
| 2482 | $matched = do_shortcode( $shortcode[0] ); |
2448 | 2483 | $content = str_replace( $shortcode[0], '', $content, $count ); |
| 2484 | } |
2449 | 2485 | } |
2450 | 2486 | } |
2451 | 2487 | } |
… |
… |
function get_the_post_format_image( $attached_size = 'full', &$post = null ) { |
2455 | 2491 | if ( preg_match_all( '#' . get_tag_regex( $tag ) . '#', $content, $matches, PREG_SET_ORDER ) && ! empty( $matches ) ) { |
2456 | 2492 | foreach ( $matches as $match ) { |
2457 | 2493 | foreach ( $urls as $url ) { |
2458 | | if ( strstr( $match[0], $url ) ) |
| 2494 | if ( strstr( $match[0], $url ) ) { |
| 2495 | if ( ! $matched ) |
| 2496 | $matched = $match[0]; |
2459 | 2497 | $content = str_replace( $match[0], '', $content, $count ); |
| 2498 | } |
2460 | 2499 | } |
2461 | 2500 | } |
2462 | 2501 | } |
2463 | 2502 | } |
2464 | 2503 | |
2465 | 2504 | $post->split_content = $content; |
2466 | | $image = wp_get_attachment_image( $media->ID, $attached_size ); |
2467 | | $post->format_content = sprintf( $link_fmt, $image ); |
| 2505 | if ( ! $matched ) { |
| 2506 | $image = wp_get_attachment_image( $media->ID, $attached_size ); |
| 2507 | $post->format_content = sprintf( $link_fmt, $image ); |
| 2508 | } else { |
| 2509 | $post->format_content = $matched; |
| 2510 | if ( ! empty( $meta['url'] ) && false === stripos( $matched, '<a ' ) ) |
| 2511 | $post->format_content = sprintf( $link_fmt, $matched ); |
| 2512 | } |
2468 | 2513 | return $post->format_content; |
2469 | 2514 | } |
2470 | 2515 | |
… |
… |
function attachment_url_to_postid( $url ) { |
2508 | 2553 | } |
2509 | 2554 | |
2510 | 2555 | return 0; |
2511 | | } |
2512 | | No newline at end of file |
| 2556 | } |