Skip to content

Commit

Permalink
Updating readme to match new setup instructions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Adams committed Jul 20, 2012
1 parent 3e938f9 commit c0b8d6b
Showing 1 changed file with 44 additions and 29 deletions.
73 changes: 44 additions & 29 deletions README.md
Expand Up @@ -2,50 +2,65 @@

Struts is an Options library for WordPress that aims to make setting up Theme options a breeze.

Currently Struts is under development and not recommended for use just yet - but don't worry, we're working furiously on it!
## How it works:

## How it will work:

* In your functions.php file, all you would need to do to setup your theme options
* In your functions.php file, all you need to do to setup your theme options

<?php
function mytheme_options_init() {
locate_template( array( 'path/to/struts/classes/struts.php' ), true );

add_action( 'after_setup_theme', 'setup_your_theme_options' );
Struts::load_config( array(
'struts_root_uri' => get_template_directory_uri() . '/path/to/struts', // required, set this to the URI of the root Struts directory
'use_struts_skin' => true, // optional, overrides the Settings API html output
) );

function setup_your_theme_options() {
require( dirname( __FILE__ ) . '/includes/struts/bootstrap.php' );
global $mytheme_options;

global $your_theme_options;
$mytheme_options = new Struts_Options( 'mytheme', 'theme_mytheme_options' );

$your_theme_options = new Struts_Options( 'your_theme', 'your_theme_options' );
// Setup the option sections
$mytheme_options->add_section( 'section_one', __( 'Section One', 'mytheme' ), 200 ); // 200 is priority of section in the customizer
$mytheme_options->add_section( 'section_two', __( 'Section Two', 'mytheme' ), 201 );

$your_theme_options->add_section( 'first_section', 'Text for First Section' );
$your_theme_options->add_section( 'second_section', 'Text for Second Section' );
/* Section One
* ------------------------------------------------------------------ */

$your_theme_options->add_option( 'my_first_option', 'text', 'first_section' )
->default_value( 'The default text' )
->tab( 'general')
->label( 'Enable Featured Slider' );
$mytheme_options->add_option( 'option_one', 'image', 'section_one' )
->default_value( '' )
->label( __( 'Image option:', 'mytheme' ) )
->description( __( 'Upload an image (making sure to click <strong>"Insert into post"</strong>) or enter an <abbr title="Universal resource locator">URL</abbr> for your image.', 'mytheme' ) );

$your_theme_options->add_option( 'select_this', 'select', 'second_section' )
$mytheme_options->add_option( 'option_two', 'select', 'section_one' )
->valid_values( array(
'one' => 'ONE',
'two' => 'TWO',
'three' => 'THREE' ) )
->default_value( 'two' )
->label( 'Select The Value' );

/* More options go here... */

$your_theme_options->initialize();
'first_value' => __( 'First Value', 'mytheme' ),
'second_value' => __( 'Second Value', 'mytheme' ) ) )
->default_value( 'first_value' )
->label( __( 'Select option:', 'mytheme' ) )
->description( __( 'Select an option from the select dropdown.', 'mytheme' ) );

/* Section Two
* ------------------------------------------------------------------ */

$mytheme_options->add_option( 'option_three', 'checkbox', 'section_two' )
->default_value( false )
->label( __( 'Checkbox option', 'mytheme' ) )
->description( __( 'A checkbox option.', 'mytheme' ) );

$mytheme_options->add_option( 'option_four', 'text', 'section_two' )
->label( __( 'A text option:', 'mytheme' ) )
->description( __( 'A text input.', 'mytheme' ) );
}

function get_your_theme_options( $option_name ) {
global $your_theme_options;
add_action( 'after_setup_theme', 'mytheme_options_init', 5 );

// Gets the value for a requested option.
function mytheme_option( $option_name ) {
global $mytheme_options;

return $your_theme_options->option_value( $option_name );
return $mytheme_options->get_value( $option_name );
}

Struts aims to make options as simple as possible, so you can get setup and running quickly.
Struts makes options as simple as possible, so you can get setup and running quickly.

Powered by [The Theme Foundry](http://thethemefoundry.com/)

0 comments on commit c0b8d6b

Please sign in to comment.