add_attachment.php
1 month ago
admin_head.php
1 month ago
admin_init.php
1 month ago
admin_menu.php
1 month ago
admin_notices.php
1 month ago
attachment_updated.php
1 month ago
delete_post.php
1 month ago
pmxi_after_xml_import.php
1 month ago
pmxi_before_xml_import.php
1 month ago
pmxi_extend_options_custom_fields.php
1 month ago
wp_ajax_auto_detect_cf.php
1 month ago
wp_ajax_auto_detect_sf.php
1 month ago
wp_ajax_delete_import.php
1 month ago
wp_ajax_dismiss_notifications.php
1 month ago
wp_ajax_import_failed.php
1 month ago
wp_ajax_test_images.php
1 month ago
wp_ajax_wpai_dismiss_review_modal.php
1 month ago
wp_ajax_wpai_send_feedback.php
1 month ago
wpmu_new_blog.php
1 month ago
pmxi_extend_options_custom_fields.php
86 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) exit; |
| 3 | /** |
| 4 | * @param $post_type |
| 5 | * @param $post |
| 6 | */ |
| 7 | function pmxi_pmxi_extend_options_custom_fields($post_type, $post) { |
| 8 | if ( class_exists('ACF') && ! is_plugin_active('wpai-acf-add-on/wpai-acf-add-on.php') && !class_exists('PMAI_Plugin')) { |
| 9 | |
| 10 | global $acf; |
| 11 | |
| 12 | $savedGroups = array(); |
| 13 | |
| 14 | if ( !is_null($acf) && isset($acf->settings['version']) && version_compare($acf->settings['version'], '5.0.0') >= 0 ) { |
| 15 | $savedGroups = get_posts(array( |
| 16 | 'posts_per_page' => -1, |
| 17 | 'post_type' => 'acf-field-group', |
| 18 | 'order' => 'ASC', |
| 19 | 'orderby' => 'title' |
| 20 | )); |
| 21 | $groups = []; |
| 22 | if (function_exists('acf_local')) { |
| 23 | $groups = acf_local()->groups; |
| 24 | } |
| 25 | if (empty($groups) && function_exists('acf_get_local_field_groups')) { |
| 26 | $groups = acf_get_local_field_groups(); |
| 27 | } |
| 28 | } else { |
| 29 | // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound |
| 30 | $groups = apply_filters('acf/get_field_groups', array()); |
| 31 | } |
| 32 | |
| 33 | if (!empty($savedGroups)) { |
| 34 | foreach ($savedGroups as $key => $group) { |
| 35 | if ( version_compare($acf->settings['version'], '5.0.0') >= 0 ) { |
| 36 | $groupData = acf_get_field_group($group); |
| 37 | // Prepare validation rules. |
| 38 | if (!empty($groupData['location'])) { |
| 39 | foreach ($groupData['location'] as $i => $locations) { |
| 40 | foreach ($locations as $j => $location) { |
| 41 | if ($location['param'] !== 'post_type') { |
| 42 | unset($groupData['location'][$i][$j]); |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | // Only render visible field groups. |
| 48 | if (in_array($post_type, array('taxonomies', 'import_users')) || acf_get_field_group_visibility($groupData, array('post_type' => $post_type)) || empty($groupData['location'][0])) { |
| 49 | if (!isset($groups[$group->post_name])) { |
| 50 | $groups[] = array( |
| 51 | 'ID' => $group->ID, |
| 52 | 'title' => $group->post_title, |
| 53 | 'slug' => $group->post_excerpt |
| 54 | ); |
| 55 | } else { |
| 56 | $groups[$group->post_name]['ID'] = $group->ID; |
| 57 | } |
| 58 | } |
| 59 | } else { |
| 60 | if (!isset($groups[$group->post_name])) { |
| 61 | $groups[] = array( |
| 62 | 'ID' => $group->ID, |
| 63 | 'title' => $group->post_title, |
| 64 | 'slug' => $group->post_excerpt |
| 65 | ); |
| 66 | } else { |
| 67 | $groups[$group->post_name]['ID'] = $group->ID; |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | if (!empty($groups)) { |
| 74 | foreach ($groups as $key => $group) { |
| 75 | if (empty($group['ID']) && !empty($group['id'])) { |
| 76 | $groups[$key]['ID'] = $group['id']; |
| 77 | } elseif (empty($group['ID']) && !empty($group['key'])) { |
| 78 | $groups[$key]['ID'] = $group['key']; |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | require_once WP_ALL_IMPORT_ROOT_DIR . '/views/admin/promotion/acf.php'; |
| 84 | } |
| 85 | } |
| 86 |