zeshan-a
10/12/2016 - 12:58 PM

Creates separate Advanced Custom Fields options pages for the specified languages.

Creates separate Advanced Custom Fields options pages for the specified languages.

<?php // Don't copy this line if you are inserting in a file that has it already. 

/**
 * ACF Options Page
 * 
 * Instructions: 
 * Add more languages to the array below: $languages
 *
 * @author: Zeshan Ahmed <https://zeshanahmed.com/>
 */

if ( function_exists( 'acf_add_options_page' ) ) {

  
  // Main Theme Settings Page
  $parent = acf_add_options_page( array(
    'page_title' => 'Theme General Settings',
    'menu_title' => 'Theme Settings',
    'redirect'   => 'Theme Settings',
  ) );

  // 
  // Global Options
  // Same options on all languages. e.g., social profiles links
  // 

  acf_add_options_sub_page( array(
    'page_title' => 'Global Options',
    'menu_title' => __('Global Options', 'text-domain'),
    'menu_slug'  => "acf-options",
    'parent'     => $parent['menu_slug']
  ) );

  // 
  // Language Specific Options
  // Translatable options specific languages.
  // 
  
  $languages = array( 'it', 'en' );

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

}