/core/fields/relationship.php

  1. <?php 
  2.  
  3. class acf_field_relationship extends acf_field 
  4. /** 
  5. * __construct 
  6. * 
  7. * Set name / label needed for actions / filters 
  8. * 
  9. * @since 3.6 
  10. * @date 23/01/13 
  11. */ 
  12.  
  13. function __construct() 
  14. // vars 
  15. $this->name = 'relationship'; 
  16. $this->label = __("Relationship", 'acf'); 
  17. $this->category = __("Relational", 'acf'); 
  18. $this->defaults = array( 
  19. 'post_type' => array('all'),  
  20. 'max' => '',  
  21. 'taxonomy' => array('all'),  
  22. 'filters' => array('search'),  
  23. 'result_elements' => array('post_title', 'post_type'),  
  24. 'return_format' => 'object' 
  25. ); 
  26. $this->l10n = array( 
  27. 'max' => __("Maximum values reached ( {max} values )", 'acf') 
  28. ); 
  29.  
  30.  
  31. // do not delete! 
  32. parent::__construct(); 
  33.  
  34.  
  35. // extra 
  36. add_action('wp_ajax_acf/fields/relationship/query_posts', array($this, 'query_posts')); 
  37. add_action('wp_ajax_nopriv_acf/fields/relationship/query_posts', array($this, 'query_posts')); 
  38.  
  39.  
  40. /** 
  41. * load_field() 
  42. *  
  43. * This filter is appied to the $field after it is loaded from the database 
  44. *  
  45. * @type filter 
  46. * @since 3.6 
  47. * @date 23/01/13 
  48. *  
  49. * @param $field - the field array holding all the field options 
  50. *  
  51. * @return $field - the field array holding all the field options 
  52. */ 
  53.  
  54. function load_field( $field ) 
  55. // validate post_type 
  56. if( !$field['post_type'] || !is_array($field['post_type']) || in_array('', $field['post_type']) ) 
  57. $field['post_type'] = array( 'all' ); 
  58.  
  59.  
  60. // validate taxonomy 
  61. if( !$field['taxonomy'] || !is_array($field['taxonomy']) || in_array('', $field['taxonomy']) ) 
  62. $field['taxonomy'] = array( 'all' ); 
  63.  
  64.  
  65. // validate result_elements 
  66. if( !is_array( $field['result_elements'] ) ) 
  67. $field['result_elements'] = array(); 
  68.  
  69. if( !in_array('post_title', $field['result_elements']) ) 
  70. $field['result_elements'][] = 'post_title'; 
  71.  
  72.  
  73. // filters 
  74. if( !is_array( $field['filters'] ) ) 
  75. $field['filters'] = array(); 
  76.  
  77.  
  78. // return 
  79. return $field; 
  80.  
  81.  
  82. /** 
  83. * get_result 
  84. * 
  85. * description 
  86. * 
  87. * @type function 
  88. * @date 5/02/2015 
  89. * @since 5.1.5 
  90. * 
  91. * @param $post_id (int) 
  92. * @return $post_id (int) 
  93. */ 
  94.  
  95. function get_result( $post, $field, $the_post, $options = array() ) { 
  96.  
  97. // right aligned info 
  98. $title = '<span class="relationship-item-info">'; 
  99.  
  100. if( in_array('post_type', $field['result_elements']) ) { 
  101.  
  102. $post_type_object = get_post_type_object( $post->post_type ); 
  103. $title .= $post_type_object->labels->singular_name; 
  104.  
  105.  
  106.  
  107. // WPML 
  108. if( !empty($options['lang']) ) { 
  109.  
  110. $title .= ' (' . $options['lang'] . ')'; 
  111.  
  112. } elseif( defined('ICL_LANGUAGE_CODE') ) { 
  113.  
  114. $title .= ' (' . ICL_LANGUAGE_CODE . ')'; 
  115.  
  116.  
  117. $title .= '</span>'; 
  118.  
  119.  
  120. // featured_image 
  121. if( in_array('featured_image', $field['result_elements']) ) { 
  122.  
  123. $image = ''; 
  124.  
  125. if( $post->post_type == 'attachment' ) { 
  126.  
  127. $image = wp_get_attachment_image( $post->ID, array(21, 21) ); 
  128.  
  129. } else { 
  130.  
  131. $image = get_the_post_thumbnail( $post->ID, array(21, 21) ); 
  132.  
  133.  
  134. $title .= '<div class="result-thumbnail">' . $image . '</div>'; 
  135.  
  136.  
  137.  
  138. // title 
  139. $post_title = get_the_title( $post->ID ); 
  140.  
  141.  
  142. // empty 
  143. if( $post_title === '' ) { 
  144.  
  145. $post_title = __('(no title)', 'acf'); 
  146.  
  147.  
  148.  
  149. $title .= $post_title; 
  150.  
  151.  
  152. // status 
  153. if( get_post_status( $post->ID ) != "publish" ) { 
  154.  
  155. $title .= ' (' . get_post_status( $post->ID ) . ')'; 
  156.  
  157.  
  158.  
  159. // filters 
  160. $title = apply_filters('acf/fields/relationship/result', $title, $post, $field, $the_post); 
  161. $title = apply_filters('acf/fields/relationship/result/name=' . $field['_name'] , $title, $post, $field, $the_post); 
  162. $title = apply_filters('acf/fields/relationship/result/key=' . $field['key'], $title, $post, $field, $the_post); 
  163.  
  164.  
  165. // return 
  166. return $title; 
  167.  
  168.  
  169.  
  170. /** 
  171. * query_posts 
  172. * 
  173. * @description:  
  174. * @since: 3.6 
  175. * @created: 27/01/13 
  176. */ 
  177.  
  178. function query_posts() 
  179. // vars 
  180. $r = array( 
  181. 'next_page_exists' => 1,  
  182. 'html' => '' 
  183. ); 
  184.  
  185.  
  186. // options 
  187. $options = array( 
  188. 'post_type' => 'all',  
  189. 'taxonomy' => 'all',  
  190. 'posts_per_page' => 10,  
  191. 'paged' => 1,  
  192. 'orderby' => 'title',  
  193. 'order' => 'ASC',  
  194. 'post_status' => 'any',  
  195. 'suppress_filters' => false,  
  196. 's' => '',  
  197. 'lang' => false,  
  198. 'update_post_meta_cache' => false,  
  199. 'field_key' => '',  
  200. 'nonce' => '',  
  201. 'ancestor' => false,  
  202. ); 
  203.  
  204. $options = array_merge( $options, $_POST ); 
  205.  
  206.  
  207. // validate 
  208. if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') ) 
  209. die(); 
  210.  
  211.  
  212. // WPML 
  213. if( $options['lang'] ) 
  214. global $sitepress; 
  215.  
  216. if( !empty($sitepress) ) 
  217. $sitepress->switch_lang( $options['lang'] ); 
  218.  
  219.  
  220. // convert types 
  221. $options['post_type'] = explode(', ', $options['post_type']); 
  222. $options['taxonomy'] = explode(', ', $options['taxonomy']); 
  223.  
  224.  
  225. // load all post types by default 
  226. if( in_array('all', $options['post_type']) ) 
  227. $options['post_type'] = apply_filters('acf/get_post_types', array()); 
  228.  
  229.  
  230. // attachment doesn't work if it is the only item in an array??? 
  231. if( is_array($options['post_type']) && count($options['post_type']) == 1 ) 
  232. $options['post_type'] = $options['post_type'][0]; 
  233.  
  234.  
  235. // create tax queries 
  236. if( ! in_array('all', $options['taxonomy']) ) 
  237. // vars 
  238. $taxonomies = array(); 
  239. $options['tax_query'] = array(); 
  240.  
  241. foreach( $options['taxonomy'] as $v ) 
  242.  
  243. // find term (find taxonomy!) 
  244. // $term = array( 0 => $taxonomy, 1 => $term_id ) 
  245. $term = explode(':', $v);  
  246.  
  247.  
  248. // validate 
  249. if( !is_array($term) || !isset($term[1]) ) 
  250. continue; 
  251.  
  252.  
  253. // add to tax array 
  254. $taxonomies[ $term[0] ][] = $term[1]; 
  255.  
  256.  
  257.  
  258. // now create the tax queries 
  259. foreach( $taxonomies as $k => $v ) 
  260. $options['tax_query'][] = array( 
  261. 'taxonomy' => $k,  
  262. 'field' => 'id',  
  263. 'terms' => $v,  
  264. ); 
  265.  
  266. unset( $options['taxonomy'] ); 
  267.  
  268.  
  269. // load field 
  270. $field = array(); 
  271. if( $options['ancestor'] ) 
  272. $ancestor = apply_filters('acf/load_field', array(), $options['ancestor'] ); 
  273. $field = acf_get_child_field_from_parent_field( $options['field_key'], $ancestor ); 
  274. else 
  275. $field = apply_filters('acf/load_field', array(), $options['field_key'] ); 
  276.  
  277.  
  278. // get the post from which this field is rendered on 
  279. $the_post = get_post( $options['post_id'] ); 
  280.  
  281.  
  282. // filters 
  283. $options = apply_filters('acf/fields/relationship/query', $options, $field, $the_post); 
  284. $options = apply_filters('acf/fields/relationship/query/name=' . $field['_name'], $options, $field, $the_post ); 
  285. $options = apply_filters('acf/fields/relationship/query/key=' . $field['key'], $options, $field, $the_post ); 
  286.  
  287.  
  288. // query 
  289. $wp_query = new WP_Query( $options ); 
  290.  
  291.  
  292. // global 
  293. global $post; 
  294.  
  295.  
  296. // loop 
  297. while( $wp_query->have_posts() ) { 
  298.  
  299. $wp_query->the_post(); 
  300.  
  301.  
  302. // get title 
  303. $title = $this->get_result($post, $field, $the_post, $options); 
  304.  
  305.  
  306. // update html 
  307. $r['html'] .= '<li><a href="' . get_permalink($post->ID) . '" data-post_id="' . $post->ID . '">' . $title . '<span class="acf-button-add"></span></a></li>'; 
  308.  
  309.  
  310.  
  311. // next page 
  312. if( (int)$options['paged'] >= $wp_query->max_num_pages ) { 
  313.  
  314. $r['next_page_exists'] = 0; 
  315.  
  316.  
  317.  
  318. // reset 
  319. wp_reset_postdata(); 
  320.  
  321.  
  322. // return JSON 
  323. echo json_encode( $r ); 
  324.  
  325. die(); 
  326.  
  327.  
  328.  
  329. /** 
  330. * create_field() 
  331. * 
  332. * Create the HTML interface for your field 
  333. * 
  334. * @param $field - an array holding all the field's data 
  335. * 
  336. * @type action 
  337. * @since 3.6 
  338. * @date 23/01/13 
  339. */ 
  340.  
  341. function create_field( $field ) 
  342. // global 
  343. global $post; 
  344.  
  345.  
  346. // no row limit? 
  347. if( !$field['max'] || $field['max'] < 1 ) 
  348. $field['max'] = 9999; 
  349.  
  350.  
  351. // class 
  352. $class = ''; 
  353. if( $field['filters'] ) 
  354. foreach( $field['filters'] as $filter ) 
  355. $class .= ' has-' . $filter; 
  356.  
  357. $attributes = array( 
  358. 'max' => $field['max'],  
  359. 's' => '',  
  360. 'paged' => 1,  
  361. 'post_type' => implode(', ', $field['post_type']),  
  362. 'taxonomy' => implode(', ', $field['taxonomy']),  
  363. 'field_key' => $field['key'] 
  364. ); 
  365.  
  366.  
  367. // Lang 
  368. if( defined('ICL_LANGUAGE_CODE') ) 
  369. $attributes['lang'] = ICL_LANGUAGE_CODE; 
  370.  
  371.  
  372. // parent 
  373. preg_match('/\[(field_.*?)\]/', $field['name'], $ancestor); 
  374. if( isset($ancestor[1]) && $ancestor[1] != $field['key']) 
  375. $attributes['ancestor'] = $ancestor[1]; 
  376.  
  377. ?> 
  378. <div class="acf_relationship<?php echo $class; ?>"<?php foreach( $attributes as $k => $v ): ?> data-<?php echo $k; ?>="<?php echo $v; ?>"<?php endforeach; ?>> 
  379.  
  380.  
  381. <!-- Hidden Blank default value --> 
  382. <input type="hidden" name="<?php echo $field['name']; ?>" value="" /> 
  383.  
  384.  
  385. <!-- Left List --> 
  386. <div class="relationship_left"> 
  387. <table class="widefat"> 
  388. <thead> 
  389. <?php if(in_array( 'search', $field['filters']) ): ?> 
  390. <tr> 
  391. <th> 
  392. <input class="relationship_search" placeholder="<?php _e("Search...", 'acf'); ?>" type="text" id="relationship_<?php echo $field['name']; ?>" /> 
  393. </th> 
  394. </tr> 
  395. <?php endif; ?> 
  396. <?php if(in_array( 'post_type', $field['filters']) ): ?> 
  397. <tr> 
  398. <th> 
  399. <?php  
  400.  
  401. // vars 
  402. $choices = array( 
  403. 'all' => __("Filter by post type", 'acf') 
  404. ); 
  405.  
  406.  
  407. if( in_array('all', $field['post_type']) ) 
  408. $post_types = apply_filters( 'acf/get_post_types', array() ); 
  409. $choices = array_merge( $choices, $post_types); 
  410. else 
  411. foreach( $field['post_type'] as $post_type ) 
  412. $choices[ $post_type ] = $post_type; 
  413.  
  414.  
  415. // create field 
  416. do_action('acf/create_field', array( 
  417. 'type' => 'select',  
  418. 'name' => '',  
  419. 'class' => 'select-post_type',  
  420. 'value' => '',  
  421. 'choices' => $choices,  
  422. )); 
  423.  
  424. ?> 
  425. </th> 
  426. </tr> 
  427. <?php endif; ?> 
  428. </thead> 
  429. </table> 
  430. <ul class="bl relationship_list"> 
  431. <li class="load-more"> 
  432. <div class="acf-loading"></div> 
  433. </li> 
  434. </ul> 
  435. </div> 
  436. <!-- /Left List --> 
  437.  
  438. <!-- Right List --> 
  439. <div class="relationship_right"> 
  440. <ul class="bl relationship_list"> 
  441. <?php 
  442.  
  443. if( $field['value'] ) 
  444. foreach( $field['value'] as $p ) 
  445. $title = $this->get_result($p, $field, $post); 
  446.  
  447.  
  448. echo '<li> 
  449. <a href="' . get_permalink($p->ID) . '" class="" data-post_id="' . $p->ID . '">' . $title . '<span class="acf-button-remove"></span></a> 
  450. <input type="hidden" name="' . $field['name'] . '[]" value="' . $p->ID . '" /> 
  451. </li>'; 
  452.  
  453.  
  454.  
  455. ?> 
  456. </ul> 
  457. </div> 
  458. <!-- / Right List --> 
  459.  
  460. </div> 
  461. <?php 
  462.  
  463.  
  464.  
  465. /** 
  466. * create_options() 
  467. * 
  468. * Create extra options for your field. This is rendered when editing a field. 
  469. * The value of $field['name'] can be used (like bellow) to save extra data to the $field 
  470. * 
  471. * @type action 
  472. * @since 3.6 
  473. * @date 23/01/13 
  474. * 
  475. * @param $field - an array holding all the field's data 
  476. */ 
  477.  
  478. function create_options( $field ) 
  479. // vars 
  480. $key = $field['name']; 
  481.  
  482. ?> 
  483. <tr class="field_option field_option_<?php echo $this->name; ?>"> 
  484. <td class="label"> 
  485. <label><?php _e("Return Format", 'acf'); ?></label> 
  486. <p><?php _e("Specify the returned value on front end", 'acf') ?></p> 
  487. </td> 
  488. <td> 
  489. <?php 
  490. do_action('acf/create_field', array( 
  491. 'type' => 'radio',  
  492. 'name' => 'fields['.$key.'][return_format]',  
  493. 'value' => $field['return_format'],  
  494. 'layout' => 'horizontal',  
  495. 'choices' => array( 
  496. 'object' => __("Post Objects", 'acf'),  
  497. 'id' => __("Post IDs", 'acf') 
  498. )); 
  499. ?> 
  500. </td> 
  501. </tr> 
  502. <tr class="field_option field_option_<?php echo $this->name; ?>"> 
  503. <td class="label"> 
  504. <label for=""><?php _e("Post Type", 'acf'); ?></label> 
  505. </td> 
  506. <td> 
  507. <?php  
  508.  
  509. $choices = array( 
  510. 'all' => __("All", 'acf') 
  511. ); 
  512. $choices = apply_filters('acf/get_post_types', $choices); 
  513.  
  514.  
  515. do_action('acf/create_field', array( 
  516. 'type' => 'select',  
  517. 'name' => 'fields['.$key.'][post_type]',  
  518. 'value' => $field['post_type'],  
  519. 'choices' => $choices,  
  520. 'multiple' => 1,  
  521. )); 
  522.  
  523. ?> 
  524. </td> 
  525. </tr> 
  526. <tr class="field_option field_option_<?php echo $this->name; ?>"> 
  527. <td class="label"> 
  528. <label><?php _e("Filter from Taxonomy", 'acf'); ?></label> 
  529. </td> 
  530. <td> 
  531. <?php  
  532. $choices = array( 
  533. '' => array( 
  534. 'all' => __("All", 'acf') 
  535. ); 
  536. $simple_value = false; 
  537. $choices = apply_filters('acf/get_taxonomies_for_select', $choices, $simple_value); 
  538.  
  539.  
  540. do_action('acf/create_field', array( 
  541. 'type' => 'select',  
  542. 'name' => 'fields['.$key.'][taxonomy]',  
  543. 'value' => $field['taxonomy'],  
  544. 'choices' => $choices,  
  545. 'multiple' => 1,  
  546. )); 
  547. ?> 
  548. </td> 
  549. </tr> 
  550. <tr class="field_option field_option_<?php echo $this->name; ?>"> 
  551. <td class="label"> 
  552. <label><?php _e("Filters", 'acf'); ?></label> 
  553. </td> 
  554. <td> 
  555. <?php  
  556. do_action('acf/create_field', array( 
  557. 'type' => 'checkbox',  
  558. 'name' => 'fields['.$key.'][filters]',  
  559. 'value' => $field['filters'],  
  560. 'choices' => array( 
  561. 'search' => __("Search", 'acf'),  
  562. 'post_type' => __("Post Type Select", 'acf'),  
  563. )); 
  564. ?> 
  565. </td> 
  566. </tr> 
  567. <tr class="field_option field_option_<?php echo $this->name; ?>"> 
  568. <td class="label"> 
  569. <label><?php _e("Elements", 'acf'); ?></label> 
  570. <p><?php _e("Selected elements will be displayed in each result", 'acf') ?></p> 
  571. </td> 
  572. <td> 
  573. <?php  
  574. do_action('acf/create_field', array( 
  575. 'type' => 'checkbox',  
  576. 'name' => 'fields['.$key.'][result_elements]',  
  577. 'value' => $field['result_elements'],  
  578. 'choices' => array( 
  579. 'featured_image' => __("Featured Image", 'acf'),  
  580. 'post_title' => __("Post Title", 'acf'),  
  581. 'post_type' => __("Post Type", 'acf'),  
  582. ),  
  583. 'disabled' => array( 
  584. 'post_title' 
  585. )); 
  586. ?> 
  587. </td> 
  588. </tr> 
  589. <tr class="field_option field_option_<?php echo $this->name; ?>"> 
  590. <td class="label"> 
  591. <label><?php _e("Maximum posts", 'acf'); ?></label> 
  592. </td> 
  593. <td> 
  594. <?php  
  595. do_action('acf/create_field', array( 
  596. 'type' => 'number',  
  597. 'name' => 'fields['.$key.'][max]',  
  598. 'value' => $field['max'],  
  599. )); 
  600. ?> 
  601. </td> 
  602. </tr> 
  603. <?php 
  604.  
  605.  
  606.  
  607. /** 
  608. * format_value() 
  609. * 
  610. * This filter is appied to the $value after it is loaded from the db and before it is passed to the create_field action 
  611. * 
  612. * @type filter 
  613. * @since 3.6 
  614. * @date 23/01/13 
  615. * 
  616. * @param $value - the value which was loaded from the database 
  617. * @param $post_id - the $post_id from which the value was loaded 
  618. * @param $field - the field array holding all the field options 
  619. * 
  620. * @return $value - the modified value 
  621. */ 
  622.  
  623. function format_value( $value, $post_id, $field ) 
  624. // empty
  625. if( !empty($value) ) 
  626. // Pre 3.3.3, the value is a string coma seperated 
  627. if( is_string($value) ) 
  628. $value = explode(', ', $value); 
  629.  
  630.  
  631. // convert to integers 
  632. if( is_array($value) ) 
  633. $value = array_map('intval', $value); 
  634.  
  635. // convert into post objects 
  636. $value = $this->get_posts( $value ); 
  637.  
  638.  
  639.  
  640. // return value 
  641. return $value;  
  642.  
  643.  
  644. /** 
  645. * format_value_for_api() 
  646. * 
  647. * This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field 
  648. * 
  649. * @type filter 
  650. * @since 3.6 
  651. * @date 23/01/13 
  652. * 
  653. * @param $value - the value which was loaded from the database 
  654. * @param $post_id - the $post_id from which the value was loaded 
  655. * @param $field - the field array holding all the field options 
  656. * 
  657. * @return $value - the modified value 
  658. */ 
  659.  
  660. function format_value_for_api( $value, $post_id, $field ) 
  661. // empty
  662. if( !$value ) 
  663. return $value; 
  664.  
  665.  
  666. // Pre 3.3.3, the value is a string coma seperated 
  667. if( is_string($value) ) 
  668. $value = explode(', ', $value); 
  669.  
  670.  
  671. // empty
  672. if( !is_array($value) || empty($value) ) 
  673. return $value; 
  674.  
  675.  
  676. // convert to integers 
  677. $value = array_map('intval', $value); 
  678.  
  679.  
  680. // return format 
  681. if( $field['return_format'] == 'object' ) 
  682. $value = $this->get_posts( $value );  
  683.  
  684.  
  685. // return 
  686. return $value; 
  687.  
  688.  
  689.  
  690. /** 
  691. * get_posts 
  692. * 
  693. * This function will take an array of post_id's ($value) and return an array of post_objects 
  694. * 
  695. * @type function 
  696. * @date 7/08/13 
  697. * 
  698. * @param $post_ids (array) the array of post ID's 
  699. * @return (array) an array of post objects 
  700. */ 
  701.  
  702. function get_posts( $post_ids ) 
  703. // validate 
  704. if( empty($post_ids) ) 
  705. return $post_ids; 
  706.  
  707.  
  708. // vars 
  709. $r = array(); 
  710.  
  711.  
  712. // find posts (DISTINCT POSTS) 
  713. $posts = get_posts(array( 
  714. 'numberposts' => -1,  
  715. 'post__in' => $post_ids,  
  716. 'post_type' => apply_filters('acf/get_post_types', array()),  
  717. 'post_status' => 'any',  
  718. )); 
  719.  
  720.  
  721. $ordered_posts = array(); 
  722. foreach( $posts as $p ) 
  723. // create array to hold value data 
  724. $ordered_posts[ $p->ID ] = $p; 
  725.  
  726.  
  727. // override value array with attachments 
  728. foreach( $post_ids as $k => $v) 
  729. // check that post exists (my have been trashed) 
  730. if( isset($ordered_posts[ $v ]) ) 
  731. $r[] = $ordered_posts[ $v ]; 
  732.  
  733.  
  734. // return 
  735. return $r; 
  736.  
  737.  
  738. /** 
  739. * update_value() 
  740. * 
  741. * This filter is appied to the $value before it is updated in the db 
  742. * 
  743. * @type filter 
  744. * @since 3.6 
  745. * @date 23/01/13 
  746. * 
  747. * @param $value - the value which will be saved in the database 
  748. * @param $post_id - the $post_id of which the value will be saved 
  749. * @param $field - the field array holding all the field options 
  750. * 
  751. * @return $value - the modified value 
  752. */ 
  753.  
  754. function update_value( $value, $post_id, $field ) 
  755. // validate 
  756. if( empty($value) ) 
  757. return $value; 
  758.  
  759.  
  760. if( is_string($value) ) 
  761. // string 
  762. $value = explode(', ', $value); 
  763.  
  764. elseif( is_object($value) && isset($value->ID) ) 
  765. // object 
  766. $value = array( $value->ID ); 
  767.  
  768. elseif( is_array($value) ) 
  769. // array 
  770. foreach( $value as $k => $v ) { 
  771.  
  772. // object
  773. if( is_object($v) && isset($v->ID) ) 
  774. $value[ $k ] = $v->ID; 
  775.  
  776.  
  777.  
  778. // save value as strings, so we can clearly search for them in SQL LIKE statements 
  779. $value = array_map('strval', $value); 
  780.  
  781.  
  782. return $value; 
  783.  
  784.  
  785. new acf_field_relationship(); 
  786.  
  787. ?> 
.