$ascend[ $options_key ]['font-family'],
'font-style' => array(),
'subsets' => array(),
);
if ( isset( $ascend[ $options_key ]['font-weight'] ) && ! empty( $ascend[ $options_key ]['font-weight'] ) ) {
if ( isset( $ascend[ $options_key ]['font-style'] ) && ! empty( $ascend[ $options_key ]['font-style'] ) && ! is_numeric( $ascend[ $options_key ]['font-style'] ) && 'normal' !== $ascend[ $options_key ]['font-style'] ) {
$load_gfonts[ sanitize_key( $ascend[ $options_key ]['font-family'] ) ]['font-style'][ $ascend[ $options_key ]['font-weight'] . $ascend[ $options_key ]['font-style'] ] = $ascend[ $options_key ]['font-weight'] . $ascend[ $options_key ]['font-style'];
} else {
$load_gfonts[ sanitize_key( $ascend[ $options_key ]['font-family'] ) ]['font-style'][ $ascend[ $options_key ]['font-weight'] ] = $ascend[ $options_key ]['font-weight'];
}
}
if ( isset( $ascend[ $options_key ]['subsets'] ) && ! empty( $ascend[ $options_key ]['subsets'] ) ) {
$load_gfonts[ sanitize_key( $ascend[ $options_key ]['font-family'] ) ]['subsets'][ $ascend[ $options_key ]['subsets'] ] = $ascend[ $options_key ]['subsets'];
}
}
if ( 'font_p' === $options_key ) {
$load_gfonts[ sanitize_key( $ascend[ $options_key ]['font-family'] ) ]['font-style']['400italic'] = '400italic';
$load_gfonts[ sanitize_key( $ascend[ $options_key ]['font-family'] ) ]['font-style']['400'] = '400';
$load_gfonts[ sanitize_key( $ascend[ $options_key ]['font-family'] ) ]['font-style']['700italic'] = '700italic';
$load_gfonts[ sanitize_key( $ascend[ $options_key ]['font-family'] ) ]['font-style']['700'] = '700';
}
}
}
if ( ! empty( $load_gfonts ) ) {
// Build the font family link.
$link = '';
$subsets = array();
foreach ( $load_gfonts as $gfont_values ) {
if ( ! empty( $link ) ) {
$link .= '%7C'; // Append a new font to the string.
}
$link .= $gfont_values['font-family'];
if ( ! empty( $gfont_values['font-style'] ) ) {
$link .= ':';
$link .= implode( ',', $gfont_values['font-style'] );
}
if ( ! empty( $gfont_values['subsets'] ) ) {
foreach ( $gfont_values['subsets'] as $subset ) {
if ( ! in_array( $subset, $subsets ) ) {
array_push( $subsets, $subset );
}
}
}
}
if ( ! empty( $subsets ) ) {
$link .= '&subset=' . implode( ',', $subsets );
}
echo '';
}
echo '';
}
add_action( 'admin_head-post.php', 'ascend_editor_dynamic_css' );
add_action( 'admin_head-post-new.php', 'ascend_editor_dynamic_css' );
add_action( 'admin_head-edit.php', 'ascend_editor_dynamic_css' );