Widget form not displaying for media widgets in WordPress

enter image description here

I am creating a plugin where I want to display the widget’s form using the following code. Widget form for media widgets is not being displayed while other widget’s form is being displayed perfectly. Is this something to do with wpmedia or some other javascript files or libraries?

 <?php
    public static function mmth_widget_items($widget_id, $widget_key_id = 0){   
        global $wp_registered_widget_controls;   
        $control = $wp_registered_widget_controls[$widget_id];
        $nonce = wp_create_nonce('mmth_save_widget_' . $widget_id);  
        $id_base = isset( $control['id_base'] ) ? $control['id_base'] : $control['id']; 
        ?>
        <div id="widget-<?php echo $widget_id; ?>" class="widget"  data-item-key-id="<?php
        echo $widget_key_id; ?>">
            <div class="widget-top">

                <div class="widget-title-action">
                    <button type="button" class="widget-action hide-if-no-js widget-form-open" aria-expanded="false">
                        <span class="screen-reader-text"><?php printf( __( 'Edit widget: %s' ), $control['name'] ); ?></span>
                        <span class="toggle-indicator" aria-hidden="true"></span>
                    </button>

                </div>
                <div class="widget-title">
                    <h3><?php echo $control['name']; ?><span class="in-widget-title"></span></h3>
                </div>
            </div>

            <div class="widget-inner widget-inside">
                <form method='post'  class="mmth_widget_save_form">
                    <input type="hidden" name="widget-id" class="widget-id" value="<?php echo esc_attr($widget_id) ?>" />
                    <input type='hidden' name='id_base'   class="id_base" value='<?php echo esc_attr($id_base); ?>' />
                    <input type='hidden' name='widget_id' value='<?php echo esc_attr($widget_id) ?>' />
                    <input type='hidden' name='_wpnonce'  value='<?php echo esc_attr($nonce) ?>' />
                    <div class='widget-content'>
                        <?php
                        if ( is_callable( $control['callback'] ) ) {
                            call_user_func_array( $control['callback'], $control['params'] );
                        }
                        ?>

                        <div class='widget-controls'>
                            <a class='delete' href='#delete'><?php _e('Delete', 'mmth'); ?></a> |
                            <a class='close' href='#close'><?php _e('Close', 'mmth'); ?></a>
                        </div>

                        <?php
                            submit_button( __( 'Save' ), 'button-primary alignright', 'savewidget', false );
                        ?>
                        <div class="clear"></div>
                    </div>
                </form>
            </div>

        </div>
        <?php
    }

Read more here:: Widget form not displaying for media widgets in WordPress

Leave a Reply

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