$w ) {
$c = hexdec( substr( $hex, $i * 2, 2 ) ) / 255;
$c = $c <= 0.03928 ? $c / 12.92 : pow( ( $c + 0.055 ) / 1.055, 2.4 );
$lum += $w * $c;
}
// White text needs at least 4.5:1 against the color; otherwise use near-black.
return ( 1.05 / ( $lum + 0.05 ) ) >= 4.5 ? '#ffffff' : '#202124';
}
/**
* Bulletproof button (padding on a table cell, which Outlook honors).
*
* @param string $url URL.
* @param string $label Label.
* @return string
*/
public static function button( $url, $label ) {
return '
' . self::button_cell( $url, $label, 'primary' ) . '
';
}
/**
* Several buttons side by side (they wrap on narrow screens).
*
* @param array $buttons Label => URL.
* @param string $style primary | secondary.
* @return string
*/
public static function buttons( $buttons, $style = 'secondary' ) {
$out = '';
foreach ( $buttons as $label => $url ) {
$out .= '' . self::button_cell( $url, $label, $style ) . '
';
}
return '' !== $out ? '' . $out . '
' : '';
}
/**
* @param string $url URL.
* @param string $label Label.
* @param string $style primary | secondary.
* @return string
*/
private static function button_cell( $url, $label, $style ) {
$accent = self::accent();
if ( 'secondary' === $style ) {
return ''
. '' . esc_html( $label ) . ' | ';
}
return ''
. '' . esc_html( $label ) . ' | ';
}
/**
* @param string $content HTML content.
* @param array|null $lo LO profile.
* @param string $lang Language.
* @return string
*/
public static function wrap( $content, $lo = null, $lang = 'en' ) {
$font = "'Google Sans','Helvetica Neue',Arial,sans-serif";
$link = self::accent();
$signature = '';
if ( $lo ) {
$lines = array_filter(
array(
'' . esc_html( $lo['name'] ) . '' . ( $lo['title'] ? ', ' . esc_html( $lo['title'] ) : '' ),
$lo['nmls'] ? 'NMLS ' . esc_html( $lo['nmls'] ) : '',
$lo['phone'] ? '' . esc_html( $lo['phone'] ) . '' : '',
$lo['email'] ? '' . esc_html( $lo['email'] ) . '' : '',
)
);
$photo = $lo['photo'] ? ' . ') | ' : '';
$signature = '' . $photo . '' . implode( ' ', $lines ) . ' |
|
';
}
$company = Copy::company();
$footer = array_filter(
array(
esc_html( $company['name'] ),
$company['nmls'] ? 'NMLS ' . esc_html( $company['nmls'] ) : '',
'es' === $lang ? 'Igualdad de oportunidades en la vivienda' : 'Equal Housing Opportunity',
)
);
return ''
. ''
. ''
. ''
. '| '
. $content . $signature
. ' | '
. '' . implode( ' ยท ', $footer ) . ' '
. ''
. ' |
';
}
}