<?php

// Hide ACF field group menu item
add_filter('acf/settings/show_admin', '__return_false');

// Customize ACF path
add_filter('acf/settings/path', 'my_acf_settings_path');

function my_acf_settings_path($path)
{

    // update path
    $path = get_stylesheet_directory() . '/inc/acf/';

    // return
    return $path;
}

// Customize ACF dir
add_filter('acf/settings/dir', 'my_acf_settings_dir');

function my_acf_settings_dir($dir)
{

    // update path
    $dir = get_stylesheet_directory_uri() . '/inc/acf/';

    // return
    return $dir;
}

// Save ACF field as JSON
add_filter('acf/settings/save_json', 'my_acf_json_save_point');

function my_acf_json_save_point($path)
{

    // update path
    $path = get_stylesheet_directory() . '/inc/acf-json';

    // return
    return $path;
}

// Load ACF field from JSON
add_filter('acf/settings/load_json', 'my_acf_json_load_point');

function my_acf_json_load_point($paths)
{

    // remove original path (optional)
    unset($paths[0]);

    // append path
    $paths[] = get_stylesheet_directory() . '/inc/acf-json';

    // return
    return $paths;
}

//   Theme Options
if (function_exists('acf_add_options_page')) {

    acf_add_options_page(array(
        'page_title'     => 'Department of CSE: General Settings',
        'menu_title'    => 'UIU Theme: CSE',
        'menu_slug'     => 'uiu-cse-general-settings',
        'capability'    => 'edit_posts',
        'position' => '10.5',
        'redirect'        => false
    ));

    acf_add_options_sub_page(array(
        'page_title'     => 'Department of CSE: All Sliders',
        'menu_title'    => 'Slider Settings',
        'parent_slug'    => 'uiu-cse-general-settings',
    ));

    acf_add_options_sub_page(array(
        'page_title'     => 'Department of CSE: API Settings',
        'menu_title'    => 'API Settings',
        'parent_slug'    => 'uiu-cse-general-settings',
    ));

    // acf_add_options_sub_page(array(
    // 	'page_title' 	=> 'Theme Footer Settings',
    // 	'menu_title'	=> 'Footer',
    // 	'parent_slug'    => 'uiu-cse-general-settings',
    // 	));
}
