Edit File by line
/home/barbar84/www/wp-inclu...
File: media.php
}
[2000] Fix | Delete
[2001] Fix | Delete
/**
[2002] Fix | Delete
* Filters the `loading` attribute value to add to an iframe. Default `lazy`.
[2003] Fix | Delete
*
[2004] Fix | Delete
* Returning `false` or an empty string will not add the attribute.
[2005] Fix | Delete
* Returning `true` will add the default value.
[2006] Fix | Delete
*
[2007] Fix | Delete
* @since 5.7.0
[2008] Fix | Delete
*
[2009] Fix | Delete
* @param string|bool $value The `loading` attribute value. Returning a falsey value will result in
[2010] Fix | Delete
* the attribute being omitted for the iframe. Default 'lazy'.
[2011] Fix | Delete
* @param string $iframe The HTML `iframe` tag to be filtered.
[2012] Fix | Delete
* @param string $context Additional context about how the function was called or where the iframe tag is.
[2013] Fix | Delete
*/
[2014] Fix | Delete
$value = apply_filters( 'wp_iframe_tag_add_loading_attr', 'lazy', $iframe, $context );
[2015] Fix | Delete
[2016] Fix | Delete
if ( $value ) {
[2017] Fix | Delete
if ( ! in_array( $value, array( 'lazy', 'eager' ), true ) ) {
[2018] Fix | Delete
$value = 'lazy';
[2019] Fix | Delete
}
[2020] Fix | Delete
[2021] Fix | Delete
return str_replace( '<iframe', '<iframe loading="' . esc_attr( $value ) . '"', $iframe );
[2022] Fix | Delete
}
[2023] Fix | Delete
[2024] Fix | Delete
return $iframe;
[2025] Fix | Delete
}
[2026] Fix | Delete
[2027] Fix | Delete
/**
[2028] Fix | Delete
* Adds a 'wp-post-image' class to post thumbnails. Internal use only.
[2029] Fix | Delete
*
[2030] Fix | Delete
* Uses the {@see 'begin_fetch_post_thumbnail_html'} and {@see 'end_fetch_post_thumbnail_html'}
[2031] Fix | Delete
* action hooks to dynamically add/remove itself so as to only filter post thumbnails.
[2032] Fix | Delete
*
[2033] Fix | Delete
* @ignore
[2034] Fix | Delete
* @since 2.9.0
[2035] Fix | Delete
*
[2036] Fix | Delete
* @param string[] $attr Array of thumbnail attributes including src, class, alt, title, keyed by attribute name.
[2037] Fix | Delete
* @return string[] Modified array of attributes including the new 'wp-post-image' class.
[2038] Fix | Delete
*/
[2039] Fix | Delete
function _wp_post_thumbnail_class_filter( $attr ) {
[2040] Fix | Delete
$attr['class'] .= ' wp-post-image';
[2041] Fix | Delete
return $attr;
[2042] Fix | Delete
}
[2043] Fix | Delete
[2044] Fix | Delete
/**
[2045] Fix | Delete
* Adds '_wp_post_thumbnail_class_filter' callback to the 'wp_get_attachment_image_attributes'
[2046] Fix | Delete
* filter hook. Internal use only.
[2047] Fix | Delete
*
[2048] Fix | Delete
* @ignore
[2049] Fix | Delete
* @since 2.9.0
[2050] Fix | Delete
*
[2051] Fix | Delete
* @param string[] $attr Array of thumbnail attributes including src, class, alt, title, keyed by attribute name.
[2052] Fix | Delete
*/
[2053] Fix | Delete
function _wp_post_thumbnail_class_filter_add( $attr ) {
[2054] Fix | Delete
add_filter( 'wp_get_attachment_image_attributes', '_wp_post_thumbnail_class_filter' );
[2055] Fix | Delete
}
[2056] Fix | Delete
[2057] Fix | Delete
/**
[2058] Fix | Delete
* Removes the '_wp_post_thumbnail_class_filter' callback from the 'wp_get_attachment_image_attributes'
[2059] Fix | Delete
* filter hook. Internal use only.
[2060] Fix | Delete
*
[2061] Fix | Delete
* @ignore
[2062] Fix | Delete
* @since 2.9.0
[2063] Fix | Delete
*
[2064] Fix | Delete
* @param string[] $attr Array of thumbnail attributes including src, class, alt, title, keyed by attribute name.
[2065] Fix | Delete
*/
[2066] Fix | Delete
function _wp_post_thumbnail_class_filter_remove( $attr ) {
[2067] Fix | Delete
remove_filter( 'wp_get_attachment_image_attributes', '_wp_post_thumbnail_class_filter' );
[2068] Fix | Delete
}
[2069] Fix | Delete
[2070] Fix | Delete
add_shortcode( 'wp_caption', 'img_caption_shortcode' );
[2071] Fix | Delete
add_shortcode( 'caption', 'img_caption_shortcode' );
[2072] Fix | Delete
[2073] Fix | Delete
/**
[2074] Fix | Delete
* Builds the Caption shortcode output.
[2075] Fix | Delete
*
[2076] Fix | Delete
* Allows a plugin to replace the content that would otherwise be returned. The
[2077] Fix | Delete
* filter is {@see 'img_caption_shortcode'} and passes an empty string, the attr
[2078] Fix | Delete
* parameter and the content parameter values.
[2079] Fix | Delete
*
[2080] Fix | Delete
* The supported attributes for the shortcode are 'id', 'caption_id', 'align',
[2081] Fix | Delete
* 'width', 'caption', and 'class'.
[2082] Fix | Delete
*
[2083] Fix | Delete
* @since 2.6.0
[2084] Fix | Delete
* @since 3.9.0 The `class` attribute was added.
[2085] Fix | Delete
* @since 5.1.0 The `caption_id` attribute was added.
[2086] Fix | Delete
*
[2087] Fix | Delete
* @param array $attr {
[2088] Fix | Delete
* Attributes of the caption shortcode.
[2089] Fix | Delete
*
[2090] Fix | Delete
* @type string $id ID of the image and caption container element, i.e. `<figure>` or `<div>`.
[2091] Fix | Delete
* @type string $caption_id ID of the caption element, i.e. `<figcaption>` or `<p>`.
[2092] Fix | Delete
* @type string $align Class name that aligns the caption. Default 'alignnone'. Accepts 'alignleft',
[2093] Fix | Delete
* 'aligncenter', alignright', 'alignnone'.
[2094] Fix | Delete
* @type int $width The width of the caption, in pixels.
[2095] Fix | Delete
* @type string $caption The caption text.
[2096] Fix | Delete
* @type string $class Additional class name(s) added to the caption container.
[2097] Fix | Delete
* }
[2098] Fix | Delete
* @param string $content Shortcode content.
[2099] Fix | Delete
* @return string HTML content to display the caption.
[2100] Fix | Delete
*/
[2101] Fix | Delete
function img_caption_shortcode( $attr, $content = null ) {
[2102] Fix | Delete
// New-style shortcode with the caption inside the shortcode with the link and image tags.
[2103] Fix | Delete
if ( ! isset( $attr['caption'] ) ) {
[2104] Fix | Delete
if ( preg_match( '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches ) ) {
[2105] Fix | Delete
$content = $matches[1];
[2106] Fix | Delete
$attr['caption'] = trim( $matches[2] );
[2107] Fix | Delete
}
[2108] Fix | Delete
} elseif ( strpos( $attr['caption'], '<' ) !== false ) {
[2109] Fix | Delete
$attr['caption'] = wp_kses( $attr['caption'], 'post' );
[2110] Fix | Delete
}
[2111] Fix | Delete
[2112] Fix | Delete
/**
[2113] Fix | Delete
* Filters the default caption shortcode output.
[2114] Fix | Delete
*
[2115] Fix | Delete
* If the filtered output isn't empty, it will be used instead of generating
[2116] Fix | Delete
* the default caption template.
[2117] Fix | Delete
*
[2118] Fix | Delete
* @since 2.6.0
[2119] Fix | Delete
*
[2120] Fix | Delete
* @see img_caption_shortcode()
[2121] Fix | Delete
*
[2122] Fix | Delete
* @param string $output The caption output. Default empty.
[2123] Fix | Delete
* @param array $attr Attributes of the caption shortcode.
[2124] Fix | Delete
* @param string $content The image element, possibly wrapped in a hyperlink.
[2125] Fix | Delete
*/
[2126] Fix | Delete
$output = apply_filters( 'img_caption_shortcode', '', $attr, $content );
[2127] Fix | Delete
[2128] Fix | Delete
if ( ! empty( $output ) ) {
[2129] Fix | Delete
return $output;
[2130] Fix | Delete
}
[2131] Fix | Delete
[2132] Fix | Delete
$atts = shortcode_atts(
[2133] Fix | Delete
array(
[2134] Fix | Delete
'id' => '',
[2135] Fix | Delete
'caption_id' => '',
[2136] Fix | Delete
'align' => 'alignnone',
[2137] Fix | Delete
'width' => '',
[2138] Fix | Delete
'caption' => '',
[2139] Fix | Delete
'class' => '',
[2140] Fix | Delete
),
[2141] Fix | Delete
$attr,
[2142] Fix | Delete
'caption'
[2143] Fix | Delete
);
[2144] Fix | Delete
[2145] Fix | Delete
$atts['width'] = (int) $atts['width'];
[2146] Fix | Delete
[2147] Fix | Delete
if ( $atts['width'] < 1 || empty( $atts['caption'] ) ) {
[2148] Fix | Delete
return $content;
[2149] Fix | Delete
}
[2150] Fix | Delete
[2151] Fix | Delete
$id = '';
[2152] Fix | Delete
$caption_id = '';
[2153] Fix | Delete
$describedby = '';
[2154] Fix | Delete
[2155] Fix | Delete
if ( $atts['id'] ) {
[2156] Fix | Delete
$atts['id'] = sanitize_html_class( $atts['id'] );
[2157] Fix | Delete
$id = 'id="' . esc_attr( $atts['id'] ) . '" ';
[2158] Fix | Delete
}
[2159] Fix | Delete
[2160] Fix | Delete
if ( $atts['caption_id'] ) {
[2161] Fix | Delete
$atts['caption_id'] = sanitize_html_class( $atts['caption_id'] );
[2162] Fix | Delete
} elseif ( $atts['id'] ) {
[2163] Fix | Delete
$atts['caption_id'] = 'caption-' . str_replace( '_', '-', $atts['id'] );
[2164] Fix | Delete
}
[2165] Fix | Delete
[2166] Fix | Delete
if ( $atts['caption_id'] ) {
[2167] Fix | Delete
$caption_id = 'id="' . esc_attr( $atts['caption_id'] ) . '" ';
[2168] Fix | Delete
$describedby = 'aria-describedby="' . esc_attr( $atts['caption_id'] ) . '" ';
[2169] Fix | Delete
}
[2170] Fix | Delete
[2171] Fix | Delete
$class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] );
[2172] Fix | Delete
[2173] Fix | Delete
$html5 = current_theme_supports( 'html5', 'caption' );
[2174] Fix | Delete
// HTML5 captions never added the extra 10px to the image width.
[2175] Fix | Delete
$width = $html5 ? $atts['width'] : ( 10 + $atts['width'] );
[2176] Fix | Delete
[2177] Fix | Delete
/**
[2178] Fix | Delete
* Filters the width of an image's caption.
[2179] Fix | Delete
*
[2180] Fix | Delete
* By default, the caption is 10 pixels greater than the width of the image,
[2181] Fix | Delete
* to prevent post content from running up against a floated image.
[2182] Fix | Delete
*
[2183] Fix | Delete
* @since 3.7.0
[2184] Fix | Delete
*
[2185] Fix | Delete
* @see img_caption_shortcode()
[2186] Fix | Delete
*
[2187] Fix | Delete
* @param int $width Width of the caption in pixels. To remove this inline style,
[2188] Fix | Delete
* return zero.
[2189] Fix | Delete
* @param array $atts Attributes of the caption shortcode.
[2190] Fix | Delete
* @param string $content The image element, possibly wrapped in a hyperlink.
[2191] Fix | Delete
*/
[2192] Fix | Delete
$caption_width = apply_filters( 'img_caption_shortcode_width', $width, $atts, $content );
[2193] Fix | Delete
[2194] Fix | Delete
$style = '';
[2195] Fix | Delete
[2196] Fix | Delete
if ( $caption_width ) {
[2197] Fix | Delete
$style = 'style="width: ' . (int) $caption_width . 'px" ';
[2198] Fix | Delete
}
[2199] Fix | Delete
[2200] Fix | Delete
if ( $html5 ) {
[2201] Fix | Delete
$html = sprintf(
[2202] Fix | Delete
'<figure %s%s%sclass="%s">%s%s</figure>',
[2203] Fix | Delete
$id,
[2204] Fix | Delete
$describedby,
[2205] Fix | Delete
$style,
[2206] Fix | Delete
esc_attr( $class ),
[2207] Fix | Delete
do_shortcode( $content ),
[2208] Fix | Delete
sprintf(
[2209] Fix | Delete
'<figcaption %sclass="wp-caption-text">%s</figcaption>',
[2210] Fix | Delete
$caption_id,
[2211] Fix | Delete
$atts['caption']
[2212] Fix | Delete
)
[2213] Fix | Delete
);
[2214] Fix | Delete
} else {
[2215] Fix | Delete
$html = sprintf(
[2216] Fix | Delete
'<div %s%sclass="%s">%s%s</div>',
[2217] Fix | Delete
$id,
[2218] Fix | Delete
$style,
[2219] Fix | Delete
esc_attr( $class ),
[2220] Fix | Delete
str_replace( '<img ', '<img ' . $describedby, do_shortcode( $content ) ),
[2221] Fix | Delete
sprintf(
[2222] Fix | Delete
'<p %sclass="wp-caption-text">%s</p>',
[2223] Fix | Delete
$caption_id,
[2224] Fix | Delete
$atts['caption']
[2225] Fix | Delete
)
[2226] Fix | Delete
);
[2227] Fix | Delete
}
[2228] Fix | Delete
[2229] Fix | Delete
return $html;
[2230] Fix | Delete
}
[2231] Fix | Delete
[2232] Fix | Delete
add_shortcode( 'gallery', 'gallery_shortcode' );
[2233] Fix | Delete
[2234] Fix | Delete
/**
[2235] Fix | Delete
* Builds the Gallery shortcode output.
[2236] Fix | Delete
*
[2237] Fix | Delete
* This implements the functionality of the Gallery Shortcode for displaying
[2238] Fix | Delete
* WordPress images on a post.
[2239] Fix | Delete
*
[2240] Fix | Delete
* @since 2.5.0
[2241] Fix | Delete
*
[2242] Fix | Delete
* @param array $attr {
[2243] Fix | Delete
* Attributes of the gallery shortcode.
[2244] Fix | Delete
*
[2245] Fix | Delete
* @type string $order Order of the images in the gallery. Default 'ASC'. Accepts 'ASC', 'DESC'.
[2246] Fix | Delete
* @type string $orderby The field to use when ordering the images. Default 'menu_order ID'.
[2247] Fix | Delete
* Accepts any valid SQL ORDERBY statement.
[2248] Fix | Delete
* @type int $id Post ID.
[2249] Fix | Delete
* @type string $itemtag HTML tag to use for each image in the gallery.
[2250] Fix | Delete
* Default 'dl', or 'figure' when the theme registers HTML5 gallery support.
[2251] Fix | Delete
* @type string $icontag HTML tag to use for each image's icon.
[2252] Fix | Delete
* Default 'dt', or 'div' when the theme registers HTML5 gallery support.
[2253] Fix | Delete
* @type string $captiontag HTML tag to use for each image's caption.
[2254] Fix | Delete
* Default 'dd', or 'figcaption' when the theme registers HTML5 gallery support.
[2255] Fix | Delete
* @type int $columns Number of columns of images to display. Default 3.
[2256] Fix | Delete
* @type string|int[] $size Size of the images to display. Accepts any registered image size name, or an array
[2257] Fix | Delete
* of width and height values in pixels (in that order). Default 'thumbnail'.
[2258] Fix | Delete
* @type string $ids A comma-separated list of IDs of attachments to display. Default empty.
[2259] Fix | Delete
* @type string $include A comma-separated list of IDs of attachments to include. Default empty.
[2260] Fix | Delete
* @type string $exclude A comma-separated list of IDs of attachments to exclude. Default empty.
[2261] Fix | Delete
* @type string $link What to link each image to. Default empty (links to the attachment page).
[2262] Fix | Delete
* Accepts 'file', 'none'.
[2263] Fix | Delete
* }
[2264] Fix | Delete
* @return string HTML content to display gallery.
[2265] Fix | Delete
*/
[2266] Fix | Delete
function gallery_shortcode( $attr ) {
[2267] Fix | Delete
$post = get_post();
[2268] Fix | Delete
[2269] Fix | Delete
static $instance = 0;
[2270] Fix | Delete
$instance++;
[2271] Fix | Delete
[2272] Fix | Delete
if ( ! empty( $attr['ids'] ) ) {
[2273] Fix | Delete
// 'ids' is explicitly ordered, unless you specify otherwise.
[2274] Fix | Delete
if ( empty( $attr['orderby'] ) ) {
[2275] Fix | Delete
$attr['orderby'] = 'post__in';
[2276] Fix | Delete
}
[2277] Fix | Delete
$attr['include'] = $attr['ids'];
[2278] Fix | Delete
}
[2279] Fix | Delete
[2280] Fix | Delete
/**
[2281] Fix | Delete
* Filters the default gallery shortcode output.
[2282] Fix | Delete
*
[2283] Fix | Delete
* If the filtered output isn't empty, it will be used instead of generating
[2284] Fix | Delete
* the default gallery template.
[2285] Fix | Delete
*
[2286] Fix | Delete
* @since 2.5.0
[2287] Fix | Delete
* @since 4.2.0 The `$instance` parameter was added.
[2288] Fix | Delete
*
[2289] Fix | Delete
* @see gallery_shortcode()
[2290] Fix | Delete
*
[2291] Fix | Delete
* @param string $output The gallery output. Default empty.
[2292] Fix | Delete
* @param array $attr Attributes of the gallery shortcode.
[2293] Fix | Delete
* @param int $instance Unique numeric ID of this gallery shortcode instance.
[2294] Fix | Delete
*/
[2295] Fix | Delete
$output = apply_filters( 'post_gallery', '', $attr, $instance );
[2296] Fix | Delete
[2297] Fix | Delete
if ( ! empty( $output ) ) {
[2298] Fix | Delete
return $output;
[2299] Fix | Delete
}
[2300] Fix | Delete
[2301] Fix | Delete
$html5 = current_theme_supports( 'html5', 'gallery' );
[2302] Fix | Delete
$atts = shortcode_atts(
[2303] Fix | Delete
array(
[2304] Fix | Delete
'order' => 'ASC',
[2305] Fix | Delete
'orderby' => 'menu_order ID',
[2306] Fix | Delete
'id' => $post ? $post->ID : 0,
[2307] Fix | Delete
'itemtag' => $html5 ? 'figure' : 'dl',
[2308] Fix | Delete
'icontag' => $html5 ? 'div' : 'dt',
[2309] Fix | Delete
'captiontag' => $html5 ? 'figcaption' : 'dd',
[2310] Fix | Delete
'columns' => 3,
[2311] Fix | Delete
'size' => 'thumbnail',
[2312] Fix | Delete
'include' => '',
[2313] Fix | Delete
'exclude' => '',
[2314] Fix | Delete
'link' => '',
[2315] Fix | Delete
),
[2316] Fix | Delete
$attr,
[2317] Fix | Delete
'gallery'
[2318] Fix | Delete
);
[2319] Fix | Delete
[2320] Fix | Delete
$id = (int) $atts['id'];
[2321] Fix | Delete
[2322] Fix | Delete
if ( ! empty( $atts['include'] ) ) {
[2323] Fix | Delete
$_attachments = get_posts(
[2324] Fix | Delete
array(
[2325] Fix | Delete
'include' => $atts['include'],
[2326] Fix | Delete
'post_status' => 'inherit',
[2327] Fix | Delete
'post_type' => 'attachment',
[2328] Fix | Delete
'post_mime_type' => 'image',
[2329] Fix | Delete
'order' => $atts['order'],
[2330] Fix | Delete
'orderby' => $atts['orderby'],
[2331] Fix | Delete
)
[2332] Fix | Delete
);
[2333] Fix | Delete
[2334] Fix | Delete
$attachments = array();
[2335] Fix | Delete
foreach ( $_attachments as $key => $val ) {
[2336] Fix | Delete
$attachments[ $val->ID ] = $_attachments[ $key ];
[2337] Fix | Delete
}
[2338] Fix | Delete
} elseif ( ! empty( $atts['exclude'] ) ) {
[2339] Fix | Delete
$post_parent_id = $id;
[2340] Fix | Delete
$attachments = get_children(
[2341] Fix | Delete
array(
[2342] Fix | Delete
'post_parent' => $id,
[2343] Fix | Delete
'exclude' => $atts['exclude'],
[2344] Fix | Delete
'post_status' => 'inherit',
[2345] Fix | Delete
'post_type' => 'attachment',
[2346] Fix | Delete
'post_mime_type' => 'image',
[2347] Fix | Delete
'order' => $atts['order'],
[2348] Fix | Delete
'orderby' => $atts['orderby'],
[2349] Fix | Delete
)
[2350] Fix | Delete
);
[2351] Fix | Delete
} else {
[2352] Fix | Delete
$post_parent_id = $id;
[2353] Fix | Delete
$attachments = get_children(
[2354] Fix | Delete
array(
[2355] Fix | Delete
'post_parent' => $id,
[2356] Fix | Delete
'post_status' => 'inherit',
[2357] Fix | Delete
'post_type' => 'attachment',
[2358] Fix | Delete
'post_mime_type' => 'image',
[2359] Fix | Delete
'order' => $atts['order'],
[2360] Fix | Delete
'orderby' => $atts['orderby'],
[2361] Fix | Delete
)
[2362] Fix | Delete
);
[2363] Fix | Delete
}
[2364] Fix | Delete
[2365] Fix | Delete
if ( ! empty( $post_parent_id ) ) {
[2366] Fix | Delete
$post_parent = get_post( $post_parent_id );
[2367] Fix | Delete
[2368] Fix | Delete
// terminate the shortcode execution if user cannot read the post or password-protected
[2369] Fix | Delete
if (
[2370] Fix | Delete
( ! is_post_publicly_viewable( $post_parent->ID ) && ! current_user_can( 'read_post', $post_parent->ID ) )
[2371] Fix | Delete
|| post_password_required( $post_parent ) ) {
[2372] Fix | Delete
return '';
[2373] Fix | Delete
}
[2374] Fix | Delete
}
[2375] Fix | Delete
[2376] Fix | Delete
if ( empty( $attachments ) ) {
[2377] Fix | Delete
return '';
[2378] Fix | Delete
}
[2379] Fix | Delete
[2380] Fix | Delete
if ( is_feed() ) {
[2381] Fix | Delete
$output = "\n";
[2382] Fix | Delete
foreach ( $attachments as $att_id => $attachment ) {
[2383] Fix | Delete
if ( ! empty( $atts['link'] ) ) {
[2384] Fix | Delete
if ( 'none' === $atts['link'] ) {
[2385] Fix | Delete
$output .= wp_get_attachment_image( $att_id, $atts['size'], false, $attr );
[2386] Fix | Delete
} else {
[2387] Fix | Delete
$output .= wp_get_attachment_link( $att_id, $atts['size'], false );
[2388] Fix | Delete
}
[2389] Fix | Delete
} else {
[2390] Fix | Delete
$output .= wp_get_attachment_link( $att_id, $atts['size'], true );
[2391] Fix | Delete
}
[2392] Fix | Delete
$output .= "\n";
[2393] Fix | Delete
}
[2394] Fix | Delete
return $output;
[2395] Fix | Delete
}
[2396] Fix | Delete
[2397] Fix | Delete
$itemtag = tag_escape( $atts['itemtag'] );
[2398] Fix | Delete
$captiontag = tag_escape( $atts['captiontag'] );
[2399] Fix | Delete
$icontag = tag_escape( $atts['icontag'] );
[2400] Fix | Delete
$valid_tags = wp_kses_allowed_html( 'post' );
[2401] Fix | Delete
if ( ! isset( $valid_tags[ $itemtag ] ) ) {
[2402] Fix | Delete
$itemtag = 'dl';
[2403] Fix | Delete
}
[2404] Fix | Delete
if ( ! isset( $valid_tags[ $captiontag ] ) ) {
[2405] Fix | Delete
$captiontag = 'dd';
[2406] Fix | Delete
}
[2407] Fix | Delete
if ( ! isset( $valid_tags[ $icontag ] ) ) {
[2408] Fix | Delete
$icontag = 'dt';
[2409] Fix | Delete
}
[2410] Fix | Delete
[2411] Fix | Delete
$columns = (int) $atts['columns'];
[2412] Fix | Delete
$itemwidth = $columns > 0 ? floor( 100 / $columns ) : 100;
[2413] Fix | Delete
$float = is_rtl() ? 'right' : 'left';
[2414] Fix | Delete
[2415] Fix | Delete
$selector = "gallery-{$instance}";
[2416] Fix | Delete
[2417] Fix | Delete
$gallery_style = '';
[2418] Fix | Delete
[2419] Fix | Delete
/**
[2420] Fix | Delete
* Filters whether to print default gallery styles.
[2421] Fix | Delete
*
[2422] Fix | Delete
* @since 3.1.0
[2423] Fix | Delete
*
[2424] Fix | Delete
* @param bool $print Whether to print default gallery styles.
[2425] Fix | Delete
* Defaults to false if the theme supports HTML5 galleries.
[2426] Fix | Delete
* Otherwise, defaults to true.
[2427] Fix | Delete
*/
[2428] Fix | Delete
if ( apply_filters( 'use_default_gallery_style', ! $html5 ) ) {
[2429] Fix | Delete
$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
[2430] Fix | Delete
[2431] Fix | Delete
$gallery_style = "
[2432] Fix | Delete
<style{$type_attr}>
[2433] Fix | Delete
#{$selector} {
[2434] Fix | Delete
margin: auto;
[2435] Fix | Delete
}
[2436] Fix | Delete
#{$selector} .gallery-item {
[2437] Fix | Delete
float: {$float};
[2438] Fix | Delete
margin-top: 10px;
[2439] Fix | Delete
text-align: center;
[2440] Fix | Delete
width: {$itemwidth}%;
[2441] Fix | Delete
}
[2442] Fix | Delete
#{$selector} img {
[2443] Fix | Delete
border: 2px solid #cfcfcf;
[2444] Fix | Delete
}
[2445] Fix | Delete
#{$selector} .gallery-caption {
[2446] Fix | Delete
margin-left: 0;
[2447] Fix | Delete
}
[2448] Fix | Delete
/* see gallery_shortcode() in wp-includes/media.php */
[2449] Fix | Delete
</style>\n\t\t";
[2450] Fix | Delete
}
[2451] Fix | Delete
[2452] Fix | Delete
$size_class = sanitize_html_class( is_array( $atts['size'] ) ? implode( 'x', $atts['size'] ) : $atts['size'] );
[2453] Fix | Delete
$gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
[2454] Fix | Delete
[2455] Fix | Delete
/**
[2456] Fix | Delete
* Filters the default gallery shortcode CSS styles.
[2457] Fix | Delete
*
[2458] Fix | Delete
* @since 2.5.0
[2459] Fix | Delete
*
[2460] Fix | Delete
* @param string $gallery_style Default CSS styles and opening HTML div container
[2461] Fix | Delete
* for the gallery shortcode output.
[2462] Fix | Delete
*/
[2463] Fix | Delete
$output = apply_filters( 'gallery_style', $gallery_style . $gallery_div );
[2464] Fix | Delete
[2465] Fix | Delete
$i = 0;
[2466] Fix | Delete
[2467] Fix | Delete
foreach ( $attachments as $id => $attachment ) {
[2468] Fix | Delete
[2469] Fix | Delete
$attr = ( trim( $attachment->post_excerpt ) ) ? array( 'aria-describedby' => "$selector-$id" ) : '';
[2470] Fix | Delete
[2471] Fix | Delete
if ( ! empty( $atts['link'] ) && 'file' === $atts['link'] ) {
[2472] Fix | Delete
$image_output = wp_get_attachment_link( $id, $atts['size'], false, false, false, $attr );
[2473] Fix | Delete
} elseif ( ! empty( $atts['link'] ) && 'none' === $atts['link'] ) {
[2474] Fix | Delete
$image_output = wp_get_attachment_image( $id, $atts['size'], false, $attr );
[2475] Fix | Delete
} else {
[2476] Fix | Delete
$image_output = wp_get_attachment_link( $id, $atts['size'], true, false, false, $attr );
[2477] Fix | Delete
}
[2478] Fix | Delete
[2479] Fix | Delete
$image_meta = wp_get_attachment_metadata( $id );
[2480] Fix | Delete
[2481] Fix | Delete
$orientation = '';
[2482] Fix | Delete
[2483] Fix | Delete
if ( isset( $image_meta['height'], $image_meta['width'] ) ) {
[2484] Fix | Delete
$orientation = ( $image_meta['height'] > $image_meta['width'] ) ? 'portrait' : 'landscape';
[2485] Fix | Delete
}
[2486] Fix | Delete
[2487] Fix | Delete
$output .= "<{$itemtag} class='gallery-item'>";
[2488] Fix | Delete
$output .= "
[2489] Fix | Delete
<{$icontag} class='gallery-icon {$orientation}'>
[2490] Fix | Delete
$image_output
[2491] Fix | Delete
</{$icontag}>";
[2492] Fix | Delete
[2493] Fix | Delete
if ( $captiontag && trim( $attachment->post_excerpt ) ) {
[2494] Fix | Delete
$output .= "
[2495] Fix | Delete
<{$captiontag} class='wp-caption-text gallery-caption' id='$selector-$id'>
[2496] Fix | Delete
" . wptexturize( $attachment->post_excerpt ) . "
[2497] Fix | Delete
</{$captiontag}>";
[2498] Fix | Delete
}
[2499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function