All in one
In your functions.php
<?php
use crewstyle\TeaThemeOptions\TeaThemeOptions;
/**
* your_theme_description
*
* @package your_package
* @subpackage your_subpackage
* @since your_package_version
*/
if (!defined('ABSPATH')) {
die('You are not authorized to directly access to this page');
}
//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
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' => __('© your_name, all rights reserved ~ Built with ♥ with the Tea Theme Options!')
),
);
}
//Build menus
$tea->buildMenus();
//Build post type
$tea_configs = array(
'slug' => 'project',
'labels' => array(
'name' => __('Projects'),
'singular_name' => __('Project'),
),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_icon' => 'dashicons-portfolio',
'menu_position' => 5,
'public' => true,
'query_var' => true,
'show_ui' => true,
'supports' => array('title', 'editor', 'excerpt', 'thumbnail', 'revision', 'comments'),
'taxonomies' => array(),
);
//Build contents
$tea_contents = array(
array(
'type' => 'textarea',
'id' => 'source',
'title' => 'Video URL',
'placeholder' => 'http://...',
'description' => 'Enter here your Video URL.'
)
);
//Add post type to WP
$tea->addPostType($tea_configs, $tea_contents);
//Delete variables because we love our server!
unset($tea_configs, $tea_contents);
//Build post types
$tea->buildPostTypes();
//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();
Updated less than a minute ago