: 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_PTBRelations extends Tbp_Dynamic_Item {
function is_available() {
return function_exists( 'run_ptb' );
function get_category() {
return array( 'wp_editor' );
return __( 'PTB Custom Fields (Relations)', 'tbp' );
function get_value( $args = array() ) {
$args = wp_parse_args( $args, array(
if ( empty( $args['field'] ) ) {
list( $post_type, $field_name ) = explode( ':', $args['field'] );
$ptb = PTB::get_option()->get_options();
if ( ! isset( $ptb['cpt'][ $post_type ]['meta_boxes'][ $field_name ] ) ) {
$ptb_options = PTB::get_option();
$def = $ptb['cpt'][ $post_type ]['meta_boxes'][ $field_name ];
$rel_options = PTB_Relation::get_option();
$template = $rel_options->get_relation_template( $def['post_type'], get_post_type() );
$themplate_layout = $ptb_options->get_post_type_template( $template['id'] );
if ( ! isset( $themplate_layout['relation']['layout'] ) ) {
$is_shortcode = PTB_Public::$shortcode;
PTB_Public::$shortcode = true;
$ver = PTB::get_plugin_version( WP_PLUGIN_DIR . '/themify-ptb-relation/themify-ptb-relation.php' );
$themplate = new PTB_Form_PTT_Them( 'ptb', $ver );
$cf_value = get_post_meta( get_the_ID(), "ptb_{$field_name}", true );
$relType = ! empty( $cf_value['relType'] ) ? (int) $cf_value['relType'] : 1;
$ids = array_filter( explode( ', ', $cf_value['ids'] ) );
'post_type' => $def['post_type'],
'post_status' => 'publish',
'order' => $args['order'],
'orderby' => $args['orderby'],
$query_args['post__in'] = $ids;
$query_args['posts_per_page'] = empty( $args['limit'] ) ? count( $ids ) : $args['limit'];
$terms = get_terms( array(
foreach ( $terms as $term ) {
$tmp[ $term->taxonomy ][] = $term->term_id;
foreach ( $tmp as $k => $v ) {
if ( ! empty( $value ) ) {
$value['relation'] = 'AND';
$query_args['tax_query'] = $value;
if ( empty( $args['limit'] ) ) {
$query_args['nopaging'] = 1;
$query_args['posts_per_page'] = $args['limit'];
$rel_posts = $query->query( $query_args );
$item_tag = $args['show'] === 'slider' ? 'li' : 'div';
foreach ( $rel_posts as $p ) {
$cmb_options = $post_support = $post_meta = $post_taxonomies = array();
$ptb_options->get_post_type_data( $def['post_type'], $cmb_options, $post_support, $post_taxonomies );
$post_meta['post_url'] = get_permalink();
$post_meta['taxonomies'] = ! empty( $post_taxonomies ) ? wp_get_post_terms( get_the_ID(), array_values($post_taxonomies ) ) : array();
$post_meta = array_merge( $post_meta, get_post_custom(), get_post( '', ARRAY_A ) );
$content .= '<' . $item_tag . ' class="ptb_relation_item">' . $themplate->display_public_themplate( $themplate_layout['relation'], $post_support, $cmb_options, $post_meta, $rel_post_type, false ) . '</' . $item_tag . '>';
PTB_Public::$shortcode = $is_shortcode;
if ( $args['show'] === 'slider' ) {
'minSlides' => $args['minSlides'],
'autoHover' => $args['autoHover'],
'pause' => $args['pause'],
'pager' => $args['pager'],
'controls' => $args['controls'],
if ( ! wp_script_is( 'ptb-relation' ) ) {
wp_enqueue_style( 'ptb-bxslider' );
wp_enqueue_script( 'ptb-relation' );
$content = '<ul data-slider="' . esc_attr( json_encode( $slider_args ) ) . '" class="ptb_relation_post_slider">' . $content . '</ul>';
$wrap_class = 'ptb_loops_shortcode ptb_relation_posts tf_clearfix';
if ( $args['show'] === 'slider' ) {
$wrap_class .= ' ptb_relation_slider';
$wrap_class .= ' ptb_relation_grid';
$wrap_class .= ' ptb_relation_columns_' . $args['columns'];
if ( $args['masonry'] ) {
wp_enqueue_script( 'ptb-relation' );
$wrap_class .= ' ptb_relation_masonry';
if ( ! empty( $content ) ) {
'<div class="' . $wrap_class . '">'
/* collect "progress_bar" 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'] === 'relation' ) {
$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' ),
'label' => __( 'Show', 'tbp' ),
'grid' => __( 'Grid', 'tbp' ),
'slider' => __( 'Slider', 'tbp' ),
'grid' => array( 'show' => array( 'columns' ), 'hide' => array( 'minSlides', 'autoHover', 'pause', 'pager', 'controls' ) ),
'slider' => array( 'hide' => array( 'columns' ), 'show' => array( 'minSlides', 'autoHover', 'pause', 'pager', 'controls' ) ),
'label' => __( 'Grid Columns', 'tbp' ),
'options' => array( 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9 ),
'label' => __( 'Masonry', 'tbp' ),
'options' => array( 0 => __( 'No', 'tbp' ), 1 => __( 'Yes', 'tbp' ) ),
'label' => __( 'Visible Slides', 'tbp' ),
'options' => array( 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7 ),
'label' => __( 'Pause On Hover', 'tbp' ),
'options' => array( 1 => __( 'Yes', 'tbp' ), 0 => __( 'No', 'tbp' ) ),
'label' => __( 'Auto Scroll', 'tbp' ),
'options' => array( 1 => __( '1 Second', 'tbp' ), 2 => __( '2 Seconds', 'tbp' ), 3 => __( '3 Seconds', 'tbp' ), 4 => __( '4 Seconds', 'tbp' ), 5 => __( '5 Seconds', 'tbp' ), 6 => __( '6 Seconds', 'tbp' ), 7 => __( '7 Seconds', 'tbp' ), 8 => __( '8 Seconds', 'tbp' ), 9 => __( '9 Seconds', 'tbp' ), ),
'label' => __( 'Show Slider Pagination', 'tbp' ),
'options' => array( 1 => __( 'Yes', 'tbp' ), 0 => __( 'No', 'tbp' ) ),
'label' => __( 'Show Slider arrow buttons', 'tbp' ),
'options' => array( 1 => __( 'Yes', 'tbp' ), 0 => __( 'No', 'tbp' ) ),
'label' => __( 'Limit', 'tbp' ),
'help' => __( 'Maximum number of posts to display.', 'tbp' ),
'label' => __( 'Order', 'tbp' ),
'asc' => __( 'Ascending', 'tbp' ),
'desc' => __( 'Descending', 'tbp' ),
'label' => __( 'Order By', 'tbp' ),
'date' => __( 'Date', 'tbp' ),
'id' => __( 'ID', 'tbp' ),
'author' => __( 'Author', 'tbp' ),
'title' => __( 'Title', 'tbp' ),
'name' => __( 'Name', 'tbp' ),
'modified' => __( 'Modified', 'tbp' ),
'rand' => __( 'Random', 'tbp' ),
'comment_count' => __( 'Comment Count', 'tbp' ),
'menu_order' => __( 'Menu Order', 'tbp' ),