Badblog

welcome to our blog

We are Learncodz.


Posts

Comments

The Team

Blog Codz Author

Connect With Us

Join To Connect With Us

Portfolio

    Posted by: Unknown Posted date: 17:56 / comment : 0

    In the first three parts of this series, you've started creating your WordPress widget. In this part, I'll show you how to create the form for your widget and ensure that WordPress can update any settings on it.
    This will mean writing two functions for your Tutsplus_List_Pages_Widget class: the form function and the update function.
    To see all of the parts in this series, click the links:
    To follow this tutorial, you'll need:
    To create the form for your widget, you'll need to populate the form function that you've already added to your Tutsplus_List_Pages_Widget class.
    Open your plugin file, find that function and edit it so it reads:
    This adds the markup for the field, including one input field ($depth), which will be used to set how deep into the page hierarchy the list should go. The default is -1 which will display all levels.
    Now save your plugin file. You'll find that the widget now has a form:
    However if you type anything into it it won't save. So you need to allow the form to save what's input.
    To do this you need to work with the update function you created earlier on. Edit it so it reads:
    This replaces the old value of the depth field ($old_instance) with the new value ($new_instance), and sanitises it using strip_tags. Now when you type into the field, it will save:
    You now have a working form for your widget, which means everything is in place expect actually displaying your widget's output on the site. That's covered in the next tutorial.

    icon allbkg

    Tagged with:

    Next
    Newer Post
    Previous
    Older Post

    No comments:

Comments

The Visitors says
Download Free Software Latest Version