• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
seegatesite header

Seegatesite.com

Seegatesite.com - Programming Tutorial , Sharing , How and Learn Together

  • TOOLS
    • Bootstrap Navbar Online Generator
    • Customize Sidebar Menu Bootstrap 3
    • Bootstrap Demo
  • ADVERTISE
  • CATEGORIES
    • Android
    • Blogging Tips
    • Database
    • CSS
    • Info Gadget
    • Javascript
    • Linux
    • PHP
    • Various
    • WordPress
  • Q&A
  • PHP
  • JAVASCRIPT
  • JQUERY
  • ANGULAR
  • WORDPRESS
  • SEO
  • REACT
🏠 » PHP » Easy Create Wordpress Theme Options with Framework

Easy Create WordPress Theme Options with Framework

By Sigit Prasetya Nugroho ∙ October 29, 2014 ∙ PHP ∙ Leave a Comment

Share : TwitterFacebookTelegramWhatsapp

Using the options plugin framework allows us to create a theme options. For those developers wordpress templates, this framework helps us to make the initial setting themes without much coding.

how to use options framework plugin

Quoted from the website http://wptheming.com/options-framework-theme/, The Options Framework Theme has all the code included to build a out a full featured options panel. It’s a bundled version of the Options Framework Plugin for those folks who want to build the options directly into the theme (rather than relying on a plugin).

Table of Contents

  • 1  How to build wordpress theme options for your own theme? 
    • 1.1  How to call theme options value that we have built 

 How to build wordpress theme options for your own theme? 

1. Download options framework from github.

2. Copy that framework folder at your theme directory.

3. Call options-framework.php class from functions.php (your theme functions) like example below

1
2
3
4
if ( !function_exists( 'optionsframework_init' ) ) {
define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/_/inc/' );
require_once dirname( __FILE__ ) . '/_/inc/options-framework.php';
}

From the example, we must define options framework directory first and call options-framework.php with require_once

4. Create php file as options.php in the root folder of your theme (Your wordpress theme options will be stored here).

5. Write the following syntax in options.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
function optionsframework_option_name() {
$themename = get_option( 'stylesheet' );
$themename = preg_replace("/\W/", "_", strtolower($themename) );
$optionsframework_settings = get_option( 'optionsframework' );
$optionsframework_settings['id'] = $themename;
update_option( 'optionsframework', $optionsframework_settings );
}
function optionsframework_options() {
$options_categories = array();
$options_categories_obj = get_categories();
foreach ($options_categories_obj as $category) {
$options_categories[$category->cat_ID] = $category->cat_name;
}
$options_tags = array();
$options_tags_obj = get_tags();
foreach ( $options_tags_obj as $tag ) {
$options_tags[$tag->term_id] = $tag->name;
}
$options_pages = array();
$options_pages_obj = get_pages('sort_column=post_parent,menu_order');
$options_pages[''] = 'Select a page:';
foreach ($options_pages_obj as $page) {
$options_pages[$page->ID] = $page->post_title;
}
 
$options = array();
 
// options will be written below
$options[] = array(
'name' => __('License Keys', 'standar'),
'type' => 'heading');
$options[] = array(
'name' => __('License key', 'html5reset'),
'desc' => __('License key', 'html5reset'),
'id'   => 'my_licensekey',
'std'  => '',
'type' => 'password');
$options[] = array(
'name' => __('Secret key', 'html5reset'),
'desc' => __('Secret key', 'html5reset'),
'id'   => 'my_secretkey',
'std'  => '',
'type' => 'password');
$options[] = array(
'name' => __('Google Webmasters', 'html5reset'),
'desc' => __("Speaking of Google, don't forget to set your site up: <a href='http://google.com/webmasters' target='_blank' rel='nofollow'>http://google.com/webmasters</a>", 'html5reset'),
'id' => 'meta_google',
'std' => '',
'type' => 'text');
// Ads
$options[] = array(
'name' => __('Advertisements', 'html5reset'),
'type' => 'heading');
$options[] = array(
'name' => __('Header Ads', 'html5reset'),
'desc' => __('Header Ads (Use 728 x 90 Banner ads)', 'html5reset'),
'id' => 'my_ads1',
'type' => 'textarea');
$options[] = array(
'name' => __('Home Ads', 'html5reset'),
'desc' => __('Home Ads (Use 300 x 250 Banner ads)', 'html5reset'),
'id' => 'my_ads2',
'type' => 'upload');
return $options;
}

Explanation :

  • To create options heading write the following syntax.

1
2
3
$options[] = array(
'name' => __('Advertisements', 'html5reset'),
'type' => 'heading');

  • To create options value write the following syntax.

1
2
3
4
5
6
$options[] = array(
'name' => __('License key', 'html5reset'),
'desc' => __('License key', 'html5reset'),
'id'   => 'sgt_licensekey',
'std'  => '',
'type' => 'text');

  • From the official website, These are the options currently available.- text
    – textarea
    – checkbox
    – select
    – radio
    – upload (an image uploader)
    – images (use images instead of radio buttons)
    – background (a set of options to define a background)
    – multicheck
    – color (a jquery color picker)
    – typography (a set of options to define typography)
    – editor
    I tried to add a password options and not be a problem.
    1
    'type' =&gt; 'password'

example wordpress theme options

 How to call theme options value that we have built 

Use syntax below to call the wordpress options we have built

1
of_get_option("value_id")

In example :

If you have google site verification options, you can put the source code in header.php as below

1
echo '<meta name="google-site-verification" content="'.of_get_option("meta_google").'" />'; ?>

Okay, easy right. If you have question or want to provide feedback on my articles, please write comment below. In addition to the Easy Create WordPress Theme Options with Framework article, there are a lot of my articles useful for you, please check here

Another PHP Related Post :

  • Tutorial Create Simple POS Using ReactJS And Laravel Lumen Part 1
  • How To Replace String With Another String In PHP
  • Login Page – Tutorial CRUD Client and API Server Using JQuery And Lumen Part 2
  • Tutorial CRUD Client and API Server Using JQuery And Lumen Part 1
  • How To Solve Problems Illegal mix of collations (latin1_swedish_ci,IMPLICIT) In Laravel
  • How To Resolve No ‘Access-Control-Allow-Origin’ Header In Lumen

Avatar for Sigit Prasetya Nugroho

About Sigit Prasetya Nugroho

This site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Welcome to my Home,

Avatar for Sigit Prasetya NugrohoThis site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.



Popular Articles

Checked checkbox AdminLTE Bootstrap in Jquery

November 4, 2014 By Sigit Prasetya Nugroho 7 Comments

Simple create date format validation with jqueryUI

December 21, 2014 By Sigit Prasetya Nugroho Leave a Comment

Create Simple Progress Bar for Fake Online Generator with Jquery

January 10, 2015 By Sigit Prasetya Nugroho Leave a Comment

22+ Coolest Free Jquery Plugin For Premium Theme

October 3, 2015 By Sigit Prasetya Nugroho Leave a Comment

Easy Build Your Anti Copy Paste Plugin

October 6, 2015 By Sigit Prasetya Nugroho Leave a Comment

Popular Tags

adminlte (15) adsense (13) adsense tips (4) affiliate amazon (13) amazon (12) Android (8) angular (16) angular 4 (12) angular 5 (4) asin grabber (3) Bootstrap (27) codeigniter (5) create wordpress theme (5) crud (8) css (6) free wordpress theme (7) google adsense (4) imacros (4) increase traffic (6) jquery (34) laravel (10) laravel 5 (5) learn android (5) lumen api (4) modal dialog (5) mysql (6) nodeJs (4) optimize seo (4) pdo (6) php (30) plugin (53) pos (8) Publisher Tips (5) react (6) Reactjs (9) SEO (37) theme (17) tutorial angular (5) tutorial angular 4 (6) tutorial javascript (10) tutorial javascript beginners (4) twitter (3) wordpress (18) wordpress plugin (13) XMLRPC (5)




  • About
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms and Conditions

©2022 Seegatesite.com