/**
  *
  * Constructor
  * Starts the class automatically if $settings is given
  * @param array $settings
  * @return none
  * @since 0.1
  * @access public
  */
 public function __construct($outputclass = '')
 {
     if ('' != $outputclass) {
         $this->set_output($outputclass);
     }
     self::$config = new stdClass();
     self::$config->basic = new stdClass();
     self::$config->scripts = new stdClass();
     self::$config->styles = new stdClass();
     self::$config->sections = new stdClass();
 }
 /**
  * 
  * Constructor
  * @@param none
  * @return void
  * @since 0.1
  * @access public
  * @return object
  */
 public function __construct()
 {
     if (null !== self::$plugin_self) {
         return self::$plugin_self;
     }
     // register the deactivation hook
     register_deactivation_hook(__FILE__, array(&$this, 'deactivation'));
     // create an instance of the class
     $optionspage = new Easy_Settings_API();
     // starts with basic configuration
     $base_config = new stdClass();
     $base_config->options_group = self::OPTIONS_GROUP;
     $base_config->options_name = self::OPTIONS_NAME;
     $base_config->validate_callback = array(__CLASS__, 'validate_input');
     //'Settings_API_Class_Demo::validate_input',
     $base_config->menu_position = 'options';
     $base_config->page_slug = 'sac_demopage';
     $base_config->page_title = 'Settings API Class Demo Page';
     $base_config->menu_title = 'SAC Demopage';
     $base_config->description = 'This is a demo page for the Settings API Class.';
     $base_config->capability = 'manage_options';
     $base_config->icon = 'icon-options-general';
     $optionspage->basic_config($base_config, __FILE__);
     /*
      * JavaScript
      * 
      * tag = source 		:: simplest way (script will be enqueued with no dependencies, in head)
      * 
      * tag->src 			= string 	:: full relative path to file
      * tag->dependencies	= array()	:: dependencies as array 
      * tag->version			= string	:: js version
      * tag->in_footer		= bool		:: load script in footer (true) or head (false)
      */
     $scripts = new stdClass();
     $scripts->sac_demo_js = plugins_url('js/demo_js.js', __FILE__);
     $scripts->sac_demo1_js->src = plugins_url('js/alert.js', __FILE__);
     $scripts->sac_demo2_js->src = plugins_url('/js/demo_js.js', __FILE__);
     $scripts->sac_demo2_js->dependencies = array('jquery');
     $scripts->sac_demo2_js->version = false;
     $scripts->sac_demo2_js->in_footer = true;
     $optionspage->add_script($scripts);
     /*
      * Stylesheets
      *
      * tag->src 	= string		:: full relative path to sourcefile 
      * tag->deps 	= array			:: array with dependencies
      */
     $styles = new stdClass();
     $styles->first_demo_style->src = plugins_url('css/demostyle.css', __FILE__);
     $styles->first_demo_style->deps = 'none';
     $styles->second_demo_style->src = plugins_url('css/demostyle.css', __FILE__);
     $styles->third_demo_style = plugins_url('css/demostyle.css', __FILE__);
     $optionspage->add_style($styles);
     /*
      * Sections
      * 
      * tag->title
      * tag->description
      */
     $sections = new stdClass();
     $sections->general->title = __('General Settings');
     $sections->general->description = __('Description for general settings (optional).');
     $sections->multi->title = __('Multiple Choice');
     $sections->multi->description = __('More than one choice are available.');
     $optionspage->add_section($sections);
     /*
      * Settings fields
      * 
      * Each field can define some params. Minimum are 'id', 'type', 'title' and 'section'
      * 
      * tag->id
      * tag->type
      * tag->title
      * tag->section
      * tag->some_other_params
      */
     /* fields for section 'general' */
     // heading field
     $field = new stdClass();
     $field->heading->id = 'demo_heading';
     $field->heading->type = 'heading';
     $field->heading->title = 'Heading';
     $field->heading->section = 'general';
     $field->heading->description = __('Headings only use the title and description as parameter.');
     $optionspage->add_field($field);
     // custom field
     $field = new stdClass();
     $field->custom->id = 'demo_custom';
     $field->custom->type = 'custom';
     $field->custom->title = 'Custom';
     $field->custom->section = 'general';
     $field->custom->description = 'Custum is using a callbackfunction to display the input';
     $field->custom->callback = array(__CLASS__, 'custom_callback');
     // each single array-element is passed as single argument to the
     // callback-function.
     // all keys in an associativ array will be lost.
     // if an array should passed as argument to the callback-function,
     // it must be itself an array.
     $field->custom->arguments = array('one' => 'eins', array('two' => 'zwei'));
     $optionspage->add_field($field);
     // checkbox field
     $field = new stdClass();
     $field->checkbox->id = 'demo_checkbox';
     $field->checkbox->type = 'checkbox';
     $field->checkbox->title = __('Checkbox');
     $field->checkbox->section = 'general';
     $field->checkbox->description = __('The description of the checkbox');
     $field->checkbox->text_after = __('Text after the checkbox. This text is formated as <code>label</code>.');
     $field->checkbox->std = 'on';
     // values are 'on' or '' (empty). Everything else than 'on' is equal to an empty value
     $optionspage->add_field($field);
     // adding more than one field at once
     $field = new stdClass();
     // input field
     $field->input->id = 'demo_textinput';
     $field->input->title = __('Text input');
     $field->input->section = 'general';
     $field->input->description = __('The description of the text input');
     $field->input->text_after = __('Text after the input-field');
     $field->input->std = 'demo text';
     $field->input->size = 30;
     $field->input->type = 'text';
     // password field
     $field->password->id = 'demo_password';
     $field->password->title = __('Password');
     $field->password->section = 'general';
     $field->password->description = __('You can even preselect a standard password');
     $field->password->text_after = __('Text after the password-field');
     $field->password->std = 'password';
     $field->password->size = 30;
     $field->password->type = 'password';
     // textarea field
     $field->textarea->id = 'demo_texarea';
     $field->textarea->title = __('Textarea');
     $field->textarea->description = __('The description of the textarea');
     $field->textarea->text_after = __('Text after the textarea');
     $field->textarea->std = 'Textareas are good for longer inputs. You can select the width and height of the textarea with the rows- and cols-parameter.';
     $field->textarea->rows = 3;
     $field->textarea->cols = 30;
     $field->textarea->type = 'textarea';
     $field->textarea->section = 'general';
     $optionspage->add_field($field);
     /* fields for section 'multi' (inputs with multiple choice) */
     $mfield = new stdClass();
     // radio field
     $mfields->radio->id = 'demo_radio';
     $mfields->radio->title = __('Radio');
     $mfields->radio->description = __('The description of the radio');
     $mfields->radio->choices = array('yes' => 'Yes', 'no' => 'No', 'maybe' => 'Maybe');
     $mfields->radio->std = 'yes';
     $mfields->radio->type = 'radio';
     //$mfields->radio->section		= 'multi';
     // select field
     $mfields->select->id = 'demo_select';
     $mfields->select->title = __('Select');
     $mfields->select->description = __('The description of select');
     $mfields->select->choices = array('' => 'Please select', 'yes' => 'Yes', 'no' => 'No', 'maybe' => 'Maybe');
     $mfields->select->std = '';
     $mfields->select->type = 'select';
     //$mfields->select->section		= 'multi';
     // field multicheckbox
     $mfields->mcheckbox->id = 'demo_multicheckbox';
     $mfields->mcheckbox->title = __('Multi checkbox');
     $mfields->mcheckbox->description = __('The description of multi checkbox');
     $mfields->mcheckbox->choices = array('yes' => 'Yes', 'no' => 'No', 'maybe' => 'Maybe');
     $mfields->mcheckbox->std = array('no', 'maybe');
     $mfields->mcheckbox->type = 'mcheckbox';
     //$mfields->mcheckbox->section		= 'multi';
     // field multiselect
     $mfields->mselect->id = 'demo_mselect';
     $mfields->mselect->title = __('Multi-Select');
     $mfields->mselect->description = __('The description of multi-select');
     $mfields->mselect->choices = array('' => 'Please select', 'yes' => 'Yes', 'no' => 'No', 'maybe' => 'Maybe');
     $mfields->mselect->std = array('yes', 'no');
     $mfields->mselect->size = 0;
     $mfields->mselect->type = 'mselect';
     // adding fields to section 'multi'
     // notice that the section where to add the fields
     // is set in method-call not in the field definitions
     $optionspage->add_field($mfields, 'multi');
     // create the optionspage
     $optionspage->create_optionspage();
     // copy the config for use in validate-callback
     self::$optionspage = $optionspage;
 }