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
/home/sportsfe.../httpdocs/wp-conte.../plugins/themify-.../includes/dynamic-...
File: PTBRelations.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* @package Themify Builder Pro
[2] Fix | Delete
* @link https://themify.me/
[3] Fix | Delete
*/
[4] Fix | Delete
class Tbp_Dynamic_Item_PTBRelations extends Tbp_Dynamic_Item {
[5] Fix | Delete
[6] Fix | Delete
function is_available() {
[7] Fix | Delete
return function_exists( 'run_ptb' );
[8] Fix | Delete
}
[9] Fix | Delete
[10] Fix | Delete
function get_category() {
[11] Fix | Delete
return 'ptb';
[12] Fix | Delete
}
[13] Fix | Delete
[14] Fix | Delete
function get_type() {
[15] Fix | Delete
return array( 'wp_editor' );
[16] Fix | Delete
}
[17] Fix | Delete
[18] Fix | Delete
function get_label() {
[19] Fix | Delete
return __( 'PTB Custom Fields (Relations)', 'tbp' );
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
function get_value( $args = array() ) {
[23] Fix | Delete
$args = wp_parse_args( $args, array(
[24] Fix | Delete
'show' => 'grid',
[25] Fix | Delete
'columns' => 1,
[26] Fix | Delete
'minSlides' => 1,
[27] Fix | Delete
'autoHover' => 1,
[28] Fix | Delete
'pause' => 1,
[29] Fix | Delete
'pager' => 1,
[30] Fix | Delete
'controls' => 1,
[31] Fix | Delete
'orderby' => 'post__in',
[32] Fix | Delete
'order' => 'asc',
[33] Fix | Delete
'limit' => '',
[34] Fix | Delete
'masonry' => 0,
[35] Fix | Delete
) );
[36] Fix | Delete
[37] Fix | Delete
if ( empty( $args['field'] ) ) {
[38] Fix | Delete
return '';
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
list( $post_type, $field_name ) = explode( ':', $args['field'] );
[42] Fix | Delete
$ptb = PTB::get_option()->get_options();
[43] Fix | Delete
[44] Fix | Delete
if ( ! isset( $ptb['cpt'][ $post_type ]['meta_boxes'][ $field_name ] ) ) {
[45] Fix | Delete
return '';
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
$ptb_options = PTB::get_option();
[49] Fix | Delete
$def = $ptb['cpt'][ $post_type ]['meta_boxes'][ $field_name ];
[50] Fix | Delete
$rel_options = PTB_Relation::get_option();
[51] Fix | Delete
$template = $rel_options->get_relation_template( $def['post_type'], get_post_type() );
[52] Fix | Delete
if ( ! $template ) {
[53] Fix | Delete
return '';
[54] Fix | Delete
}
[55] Fix | Delete
$themplate_layout = $ptb_options->get_post_type_template( $template['id'] );
[56] Fix | Delete
if ( ! isset( $themplate_layout['relation']['layout'] ) ) {
[57] Fix | Delete
return;
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
$content = '';
[61] Fix | Delete
$is_shortcode = PTB_Public::$shortcode;
[62] Fix | Delete
PTB_Public::$shortcode = true;
[63] Fix | Delete
$ver = PTB::get_plugin_version( WP_PLUGIN_DIR . '/themify-ptb-relation/themify-ptb-relation.php' );
[64] Fix | Delete
$themplate = new PTB_Form_PTT_Them( 'ptb', $ver );
[65] Fix | Delete
$cf_value = get_post_meta( get_the_ID(), "ptb_{$field_name}", true );
[66] Fix | Delete
$relType = ! empty( $cf_value['relType'] ) ? (int) $cf_value['relType'] : 1;
[67] Fix | Delete
$ids = array_filter( explode( ', ', $cf_value['ids'] ) );
[68] Fix | Delete
if ( empty( $ids ) ) {
[69] Fix | Delete
return;
[70] Fix | Delete
}
[71] Fix | Delete
$query_args = array(
[72] Fix | Delete
'post_type' => $def['post_type'],
[73] Fix | Delete
'post_status' => 'publish',
[74] Fix | Delete
'order' => $args['order'],
[75] Fix | Delete
'orderby' => $args['orderby'],
[76] Fix | Delete
'no_found_rows' => 1,
[77] Fix | Delete
);
[78] Fix | Delete
if ( $relType === 1 ) {
[79] Fix | Delete
$query_args['post__in'] = $ids;
[80] Fix | Delete
$query_args['posts_per_page'] = empty( $args['limit'] ) ? count( $ids ) : $args['limit'];
[81] Fix | Delete
} else {
[82] Fix | Delete
$tmp = array();
[83] Fix | Delete
$terms = get_terms( array(
[84] Fix | Delete
'include' => $ids
[85] Fix | Delete
) );
[86] Fix | Delete
foreach ( $terms as $term ) {
[87] Fix | Delete
$tmp[ $term->taxonomy ][] = $term->term_id;
[88] Fix | Delete
}
[89] Fix | Delete
$value = array();
[90] Fix | Delete
$temp = array();
[91] Fix | Delete
foreach ( $tmp as $k => $v ) {
[92] Fix | Delete
$value[] = array(
[93] Fix | Delete
'taxonomy' => $k,
[94] Fix | Delete
'field' => 'term_id',
[95] Fix | Delete
'terms' => $v
[96] Fix | Delete
);
[97] Fix | Delete
}
[98] Fix | Delete
if ( ! empty( $value ) ) {
[99] Fix | Delete
$value['relation'] = 'AND';
[100] Fix | Delete
$query_args['tax_query'] = $value;
[101] Fix | Delete
}
[102] Fix | Delete
if ( empty( $args['limit'] ) ) {
[103] Fix | Delete
$query_args['nopaging'] = 1;
[104] Fix | Delete
} else {
[105] Fix | Delete
$query_args['posts_per_page'] = $args['limit'];
[106] Fix | Delete
}
[107] Fix | Delete
}
[108] Fix | Delete
global $post;
[109] Fix | Delete
$old_post = clone $post;
[110] Fix | Delete
$query = new WP_Query;
[111] Fix | Delete
$rel_posts = $query->query( $query_args );
[112] Fix | Delete
$item_tag = $args['show'] === 'slider' ? 'li' : 'div';
[113] Fix | Delete
foreach ( $rel_posts as $p ) {
[114] Fix | Delete
$post = $p;
[115] Fix | Delete
setup_postdata( $post );
[116] Fix | Delete
[117] Fix | Delete
$cmb_options = $post_support = $post_meta = $post_taxonomies = array();
[118] Fix | Delete
$ptb_options->get_post_type_data( $def['post_type'], $cmb_options, $post_support, $post_taxonomies );
[119] Fix | Delete
$post_meta['post_url'] = get_permalink();
[120] Fix | Delete
$post_meta['taxonomies'] = ! empty( $post_taxonomies ) ? wp_get_post_terms( get_the_ID(), array_values($post_taxonomies ) ) : array();
[121] Fix | Delete
$post_meta = array_merge( $post_meta, get_post_custom(), get_post( '', ARRAY_A ) );
[122] Fix | Delete
$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 . '>';
[123] Fix | Delete
}
[124] Fix | Delete
PTB_Public::$shortcode = $is_shortcode;
[125] Fix | Delete
$post = $old_post;
[126] Fix | Delete
setup_postdata( $post );
[127] Fix | Delete
[128] Fix | Delete
if ( $args['show'] === 'slider' ) {
[129] Fix | Delete
$slider_args = array(
[130] Fix | Delete
'minSlides' => $args['minSlides'],
[131] Fix | Delete
'autoHover' => $args['autoHover'],
[132] Fix | Delete
'pause' => $args['pause'],
[133] Fix | Delete
'pager' => $args['pager'],
[134] Fix | Delete
'controls' => $args['controls'],
[135] Fix | Delete
);
[136] Fix | Delete
if ( ! wp_script_is( 'ptb-relation' ) ) {
[137] Fix | Delete
wp_enqueue_style( 'ptb-bxslider' );
[138] Fix | Delete
wp_enqueue_script( 'ptb-relation' );
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
$content = '<ul data-slider="' . esc_attr( json_encode( $slider_args ) ) . '" class="ptb_relation_post_slider">' . $content . '</ul>';
[142] Fix | Delete
}
[143] Fix | Delete
[144] Fix | Delete
$wrap_class = 'ptb_loops_shortcode ptb_relation_posts tf_clearfix';
[145] Fix | Delete
if ( $args['show'] === 'slider' ) {
[146] Fix | Delete
$wrap_class .= ' ptb_relation_slider';
[147] Fix | Delete
} else {
[148] Fix | Delete
$wrap_class .= ' ptb_relation_grid';
[149] Fix | Delete
$wrap_class .= ' ptb_relation_columns_' . $args['columns'];
[150] Fix | Delete
if ( $args['masonry'] ) {
[151] Fix | Delete
wp_enqueue_script( 'ptb-relation' );
[152] Fix | Delete
$wrap_class .= ' ptb_relation_masonry';
[153] Fix | Delete
}
[154] Fix | Delete
}
[155] Fix | Delete
[156] Fix | Delete
if ( ! empty( $content ) ) {
[157] Fix | Delete
$content =
[158] Fix | Delete
'<div class="' . $wrap_class . '">'
[159] Fix | Delete
. $content
[160] Fix | Delete
. '</div>';
[161] Fix | Delete
}
[162] Fix | Delete
[163] Fix | Delete
return $content;
[164] Fix | Delete
}
[165] Fix | Delete
[166] Fix | Delete
function get_options() {
[167] Fix | Delete
$options = array();
[168] Fix | Delete
[169] Fix | Delete
/* collect "progress_bar" field types in all post types */
[170] Fix | Delete
$ptb = PTB::$options->get_custom_post_types();
[171] Fix | Delete
foreach ( $ptb as $post_type_key => $post_type ) {
[172] Fix | Delete
if ( is_array( $post_type->meta_boxes ) ) {
[173] Fix | Delete
foreach ( $post_type->meta_boxes as $key => $field ) {
[174] Fix | Delete
if ( $field['type'] === 'relation' ) {
[175] Fix | Delete
$label = PTB_Utils::get_label( $post_type->plural_label );
[176] Fix | Delete
$name = PTB_Utils::get_label( $field['name'] );
[177] Fix | Delete
$options[ "{$post_type_key}:{$key}" ] = sprintf( '%s: %s', $label, $name );
[178] Fix | Delete
}
[179] Fix | Delete
}
[180] Fix | Delete
}
[181] Fix | Delete
}
[182] Fix | Delete
[183] Fix | Delete
return array(
[184] Fix | Delete
array(
[185] Fix | Delete
'label' => __( 'Field', 'tbp' ),
[186] Fix | Delete
'id' => 'field',
[187] Fix | Delete
'type' => 'select',
[188] Fix | Delete
'options' => $options,
[189] Fix | Delete
),
[190] Fix | Delete
array(
[191] Fix | Delete
'label' => __( 'Show', 'tbp' ),
[192] Fix | Delete
'id' => 'show',
[193] Fix | Delete
'type' => 'select',
[194] Fix | Delete
'options' => array(
[195] Fix | Delete
'grid' => __( 'Grid', 'tbp' ),
[196] Fix | Delete
'slider' => __( 'Slider', 'tbp' ),
[197] Fix | Delete
),
[198] Fix | Delete
'binding' => array(
[199] Fix | Delete
'grid' => array( 'show' => array( 'columns' ), 'hide' => array( 'minSlides', 'autoHover', 'pause', 'pager', 'controls' ) ),
[200] Fix | Delete
'slider' => array( 'hide' => array( 'columns' ), 'show' => array( 'minSlides', 'autoHover', 'pause', 'pager', 'controls' ) ),
[201] Fix | Delete
),
[202] Fix | Delete
),
[203] Fix | Delete
array(
[204] Fix | Delete
'label' => __( 'Grid Columns', 'tbp' ),
[205] Fix | Delete
'id' => 'columns',
[206] Fix | Delete
'type' => 'select',
[207] Fix | Delete
'options' => array( 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9 ),
[208] Fix | Delete
),
[209] Fix | Delete
array(
[210] Fix | Delete
'label' => __( 'Masonry', 'tbp' ),
[211] Fix | Delete
'id' => 'masonry',
[212] Fix | Delete
'type' => 'select',
[213] Fix | Delete
'options' => array( 0 => __( 'No', 'tbp' ), 1 => __( 'Yes', 'tbp' ) ),
[214] Fix | Delete
),
[215] Fix | Delete
array(
[216] Fix | Delete
'label' => __( 'Visible Slides', 'tbp' ),
[217] Fix | Delete
'id' => 'minSlides',
[218] Fix | Delete
'type' => 'select',
[219] Fix | Delete
'options' => array( 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7 ),
[220] Fix | Delete
),
[221] Fix | Delete
array(
[222] Fix | Delete
'label' => __( 'Pause On Hover', 'tbp' ),
[223] Fix | Delete
'id' => 'autoHover',
[224] Fix | Delete
'type' => 'select',
[225] Fix | Delete
'options' => array( 1 => __( 'Yes', 'tbp' ), 0 => __( 'No', 'tbp' ) ),
[226] Fix | Delete
),
[227] Fix | Delete
array(
[228] Fix | Delete
'label' => __( 'Auto Scroll', 'tbp' ),
[229] Fix | Delete
'id' => 'pause',
[230] Fix | Delete
'type' => 'select',
[231] Fix | Delete
'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' ), ),
[232] Fix | Delete
),
[233] Fix | Delete
array(
[234] Fix | Delete
'label' => __( 'Show Slider Pagination', 'tbp' ),
[235] Fix | Delete
'id' => 'pager',
[236] Fix | Delete
'type' => 'select',
[237] Fix | Delete
'options' => array( 1 => __( 'Yes', 'tbp' ), 0 => __( 'No', 'tbp' ) ),
[238] Fix | Delete
),
[239] Fix | Delete
array(
[240] Fix | Delete
'label' => __( 'Show Slider arrow buttons', 'tbp' ),
[241] Fix | Delete
'id' => 'controls',
[242] Fix | Delete
'type' => 'select',
[243] Fix | Delete
'options' => array( 1 => __( 'Yes', 'tbp' ), 0 => __( 'No', 'tbp' ) ),
[244] Fix | Delete
),
[245] Fix | Delete
array(
[246] Fix | Delete
'label' => __( 'Limit', 'tbp' ),
[247] Fix | Delete
'id' => 'limit',
[248] Fix | Delete
'type' => 'text',
[249] Fix | Delete
'help' => __( 'Maximum number of posts to display.', 'tbp' ),
[250] Fix | Delete
),
[251] Fix | Delete
array(
[252] Fix | Delete
'label' => __( 'Order', 'tbp' ),
[253] Fix | Delete
'id' => 'order',
[254] Fix | Delete
'type' => 'select',
[255] Fix | Delete
'options' => array(
[256] Fix | Delete
'asc' => __( 'Ascending', 'tbp' ),
[257] Fix | Delete
'desc' => __( 'Descending', 'tbp' ),
[258] Fix | Delete
),
[259] Fix | Delete
),
[260] Fix | Delete
array(
[261] Fix | Delete
'label' => __( 'Order By', 'tbp' ),
[262] Fix | Delete
'id' => 'orderby',
[263] Fix | Delete
'type' => 'select',
[264] Fix | Delete
'options' => array(
[265] Fix | Delete
'date' => __( 'Date', 'tbp' ),
[266] Fix | Delete
'id' => __( 'ID', 'tbp' ),
[267] Fix | Delete
'author' => __( 'Author', 'tbp' ),
[268] Fix | Delete
'title' => __( 'Title', 'tbp' ),
[269] Fix | Delete
'name' => __( 'Name', 'tbp' ),
[270] Fix | Delete
'modified' => __( 'Modified', 'tbp' ),
[271] Fix | Delete
'rand' => __( 'Random', 'tbp' ),
[272] Fix | Delete
'comment_count' => __( 'Comment Count', 'tbp' ),
[273] Fix | Delete
'menu_order' => __( 'Menu Order', 'tbp' ),
[274] Fix | Delete
),
[275] Fix | Delete
),
[276] Fix | Delete
);
[277] Fix | Delete
}
[278] Fix | Delete
}
[279] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function