• What is the best practice to implement conditions? Within callback or wrapping the hook?

    Like,

    function myfunction() {
    	if ( get_option() ) {
    		// Do Something
    	}
    }
    add_action( 'hook', 'myfunction' );

    Or,

    function myfunction() {
    	// Do Something
    }
    if ( get_option() ) {
    	add_action( 'hook', 'myfunction' );
    }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Best Practice for Conditions’ is closed to new replies.