<?php

/**
 * Created by PhpStorm.
 * User: marco
 * Date: 20/06/17
 * Time: 18.27
 */

//LABEL E TRADUZIONI
if( function_exists('acf_add_local_field_group') ):

    $class_labels = o66_labels::label;
    $labels_array = array();

    foreach ($class_labels as $label_title){
        $label_name_minus = sanitize_title( $label_title );
        $label_name = str_replace('-', '_',$label_name_minus);
        $label_label = $label_title;
        $label_key = 'field_'.$label_name.'_o66_label';

        $oneLabel =  array(
            'key' => $label_key,
            'label' => $label_label,
            'name' => $label_name,
            'type' => 'text',
            'instructions' => '',
            'required' => 0,
            'conditional_logic' => 0,
            'wrapper' => array(
                'width' => '33',
                'class' => '',
                'id' => '',
            ),
            'default_value' => '',
            'placeholder' => '',
            'prepend' => '',
            'append' => '',
            'maxlength' => '',
        );
        array_push($labels_array, $oneLabel);


    }

    //le opzioni stanno tutte in un array
    //devo pushare elementi dentro fields
    acf_add_local_field_group(array(
        'key' => 'group_o66_labels',
        'title' => 'Labels',
        'fields' => $labels_array,
        'location' => array(
            array(
                array(
                    'param' => 'options_page',
                    'operator' => '==',
                    'value' => 'acf-options-testi-e-traduzioni',
                ),
            ),
        ),
        'menu_order' => 0,
        'position' => 'normal',
        'style' => 'default',
        'label_placement' => 'top',
        'instruction_placement' => 'label',
        'hide_on_screen' => '',
        'active' => 1,
        'description' => '',
    ));

endif;

if( function_exists('acf_add_local_field_group') ):

    $class_labels = o66_post_types::post_types;
    $labels_array = array();

    foreach ($class_labels as $label_title){
        $label_name_minus = sanitize_title( $label_title );
        $label_name = 'index_page_'.str_replace('-', '_',$label_name_minus);
        $label_label = 'Index Page: '.$label_title;
        $label_key = 'field_'.$label_name.'_o66_index_page';

        $oneLabel =  array(
            'key' => $label_key,
            'label' => $label_label,
            'name' => $label_name,
            'type' => 'post_object',
            'instructions' => '',
            'required' => 0,
            'conditional_logic' => 0,
            'wrapper' => array(
                'width' => '',
                'class' => '',
                'id' => '',
            ),
            'post_type' => array(
                0 => 'page',
            ),
            'taxonomy' => array(
            ),
            'allow_null' => 0,
            'multiple' => 0,
            'return_format' => 'object',
            'ui' => 1,
        );
        array_push($labels_array, $oneLabel);


    }

    acf_add_local_field_group(array(
        'key' => 'group_5b54a2a185a21',
        'title' => 'Index Pages',
        'fields' => $labels_array,
        'location' => array(
            array(
                array(
                    'param' => 'options_page',
                    'operator' => '==',
                    'value' => 'acf-options-impostazioni-avanzate',
                ),
            ),
        ),
        'menu_order' => 0,
        'position' => 'normal',
        'style' => 'default',
        'label_placement' => 'top',
        'instruction_placement' => 'label',
        'hide_on_screen' => '',
        'active' => 1,
        'description' => '',
    ));

endif;