Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

Abhik on "Best Practice for Conditions"

$
0
0

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 all articles
Browse latest Browse all 8245

Trending Articles