Betiok
6/19/2017 - 11:15 AM

ACF Options Page

ACF Options Page

/*------------------------------------*\
	ACF Options Page
\*------------------------------------*/

if ( function_exists( 'acf_add_options_page' ) ) {
    $parent = acf_add_options_page( array(
        'page_title' => 'Theme Settings',
        'menu_title' => 'Theme Settings',
        'redirect'   => 'Theme Settings',
        'menu_slug'  => 'options',
    ) );

    acf_add_options_sub_page( array(
        'page_title' => 'Global Options',
        'menu_title' => __('Global Options', 'custom'),
        'menu_slug'  => 'global-options',
        'parent'     => $parent['menu_slug']
    ) );

    acf_add_options_sub_page( array(
        'page_title' => 'Locations',
        'menu_title' => __('Locations', 'custom'),
        'menu_slug'  => 'locations',
        'parent'     => $parent['menu_slug']
    ) );
    
    $languages = array('en', 'fr');

    foreach ($languages as $lang) {
        acf_add_options_sub_page( array(
            'page_title' => 'Options (' . strtoupper( $lang ) . ')',
            'menu_title' => __('Options (' . strtoupper( $lang ) . ')', 'custom'),
            'menu_slug'  => "options-${lang}",
            'post_id'    => $lang,
            'parent'     => $parent['menu_slug']
        ) );
    }
}