<commit_before>Tea Theme Options
=================

The Tea Theme Options (or **Tea TO**) allows you to easily add professional looking theme options panels to your WordPress theme. **Tea TO** uses the [Transient Wordpress API](http://codex.wordpress.org/Transients_API) and puts all data in cache.  
This document contains information on how to download, install, and start using the Tea Theme Options Wordpress project.  
Note: Tea Theme Options is built for [Wordpress](http://wordpress.org "CMS Wordpress") v3.x and uses the Wordpress built-in pages.


1) Installing the theme roller
------------------------------

**To get started, checkout** https://github.com/takeatea/tea_to_wp into the `wp-content/your_template/`

    git clone https://github.com/takeatea/tea_to_wp __YOUR_TEA_TO_CUSTOM_FOLDER__

Check your new `__YOUR_TEA_TO_CUSTOM_FOLDER__` folder is created in your template directory (you can rename it if you want).

Include the `tea-theme-options.php` file in your `functions.php`

    include('__YOUR_TEA_TO_CUSTOM_FOLDER__/tea-theme-options.php');


2) Create a new Tea_Theme_Options object and set details
--------------------------------------------------------

Before starting, in your `functions.php` instanciate a new object with an uniq identifier:

    $tea = new Tea_Theme_Options('your_identifier');

And set details:

    $tea->__setDuration(86400); //Will stock transient for 86400sec, eq. to 24h
    $tea->__setDirectory('__YOUR_TEA_TO_CUSTOM_FOLDER__'); //Will define the current Tea Theme Options directory.

NOTA: by default, the Tea TO will consider the `tea_theme_options` folder


3) Let's roll!
--------------

Create your new first page with global details (as capability, icon, bigicon and descripton if you want):

    $tea->addPage(array(
        //used in your page
        'title' => 'My first page',
        //used in the admin menu
        'name' => 'First page',
        //a writer can use this page. If you want to give access only to the admin, use 'admin' instead
        'capability' => 'edit_pages',
        //used in the admin menu
        'icon' => get_template_directory_uri() . '/img/admin/settings_16.png',
        //used in your page
        'bigicon' => get_template_directory_uri() . '/img/admin/settings_32.png',
        //used in your page
        'description' => 'Here is a description of my first page'
    ));

Add all used fields in the last created page (to get definition fields, see below the [Adding fields](#5-adding-fields) section):

    $tea->addFields(array(
        array(
            'type' => 'text',
            'title' => 'My first text title',
            'id' => 'my_first_text_id',
            'std' => 'My default text value'
            'description' => 'My first text description'
        ),
        array(
            'type' => 'password',
            'title' => 'My first password field',
            'id' => 'my_first_password_id',
            'description' => 'My first password description'
        )
    ));

Create a new sub page with usefull parameters (add description if you need it). Try to put uniq slug for each array:

    $tea->addSubpage(array(
        'title' => 'Subpage Options',
        'name' => 'Homepage',
        'slug' => '_homepage'
    ));

Add all used fields in the last created page (to get definition fields, see below the [Adding fields](#5-adding-fields) section):

    $tea->addFields(array(
        array(
            'type' => 'text',
            'title' => 'My second text title',
            'id' => 'my_second_text_id',
            'std' => 'My other default text value'
            'description' => 'My second text description'
        ),
        array(
            'type' => 'checkbox',
            'title' => 'My first checkbox field',
            'id' => 'my_first_checkbox_id',
            'std' => array('check1', 'check2'),
            'description' => 'My first checkbox description',
            'options' => array(
                'check1' => 'First checbox',
                'check2' => 'Second checbox',
                'check3' => 'Third checbox'
            )
        )
    ));


4) Building menus
-----------------

The last step is to build menus and get your pages available in the adminbar menu.

    $tea->buildMenus();


5) Adding fields
----------------

Adding fields is quite simple. All you have to do is to create an array and define
all inputs nedded in your Wordpress template.
Note: the Tea Theme Options uses transient to stock options. All options are named as `tea_to_your_input_id`

All available types are:

**Display inputs**:
+ Br, display a simple breakline with clear css class
+ Heading, display a simple title
+ Hr, equivalent to the br input, but display an horizontal line

**Normal inputs**:
+ Checkbox
+ Hidden
+ Password
+ Radio
+ Text
+ Textarea
+ Upload (for images only)

**Special inputs**:
+ Category, offers a WP category listing with multiselect option if needed
+ Color, offers an input text with colorpicker
+ Font, offers a list of font choices with image labels (uniq choices)
+ Group, offers the possibility to add multiple inputs<commit_msg>fix another mistake in README.md<commit_after>Tea Theme Options
=================

The Tea Theme Options (or **Tea TO**) allows you to easily add professional looking theme options panels to your WordPress theme. **Tea TO** uses the [Transient Wordpress API](http://codex.wordpress.org/Transients_API) and puts all data in cache.  
This document contains information on how to download, install, and start using the Tea Theme Options Wordpress project.  
Note: Tea Theme Options is built for [Wordpress](http://wordpress.org "CMS Wordpress") v3.x and uses the Wordpress built-in pages.


1) Installing the theme roller
------------------------------

**To get started, checkout** https://github.com/takeatea/tea_to_wp into the `wp-content/your_template/__YOUR_TEA_TO_CUSTOM_FOLDER__/` by this command line:

    git clone https://github.com/takeatea/tea_to_wp __YOUR_TEA_TO_CUSTOM_FOLDER__

Check your new `__YOUR_TEA_TO_CUSTOM_FOLDER__` folder is created in your template directory.

Include the `tea-theme-options.php` file in your `functions.php`

    include('__YOUR_TEA_TO_CUSTOM_FOLDER__/tea-theme-options.php');


2) Create a new Tea_Theme_Options object and set details
--------------------------------------------------------

Before starting, in your `functions.php` instanciate a new object with an uniq identifier:

    $tea = new Tea_Theme_Options('your_identifier');

And set details:

    $tea->__setDuration(86400); //Will stock transient for 86400sec, eq. to 24h
    $tea->__setDirectory('__YOUR_TEA_TO_CUSTOM_FOLDER__'); //Will define the current Tea Theme Options directory.

NOTA: by default, the Tea TO will consider the `tea_theme_options` folder


3) Let's roll!
--------------

Create your new first page with global details (as capability, icon, bigicon and descripton if you want):

    $tea->addPage(array(
        //used in your page
        'title' => 'My first page',
        //used in the admin menu
        'name' => 'First page',
        //a writer can use this page. If you want to give access only to the admin, use 'admin' instead
        'capability' => 'edit_pages',
        //used in the admin menu
        'icon' => get_template_directory_uri() . '/img/admin/settings_16.png',
        //used in your page
        'bigicon' => get_template_directory_uri() . '/img/admin/settings_32.png',
        //used in your page
        'description' => 'Here is a description of my first page'
    ));

Add all used fields in the last created page (to get definition fields, see below the [Adding fields](#5-adding-fields) section):

    $tea->addFields(array(
        array(
            'type' => 'text',
            'title' => 'My first text title',
            'id' => 'my_first_text_id',
            'std' => 'My default text value'
            'description' => 'My first text description'
        ),
        array(
            'type' => 'password',
            'title' => 'My first password field',
            'id' => 'my_first_password_id',
            'description' => 'My first password description'
        )
    ));

Create a new sub page with usefull parameters (add description if you need it). Try to put uniq slug for each array:

    $tea->addSubpage(array(
        'title' => 'Subpage Options',
        'name' => 'Homepage',
        'slug' => '_homepage'
    ));

Add all used fields in the last created page (to get definition fields, see below the [Adding fields](#5-adding-fields) section):

    $tea->addFields(array(
        array(
            'type' => 'text',
            'title' => 'My second text title',
            'id' => 'my_second_text_id',
            'std' => 'My other default text value'
            'description' => 'My second text description'
        ),
        array(
            'type' => 'checkbox',
            'title' => 'My first checkbox field',
            'id' => 'my_first_checkbox_id',
            'std' => array('check1', 'check2'),
            'description' => 'My first checkbox description',
            'options' => array(
                'check1' => 'First checbox',
                'check2' => 'Second checbox',
                'check3' => 'Third checbox'
            )
        )
    ));


4) Building menus
-----------------

The last step is to build menus and get your pages available in the admin menu.

    $tea->buildMenus();


5) Adding fields
----------------

Adding fields is quite simple. All you have to do is to create an array and define all inputs nedded in your Wordpress template.  
NOTA: the **Tea TO** uses [Transient Wordpress API](http://codex.wordpress.org/Transients_API) to stock options.

All available types are:

**Display inputs**:
+ Br, display a simple breakline with clear css class
+ Heading, display a simple title
+ Hr, equivalent to the br input, but display an horizontal line

**Normal inputs**:
+ Checkbox
+ Hidden
+ Password
+ Radio
+ Text
+ Textarea
+ Upload (for images only)

**Special inputs**:
+ Category, offers a WP category listing with multiselect option if needed
+ Color, offers an input text with colorpicker
+ Font, offers a list of font choices with image labels (uniq choices)
+ Group, offers the possibility to add multiple inputs
{'fraction_non_alphanumeric': 0.1292986205556635, 'fraction_numerical': 0.005634350106858364, 'mean_word_length': 2.625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 81, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1283286', 'n_tokens_mistral': 2991, 'n_tokens_neox': 2875, 'n_words': 1113}