Advanced Custom Fields - Version 4.1.3

Version Description

  • [Fixed] Relationship field: Fix global $post conflict issues - http://support.advancedcustomfields.com/discussion/6022/bug-with-4-1-2-acf-rewrite-global-post
Download this release

Release Info

Developer elliotcondon
Plugin Icon 128x128 Advanced Custom Fields
Version 4.1.3
Comparing to
See all releases

Code changes from version 4.1.2 to 4.1.3

acf.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Advanced Custom Fields
4
  Plugin URI: http://www.advancedcustomfields.com/
5
  Description: Fully customise WordPress edit screens with powerful fields. Boasting a professional interface and a powerfull API, it’s a must have for any web developer working with WordPress. Field types include: Wysiwyg, text, textarea, image, file, select, checkbox, page link, post object, date picker, color picker, repeater, flexible content, gallery and more!
6
- Version: 4.1.2
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  License: GPL
@@ -66,7 +66,7 @@ class Acf
66
  $this->settings = array(
67
  'path' => apply_filters('acf/helpers/get_path', __FILE__),
68
  'dir' => apply_filters('acf/helpers/get_dir', __FILE__),
69
- 'version' => '4.1.2',
70
  'upgrade_version' => '3.4.1',
71
  );
72
 
3
  Plugin Name: Advanced Custom Fields
4
  Plugin URI: http://www.advancedcustomfields.com/
5
  Description: Fully customise WordPress edit screens with powerful fields. Boasting a professional interface and a powerfull API, it’s a must have for any web developer working with WordPress. Field types include: Wysiwyg, text, textarea, image, file, select, checkbox, page link, post object, date picker, color picker, repeater, flexible content, gallery and more!
6
+ Version: 4.1.3
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  License: GPL
66
  $this->settings = array(
67
  'path' => apply_filters('acf/helpers/get_path', __FILE__),
68
  'dir' => apply_filters('acf/helpers/get_dir', __FILE__),
69
+ 'version' => '4.1.3',
70
  'upgrade_version' => '3.4.1',
71
  );
72
 
core/controllers/location.php CHANGED
@@ -590,13 +590,15 @@ class acf_location
590
 
591
  function rule_match_user_type( $match, $rule, $options )
592
  {
593
- if($rule['operator'] == "==")
 
 
594
  {
595
- $match = ( current_user_can($rule['value']) );
596
  }
597
- elseif($rule['operator'] == "!=")
598
  {
599
- $match = ( ! current_user_can($rule['value']) );
600
  }
601
 
602
  return $match;
590
 
591
  function rule_match_user_type( $match, $rule, $options )
592
  {
593
+ $user = wp_get_current_user();
594
+
595
+ if( $rule['operator'] == "==" )
596
  {
597
+ $match = in_array( $rule['value'], $user->roles );
598
  }
599
+ elseif( $rule['operator'] == "!=" )
600
  {
601
+ $match = ( ! in_array( $rule['value'], $user->roles ) );
602
  }
603
 
604
  return $match;
core/fields/_functions.php CHANGED
@@ -370,7 +370,7 @@ class acf_field_functions
370
  function load_field_defaults( $field )
371
  {
372
  // validate $field
373
- if( ! $field )
374
  {
375
  $field = array();
376
  }
370
  function load_field_defaults( $field )
371
  {
372
  // validate $field
373
+ if( !is_array($field) )
374
  {
375
  $field = array();
376
  }
core/fields/page_link.php CHANGED
@@ -2,6 +2,9 @@
2
 
3
  class acf_field_page_link extends acf_field
4
  {
 
 
 
5
 
6
  /*
7
  * __construct
@@ -18,6 +21,11 @@ class acf_field_page_link extends acf_field
18
  $this->name = 'page_link';
19
  $this->label = __("Page Link",'acf');
20
  $this->category = __("Relational",'acf');
 
 
 
 
 
21
 
22
 
23
  // do not delete!
@@ -26,6 +34,38 @@ class acf_field_page_link extends acf_field
26
  }
27
 
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  /*
30
  * create_field()
31
  *
@@ -63,13 +103,7 @@ class acf_field_page_link extends acf_field
63
  function create_options( $field )
64
  {
65
  // defaults
66
- $defaults = array(
67
- 'post_type' => '',
68
- 'multiple' => 0,
69
- 'allow_null' => 0,
70
- );
71
-
72
- $field = array_merge($defaults, $field);
73
  $key = $field['name'];
74
 
75
  ?>
@@ -81,7 +115,7 @@ class acf_field_page_link extends acf_field
81
  <?php
82
 
83
  $choices = array(
84
- '' => __("All",'acf')
85
  );
86
  $choices = apply_filters('acf/get_post_types', $choices);
87
 
2
 
3
  class acf_field_page_link extends acf_field
4
  {
5
+ // vars
6
+ var $defaults;
7
+
8
 
9
  /*
10
  * __construct
21
  $this->name = 'page_link';
22
  $this->label = __("Page Link",'acf');
23
  $this->category = __("Relational",'acf');
24
+ $this->defaults = array(
25
+ 'post_type' => array('all'),
26
+ 'multiple' => 0,
27
+ 'allow_null' => 0,
28
+ );
29
 
30
 
31
  // do not delete!
34
  }
35
 
36
 
37
+ /*
38
+ * load_field()
39
+ *
40
+ * This filter is appied to the $field after it is loaded from the database
41
+ *
42
+ * @type filter
43
+ * @since 3.6
44
+ * @date 23/01/13
45
+ *
46
+ * @param $field - the field array holding all the field options
47
+ *
48
+ * @return $field - the field array holding all the field options
49
+ */
50
+
51
+ function load_field( $field )
52
+ {
53
+ // defaults
54
+ $field = array_merge($this->defaults, $field);
55
+
56
+
57
+ // validate post_type
58
+ if( !$field['post_type'] || !is_array($field['post_type']) || in_array('', $field['post_type']) )
59
+ {
60
+ $field['post_type'] = array( 'all' );
61
+ }
62
+
63
+
64
+ // return
65
+ return $field;
66
+ }
67
+
68
+
69
  /*
70
  * create_field()
71
  *
103
  function create_options( $field )
104
  {
105
  // defaults
106
+ $field = array_merge($this->defaults, $field);
 
 
 
 
 
 
107
  $key = $field['name'];
108
 
109
  ?>
115
  <?php
116
 
117
  $choices = array(
118
+ 'all' => __("All",'acf')
119
  );
120
  $choices = apply_filters('acf/get_post_types', $choices);
121
 
core/fields/post_object.php CHANGED
@@ -35,6 +35,45 @@ class acf_field_post_object extends acf_field
35
  }
36
 
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  /*
39
  * create_field()
40
  *
@@ -49,9 +88,12 @@ class acf_field_post_object extends acf_field
49
 
50
  function create_field( $field )
51
  {
52
- // temp store the_post
 
 
 
 
53
  global $post;
54
- $the_post = $post;
55
 
56
 
57
  // vars
@@ -64,23 +106,6 @@ class acf_field_post_object extends acf_field
64
  'suppress_filters' => false,
65
  );
66
 
67
-
68
- $field = array_merge($this->defaults, $field);
69
-
70
-
71
- // validate post_type
72
- if( !$field['post_type'] || !is_array($field['post_type']) || in_array('', $field['post_type']) )
73
- {
74
- $field['post_type'] = array( 'all' );
75
- }
76
-
77
-
78
- // validate taxonomy
79
- if( !$field['taxonomy'] || !is_array($field['taxonomy']) || in_array('', $field['taxonomy']) )
80
- {
81
- $field['taxonomy'] = array( 'all' );
82
- }
83
-
84
 
85
  // load all post types by default
86
  if( in_array('all', $field['post_type']) )
@@ -152,9 +177,9 @@ class acf_field_post_object extends acf_field
152
 
153
 
154
  // filters
155
- $args = apply_filters('acf/fields/post_object/query', $args, $field, $the_post);
156
- $args = apply_filters('acf/fields/post_object/query/name=' . $field['name'], $args, $field, $the_post );
157
- $args = apply_filters('acf/fields/post_object/query/key=' . $field['key'], $args, $field, $the_post );
158
 
159
 
160
  if( $get_pages )
@@ -169,11 +194,11 @@ class acf_field_post_object extends acf_field
169
 
170
  if($posts)
171
  {
172
- foreach( $posts as $post )
173
  {
174
  // find title. Could use get_the_title, but that uses get_post(), so I think this uses less Memory
175
  $title = '';
176
- $ancestors = get_ancestors( $post->ID, $post->post_type );
177
  if($ancestors)
178
  {
179
  foreach($ancestors as $a)
@@ -181,13 +206,13 @@ class acf_field_post_object extends acf_field
181
  $title .= '–';
182
  }
183
  }
184
- $title .= ' ' . apply_filters( 'the_title', $post->post_title, $post->ID );
185
 
186
 
187
  // status
188
- if($post->post_status != "publish")
189
  {
190
- $title .= " ($post->post_status)";
191
  }
192
 
193
  // WPML
@@ -198,23 +223,23 @@ class acf_field_post_object extends acf_field
198
 
199
 
200
  // filters
201
- $title = apply_filters('acf/fields/post_object/result', $title, $post, $field, $the_post);
202
- $title = apply_filters('acf/fields/post_object/result/name=' . $field['name'] , $title, $post, $field, $the_post);
203
- $title = apply_filters('acf/fields/post_object/result/key=' . $field['key'], $title, $post, $field, $the_post);
204
 
205
 
206
  // add to choices
207
  if( count($field['post_type']) == 1 )
208
  {
209
- $field['choices'][ $post->ID ] = $title;
210
  }
211
  else
212
  {
213
  // group by post type
214
- $post_type_object = get_post_type_object( $post->post_type );
215
  $post_type_name = $post_type_object->labels->name;
216
 
217
- $field['choices'][ $post_type_name ][ $post->ID ] = $title;
218
  }
219
 
220
 
@@ -247,14 +272,7 @@ class acf_field_post_object extends acf_field
247
  function create_options( $field )
248
  {
249
  // vars
250
- $defaults = array(
251
- 'post_type' => '',
252
- 'multiple' => 0,
253
- 'allow_null' => 0,
254
- 'taxonomy' => array('all'),
255
- );
256
-
257
- $field = array_merge($defaults, $field);
258
  $key = $field['name'];
259
 
260
  ?>
@@ -266,7 +284,7 @@ class acf_field_post_object extends acf_field
266
  <?php
267
 
268
  $choices = array(
269
- '' => __("All",'acf')
270
  );
271
  $choices = apply_filters('acf/get_post_types', $choices);
272
 
35
  }
36
 
37
 
38
+ /*
39
+ * load_field()
40
+ *
41
+ * This filter is appied to the $field after it is loaded from the database
42
+ *
43
+ * @type filter
44
+ * @since 3.6
45
+ * @date 23/01/13
46
+ *
47
+ * @param $field - the field array holding all the field options
48
+ *
49
+ * @return $field - the field array holding all the field options
50
+ */
51
+
52
+ function load_field( $field )
53
+ {
54
+ // defaults
55
+ $field = array_merge($this->defaults, $field);
56
+
57
+
58
+ // validate post_type
59
+ if( !$field['post_type'] || !is_array($field['post_type']) || in_array('', $field['post_type']) )
60
+ {
61
+ $field['post_type'] = array( 'all' );
62
+ }
63
+
64
+
65
+ // validate taxonomy
66
+ if( !$field['taxonomy'] || !is_array($field['taxonomy']) || in_array('', $field['taxonomy']) )
67
+ {
68
+ $field['taxonomy'] = array( 'all' );
69
+ }
70
+
71
+
72
+ // return
73
+ return $field;
74
+ }
75
+
76
+
77
  /*
78
  * create_field()
79
  *
88
 
89
  function create_field( $field )
90
  {
91
+ // defaults
92
+ $field = array_merge($this->defaults, $field);
93
+
94
+
95
+ // global
96
  global $post;
 
97
 
98
 
99
  // vars
106
  'suppress_filters' => false,
107
  );
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
 
110
  // load all post types by default
111
  if( in_array('all', $field['post_type']) )
177
 
178
 
179
  // filters
180
+ $args = apply_filters('acf/fields/post_object/query', $args, $field, $post);
181
+ $args = apply_filters('acf/fields/post_object/query/name=' . $field['name'], $args, $field, $post );
182
+ $args = apply_filters('acf/fields/post_object/query/key=' . $field['key'], $args, $field, $post );
183
 
184
 
185
  if( $get_pages )
194
 
195
  if($posts)
196
  {
197
+ foreach( $posts as $p )
198
  {
199
  // find title. Could use get_the_title, but that uses get_post(), so I think this uses less Memory
200
  $title = '';
201
+ $ancestors = get_ancestors( $p->ID, $p->post_type );
202
  if($ancestors)
203
  {
204
  foreach($ancestors as $a)
206
  $title .= '–';
207
  }
208
  }
209
+ $title .= ' ' . apply_filters( 'the_title', $p->post_title, $p->ID );
210
 
211
 
212
  // status
213
+ if( $p->post_status != "publish" )
214
  {
215
+ $title .= " ($p->post_status)";
216
  }
217
 
218
  // WPML
223
 
224
 
225
  // filters
226
+ $title = apply_filters('acf/fields/post_object/result', $title, $p, $field, $post);
227
+ $title = apply_filters('acf/fields/post_object/result/name=' . $field['name'] , $title, $p, $field, $post);
228
+ $title = apply_filters('acf/fields/post_object/result/key=' . $field['key'], $title, $p, $field, $post);
229
 
230
 
231
  // add to choices
232
  if( count($field['post_type']) == 1 )
233
  {
234
+ $field['choices'][ $p->ID ] = $title;
235
  }
236
  else
237
  {
238
  // group by post type
239
+ $post_type_object = get_post_type_object( $p->post_type );
240
  $post_type_name = $post_type_object->labels->name;
241
 
242
+ $field['choices'][ $post_type_name ][ $p->ID ] = $title;
243
  }
244
 
245
 
272
  function create_options( $field )
273
  {
274
  // vars
275
+ $field = array_merge($this->defaults, $field);
 
 
 
 
 
 
 
276
  $key = $field['name'];
277
 
278
  ?>
284
  <?php
285
 
286
  $choices = array(
287
+ 'all' => __("All",'acf')
288
  );
289
  $choices = apply_filters('acf/get_post_types', $choices);
290
 
core/fields/relationship.php CHANGED
@@ -40,6 +40,64 @@ class acf_field_relationship extends acf_field
40
  }
41
 
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  /*
44
  * posts_where
45
  *
@@ -191,8 +249,8 @@ class acf_field_relationship extends acf_field
191
  $field = apply_filters('acf/load_field', array(), $options['field_key'] );
192
  }
193
 
194
- $field = array_merge( $this->defaults, $field );
195
 
 
196
  $the_post = get_post( $options['post_id'] );
197
 
198
 
@@ -210,14 +268,14 @@ class acf_field_relationship extends acf_field
210
 
211
  if( $posts )
212
  {
213
- foreach( $posts as $post )
214
  {
215
  // right aligned info
216
  $title = '<span class="relationship-item-info">';
217
 
218
  if( in_array('post_type', $field['result_elements']) )
219
  {
220
- $title .= $post->post_type;
221
  }
222
 
223
  // WPML
@@ -232,28 +290,28 @@ class acf_field_relationship extends acf_field
232
  // featured_image
233
  if( in_array('featured_image', $field['result_elements']) )
234
  {
235
- $image = get_the_post_thumbnail( $post->ID, array(21, 21) );
236
 
237
  $title .= '<div class="result-thumbnail">' . $image . '</div>';
238
  }
239
 
240
 
241
  // find title. Could use get_the_title, but that uses get_post(), so I think this uses less Memory
242
- $title .= apply_filters( 'the_title', $post->post_title, $post->ID );
243
 
244
  // status
245
- if($post->post_status != "publish")
246
  {
247
- $title .= " ($post->post_status)";
248
  }
249
 
250
  // filters
251
- $title = apply_filters('acf/fields/relationship/result', $title, $post, $field, $the_post);
252
- $title = apply_filters('acf/fields/relationship/result/name=' . $field['name'] , $title, $post, $field, $the_post);
253
- $title = apply_filters('acf/fields/relationship/result/key=' . $field['key'], $title, $post, $field, $the_post);
254
 
255
 
256
- $results .= '<li><a href="' . get_permalink($post->ID) . '" data-post_id="' . $post->ID . '">' . $title . '<span class="acf-button-add"></span></a></li>';
257
  }
258
  }
259
 
@@ -278,13 +336,8 @@ class acf_field_relationship extends acf_field
278
 
279
  function create_field( $field )
280
  {
281
- // temp store the_post
282
  global $post;
283
- $the_post = $post;
284
-
285
-
286
- // vars
287
- $field = array_merge($this->defaults, $field);
288
 
289
 
290
  // no row limit?
@@ -294,20 +347,6 @@ class acf_field_relationship extends acf_field
294
  }
295
 
296
 
297
- // validate post_type
298
- if( !$field['post_type'] || !is_array($field['post_type']) || in_array('', $field['post_type']) )
299
- {
300
- $field['post_type'] = array( 'all' );
301
- }
302
-
303
-
304
- // validate taxonomy
305
- if( !$field['taxonomy'] || !is_array($field['taxonomy']) || in_array('', $field['taxonomy']) )
306
- {
307
- $field['taxonomy'] = array( 'all' );
308
- }
309
-
310
-
311
  // class
312
  $class = '';
313
  if( $field['filters'] )
@@ -425,14 +464,14 @@ class acf_field_relationship extends acf_field
425
 
426
  if( $field['value'] )
427
  {
428
- foreach( $field['value'] as $post )
429
  {
430
  // right aligned info
431
  $title = '<span class="relationship-item-info">';
432
 
433
  if( in_array('post_type', $field['result_elements']) )
434
  {
435
- $title .= $post->post_type;
436
  }
437
 
438
  // WPML
@@ -447,31 +486,31 @@ class acf_field_relationship extends acf_field
447
  // featured_image
448
  if( in_array('featured_image', $field['result_elements']) )
449
  {
450
- $image = get_the_post_thumbnail( $post->ID, array(21, 21) );
451
 
452
  $title .= '<div class="result-thumbnail">' . $image . '</div>';
453
  }
454
 
455
 
456
  // find title. Could use get_the_title, but that uses get_post(), so I think this uses less Memory
457
- $title .= apply_filters( 'the_title', $post->post_title, $post->ID );
458
 
459
  // status
460
- if($post->post_status != "publish")
461
  {
462
- $title .= " ($post->post_status)";
463
  }
464
 
465
 
466
  // filters
467
- $title = apply_filters('acf/fields/relationship/result', $title, $post, $field, $the_post);
468
- $title = apply_filters('acf/fields/relationship/result/name=' . $field['name'] , $title, $post, $field, $the_post);
469
- $title = apply_filters('acf/fields/relationship/result/key=' . $field['key'], $title, $post, $field, $the_post);
470
 
471
 
472
  echo '<li>
473
- <a href="' . get_permalink($post->ID) . '" class="" data-post_id="' . $post->ID . '">' . $title . '<span class="acf-button-remove"></span></a>
474
- <input type="hidden" name="' . $field['name'] . '[]" value="' . $post->ID . '" />
475
  </li>';
476
 
477
 
@@ -488,6 +527,7 @@ class acf_field_relationship extends acf_field
488
  }
489
 
490
 
 
491
  /*
492
  * create_options()
493
  *
@@ -507,26 +547,6 @@ class acf_field_relationship extends acf_field
507
  $field = array_merge($this->defaults, $field);
508
  $key = $field['name'];
509
 
510
-
511
-
512
- // validate taxonomy
513
- if( !is_array($field['taxonomy']) )
514
- {
515
- $field['taxonomy'] = array('all');
516
- }
517
-
518
-
519
- // validate result_elements
520
- if( !is_array( $field['result_elements'] ) )
521
- {
522
- $field['result_elements'] = array();
523
- }
524
-
525
- if( !in_array('post_title', $field['result_elements']) )
526
- {
527
- $field['result_elements'][] = 'post_title';
528
- }
529
-
530
  ?>
531
  <tr class="field_option field_option_<?php echo $this->name; ?>">
532
  <td class="label">
@@ -686,10 +706,10 @@ class acf_field_relationship extends acf_field
686
 
687
 
688
  $ordered_posts = array();
689
- foreach( $posts as $post )
690
  {
691
  // create array to hold value data
692
- $ordered_posts[ $post->ID ] = $post;
693
  }
694
 
695
 
40
  }
41
 
42
 
43
+ /*
44
+ * load_field()
45
+ *
46
+ * This filter is appied to the $field after it is loaded from the database
47
+ *
48
+ * @type filter
49
+ * @since 3.6
50
+ * @date 23/01/13
51
+ *
52
+ * @param $field - the field array holding all the field options
53
+ *
54
+ * @return $field - the field array holding all the field options
55
+ */
56
+
57
+ function load_field( $field )
58
+ {
59
+ // defaults
60
+ $field = array_merge($this->defaults, $field);
61
+
62
+
63
+ // validate post_type
64
+ if( !$field['post_type'] || !is_array($field['post_type']) || in_array('', $field['post_type']) )
65
+ {
66
+ $field['post_type'] = array( 'all' );
67
+ }
68
+
69
+
70
+ // validate taxonomy
71
+ if( !$field['taxonomy'] || !is_array($field['taxonomy']) || in_array('', $field['taxonomy']) )
72
+ {
73
+ $field['taxonomy'] = array( 'all' );
74
+ }
75
+
76
+
77
+ // validate result_elements
78
+ if( !is_array( $field['result_elements'] ) )
79
+ {
80
+ $field['result_elements'] = array();
81
+ }
82
+
83
+ if( !in_array('post_title', $field['result_elements']) )
84
+ {
85
+ $field['result_elements'][] = 'post_title';
86
+ }
87
+
88
+
89
+ // filters
90
+ if( !is_array( $field['filters'] ) )
91
+ {
92
+ $field['filters'] = array();
93
+ }
94
+
95
+
96
+ // return
97
+ return $field;
98
+ }
99
+
100
+
101
  /*
102
  * posts_where
103
  *
249
  $field = apply_filters('acf/load_field', array(), $options['field_key'] );
250
  }
251
 
 
252
 
253
+ // get the post from which this field is rendered on
254
  $the_post = get_post( $options['post_id'] );
255
 
256
 
268
 
269
  if( $posts )
270
  {
271
+ foreach( $posts as $p )
272
  {
273
  // right aligned info
274
  $title = '<span class="relationship-item-info">';
275
 
276
  if( in_array('post_type', $field['result_elements']) )
277
  {
278
+ $title .= $p->post_type;
279
  }
280
 
281
  // WPML
290
  // featured_image
291
  if( in_array('featured_image', $field['result_elements']) )
292
  {
293
+ $image = get_the_post_thumbnail( $p->ID, array(21, 21) );
294
 
295
  $title .= '<div class="result-thumbnail">' . $image . '</div>';
296
  }
297
 
298
 
299
  // find title. Could use get_the_title, but that uses get_post(), so I think this uses less Memory
300
+ $title .= apply_filters( 'the_title', $p->post_title, $p->ID );
301
 
302
  // status
303
+ if($p->post_status != "publish")
304
  {
305
+ $title .= " ($p->post_status)";
306
  }
307
 
308
  // filters
309
+ $title = apply_filters('acf/fields/relationship/result', $title, $p, $field, $the_post);
310
+ $title = apply_filters('acf/fields/relationship/result/name=' . $field['name'] , $title, $p, $field, $the_post);
311
+ $title = apply_filters('acf/fields/relationship/result/key=' . $field['key'], $title, $p, $field, $the_post);
312
 
313
 
314
+ $results .= '<li><a href="' . get_permalink($p->ID) . '" data-post_id="' . $p->ID . '">' . $title . '<span class="acf-button-add"></span></a></li>';
315
  }
316
  }
317
 
336
 
337
  function create_field( $field )
338
  {
339
+ // global
340
  global $post;
 
 
 
 
 
341
 
342
 
343
  // no row limit?
347
  }
348
 
349
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
350
  // class
351
  $class = '';
352
  if( $field['filters'] )
464
 
465
  if( $field['value'] )
466
  {
467
+ foreach( $field['value'] as $p )
468
  {
469
  // right aligned info
470
  $title = '<span class="relationship-item-info">';
471
 
472
  if( in_array('post_type', $field['result_elements']) )
473
  {
474
+ $title .= $p->post_type;
475
  }
476
 
477
  // WPML
486
  // featured_image
487
  if( in_array('featured_image', $field['result_elements']) )
488
  {
489
+ $image = get_the_post_thumbnail( $p->ID, array(21, 21) );
490
 
491
  $title .= '<div class="result-thumbnail">' . $image . '</div>';
492
  }
493
 
494
 
495
  // find title. Could use get_the_title, but that uses get_post(), so I think this uses less Memory
496
+ $title .= apply_filters( 'the_title', $p->post_title, $p->ID );
497
 
498
  // status
499
+ if($p->post_status != "publish")
500
  {
501
+ $title .= " ($p->post_status)";
502
  }
503
 
504
 
505
  // filters
506
+ $title = apply_filters('acf/fields/relationship/result', $title, $p, $field, $post);
507
+ $title = apply_filters('acf/fields/relationship/result/name=' . $field['name'] , $title, $p, $field, $post);
508
+ $title = apply_filters('acf/fields/relationship/result/key=' . $field['key'], $title, $p, $field, $post);
509
 
510
 
511
  echo '<li>
512
+ <a href="' . get_permalink($p->ID) . '" class="" data-post_id="' . $p->ID . '">' . $title . '<span class="acf-button-remove"></span></a>
513
+ <input type="hidden" name="' . $field['name'] . '[]" value="' . $p->ID . '" />
514
  </li>';
515
 
516
 
527
  }
528
 
529
 
530
+
531
  /*
532
  * create_options()
533
  *
547
  $field = array_merge($this->defaults, $field);
548
  $key = $field['name'];
549
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
550
  ?>
551
  <tr class="field_option field_option_<?php echo $this->name; ?>">
552
  <td class="label">
706
 
707
 
708
  $ordered_posts = array();
709
+ foreach( $posts as $p )
710
  {
711
  // create array to hold value data
712
+ $ordered_posts[ $p->ID ] = $p;
713
  }
714
 
715
 
js/input/image.js CHANGED
@@ -115,7 +115,7 @@
115
  multiple : multiple,
116
  library : {
117
  type : 'image'
118
- },
119
  });
120
 
121
 
115
  multiple : multiple,
116
  library : {
117
  type : 'image'
118
+ }
119
  });
120
 
121
 
readme.txt CHANGED
@@ -101,6 +101,9 @@ http://support.advancedcustomfields.com/
101
 
102
  == Changelog ==
103
 
 
 
 
104
  = 4.1.2 =
105
  * [Added] Post Object field: Add filter to customize choices - http://support.advancedcustomfields.com/discussion/5883/show-extra-post-info-in-a-post-object-dropdown-list
106
  * [Fixed] Relationship field: Fix error when used as grand child - http://support.advancedcustomfields.com/discussion/5898/in_array-errors-on-relationship-field
101
 
102
  == Changelog ==
103
 
104
+ = 4.1.3 =
105
+ * [Fixed] Relationship field: Fix global $post conflict issues - http://support.advancedcustomfields.com/discussion/6022/bug-with-4-1-2-acf-rewrite-global-post
106
+
107
  = 4.1.2 =
108
  * [Added] Post Object field: Add filter to customize choices - http://support.advancedcustomfields.com/discussion/5883/show-extra-post-info-in-a-post-object-dropdown-list
109
  * [Fixed] Relationship field: Fix error when used as grand child - http://support.advancedcustomfields.com/discussion/5898/in_array-errors-on-relationship-field