compatibility.php
132 lines
| 1 | <?php |
| 2 | |
| 3 | if(!defined('ABSPATH')) |
| 4 | exit; |
| 5 | |
| 6 | /** |
| 7 | * ACF Extended: 0.8 |
| 8 | * Settings: Renamed acfe_php* to acfe/php* |
| 9 | */ |
| 10 | if(acf_get_setting('acfe_php') !== null){ |
| 11 | acf_update_setting('acfe/php', acf_get_setting('acfe_php')); |
| 12 | } |
| 13 | |
| 14 | if(acf_get_setting('php_save') !== null){ |
| 15 | acf_update_setting('acfe/php_save', acf_get_setting('php_save')); |
| 16 | } |
| 17 | |
| 18 | if(acf_get_setting('php_load') !== null){ |
| 19 | acf_update_setting('acfe/php_load', acf_get_setting('php_load')); |
| 20 | } |
| 21 | |
| 22 | if(acf_get_setting('php_found') !== null){ |
| 23 | acf_update_setting('acfe/php_found', acf_get_setting('php_found')); |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * ACF Extended: 0.8 |
| 28 | * Field Group Location: Archive renamed to List |
| 29 | */ |
| 30 | add_filter('acf/validate_field_group', 'acfe_compatibility_field_group_location_list', 20); |
| 31 | function acfe_compatibility_field_group_location_list($field_group){ |
| 32 | |
| 33 | if(!acf_maybe_get($field_group, 'location')) |
| 34 | return $field_group; |
| 35 | |
| 36 | foreach($field_group['location'] as &$or){ |
| 37 | |
| 38 | foreach($or as &$and){ |
| 39 | |
| 40 | if(!isset($and['value'])) |
| 41 | continue; |
| 42 | |
| 43 | // Post Type List |
| 44 | if($and['param'] === 'post_type' && acfe_ends_with($and['value'], '_archive')){ |
| 45 | |
| 46 | $and['param'] = 'post_type_list'; |
| 47 | $and['value'] = substr_replace($and['value'], '', -8); |
| 48 | |
| 49 | } |
| 50 | |
| 51 | // Taxonomy List |
| 52 | elseif($and['param'] === 'taxonomy' && acfe_ends_with($and['value'], '_archive')){ |
| 53 | |
| 54 | $and['param'] = 'taxonomy_list'; |
| 55 | $and['value'] = substr_replace($and['value'], '', -8); |
| 56 | |
| 57 | } |
| 58 | |
| 59 | } |
| 60 | |
| 61 | } |
| 62 | |
| 63 | return $field_group; |
| 64 | |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * ACF Extended: 0.8 |
| 69 | * Field Filter Value: Removed from this version |
| 70 | */ |
| 71 | add_filter('acf/validate_field', 'acfe_compatibility_field_acfe_update', 20); |
| 72 | function acfe_compatibility_field_acfe_update($field){ |
| 73 | |
| 74 | if(!acf_maybe_get($field, 'acfe_update')) |
| 75 | return $field; |
| 76 | |
| 77 | unset($field['acfe_update']); |
| 78 | |
| 79 | return $field; |
| 80 | |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Plugin: Post Types Order |
| 85 | * https://wordpress.org/plugins/post-types-order/ |
| 86 | * The plugin apply custom order to 'acf-field-group' Post Type. We have to fix this |
| 87 | */ |
| 88 | add_filter('pto/posts_orderby/ignore', 'acfe_compatibility_pto_acf_field_group', 10, 3); |
| 89 | function acfe_compatibility_pto_acf_field_group($ignore, $orderby, $query){ |
| 90 | |
| 91 | if(is_admin() && $query->is_main_query() && $query->get('post_type') === 'acf-field-group') |
| 92 | $ignore = true; |
| 93 | |
| 94 | return $ignore; |
| 95 | |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Plugin: Category Order and Taxonomy Terms Order |
| 100 | * https://wordpress.org/plugins/taxonomy-terms-order/ |
| 101 | * The plugin add a submenu to 'Custom Fields' to order Field Group Categories. It's unecessary |
| 102 | */ |
| 103 | add_action('admin_menu', 'acfe_compatibility_cotto_submenu', 999); |
| 104 | function acfe_compatibility_cotto_submenu(){ |
| 105 | |
| 106 | remove_submenu_page('edit.php?post_type=acf-field-group', 'to-interface-acf-field-group'); |
| 107 | |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Plugin: Rank Math SEO |
| 112 | * https://wordpress.org/plugins/seo-by-rank-math/ |
| 113 | * Fix the plugin post metabox which is always above ACF metaboxes |
| 114 | */ |
| 115 | add_filter('rank_math/metabox/priority', 'acfe_compatibility_rankmath_metaboxes_priority'); |
| 116 | function acfe_compatibility_rankmath_metaboxes_priority(){ |
| 117 | |
| 118 | return 'default'; |
| 119 | |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * Plugin: YOAST SEO |
| 124 | * https://wordpress.org/plugins/wordpress-seo/ |
| 125 | * Fix the plugin post metabox which is always above ACF metaboxes |
| 126 | */ |
| 127 | add_filter('wpseo_metabox_prio', 'acfe_compatibility_yoast_metaboxes_priority'); |
| 128 | function acfe_compatibility_yoast_metaboxes_priority(){ |
| 129 | |
| 130 | return 'default'; |
| 131 | |
| 132 | } |