name = 'relationship'; $this->label = __( 'Relationship', 'cfs' ); } function html( $field ) { global $wpdb; $selected_posts = array(); $available_posts = array(); $post_types = array(); if ( ! empty( $field->options['post_types'] ) ) { foreach ( $field->options['post_types'] as $type ) { $post_types[] = $type; } } else { $post_types = get_post_types( array( 'exclude_from_search' => true ) ); } $args = array( 'post_type' => $post_types, 'post_status' => array( 'publish', 'private' ), 'posts_per_page' => -1, 'fields' => 'ids', 'orderby' => 'title', 'order' => 'ASC' ); $args = apply_filters( 'cfs_field_relationship_query_args', $args, array( 'field' => $field ) ); $query = new WP_Query( $args ); foreach ( $query->posts as $post_id ) { $post = get_post( $post_id ); $post_title = ( 'private' == $post->post_status ) ? '(Private) ' . $post->post_title : $post->post_title; $available_posts[] = (object) array( 'ID' => $post->ID, 'post_type' => $post->post_type, 'post_status' => $post->post_status, 'post_title' => $post_title, ); } if ( ! empty( $field->value ) ) { $results = $wpdb->get_results( "SELECT ID, post_status, post_title FROM $wpdb->posts WHERE ID IN ($field->value) ORDER BY FIELD(ID,$field->value)" ); foreach ( $results as $result ) { $result->post_title = ( 'private' == $result->post_status ) ? '(Private) ' . $result->post_title : $result->post_title; $selected_posts[ $result->ID ] = $result; } } ?>
ID ] ) ) ? ' class="used"' : ''; ?>
title="post_type; ?>">post_title, $post->ID, $field ); ?>
post_title, $post->ID, $field ); ?>
false ); $choices = apply_filters( 'cfs_field_relationship_post_types', get_post_types( $args ) ); ?>

create_field( array( 'type' => 'select', 'input_name' => "cfs[fields][$key][options][post_types]", 'options' => array( 'multiple' => '1', 'choices' => $choices ), 'value' => $this->get_option( $field, 'post_types' ), )); ?>