Plugin installation
Via WordPress | Via FTP |
---|---|
|
|
Populate the panel
There are three ways to populate the options panel with new settings and new navigation menu items but in all cases you will use a single array.
Via json array
Create an empty file settings.json
, you can use the name you want, or download the example file below.
Insert the json array you want with the following syntax. The top level
array items are the primary navigation menu items
,
the second level
array items can be used as secondary navigation menu items
or as settings
. You can view all the settings codes on the next sections.
{ "settings": { "Primary menu 1": { "Secondary menu 1": [ { "type": "information", "id": "setting-1", "title": "Setting 1", "content": "Custom text 1" } ] }, "Primary menu 2": [ { "type": "information", "id": "setting-2", "title": "Setting 2", "content": "Custom text 2" } ] } }
Download settings.json
After the json file is ready you need to load them. You can do it in two ways.
By placing the json file inside the /custom/
folder of the Themekit Options plugin folder, in this case the file name must be settings.json
.
A backup of the /custom/ folder is automatically created when the plugin is deleted and automatically restored on plugin activation,
this ensure the custom contents will not be lost if the plugin is deleted or updated.
If you want to locate the json file somewhere else, you can do it by using the following function, insert it into the functions.php
file that's located into the theme folder or,
if you want to use a plugin, into the main plugin file. Replace YOUR-PATH with the path of your json file.
To get the theme path use the function get_template_directory()
, to get the Themekit Options path use the constant THEMEKIT_OPTIONS_PATH
.
function themekit_options_custom_settings($array) { $path = 'YOUR-PATH'; return themekit_options_update_settings_array($array, themekit_options_get_array_settings($path)); } add_filter('themekit_options_init_panel', 'themekit_options_custom_settings');
Via PHP array
Use the following function, insert it into the functions.php
file that's located into the theme folder or,
if you want to use a plugin, into the main plugin file. Replace the $custom_array
content with your one.
function themekit_options_custom_settings($array) { $custom_array = array( 'Primary menu 1' => array( "Secondary menu 1" => array( array("type" => "information", "id" => "setting-1", "title" => "Setting 1", "content" => "Custom text 1"), array("type" => "information", "id" => "setting-2", "title" => "Setting 2", "content" => "Custom text 2") ), "Secondary menu 2" => array( array("type" => "information", "id" => "setting-3", "title" => "Setting 3", "content" => "Custom text 3"), array("type" => "information", "id" => "setting-4", "title" => "Setting 4", "content" => "Custom text 4") ) ), 'Primary menu 2' => array( array("type" => "information", "id" => "setting-5", "title" => "Setting 5", "content" => "Custom text 5"), array("type" => "information", "id" => "setting-6", "title" => "Setting 6", "content" => "Custom text 6") ), ); return themekit_options_update_settings_array($array, $custom_array); } add_filter('themekit_options_init_panel', 'themekit_options_custom_settings');
Via built-in array
The plugin come with a buit-in settings array with all common settings required by the premium themes. To activate it define the constant THEMEKIT_OPTIONS_DEFAULT
and set it to true
.
You can definte it with the function define('THEMEKIT_OPTIONS_DEFAULT', true);
into the functions.php
file that's located into the theme folder or
if you want to use a plugin, into the main plugin file. The default settings and navigation menu items can be extended with your custom settings.
Settings list
Every setting require the following values: type
, id
, title
and content
. The id
must be unique.
You can download a pre-built setting file by click the button below, insert the setting.json file and the thumbs folder into the /custom/ plugin folder.
Information
Display a text message with a title.
{ "type": "information", "id": "", "title": "", "content": "" }
Text
Input text to insert a small plain text.
{ "type": "text", "id": "", "title": "", "content": "", "multilingual": true }
multilingual |
Enable or disable the multilingual feature. |
Textarea
Input text to insert a large plain text.
{ "type": "textarea", "id": "", "title": "", "content": "", "multilingual": true }
multilingual |
Enable or disable the multilingual feature. |
Select
Select input that display a list of options.
{ "type": "select", "id": "", "title": "", "content": "", "value": [ "Value 1", "Value 2", "Value 3" ] }
value |
Array of options. The returned value will be formatted, all lowercase and with spaces replaced by the - char. Ex. option Value 1 will be returned as value-1. |
Select image
Display a list of options where each option is an image.
{ "type": "select-image", "id": "", "title": "", "content": "", "value": [ [ "Value 1", "image-1.png" ], [ "Value 2", "image-2.png" ], [ "Value 3", "image-3.png" ] ] }
value |
Array of options. Each option is an array that contain the value name and the image name. All the images must be inserted into the folder "/wp-content/plugins/themekit-options/custom/thumbs/". Create the folder "thumbs" if it doesn't exist. A backup of the /custom/ folder is automatically created when the plugin is deleted and automatically restored on plugin activation, this ensure the custom contents will not be lost if the plugin is deleted or updated. |
Radio
List of radio buttons to choose a single option between many.
{ "type": "radio", "id": "", "title": "", "content": "", "value": [ "Value 1", "Value 2", "Value 3" ] }
value |
Array of options. The returned value will be formatted, all lowercase and with spaces replaced by the - char. Ex. option Value 1 will be returned as value-1. |
Checkbox
Checkbox to enable or disable an option.
{ "type": "checkbox", "id": "", "title": "", "content": "" }
Number
Text input that allow to insert only numbers.
{ "type": "number", "id": "", "title": "", "content": "", "unit": "px" }
unit |
Display the numbers unit. Ex. px or %. |
Number 4X
Display 4 input numbers horizontally.
{ "type": "number-4", "id": "", "title": "", "content": "", "unit": "px" }
unit |
Display the numbers unit. Ex. px or %. |
Read the value |
To read the value use the following code:
$numbers = themekit_options_get_setting('SETTING-ID');
if (isset($numbers)) {
echo $numbers[0] . ' ' . $numbers[1] . ' ' . $numbers[2] . ' ' . $numbers[3];
}
|
Range
Numeric horizontal range input that allow to drag a cursor with the mouse to change the value.
{ "type": "range", "id": "", "title": "", "content": "", "range": [ 0, 100 ], "unit": "px" }
range |
Minimum and maximum values. Default is 0 to 100. |
unit |
Display the numbers unit. Ex. px or %. |
Upload
Allow to upload or select an already uploaded file in the WordPress Media Library.
{ "type": "upload", "id": "", "title": "", "content": "" }
Upload image
Allow to upload or select an already uploaded file in the WordPress Media Library and preview it.
{ "type": "upload-image", "id": "", "title": "", "content": "", "background-size": "auto 80px" }
background-size |
Set the image preview sizes. Insert the width and height values in this order. Ex. auto 80px. |
Code editor
Powerful HTML, JS, and CSS editor powered by Codemirror.
{ "type": "code", "id": "", "title": "", "content": "", "mode": "css", "multilingual": true }
mode |
Choose between css, js, htmlmixed. |
multilingual |
Enable or disable the multilingual feature. |
WP editor
The default WYSIWYG WordPress editor.
{ "type": "wp-editor", "id": "", "title": "", "content": "" }
Color
Allow to visually choose a color.
{ "type": "color", "id": "", "title": "", "content": "" }
Multi input
Display multiple input types.
{ "type": "multi-input", "id": "", "title": "", "content": "", "value": [ { "type": "upload", "id": "", "title": "" }, { "type": "text", "id": "", "title": "", "multilingual": true }, { "type": "textarea", "id": "", "title": "", "multilingual": true }, { "type": "checkbox", "id": "", "title": "" } ] }
value |
Array of components. The supported components are text, textarea, upload and checkbox. The json array is the same of the original components.
Each component must use a unique id. The read the value use the following code:
$values = themekit_options_get_setting('SETTING-ID');
if (isset($values[0])) {
echo $values['SUB-SETTING-ID'][0];
}
|
Repeater
Allow the adding and deleting of infinite values.
{ "type": "repeater", "id": "", "title": "", "content": "", "items": [ { "type": "text", "name": "", "id": "" }, { "type": "text", "name": "", "id": "" }, { "type": "textarea", "name": "", "id": "" } ] }
items |
Array of inputs. The supported inputs are text and textarea and their json array is showed above. Name is the displaied text, id must be locally unique, type can be "text" or "textarea". |
Returned value |
The returned value is an array of associative arrays, like the below one, the id is the id of the component, the value is the returned value.
[ { "id": "value" }, { "id": "value" } ],[ { "id": "value" }, { "id": "value" } ]You can use the following PHP code to display the values. $items = themekit_options_get_setting('SETTING-ID'); if (is_array($items)) { for ($i = 0; $i < count($items); $i++) { echo $items[$i]["COMPONENT-ID"]; echo $items[$i]["COMPONENT-ID-2"]; } } |
Google Fonts
Google Fonts selector with styles and automatic front loading.
{ "type": "font", "id": "", "title": "", "content": "" }
Fonts list | We maintain updated the fonts list but in the case you need to edit them you can find it inside the folder "/wp-content/plugins/themekit-options/include/resources/", file "google-fonts.json". The list generated from https://github.com/jonathantneal/google-fonts-complete. |
Widgets
Visually create and delete infinite Widgets areas by just insert the name and description.
{ "type": "widgets", "id": "", "title": "", "content": "" }
Usage | Add as many widgets as you want and save the settings. The new areas will be available under the Widgets page accessible from the WordPress menu > Appearance > Widgets. |
Special setting | This is a special setting and should be used only one time. This setting should be hidden in the single post panel, see the Extra settings section for more details. The values of the widgets are stored into the "private" array. |
Post Types
Visually create and delete infinite Post Types.
{ "type": "post-types", "id": "", "title": "", "content": "", "show_default_taxonomies": true, "allow_custom_taxonomies": true, "allow_custom_archive_page": true }
show_default_taxonomies |
Enabled or disable the option to use the default "category" and "tags" taxonomies. These taxonomies are global and shared by all Post Types, including the blog posts. |
allow_custom_taxonomies |
Enabled or disable the option to add and delete infinite taxonomies. |
allow_custom_archive_page |
Enabled or disable the option to choose a standard page as archive. |
Usage | Add as many Post Types as you want, save the settings and reload the page. The new Post Types will be visible from the WordPress menu. |
Special setting | This is a special setting and should be used only one time. This setting should be hidden in the single post panel, see the Extra settings section for more details. The values of the Post Types are stored into the "private" array. |
Features |
|
System requirements
Check the hosting settings and communicate to the user potential requirements issues.
{ "type": "system-requirements", "id": "", "title": "", "content": "", "value": [ "memory-limit", "upload-max-size", "post-max-size", "max-execution-time", "zip", "uploads-folder-writable", "php-version" ] }
value |
Array of requirements to check and display. Below the full list.
|
Special setting | This is a special setting and should be used only one time. This setting should be hidden in the single post panel, see the Extra settings section for more details. |
Export
Export the contents of the website and save them into a zip archive.
{ "type": "export", "id": "", "title": "", "content": "" }
Placeholder option | Allow the convertion of all images and videos to placeholders generated by placeholder.com. This option is time expensive and you need large PHP execution time to avoid errors. |
Export contents |
|
Revolution Slider |
The sliders of Revolution Slider must be manually exported from Revolution Slider page.
All the slider export files must be inserted into a folder with revslider , this folder must be inserted into the main export archive file.
|
Special setting | This is a special setting and should be used only one time. This setting should be hidden in the single post panel, see the Extra settings section for more details. |
Import
Import the contents of an import file.
{ "type": "import", "id": "", "title": "", "content": "", "envato-verification": true, "allow-zip-upload": true, "thumbs": true, "imports": [ { "name": "Demo 1", "url": "DEMO-FILE-URL", "thumb": "demo-1.jpg", "required": [ "woocommerce", "revslider" ] }, { "name": "Demo 2", "url": "DEMO-FILE-URL", "thumb": "demo-2.jpg", "required": [ "revslider" ] }, { "name": "Demo 3", "url": "DEMO-FILE-URL", "thumb": "demo-3.jpg" } ] }
allow-zip-upload |
Enable the option to manually upload a import file to import. |
thumbs |
If setted to false the imports list will be displayed as select input without images. In this case the array of the "imports" can contain only the name and the url. |
imports |
Array of import files.
|
envato-verification |
Enable the Envato purchase code verification. See the Envato verification section for more details. |
Import contents |
|
Special setting | This is a special setting and should be used only one time. This setting should be hidden in the single post panel, see the Extra settings section for more details. |
Envato verification
Enable the Envato purchase code verification to allow the download and importing of a demo only to the users with a valid purchase code.
Installation and usage instructions:
-
Upload the file
envato.php
to your server, the one that will host the import files, create a dedicated folder for that, ex. https://yoursite.com/demos/envato.php. You can find this file inside the folder/wp-content/plugins/themekit-options/include/
. Do not rename the file. - Go to https://build.envato.com/my-apps/ and register a new app.
-
As
App name
insert the name you want. OnRequired permissions
check only "View the user's items' sales history". AsConfirmation URL
insert the link the envato.php file, ex. https://yoursite.com/demos/envato.php. - Click "Register App".
-
Open the file
envato.php
you previously uploaded and edit the following variables.
$PRODUCTS_IDS
Insert here the array of IDs of the Envato products you want validate. Ex.array("2751380", "1151366")
You can find the ID of a product from his URL. Ex. the ID of https://codecanyon.net/item/slider-revolution-responsive-wordpress-plugin/2751380 is 2751380.
$DEMOS_DIR
Insert here the name of the real directory that will contain your import files. The directory must be inside the same directory of the envato.php file. The directory name should be long and random like a password to avoid someone can find it, ex. AED90KOP.
$CLIENT_ID
Insert here your Envato App OAuth client ID.
$SECRET_KEY
Insert here your Envato App Secret key.
$BLOCK_MULTIPLE_DOMAINS = true;
Set it to true to allow the usage of a purchase code only to maximum 3 domains, if the user try to use the purchase code to more than 3 domains an alert message will appear and the download of the demo will be blocked. -
Go to this link: https://api.envato.com/authorization?response_type=code&client_id=[YOUR-APP-CLIENT-ID]&redirect_uri=[YOUR-URL]
Replace[YOUR-APP-CLIENT-ID]
with your Envato App OAuth client ID and[YOUR-URL]
with the url of the envato.php file, ex. https://yoursite.com/demos/envato.php. - In the imports array of the code above the URLs of all imports must point the the envato.php file but with an extra URL attribute to comunicate the import file name. Ex. https://yoursite.com/demos/envato.php?demo=demo-1.zip
- Upload all your import files inside the directory declared in the
$DEMO_DIR
variable. Ex. https://yoursite.com/demos/AED90KOP/demo-1.zip - You're done.
How it work
- The purchase code verification is really solid due it happen all on your server side and now files are sent by your server if the code is not valid.
- The import file sent the user's website is a temporary copy of the original file with another name and within another folder.
- The temporary file is automatically deleted when the user finish the import process, to add another security layer, all the temporary files older than 30 minutes are automatically deleted when the envato.php file is executed again by another user.
-
If you enabled the
$BLOCK_MULTIPLE_DOMAINS
option, a json file containing the list of all purchase codes and domains will be generated in the same folder of the envato.php file. This file is encrypted but you can view it by going to this url: https://yoursite.com/demos/envato.php?domains=show&key=[YOUR-APP-SECRET-KEY]. Replace[YOUR-APP-SECRET-KEY]
with Envato App Secret key. - All the stored files are encrypted, the encryption key is your Envato App Secret key
Read a setting
To read a setting you need to use the following PHP function. Replace SETTING-ID
with the ID of the setting you want to get the value for.
themekit_options_get_setting('SETTING-ID');
Returned value types
Most setting types return a string or numeric value but others return and array.
Currently only the Repeater
setting return an array, you can use the following PHP code to read the array.
$items = themekit_options_get_setting('SETTING-ID'); if (is_array($items)) { for ($i = 0; $i < count($items); $i++) { echo $items[$i]["COMPONENT-ID"]; echo $items[$i]["COMPONENT-ID-2"]; } }
Manually get the global settings array
Some special setting like the Widgets
and the Post Types
store their value in a private area and can not be accessed directly.
All values, including the private area ones, are stored into the single global settings array
, to get them use the following PHP code.
global $THEMEKIT_OPTIONS_SETTINGS; if (!isset($THEMEKIT_OPTIONS_SETTINGS)) { $THEMEKIT_OPTIONS_SETTINGS = get_option('themekit-options-settings'); }
To read the Widgets
and Post Types
values use the keys $THEMEKIT_OPTIONS_SETTINGS['private']['widgets']
and $THEMEKIT_OPTIONS_SETTINGS['private']['post-types']
.
Multilingual settings
The multilingual settings are compatible only with WPML
and Polylang plugins.
You don't need any configuration to use the multilingual feature, it's all automatic. You only need to add the option multilingual: true
to the json setting array.
- If the translation is not found the main language content will be used instead.
- The multilingual components are text, textarea and code editor.
- Work with global options and single post options.
- The global options panel will display a new field for each language.
- The single post options panel will display only the field of the current page language.
Extra settings
The settings json array can contain additional settings. Add the key advanced
to the root of the json array and inside it add the extra settings. Like showed below.
{ "settings": { "Primary menu 1": { "Secondary menu 1": [ { "type": "information", "id": "setting-1", "title": "Setting 1", "content": "Custom text 1" } ] }, "Primary menu 2": [ { "type": "information", "id": "setting-2", "title": "Setting 2", "content": "Custom text 2" } ] }, "advanced": { "hidden-items": [ "setting-1", "Primary menu 1" ] } }
Setting name | Description |
---|---|
hidden-items |
Array of settings ids and menu items names to hide only on the single post panel. Add the settings id of the setting you want to hide and the menu or submenu name of the menu and submenu items you want to hide. |
CSS generation
This feature allow the generation of a css file that contain the values setted in the theme option panel. Below the usage instructions.
- Create a css file named
custom.css
or download the example file below. The file name must be custom.css. - Move this file inside the folder "/wp-content/plugins/themekit-options/custom/".
- Insert your css codes as usually but replace the css values with the code
[themekit:SETTING-ID]
where SETTING-ID is the ID if the setting you want to use. See the example below. - You're done!
body { font-family: [themekit:setting-id-1]; color: [themekit:setting-id-2]; } p { font-size: [themekit:setting-id-3]px; }
How it work
- Everytime the Theme options panel is updated a css file named custom.auto.css with the final css is generated.
- The custom.auto.css file is automatically loaded on the front-end.
- Only the styles with a value in the theme options are generated, the others are not included.
- Static styles not synchronized with the theme options can also be included, in the example file below the static style is
.static-css { color: red; }
.
Download custom.css
Panel customization
The panel is white label and full brandable. See below constants
can be inserted into the functions.php
file that's located into the theme folder or,
if you want to use a plugin, into the main plugin file.
Code | Description |
---|---|
define('THEMEKIT_OPTIONS_LOGO', 'LOGO-URL'); |
Replace the theme options panel logo with your logo. Replace LOGO-URL with the url of your logo.
You can use the PHP function get_template_directory_uri() to get the theme directory url.
|
define('THEMEKIT_OPTIONS_DOCS', 'DOCUMENTATION-URL'); |
Replace the theme options panel documentation link with your link. Replace DOCUMENTATION-URL with the url of your documentation.
|
define('THEMEKIT_OPTIONS_SINGLE_POST', true); |
Include the theme options panel into each post, post type item, and page. Set to false to disable it. Default is true. |
define('THEMEKIT_OPTIONS_DEFAULT', true); |
Include a built-in settings array with all common settings required by the premium themes. You can add custom settings also if the default settings are enabled. Default is false. |
Custom files
You can include four different custom files and the theme options will automatically load them. All the following files must be included inside the folder "/wp-content/plugins/themekit-options/custom/". You can download the example files from the button below.
File name | Description |
---|---|
custom.css |
Insert here custom css codes. This file, if exist, will be automatically loaded in the front-end. This file is used also by the css generation feature. |
custom.js |
Insert here custom javascript or JQuery codes. This file, if exist, will be automatically loaded in the front-end. |
custom.php |
Insert here custom PHP codes. This file, if exist, will be automatically loaded in the front-end. |
admin.css |
Insert here custom css codes. This file, if exist, will be automatically loaded in the back-end and can be used to further customize the panel design. |
Download custom files