function admin_bar_menu()

in web/wp-content/plugins/acf-extended/includes/locations/post-type-archive.php [159:247]


    function admin_bar_menu($wp_admin_bar){
        
        // bail early
        if(is_admin()){
            return;
        }
        
        // validate front archive page
        // is_home() is for post type: post
        if(!is_post_type_archive() && !is_home()){
            return;
        }
        
        // try get_post_type()
        $post_type = get_post_type();
    
        if(!$post_type){
        
            // try get_queried_object()
            $object = get_queried_object();
        
            if(is_a($object, 'WP_Post_Type')){
                $post_type = $object->name;
            }
        
        }
        
        if(!$post_type){
            return;
        }
        
        // get object
        $object = get_post_type_object($post_type);
        
        // check has archive
        $has_archive = acfe_maybe_get($object, 'has_archive') || $object->name === 'post';
        $has_archive_page = acfe_maybe_get($object, 'acfe_admin_archive');
        
        if(!$has_archive || !$has_archive_page){
            return;
        }
        
        // get options pages
        $options_pages = acf_get_options_pages();
        
        if(empty($options_pages)){
            return;
        }
    
        $options_page = false;
        
        // loop options pages
        foreach($options_pages as $page){
            
            // validate page
            if(acfe_maybe_get($page, 'acfe_post_type_archive') === $post_type){
                $options_page = $page;
                break;
                
            }
            
        }
        
        if($options_page){
    
            // get capability
            $capability = $options_page['capability'];
    
            // check capability
            if(current_user_can($capability)){
        
                // parent
                $parent = $this->get_menu_parent_slug($object);
        
                // add menu item
                $wp_admin_bar->add_node(array(
                    'id'     => 'edit',
                    'title'  => __('Edit') . ' ' . $object->label . ' ' . __('Archive'),
                    'parent' => false,
                    'href'   => add_query_arg(array('page' => "{$object->name}-archive"), admin_url($parent)),
                    'meta'   => array('class' => 'ab-item')
                ));
        
            }
            
            
        }
        
    }