WordPress "in_widget_form" does not display basic HTML Code

Viewed 10

I have been taking what I thought would be a simple HTML code. I tried to follow this tutorial here:

However, I am not able to get a simple input field to be added to the bottom of any widget. Could someone please tell me what I am missing?

After add below to my functions file, below does not output HTML of any thing withing wp-admin/widgets.php. Help please!

    function thmfdn_add_menu_description_option( $widget, $return, $instance ) {
        // Are we dealing with a nav menu widget?
        if ( 'nav_menu' == $widget->id_base ) {
     
            // Display the description option.
            $description = isset( $instance['description'] ) ? $instance['description'] : '';
            ?>
                <p>
                    <input class="checkbox" type="checkbox" id="<?php echo $widget->get_field_id('description'); ?>" name="<?php echo $widget->get_field_name('description'); ?>" <?php checked( true , $description ); ?> />
                    <label for="<?php echo $widget->get_field_id('description'); ?>">
                        <?php _e( 'Show descriptions', 'thmfdn_textdomain' ); ?>
                    </label>
                </p>
            <?php
        }
    }
add_action('in_widget_form', 'thmfdn_add_menu_description_option', 10, 3 );

My goal is to add visibility controls to widgets in order to dynamically display or high them on the frontend based on user logged in or not. To achieve that I want to extend existing widgets by adding extra settings that sets whether a widget should be rendered on frontend based on user status.

Thank you for any correction or solutions.

0 Answers
Related