Create a custom menu

With a tiny example :)

1. Make the Tea Theme Options working

As we said before:

<?php

use crewstyle\TeaThemeOptions\TeaThemeOptions;

//Include composer autoload
require_once __DIR__.'/vendor/autoload.php';

//Instanciate a new TeaThemeOptions
$tea = new TeaThemeOptions();

2. Define what you want

Specify your wanted components:

<?php

//Define an example page and build menu
$tea->addMenu(array(
    'title' => __('Example page'),
    'name' => __('Example page'),
    'slug' => 'examplepage'
));

//Build contents with a filter composed by `tto_template_%s_contents`
//replacing `%s` by the slug's page
add_filter('tto_template_examplepage_contents', 'tto_examplepage');
function tto_examplepage($contents)
{
	return array(
    array(
      'type' => 'heading',
      'title' => __('Header.')
    ),
    array(
      'type' => 'radio',
      'title' => __('Fix the main menu bar to the top of the screen?'),
      'id' => 'header_menu_position',
      'default' => 'yes',
      'options' => array(
        'yes' => __('Yes'),
        'no' => __('No')
      )
    ),
    array(
      'type' => 'heading',
      'title' => __('Footer.')
    ),
    array(
      'type' => 'text',
      'title' => __('Copyright.'),
      'id' => 'footer_copyright',
      'default' => __('&copy; your_name, all rights reserved ~ Built with ♥ with the Tea Theme Options!')
    ),
  );
}

3. Build the menu

<?php

//Build menus
$tea->buildMenus();

4. All in one

Here is a complete snapshot of what you have to do. Remember to make all these modifications in your functions.php theme file.

<?php

use crewstyle\TeaThemeOptions\TeaThemeOptions;

//Include composer autoload
require_once __DIR__.'/vendor/autoload.php';

//Instanciate a new TeaThemeOptions
$tea = new TeaThemeOptions();

//Define an example page and build menu
$tea->addMenu(array(
    'title' => __('Example page'),
    'name' => __('Example page'),
    'slug' => 'examplepage'
));

//Build contents with a filter composed by `tto_template_%s_contents`
//replacing `%s` by the slug's page
add_filter('tto_template_examplepage_contents', 'tto_examplepage');
function tto_examplepage($contents)
{
	return array(
    array(
      'type' => 'heading',
      'title' => __('Header.')
    ),
    array(
      'type' => 'radio',
      'title' => __('Fix the main menu bar to the top of the screen?'),
      'id' => 'header_menu_position',
      'default' => 'yes',
      'options' => array(
        'yes' => __('Yes'),
        'no' => __('No')
      )
    ),
    array(
      'type' => 'heading',
      'title' => __('Footer.')
    ),
    array(
      'type' => 'text',
      'title' => __('Copyright.'),
      'id' => 'footer_copyright',
      'default' => __('&copy; your_name, all rights reserved ~ Built with ♥ with the Tea Theme Options!')
    ),
  );
}

//Build menus
$tea->buildMenus();

Pay attention: do not hesitate to make conditions on what you need in your backend panel versus what you need in your frontend website.