Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../public_h.../wp-inclu...
File: media.php
[2500] Fix | Delete
return $html;
[2501] Fix | Delete
}
[2502] Fix | Delete
[2503] Fix | Delete
add_shortcode( 'gallery', 'gallery_shortcode' );
[2504] Fix | Delete
[2505] Fix | Delete
/**
[2506] Fix | Delete
* Builds the Gallery shortcode output.
[2507] Fix | Delete
*
[2508] Fix | Delete
* This implements the functionality of the Gallery Shortcode for displaying
[2509] Fix | Delete
* WordPress images on a post.
[2510] Fix | Delete
*
[2511] Fix | Delete
* @since 2.5.0
[2512] Fix | Delete
* @since 2.8.0 Added the `$attr` parameter to set the shortcode output. New attributes included
[2513] Fix | Delete
* such as `size`, `itemtag`, `icontag`, `captiontag`, and columns. Changed markup from
[2514] Fix | Delete
* `div` tags to `dl`, `dt` and `dd` tags. Support more than one gallery on the
[2515] Fix | Delete
* same page.
[2516] Fix | Delete
* @since 2.9.0 Added support for `include` and `exclude` to shortcode.
[2517] Fix | Delete
* @since 3.5.0 Use get_post() instead of global `$post`. Handle mapping of `ids` to `include`
[2518] Fix | Delete
* and `orderby`.
[2519] Fix | Delete
* @since 3.6.0 Added validation for tags used in gallery shortcode. Add orientation information to items.
[2520] Fix | Delete
* @since 3.7.0 Introduced the `link` attribute.
[2521] Fix | Delete
* @since 3.9.0 `html5` gallery support, accepting 'itemtag', 'icontag', and 'captiontag' attributes.
[2522] Fix | Delete
* @since 4.0.0 Removed use of `extract()`.
[2523] Fix | Delete
* @since 4.1.0 Added attribute to `wp_get_attachment_link()` to output `aria-describedby`.
[2524] Fix | Delete
* @since 4.2.0 Passed the shortcode instance ID to `post_gallery` and `post_playlist` filters.
[2525] Fix | Delete
* @since 4.6.0 Standardized filter docs to match documentation standards for PHP.
[2526] Fix | Delete
* @since 5.1.0 Code cleanup for WPCS 1.0.0 coding standards.
[2527] Fix | Delete
* @since 5.3.0 Saved progress of intermediate image creation after upload.
[2528] Fix | Delete
* @since 5.5.0 Ensured that galleries can be output as a list of links in feeds.
[2529] Fix | Delete
* @since 5.6.0 Replaced order-style PHP type conversion functions with typecasts. Fix logic for
[2530] Fix | Delete
* an array of image dimensions.
[2531] Fix | Delete
*
[2532] Fix | Delete
* @param array $attr {
[2533] Fix | Delete
* Attributes of the gallery shortcode.
[2534] Fix | Delete
*
[2535] Fix | Delete
* @type string $order Order of the images in the gallery. Default 'ASC'. Accepts 'ASC', 'DESC'.
[2536] Fix | Delete
* @type string $orderby The field to use when ordering the images. Default 'menu_order ID'.
[2537] Fix | Delete
* Accepts any valid SQL ORDERBY statement.
[2538] Fix | Delete
* @type int $id Post ID.
[2539] Fix | Delete
* @type string $itemtag HTML tag to use for each image in the gallery.
[2540] Fix | Delete
* Default 'dl', or 'figure' when the theme registers HTML5 gallery support.
[2541] Fix | Delete
* @type string $icontag HTML tag to use for each image's icon.
[2542] Fix | Delete
* Default 'dt', or 'div' when the theme registers HTML5 gallery support.
[2543] Fix | Delete
* @type string $captiontag HTML tag to use for each image's caption.
[2544] Fix | Delete
* Default 'dd', or 'figcaption' when the theme registers HTML5 gallery support.
[2545] Fix | Delete
* @type int $columns Number of columns of images to display. Default 3.
[2546] Fix | Delete
* @type string|int[] $size Size of the images to display. Accepts any registered image size name, or an array
[2547] Fix | Delete
* of width and height values in pixels (in that order). Default 'thumbnail'.
[2548] Fix | Delete
* @type string $ids A comma-separated list of IDs of attachments to display. Default empty.
[2549] Fix | Delete
* @type string $include A comma-separated list of IDs of attachments to include. Default empty.
[2550] Fix | Delete
* @type string $exclude A comma-separated list of IDs of attachments to exclude. Default empty.
[2551] Fix | Delete
* @type string $link What to link each image to. Default empty (links to the attachment page).
[2552] Fix | Delete
* Accepts 'file', 'none'.
[2553] Fix | Delete
* }
[2554] Fix | Delete
* @return string HTML content to display gallery.
[2555] Fix | Delete
*/
[2556] Fix | Delete
function gallery_shortcode( $attr ) {
[2557] Fix | Delete
$post = get_post();
[2558] Fix | Delete
[2559] Fix | Delete
static $instance = 0;
[2560] Fix | Delete
++$instance;
[2561] Fix | Delete
[2562] Fix | Delete
if ( ! empty( $attr['ids'] ) ) {
[2563] Fix | Delete
// 'ids' is explicitly ordered, unless you specify otherwise.
[2564] Fix | Delete
if ( empty( $attr['orderby'] ) ) {
[2565] Fix | Delete
$attr['orderby'] = 'post__in';
[2566] Fix | Delete
}
[2567] Fix | Delete
$attr['include'] = $attr['ids'];
[2568] Fix | Delete
}
[2569] Fix | Delete
[2570] Fix | Delete
/**
[2571] Fix | Delete
* Filters the default gallery shortcode output.
[2572] Fix | Delete
*
[2573] Fix | Delete
* If the filtered output isn't empty, it will be used instead of generating
[2574] Fix | Delete
* the default gallery template.
[2575] Fix | Delete
*
[2576] Fix | Delete
* @since 2.5.0
[2577] Fix | Delete
* @since 4.2.0 The `$instance` parameter was added.
[2578] Fix | Delete
*
[2579] Fix | Delete
* @see gallery_shortcode()
[2580] Fix | Delete
*
[2581] Fix | Delete
* @param string $output The gallery output. Default empty.
[2582] Fix | Delete
* @param array $attr Attributes of the gallery shortcode.
[2583] Fix | Delete
* @param int $instance Unique numeric ID of this gallery shortcode instance.
[2584] Fix | Delete
*/
[2585] Fix | Delete
$output = apply_filters( 'post_gallery', '', $attr, $instance );
[2586] Fix | Delete
[2587] Fix | Delete
if ( ! empty( $output ) ) {
[2588] Fix | Delete
return $output;
[2589] Fix | Delete
}
[2590] Fix | Delete
[2591] Fix | Delete
$html5 = current_theme_supports( 'html5', 'gallery' );
[2592] Fix | Delete
$atts = shortcode_atts(
[2593] Fix | Delete
array(
[2594] Fix | Delete
'order' => 'ASC',
[2595] Fix | Delete
'orderby' => 'menu_order ID',
[2596] Fix | Delete
'id' => $post ? $post->ID : 0,
[2597] Fix | Delete
'itemtag' => $html5 ? 'figure' : 'dl',
[2598] Fix | Delete
'icontag' => $html5 ? 'div' : 'dt',
[2599] Fix | Delete
'captiontag' => $html5 ? 'figcaption' : 'dd',
[2600] Fix | Delete
'columns' => 3,
[2601] Fix | Delete
'size' => 'thumbnail',
[2602] Fix | Delete
'include' => '',
[2603] Fix | Delete
'exclude' => '',
[2604] Fix | Delete
'link' => '',
[2605] Fix | Delete
),
[2606] Fix | Delete
$attr,
[2607] Fix | Delete
'gallery'
[2608] Fix | Delete
);
[2609] Fix | Delete
[2610] Fix | Delete
$id = (int) $atts['id'];
[2611] Fix | Delete
[2612] Fix | Delete
if ( ! empty( $atts['include'] ) ) {
[2613] Fix | Delete
$_attachments = get_posts(
[2614] Fix | Delete
array(
[2615] Fix | Delete
'include' => $atts['include'],
[2616] Fix | Delete
'post_status' => 'inherit',
[2617] Fix | Delete
'post_type' => 'attachment',
[2618] Fix | Delete
'post_mime_type' => 'image',
[2619] Fix | Delete
'order' => $atts['order'],
[2620] Fix | Delete
'orderby' => $atts['orderby'],
[2621] Fix | Delete
)
[2622] Fix | Delete
);
[2623] Fix | Delete
[2624] Fix | Delete
$attachments = array();
[2625] Fix | Delete
foreach ( $_attachments as $key => $val ) {
[2626] Fix | Delete
$attachments[ $val->ID ] = $_attachments[ $key ];
[2627] Fix | Delete
}
[2628] Fix | Delete
} elseif ( ! empty( $atts['exclude'] ) ) {
[2629] Fix | Delete
$post_parent_id = $id;
[2630] Fix | Delete
$attachments = get_children(
[2631] Fix | Delete
array(
[2632] Fix | Delete
'post_parent' => $id,
[2633] Fix | Delete
'exclude' => $atts['exclude'],
[2634] Fix | Delete
'post_status' => 'inherit',
[2635] Fix | Delete
'post_type' => 'attachment',
[2636] Fix | Delete
'post_mime_type' => 'image',
[2637] Fix | Delete
'order' => $atts['order'],
[2638] Fix | Delete
'orderby' => $atts['orderby'],
[2639] Fix | Delete
)
[2640] Fix | Delete
);
[2641] Fix | Delete
} else {
[2642] Fix | Delete
$post_parent_id = $id;
[2643] Fix | Delete
$attachments = get_children(
[2644] Fix | Delete
array(
[2645] Fix | Delete
'post_parent' => $id,
[2646] Fix | Delete
'post_status' => 'inherit',
[2647] Fix | Delete
'post_type' => 'attachment',
[2648] Fix | Delete
'post_mime_type' => 'image',
[2649] Fix | Delete
'order' => $atts['order'],
[2650] Fix | Delete
'orderby' => $atts['orderby'],
[2651] Fix | Delete
)
[2652] Fix | Delete
);
[2653] Fix | Delete
}
[2654] Fix | Delete
[2655] Fix | Delete
if ( ! empty( $post_parent_id ) ) {
[2656] Fix | Delete
$post_parent = get_post( $post_parent_id );
[2657] Fix | Delete
[2658] Fix | Delete
// Terminate the shortcode execution if the user cannot read the post or it is password-protected.
[2659] Fix | Delete
if ( ! is_post_publicly_viewable( $post_parent->ID ) && ! current_user_can( 'read_post', $post_parent->ID )
[2660] Fix | Delete
|| post_password_required( $post_parent )
[2661] Fix | Delete
) {
[2662] Fix | Delete
return '';
[2663] Fix | Delete
}
[2664] Fix | Delete
}
[2665] Fix | Delete
[2666] Fix | Delete
if ( empty( $attachments ) ) {
[2667] Fix | Delete
return '';
[2668] Fix | Delete
}
[2669] Fix | Delete
[2670] Fix | Delete
if ( is_feed() ) {
[2671] Fix | Delete
$output = "\n";
[2672] Fix | Delete
foreach ( $attachments as $att_id => $attachment ) {
[2673] Fix | Delete
if ( ! empty( $atts['link'] ) ) {
[2674] Fix | Delete
if ( 'none' === $atts['link'] ) {
[2675] Fix | Delete
$output .= wp_get_attachment_image( $att_id, $atts['size'], false, $attr );
[2676] Fix | Delete
} else {
[2677] Fix | Delete
$output .= wp_get_attachment_link( $att_id, $atts['size'], false );
[2678] Fix | Delete
}
[2679] Fix | Delete
} else {
[2680] Fix | Delete
$output .= wp_get_attachment_link( $att_id, $atts['size'], true );
[2681] Fix | Delete
}
[2682] Fix | Delete
$output .= "\n";
[2683] Fix | Delete
}
[2684] Fix | Delete
return $output;
[2685] Fix | Delete
}
[2686] Fix | Delete
[2687] Fix | Delete
$itemtag = tag_escape( $atts['itemtag'] );
[2688] Fix | Delete
$captiontag = tag_escape( $atts['captiontag'] );
[2689] Fix | Delete
$icontag = tag_escape( $atts['icontag'] );
[2690] Fix | Delete
$valid_tags = wp_kses_allowed_html( 'post' );
[2691] Fix | Delete
if ( ! isset( $valid_tags[ $itemtag ] ) ) {
[2692] Fix | Delete
$itemtag = 'dl';
[2693] Fix | Delete
}
[2694] Fix | Delete
if ( ! isset( $valid_tags[ $captiontag ] ) ) {
[2695] Fix | Delete
$captiontag = 'dd';
[2696] Fix | Delete
}
[2697] Fix | Delete
if ( ! isset( $valid_tags[ $icontag ] ) ) {
[2698] Fix | Delete
$icontag = 'dt';
[2699] Fix | Delete
}
[2700] Fix | Delete
[2701] Fix | Delete
$columns = (int) $atts['columns'];
[2702] Fix | Delete
$itemwidth = $columns > 0 ? floor( 100 / $columns ) : 100;
[2703] Fix | Delete
$float = is_rtl() ? 'right' : 'left';
[2704] Fix | Delete
[2705] Fix | Delete
$selector = "gallery-{$instance}";
[2706] Fix | Delete
[2707] Fix | Delete
$gallery_style = '';
[2708] Fix | Delete
[2709] Fix | Delete
/**
[2710] Fix | Delete
* Filters whether to print default gallery styles.
[2711] Fix | Delete
*
[2712] Fix | Delete
* @since 3.1.0
[2713] Fix | Delete
*
[2714] Fix | Delete
* @param bool $print Whether to print default gallery styles.
[2715] Fix | Delete
* Defaults to false if the theme supports HTML5 galleries.
[2716] Fix | Delete
* Otherwise, defaults to true.
[2717] Fix | Delete
*/
[2718] Fix | Delete
if ( apply_filters( 'use_default_gallery_style', ! $html5 ) ) {
[2719] Fix | Delete
$type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
[2720] Fix | Delete
[2721] Fix | Delete
$gallery_style = "
[2722] Fix | Delete
<style{$type_attr}>
[2723] Fix | Delete
#{$selector} {
[2724] Fix | Delete
margin: auto;
[2725] Fix | Delete
}
[2726] Fix | Delete
#{$selector} .gallery-item {
[2727] Fix | Delete
float: {$float};
[2728] Fix | Delete
margin-top: 10px;
[2729] Fix | Delete
text-align: center;
[2730] Fix | Delete
width: {$itemwidth}%;
[2731] Fix | Delete
}
[2732] Fix | Delete
#{$selector} img {
[2733] Fix | Delete
border: 2px solid #cfcfcf;
[2734] Fix | Delete
}
[2735] Fix | Delete
#{$selector} .gallery-caption {
[2736] Fix | Delete
margin-left: 0;
[2737] Fix | Delete
}
[2738] Fix | Delete
/* see gallery_shortcode() in wp-includes/media.php */
[2739] Fix | Delete
</style>\n\t\t";
[2740] Fix | Delete
}
[2741] Fix | Delete
[2742] Fix | Delete
$size_class = sanitize_html_class( is_array( $atts['size'] ) ? implode( 'x', $atts['size'] ) : $atts['size'] );
[2743] Fix | Delete
$gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>";
[2744] Fix | Delete
[2745] Fix | Delete
/**
[2746] Fix | Delete
* Filters the default gallery shortcode CSS styles.
[2747] Fix | Delete
*
[2748] Fix | Delete
* @since 2.5.0
[2749] Fix | Delete
*
[2750] Fix | Delete
* @param string $gallery_style Default CSS styles and opening HTML div container
[2751] Fix | Delete
* for the gallery shortcode output.
[2752] Fix | Delete
*/
[2753] Fix | Delete
$output = apply_filters( 'gallery_style', $gallery_style . $gallery_div );
[2754] Fix | Delete
[2755] Fix | Delete
$i = 0;
[2756] Fix | Delete
[2757] Fix | Delete
foreach ( $attachments as $id => $attachment ) {
[2758] Fix | Delete
[2759] Fix | Delete
$attr = ( trim( $attachment->post_excerpt ) ) ? array( 'aria-describedby' => "$selector-$id" ) : '';
[2760] Fix | Delete
[2761] Fix | Delete
if ( ! empty( $atts['link'] ) && 'file' === $atts['link'] ) {
[2762] Fix | Delete
$image_output = wp_get_attachment_link( $id, $atts['size'], false, false, false, $attr );
[2763] Fix | Delete
} elseif ( ! empty( $atts['link'] ) && 'none' === $atts['link'] ) {
[2764] Fix | Delete
$image_output = wp_get_attachment_image( $id, $atts['size'], false, $attr );
[2765] Fix | Delete
} else {
[2766] Fix | Delete
$image_output = wp_get_attachment_link( $id, $atts['size'], true, false, false, $attr );
[2767] Fix | Delete
}
[2768] Fix | Delete
[2769] Fix | Delete
$image_meta = wp_get_attachment_metadata( $id );
[2770] Fix | Delete
[2771] Fix | Delete
$orientation = '';
[2772] Fix | Delete
[2773] Fix | Delete
if ( isset( $image_meta['height'], $image_meta['width'] ) ) {
[2774] Fix | Delete
$orientation = ( $image_meta['height'] > $image_meta['width'] ) ? 'portrait' : 'landscape';
[2775] Fix | Delete
}
[2776] Fix | Delete
[2777] Fix | Delete
$output .= "<{$itemtag} class='gallery-item'>";
[2778] Fix | Delete
$output .= "
[2779] Fix | Delete
<{$icontag} class='gallery-icon {$orientation}'>
[2780] Fix | Delete
$image_output
[2781] Fix | Delete
</{$icontag}>";
[2782] Fix | Delete
[2783] Fix | Delete
if ( $captiontag && trim( $attachment->post_excerpt ) ) {
[2784] Fix | Delete
$output .= "
[2785] Fix | Delete
<{$captiontag} class='wp-caption-text gallery-caption' id='$selector-$id'>
[2786] Fix | Delete
" . wptexturize( $attachment->post_excerpt ) . "
[2787] Fix | Delete
</{$captiontag}>";
[2788] Fix | Delete
}
[2789] Fix | Delete
[2790] Fix | Delete
$output .= "</{$itemtag}>";
[2791] Fix | Delete
[2792] Fix | Delete
if ( ! $html5 && $columns > 0 && 0 === ++$i % $columns ) {
[2793] Fix | Delete
$output .= '<br style="clear: both" />';
[2794] Fix | Delete
}
[2795] Fix | Delete
}
[2796] Fix | Delete
[2797] Fix | Delete
if ( ! $html5 && $columns > 0 && 0 !== $i % $columns ) {
[2798] Fix | Delete
$output .= "
[2799] Fix | Delete
<br style='clear: both' />";
[2800] Fix | Delete
}
[2801] Fix | Delete
[2802] Fix | Delete
$output .= "
[2803] Fix | Delete
</div>\n";
[2804] Fix | Delete
[2805] Fix | Delete
return $output;
[2806] Fix | Delete
}
[2807] Fix | Delete
[2808] Fix | Delete
/**
[2809] Fix | Delete
* Outputs the templates used by playlists.
[2810] Fix | Delete
*
[2811] Fix | Delete
* @since 3.9.0
[2812] Fix | Delete
*/
[2813] Fix | Delete
function wp_underscore_playlist_templates() {
[2814] Fix | Delete
?>
[2815] Fix | Delete
<script type="text/html" id="tmpl-wp-playlist-current-item">
[2816] Fix | Delete
<# if ( data.thumb && data.thumb.src ) { #>
[2817] Fix | Delete
<img src="{{ data.thumb.src }}" alt="" />
[2818] Fix | Delete
<# } #>
[2819] Fix | Delete
<div class="wp-playlist-caption">
[2820] Fix | Delete
<span class="wp-playlist-item-meta wp-playlist-item-title">
[2821] Fix | Delete
<# if ( data.meta.album || data.meta.artist ) { #>
[2822] Fix | Delete
<?php
[2823] Fix | Delete
/* translators: %s: Playlist item title. */
[2824] Fix | Delete
printf( _x( '&#8220;%s&#8221;', 'playlist item title' ), '{{ data.title }}' );
[2825] Fix | Delete
?>
[2826] Fix | Delete
<# } else { #>
[2827] Fix | Delete
{{ data.title }}
[2828] Fix | Delete
<# } #>
[2829] Fix | Delete
</span>
[2830] Fix | Delete
<# if ( data.meta.album ) { #><span class="wp-playlist-item-meta wp-playlist-item-album">{{ data.meta.album }}</span><# } #>
[2831] Fix | Delete
<# if ( data.meta.artist ) { #><span class="wp-playlist-item-meta wp-playlist-item-artist">{{ data.meta.artist }}</span><# } #>
[2832] Fix | Delete
</div>
[2833] Fix | Delete
</script>
[2834] Fix | Delete
<script type="text/html" id="tmpl-wp-playlist-item">
[2835] Fix | Delete
<div class="wp-playlist-item">
[2836] Fix | Delete
<a class="wp-playlist-caption" href="{{ data.src }}">
[2837] Fix | Delete
{{ data.index ? ( data.index + '. ' ) : '' }}
[2838] Fix | Delete
<# if ( data.caption ) { #>
[2839] Fix | Delete
{{ data.caption }}
[2840] Fix | Delete
<# } else { #>
[2841] Fix | Delete
<# if ( data.artists && data.meta.artist ) { #>
[2842] Fix | Delete
<span class="wp-playlist-item-title">
[2843] Fix | Delete
<?php
[2844] Fix | Delete
/* translators: %s: Playlist item title. */
[2845] Fix | Delete
printf( _x( '&#8220;%s&#8221;', 'playlist item title' ), '{{{ data.title }}}' );
[2846] Fix | Delete
?>
[2847] Fix | Delete
</span>
[2848] Fix | Delete
<span class="wp-playlist-item-artist"> &mdash; {{ data.meta.artist }}</span>
[2849] Fix | Delete
<# } else { #>
[2850] Fix | Delete
<span class="wp-playlist-item-title">{{{ data.title }}}</span>
[2851] Fix | Delete
<# } #>
[2852] Fix | Delete
<# } #>
[2853] Fix | Delete
</a>
[2854] Fix | Delete
<# if ( data.meta.length_formatted ) { #>
[2855] Fix | Delete
<div class="wp-playlist-item-length">{{ data.meta.length_formatted }}</div>
[2856] Fix | Delete
<# } #>
[2857] Fix | Delete
</div>
[2858] Fix | Delete
</script>
[2859] Fix | Delete
<?php
[2860] Fix | Delete
}
[2861] Fix | Delete
[2862] Fix | Delete
/**
[2863] Fix | Delete
* Outputs and enqueues default scripts and styles for playlists.
[2864] Fix | Delete
*
[2865] Fix | Delete
* @since 3.9.0
[2866] Fix | Delete
*
[2867] Fix | Delete
* @param string $type Type of playlist. Accepts 'audio' or 'video'.
[2868] Fix | Delete
*/
[2869] Fix | Delete
function wp_playlist_scripts( $type ) {
[2870] Fix | Delete
wp_enqueue_style( 'wp-mediaelement' );
[2871] Fix | Delete
wp_enqueue_script( 'wp-playlist' );
[2872] Fix | Delete
?>
[2873] Fix | Delete
<!--[if lt IE 9]><script>document.createElement('<?php echo esc_js( $type ); ?>');</script><![endif]-->
[2874] Fix | Delete
<?php
[2875] Fix | Delete
add_action( 'wp_footer', 'wp_underscore_playlist_templates', 0 );
[2876] Fix | Delete
add_action( 'admin_footer', 'wp_underscore_playlist_templates', 0 );
[2877] Fix | Delete
}
[2878] Fix | Delete
[2879] Fix | Delete
/**
[2880] Fix | Delete
* Builds the Playlist shortcode output.
[2881] Fix | Delete
*
[2882] Fix | Delete
* This implements the functionality of the playlist shortcode for displaying
[2883] Fix | Delete
* a collection of WordPress audio or video files in a post.
[2884] Fix | Delete
*
[2885] Fix | Delete
* @since 3.9.0
[2886] Fix | Delete
*
[2887] Fix | Delete
* @global int $content_width
[2888] Fix | Delete
*
[2889] Fix | Delete
* @param array $attr {
[2890] Fix | Delete
* Array of default playlist attributes.
[2891] Fix | Delete
*
[2892] Fix | Delete
* @type string $type Type of playlist to display. Accepts 'audio' or 'video'. Default 'audio'.
[2893] Fix | Delete
* @type string $order Designates ascending or descending order of items in the playlist.
[2894] Fix | Delete
* Accepts 'ASC', 'DESC'. Default 'ASC'.
[2895] Fix | Delete
* @type string $orderby Any column, or columns, to sort the playlist. If $ids are
[2896] Fix | Delete
* passed, this defaults to the order of the $ids array ('post__in').
[2897] Fix | Delete
* Otherwise default is 'menu_order ID'.
[2898] Fix | Delete
* @type int $id If an explicit $ids array is not present, this parameter
[2899] Fix | Delete
* will determine which attachments are used for the playlist.
[2900] Fix | Delete
* Default is the current post ID.
[2901] Fix | Delete
* @type array $ids Create a playlist out of these explicit attachment IDs. If empty,
[2902] Fix | Delete
* a playlist will be created from all $type attachments of $id.
[2903] Fix | Delete
* Default empty.
[2904] Fix | Delete
* @type array $exclude List of specific attachment IDs to exclude from the playlist. Default empty.
[2905] Fix | Delete
* @type string $style Playlist style to use. Accepts 'light' or 'dark'. Default 'light'.
[2906] Fix | Delete
* @type bool $tracklist Whether to show or hide the playlist. Default true.
[2907] Fix | Delete
* @type bool $tracknumbers Whether to show or hide the numbers next to entries in the playlist. Default true.
[2908] Fix | Delete
* @type bool $images Show or hide the video or audio thumbnail (Featured Image/post
[2909] Fix | Delete
* thumbnail). Default true.
[2910] Fix | Delete
* @type bool $artists Whether to show or hide artist name in the playlist. Default true.
[2911] Fix | Delete
* }
[2912] Fix | Delete
*
[2913] Fix | Delete
* @return string Playlist output. Empty string if the passed type is unsupported.
[2914] Fix | Delete
*/
[2915] Fix | Delete
function wp_playlist_shortcode( $attr ) {
[2916] Fix | Delete
global $content_width;
[2917] Fix | Delete
$post = get_post();
[2918] Fix | Delete
[2919] Fix | Delete
static $instance = 0;
[2920] Fix | Delete
++$instance;
[2921] Fix | Delete
[2922] Fix | Delete
if ( ! empty( $attr['ids'] ) ) {
[2923] Fix | Delete
// 'ids' is explicitly ordered, unless you specify otherwise.
[2924] Fix | Delete
if ( empty( $attr['orderby'] ) ) {
[2925] Fix | Delete
$attr['orderby'] = 'post__in';
[2926] Fix | Delete
}
[2927] Fix | Delete
$attr['include'] = $attr['ids'];
[2928] Fix | Delete
}
[2929] Fix | Delete
[2930] Fix | Delete
/**
[2931] Fix | Delete
* Filters the playlist output.
[2932] Fix | Delete
*
[2933] Fix | Delete
* Returning a non-empty value from the filter will short-circuit generation
[2934] Fix | Delete
* of the default playlist output, returning the passed value instead.
[2935] Fix | Delete
*
[2936] Fix | Delete
* @since 3.9.0
[2937] Fix | Delete
* @since 4.2.0 The `$instance` parameter was added.
[2938] Fix | Delete
*
[2939] Fix | Delete
* @param string $output Playlist output. Default empty.
[2940] Fix | Delete
* @param array $attr An array of shortcode attributes.
[2941] Fix | Delete
* @param int $instance Unique numeric ID of this playlist shortcode instance.
[2942] Fix | Delete
*/
[2943] Fix | Delete
$output = apply_filters( 'post_playlist', '', $attr, $instance );
[2944] Fix | Delete
[2945] Fix | Delete
if ( ! empty( $output ) ) {
[2946] Fix | Delete
return $output;
[2947] Fix | Delete
}
[2948] Fix | Delete
[2949] Fix | Delete
$atts = shortcode_atts(
[2950] Fix | Delete
array(
[2951] Fix | Delete
'type' => 'audio',
[2952] Fix | Delete
'order' => 'ASC',
[2953] Fix | Delete
'orderby' => 'menu_order ID',
[2954] Fix | Delete
'id' => $post ? $post->ID : 0,
[2955] Fix | Delete
'include' => '',
[2956] Fix | Delete
'exclude' => '',
[2957] Fix | Delete
'style' => 'light',
[2958] Fix | Delete
'tracklist' => true,
[2959] Fix | Delete
'tracknumbers' => true,
[2960] Fix | Delete
'images' => true,
[2961] Fix | Delete
'artists' => true,
[2962] Fix | Delete
),
[2963] Fix | Delete
$attr,
[2964] Fix | Delete
'playlist'
[2965] Fix | Delete
);
[2966] Fix | Delete
[2967] Fix | Delete
$id = (int) $atts['id'];
[2968] Fix | Delete
[2969] Fix | Delete
if ( 'audio' !== $atts['type'] ) {
[2970] Fix | Delete
$atts['type'] = 'video';
[2971] Fix | Delete
}
[2972] Fix | Delete
[2973] Fix | Delete
$args = array(
[2974] Fix | Delete
'post_status' => 'inherit',
[2975] Fix | Delete
'post_type' => 'attachment',
[2976] Fix | Delete
'post_mime_type' => $atts['type'],
[2977] Fix | Delete
'order' => $atts['order'],
[2978] Fix | Delete
'orderby' => $atts['orderby'],
[2979] Fix | Delete
);
[2980] Fix | Delete
[2981] Fix | Delete
if ( ! empty( $atts['include'] ) ) {
[2982] Fix | Delete
$args['include'] = $atts['include'];
[2983] Fix | Delete
$_attachments = get_posts( $args );
[2984] Fix | Delete
[2985] Fix | Delete
$attachments = array();
[2986] Fix | Delete
foreach ( $_attachments as $key => $val ) {
[2987] Fix | Delete
$attachments[ $val->ID ] = $_attachments[ $key ];
[2988] Fix | Delete
}
[2989] Fix | Delete
} elseif ( ! empty( $atts['exclude'] ) ) {
[2990] Fix | Delete
$args['post_parent'] = $id;
[2991] Fix | Delete
$args['exclude'] = $atts['exclude'];
[2992] Fix | Delete
$attachments = get_children( $args );
[2993] Fix | Delete
} else {
[2994] Fix | Delete
$args['post_parent'] = $id;
[2995] Fix | Delete
$attachments = get_children( $args );
[2996] Fix | Delete
}
[2997] Fix | Delete
[2998] Fix | Delete
if ( ! empty( $args['post_parent'] ) ) {
[2999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function