• Resolved sandyfischler

    (@sandyfischler)


    I’ve got multiple tabs open with tutorials for creating a custom WP widget and I’m confused since they are all saying slighting different things.

    I’ve created my plugin and it shows up in the plugin list (good so far).

    Where I’m challenged is in adding the code to actually create the widget and what order things go in since each tutorial is doing it differently and I’d like to start out with Best Practices.

    This where I am so far and I’m already stuck because I have questions….

    <?php
    /*
    Plugin Name: Fuller Donation Widgets
    Description: Donation channel widgets
    Author: Sandy Fischler
    Version: 1
    */
    /* Start Adding Functions Below this Line */
    
    class fuller_of_openstrap_donation_page_one extends WP_Widget {
        function fuller_of_openstrap_donation_page_one() {
            parent::__construct(false, $name = __('Fuller Donation Widget One', 'fuller_of_openstrap_donation_page_one') );
        }

    Questions:

    1) Do I state the class first or register the widget first? I see it done both ways. One tutorial starts out with register widget and another has it much lower in the code.

    2) In the WP codex they use parent::__construct, in one tutorial they use parent::WP_Widget which is correct?

    Thanks!

Viewing 4 replies - 16 through 19 (of 19 total)
Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘Custom Widget Code’ is closed to new replies.