Hot File

Lesson 08: Creating pages in WordPress Management Options

View: 242    Dowload: 0   Comment: 0   Post by: admin  
Author: none   Category: WordPress template   Fields: Other

6 point/2 review File has been tested

Applying the knowledge of Options in WordPress API is in this article I will guide you to create a page in admin management options .

Introduction

Applying the knowledge of Lesson 07: Options in WordPress API is in this article I will guide you to create a page in admin management options
In previous articles I have outlined an example of management information email username and password , so in this article we will create a two- page information management , ie the user can edit and change their values ​​change .

To create this Options page management , you will have to make the turn in steps that I will present below

1. Create admin menu

When you log into the admin management system will see a menu based user interface as follows :

This is the default menu ( fixed ) of WordPress .

 Problems learn all this , I'll menu for a future article , so in this article I will guide you how to add a simple menu whiff , and his position will add a submenu inside Appearance items named Theme Options and click on the menu when the page will redirect to manage your Gmail account information . 

  click the file you Option-api.php erase all the old code and paste into the following code:

// Additional content on a menu submenu father
add_submenu_options function ( )
{
    add_submenu_page (
            ' Themes.php ' , // Menu father
            ' Theme Options' , // menu title
            ' Theme Options' , // The name of the menu
            ' Manage_options ' , // The access , meaningful values ​​only supper admin and user admin DC
            ' Theme - options' , // menu Slug
            ' Access_menu_options ' // callback displays the contents of the menu
    ) ;
}
 
// Add the action displayed on the Action submenu admin_menu Hooks
add_action ( ' admin_menu ' , ' add_submenu_options ' ) ;

 

This code displays a submenu within the Appearance menu father .

You try to click Theme Options menu you will get an error message like the following page :

This error may mean that you lack a callback function named access_menu_options . access_menu_options are values ​​that have been instilled into add_submenu_page code . To all my fault, you create a function in the file named access_menu_options option-api.php always offline.

// Additional content on a menu submenu father
add_submenu_options function ( )
{
    add_submenu_page (
            ' Themes.php ' , // Menu father
            ' Theme Options' , // menu title
            ' Theme Options' , // The name of the menu
            ' Manage_options ' , // The access , meaningful values ​​only supper admin and user admin DC
            ' Theme - options' , // menu Slug
            ' Access_menu_options ' // callback displays the contents of the menu
    ) ;
}
 
// Handler when clicking on menu
access_menu_options function ( )
{
    echo ' < h1 > Welcome to Theme Options Page < / h1 > ' ;
}
 
// Add the action displayed on the Action submenu admin_menu Hooks
add_action ( ' admin_menu ' , ' add_submenu_options ' ) ;

Rerun this page you will find there is no error message again .

2. Create a form management interface Theme Options

Access_menu_options function will have the task of handling display of the form interface . However for ease of file management , you create a folder named templates within public folder , then create a theme-option.php files inside the folder template used to display a form, ultimately require a file theme-option.php in access_menu_options function .

Folder structure :

Content in access_menu_options function :

// Handler when clicking on menu
access_menu_options function ( )
{
    require ( ' template / theme - option.php ' ) ;
}

theme-option.php file contents


 

Manage theme options

Email
Password
 

This menu strange running , you will see an interface as follows :

Thus we have completed step 2 , was wonderful .

3. Show information before updating

Now we will code the function to display information on the input box so that users can edit using the APIs get_option Options .

You fix access_menu_options function as follows:

// Handler when clicking on menu
access_menu_options function ( )
{
     
     
    // Get the information in the table Options
    $ Email = get_option ( ' mailer_gmail_username ' ) ;
    $ Pass = get_option ( ' mailer_gmail_password ' ) ;
     
    require ( ' template / theme - option.php ' ) ;
}

Then through theme-option.php file amended as follows :


 

Manage theme options

Email
Password
 

4. Handling save information Options

You want to look your form management option not transmit path into the action attribute , so when submitting the form it will handle in the pages up .

You fix access_menu_options function as follows:

// Handler when clicking on menu
access_menu_options function ( )
{
    if ( ! empty ( $ _ POST [ 'save - theme -option ' ] ) )
    {
        $ Email = $ _ POST [ ' email ' ] ;
        $ Pass = $ _ POST [ ' password' ] ;
         
        // Update ( if not, add a new automated system )
        update_option ( ' mailer_gmail_username ' , $ email ) ;
        update_option ( ' mailer_gmail_password ' , $ pass) ;
    }
     
    // Get the information in the table Options
    $ Email = get_option ( ' mailer_gmail_username ' ) ;
    $ Pass = get_option ( ' mailer_gmail_password ' ) ;
     
    require ( ' template / theme - option.php ' ) ;
}

And this is the final step of this management function options . You go to this page and make updates contents 2 information to see the results offline :)

5. Conclusion

In this article I only guide basic usage and no combination of security functions in WordPress so you take a whiff for reference , the latter when it comes to security issues , we 'll do it again a more professional way .  This article I have not learned to use the function for creating the menu , so my next post will talk about this issue .

Lesson 08: Creating pages in WordPress Management Options

Lesson 08: Creating pages in WordPress Management Options Posted on 06-05-2016  Applying the knowledge of Options in WordPress API is in this article I will guide you to create a page in admin management options . 3/10 242

Comment:

To comment you must be logged in members.

Files with category

  • 11 Powerful Tips and Techniques in wordpress

    View: 313    Download: 0   Comment: 0   Author: none  

    11 Powerful Tips and Techniques in wordpress

    Category: WordPress template
    Fields: Other

    0/0 review
    Debugging is an essential skill for any developer. This tutorial will show you 11 powerful ways to debug WordPress and PHP errors.

  • MH Edition Lite Responsive WordPress Theme 2017 Free

    View: 380    Download: 3   Comment: 0   Author: none  

    MH Edition Lite Responsive WordPress Theme 2017 Free

    Category: WordPress template
    Fields: Other

    0/0 review
    MH Edition lite is a flexible and visually sophisticated WordPress theme for technology and news magazines. This magazine theme can transform your current WordPress website into a powerful and yet lightweight online magazine or dynamic news website...

  • Morning Monday Lite Responsive WordPress Theme Free

    View: 361    Download: 5   Comment: 0   Author: none  

    Morning Monday Lite Responsive WordPress Theme Free

    Category: WordPress template
    Fields: Other

    2.25/2 review
    Morning Monday Lite theme is designed for magazine with flexible layout. The theme is based on KOPATHEME layout manager technique that will let you flexibility choose layout options of every pages within your site.

  • How to Translate a WordPress Plugin Description

    View: 442    Download: 0   Comment: 0   Author: none  

    How to Translate a WordPress Plugin Description

    Category: WordPress template
    Fields: Other

    0.020325203252033/246 review
    If you’ve developed a useful plugin for WordPress, that’s great – but it’s even better if you make your plugin accessible to users speaking other languages.

  • Lovecraft Responsive WordPress Theme Free

    View: 315    Download: 1   Comment: 0   Author: none  

    Lovecraft Responsive WordPress Theme Free

    Category: WordPress template
    Fields: Other

    2/2 review
    Lovecraft is a beautiful two-column theme for bloggers. It features a responsive design, great typography, a full-width header image

  • Ascent Theme is a fully responsive WordPress theme

    View: 4904    Download: 0   Comment: 0   Author: none  

    Ascent Theme is a fully responsive WordPress theme

    Category: WordPress template
    Fields: Other

    4.5/1 review
    Ascent Theme is a fully responsive WordPress theme that looks elegant on any devices. It is simple, clean and lightweight WordPress theme based on the most modern technologies like HTML5 and CSS3.

  • Photolab Responsive WordPress Theme Free

    View: 406    Download: 0   Comment: 0   Author: none  

    Photolab Responsive WordPress Theme Free

    Category: WordPress template
    Fields: Other

    4/1 review
    Photolab theme echoes a flat design approach and a modern clean look perfect for creating an engaging blog. Its layout inspired by the latest trends underlines visual excellence of the theme without distracting from the content.

  • ZeroGravity is a simple and light WordPress theme

    View: 378    Download: 0   Comment: 0   Author: none  

    ZeroGravity is a simple and light WordPress theme

    Category: WordPress template
    Fields: Other

    4.5/1 review
    ZeroGravity is a simple and light WordPress theme with a clear and neat design. Some its features are: left sidebar or right, custom theme color (blue, green, orange, red, pink, yellow or purple), custom favicon, six different Google Fonts,...

 
Newsletter Email

File suggestion for you

File top downloads

logo codetitle
Codetitle.com - library source code to share, download the file to the community
Copyright © 2015. All rights reserved. codetitle.com Develope by Vinagon .Ltd