PATH:
home
/
fengshp
/
www
/
wp-content
/
plugins
/
themify-builder-pro
/
includes
/
dynamic-query
<?php /** * Builder Plugin Compatibility Code * * @package Themify_Builder Pro */ /** * @link https://themify.me/ptb-addons/relation */ class Tbp_Dynamic_Query_PtbRelation { static function get_id():string { return 'ptbRelation'; } static function get_label():string { return __( 'PTB Relations', 'tbp' ); } static function get_options():array { return array( array( 'id' => 'ptbRelation_field', 'type' => 'select', 'label' => __( 'PTB Relations Field', 'tbp' ), 'dataset' => 'ptb_fields', 'dataset_args' => [ 'type' => [ 'relation' ] ] ), ); } static function pre_get_posts( &$query, ?array $settings = [] ):bool { if ( empty( $settings['ptbRelation_field'] ) ) { return false; } list( $post_type, $field_name ) = explode( ':', $settings['ptbRelation_field'] ); $cf_value = get_post_meta( get_the_ID(), "ptb_{$field_name}", true ); $relType = ! empty( $cf_value['relType'] ) ? (int) $cf_value['relType'] : 1; $ids = ! empty( $cf_value['ids'] ) ? $cf_value['ids'] : $cf_value; $ids = array_filter( is_array( $ids ) ? $ids : explode( ', ', $ids ) ); if ( empty( $ids ) ) { return false; } $ptb = PTB::get_option()->get_cpt_cmb_options( $post_type ); $def = isset( $ptb[ $field_name ] ) ? $ptb[ $field_name ] : false; if ( $def === false ) { return false; } $query->set( 'post_type', $def['post_type'] ); if ( $relType === 1 ) { $query->set( 'post__in', $ids ); } else { $tax_query = array( 'relation' => 'AND', ); $terms = get_terms( array( 'include' => $ids ) ); foreach ( $terms as $term ) { if ( isset( $tax_query[ $term->taxonomy ] ) ) { $tax_query[ $term->taxonomy ]['terms'][] = $term->term_id; } else { $tax_query[ $term->taxonomy ] = array( 'taxonomy' => $term->taxonomy, 'field' => 'term_id', 'terms' => array( $term->term_id ), ); } } $query->set( 'tax_query', $tax_query ); } return true; } }
[+]
..
[-] acf.php
[edit]
[-] tep.php
[edit]
[-] ptbSearch.php
[edit]
[-] wishlisted.php
[edit]
[-] childs.php
[edit]
[-] ptbSubmission.php
[edit]
[-] ptbRelation.php
[edit]
[-] currentuser.php
[edit]
[-] sameauthor.php
[edit]
[-] on.php
[edit]