What do add_action and do_action do in WordPress?
add_action('foo','bar');
do_action('foo');
function bar(){
echo "this is the bar function";
}
This would cause “this is the bar function” to be echoed to the browser. This is WordPress implementation of the Observer design pattern. In other words, the call to add_action as stated above tells the WP engine to listen for the action “foo” to be called, when it is, any function added through add_action will be called “Or notified as is the case with the Observer design pattern)
