PodsAdmin::parent_file PHP Method

parent_file() public method

Set the correct parent_file to highlight the correct top level menu
public parent_file ( $parent_file ) : mixed | string
$parent_file The parent file
return mixed | string
    public function parent_file($parent_file)
    {
        global $current_screen;
        if (isset($current_screen) && !empty($current_screen->taxonomy)) {
            $taxonomies = PodsMeta::$taxonomies;
            if (!empty($taxonomies)) {
                foreach ((array) $taxonomies as $pod) {
                    if ($current_screen->taxonomy !== $pod['name']) {
                        continue;
                    }
                    $menu_slug = 'edit-tags.php?taxonomy=' . $pod['name'];
                    $menu_location = pods_var('menu_location', $pod['options'], 'default');
                    $menu_location_custom = pods_var('menu_location_custom', $pod['options'], '');
                    if ('settings' == $menu_location) {
                        $parent_file = 'options-general.php';
                    } elseif ('appearances' == $menu_location) {
                        $parent_file = 'themes.php';
                    } elseif ('objects' == $menu_location) {
                        $parent_file = $menu_slug;
                    } elseif ('top' == $menu_location) {
                        $parent_file = $menu_slug;
                    } elseif ('submenu' == $menu_location && !empty($menu_location_custom)) {
                        $parent_file = $menu_location_custom;
                    }
                    break;
                }
            }
        }
        if (isset($current_screen) && !empty($current_screen->post_type)) {
            global $submenu_file;
            $components = PodsInit::$components->components;
            foreach ($components as $component => $component_data) {
                if (!empty($component_data['MenuPage']) && $parent_file === $component_data['MenuPage']) {
                    $parent_file = 'pods';
                    $submenu_file = $component_data['MenuPage'];
                }
            }
        }
        return $parent_file;
    }