Fixing match check
-
Hi Parimal,
nice plugin, thank’s for starting it.
If I could add a few fixes/suggestions.
To add other options pages to the site I use this in functions.phpuse function CustomOptionPageACF\copacf_add_custom_options_page;copacf_add_custom_options_page([
'page_title' => 'General Settings',
'menu_title' => 'General Settings',
'menu_slug' => 'general-settings',
'capability' => 'manage_options',
]);
Now when selecting location for ACF fields to appear, at the moment the dropdown only shows the last options page in the list instead of all available pages.
To fix this, in custom-option-page-for-acf.php change line 281 from'post_name' => $page['menu_slug'],to'name' => $page['menu_slug'],
Then in the location.php file, update ‘match’ function to this:public function match($rule, $screen, $field_group) { // Current admin screen page slug $page_slug = !empty($_GET['page']) ? sanitize_text_field(wp_unslash($_GET['page'])) : ''; if (!$page_slug) { return false; } // Load the ACF-COP post selected in the location rule $target_post = get_post((int) $rule['value']); if (!$target_post || $target_post->post_type !== 'acf-cop') { return false; } // Match by comparing slug to current page return $target_post->post_name === $page_slug; }
Can you please review and implement.
Please let me know so I can pull the latest/updated version.
Thank you.
Alex
The topic ‘Fixing match check’ is closed to new replies.