There are 10 direct free kick offences or "fouls":
These must be committed by a player, against an opponent, on the field, and during active play. If any are committed by a defender, against an attacker, and within the defender's penalty area, then a penalty kick is awarded instead.
A foul may also be misconduct as well, depending on it's nature, resulting in a caution or a send off.
Only if the kick awarded was a direct free kick.
A direct free kick awarded from 12 yards in front of the goal would be within the penalty area. It would have to be a kick awarded to the defense, because if a defender had committed a direct free kick offense at that location the restart would, instead, have been a penalty kick for the attackers.
Yes. An indirect free kick, for either team, may be awarded within the penalty area. Only the defense may be awarded a direct free kick in the penalty area.
When a foul, specifically a direct free kick offense, is committed by a defender, against an attacker, in the penalty area.
A direct free kick is awarded when someone commits a penal foul: handling the ball, tripping or attempting to trip, striking or attempting to strike, kicking or attempting to kick, jumping at, charging, or pushing an opponent. The ball is placed at the spot of the foul, and a player on the offended team takes the kick. The ball is in play when it is kicked and moves. If a direct free kick is awarded within the kicking team's own goal area, the ball may be placed anywhere in the goal area for the kick (similar to positioning for a goal kick). If a direct free kick is awarded within the kicking team's own penalty area (including the goal area), the ball is not in play until it is kicked directly out of the area. If the direct free kick is awarded in the offending team's penalty area, a penalty kick is awarded instead.
For deliberate handling, a direct free kick is awarded to the opposing team.
A direct free kick (or DFK) is awarded when the opposing team has committed a penal foul as defined in Law 12 outside of their own defensive penalty area.
"Foul" is a term used to describe an offence punishable by a direct free kick. If a defender fouls an attacker in the defender's penalty area then a penalty kick is the prescribed restart. There's a loophole in your question. What if the attacker fouls the defender in the defender's penalty area? A direct free kick is awarded to the defense.
clearance
There are penalty kicks in soccer. A penalty kick is awarded when a defender commits a direct free kick offense while within his own penalty area.
Only when a foul is committed such as handball or a bad tackle - offsides or back passes are indirect free kicks!
A goal keeper cannot deliberately handle the ball outside of his own penalty area. If they do, then a direct free kick is awarded to the opponents.