<?php
/**
 * Created by PhpStorm.
 * User: marco
 * Date: 27/06/18
 * Time: 10.30
 */
if (function_exists('acf_add_options_page')) {

    acf_add_options_page(array(
        'page_title' => 'Opzioni',
        'menu_title' => 'Opzioni',
        'menu_slug' => 'opzioni',
        'capability' => 'edit_posts',
        'redirect' => false
    ));

    acf_add_options_sub_page(array(
        'page_title' => 'Testi e Traduzioni',
        'menu_title' => 'Testi e Traduzioni',
        'parent_slug' => 'opzioni',
    ));

    acf_add_options_sub_page(array(
        'page_title' => 'Impostazioni Avanzate',
        'menu_title' => 'Impostazioni Avanzate',
        'parent_slug' => 'opzioni',
    ));

    $apps_array = o66_applications::applications_index;

    foreach ($apps_array as $app_index) {
        $option_page = $app_index['option_page'];
        $option_page_title = $app_index['option_page_title'];
        $option_page_menu_title = $app_index['option_page_menu_title'];
        if (!empty($option_page)) {
            acf_add_options_sub_page(array(
                'page_title' => $option_page_title,
                'menu_title' => $option_page_menu_title,
                'parent_slug' => $option_page,
            ));
        }

    }

}