'settings', //sub page to settings page 'page_title' => __('Demo Admin Page','adle'), //The name of this page 'capability' => 'edit_themes', // The capability needed to view the page 'option_group' => 'demo_options', //the name of the option to create in the database 'id' => 'admin_page', // meta box id, unique per page 'fields' => array(), // list of fields (can be added by field arrays) 'local_images' => false, // Use local or hosted images (meta box images for add/remove) 'use_with_theme' => false //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false). ); /** * instantiate your admin page */ $options_panel = new BF_Admin_Page_Class($config); $options_panel->OpenTabs_container(''); /** * define your admin page tabs listing */ $options_panel->TabsListing(array( 'links' => array( 'options_1' => __('Simple Options','adle'), 'options_2' => __('Fancy Options','adle'), 'options_3' => __('Editor Options','adle'), 'options_4' => __('WordPress Options','adle'), 'options_5' => __('Advanced Options','adle'), 'options_6' => __('Field Validation','adle'), 'options_7' => __('Import Export','adle'), ) )); /** * Open admin page first tab */ $options_panel->OpenTab('options_1'); /** * Add fields to your admin page first tab * * Simple options: * input text, checbox, select, radio * textarea */ //title $options_panel->Title(__("Simple Options","adle")); //An optionl descrption paragraph $options_panel->addParagraph(__("This is a simple paragraph","adle")); //text field $options_panel->addText('text_field_id', array('name'=> __('My Text ','adle'), 'std'=> 'text', 'desc' => __('Simple text field description','adle'))); //textarea field $options_panel->addTextarea('textarea_field_id',array('name'=> __('My Textarea ','adle'), 'std'=> 'textarea', 'desc' => __('Simple textarea field description','adle'))); //checkbox field $options_panel->addCheckbox('checkbox_field_id',array('name'=> __('My Checkbox ','adle'), 'std' => true, 'desc' => __('Simple checkbox field description','adle'))); //select field $options_panel->addSelect('select_field_id',array('selectkey1'=>'Select Value1','selectkey2'=>'Select Value2'),array('name'=> __('My select ','adle'), 'std'=> array('selectkey2'), 'desc' => __('Simple select field description','adle'))); //radio field $options_panel->addRadio('radio_field_id',array('radiokey1'=>'Radio Value1','radiokey2'=>'Radio Value2'),array('name'=> __('My Radio Filed','adle'), 'std'=> array('radiokey2'), 'desc' => __('Simple radio field description','adle'))); /** * Close first tab */ $options_panel->CloseTab(); /** * Open admin page Second tab */ $options_panel->OpenTab('options_2'); /** * Add fields to your admin page 2nd tab * * Fancy options: * typography field * image uploader * Pluploader * date picker * time picker * color picker */ //title $options_panel->Title(__('Fancy Options','adle')); //Typography field $options_panel->addTypo('typography_field_id',array('name' => __("My Typography","adle"),'std' => array('size' => '14px', 'color' => '#000000', 'face' => 'arial', 'style' => 'normal'), 'desc' => __('Typography field description','adle'))); //Image field $options_panel->addImage('image_field_id',array('name'=> __('My Image ','adle'),'preview_height' => '120px', 'preview_width' => '440px', 'desc' => __('Simple image field description','adle'))); //PLupload field $options_panel->addPlupload('plupload_field_ID',array('name' => __('PlUpload Field','adle'), 'multiple' => true, 'desc' => __('Simple multiple image field description','adle'))); //date field $options_panel->addDate('date_field_id',array('name'=> __('My Date ','adle'), 'desc' => __('Simple date picker field description','adle'))); //Time field $options_panel->addTime('time_field_id',array('name'=> __('My Time ','adle'), 'desc' => __('Simple time picker field description','adle'))); //Color field $options_panel->addColor('color_field_id',array('name'=> __('My Color ','adle'), 'desc' => __('Simple color picker field description','adle'))); /** * Close second tab */ $options_panel->CloseTab(); /** * Open admin page 3rd tab */ $options_panel->OpenTab('options_3'); /** * Add fields to your admin page 3rd tab * * Editor options: * WYSIWYG (tinyMCE editor) * Syntax code editor (css,html,js,php) */ //title $options_panel->Title(__("Editor Options","adle")); //wysiwyg field $options_panel->addWysiwyg('wysiwyg_field_id',array('name'=> __('My wysiwyg Editor ','adle'), 'desc' => __('wysiwyg field description','adle'))); //code editor field $options_panel->addCode('code_field_id',array('name'=> __('Code Editor ','adle'),'syntax' => 'php', 'desc' => __('code editor field description','adle'))); /** * Close 3rd tab */ $options_panel->CloseTab(); /** * Open admin page 4th tab */ $options_panel->OpenTab('options_4'); /** * Add fields to your admin page 4th tab * * WordPress Options: * Taxonomies dropdown * posts dropdown * Taxonomies checkboxes list * posts checkboxes list * */ //title $options_panel->Title(__("WordPress Options","adle")); //taxonomy select field $options_panel->addTaxonomy('taxonomy_field_id',array('taxonomy' => 'category'),array('name'=> __('My Taxonomy Select','adle'),'class' => 'no-fancy','desc' => __('This field has a
.no-fancyclass which disables the fancy select2 functions','adle') )); //posts select field $options_panel->addPosts('posts_field_id',array('args' => array('post_type' => 'post')),array('name'=> __('My Posts Select','adle'), 'desc' => __('posts select field description','adle'))); //Roles select field $options_panel->addRoles('roles_field_id',array(),array('name'=> __('My Roles Select','adle'), 'desc' => __('roles select field description','adle'))); //taxonomy checkbox field $options_panel->addTaxonomy('taxonomy2_field_id',array('taxonomy' => 'category','type' => 'checkbox_list'),array('name'=> __('My Taxonomy Checkboxes','adle'), 'desc' => __('taxonomy checkboxes field description','adle'))); //posts checkbox field $options_panel->addPosts('posts2_field_id',array('post_type' => 'post','type' => 'checkbox_list'),array('name'=> __('My Posts Checkboxes','adle'), 'class' => 'no-toggle','desc' => __('This field has a
.no-toggleclass which disables the fancy Iphone like toggle','adle'))); //Roles checkbox field $options_panel->addRoles('roles2_field_id',array('type' => 'checkbox_list' ),array('name'=> __('My Roles Checkboxes','adle'), 'desc' => __('roles checboxes field description','adle'))); /** * Close 4th tab */ $options_panel->CloseTab(); /** * Open admin page 5th tab */ $options_panel->OpenTab('options_5'); //title $options_panel->Title(__("Advanced Options","adle")); //sortable field $options_panel->addSortable('sortable_field_id',array('1' => 'One','2'=> 'Two', '3' => 'three', '4'=> 'four'),array('name' => __('My Sortable Field','adle'), 'desc' => __('Sortable field description','adle'))); /* * To Create a reapeater Block first create an array of fields * use the same functions as above but add true as a last param */ $repeater_fields[] = $options_panel->addText('re_text_field_id',array('name'=> __('My Text ','adle')),true); $repeater_fields[] = $options_panel->addTextarea('re_textarea_field_id',array('name'=> __('My Textarea ','adle')),true); $repeater_fields[] = $options_panel->addImage('image_field_id',array('name'=> __('My Image ','adle')),true); $repeater_fields[] = $options_panel->addCheckbox('checkbox_field_id',array('name'=> __('My Checkbox ','adle')),true); /* * Then just add the fields to the repeater block */ //repeater block $options_panel->addRepeaterBlock('re_',array('sortable' => true, 'inline' => true, 'name' => __('This is a Repeater Block','adle'),'fields' => $repeater_fields, 'desc' => __('Repeater field description','adle'))); /** * To Create a Conditional Block first create an array of fields (just like a repeater block * use the same functions as above but add true as a last param */ $Conditinal_fields[] = $options_panel->addText('con_text_field_id',array('name'=> __('My Text ','adle')),true); $Conditinal_fields[] = $options_panel->addTextarea('con_textarea_field_id',array('name'=> __('My Textarea ','adle')),true); $Conditinal_fields[] = $options_panel->addImage('con_image_field_id',array('name'=> __('My Image ','adle')),true); $Conditinal_fields[] = $options_panel->addCheckbox('con_checkbox_field_id',array('name'=> __('My Checkbox ','adle')),true); /** * Then just add the fields to the repeater block */ //conditinal block $options_panel->addCondition('conditinal_fields', array( 'name' => __('Enable conditinal fields? ','adle'), 'desc' => __('Turn ON if you want to enable the conditinal fields.','adle'), 'fields' => $Conditinal_fields, 'std' => false )); /** * Close 5th tab */ $options_panel->CloseTab(); /** * Open admin page 6th tab * field validation * `email` => validate email * `alphanumeric` => validate alphanumeric * `url` => validate url * `length` => check for string length * `maxlength` => check for max string length * `minlength` => check for min string length * `maxvalue` => check for max numeric value * `minvalue` => check for min numeric value * `numeric` => check for numeric value */ $options_panel->OpenTab('options_6'); //email validation $options_panel->addText('email_text_field_id', array( 'name' => __('My Email validation ','adle'), 'std' => 'test@domain.com', 'desc' => __("Field with email validation","adle"), 'validate' => array( 'email' => array('param' => '','message' => __("must be a valid email address","adle")) ) ) ); //alphanumeric validation $options_panel->addText('an_text_field_id', array( 'name' => __('My alpha numeric validation ','adle'), 'std' => 'abcd1234', 'desc' => __("Field with alpa numeric validation, try entring something like #$","adle"), 'validate' => array( 'alphanumeric' => array('param' => '','message' => __("must be a valid alpha numeric chars only","adle")) ) ) ); // string length exceeds maximum length validation $options_panel->addText('max_text_field_id', array( 'name' => __('My Max length of string validation ','adle'), 'std' => 'abcdefghi', 'desc' => __("Field with max string lenght validation,So try entering a longer string","adle"), 'validate' => array( 'maxlength' => array('param' => 10,'message' => __("must be not exceed 10 chars long","adle")) ) ) ); // string length exceeds maximum length validation $options_panel->addText('min_text_field_id', array( 'name' => __('My Min length of string validation ','adle'), 'std' => 'abcdefghi', 'desc' => __("Field with min string lenght validation, So try entering a shorter string","adle"), 'validate' => array( 'minlength' => array('param' => 8,'message' => __("must be a minimum length of 8 chars long","adle")) ) ) ); // check for exactly length of string validation $options_panel->addText('exact_text_field_id', array( 'name' => __('My exactly length of string validation ','adle'), 'std' => 'abcdefghij', 'desc' => __("Field with exact string lenght validation, So try entering a shorter or longer string","adle"), 'validate' => array( 'length' => array('param' => 10,'message' => __("must be exactly 10 chars long","adle")) ) ) ); //is_numeric $options_panel->addText('n_text_field_id', array( 'name' => __('My numeric validation ','adle'), 'std' => 1, 'desc' => __("Field with numeric value validation","adle"), 'validate' => array( 'numeric' => array('param' => '','message' => __("must be numeric value","adle")) ) ) ); //min numeric value $options_panel->addText('nmin_text_field_id', array( 'name' => __('My Min numeric validation ','adle'), 'std' => 9, 'desc' => __("Field with min numeric value validation","adle"), 'validate' => array( 'minvalue' => array('param' => 8,'message' => __("must be numeric with a min value of 8","adle")) ) ) ); //max numeric value $options_panel->addText('nmax_text_field_id', array( 'name' => __('My Max numeric validation ','adle'), 'std' => 9, 'desc' => __("Field with max numeric value validation","adle"), 'validate' => array( 'maxvalue' => array('param' => 10,'message' => __("must be numeric with a Max value of 10","adle")) ) ) ); //is_url validation $options_panel->addText('url_text_field_id', array( 'name' => __('My URL validation ','adle'), 'std' => 'http://en.bainternet.info', 'desc' => __("Field with url value validation","adle"), 'validate' => array( 'url' => array('param' => '','message' => __("must be a valid URL","adle")) ) ) ); /** * Close 6th tab */ $options_panel->CloseTab(); /** * Open admin page 7th tab */ $options_panel->OpenTab('options_7'); //title $options_panel->Title(__("Import Export","adle")); /** * add import export functionallty */ $options_panel->addImportExport(); /** * Close 7th tab */ $options_panel->CloseTab(); $options_panel->CloseTab(); //Now Just for the fun I'll add Help tabs $options_panel->HelpTab(array( 'id' =>'tab_id', 'title' => __('My help tab title','adle'), 'content' =>'
'.__('This is my Help Tab content','adle').'
' )); $options_panel->HelpTab(array( 'id' => 'tab_id2', 'title' => __('My 2nd help tab title','adle'), 'callback' => 'help_tab_callback_demo' )); //help tab callback function function help_tab_callback_demo(){ echo ''.__('This is my 2nd Help Tab content from a callback function','adle').'
'; }