public function transform($fields)
 {
     return array_map(function ($control) {
         $value = array_key_exists('value', $control) ? $control['value'] : '';
         if (is_string($value) && startsWith($value, '@')) {
             $option = str_replace('@', '', $value);
             $pieces = explode(".", $option);
             if (count($pieces) == 2) {
                 $options = \Onepager::getOption($pieces[0]);
                 if (is_array($options) && array_key_exists($pieces[1], $options)) {
                     $control['value'] = $options[$pieces[1]];
                 } else {
                     $control['value'] = "";
                 }
             } else {
                 $control['value'] = \Onepager::getOption($option);
             }
         }
         //obligatory name
         $name = array_key_exists('name', $control) ? $control['name'] : "";
         //optional
         $type = isset($control['type']) ? $control['type'] : "text";
         switch ($type) {
             case 'divider':
                 $default = array('label' => 'divider');
                 break;
             case 'note':
                 $default = array('text' => 'note');
                 break;
             case 'link':
                 $default = array('value' => array('url' => array_get($control, 'url', ''), 'text' => array_get($control, 'url', ''), 'target' => array_get($control, 'url', false)));
                 break;
             case 'repeater':
                 $control['fields'] = array_map(function ($control) {
                     return $this->transform($control);
                 }, $control['fields']);
                 $default = array("label" => ucfirst($name), "type" => "repeater", "class" => "{$name}-control", "help" => "", "fields" => array());
                 break;
             default:
                 $default = array("placeholder" => ucfirst($name), "label" => ucfirst($name), "type" => $type, "class" => "{$name}-control", "help" => "", "value" => '');
                 //because react-bootstrap expects addonAfter
                 //append is just a syntactical sugar
                 if (array_key_exists('append', $control)) {
                     $default['addonAfter'] = $control['append'];
                 }
                 //because react-bootstrap expects addonBefore
                 //prepend is just a syntactiacal sugar
                 if (array_key_exists('prepend', $control)) {
                     $default['addonBefore'] = $control['prepend'];
                 }
         }
         $control = array_merge($default, $control);
         return $control;
     }, $fields);
 }
function onepager_localize_script_data($pageId)
{
    $onepager = onepager();
    $ajaxUrl = $onepager->api()->getAjaxUrl();
    $nav_arr = $onepager->content()->getMenus();
    $cat_arr = $onepager->content()->getCategories();
    $pages_arr = $onepager->content()->getPages();
    $blocks = array_values((array) $onepager->blockManager()->all());
    $groupOrder = $onepager->blockManager()->getGroupOrder();
    $sections = array_map(function ($section) {
        $section = onepager()->render()->sectionBlockDataMerge($section);
        $section['content'] = onepager()->render()->section($section);
        $section['style'] = onepager()->render()->style($section);
        return $section;
    }, onepager()->section()->getAllValid($pageId));
    $footer_markup = get_editor_section_list_footer();
    $disableUrl = getOpBuildModeUrl(getCurrentPageURL(), false);
    return array('ajaxUrl' => $ajaxUrl, 'optionPanel' => onepager()->optionsPanel("onepager")->getOptions(), 'options' => get_option('onepager'), 'page' => 'onepager', 'blocks' => $blocks, 'pageId' => $pageId, 'sections' => $sections, 'menus' => $nav_arr, 'pages' => $pages_arr, 'categories' => $cat_arr, 'groupOrder' => $groupOrder, 'footer' => $footer_markup, 'disable' => $disableUrl, 'presets' => Onepager::getPresets(), 'basePreset' => Onepager::getBasePreset(), 'config' => getOnepagerConfig());
}
<?php

return array('slug' => 'portfolio-1', 'groups' => array('portfolios'), 'contents' => array(array('name' => 'title', 'value' => 'Our Works'), array('name' => 'items', 'type' => 'repeater', 'fields' => array(array(array('name' => 'title', 'value' => 'Unity'), array('name' => 'description', 'type' => 'textarea', 'value' => 'Onepage Joomla Template'), array('name' => 'thumb', 'type' => 'image', 'value' => 'http://s3.amazonaws.com/quantum-assets/images/1-thumb.jpg'), array('name' => 'image', 'type' => 'image', 'value' => 'http://s3.amazonaws.com/quantum-assets/images/1.jpg')), array(array('name' => 'title', 'value' => 'BizCorp'), array('name' => 'description', 'type' => 'textarea', 'value' => 'Onepage Joomla Template'), array('name' => 'thumb', 'type' => 'image', 'value' => 'http://s3.amazonaws.com/quantum-assets/images/2-thumb.jpg'), array('name' => 'image', 'type' => 'image', 'value' => 'http://s3.amazonaws.com/quantum-assets/images/2.jpg')), array(array('name' => 'title', 'value' => 'Eventx'), array('name' => 'description', 'type' => 'textarea', 'value' => 'Event Template for Joomla'), array('name' => 'thumb', 'type' => 'image', 'value' => 'http://s3.amazonaws.com/quantum-assets/images/3-thumb.jpg'), array('name' => 'image', 'type' => 'image', 'value' => 'http://s3.amazonaws.com/quantum-assets/images/3.jpg'))))), 'settings' => array(array('name' => 'title_size', 'label' => 'Title Size', 'append' => 'px', 'value' => '@section_title_size'), array('name' => 'title_transformation', 'label' => 'Title Transformation', 'type' => 'select', 'value' => 'text-uppercase', 'options' => array('text-lowercase' => 'Lowercase', 'text-uppercase' => 'Uppercase', 'text-capitalize' => 'Capitalized')), array('name' => 'animation', 'label' => 'Animation Title', 'type' => 'select', 'value' => 'zoomIn', 'options' => array('0' => 'None', 'fadeIn' => 'Fade', 'zoomIn' => 'Zoom In', 'fadeInLeft' => 'Slide Left', 'fadeInRight' => 'Slide Right', 'fadeInUp' => 'Slide Up', 'fadeInDown' => 'Slide Down')), array('name' => 'overlay_animation', 'label' => 'Overlay Animation', 'type' => 'select', 'value' => 'scale', 'options' => array('slide-top' => 'Slide Top', 'slide-bottom' => 'Slide Bottom', 'slide-left' => 'Slide Left', 'slide-right' => 'Slide RIght', 'fade' => 'Fade', 'scale' => 'Scale', 'spin' => 'Spin'))), 'styles' => array(array('name' => 'bg_color', 'label' => 'Background Color', 'type' => 'colorpicker', 'value' => '#fff'), array('name' => 'title_color', 'label' => 'Title Color', 'type' => 'colorpicker', 'value' => '#323232'), array('name' => 'icon_bg', 'label' => 'Icon Background', 'type' => 'colorpicker', 'value' => '@color.primary')), 'assets' => function ($path) {
    // Magnefic popup from Onepager assets dir
    Onepager::addScript('magnific-popup', asset('assets/js/jquery.magnific-popup.js'), array('jquery'));
    Onepager::addStyle('magnific-popup', asset('assets/css/magnific-popup.css'));
    // Local file
    Onepager::addStyle('portfolio-1', $path . '/style.css');
});
<?php

return array('slug' => 'navbar-2', 'groups' => array('navbars'), 'contents' => array(array('name' => 'logo', 'type' => 'image', 'value' => 'http://s3.amazonaws.com/quantum-assets/logo-dark.png'), array('name' => 'menu', 'type' => 'menu')), 'settings' => array(array('name' => 'sticky_nav', 'label' => 'Sticky Nav', 'type' => 'select', 'value' => 1, 'options' => array(1 => 'Enabled', 0 => 'Disabled'))), 'styles' => array(array('name' => 'bg_color', 'label' => 'Background Color', 'type' => 'colorpicker', 'value' => '#ffffff'), array('name' => 'bg_offcanvas', 'label' => 'Offcanvas Background', 'type' => 'colorpicker', 'value' => '#2B2D42'), array('name' => 'link_color', 'label' => 'Link Color', 'type' => 'colorpicker', 'value' => '#EDF2F4'), array('name' => 'link_hover_color', 'label' => 'Link Hover Color', 'type' => 'colorpicker', 'value' => '@color.primary')), "assets" => function ($path) {
    Onepager::addStyle('navbar-2', $path . '/style.css');
});
<?php

return array('slug' => 'header-2', 'groups' => array('headers'), 'contents' => array(array('name' => 'logo', 'type' => 'image', 'value' => 'http://s3.amazonaws.com/quantum-assets/logo-white.png'), array('name' => 'menu', 'type' => 'menu'), array('name' => 'sliders', 'type' => 'repeater', 'fields' => array(array(array('name' => 'title', 'value' => 'Onepage Website Builder for WordPress'), array('name' => 'description', 'type' => 'editor', 'value' => 'Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning.'), array('name' => 'link', 'value' => '#'), array('name' => 'link_text', 'label' => 'Link Text', 'placeholder' => 'Button Text', 'value' => 'Download Now'), array('name' => 'image', 'type' => 'image', 'value' => 'https://s3.amazonaws.com/quantum-assets/video-thumb.jpg'), array('name' => 'video_url', 'label' => 'Video URL', 'value' => 'https://www.youtube.com/watch?v=SSrvuFgYc-g')), array(array('name' => 'title', 'value' => 'First Page Builder for WordPress & Joomla'), array('name' => 'description', 'type' => 'editor', 'value' => 'Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning.'), array('name' => 'link', 'value' => '#'), array('name' => 'link_text', 'label' => 'Link Text', 'placeholder' => 'Button Text', 'value' => 'Download Now'), array('name' => 'image', 'type' => 'image', 'value' => 'http://s3.amazonaws.com/quantum-assets/video-thumb-2.jpg'), array('name' => 'video_url', 'label' => 'Video URL', 'value' => 'https://vimeo.com/channels/staffpicks/128807157'))))), 'settings' => array(array('name' => 'sticky_nav', 'label' => 'Sticky Nav', 'type' => 'select', 'value' => 1, 'options' => array(1 => 'Enabled', 0 => 'Disabled')), array('name' => 'title_transformation', 'label' => 'Title Transformation', 'type' => 'select', 'value' => 'text-uppercase', 'options' => array('text-lowercase' => 'Lowercase', 'text-uppercase' => 'Uppercase', 'text-capitalize' => 'Capitalized')), array('name' => 'slider_height', 'label' => 'Slider Height', 'append' => 'px', 'value' => '450'), array('name' => 'cta', 'label' => 'Call To Action Link', 'placeholder' => 'http://doamin.com'), array('name' => 'cta_text', 'label' => 'Call To Action Text', 'value' => 'Call To Action', 'placeholder' => 'Call To Action')), 'styles' => array(array('label' => 'Nav Style', 'type' => 'divider'), array('name' => 'nav_bg', 'label' => 'Sticky Background', 'type' => 'colorpicker', 'value' => 'rgba(0,0,0,0.5)'), array('name' => 'link_color', 'label' => 'Link Color', 'type' => 'colorpicker', 'value' => '#fff'), array('name' => 'link_hover_color', 'label' => 'Link Hover Color', 'type' => 'colorpicker', 'value' => '#232323'), array('name' => 'cta_bg', 'label' => 'Button Background', 'type' => 'colorpicker', 'value' => '#ee534f'), array('name' => 'cta_color', 'label' => 'Button Text Color', 'type' => 'colorpicker', 'value' => '#fff'), array('label' => 'Slider Style', 'type' => 'divider'), array('name' => 'slider_bg', 'label' => 'Slider Background', 'type' => 'image', 'value' => 'http://s3.amazonaws.com/quantum-assets/bg/bg4.jpg')), 'assets' => function ($path) {
    // Magnefic popup load from onepager assets
    Onepager::addScript('tx-magnific-popup', asset('assets/js/jquery.magnific-popup.js'), array('jquery'));
    Onepager::addStyle('tx-magnific-popup', asset('assets/css/magnific-popup.css'));
    // Local assets
    Onepager::addStyle('header-2', $path . '/style.css');
});
<?php

return array('slug' => 'content-3', 'groups' => array('contents'), 'contents' => array(array('name' => 'title', 'value' => 'Onepage Makes Website Building Easy and Fun'), array('name' => 'description', 'type' => 'textarea', 'value' => 'Dont limit yourself. Many people limit themselves to what they think they can do. You can go as far as your mind lets you. What you believe, remember, you can achieve'), array('name' => 'image', 'type' => 'image', 'value' => 'https://s3.amazonaws.com/quantum-assets/phone-light.png'), array('name' => 'items', 'type' => 'repeater', 'fields' => array(array(array('name' => 'title', 'value' => 'Beautiful and Responsive Design'), array('name' => 'bg_parallax', 'type' => 'switch', 'label' => 'Parallax Background'), array('depends' => 'bg_parallax', 'name' => 'description', 'type' => 'textarea', 'value' => 'The best and most beautiful things in the world cannot be seen or even touched - they must be felt with the heart'), array('name' => 'media', 'type' => 'media', 'value' => 'http://s3.amazonaws.com/quantum-assets/icons/camera.png')), array(array('name' => 'title', 'value' => 'Cross Browser Compatibility'), array('name' => 'description', 'type' => 'textarea', 'value' => 'TDesign is not how it looks like of feels lie, design is how its works'), array('name' => 'media', 'type' => 'media', 'value' => 'http://s3.amazonaws.com/quantum-assets/icons/browser.png')), array(array('name' => 'title', 'value' => 'Well Documenation'), array('name' => 'description', 'type' => 'textarea', 'value' => 'Start by doing whats necessary; then do whats possible; and suddenly you are doing the impossible.'), array('name' => 'media', 'type' => 'media', 'value' => 'http://s3.amazonaws.com/quantum-assets/icons/documents.png'))))), 'settings' => array(array('name' => 'title_size', 'label' => 'Title Size', 'append' => 'px', 'value' => '@section_title_size'), array('name' => 'title_transformation', 'label' => 'Title Transformation', 'type' => 'select', 'value' => 'text-uppercase', 'options' => array('text-lowercase' => 'Lowercase', 'text-uppercase' => 'Uppercase', 'text-capitalize' => 'Capitalized')), array('name' => 'animation_media', 'label' => 'Animation Media', 'type' => 'select', 'value' => 'fadeInRight', 'options' => array('0' => 'None', 'fadeIn' => 'Fade', 'fadeInLeft' => 'Slide Left', 'fadeInRight' => 'Slide Right', 'fadeInUp' => 'Slide Up', 'fadeInDown' => 'Slide Down')), array('name' => 'animation_title', 'label' => 'Animation Title', 'type' => 'select', 'value' => 'fadeInDown', 'options' => array('0' => 'None', 'fadeIn' => 'Fade', 'fadeInLeft' => 'Slide Left', 'fadeInRight' => 'Slide Right', 'fadeInUp' => 'Slide Up', 'fadeInDown' => 'Slide Down')), array('name' => 'animation_item', 'label' => 'Animation Items', 'type' => 'select', 'value' => 'fadeInLeft', 'options' => array('0' => 'None', 'fadeIn' => 'Fade', 'zoomIn' => 'Zoom In', 'fadeInLeft' => 'Slide Left', 'fadeInRight' => 'Slide Right', 'fadeInUp' => 'Slide Up', 'fadeInDown' => 'Slide Down'))), 'styles' => array(array('name' => 'bg_color', 'label' => 'Background Color', 'type' => 'colorpicker', 'value' => '#fff'), array('name' => 'title_color', 'label' => 'Title Color', 'type' => 'colorpicker', 'value' => '#323232'), array('name' => 'text_color', 'label' => 'Text Color', 'type' => 'colorpicker', 'value' => '#727272'), array('name' => 'icon_color', 'label' => 'Icon Color', 'type' => 'colorpicker')), 'assets' => function ($path) {
    Onepager::addStyle('content-3', $path . '/style.css');
});
<?php

return array('slug' => 'slider-1', 'groups' => array('sliders'), 'contents' => array(array('name' => 'sliders', 'type' => 'repeater', 'fields' => array(array(array('name' => 'title', 'value' => 'Onepage Builder for WordPress'), array('name' => 'description', 'type' => 'textarea', 'value' => 'Building onepage website has never been easier before'), array('name' => 'image', 'type' => 'image', 'value' => 'http://s3.amazonaws.com/quantum-assets/icons/headphone-big.png'), array('name' => 'link', 'value' => 'http://getonepager.com'), array('name' => 'link_text', 'label' => 'Link Text', 'placeholder' => 'Download Now', 'value' => 'Download Now')), array(array('name' => 'title', 'value' => 'Revolutionary Website Builder'), array('name' => 'description', 'type' => 'textarea', 'value' => 'Ridiculously easy and built for tomorrows internet in mind'), array('name' => 'image', 'type' => 'image', 'value' => 'http://s3.amazonaws.com/quantum-assets/icons/responsive-big.png'), array('name' => 'link', 'value' => 'http://getonepager.com'), array('name' => 'link_text', 'label' => 'Link Text', 'placeholder' => 'Download Now', 'value' => 'Download Now'))))), 'settings' => array(array('name' => 'title_size', 'label' => 'Title Size', 'append' => 'px', 'value' => '@section_title_size'), array('name' => 'title_transformation', 'label' => 'Title Transformation', 'type' => 'select', 'value' => 'text-uppercase', 'options' => array('text-lowercase' => 'Lowercase', 'text-uppercase' => 'Uppercase', 'text-capitalize' => 'Capitalized')), array('name' => 'slider_height', 'label' => 'Slider Height', 'append' => 'px', 'value' => '600')), 'styles' => array(array('name' => 'slider_bg', 'label' => 'Slider Background', 'type' => 'image', 'value' => 'http://s3.amazonaws.com/quantum-assets/bg/bg2.jpg'), array('name' => 'button_bg', 'label' => 'Button Background', 'type' => 'colorpicker', 'value' => '@color.primary'), array('name' => 'button_color', 'label' => 'Button Color', 'type' => 'colorpicker', 'value' => '#fff'), array('name' => 'button_hover_color', 'label' => 'Button Hover Color', 'type' => 'colorpicker', 'value' => '@color.accent')), 'assets' => function ($path) {
    Onepager::addStyle('slider-1', $path . '/style.css');
});
Onepager::addPresets("default", array(['primary' => 'red', 'secondary' => 'yellow'], ['primary' => 'green', 'secondary' => 'yellow']));
Onepager::addPresets("default", array(['primary' => 'blue', 'secondary' => 'yellow'], ['primary' => 'green', 'secondary' => 'yellow', 'a1' => 'pink', 'a2' => 'red']));
add_action('wp_head', function () {
    // Favicion
    echo '<link rel="icon" href="' . Onepager::getOption('favicon') . '">';
    // Google Analytics
    echo Onepager::getOption('google_analytics');
    // Full pager
    if (Onepager::getOption('full_screen')) {
        echo '<script>
            jQuery(document).ready(function() {
              jQuery(".op-sections").fullpage({
                  sectionSelector: ".op-section",
                  css3: true,
                  scrollingSpeed: 100,
                  scrollBar: true
              });
            });
          </script>';
    }
});
if (Onepager::getOption('full_screen')) {
    add_action('wp_enqueue_scripts', function () {
        $q = onepager()->asset();
        // Full page
        // $q->script( 'op-easings', asset( 'assets/js/jquery.easings.min.js' ) );
        $q->script('op-slimscroll', asset('assets/js/jquery.slimscroll.min.js'));
        $q->script('op-fullpage', asset('assets/js/jquery.fullPage.js'));
        $q->style('op-fullpage', asset('assets/css/jquery.fullPage.css'));
    });
}
<?php

return array('slug' => 'team-1', 'groups' => array('teams'), 'contents' => array(array('name' => 'title', 'value' => 'Meet The Team'), array('name' => 'items', 'type' => 'repeater', 'fields' => array(array(array('name' => 'title', 'label' => 'Name', 'value' => 'Steve Jobs'), array('name' => 'designation', 'value' => 'CEO, Apple Inc'), array('name' => 'image', 'type' => 'image', 'value' => 'http://s3.amazonaws.com/quantum-assets/images/4-thumb.jpg'), array('name' => 'social', 'label' => 'Social Profiles', 'value' => array('http://facebook.com/ThemeXpert', 'http://twitter.com/themexpert', 'http://linkedin.com/themexpert'))), array(array('name' => 'title', 'label' => 'Name', 'value' => 'Nikola Tesla'), array('name' => 'designation', 'value' => 'Scientist'), array('name' => 'image', 'type' => 'image', 'value' => 'http://s3.amazonaws.com/quantum-assets/images/5-thumb.jpg'), array('name' => 'social', 'label' => 'Social Profiles', 'value' => array('http://behance.net/ThemeXpert', 'http://dribbble.com/themexpert', 'http://twitter.com/themexpert.com'))), array(array('name' => 'title', 'label' => 'Name', 'value' => 'Elon Musk'), array('name' => 'designation', 'value' => 'CEO, Tesla Motors'), array('name' => 'image', 'type' => 'image', 'value' => 'http://s3.amazonaws.com/quantum-assets/images/6-thumb.jpg'), array('name' => 'social', 'label' => 'Social Profiles', 'value' => array('http://github.com/ThemeXpert', 'http://codepen.io/themexpert')))))), 'settings' => array(array('name' => 'title_size', 'label' => 'Title Size', 'append' => 'px', 'value' => '@section_title_size'), array('name' => 'title_transformation', 'label' => 'Title Transformation', 'type' => 'select', 'value' => 'text-uppercase', 'options' => array('text-lowercase' => 'Lowercase', 'text-uppercase' => 'Uppercase', 'text-capitalize' => 'Capitalized')), array('name' => 'animation', 'label' => 'Animation Title', 'type' => 'select', 'value' => 'zoomIn', 'options' => array('0' => 'None', 'fadeIn' => 'Fade', 'zoomIn' => 'Zoom In', 'fadeInLeft' => 'Slide Left', 'fadeInRight' => 'Slide Right', 'fadeInUp' => 'Slide Up', 'fadeInDown' => 'Slide Down')), array('name' => 'overlay_animation', 'label' => 'Overlay Animation', 'type' => 'select', 'value' => 'scale', 'options' => array('slide-top' => 'Slide Top', 'slide-bottom' => 'Slide Bottom', 'slide-left' => 'Slide Left', 'slide-right' => 'Slide RIght', 'fade' => 'Fade', 'scale' => 'Scale', 'spin' => 'Spin'))), 'styles' => array(array('name' => 'bg_color', 'label' => 'Background Color', 'type' => 'colorpicker', 'value' => '#fff'), array('name' => 'title_color', 'label' => 'Title Color', 'type' => 'colorpicker', 'value' => '#323232')), 'assets' => function ($path) {
    Onepager::addStyle('team-1', $path . '/style.css');
});