admin
4 years ago
field-groups
4 years ago
fields
4 years ago
fields-settings
4 years ago
forms
4 years ago
locations
4 years ago
modules
4 years ago
acfe-field-functions.php
4 years ago
acfe-field-group-functions.php
4 years ago
acfe-file-functions.php
4 years ago
acfe-form-functions.php
4 years ago
acfe-helper-functions.php
4 years ago
acfe-meta-functions.php
4 years ago
acfe-post-functions.php
4 years ago
acfe-screen-functions.php
4 years ago
acfe-template-functions.php
4 years ago
acfe-term-functions.php
4 years ago
acfe-user-functions.php
4 years ago
acfe-wp-functions.php
4 years ago
assets.php
4 years ago
compatibility.php
4 years ago
hooks.php
4 years ago
init.php
4 years ago
local-meta.php
4 years ago
multilang.php
4 years ago
settings.php
4 years ago
upgrades.php
4 years ago
compatibility.php
707 lines
| 1 | <?php |
| 2 | |
| 3 | use WPGraphQL\AppContext; |
| 4 | use WPGraphQL\Model\Term; |
| 5 | |
| 6 | if(!defined('ABSPATH')) |
| 7 | exit; |
| 8 | |
| 9 | if(!class_exists('acfe_compatibility')): |
| 10 | |
| 11 | class acfe_compatibility{ |
| 12 | |
| 13 | function __construct(){ |
| 14 | |
| 15 | add_action('acf/init', array($this, 'init'), 98); |
| 16 | add_action('after_plugin_row_' . ACFE_BASENAME, array($this, 'plugin_row'), 5, 3); |
| 17 | |
| 18 | add_filter('acfe/form/import_args', array($this, 'acfe_form_import_compatibility'), 10, 3); |
| 19 | add_filter('pto/posts_orderby/ignore', array($this, 'pto_acf_field_group'), 10, 3); |
| 20 | add_filter('pto/get_options', array($this, 'pto_options_acf_field_group')); |
| 21 | |
| 22 | add_action('admin_menu', array($this, 'cotto_submenu'), 999); |
| 23 | add_filter('rank_math/metabox/priority', array($this, 'rankmath_metaboxes_priority')); |
| 24 | add_filter('wpseo_metabox_prio', array($this, 'yoast_metaboxes_priority')); |
| 25 | add_filter('pll_get_post_types', array($this, 'polylang'), 10, 2); |
| 26 | add_action('elementor/documents/register_controls', array($this, 'elementor')); |
| 27 | add_filter('wpgraphql_acf_supported_fields', array($this, 'wpgraphql_supported_fields')); |
| 28 | add_filter('wpgraphql_acf_register_graphql_field', array($this, 'wpgraphql_register_field'), 10, 4); |
| 29 | |
| 30 | } |
| 31 | |
| 32 | function plugin_row($plugin_file, $plugin_data, $status){ |
| 33 | |
| 34 | // Bail early |
| 35 | if(acfe()->acf()) return; |
| 36 | |
| 37 | // Check WP version |
| 38 | $colspan = version_compare($GLOBALS['wp_version'], '5.5', '<') ? 3 : 4; |
| 39 | |
| 40 | ?> |
| 41 | <style> |
| 42 | .plugins tr[data-plugin='<?php echo ACFE_BASENAME; ?>'] th, |
| 43 | .plugins tr[data-plugin='<?php echo ACFE_BASENAME; ?>'] td{ |
| 44 | box-shadow:none; |
| 45 | } |
| 46 | |
| 47 | <?php if(isset($plugin_data['update']) && !empty($plugin_data['update'])){ ?> |
| 48 | |
| 49 | .plugins tr.acfe-plugin-tr td{ |
| 50 | box-shadow:none !important; |
| 51 | } |
| 52 | |
| 53 | .plugins tr.acfe-plugin-tr .update-message{ |
| 54 | margin-bottom:0; |
| 55 | } |
| 56 | |
| 57 | <?php } ?> |
| 58 | </style> |
| 59 | |
| 60 | <tr class="plugin-update-tr active acfe-plugin-tr"> |
| 61 | <td colspan="<?php echo $colspan; ?>" class="plugin-update colspanchange"> |
| 62 | <div class="update-message notice inline notice-error notice-alt"> |
| 63 | <p><?php _e('ACF Extended requires <a href="https://www.advancedcustomfields.com/pro/" target="_blank">Advanced Custom Fields PRO</a> (minimum: 5.8).', 'acfe'); ?></p> |
| 64 | </div> |
| 65 | </td> |
| 66 | </tr> |
| 67 | <?php |
| 68 | |
| 69 | } |
| 70 | |
| 71 | function init(){ |
| 72 | |
| 73 | $this->update_settings(); |
| 74 | |
| 75 | add_filter('acf/validate_field_group', array($this, 'field_group_location_list'), 20); |
| 76 | add_filter('acf/validate_field', array($this, 'field_acfe_update'), 20); |
| 77 | |
| 78 | add_filter('acf/validate_field/type=group', array($this, 'field_seamless_style'), 20); |
| 79 | add_filter('acf/validate_field/type=clone', array($this, 'field_seamless_style'), 20); |
| 80 | add_filter('acf/validate_field/type=acfe_dynamic_message', array($this, 'field_dynamic_message'), 20); |
| 81 | add_filter('acfe/load_fields/type=flexible_content', array($this, 'field_flexible_settings_title'), 20, 2); |
| 82 | |
| 83 | add_filter('acf/prepare_field/name=acfe_flexible_category', array($this, 'field_flexible_layout_categories'), 10, 2); |
| 84 | |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * ACF Extended: Settings |
| 89 | */ |
| 90 | function update_settings(){ |
| 91 | |
| 92 | // ACF Extended: 0.8.8 - 'acfe/modules/taxonomies' is now used for the old 'acfe/modules/dynamic_taxonomies' |
| 93 | // ACF Extended: 0.8.6.3 - Renamed 'acfe/modules/taxonomies' to 'acfe/modules/ui' |
| 94 | //if(acf_get_setting('acfe/modules/taxonomies') !== null){ |
| 95 | // acf_update_setting('acfe/modules/ui', acf_get_setting('acfe/modules/taxonomies')); |
| 96 | //} |
| 97 | |
| 98 | // ACF Extended: 0.8 - Renamed 'acfe_php*' to 'acfe/php*' |
| 99 | if(acf_get_setting('acfe_php') !== null){ |
| 100 | acf_update_setting('acfe/php', acf_get_setting('acfe_php')); |
| 101 | } |
| 102 | |
| 103 | if(acf_get_setting('php_save') !== null){ |
| 104 | acf_update_setting('acfe/php_save', acf_get_setting('php_save')); |
| 105 | } |
| 106 | |
| 107 | if(acf_get_setting('php_load') !== null){ |
| 108 | acf_update_setting('acfe/php_load', acf_get_setting('php_load')); |
| 109 | } |
| 110 | |
| 111 | if(acf_get_setting('php_found') !== null){ |
| 112 | acf_update_setting('acfe/php_found', acf_get_setting('php_found')); |
| 113 | } |
| 114 | |
| 115 | // ACF Extended: 0.8.8 - renamed modules |
| 116 | if(acf_get_setting('acfe/modules/dynamic_block_types') !== null){ |
| 117 | acf_update_setting('acfe/modules/block_types', acf_get_setting('acfe/modules/dynamic_block_types')); |
| 118 | } |
| 119 | |
| 120 | if(acf_get_setting('acfe/modules/dynamic_forms') !== null){ |
| 121 | acf_update_setting('acfe/modules/forms', acf_get_setting('acfe/modules/dynamic_forms')); |
| 122 | } |
| 123 | |
| 124 | if(acf_get_setting('acfe/modules/dynamic_options_pages') !== null){ |
| 125 | acf_update_setting('acfe/modules/options_pages', acf_get_setting('acfe/modules/dynamic_options_pages')); |
| 126 | } |
| 127 | |
| 128 | if(acf_get_setting('acfe/modules/dynamic_post_types') !== null){ |
| 129 | acf_update_setting('acfe/modules/post_types', acf_get_setting('acfe/modules/dynamic_post_types')); |
| 130 | } |
| 131 | |
| 132 | if(acf_get_setting('acfe/modules/dynamic_taxonomies') !== null){ |
| 133 | acf_update_setting('acfe/modules/taxonomies', acf_get_setting('acfe/modules/dynamic_taxonomies')); |
| 134 | } |
| 135 | |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * ACF Extended: 0.8 |
| 140 | * Field Group Location: Archive renamed to List |
| 141 | */ |
| 142 | function field_group_location_list($field_group){ |
| 143 | |
| 144 | if(!acf_maybe_get($field_group, 'location')) |
| 145 | return $field_group; |
| 146 | |
| 147 | foreach($field_group['location'] as &$or){ |
| 148 | |
| 149 | foreach($or as &$and){ |
| 150 | |
| 151 | if(!isset($and['value'])) |
| 152 | continue; |
| 153 | |
| 154 | // Post Type List |
| 155 | if($and['param'] === 'post_type' && acfe_ends_with($and['value'], '_archive')){ |
| 156 | |
| 157 | $and['param'] = 'post_type_list'; |
| 158 | $and['value'] = substr_replace($and['value'], '', -8); |
| 159 | |
| 160 | } |
| 161 | |
| 162 | // Taxonomy List |
| 163 | elseif($and['param'] === 'taxonomy' && acfe_ends_with($and['value'], '_archive')){ |
| 164 | |
| 165 | $and['param'] = 'taxonomy_list'; |
| 166 | $and['value'] = substr_replace($and['value'], '', -8); |
| 167 | |
| 168 | } |
| 169 | |
| 170 | } |
| 171 | |
| 172 | } |
| 173 | |
| 174 | return $field_group; |
| 175 | |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * ACF Extended: 0.8 |
| 180 | * Field Filter Value: Removed from this version |
| 181 | */ |
| 182 | function field_acfe_update($field){ |
| 183 | |
| 184 | if(!acf_maybe_get($field, 'acfe_update')) |
| 185 | return $field; |
| 186 | |
| 187 | unset($field['acfe_update']); |
| 188 | |
| 189 | return $field; |
| 190 | |
| 191 | } |
| 192 | |
| 193 | /** |
| 194 | * ACF Extended: 0.8.5 |
| 195 | * Field Group/Clone: Fixed typo "Seamless" |
| 196 | */ |
| 197 | function field_seamless_style($field){ |
| 198 | |
| 199 | if($seamless = acf_maybe_get($field, 'acfe_seemless_style', false)){ |
| 200 | |
| 201 | $field['acfe_seamless_style'] = $seamless; |
| 202 | |
| 203 | } |
| 204 | |
| 205 | return $field; |
| 206 | |
| 207 | } |
| 208 | |
| 209 | /** |
| 210 | * ACF Extended: 0.8.8.5 |
| 211 | * Renamed Dynamic Message to Dynamic Render |
| 212 | */ |
| 213 | function field_dynamic_message($field){ |
| 214 | |
| 215 | $field['type'] = 'acfe_dynamic_render'; |
| 216 | |
| 217 | return $field; |
| 218 | |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * ACF Extended: 0.8.4.5 |
| 223 | * Field Flexible Content: Fix duplicated "layout_settings" & "layout_title" |
| 224 | */ |
| 225 | function field_flexible_settings_title($fields, $parent){ |
| 226 | |
| 227 | // Check if is tool screen |
| 228 | if(!acf_is_screen(acfe_get_acf_screen_id('acf-tools'))) |
| 229 | return $fields; |
| 230 | |
| 231 | foreach($fields as $_k => $_field){ |
| 232 | |
| 233 | // field name |
| 234 | $_field_name = acf_maybe_get($_field, 'name'); |
| 235 | |
| 236 | // check 'acfe_flexible_layout_title' & 'layout_settings' |
| 237 | if($_field_name !== 'acfe_flexible_layout_title' && $_field_name !== 'layout_settings') |
| 238 | continue; |
| 239 | |
| 240 | // unset |
| 241 | unset($fields[$_k]); |
| 242 | |
| 243 | } |
| 244 | |
| 245 | return $fields; |
| 246 | |
| 247 | } |
| 248 | |
| 249 | /** |
| 250 | * ACF Extended: 0.8.6.7 |
| 251 | * Field Flexible Content: Compatibility for Layout Categories |
| 252 | */ |
| 253 | function field_flexible_layout_categories($field){ |
| 254 | |
| 255 | $value = acf_maybe_get($field, 'value'); |
| 256 | |
| 257 | if(empty($value)) |
| 258 | return $field; |
| 259 | |
| 260 | if(is_string($value)){ |
| 261 | |
| 262 | $explode = explode('|', $value); |
| 263 | |
| 264 | $choices = array(); |
| 265 | |
| 266 | foreach($explode as $v){ |
| 267 | |
| 268 | $v = trim($v); |
| 269 | $choices[$v] = $v; |
| 270 | |
| 271 | } |
| 272 | |
| 273 | $field['choices'] = $choices; |
| 274 | $field['value'] = $choices; |
| 275 | |
| 276 | } |
| 277 | |
| 278 | return $field; |
| 279 | |
| 280 | } |
| 281 | |
| 282 | /** |
| 283 | * ACF Extended: 0.8.5 |
| 284 | * Module Dynamic Forms: Upgrade previous versions |
| 285 | */ |
| 286 | function acfe_form_import_compatibility($args, $name, $post_id){ |
| 287 | |
| 288 | // ACF Extended: 0.8.5 Compatibility - Step 1 |
| 289 | // Groups upgrade |
| 290 | $has_upgraded = false; |
| 291 | |
| 292 | $rules = array( |
| 293 | |
| 294 | // Post: title |
| 295 | array( |
| 296 | 'group' => 'field_acfe_form_post_save_post_title_group', |
| 297 | 'sub_field' => 'field_acfe_form_post_save_post_title', |
| 298 | 'sub_field_custom' => 'field_acfe_form_post_save_post_title_custom', |
| 299 | ), |
| 300 | |
| 301 | // Post: name |
| 302 | array( |
| 303 | 'group' => 'field_acfe_form_post_save_post_name_group', |
| 304 | 'sub_field' => 'field_acfe_form_post_save_post_name', |
| 305 | 'sub_field_custom' => 'field_acfe_form_post_save_post_name_custom', |
| 306 | ), |
| 307 | |
| 308 | // Term: name |
| 309 | array( |
| 310 | 'group' => 'field_acfe_form_term_save_name_group', |
| 311 | 'sub_field' => 'field_acfe_form_term_save_name', |
| 312 | 'sub_field_custom' => 'field_acfe_form_term_save_name_custom', |
| 313 | ), |
| 314 | |
| 315 | // Term: slug |
| 316 | array( |
| 317 | 'group' => 'field_acfe_form_term_save_slug_group', |
| 318 | 'sub_field' => 'field_acfe_form_term_save_slug', |
| 319 | 'sub_field_custom' => 'field_acfe_form_term_save_slug_custom', |
| 320 | ), |
| 321 | |
| 322 | // User: e-mail |
| 323 | array( |
| 324 | 'group' => 'field_acfe_form_user_save_email_group', |
| 325 | 'sub_field' => 'field_acfe_form_user_save_email', |
| 326 | 'sub_field_custom' => 'field_acfe_form_user_save_email_custom', |
| 327 | ), |
| 328 | |
| 329 | // User: username |
| 330 | array( |
| 331 | 'group' => 'field_acfe_form_user_save_username_group', |
| 332 | 'sub_field' => 'field_acfe_form_user_save_username', |
| 333 | 'sub_field_custom' => 'field_acfe_form_user_save_username_custom', |
| 334 | ), |
| 335 | |
| 336 | // User: password |
| 337 | array( |
| 338 | 'group' => 'field_acfe_form_user_save_password_group', |
| 339 | 'sub_field' => 'field_acfe_form_user_save_password', |
| 340 | 'sub_field_custom' => 'field_acfe_form_user_save_password_custom', |
| 341 | ), |
| 342 | |
| 343 | // User: first name |
| 344 | array( |
| 345 | 'group' => 'field_acfe_form_user_save_first_name_group', |
| 346 | 'sub_field' => 'field_acfe_form_user_save_first_name', |
| 347 | 'sub_field_custom' => 'field_acfe_form_user_save_first_name_custom', |
| 348 | ), |
| 349 | |
| 350 | // User: last name |
| 351 | array( |
| 352 | 'group' => 'field_acfe_form_user_save_last_name_group', |
| 353 | 'sub_field' => 'field_acfe_form_user_save_last_name', |
| 354 | 'sub_field_custom' => 'field_acfe_form_user_save_last_name_custom', |
| 355 | ), |
| 356 | |
| 357 | // User: nickname |
| 358 | array( |
| 359 | 'group' => 'field_acfe_form_user_save_nickname_group', |
| 360 | 'sub_field' => 'field_acfe_form_user_save_nickname', |
| 361 | 'sub_field_custom' => 'field_acfe_form_user_save_nickname_custom', |
| 362 | ), |
| 363 | |
| 364 | // User: display name |
| 365 | array( |
| 366 | 'group' => 'field_acfe_form_user_save_display_name_group', |
| 367 | 'sub_field' => 'field_acfe_form_user_save_display_name', |
| 368 | 'sub_field_custom' => 'field_acfe_form_user_save_display_name_custom', |
| 369 | ), |
| 370 | |
| 371 | // User: website |
| 372 | array( |
| 373 | 'group' => 'field_acfe_form_user_save_website_group', |
| 374 | 'sub_field' => 'field_acfe_form_user_save_website', |
| 375 | 'sub_field_custom' => 'field_acfe_form_user_save_website_custom', |
| 376 | ), |
| 377 | |
| 378 | ); |
| 379 | |
| 380 | foreach($args['acfe_form_actions'] as &$row){ |
| 381 | |
| 382 | foreach($rules as $rule){ |
| 383 | |
| 384 | if(!acf_maybe_get($row, $rule['group'])) |
| 385 | continue; |
| 386 | |
| 387 | $value = null; |
| 388 | $group = $row[$rule['group']]; |
| 389 | |
| 390 | if(acf_maybe_get($group, $rule['sub_field']) === 'custom'){ |
| 391 | |
| 392 | $value = acf_maybe_get($group, $rule['sub_field_custom']); |
| 393 | |
| 394 | }else{ |
| 395 | |
| 396 | $value = acf_maybe_get($group, $rule['sub_field']); |
| 397 | |
| 398 | } |
| 399 | |
| 400 | unset($row[$rule['group']]); |
| 401 | |
| 402 | $row[$rule['sub_field']] = $value; |
| 403 | |
| 404 | $has_upgraded = true; |
| 405 | |
| 406 | } |
| 407 | |
| 408 | } |
| 409 | |
| 410 | // ACF Extended: 0.8.5 Compatibility - Step 2 |
| 411 | // Field mapping upgrade |
| 412 | if($has_upgraded){ |
| 413 | |
| 414 | // Rules |
| 415 | $rules = array( |
| 416 | |
| 417 | array( |
| 418 | 'load_values' => 'field_acfe_form_post_load_values', |
| 419 | 'fields' => array( |
| 420 | 'field_acfe_form_post_map_post_type' => 'field_acfe_form_post_save_post_type', |
| 421 | 'field_acfe_form_post_map_post_status' => 'field_acfe_form_post_save_post_status', |
| 422 | 'field_acfe_form_post_map_post_title' => 'field_acfe_form_post_save_post_title', |
| 423 | 'field_acfe_form_post_map_post_name' => 'field_acfe_form_post_save_post_name', |
| 424 | 'field_acfe_form_post_map_post_content' => 'field_acfe_form_post_save_post_content', |
| 425 | 'field_acfe_form_post_map_post_author' => 'field_acfe_form_post_save_post_author', |
| 426 | 'field_acfe_form_post_map_post_parent' => 'field_acfe_form_post_save_post_parent', |
| 427 | 'field_acfe_form_post_map_post_terms' => 'field_acfe_form_post_save_post_terms', |
| 428 | ) |
| 429 | ), |
| 430 | |
| 431 | array( |
| 432 | 'load_values' => 'field_acfe_form_term_load_values', |
| 433 | 'fields' => array( |
| 434 | 'field_acfe_form_term_map_name' => 'field_acfe_form_term_save_name', |
| 435 | 'field_acfe_form_term_map_slug' => 'field_acfe_form_term_save_slug', |
| 436 | 'field_acfe_form_term_map_taxonomy' => 'field_acfe_form_term_save_taxonomy', |
| 437 | 'field_acfe_form_term_map_parent' => 'field_acfe_form_term_save_parent', |
| 438 | 'field_acfe_form_term_map_description' => 'field_acfe_form_term_save_description', |
| 439 | ) |
| 440 | ), |
| 441 | |
| 442 | array( |
| 443 | 'load_values' => 'field_acfe_form_user_load_values', |
| 444 | 'fields' => array( |
| 445 | 'field_acfe_form_user_map_email' => 'field_acfe_form_user_save_email', |
| 446 | 'field_acfe_form_user_map_username' => 'field_acfe_form_user_save_username', |
| 447 | 'field_acfe_form_user_map_password' => 'field_acfe_form_user_save_password', |
| 448 | 'field_acfe_form_user_map_first_name' => 'field_acfe_form_user_save_first_name', |
| 449 | 'field_acfe_form_user_map_last_name' => 'field_acfe_form_user_save_last_name', |
| 450 | 'field_acfe_form_user_map_nickname' => 'field_acfe_form_user_save_nickname', |
| 451 | 'field_acfe_form_user_map_display_name' => 'field_acfe_form_user_save_display_name', |
| 452 | 'field_acfe_form_user_map_website' => 'field_acfe_form_user_save_website', |
| 453 | 'field_acfe_form_user_map_description' => 'field_acfe_form_user_save_description', |
| 454 | 'field_acfe_form_user_map_role' => 'field_acfe_form_user_save_role', |
| 455 | ) |
| 456 | ), |
| 457 | |
| 458 | ); |
| 459 | |
| 460 | foreach($args['acfe_form_actions'] as &$row){ |
| 461 | |
| 462 | foreach($rules as $rule){ |
| 463 | |
| 464 | $load_values = acf_maybe_get($row, $rule['load_values']); |
| 465 | $fields = $rule['fields']; |
| 466 | |
| 467 | if(!empty($load_values)) |
| 468 | continue; |
| 469 | |
| 470 | foreach($fields as $map => $save){ |
| 471 | |
| 472 | $map_value = acf_maybe_get($row, $map); |
| 473 | |
| 474 | if(empty($map_value)) |
| 475 | continue; |
| 476 | |
| 477 | if($save === 'field_acfe_form_post_save_post_content'){ |
| 478 | |
| 479 | $row['field_acfe_form_post_save_post_content_group'][$save] = $map_value; |
| 480 | |
| 481 | } |
| 482 | |
| 483 | elseif($save === 'field_acfe_form_term_save_description'){ |
| 484 | |
| 485 | $row['field_acfe_form_term_save_description_group'][$save] = $map_value; |
| 486 | |
| 487 | } |
| 488 | |
| 489 | elseif($save === 'field_acfe_form_user_save_description'){ |
| 490 | |
| 491 | $row['field_acfe_form_user_save_description_group'][$save] = $map_value; |
| 492 | |
| 493 | } |
| 494 | |
| 495 | else{ |
| 496 | |
| 497 | $row[$save] = $map_value; |
| 498 | |
| 499 | } |
| 500 | |
| 501 | } |
| 502 | |
| 503 | } |
| 504 | |
| 505 | } |
| 506 | |
| 507 | } |
| 508 | |
| 509 | return $args; |
| 510 | |
| 511 | } |
| 512 | |
| 513 | /** |
| 514 | * Plugin: Post Types Order |
| 515 | * https://wordpress.org/plugins/post-types-order/ |
| 516 | * The plugin apply custom order to ACF Field Group Post Type. We have to fix this |
| 517 | */ |
| 518 | function pto_acf_field_group($ignore, $orderby, $query){ |
| 519 | |
| 520 | if(is_admin() && $query->is_main_query() && $query->get('post_type') === 'acf-field-group') |
| 521 | $ignore = true; |
| 522 | |
| 523 | return $ignore; |
| 524 | |
| 525 | } |
| 526 | |
| 527 | /** |
| 528 | * Plugin: Post Types Order |
| 529 | * https://wordpress.org/plugins/post-types-order/ |
| 530 | * The plugin apply a drag & drop UI on ACF Field Group UI. We have to fix this |
| 531 | */ |
| 532 | function pto_options_acf_field_group($options){ |
| 533 | |
| 534 | $options['show_reorder_interfaces']['acf-field-group'] = 'hide'; |
| 535 | |
| 536 | return $options; |
| 537 | |
| 538 | } |
| 539 | |
| 540 | /** |
| 541 | * Plugin: Category Order and Taxonomy Terms Order |
| 542 | * https://wordpress.org/plugins/taxonomy-terms-order/ |
| 543 | * The plugin add a submenu to 'Custom Fields' to order Field Group Categories. It's unecessary |
| 544 | */ |
| 545 | function cotto_submenu(){ |
| 546 | |
| 547 | remove_submenu_page('edit.php?post_type=acf-field-group', 'to-interface-acf-field-group'); |
| 548 | |
| 549 | } |
| 550 | |
| 551 | /** |
| 552 | * Plugin: Rank Math SEO |
| 553 | * https://wordpress.org/plugins/seo-by-rank-math/ |
| 554 | * Fix the plugin post metabox which is always above ACF metaboxes |
| 555 | */ |
| 556 | function rankmath_metaboxes_priority(){ |
| 557 | |
| 558 | return 'default'; |
| 559 | |
| 560 | } |
| 561 | |
| 562 | /** |
| 563 | * Plugin: YOAST SEO |
| 564 | * https://wordpress.org/plugins/wordpress-seo/ |
| 565 | * Fix the plugin post metabox which is always above ACF metaboxes |
| 566 | */ |
| 567 | function yoast_metaboxes_priority(){ |
| 568 | |
| 569 | return 'default'; |
| 570 | |
| 571 | } |
| 572 | |
| 573 | /** |
| 574 | * ACF Extended: 0.8.3 |
| 575 | * Modules: Enable PolyLang Translation for ACFE Form Module |
| 576 | * https://polylang.pro/doc/filter-reference/ |
| 577 | */ |
| 578 | function polylang($post_types, $is_settings){ |
| 579 | |
| 580 | if($is_settings){ |
| 581 | |
| 582 | unset($post_types['acfe-form']); |
| 583 | unset($post_types['acfe-template']); |
| 584 | |
| 585 | }else{ |
| 586 | |
| 587 | $post_types['acfe-form'] = 'acfe-form'; |
| 588 | $post_types['acfe-template'] = 'acfe-template'; |
| 589 | |
| 590 | } |
| 591 | |
| 592 | return $post_types; |
| 593 | |
| 594 | } |
| 595 | |
| 596 | /* |
| 597 | * ACF Extended: 0.8.8 |
| 598 | * Elementor Pro |
| 599 | * Fix Elementor listing all private ACF Extended Field Groups in Dynamic ACF Tags options list |
| 600 | */ |
| 601 | function elementor(){ |
| 602 | |
| 603 | add_filter('acf/load_field_groups', function($field_groups){ |
| 604 | |
| 605 | // Hidden Local Field Groups |
| 606 | $hidden = acfe_get_setting('reserved_field_groups', array()); |
| 607 | |
| 608 | foreach($field_groups as $i => $field_group){ |
| 609 | |
| 610 | if(!in_array($field_group['key'], $hidden)) |
| 611 | continue; |
| 612 | |
| 613 | unset($field_groups[$i]); |
| 614 | |
| 615 | } |
| 616 | |
| 617 | $field_groups = array_values($field_groups); |
| 618 | |
| 619 | return $field_groups; |
| 620 | |
| 621 | }, 25); |
| 622 | |
| 623 | } |
| 624 | |
| 625 | /* |
| 626 | * ACF Extended: 0.8.8.2 |
| 627 | * WP GraphQL ACF Supported Fields |
| 628 | */ |
| 629 | function wpgraphql_supported_fields($fields){ |
| 630 | |
| 631 | $acfe_fields = array( |
| 632 | 'acfe_advanced_link', |
| 633 | 'acfe_code_editor', |
| 634 | 'acfe_forms', |
| 635 | 'acfe_hidden', |
| 636 | 'acfe_post_statuses', |
| 637 | 'acfe_post_types', |
| 638 | 'acfe_slug', |
| 639 | 'acfe_taxonomies', |
| 640 | 'acfe_taxonomy_terms', |
| 641 | 'acfe_user_roles', |
| 642 | ); |
| 643 | |
| 644 | return array_merge($fields, $acfe_fields); |
| 645 | |
| 646 | } |
| 647 | |
| 648 | /* |
| 649 | * ACF Extended: 0.8.8.4 |
| 650 | * WP GraphQL ACF Register Field |
| 651 | */ |
| 652 | function wpgraphql_register_field($field_config, $type_name, $field_name, $config){ |
| 653 | |
| 654 | $acf_field = isset( $config['acf_field'] ) ? $config['acf_field'] : null; |
| 655 | $acf_type = isset( $acf_field['type'] ) ? $acf_field['type'] : null; |
| 656 | |
| 657 | if($acf_type === 'acfe_advanced_link'){ |
| 658 | |
| 659 | $field_config['type'] = array('list_of' => 'String'); |
| 660 | |
| 661 | }elseif($acf_type === 'acfe_code_editor'){ |
| 662 | |
| 663 | $field_config['type'] = 'String'; |
| 664 | |
| 665 | }elseif($acf_type === 'acfe_forms'){ |
| 666 | |
| 667 | $field_config['type'] = array('list_of' => 'String'); |
| 668 | |
| 669 | }elseif($acf_type === 'acfe_hidden'){ |
| 670 | |
| 671 | $field_config['type'] = 'String'; |
| 672 | |
| 673 | }elseif($acf_type === 'acfe_post_statuses'){ |
| 674 | |
| 675 | $field_config['type'] = array('list_of' => 'String'); |
| 676 | |
| 677 | }elseif($acf_type === 'acfe_post_types'){ |
| 678 | |
| 679 | $field_config['type'] = array('list_of' => 'String'); |
| 680 | |
| 681 | }elseif($acf_type === 'acfe_slug'){ |
| 682 | |
| 683 | $field_config['type'] = 'String'; |
| 684 | |
| 685 | }elseif($acf_type === 'acfe_taxonomies'){ |
| 686 | |
| 687 | $field_config['type'] = array('list_of' => 'String'); |
| 688 | |
| 689 | }elseif($acf_type === 'acfe_taxonomy_terms'){ |
| 690 | |
| 691 | $field_config['type'] = array('list_of' => 'String'); |
| 692 | |
| 693 | }elseif($acf_type === 'acfe_user_roles'){ |
| 694 | |
| 695 | $field_config['type'] = array('list_of' => 'String'); |
| 696 | |
| 697 | } |
| 698 | |
| 699 | return $field_config; |
| 700 | |
| 701 | } |
| 702 | |
| 703 | } |
| 704 | |
| 705 | new acfe_compatibility(); |
| 706 | |
| 707 | endif; |