plugin install

This commit is contained in:
Tony Volpe
2024-06-18 17:29:05 -04:00
parent e1aaedd1ae
commit 41f50eacc4
5880 changed files with 1057631 additions and 39681 deletions

View File

@@ -29,12 +29,33 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
'return_format' => 'object',
'bidirectional_target' => array(),
);
add_filter( 'acf/conditional_logic/choices', array( $this, 'render_field_relation_conditional_choices' ), 10, 3 );
// extra
add_action( 'wp_ajax_acf/fields/relationship/query', array( $this, 'ajax_query' ) );
add_action( 'wp_ajax_nopriv_acf/fields/relationship/query', array( $this, 'ajax_query' ) );
}
/**
* Filters choices in relation conditions.
*
* @since 6.3
*
* @param array $choices The selected choice.
* @param array $conditional_field The conditional field settings object.
* @param string $rule_value The rule value.
* @return array
*/
public function render_field_relation_conditional_choices( $choices, $conditional_field, $rule_value ) {
if ( ! is_array( $conditional_field ) || $conditional_field['type'] !== 'relationship' ) {
return $choices;
}
if ( ! empty( $rule_value ) ) {
$post_title = get_the_title( $rule_value );
$choices = array( $rule_value => $post_title );
}
return $choices;
}
/**
* description
@@ -46,7 +67,6 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function input_admin_enqueue_scripts() {
// localize
@@ -71,7 +91,6 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function ajax_query() {
// validate
@@ -97,7 +116,6 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
* @param $options (array)
* @return (array)
*/
function get_ajax_query( $options = array() ) {
// defaults
@@ -109,6 +127,7 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
'field_key' => '',
'paged' => 1,
'post_type' => '',
'include' => '',
'taxonomy' => '',
)
);
@@ -130,8 +149,7 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
$args['paged'] = intval( $options['paged'] );
// search
if ( $options['s'] !== '' ) {
if ( $options['s'] !== '' && empty( $options['include'] ) ) {
// strip slashes (search may be integer)
$s = wp_unslash( strval( $options['s'] ) );
@@ -191,6 +209,11 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
}
}
if ( ! empty( $options['include'] ) ) {
// If we have an include, we need to return only the selected posts.
$args['post__in'] = array( $options['include'] );
}
// filters
$args = apply_filters( 'acf/fields/relationship/query', $args, $field, $options['post_id'] );
$args = apply_filters( 'acf/fields/relationship/query/name=' . $field['name'], $args, $field, $options['post_id'] );
@@ -262,7 +285,6 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
* @param $text (string)
* @return (array)
*/
function get_post_result( $id, $text ) {
// vars
@@ -288,7 +310,6 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
* @param $post_id (int) the post_id to which this value is saved to
* @return (string)
*/
function get_post_title( $post, $field, $post_id = 0, $is_search = 0 ) {
// get post_id
@@ -334,7 +355,6 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
* @since 3.6
* @date 23/01/13
*/
function render_field( $field ) {
// vars
@@ -681,7 +701,6 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
*
* @return $value (mixed) the modified value
*/
function format_value( $value, $post_id, $field ) {
// bail early if no value
@@ -722,7 +741,6 @@ if ( ! class_exists( 'acf_field_relationship' ) ) :
* @param $post_id (int)
* @return $post_id (int)
*/
function validate_value( $valid, $value, $field, $input ) {
// default