Forums

Help me understand (1 post)

  1. John
    Member
    Posted 1 year ago #

    I'm relatively new to WP and I'm reading through some code in the function.php file of a template. Can someone help me to understand the add_filter function and the rest of what is going on in this code.

    // FILTER WIDGET
    function my_widget_filter($content) {
    	foreach ($content as $key => $value){
    		if (isset($value['rbrw_content'])){
    			$new_cont = str_replace('
    ', ' ', $value['rbrw_content']);
    		$new_cont = str_replace('\\\'', '\'', $new_cont);
    		$content[$key]['rbrw_content'] = $new_cont;
    		}
    	}
    	return $content;
    }
    
    add_filter( 'pre_update_option_widget_rbrichwidget', my_widget_filter );
    add_filter( 'pre_update_option_widget_text', my_widget_filter );

    I could have easily left some important code out making impossible for you to decipher, so just let me know. Oh, and I apologize if I'm posting in the wrong place. Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic