Advanced Custom Fields - Version 3.5.7

Version Description

  • [Fixed] Fix sub field default value - http://support.advancedcustomfields.com/discussion/3706/select-field-default-value-not-working
  • [Added] Add filters for custom location rules - http://support.advancedcustomfields.com/discussion/4285/how-to-retrieve-a-custom-field-within-the-function-php
  • [Fixed] Fix XML import to create unique field ID's - http://support.advancedcustomfields.com/discussion/4328/check-acf_next_field_id-to-avoid-data-corruption
  • [Fixed] Fix conditional logic with validation - http://support.advancedcustomfields.com/discussion/4295/issue-with-conditional-logic-and-obrigatory-fields
  • [Fixed] Fix repeater + relationship bug - http://support.advancedcustomfields.com/discussion/4296/relationship-field-bug
Download this release

Release Info

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

Code changes from version 3.5.6 to 3.5.7

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: 3.5.6.3
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  License: GPL
@@ -33,7 +33,8 @@ class Acf
33
  $input,
34
  $options_page,
35
  $everything_fields,
36
- $third_party;
 
37
 
38
 
39
  /*
@@ -50,7 +51,7 @@ class Acf
50
  // vars
51
  $this->path = plugin_dir_path(__FILE__);
52
  $this->dir = plugins_url('',__FILE__);
53
- $this->version = '3.5.6.3';
54
  $this->upgrade_version = '3.4.1'; // this is the latest version which requires an upgrade
55
  $this->cache = array(); // basic array cache to hold data throughout the page load
56
  $this->defaults = array(
@@ -89,10 +90,6 @@ class Acf
89
  add_filter('acf_parse_value', array($this, 'acf_parse_value'));
90
 
91
 
92
- // ajax
93
- add_action('wp_ajax_get_input_metabox_ids', array($this, 'get_input_metabox_ids'));
94
-
95
-
96
  return true;
97
  }
98
 
@@ -374,6 +371,11 @@ class Acf
374
  // Third Party Compatibility
375
  include_once('core/controllers/third_party.php');
376
  $this->third_party = new acf_third_party($this);
 
 
 
 
 
377
  }
378
 
379
 
@@ -713,6 +715,10 @@ class Acf
713
  $field = apply_filters( 'acf_parse_value', $field );
714
 
715
 
 
 
 
 
716
  return $field;
717
  }
718
 
@@ -741,7 +747,15 @@ class Acf
741
  // numbers
742
  if( is_numeric($value) )
743
  {
744
- $value = (int) $value;
 
 
 
 
 
 
 
 
745
  }
746
  }
747
 
@@ -1137,52 +1151,48 @@ class Acf
1137
  *
1138
  *-------------------------------------------------------------------------------------*/
1139
 
1140
- function get_input_metabox_ids($overrides = array(), $json = true)
1141
  {
1142
- // overrides
1143
- if(isset($_POST))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1144
  {
1145
- $override_keys = array(
1146
- 'post_id',
1147
- 'post_type',
1148
- 'page_template',
1149
- 'page_parent',
1150
- 'page_type',
1151
- 'page',
1152
- 'post',
1153
- 'post_category',
1154
- 'post_format',
1155
- 'taxonomy',
1156
- 'lang',
1157
- );
1158
-
1159
- foreach( $override_keys as $override_key )
1160
- {
1161
- if( isset($_POST[ $override_key ]) && $_POST[ $override_key ] != 'false' )
1162
- {
1163
- $overrides[ $override_key ] = $_POST[ $override_key ];
1164
- }
1165
- }
1166
-
1167
  }
1168
 
1169
 
1170
  // Parse values
1171
- $overrides = apply_filters( 'acf_parse_value', $overrides );
1172
 
1173
 
1174
  // WPML
1175
- if( isset($overrides['lang']) )
1176
  {
1177
  global $sitepress;
1178
- $sitepress->switch_lang( $overrides['lang'] );
1179
  }
1180
 
1181
 
1182
- // create post object to match against
1183
- $post = isset($overrides['post_id']) ? get_post($overrides['post_id']) : false;
1184
-
1185
-
1186
  // find all acf objects
1187
  $acfs = $this->get_field_groups();
1188
 
@@ -1190,51 +1200,60 @@ class Acf
1190
  // blank array to hold acfs
1191
  $return = array();
1192
 
1193
- if($acfs)
 
1194
  {
1195
- foreach($acfs as $acf)
1196
  {
 
1197
  $add_box = false;
1198
-
1199
- if($acf['location']['allorany'] == 'all')
 
 
1200
  {
1201
- // ALL
1202
  $add_box = true;
1203
-
1204
- if($acf['location']['rules'])
1205
- {
1206
- foreach($acf['location']['rules'] as $rule)
1207
- {
1208
-
1209
- // if any rules dont return true, dont add this acf
1210
- if(!$this->match_location_rule($post, $rule, $overrides))
1211
- {
1212
- $add_box = false;
1213
- }
1214
- }
1215
- }
1216
-
1217
  }
1218
- elseif($acf['location']['allorany'] == 'any')
 
 
1219
  {
1220
- // ANY
1221
-
1222
- $add_box = false;
 
 
 
1223
 
1224
- if($acf['location']['rules'])
1225
  {
1226
- foreach($acf['location']['rules'] as $rule)
 
 
 
 
 
 
 
 
 
1227
  {
1228
- // if any rules return true, add this acf
1229
- if($this->match_location_rule($post, $rule, $overrides))
1230
- {
1231
- $add_box = true;
1232
- }
1233
  }
 
 
 
 
 
 
 
1234
  }
1235
  }
1236
-
1237
- if($add_box == true)
 
 
1238
  {
1239
  $return[] = $acf['id'];
1240
  }
@@ -1242,608 +1261,17 @@ class Acf
1242
  }
1243
  }
1244
 
1245
- if($json)
 
 
1246
  {
1247
  echo json_encode($return);
1248
  die;
1249
  }
1250
- else
1251
- {
1252
- return $return;
1253
- }
1254
-
1255
-
1256
- }
1257
-
1258
-
1259
-
1260
-
1261
-
1262
- /*--------------------------------------------------------------------------------------
1263
- *
1264
- * match_location_rule
1265
- *
1266
- * @author Elliot Condon
1267
- * @since 2.0.0
1268
- *
1269
- *-------------------------------------------------------------------------------------*/
1270
-
1271
- function match_location_rule($post = null, $rule = array(), $overrides = array())
1272
- {
1273
-
1274
- // no post? Thats okay if you are one of the bellow exceptions. Otherwise, return false
1275
- if(!$post)
1276
- {
1277
- $exceptions = array(
1278
- 'user_type',
1279
- 'options_page',
1280
- 'ef_taxonomy',
1281
- 'ef_user',
1282
- 'ef_media',
1283
- 'post_type',
1284
- );
1285
-
1286
- if( !in_array($rule['param'], $exceptions) )
1287
- {
1288
- return false;
1289
- }
1290
- }
1291
-
1292
-
1293
- if(!isset($rule['value']))
1294
- {
1295
- return false;
1296
- }
1297
 
1298
 
1299
- switch ($rule['param']) {
1300
-
1301
- // POST TYPE
1302
- case "post_type":
1303
-
1304
- $post_type = isset($overrides['post_type']) ? $overrides['post_type'] : get_post_type($post);
1305
-
1306
- if($rule['operator'] == "==")
1307
- {
1308
- if($post_type == $rule['value'])
1309
- {
1310
- return true;
1311
- }
1312
-
1313
- return false;
1314
- }
1315
- elseif($rule['operator'] == "!=")
1316
- {
1317
- if($post_type != $rule['value'])
1318
- {
1319
- return true;
1320
- }
1321
-
1322
- return false;
1323
- }
1324
-
1325
- break;
1326
-
1327
- // PAGE
1328
- case "page":
1329
-
1330
- $page = isset($overrides['page']) ? $overrides['page'] : $post->ID;
1331
-
1332
- if($rule['operator'] == "==")
1333
- {
1334
- if($page == $rule['value'])
1335
- {
1336
- return true;
1337
- }
1338
-
1339
- return false;
1340
- }
1341
- elseif($rule['operator'] == "!=")
1342
- {
1343
- if($page != $rule['value'])
1344
- {
1345
- return true;
1346
- }
1347
-
1348
- return false;
1349
- }
1350
-
1351
- break;
1352
-
1353
- // PAGE
1354
- case "page_type":
1355
-
1356
- $page = isset($overrides['page']) ? $overrides['page'] : $post->ID;
1357
-
1358
- if( $rule['value'] == 'front_page')
1359
- {
1360
- $front_page = (int) get_option('page_on_front');
1361
-
1362
- if( $rule['operator'] == "==" )
1363
- {
1364
- if( $front_page == $page )
1365
- {
1366
- return true;
1367
- }
1368
- }
1369
- elseif( $rule['operator'] == "!=" )
1370
- {
1371
- if( $front_page != $page )
1372
- {
1373
- return true;
1374
- }
1375
- }
1376
-
1377
- return false;
1378
- }
1379
-
1380
-
1381
- if( $rule['value'] == 'posts_page')
1382
- {
1383
- $posts_page = (int) get_option('page_for_posts');
1384
-
1385
- if( $rule['operator'] == "==" )
1386
- {
1387
- if( $posts_page == $page )
1388
- {
1389
- return true;
1390
- }
1391
- }
1392
- elseif( $rule['operator'] == "!=" )
1393
- {
1394
- if( $posts_page != $page )
1395
- {
1396
- return true;
1397
- }
1398
- }
1399
-
1400
- return false;
1401
- }
1402
-
1403
-
1404
- if( $rule['value'] == 'parent')
1405
- {
1406
- $children = get_pages(array(
1407
- 'post_type' => $post->post_type,
1408
- 'child_of' => $post->ID,
1409
- ));
1410
-
1411
-
1412
- if( $rule['operator'] == "==" )
1413
- {
1414
- if( count($children) > 0 )
1415
- {
1416
- return true;
1417
- }
1418
- }
1419
- elseif( $rule['operator'] == "!=" )
1420
- {
1421
- if( count($children) == 0 )
1422
- {
1423
- return true;
1424
- }
1425
- }
1426
-
1427
- return false;
1428
- }
1429
-
1430
-
1431
- if( $rule['value'] == 'child')
1432
- {
1433
- $post_parent = $post->post_parent;
1434
- if( isset($overrides['page_parent']) )
1435
- {
1436
- $post_parent = (int) $overrides['page_parent'];
1437
- }
1438
-
1439
- if( $rule['operator'] == "==" )
1440
- {
1441
- if( $post_parent != 0 )
1442
- {
1443
- return true;
1444
- }
1445
- }
1446
- elseif( $rule['operator'] == "!=" )
1447
- {
1448
- if( $post_parent == 0 )
1449
- {
1450
- return true;
1451
- }
1452
- }
1453
-
1454
- return false;
1455
- }
1456
-
1457
-
1458
- break;
1459
-
1460
- // PAGE PARENT
1461
- case "page_parent":
1462
-
1463
- $page_parent = isset($overrides['page_parent']) ? $overrides['page_parent'] : $post->post_parent;
1464
-
1465
- if($rule['operator'] == "==")
1466
- {
1467
- if($page_parent == $rule['value'])
1468
- {
1469
- return true;
1470
- }
1471
-
1472
- return false;
1473
-
1474
- }
1475
- elseif($rule['operator'] == "!=")
1476
- {
1477
- if($page_parent != $rule['value'])
1478
- {
1479
- return true;
1480
- }
1481
-
1482
- return false;
1483
- }
1484
-
1485
- break;
1486
-
1487
- // PAGE
1488
- case "page_template":
1489
-
1490
- $page_template = isset($overrides['page_template']) ? $overrides['page_template'] : get_post_meta($post->ID,'_wp_page_template',true);
1491
-
1492
- if($rule['operator'] == "==")
1493
- {
1494
- if($page_template == $rule['value'])
1495
- {
1496
- return true;
1497
- }
1498
-
1499
- if($rule['value'] == "default" && !$page_template)
1500
- {
1501
- return true;
1502
- }
1503
-
1504
- return false;
1505
- }
1506
- elseif($rule['operator'] == "!=")
1507
- {
1508
- if($page_template != $rule['value'])
1509
- {
1510
- return true;
1511
- }
1512
-
1513
- return false;
1514
- }
1515
-
1516
- break;
1517
-
1518
- // POST
1519
- case "post":
1520
-
1521
- $post_id = isset($overrides['post']) ? $overrides['post'] : $post->ID;
1522
-
1523
- if($rule['operator'] == "==")
1524
- {
1525
- if($post_id == $rule['value'])
1526
- {
1527
- return true;
1528
- }
1529
-
1530
- return false;
1531
- }
1532
- elseif($rule['operator'] == "!=")
1533
- {
1534
- if($post_id != $rule['value'])
1535
- {
1536
- return true;
1537
- }
1538
-
1539
- return false;
1540
- }
1541
-
1542
- break;
1543
-
1544
- // POST CATEGORY
1545
- case "post_category":
1546
-
1547
- $cats = array();
1548
-
1549
- if(isset($overrides['post_category']))
1550
- {
1551
- $cats = $overrides['post_category'];
1552
- }
1553
- else
1554
- {
1555
- $all_cats = get_the_category($post->ID);
1556
- foreach($all_cats as $cat)
1557
- {
1558
- $cats[] = $cat->term_id;
1559
- }
1560
- }
1561
- if($rule['operator'] == "==")
1562
- {
1563
- if($cats)
1564
- {
1565
- if(in_array($rule['value'], $cats))
1566
- {
1567
- return true;
1568
- }
1569
- }
1570
-
1571
- return false;
1572
- }
1573
- elseif($rule['operator'] == "!=")
1574
- {
1575
- if($cats)
1576
- {
1577
- if(!in_array($rule['value'], $cats))
1578
- {
1579
- return true;
1580
- }
1581
- }
1582
-
1583
- return false;
1584
- }
1585
-
1586
- break;
1587
-
1588
-
1589
- // USER TYPE
1590
- case "user_type":
1591
-
1592
- if($rule['operator'] == "==")
1593
- {
1594
- if(current_user_can($rule['value']))
1595
- {
1596
- return true;
1597
- }
1598
-
1599
- return false;
1600
- }
1601
- elseif($rule['operator'] == "!=")
1602
- {
1603
- if(!current_user_can($rule['value']))
1604
- {
1605
- return true;
1606
- }
1607
-
1608
- return false;
1609
- }
1610
-
1611
- break;
1612
-
1613
- // Options Page
1614
- case "options_page":
1615
-
1616
- global $plugin_page;
1617
-
1618
-
1619
- // older location rules may be "options-pagename"
1620
- if( substr($rule['value'], 0, 8) == 'options-' )
1621
- {
1622
- $rule['value'] = 'acf-' . $rule['value'];
1623
- }
1624
-
1625
-
1626
- // older location ruels may be "Pagename"
1627
- if( substr($rule['value'], 0, 11) != 'acf-options' )
1628
- {
1629
- $rule['value'] = 'acf-options-' . sanitize_title( $rule['value'] );
1630
-
1631
- // value may now be wrong (acf-options-options)
1632
- if( $rule['value'] == 'acf-options-options' )
1633
- {
1634
- $rule['value'] = 'acf-options';
1635
- }
1636
- }
1637
-
1638
-
1639
- if($rule['operator'] == "==")
1640
- {
1641
- if( $plugin_page == $rule['value'] )
1642
- {
1643
- return true;
1644
- }
1645
-
1646
- return false;
1647
- }
1648
- elseif($rule['operator'] == "!=")
1649
- {
1650
- if( $plugin_page == $rule['value'] )
1651
- {
1652
- return true;
1653
- }
1654
-
1655
- return false;
1656
- }
1657
-
1658
- break;
1659
-
1660
-
1661
- // Post Format
1662
- case "post_format":
1663
-
1664
-
1665
- $post_format = isset($overrides['post_format']) ? $overrides['post_format'] : get_post_format( $post->ID );
1666
-
1667
- if( is_numeric($post_format) && $post_format == 0 )
1668
- {
1669
- $post_format = "standard";
1670
- }
1671
-
1672
-
1673
- if($rule['operator'] == "==")
1674
- {
1675
- if($post_format == $rule['value'])
1676
- {
1677
- return true;
1678
- }
1679
-
1680
- return false;
1681
- }
1682
- elseif($rule['operator'] == "!=")
1683
- {
1684
- if($post_format != $rule['value'])
1685
- {
1686
- return true;
1687
- }
1688
-
1689
- return false;
1690
- }
1691
-
1692
-
1693
- break;
1694
-
1695
- // Taxonomy
1696
- case "taxonomy":
1697
-
1698
- $terms = array();
1699
-
1700
- if(isset($overrides['taxonomy']))
1701
- {
1702
- $terms = $overrides['taxonomy'];
1703
- }
1704
- else
1705
- {
1706
- $taxonomies = get_object_taxonomies($post->post_type);
1707
- if($taxonomies)
1708
- {
1709
- foreach($taxonomies as $tax)
1710
- {
1711
- $all_terms = get_the_terms($post->ID, $tax);
1712
- if($all_terms)
1713
- {
1714
- foreach($all_terms as $all_term)
1715
- {
1716
- $terms[] = $all_term->term_id;
1717
- }
1718
- }
1719
- }
1720
- }
1721
- }
1722
-
1723
- if($rule['operator'] == "==")
1724
- {
1725
- if($terms)
1726
- {
1727
- if(in_array($rule['value'], $terms))
1728
- {
1729
- return true;
1730
- }
1731
- }
1732
-
1733
- return false;
1734
- }
1735
- elseif($rule['operator'] == "!=")
1736
- {
1737
- if($terms)
1738
- {
1739
- if(!in_array($rule['value'], $terms))
1740
- {
1741
- return true;
1742
- }
1743
- }
1744
-
1745
- return false;
1746
- }
1747
-
1748
-
1749
- break;
1750
-
1751
- // Everything Fields: Taxonomy
1752
- case "ef_taxonomy":
1753
-
1754
- if( !isset($overrides['ef_taxonomy']) )
1755
- {
1756
- return false;
1757
- }
1758
-
1759
- $ef_taxonomy = $overrides['ef_taxonomy'];
1760
-
1761
- if($rule['operator'] == "==")
1762
- {
1763
- if( $ef_taxonomy == $rule['value'] || $rule['value'] == "all" )
1764
- {
1765
- return true;
1766
- }
1767
-
1768
- return false;
1769
- }
1770
- elseif($rule['operator'] == "!=")
1771
- {
1772
- if( $ef_taxonomy != $rule['value'] || $rule['value'] == "all" )
1773
- {
1774
- return true;
1775
- }
1776
-
1777
- return false;
1778
- }
1779
-
1780
-
1781
- break;
1782
-
1783
- // Everything Fields: User
1784
- case "ef_user":
1785
-
1786
- if( !isset($overrides['ef_user']) )
1787
- {
1788
- return false;
1789
- }
1790
-
1791
- $ef_user = $overrides['ef_user'];
1792
-
1793
- if($rule['operator'] == "==")
1794
- {
1795
- if( user_can($ef_user, $rule['value']) || $rule['value'] == "all" )
1796
- {
1797
- return true;
1798
- }
1799
-
1800
- return false;
1801
- }
1802
- elseif($rule['operator'] == "!=")
1803
- {
1804
- if( user_can($ef_user, $rule['value']) || $rule['value'] == "all" )
1805
- {
1806
- return true;
1807
- }
1808
-
1809
- return false;
1810
- }
1811
-
1812
-
1813
- break;
1814
-
1815
- // Everything Fields: Media
1816
- case "ef_media":
1817
-
1818
- if( !isset($overrides['ef_media']) )
1819
- {
1820
- return false;
1821
- }
1822
-
1823
- $ef_media = $overrides['ef_media'];
1824
-
1825
- if($rule['operator'] == "==")
1826
- {
1827
- if( $rule['value'] == "all" )
1828
- {
1829
- return true;
1830
- }
1831
-
1832
- return false;
1833
- }
1834
- elseif($rule['operator'] == "!=")
1835
- {
1836
- if( $rule['value'] == "all" )
1837
- {
1838
- return true;
1839
- }
1840
-
1841
- return false;
1842
- }
1843
-
1844
-
1845
- break;
1846
- }
1847
 
1848
  }
1849
 
@@ -2129,5 +1557,58 @@ class Acf
2129
  }
2130
 
2131
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2132
  }
2133
  ?>
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: 3.5.7.2
7
  Author: Elliot Condon
8
  Author URI: http://www.elliotcondon.com/
9
  License: GPL
33
  $input,
34
  $options_page,
35
  $everything_fields,
36
+ $third_party,
37
+ $location;
38
 
39
 
40
  /*
51
  // vars
52
  $this->path = plugin_dir_path(__FILE__);
53
  $this->dir = plugins_url('',__FILE__);
54
+ $this->version = '3.5.7.2';
55
  $this->upgrade_version = '3.4.1'; // this is the latest version which requires an upgrade
56
  $this->cache = array(); // basic array cache to hold data throughout the page load
57
  $this->defaults = array(
90
  add_filter('acf_parse_value', array($this, 'acf_parse_value'));
91
 
92
 
 
 
 
 
93
  return true;
94
  }
95
 
371
  // Third Party Compatibility
372
  include_once('core/controllers/third_party.php');
373
  $this->third_party = new acf_third_party($this);
374
+
375
+
376
+ // Location
377
+ include_once('core/controllers/location.php');
378
+ $this->location = new acf_location($this);
379
  }
380
 
381
 
715
  $field = apply_filters( 'acf_parse_value', $field );
716
 
717
 
718
+ // trim name
719
+ $field['name'] = trim( $field['name'] );
720
+
721
+
722
  return $field;
723
  }
724
 
747
  // numbers
748
  if( is_numeric($value) )
749
  {
750
+ // float / int
751
+ if( strpos($value,'.') !== false )
752
+ {
753
+ $value = floatval( $value );
754
+ }
755
+ else
756
+ {
757
+ $value = intval( $value );
758
+ }
759
  }
760
  }
761
 
1151
  *
1152
  *-------------------------------------------------------------------------------------*/
1153
 
1154
+ function get_input_metabox_ids( $options = array() )
1155
  {
1156
+ // vars
1157
+ $defaults = array(
1158
+ 'post_id' => 0,
1159
+ 'post_type' => 0,
1160
+ 'page_template' => 0,
1161
+ 'page_parent' => 0,
1162
+ 'page_type' => 0,
1163
+ 'page' => 0,
1164
+ 'post' => 0,
1165
+ 'post_category' => 0,
1166
+ 'post_format' => 0,
1167
+ 'taxonomy' => 0,
1168
+ 'lang' => 0,
1169
+ 'return' => 'php'
1170
+ );
1171
+
1172
+
1173
+ // merge in $options
1174
+ $options = array_merge($defaults, $options);
1175
+
1176
+
1177
+ // merge in $_POST
1178
+ if( isset($_POST) )
1179
  {
1180
+ $options = array_merge($options, $_POST);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1181
  }
1182
 
1183
 
1184
  // Parse values
1185
+ $options = apply_filters( 'acf_parse_value', $options );
1186
 
1187
 
1188
  // WPML
1189
+ if( $options['lang'] )
1190
  {
1191
  global $sitepress;
1192
+ $sitepress->switch_lang( $options['lang'] );
1193
  }
1194
 
1195
 
 
 
 
 
1196
  // find all acf objects
1197
  $acfs = $this->get_field_groups();
1198
 
1200
  // blank array to hold acfs
1201
  $return = array();
1202
 
1203
+
1204
+ if( $acfs )
1205
  {
1206
+ foreach( $acfs as $acf )
1207
  {
1208
+ // vars
1209
  $add_box = false;
1210
+
1211
+
1212
+ // if all of the rules are required to match, start at true and let any !$match set $add_box to false
1213
+ if( $acf['location']['allorany'] == 'all' )
1214
  {
 
1215
  $add_box = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1216
  }
1217
+
1218
+
1219
+ if( $acf['location']['rules'] )
1220
  {
1221
+ // defaults
1222
+ $rule_defaults = array(
1223
+ 'param' => '',
1224
+ 'operator' => '==',
1225
+ 'value' => ''
1226
+ );
1227
 
1228
+ foreach($acf['location']['rules'] as $rule)
1229
  {
1230
+ // make sure rule has all 3 keys
1231
+ $rule = array_merge( $rule_defaults, $rule );
1232
+
1233
+
1234
+ // $match = true / false
1235
+ $match = false;
1236
+ $match = apply_filters( 'acf/location_rules/match/' . $rule['param'] , $match, $rule, $options );
1237
+
1238
+
1239
+ if( $acf['location']['allorany'] == 'all' && !$match )
1240
  {
1241
+ // if all of the rules are required to match and this rule did not, don't add this box!
1242
+ $add_box = false;
 
 
 
1243
  }
1244
+ elseif($acf['location']['allorany'] == 'any' && $match )
1245
+ {
1246
+ // if any of the rules are required to match and this rule did, add this box!
1247
+ $add_box = true;
1248
+ }
1249
+
1250
+
1251
  }
1252
  }
1253
+
1254
+
1255
+ // add ID to array
1256
+ if( $add_box )
1257
  {
1258
  $return[] = $acf['id'];
1259
  }
1261
  }
1262
  }
1263
 
1264
+
1265
+ // if json
1266
+ if( $options['return'] == 'json' )
1267
  {
1268
  echo json_encode($return);
1269
  die;
1270
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1271
 
1272
 
1273
+ // not json, normal return
1274
+ return $return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1275
 
1276
  }
1277
 
1557
  }
1558
 
1559
 
1560
+ /*
1561
+ * get_next_field_id
1562
+ *
1563
+ * @description:
1564
+ * @since: 3.5.5
1565
+ * @created: 31/12/12
1566
+ */
1567
+
1568
+ function get_next_field_id()
1569
+ {
1570
+ // vars
1571
+ global $wpdb;
1572
+ $exists = true;
1573
+
1574
+
1575
+ // get next id
1576
+ $next_id = intval( get_option('acf_next_field_id', 1) );
1577
+
1578
+
1579
+ // while doesnt exist
1580
+ while( $exists == true )
1581
+ {
1582
+ // get field from postmeta
1583
+ $row = $wpdb->get_row($wpdb->prepare(
1584
+ "
1585
+ SELECT meta_id
1586
+ FROM $wpdb->postmeta
1587
+ WHERE meta_key = %s
1588
+ ",
1589
+ 'field_' . $next_id
1590
+ ), ARRAY_A );
1591
+
1592
+
1593
+ // loop again or break through?
1594
+ if( ! $row )
1595
+ {
1596
+ $exists = false;
1597
+ }
1598
+ else
1599
+ {
1600
+ $next_id++;
1601
+ }
1602
+ }
1603
+
1604
+
1605
+ // update the acf_next_field_id
1606
+ update_option('acf_next_field_id', ($next_id + 1) );
1607
+
1608
+
1609
+ // return
1610
+ return $next_id;
1611
+ }
1612
+
1613
  }
1614
  ?>
core/api.php CHANGED
@@ -587,6 +587,7 @@ function acf_form_head()
587
  do_action('acf_print_scripts-input');
588
  do_action('acf_print_styles-input');
589
 
 
590
  // need wp styling
591
  wp_enqueue_style(array(
592
  'colors-fresh'
@@ -600,20 +601,6 @@ function acf_form_head()
600
 
601
  function acf_form_wp_head()
602
  {
603
- // global vars
604
- global $post, $acf;
605
-
606
-
607
- // Style
608
- echo '<link rel="stylesheet" type="text/css" href="'.$acf->dir.'/css/global.css?ver=' . $acf->version . '" />';
609
- echo '<link rel="stylesheet" type="text/css" href="'.$acf->dir.'/css/input.css?ver=' . $acf->version . '" />';
610
-
611
-
612
- // Javascript
613
- echo '<script type="text/javascript" src="'.$acf->dir.'/js/input-actions.js?ver=' . $acf->version . '" ></script>';
614
-
615
-
616
-
617
  // add user js + css
618
  do_action('acf_head-input');
619
  }
@@ -660,9 +647,14 @@ function acf_form($options = null)
660
 
661
 
662
  // register post box
663
- if(!$options['field_groups'])
664
  {
665
- $options['field_groups'] = $acf->get_input_metabox_ids(array('post_id' => $options['post_id']), false);
 
 
 
 
 
666
  }
667
 
668
 
587
  do_action('acf_print_scripts-input');
588
  do_action('acf_print_styles-input');
589
 
590
+
591
  // need wp styling
592
  wp_enqueue_style(array(
593
  'colors-fresh'
601
 
602
  function acf_form_wp_head()
603
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
604
  // add user js + css
605
  do_action('acf_head-input');
606
  }
647
 
648
 
649
  // register post box
650
+ if( !$options['field_groups'] )
651
  {
652
+ // get field groups
653
+ $filter = array(
654
+ 'post_id' => $options['post_id']
655
+ );
656
+ $options['field_groups'] = array();
657
+ $options['field_groups'] = apply_filters( 'acf/location/match_field_groups', $options['field_groups'], $filter );
658
  }
659
 
660
 
core/controllers/everything_fields.php CHANGED
@@ -192,8 +192,9 @@ class acf_everything_fields
192
  }
193
 
194
 
195
- // find metabox id's for this page
196
- $this->data['metabox_ids'] = $this->parent->get_input_metabox_ids( $options , false );
 
197
 
198
 
199
  // dont continue if no ids were found
192
  }
193
 
194
 
195
+ // get field groups
196
+ $metabox_ids = array();
197
+ $this->data['metabox_ids'] = apply_filters( 'acf/location/match_field_groups', $metabox_ids, $options );
198
 
199
 
200
  // dont continue if no ids were found
core/controllers/field_group.php CHANGED
@@ -559,6 +559,12 @@ class acf_field_group
559
 
560
  }
561
 
 
 
 
 
 
 
562
  $this->parent->create_field(array(
563
  'type' => 'select',
564
  'name' => 'location[rules][' . $options['key'] . '][value]',
@@ -742,16 +748,12 @@ class acf_field_group
742
  }
743
 
744
 
745
- // get next id
746
- $next_id = intval( get_option('acf_next_field_id', 1) );
747
-
748
-
749
- // update the acf_next_field_id
750
- update_option('acf_next_field_id', ($next_id + 1) );
751
 
752
 
753
- // return id
754
- die('field_' . $next_id);
755
  }
756
 
757
  }
559
 
560
  }
561
 
562
+
563
+ // allow custom location rules
564
+ $choices = apply_filters( 'acf/location/rule_values/' . $options['param'], $choices );
565
+
566
+
567
+ // create field
568
  $this->parent->create_field(array(
569
  'type' => 'select',
570
  'name' => 'location[rules][' . $options['key'] . '][value]',
748
  }
749
 
750
 
751
+ // return id
752
+ $id = $this->parent->get_next_field_id();
 
 
 
 
753
 
754
 
755
+ // die
756
+ die( 'field_' . $id );
757
  }
758
 
759
  }
core/controllers/input.php CHANGED
@@ -7,7 +7,6 @@
7
  * @since 3.2.6
8
  * @created: 23/06/12
9
  */
10
-
11
 
12
  class acf_input
13
  {
@@ -62,6 +61,7 @@ class acf_input
62
  // edit attachment hooks (used by image / file / gallery)
63
  add_action('admin_head-media.php', array($this, 'admin_head_media'));
64
  add_action('admin_head-upload.php', array($this, 'admin_head_upload'));
 
65
  }
66
 
67
 
@@ -185,13 +185,25 @@ class acf_input
185
  }
186
 
187
 
188
- // get style for page
189
- $metabox_ids = $this->parent->get_input_metabox_ids( array( 'post_id' => $post_id, 'post_type' => $typenow ), false);
190
- $style = isset($metabox_ids[0]) ? $this->get_input_style($metabox_ids[0]) : '';
191
- echo '<style type="text/css" id="acf_style" >' .$style . '</style>';
 
 
 
 
 
 
 
 
 
 
 
 
192
 
193
-
194
  // Style
 
195
  echo '<style type="text/css">.acf_postbox, .postbox[id*="acf_"] { display: none; }</style>';
196
 
197
 
7
  * @since 3.2.6
8
  * @created: 23/06/12
9
  */
 
10
 
11
  class acf_input
12
  {
61
  // edit attachment hooks (used by image / file / gallery)
62
  add_action('admin_head-media.php', array($this, 'admin_head_media'));
63
  add_action('admin_head-upload.php', array($this, 'admin_head_upload'));
64
+
65
  }
66
 
67
 
185
  }
186
 
187
 
188
+ // get field groups
189
+ $filter = array(
190
+ 'post_id' => $post_id,
191
+ 'post_type' => $typenow
192
+ );
193
+ $metabox_ids = array();
194
+ $metabox_ids = apply_filters( 'acf/location/match_field_groups', $metabox_ids, $filter );
195
+
196
+
197
+ // get style of first field group
198
+ $style = '';
199
+ if( isset($metabox_ids[0]) )
200
+ {
201
+ $style = $this->get_input_style( $metabox_ids[0] );
202
+ }
203
+
204
 
 
205
  // Style
206
+ echo '<style type="text/css" id="acf_style" >' . $style . '</style>';
207
  echo '<style type="text/css">.acf_postbox, .postbox[id*="acf_"] { display: none; }</style>';
208
 
209
 
core/controllers/location.php ADDED
@@ -0,0 +1,891 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * acf_location
5
+ *
6
+ * @description:
7
+ * @since: 3.5.7
8
+ * @created: 3/01/13
9
+ */
10
+
11
+ class acf_location
12
+ {
13
+
14
+ var $parent,
15
+ $data;
16
+
17
+ /*
18
+ * __construct
19
+ *
20
+ * @description:
21
+ * @since 3.1.8
22
+ * @created: 23/06/12
23
+ */
24
+
25
+ function __construct($parent)
26
+ {
27
+ // vars
28
+ $this->parent = $parent;
29
+
30
+
31
+ // ajax
32
+ add_action('wp_ajax_acf/location/match_field_groups_ajax', array($this, 'match_field_groups_ajax'));
33
+
34
+
35
+ // filters
36
+ add_filter('acf/location/match_field_groups', array($this, 'match_field_groups'), 10, 2);
37
+
38
+
39
+ // Basic
40
+ add_filter('acf/location/rule_match/post_type', array($this, 'rule_match_post_type'), 10, 3);
41
+ add_filter('acf/location/rule_match/user_type', array($this, 'rule_match_user_type'), 10, 3);
42
+
43
+ // Page
44
+ add_filter('acf/location/rule_match/page', array($this, 'rule_match_post'), 10, 3);
45
+ add_filter('acf/location/rule_match/page_type', array($this, 'rule_match_page_type'), 10, 3);
46
+ add_filter('acf/location/rule_match/page_parent', array($this, 'rule_match_page_parent'), 10, 3);
47
+ add_filter('acf/location/rule_match/page_template', array($this, 'rule_match_page_template'), 10, 3);
48
+
49
+ // Post
50
+ add_filter('acf/location/rule_match/post', array($this, 'rule_match_post'), 10, 3);
51
+ add_filter('acf/location/rule_match/post_category', array($this, 'rule_match_post_category'), 10, 3);
52
+ add_filter('acf/location/rule_match/post_format', array($this, 'rule_match_post_format'), 10, 3);
53
+ add_filter('acf/location/rule_match/taxonomy', array($this, 'rule_match_taxonomy'), 10, 3);
54
+
55
+ // Other
56
+ add_filter('acf/location/rule_match/ef_taxonomy', array($this, 'rule_match_ef_taxonomy'), 10, 3);
57
+ add_filter('acf/location/rule_match/ef_user', array($this, 'rule_match_ef_user'), 10, 3);
58
+ add_filter('acf/location/rule_match/ef_media', array($this, 'rule_match_ef_media'), 10, 3);
59
+
60
+ // Options Page
61
+ add_filter('acf/location/rule_match/options_page', array($this, 'rule_match_options_page'), 10, 3);
62
+
63
+
64
+
65
+ }
66
+
67
+
68
+ /*
69
+ * match_field_groups_ajax
70
+ *
71
+ * @description:
72
+ * @since: 3.5.7
73
+ * @created: 3/01/13
74
+ */
75
+
76
+ function match_field_groups_ajax()
77
+ {
78
+
79
+ // vars
80
+ $options = array(
81
+ 'nonce' => '',
82
+ 'return' => 'json'
83
+ );
84
+
85
+
86
+ // load post options
87
+ $options = array_merge($options, $_POST);
88
+
89
+
90
+ // verify nonce
91
+ if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') )
92
+ {
93
+ die(0);
94
+ }
95
+
96
+
97
+ // return array
98
+ $return = array();
99
+ $return = apply_filters( 'acf/location/match_field_groups', $return, $options );
100
+
101
+
102
+ // echo json
103
+ echo json_encode( $return );
104
+
105
+
106
+ die();
107
+ }
108
+
109
+
110
+ /*
111
+ * match_field_groups
112
+ *
113
+ * @description:
114
+ * @since: 3.5.7
115
+ * @created: 3/01/13
116
+ */
117
+
118
+ function match_field_groups( $return, $options )
119
+ {
120
+ // vars
121
+ $defaults = array(
122
+ 'post_id' => 0,
123
+ 'post_type' => 0,
124
+ 'page_template' => 0,
125
+ 'page_parent' => 0,
126
+ 'page_type' => 0,
127
+ 'post_category' => array(),
128
+ 'post_format' => 0,
129
+ 'taxonomy' => array(),
130
+ 'ef_taxonomy' => 0,
131
+ 'ef_user' => 0,
132
+ 'ef_media' => 0,
133
+ 'lang' => 0,
134
+ 'return' => 'php'
135
+ );
136
+
137
+
138
+ // merge in $options
139
+ $options = array_merge($defaults, $options);
140
+
141
+
142
+ // Parse values
143
+ $options = apply_filters( 'acf_parse_value', $options );
144
+
145
+
146
+ // WPML
147
+ if( defined('ICL_LANGUAGE_CODE') )
148
+ {
149
+ $options['lang'] = ICL_LANGUAGE_CODE;
150
+
151
+ //global $sitepress;
152
+ //$sitepress->switch_lang( $options['lang'] );
153
+ }
154
+
155
+
156
+ // find all acf objects
157
+ $acfs = apply_filters('acf/get_field_groups', false);
158
+
159
+
160
+ // blank array to hold acfs
161
+ $return = array();
162
+
163
+
164
+ if( $acfs )
165
+ {
166
+ foreach( $acfs as $acf )
167
+ {
168
+ // vars
169
+ $add_box = false;
170
+
171
+
172
+ // if all of the rules are required to match, start at true and let any !$match set $add_box to false
173
+ if( $acf['location']['allorany'] == 'all' )
174
+ {
175
+ $add_box = true;
176
+ }
177
+
178
+
179
+ if( $acf['location']['rules'] )
180
+ {
181
+ // defaults
182
+ $rule_defaults = array(
183
+ 'param' => '',
184
+ 'operator' => '==',
185
+ 'value' => ''
186
+ );
187
+
188
+ foreach($acf['location']['rules'] as $rule)
189
+ {
190
+ // make sure rule has all 3 keys
191
+ $rule = array_merge( $rule_defaults, $rule );
192
+
193
+
194
+ // $match = true / false
195
+ $match = false;
196
+ $match = apply_filters( 'acf/location/rule_match/' . $rule['param'] , $match, $rule, $options );
197
+
198
+
199
+ if( $acf['location']['allorany'] == 'all' && !$match )
200
+ {
201
+ // if all of the rules are required to match and this rule did not, don't add this box!
202
+ $add_box = false;
203
+ }
204
+ elseif($acf['location']['allorany'] == 'any' && $match )
205
+ {
206
+ // if any of the rules are required to match and this rule did, add this box!
207
+ $add_box = true;
208
+ }
209
+
210
+ }
211
+ }
212
+
213
+
214
+ // add ID to array
215
+ if( $add_box )
216
+ {
217
+ $return[] = $acf['id'];
218
+ }
219
+
220
+ }
221
+ }
222
+
223
+
224
+ return $return;
225
+ }
226
+
227
+
228
+ /*
229
+ * rule_match_post_type
230
+ *
231
+ * @description:
232
+ * @since: 3.5.7
233
+ * @created: 3/01/13
234
+ */
235
+
236
+ function rule_match_post_type( $match, $rule, $options )
237
+ {
238
+ $post_type = $options['post_type'];
239
+
240
+ if( !$post_type )
241
+ {
242
+ $post_type = get_post_type( $options['post_id'] );
243
+ }
244
+
245
+
246
+ if( $rule['operator'] == "==" )
247
+ {
248
+ $match = ( $post_type == $rule['value'] );
249
+ }
250
+ elseif( $rule['operator'] == "!=" )
251
+ {
252
+ $match = ( $post_type != $rule['value'] );
253
+ }
254
+
255
+
256
+ return $match;
257
+ }
258
+
259
+
260
+ /*
261
+ * rule_match_post
262
+ *
263
+ * @description:
264
+ * @since: 3.5.7
265
+ * @created: 3/01/13
266
+ */
267
+
268
+ function rule_match_post( $match, $rule, $options )
269
+ {
270
+ // validation
271
+ if( !$options['post_id'] )
272
+ {
273
+ return false;
274
+ }
275
+
276
+
277
+ // translate $rule['value']
278
+ // - this variable will hold the origional post_id, but $options['post_id'] will hold the translated version
279
+ //if( function_exists('icl_object_id') )
280
+ //{
281
+ // $rule['value'] = icl_object_id( $rule['value'], $options['post_type'], true );
282
+ //}
283
+
284
+
285
+ if($rule['operator'] == "==")
286
+ {
287
+ $match = ( $options['post_id'] == $rule['value'] );
288
+ }
289
+ elseif($rule['operator'] == "!=")
290
+ {
291
+ $match = ( $options['post_id'] != $rule['value'] );
292
+ }
293
+
294
+ return $match;
295
+
296
+ }
297
+
298
+
299
+ /*
300
+ * rule_match_page_type
301
+ *
302
+ * @description:
303
+ * @since: 3.5.7
304
+ * @created: 3/01/13
305
+ */
306
+
307
+ function rule_match_page_type( $match, $rule, $options )
308
+ {
309
+ // validation
310
+ if( !$options['post_id'] )
311
+ {
312
+ return false;
313
+ }
314
+
315
+ $post = get_post( $options['post_id'] );
316
+
317
+ if( $rule['value'] == 'front_page')
318
+ {
319
+
320
+ $front_page = (int) get_option('page_on_front');
321
+
322
+
323
+ if($rule['operator'] == "==")
324
+ {
325
+ $match = ( $front_page == $post->ID );
326
+ }
327
+ elseif($rule['operator'] == "!=")
328
+ {
329
+ $match = ( $front_page != $post->ID );
330
+ }
331
+
332
+ }
333
+ elseif( $rule['value'] == 'posts_page')
334
+ {
335
+
336
+ $posts_page = (int) get_option('page_for_posts');
337
+
338
+
339
+ if($rule['operator'] == "==")
340
+ {
341
+ $match = ( $posts_page == $post->ID );
342
+ }
343
+ elseif($rule['operator'] == "!=")
344
+ {
345
+ $match = ( $posts_page != $post->ID );
346
+ }
347
+
348
+ }
349
+ elseif( $rule['value'] == 'parent')
350
+ {
351
+
352
+ $children = get_pages(array(
353
+ 'post_type' => $post->post_type,
354
+ 'child_of' => $post->ID,
355
+ ));
356
+
357
+
358
+ if($rule['operator'] == "==")
359
+ {
360
+ $match = ( count($children) > 0 );
361
+ }
362
+ elseif($rule['operator'] == "!=")
363
+ {
364
+ $match = ( count($children) == 0 );
365
+ }
366
+
367
+ }
368
+ elseif( $rule['value'] == 'child')
369
+ {
370
+
371
+ $post_parent = $post->post_parent;
372
+ if( $options['page_parent'] )
373
+ {
374
+ $post_parent = $options['page_parent'];
375
+ }
376
+
377
+
378
+ if($rule['operator'] == "==")
379
+ {
380
+ $match = ( $post_parent != 0 );
381
+ }
382
+ elseif($rule['operator'] == "!=")
383
+ {
384
+ $match = ( $post_parent == 0 );
385
+ }
386
+
387
+ }
388
+
389
+ return $match;
390
+
391
+ }
392
+
393
+
394
+ /*
395
+ * rule_match_page_parent
396
+ *
397
+ * @description:
398
+ * @since: 3.5.7
399
+ * @created: 3/01/13
400
+ */
401
+
402
+ function rule_match_page_parent( $match, $rule, $options )
403
+ {
404
+ // validation
405
+ if( !$options['post_id'] )
406
+ {
407
+ return false;
408
+ }
409
+
410
+
411
+ // vars
412
+ $post = get_post( $options['post_id'] );
413
+ $page_parent = $post->post_parent;
414
+
415
+
416
+ if($rule['operator'] == "==")
417
+ {
418
+ $match = ( $page_parent == $rule['value'] );
419
+ }
420
+ elseif($rule['operator'] == "!=")
421
+ {
422
+ $match = ( $page_parent != $rule['value'] );
423
+ }
424
+
425
+ return $match;
426
+
427
+ }
428
+
429
+
430
+ /*
431
+ * rule_match_page_template
432
+ *
433
+ * @description:
434
+ * @since: 3.5.7
435
+ * @created: 3/01/13
436
+ */
437
+
438
+ function rule_match_page_template( $match, $rule, $options )
439
+ {
440
+ $page_template = $options['page_template'];
441
+ if( ! $page_template )
442
+ {
443
+ $page_template = get_post_meta( $options['post_id'], '_wp_page_template', true );
444
+ }
445
+
446
+
447
+ if( ! $page_template )
448
+ {
449
+ $post_type = $options['post_type'];
450
+
451
+ if( !$post_type )
452
+ {
453
+ $post_type = get_post_type( $options['post_id'] );
454
+ }
455
+
456
+ if( $post_type == 'page' )
457
+ {
458
+ $page_template = "default";
459
+ }
460
+ }
461
+
462
+
463
+
464
+ if($rule['operator'] == "==")
465
+ {
466
+ $match = ( $page_template == $rule['value'] );
467
+ }
468
+ elseif($rule['operator'] == "!=")
469
+ {
470
+ $match = ( $page_template != $rule['value'] );
471
+ }
472
+
473
+ return $match;
474
+
475
+ }
476
+
477
+
478
+ /*
479
+ * rule_match_post_category
480
+ *
481
+ * @description:
482
+ * @since: 3.5.7
483
+ * @created: 3/01/13
484
+ */
485
+
486
+ function rule_match_post_category( $match, $rule, $options )
487
+ {
488
+ $cats = $options['post_category'];
489
+
490
+ if( empty($cats) )
491
+ {
492
+ if( !$options['post_id'] )
493
+ {
494
+ return false;
495
+ }
496
+
497
+ $all_cats = get_the_category( $options['post_id'] );
498
+ foreach( $all_cats as $cat )
499
+ {
500
+ $cats[] = $cat->term_id;
501
+ }
502
+ }
503
+
504
+ $post_type = $options['post_type'];
505
+
506
+ if( !$post_type )
507
+ {
508
+ $post_type = get_post_type( $options['post_id'] );
509
+ }
510
+
511
+ $taxonomies = get_object_taxonomies( $post_type );
512
+
513
+
514
+
515
+ // If no $cats, this is a new post and should be treated as if it has the "Uncategorized" (1) category ticked
516
+ if( in_array('category', $taxonomies) && empty($cats) )
517
+ {
518
+ $cats[] = '1';
519
+ }
520
+
521
+
522
+ if($rule['operator'] == "==")
523
+ {
524
+ $match = false;
525
+
526
+ if($cats)
527
+ {
528
+ if( in_array($rule['value'], $cats) )
529
+ {
530
+ $match = true;
531
+ }
532
+ }
533
+
534
+ }
535
+ elseif($rule['operator'] == "!=")
536
+ {
537
+ $match = true;
538
+
539
+ if($cats)
540
+ {
541
+ if( in_array($rule['value'], $cats) )
542
+ {
543
+ $match = false;
544
+ }
545
+ }
546
+
547
+ }
548
+
549
+ return $match;
550
+
551
+ }
552
+
553
+
554
+ /*
555
+ * rule_match_user_type
556
+ *
557
+ * @description:
558
+ * @since: 3.5.7
559
+ * @created: 3/01/13
560
+ */
561
+
562
+ function rule_match_user_type( $match, $rule, $options )
563
+ {
564
+ if($rule['operator'] == "==")
565
+ {
566
+ $match = ( current_user_can($rule['value']) );
567
+ }
568
+ elseif($rule['operator'] == "!=")
569
+ {
570
+ $match = ( ! current_user_can($rule['value']) );
571
+ }
572
+
573
+ return $match;
574
+
575
+ }
576
+
577
+
578
+ /*
579
+ * rule_match_user_type
580
+ *
581
+ * @description:
582
+ * @since: 3.5.7
583
+ * @created: 3/01/13
584
+ */
585
+
586
+ function rule_match_options_page( $match, $rule, $options )
587
+ {
588
+ global $plugin_page;
589
+
590
+
591
+ // older location rules may be "options-pagename"
592
+ if( substr($rule['value'], 0, 8) == 'options-' )
593
+ {
594
+ $rule['value'] = 'acf-' . $rule['value'];
595
+ }
596
+
597
+
598
+ // older location ruels may be "Pagename"
599
+ if( substr($rule['value'], 0, 11) != 'acf-options' )
600
+ {
601
+ $rule['value'] = 'acf-options-' . sanitize_title( $rule['value'] );
602
+
603
+ // value may now be wrong (acf-options-options)
604
+ if( $rule['value'] == 'acf-options-options' )
605
+ {
606
+ $rule['value'] = 'acf-options';
607
+ }
608
+ }
609
+
610
+
611
+ if($rule['operator'] == "==")
612
+ {
613
+ $match = ( $plugin_page == $rule['value'] );
614
+ }
615
+ elseif($rule['operator'] == "!=")
616
+ {
617
+ $match = ( $plugin_page != $rule['value'] );
618
+ }
619
+
620
+
621
+ return $match;
622
+
623
+ }
624
+
625
+
626
+ /*
627
+ * rule_match_post_format
628
+ *
629
+ * @description:
630
+ * @since: 3.5.7
631
+ * @created: 3/01/13
632
+ */
633
+
634
+ function rule_match_post_format( $match, $rule, $options )
635
+ {
636
+ // vars
637
+ $post_format = $options['post_format'];
638
+ if( ! $post_format )
639
+ {
640
+ $post_format = get_post_format( $options['post_id'] );
641
+ }
642
+
643
+
644
+ if($rule['operator'] == "==")
645
+ {
646
+ $match = ( $post_format == $rule['value'] );
647
+ }
648
+ elseif($rule['operator'] == "!=")
649
+ {
650
+ $match = ( $post_format != $rule['value'] );
651
+ }
652
+
653
+
654
+ return $match;
655
+
656
+ }
657
+
658
+
659
+ /*
660
+ * rule_match_taxonomy
661
+ *
662
+ * @description:
663
+ * @since: 3.5.7
664
+ * @created: 3/01/13
665
+ */
666
+
667
+ function rule_match_taxonomy( $match, $rule, $options )
668
+ {
669
+ $terms = $options['taxonomy'];
670
+
671
+
672
+ if( empty($terms) )
673
+ {
674
+ if( !$options['post_id'] )
675
+ {
676
+ return false;
677
+ }
678
+
679
+ $post_type = $options['post_type'];
680
+
681
+ if( !$post_type )
682
+ {
683
+ $post_type = get_post_type( $options['post_id'] );
684
+ }
685
+
686
+ $taxonomies = get_object_taxonomies( $post_type );
687
+
688
+ if($taxonomies)
689
+ {
690
+ foreach($taxonomies as $tax)
691
+ {
692
+ $all_terms = get_the_terms( $options['post_id'], $tax );
693
+ if($all_terms)
694
+ {
695
+ foreach($all_terms as $all_term)
696
+ {
697
+ $terms[] = $all_term->term_id;
698
+ }
699
+ }
700
+ }
701
+ }
702
+ }
703
+
704
+
705
+ // If no $cats, this is a new post and should be treated as if it has the "Uncategorized" (1) category ticked
706
+ if( in_array('category', $taxonomies) && empty($terms) )
707
+ {
708
+ $terms[] = '1';
709
+ }
710
+
711
+
712
+ if($rule['operator'] == "==")
713
+ {
714
+ $match = false;
715
+
716
+ if($terms)
717
+ {
718
+ if( in_array($rule['value'], $terms) )
719
+ {
720
+ $match = true;
721
+ }
722
+ }
723
+
724
+ }
725
+ elseif($rule['operator'] == "!=")
726
+ {
727
+ $match = true;
728
+
729
+ if($terms)
730
+ {
731
+ if( in_array($rule['value'], $terms) )
732
+ {
733
+ $match = false;
734
+ }
735
+ }
736
+
737
+ }
738
+
739
+
740
+ return $match;
741
+
742
+ }
743
+
744
+
745
+ /*
746
+ * rule_match_ef_taxonomy
747
+ *
748
+ * @description:
749
+ * @since: 3.5.7
750
+ * @created: 3/01/13
751
+ */
752
+
753
+ function rule_match_ef_taxonomy( $match, $rule, $options )
754
+ {
755
+
756
+ $ef_taxonomy = $options['ef_taxonomy'];
757
+
758
+
759
+ if( $ef_taxonomy )
760
+ {
761
+ if($rule['operator'] == "==")
762
+ {
763
+ $match = ( $ef_taxonomy == $rule['value'] );
764
+
765
+ // override for "all"
766
+ if( $rule['value'] == "all" )
767
+ {
768
+ $match = true;
769
+ }
770
+
771
+ }
772
+ elseif($rule['operator'] == "!=")
773
+ {
774
+ $match = ( $ef_taxonomy != $rule['value'] );
775
+
776
+ // override for "all"
777
+ if( $rule['value'] == "all" )
778
+ {
779
+ $match = false;
780
+ }
781
+
782
+ }
783
+
784
+
785
+
786
+
787
+ }
788
+
789
+
790
+ return $match;
791
+
792
+ }
793
+
794
+
795
+ /*
796
+ * rule_match_ef_user
797
+ *
798
+ * @description:
799
+ * @since: 3.5.7
800
+ * @created: 3/01/13
801
+ */
802
+
803
+ function rule_match_ef_user( $match, $rule, $options )
804
+ {
805
+
806
+ $ef_user = $options['ef_user'];
807
+
808
+
809
+ if( $ef_user )
810
+ {
811
+ if($rule['operator'] == "==")
812
+ {
813
+ $match = ( user_can($ef_user, $rule['value']) );
814
+
815
+ // override for "all"
816
+ if( $rule['value'] == "all" )
817
+ {
818
+ $match = true;
819
+ }
820
+ }
821
+ elseif($rule['operator'] == "!=")
822
+ {
823
+ $match = ( !user_can($ef_user, $rule['value']) );
824
+
825
+ // override for "all"
826
+ if( $rule['value'] == "all" )
827
+ {
828
+ $match = false;
829
+ }
830
+ }
831
+
832
+ }
833
+
834
+
835
+ return $match;
836
+
837
+ }
838
+
839
+
840
+ /*
841
+ * rule_match_ef_media
842
+ *
843
+ * @description:
844
+ * @since: 3.5.7
845
+ * @created: 3/01/13
846
+ */
847
+
848
+ function rule_match_ef_media( $match, $rule, $options )
849
+ {
850
+ global $pagenow;
851
+
852
+
853
+ if( $pagenow == 'post.php' )
854
+ {
855
+ // in 3.5, the media rule should check the post type
856
+ $rule['param'] = 'post_type';
857
+ $rule['value'] = 'attachment';
858
+ return $this->rule_match_post_type( $match, $rule, $options );
859
+ }
860
+
861
+
862
+ $ef_media = $options['ef_media'];
863
+
864
+ if( $ef_media )
865
+ {
866
+ if($rule['operator'] == "==")
867
+ {
868
+ // override for "all"
869
+ if( $rule['value'] == "all" )
870
+ {
871
+ $match = true;
872
+ }
873
+ }
874
+ elseif($rule['operator'] == "!=")
875
+ {
876
+ // override for "all"
877
+ if( $rule['value'] == "all" )
878
+ {
879
+ $match = false;
880
+ }
881
+ }
882
+
883
+ }
884
+
885
+ return $match;
886
+
887
+ }
888
+
889
+ }
890
+
891
+ ?>
core/controllers/options_page.php CHANGED
@@ -132,7 +132,10 @@ class acf_options_page
132
  }
133
 
134
 
135
- $metabox_ids = $this->parent->get_input_metabox_ids(false, false);
 
 
 
136
 
137
 
138
  if(empty($metabox_ids))
132
  }
133
 
134
 
135
+ // get field groups
136
+ $filter = array();
137
+ $metabox_ids = array();
138
+ $metabox_ids = apply_filters( 'acf/location/match_field_groups', $metabox_ids, $filter );
139
 
140
 
141
  if(empty($metabox_ids))
core/controllers/third_party.php CHANGED
@@ -35,11 +35,17 @@ class acf_third_party
35
 
36
 
37
  // Duplicate Post - http://wordpress.org/extend/plugins/duplicate-post/
38
- add_action( 'dp_duplicate_page', array($this, 'dp_duplicate_page'), 11, 2);
39
 
40
 
41
  // Post Type Switcher - http://wordpress.org/extend/plugins/post-type-switcher/
42
  add_filter('pts_post_type_filter', array($this, 'pts_post_type_filter'));
 
 
 
 
 
 
43
  }
44
 
45
 
@@ -228,6 +234,45 @@ class acf_third_party
228
 
229
  return $field;
230
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
 
232
  }
233
 
35
 
36
 
37
  // Duplicate Post - http://wordpress.org/extend/plugins/duplicate-post/
38
+ add_action('dp_duplicate_page', array($this, 'dp_duplicate_page'), 11, 2);
39
 
40
 
41
  // Post Type Switcher - http://wordpress.org/extend/plugins/post-type-switcher/
42
  add_filter('pts_post_type_filter', array($this, 'pts_post_type_filter'));
43
+
44
+
45
+ // WordPres Importer
46
+ add_filter('import_post_meta_key', array($this, 'import_post_meta_key'), 10, 1);
47
+ add_action('import_post_meta', array($this, 'import_post_meta'), 10, 3);
48
+
49
  }
50
 
51
 
234
 
235
  return $field;
236
  }
237
+
238
+
239
+ /*
240
+ * import_post_meta
241
+ *
242
+ * @description:
243
+ * @since: 3.5.5
244
+ * @created: 31/12/12
245
+ */
246
+
247
+ function import_post_meta_key( $meta_key )
248
+ {
249
+ if( strpos($meta_key, 'field_') !== false )
250
+ {
251
+ $meta_key = 'field_' . $this->parent->get_next_field_id();
252
+ }
253
+
254
+ return $meta_key;
255
+ }
256
+
257
+
258
+ /*
259
+ * import_post_meta
260
+ *
261
+ * @description:
262
+ * @since: 3.5.5
263
+ * @created: 1/01/13
264
+ */
265
+
266
+ function import_post_meta( $post_id, $key, $value )
267
+ {
268
+ if( strpos($key, 'field_') !== false )
269
+ {
270
+ $value['key'] = $key;
271
+
272
+ update_post_meta( $post_id, $key, $value );
273
+ }
274
+ }
275
+
276
 
277
  }
278
 
core/fields/file.php CHANGED
@@ -189,7 +189,7 @@ class acf_File extends acf_Field
189
  {
190
  // vars
191
  $defaults = array(
192
- 'save_format' => 'object',
193
  );
194
 
195
  $field = array_merge($defaults, $field);
189
  {
190
  // vars
191
  $defaults = array(
192
+ 'save_format' => 'id',
193
  );
194
 
195
  $field = array_merge($defaults, $field);
core/fields/image.php CHANGED
@@ -189,7 +189,7 @@ class acf_Image extends acf_Field
189
  {
190
  // vars
191
  $defaults = array(
192
- 'save_format' => 'object',
193
  'preview_size' => 'thumbnail',
194
  );
195
 
189
  {
190
  // vars
191
  $defaults = array(
192
+ 'save_format' => 'id',
193
  'preview_size' => 'thumbnail',
194
  );
195
 
core/fields/repeater.php CHANGED
@@ -77,10 +77,21 @@ class acf_Repeater extends acf_Field
77
  {
78
  for( $i = 0; $i < $field['row_min']; $i++ )
79
  {
80
- if( ! isset($field['value'][$i]) )
 
81
  {
82
- $field['value'][$i] = array();
83
  }
 
 
 
 
 
 
 
 
 
 
84
  }
85
  }
86
 
@@ -103,7 +114,7 @@ class acf_Repeater extends acf_Field
103
  foreach( $field['sub_fields'] as $sub_field)
104
  {
105
  $sub_value = isset($sub_field['default_value']) ? $sub_field['default_value'] : false;
106
- $field['value']['acfcloneindex'][$sub_field['name']] = $sub_value;
107
  }
108
 
109
  ?>
77
  {
78
  for( $i = 0; $i < $field['row_min']; $i++ )
79
  {
80
+ // already have a value? continue...
81
+ if( isset($field['value'][$i]) )
82
  {
83
+ continue;
84
  }
85
+
86
+ // populate values
87
+ $field['value'][$i] = array();
88
+
89
+ foreach( $field['sub_fields'] as $sub_field)
90
+ {
91
+ $sub_value = isset($sub_field['default_value']) ? $sub_field['default_value'] : false;
92
+ $field['value'][$i][ $sub_field['name'] ] = $sub_value;
93
+ }
94
+
95
  }
96
  }
97
 
114
  foreach( $field['sub_fields'] as $sub_field)
115
  {
116
  $sub_value = isset($sub_field['default_value']) ? $sub_field['default_value'] : false;
117
+ $field['value']['acfcloneindex'][ $sub_field['name'] ] = $sub_value;
118
  }
119
 
120
  ?>
core/fields/wysiwyg.php CHANGED
@@ -165,6 +165,9 @@ class acf_Wysiwyg extends acf_Field
165
 
166
  function create_field($field)
167
  {
 
 
 
168
  // vars
169
  $defaults = array(
170
  'toolbar' => 'full',
@@ -178,7 +181,7 @@ class acf_Wysiwyg extends acf_Field
178
  ?>
179
  <div id="wp-<?php echo $id; ?>-wrap" class="acf_wysiwyg wp-editor-wrap" data-toolbar="<?php echo $field['toolbar']; ?>">
180
  <?php if($field['media_upload'] == 'yes'): ?>
181
- <?php if(get_bloginfo('version') < "3.3"): ?>
182
  <div id="editor-toolbar">
183
  <div id="media-buttons" class="hide-if-no-js">
184
  <?php do_action( 'media_buttons' ); ?>
165
 
166
  function create_field($field)
167
  {
168
+ global $wp_version;
169
+
170
+
171
  // vars
172
  $defaults = array(
173
  'toolbar' => 'full',
181
  ?>
182
  <div id="wp-<?php echo $id; ?>-wrap" class="acf_wysiwyg wp-editor-wrap" data-toolbar="<?php echo $field['toolbar']; ?>">
183
  <?php if($field['media_upload'] == 'yes'): ?>
184
+ <?php if( version_compare($wp_version, '3.3', '<') ): ?>
185
  <div id="editor-toolbar">
186
  <div id="media-buttons" class="hide-if-no-js">
187
  <?php do_action( 'media_buttons' ); ?>
core/views/meta_box_location.php CHANGED
@@ -75,6 +75,11 @@ if( empty($location['rules']) )
75
  }
76
 
77
 
 
 
 
 
 
78
  $args = array(
79
  'type' => 'select',
80
  'name' => 'location[rules]['.$k.'][param]',
@@ -88,14 +93,22 @@ if( empty($location['rules']) )
88
  ?></td>
89
  <td class="operator"><?php
90
 
 
 
 
 
 
 
 
 
 
 
 
91
  $this->parent->create_field(array(
92
  'type' => 'select',
93
  'name' => 'location[rules]['.$k.'][operator]',
94
  'value' => $rule['operator'],
95
- 'choices' => array(
96
- '==' => __("is equal to",'acf'),
97
- '!=' => __("is not equal to",'acf'),
98
- )
99
  ));
100
 
101
  ?></td>
75
  }
76
 
77
 
78
+ // allow custom location rules
79
+ $choices = apply_filters( 'acf/location/rule_types', $choices );
80
+
81
+
82
+ // create field
83
  $args = array(
84
  'type' => 'select',
85
  'name' => 'location[rules]['.$k.'][param]',
93
  ?></td>
94
  <td class="operator"><?php
95
 
96
+ $choices = array(
97
+ '==' => __("is equal to",'acf'),
98
+ '!=' => __("is not equal to",'acf'),
99
+ );
100
+
101
+
102
+ // allow custom location rules
103
+ $choices = apply_filters( 'acf/location/rule_operators', $choices );
104
+
105
+
106
+ // create field
107
  $this->parent->create_field(array(
108
  'type' => 'select',
109
  'name' => 'location[rules]['.$k.'][operator]',
110
  'value' => $rule['operator'],
111
+ 'choices' => $choices
 
 
 
112
  ));
113
 
114
  ?></td>
css/global.css CHANGED
@@ -348,22 +348,15 @@ input[type="submit"].acf-button.grey:hover {
348
  }
349
 
350
  a.acf-button[disabled],
351
- .disabled a.acf-button,
352
  input[type="submit"].acf-button[disabled] {
353
  opacity: 0.7;
354
  }
355
 
356
  a.acf-button[disabled]:hover,
357
- .disabled a.acf-button:hover,
358
  input[type="submit"].acf-button[disabled]:hover {
359
- background: #2c8bbe;
360
- background-image: -webkit-gradient(linear, left top, left bottom, from(#2c8bbe), to(#246f99)); /* Safari 4+, Chrome */
361
- background-image: -webkit-linear-gradient(top, #2c8bbe, #246f99); /* Chrome 10+, Safari 5.1+, iOS 5+ */
362
- background-image: -moz-linear-gradient(top, #2c8bbe, #246f99); /* Firefox 3.6-15 */
363
- background-image: -o-linear-gradient(top, #2c8bbe, #246f99); /* Opera 11.10+ */
364
- background-image: linear-gradient(to bottom, #2c8bbe, #246f99); /* Firefox 16+ */
365
-
366
- box-shadow: 0 1px 3px rgba(0,0,0,0.2);
367
  }
368
 
369
 
348
  }
349
 
350
  a.acf-button[disabled],
351
+ a.acf-button.disabled,
352
  input[type="submit"].acf-button[disabled] {
353
  opacity: 0.7;
354
  }
355
 
356
  a.acf-button[disabled]:hover,
357
+ a.acf-button.disabled:hover,
358
  input[type="submit"].acf-button[disabled]:hover {
359
+
 
 
 
 
 
 
 
360
  }
361
 
362
 
js/fields.js CHANGED
@@ -99,6 +99,13 @@ var acf = {
99
  field.attr('data-type', val);
100
 
101
 
 
 
 
 
 
 
 
102
  // show field options if they already exist
103
  if( tbody.children( 'tr.field_option_' + val ).exists() )
104
  {
99
  field.attr('data-type', val);
100
 
101
 
102
+ // tab - override field_name
103
+ if( val == 'tab' )
104
+ {
105
+ tbody.find('tr.field_name input[type="text"]').val('').trigger('keyup');
106
+ }
107
+
108
+
109
  // show field options if they already exist
110
  if( tbody.children( 'tr.field_option_' + val ).exists() )
111
  {
js/input-actions.js CHANGED
@@ -161,6 +161,13 @@ var acf = {
161
  div.data('validation', true);
162
 
163
 
 
 
 
 
 
 
 
164
  // text / textarea
165
  if( div.find('input[type="text"], input[type="number"], input[type="hidden"], textarea').val() == "" )
166
  {
@@ -1190,11 +1197,14 @@ var acf = {
1190
  if( row_count >= max_rows )
1191
  {
1192
  repeater.addClass('disabled');
 
1193
  }
1194
  else
1195
  {
1196
  repeater.removeClass('disabled');
 
1197
  }
 
1198
  }
1199
 
1200
 
@@ -1314,7 +1324,7 @@ var acf = {
1314
 
1315
 
1316
  // add row - before
1317
- $('.repeater .add-row-before').live('click', function(){
1318
 
1319
  var repeater = $(this).closest('.repeater'),
1320
  before = $(this).closest('tr');
@@ -1369,7 +1379,7 @@ var acf = {
1369
 
1370
 
1371
  // remove field
1372
- $('.repeater .acf-button-remove').live('click', function(){
1373
  var tr = $(this).closest('tr');
1374
  repeater_remove_row( tr );
1375
  return false;
@@ -2037,8 +2047,7 @@ var acf = {
2037
  var a = $(this),
2038
  id = a.attr('data-id'),
2039
  ul = a.closest('ul'),
2040
- inside = ul.closest('.acf_postbox').children('.inside'),
2041
- field = inside.children('.field-' + id);
2042
 
2043
 
2044
  // classes
@@ -2051,7 +2060,7 @@ var acf = {
2051
 
2052
  var tab = $(this);
2053
 
2054
- if( tab.attr('id') == field.attr('id') )
2055
  {
2056
  tab.nextUntil('.field-tab').removeClass('acf-tab_group-hide').addClass('acf-tab_group-show');
2057
  }
161
  div.data('validation', true);
162
 
163
 
164
+ // if is hidden by conditional logic, ignore
165
+ if( div.hasClass('acf-conditional_logic-hide') )
166
+ {
167
+ return;
168
+ }
169
+
170
+
171
  // text / textarea
172
  if( div.find('input[type="text"], input[type="number"], input[type="hidden"], textarea').val() == "" )
173
  {
1197
  if( row_count >= max_rows )
1198
  {
1199
  repeater.addClass('disabled');
1200
+ repeater.find('> .repeater-footer .acf-button').addClass('disabled');
1201
  }
1202
  else
1203
  {
1204
  repeater.removeClass('disabled');
1205
+ repeater.find('> .repeater-footer .acf-button').removeClass('disabled');
1206
  }
1207
+
1208
  }
1209
 
1210
 
1324
 
1325
 
1326
  // add row - before
1327
+ $('.repeater td.remove .add-row-before').live('click', function(){
1328
 
1329
  var repeater = $(this).closest('.repeater'),
1330
  before = $(this).closest('tr');
1379
 
1380
 
1381
  // remove field
1382
+ $('.repeater td.remove .acf-button-remove').live('click', function(){
1383
  var tr = $(this).closest('tr');
1384
  repeater_remove_row( tr );
1385
  return false;
2047
  var a = $(this),
2048
  id = a.attr('data-id'),
2049
  ul = a.closest('ul'),
2050
+ inside = ul.closest('.acf_postbox').children('.inside');
 
2051
 
2052
 
2053
  // classes
2060
 
2061
  var tab = $(this);
2062
 
2063
+ if( tab.hasClass('field-' + id) )
2064
  {
2065
  tab.nextUntil('.field-tab').removeClass('acf-tab_group-hide').addClass('acf-tab_group-show');
2066
  }
js/input-ajax.js CHANGED
@@ -30,16 +30,17 @@
30
  */
31
 
32
  acf.data = {
33
- action : 'get_input_metabox_ids',
34
- post_id : 0,
35
- page_template : false,
36
- page_parent : 0,
37
- page_type : false,
38
- page : 0,
39
- post : 0,
40
- post_category : false,
41
- post_format : false,
42
- taxonomy : false
 
43
  };
44
 
45
 
@@ -55,8 +56,7 @@
55
 
56
  // update post_id
57
  acf.data.post_id = acf.post_id;
58
- acf.data.page = acf.post_id;
59
- acf.data.post = acf.post_id;
60
 
61
 
62
  // MPML
@@ -91,13 +91,20 @@
91
  dataType: 'json',
92
  success: function(result){
93
 
 
 
 
 
 
 
 
94
  // hide all metaboxes
95
  $('#poststuff .acf_postbox').addClass('acf-hidden');
96
  $('#adv-settings .acf_hide_label').hide();
97
 
98
 
99
  // dont bother loading style or html for inputs
100
- if(result.length == 0)
101
  {
102
  return false;
103
  }
@@ -197,7 +204,15 @@
197
 
198
  $('#post-formats-select input[type="radio"]').live('change', function(){
199
 
200
- acf.data.post_format = $(this).val();
 
 
 
 
 
 
 
 
201
  update_fields();
202
 
203
  });
@@ -208,11 +223,11 @@
208
 
209
 
210
  // vars
211
- var values = ['0'];
212
 
213
 
214
  $('.categorychecklist input[type="checkbox"]:checked').each(function(){
215
- values.push($(this).val());
216
  });
217
 
218
 
30
  */
31
 
32
  acf.data = {
33
+ 'action' : 'acf/location/match_field_groups_ajax',
34
+ 'post_id' : 0,
35
+ 'page_template' : 0,
36
+ 'page_parent' : 0,
37
+ 'page_type' : 0,
38
+ 'post_category' : 0,
39
+ 'post_format' : 0,
40
+ 'taxonomy' : 0,
41
+ 'lang' : 0,
42
+ 'nonce' : 0,
43
+ 'return' : 'json'
44
  };
45
 
46
 
56
 
57
  // update post_id
58
  acf.data.post_id = acf.post_id;
59
+ acf.data.nonce = acf.nonce;
 
60
 
61
 
62
  // MPML
91
  dataType: 'json',
92
  success: function(result){
93
 
94
+ // validate
95
+ if( !result )
96
+ {
97
+ return false;
98
+ }
99
+
100
+
101
  // hide all metaboxes
102
  $('#poststuff .acf_postbox').addClass('acf-hidden');
103
  $('#adv-settings .acf_hide_label').hide();
104
 
105
 
106
  // dont bother loading style or html for inputs
107
+ if( result.length == 0 )
108
  {
109
  return false;
110
  }
204
 
205
  $('#post-formats-select input[type="radio"]').live('change', function(){
206
 
207
+ var val = $(this).val();
208
+
209
+ if( val == '0' )
210
+ {
211
+ val = 'standard';
212
+ }
213
+
214
+ acf.data.post_format = val;
215
+
216
  update_fields();
217
 
218
  });
223
 
224
 
225
  // vars
226
+ var values = [];
227
 
228
 
229
  $('.categorychecklist input[type="checkbox"]:checked').each(function(){
230
+ values.push( $(this).val() );
231
  });
232
 
233
 
readme.txt CHANGED
@@ -90,6 +90,23 @@ http://support.advancedcustomfields.com/
90
 
91
  == Changelog ==
92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  = 3.5.6.3 =
94
  * [Fixed] Fix bug with 3.5.6 not showing front end form
95
 
90
 
91
  == Changelog ==
92
 
93
+ = 3.5.7.2 =
94
+ * [Fixed] Fix fields not showing on attachment edit page in WP 3.5 - http://support.advancedcustomfields.com/discussion/4261/after-upgrading-to-3-5-acf-fields-assigned-to-show-on-attachments-media-edit-are-not-showing
95
+ * [Fixed] Fix sub repeater css bug - http://support.advancedcustomfields.com/discussion/4361/repeater-add-button-inappropriately-disabled
96
+ * [Fixed] Fix issue where acf_form includes scripts twice - http://support.advancedcustomfields.com/discussion/4372/afc-repeater-on-front-end
97
+ * [Fixed] Fix location rule bug with new shopp product - http://support.advancedcustomfields.com/discussion/4406/shopp-idnew-product-page-doesn039t-have-acf-fields
98
+ * [Fixed] Fix location rule bug with taxonomy / post_taxonomy - http://support.advancedcustomfields.com/discussion/4407/taxonomy-rules-ignored-until-toggling-the-taxonomy
99
+
100
+ = 3.5.7.1 =
101
+ * [Fixed] Fix issues with location rules wrongly matching
102
+
103
+ = 3.5.7 =
104
+ * [Fixed] Fix sub field default value - http://support.advancedcustomfields.com/discussion/3706/select-field-default-value-not-working
105
+ * [Added] Add filters for custom location rules - http://support.advancedcustomfields.com/discussion/4285/how-to-retrieve-a-custom-field-within-the-function-php
106
+ * [Fixed] Fix XML import to create unique field ID's - http://support.advancedcustomfields.com/discussion/4328/check-acf_next_field_id-to-avoid-data-corruption
107
+ * [Fixed] Fix conditional logic with validation - http://support.advancedcustomfields.com/discussion/4295/issue-with-conditional-logic-and-obrigatory-fields
108
+ * [Fixed] Fix repeater + relationship bug - http://support.advancedcustomfields.com/discussion/4296/relationship-field-bug
109
+
110
  = 3.5.6.3 =
111
  * [Fixed] Fix bug with 3.5.6 not showing front end form
112