• Hello,

    I wonder how I can override the function widget in the file default-widget.php on lines 377-386 from the functions.php file in the themes folder?

    377-386

    function widget( $args, $instance ) {
    		extract($args);
    		$title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
    		$text = apply_filters( 'widget_text', $instance['text'], $instance );
    		echo $before_widget;
    		if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?>
    			<div class="textwidget"><?php echo $instance['filter'] ? wpautop($text) : $text; ?></div>
    		<?php
    		echo $after_widget;
    	}

    I have found that you should be able to override with the code (this is a snippet i found, its need to be modified, but Im not sure how):

    function twentyten_remove_recent_comments_style() {
    	global $wp_widget_factory;
    	remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Text'], 'recent_comments_style' ) );
    }
    add_action( 'widgets_init', 'twentyten_remove_recent_comments_style' );
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Fredriks

    (@fredriks)

    Still looking for a solution of this problem. Somebody who has a clue?

    Any clue on what you’re trying to achieve for this one?

    Thread Starter Fredriks

    (@fredriks)

    Thanks for answer!

    The thing is that I try to change the structure of this line (the first code snippet in the first post)

    <div class="textwidget"><?php echo $instance['filter'] ? wpautop($text) : $text; ?></div>

    Because this line determines how the textelemnt in the sidebar (if you chose to have one) is built up.

    And I want to change the structure so it should be like this:
    <div class="textwidget"><div id="text_widget_top"></div><?php echo $instance['filter'] ? wpautop($text) : $text; ?><div id="text_widget_footer"></div></div>

    And I want to change it from the function.php because then I will just be able to upload the hole theme to the “themes” -directory with out have to mess with default-widget.php -file.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘How to override function widget in default-widgets.php’ is closed to new replies.