Create a custom term

Again, 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

//Build term
$tea_configs = array(
  'slug' => 'project-category',
  'post_type' => array('project'),

  'labels' => array(
    'name' => __('Categories'),
    'singular_name' => __('Category'),
  ),

  'hierarchical' => true,
  'query_var' => true,
  'rewrite' => 'project-category',
  'show_admin_column' => true,
);
//Build contents
$tea_contents = array(
  array(
    'type' => 'textarea',
    'id' => 'source',
    'title' => 'Video URL',
    'placeholder' => 'http://...',
    'description' => 'Enter here your Video URL.'
  )
);

//Add term to WP
$tea->addTerm($tea_configs, $tea_contents);
//Delete variables because we love our server!
unset($tea_configs, $tea_contents);

3. Build the Terms

<?php

//Build terms
$tea->buildTerms();

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();

//Build term
$tea_configs = array(
  'slug' => 'project-category',
  'post_type' => array('project'),

  'labels' => array(
    'name' => __('Categories'),
    'singular_name' => __('Category'),
  ),

  'hierarchical' => true,
  'query_var' => true,
  'rewrite' => 'project-category',
  'show_admin_column' => true,
);
//Build contents
$tea_contents = array(
  array(
    'type' => 'textarea',
    'id' => 'source',
    'title' => 'Video URL',
    'placeholder' => 'http://...',
    'description' => 'Enter here your Video URL.'
  )
);

//Add term to WP
$tea->addTerm($tea_configs, $tea_contents);
//Delete variables because we love our server!
unset($tea_configs, $tea_contents);

//Build terms
$tea->buildTerms();