Getting Started

1. Download the framework

Extract the zip file and upload the tkf folder into your plugins directory.  Start testing by editing the plugin.php. An example is included there.

2. Initialize the framework

In order to use the framework you need to

  • include the loader script
  • initialize the framework with a WordPress action hook.

An example:

function framework_init(){
// Get the loader script
require_once( 'loader.php' );
// Initializing framework

tk_framework();
}
// Adding to actionhook
add_action( 'init', 'framework_init' );

After initializing all the framework functions will be available to WordPress.

WordPress Markup Language

The easiest way to use the framework is the WML (WordPress Markup Language). WML is a markup language similar to HTML. Here is an example which shows you how to create an admin page and include a form.

/*
Plugin Name: Themekraft framework
Plugin URI: http://themekraft.com/framework
Description: Speed up your wordpress developement with our framework
Author: Sven Wagener
Author URI: http://themekraft.com/
License: GPL 3.0 http://www.gnu.org/licenses/gpl.txt
Version: 0.1.0
*/

function framework_init(){
// Registering the form where the data have to be saved
$args['forms'] = array( 'myform' );

require_once( 'loader.php' );
tk_framework( $args );
}
add_action( 'init', 'framework_init' );

function init_backend(){
/*
* WML
*/
$wml = '<?xml version="1.0" ?>
 <wml>
   Your WML Code here
 <wml>
 ';

tk_wml_parse( $wml );
}
add_action( 'admin_menu', 'init_backend' );

Accessing the form values

In order to access the values from the admin option page, you can use: tk_get_values( form name );

Here is an example:

$values = tk_get_values( 'myform' );
$value->firstname;
$value->lastname;
// and so on

Learn more about what you can do in the WML Documentation

Leave a Reply