Snippets: Hide portfolio media block on password protected posts

// Hide portfolio media block on password protected posts
add_filter( 'wpex_portfolio_single_blocks', function( $blocks, $instance ) {

	// Don't mess with customizer blocks
	if ( 'customizer' == $instance ) {
		return $blocks;
	}

	// Alter front-end blocks
	else {

		// Get list of active blocks
		$blocks = array_combine( $blocks, $blocks );

		// Remove media for password procted posts
		if ( isset( $blocks['media'] ) && post_password_required() ) {
			unset( $blocks['media'] );
		}

	}

	// Return blocks
	return $blocks;

}, 10, 2 );
All PHP snippets should be added via a child theme's functions.php file.