Skip to content

Instantly share code, notes, and snippets.

@awps
Created Dec 19, 2013
Embed
What would you like to do?
<?php
/*-----------------------------------------------------------
- Name: Options Widget
- Description: Test SMK Toolkit
- Version: 1.0
-------------------------------------------------------------*/
if( ! class_exists('Options_Widget') && class_exists('SMK_Toolkit_Widget') ) {
class Options_Widget extends SMK_Toolkit_Widget {
/*-----------------------------------------------------------
Constructor
-------------------------------------------------------------*/
function Options_Widget() {
$widget_ops = array(
'classname' => 'options_widget',
'description' => 'SMK Toolkit Widget Options Test'
);
//If you're using WP Color Picker, is recomended to set the widget width to a number greater then 270
$widget_settings = array(
'width' => 270,
'height' => 350
);
$this->WP_Widget('options_widget2', 'Options Widget', $widget_ops, $widget_settings );
}
/*-----------------------------------------------------------
Options
-------------------------------------------------------------*/
function options() {
$wgt_opt = array();
$wgt_opt[] = array(
'id' => 'text_field',
'type' => 'input',
'label' => 'My widget:',
//'std' => 'bla',
//'size' => 'min',
//'input' => 'text',
//'class' => 'super_class_fdfsfsdf',
'desc' => 'Input description.'
);
$wgt_opt[] = array(
'id' => 'textarea_field',
'type' => 'textarea',
'label' => 'My new textarea:',
//'std' => 'my text lalalala',
//'rows' => '10',
//'class' => 'super_class',
'desc' => 'Textarea description'
);
$wgt_opt[] = array(
'id' => 'checkbox_field',
'type' => 'checkbox',
'label' => 'My new checkbox',
'std' => 1,
//'desc' => 'Checkbox description'
);
$wgt_opt[] = array(
'id' => 'select_field',
'type' => 'select',
'options' => array('one' => 'First option', 'two' => 'Second option'),
'label' => 'My new select',
'std' => 'two',
//'desc' => 'Select description'
);
$wgt_opt[] = array(
'id' => 'radio_field',
'type' => 'radio',
'options' => array('one' => 'First option', 'two' => 'Second option'),
'label' => 'My new radio',
'std' => 'two',
//'inline' => 0,//0 or 1. "1" display elements in the same line, "0" each in a new line. Default: 0
//'desc' => 'Radio description'
);
$wgt_opt[] = array(
'id' => 'multicheck_field',
'type' => 'multicheck',
'options' => array(
'one' => 'First option',
'two' => 'Second option',
'three' => 'Third option',
'four' => 'Fourth option'
),
'label' => 'My new multicheck',
'std' => array('two'),
//'inline' => 0,//0 or 1. "1" display elements in the same line, "0" each in a new line. Default: 0
//'desc' => 'Multicheck description'
);
$wgt_opt[] = array(
'id' => 'color_field',
'type' => 'color',
'label' => 'My new color',
//'std' => '#5cc918',
//'desc' => 'Input description.'
);
$wgt_opt[] = array(
'id' => 'upload_field',
'type' => 'upload',
'label' => 'My new upload',
//'std' => '',
//'desc' => 'Input description.'
);
$wgt_opt[] = array(
'id' => 'sliderui_field',
'type' => 'sliderui',
'label' => 'My new sliderui',
'min' => '12',
'max' => '154',
'step' => '3',
'std' => '53',
'desc' => 'Input description.'
);
return $wgt_opt;
}
/*-----------------------------------------------------------
The Widget
-------------------------------------------------------------*/
function widget( $args, $instance ) {
extract($args);
echo $before_widget;
// Here is the HTML.
// For example to get first text input do the following
echo $instance['text_field']
echo $after_widget;
}
}//End Class
}//End class_exists check
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment