Skip to content

Commit

Permalink
Made address formatting from the field-type Address available to exte…
Browse files Browse the repository at this point in the history
…rnal plugins
  • Loading branch information
Luc Princen committed Nov 28, 2016
1 parent ccfd6c6 commit ed37a56
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions Classes/Fields/AddressField.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,27 @@ private function getFrontendFields(){
public function getNotificationPart( $entryItems ){

$html = '';
$address = $this->getFormattedAddress( $entryItems );

$label = $this->label;
if( $label == '' && $this->properties['placeholder'] != '' )
$label = $this->properties['placeholder'];

$html .= '<tr><td><strong>'.esc_html( $label ).'</strong></td>';
$html .= '<td>'.$address.'</td></tr>';

return $html;

}

/**
* Return a formatted address from the current entry
*
* @param array $entryItems
* @return string
*/
public function getFormattedAddress( $entryItems )
{
$address = '';
$allowed = array( $this->id.'_street', $this->id.'_zip', $this->id.'_city' );

Expand All @@ -150,15 +171,7 @@ public function getNotificationPart( $entryItems ){
}
}

$label = $this->label;
if( $label == '' && $this->properties['placeholder'] != '' )
$label = $this->properties['placeholder'];

$html .= '<tr><td><strong>'.esc_html( $label ).'</strong></td>';
$html .= '<td>'.$address.'</td></tr>';

return $html;

return $address;
}


Expand Down

0 comments on commit ed37a56

Please sign in to comment.