: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @package Themify Builder Pro
* @link https://themify.me/
class Tbp_Dynamic_Item_PTBAudioPlaylist extends Tbp_Dynamic_Item {
function is_available() {
return function_exists( 'run_ptb' );
function get_category() {
return array( 'wp_editor' );
return __( 'PTB Custom Fields (Audio Playlist)', 'tbp' );
function get_value( $args = array() ) {
if ( ! empty( $args['field'] ) ) {
$field_name = explode( ':', $args['field'] );
$cf_value = get_post_meta( get_the_ID(), "ptb_{$field_name[1]}", true );
if ( isset( $cf_value['url'] ) && is_array( $cf_value['url'] ) ) {
$value = $this->make_playlist( $cf_value );
* Modified version of wp_playlist_shortcode() where it also support external audio.
function make_playlist( $value ) {
foreach ( $value['url'] as $audio ) {
$output .= $audio . "\n";
foreach ( $value['url'] as $i => $url ) {
$attachment_id = attachment_url_to_postid( $url );
$ftype = wp_check_filetype( $url, wp_get_mime_types() );
'type' => $ftype['type'],
'title' => $value['title'][ $i ],
'caption' => $value['description'][ $i ],
$track['meta'] = array();
$meta = wp_get_attachment_metadata( $attachment_id );
if ( ! empty( $meta ) ) {
$attachment_post = get_post( $attachment_id );
foreach ( wp_get_attachment_id3_keys( $attachment_post ) as $key => $label ) {
if ( ! empty( $meta[ $key ] ) ) {
$track['meta'][ $key ] = $meta[ $key ];
$thumb_id = get_post_thumbnail_id( $attachment_id );
if ( ! empty( $thumb_id ) ) {
list( $src, $width, $height ) = wp_get_attachment_image_src( $thumb_id, 'full' );
$track['image'] = compact( 'src', 'width', 'height' );
list( $src, $width, $height ) = wp_get_attachment_image_src( $thumb_id, 'thumbnail' );
$track['thumb'] = compact( 'src', 'width', 'height' );
$src = wp_mime_type_icon( $attachment->ID );
$track['image'] = compact( 'src', 'width', 'height' );
$track['thumb'] = compact( 'src', 'width', 'height' );
return Themify_Enqueue_Assets::audio_playlist( array(
/* collect "text" field types in all post types */
$ptb = PTB::$options->get_custom_post_types();
foreach ( $ptb as $post_type_key => $post_type ) {
if ( is_array( $post_type->meta_boxes ) ) {
foreach ( $post_type->meta_boxes as $key => $field ) {
if ( $field['type'] === 'audio' ) {
$label = PTB_Utils::get_label( $post_type->plural_label );
$name = PTB_Utils::get_label( $field['name'] );
$options[ "{$post_type_key}:{$key}" ] = sprintf( '%s: %s', $label, $name );
'label' => __( 'Field', 'tbp' ),