"Arial, Helvetica, sans-serif",
"'Arial Black', Gadget, sans-serif" => "'Arial Black', Gadget, sans-serif",
"'Bookman Old Style', serif" => "'Bookman Old Style', serif",
"'Comic Sans MS', cursive" => "'Comic Sans MS', cursive",
"Courier, monospace" => "Courier, monospace",
"Garamond, serif" => "Garamond, serif",
"Georgia, serif" => "Georgia, serif",
"Impact, Charcoal, sans-serif" => "Impact, Charcoal, sans-serif",
"'Lucida Console', Monaco, monospace" => "'Lucida Console', Monaco, monospace",
"'Lucida Sans Unicode', 'Lucida Grande', sans-serif" => "'Lucida Sans Unicode', 'Lucida Grande', sans-serif",
"'MS Sans Serif', Geneva, sans-serif" => "'MS Sans Serif', Geneva, sans-serif",
"'MS Serif', 'New York', sans-serif" => "'MS Serif', 'New York', sans-serif",
"'Palatino Linotype', 'Book Antiqua', Palatino, serif" => "'Palatino Linotype', 'Book Antiqua', Palatino, serif",
"Tahoma,Geneva, sans-serif" => "Tahoma, Geneva, sans-serif",
"'Times New Roman', Times,serif" => "'Times New Roman', Times, serif",
"'Trebuchet MS', Helvetica, sans-serif" => "'Trebuchet MS', Helvetica, sans-serif",
"Verdana, Geneva, sans-serif" => "Verdana, Geneva, sans-serif",
);
/**
* Field Constructor.
*
* Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
*
* @since ReduxFramework 1.0.0
*/
function __construct( $field = array(), $value ='', $parent ) {
//parent::__construct( $parent->sections, $parent->args );
$this->parent = $parent;
$this->field = $field;
$this->value = $value;
}
/**
* Field Render Function.
*
* Takes the vars and outputs the HTML for the field in the settings
*
* @since ReduxFramework 1.0.0
*/
function render(){
global $wp_filesystem;
// Initialize the Wordpress filesystem, no more using file_put_contents function
if (empty($wp_filesystem)) {
require_once(ABSPATH .'/wp-admin/includes/file.php');
WP_Filesystem();
}
// No errors please
$defaults = array(
'font-family' => true,
'font-size' => true,
'subsets' => true,
'font-weight' => true,
'font-style' => true,
'font-backup' => false,
'color' => true,
'preview' => true,
'line-height' => true,
'word-spacing' => false,
'letter-spacing' => false,
'google' => true,
'update_weekly' => false // Enable to force updates of Google Fonts to be weekly
);
$this->field = wp_parse_args( $this->field, $defaults );
$defaults = array(
'font-family'=>'',
'font-options'=>'',
'font-backup'=>'',
'line-height'=>'',
'word-spacing' => '',
'letter-spacing' => '',
'subsets'=>'',
'google'=>false,
'font-script'=>'',
'font-weight'=>'',
'font-style'=>'',
'color'=>'',
'font-size'=>'',
);
$this->value = wp_parse_args( $this->value, $defaults );
// Since fonts declared is CSS (@font-face) are not rendered in the preview,
// they can be declared in a CSS file and passed here so they DO display in
// font preview. Do NOT pass style.css in your theme, as that will mess up
// admin page styling. It's recommended to pass a CSS file with ONLY font
// declarations.
// If field is set and not blank, then enqueue field
if (isset($this->field['ext-font-css']) && $this->field['ext-font-css'] != ''){
wp_register_style('redux-external-fonts', $this->field['ext-font-css']);
wp_enqueue_style('redux-external-fonts');
}
if (empty($this->field['units']) && !empty($this->field['default']['units'])) {
$this->field['units'] = $this->field['default']['units'];
}
if ( empty( $this->field['units'] ) || !in_array( $this->field['units'], array( 'px', 'em', 'rem', '%' ) ) ) {
$this->field['units'] = 'px';
}
$unit = $this->field['units'];
if ($this->field['font-family'] === true):
echo '
';
/**
Font Family
**/
if ( filter_var($this->value['google'], FILTER_VALIDATE_BOOLEAN) ) {
$fontFamily = explode(', ', $this->value['font-family'],2);
if (empty($fontFamily[0]) && !empty($fontFamily[1])) {
$fontFamily[0] = $fontFamily[1];
$fontFamily[1] = "";
}
}
if (!isset($fontFamily)) {
$fontFamily = array();
$fontFamily[0] = $this->value['font-family'];
$fontFamily[1] = "";
}
echo '';
echo '';
echo '
';
echo '
';
if ($this->field['google'] === true) {
// Set a flag so we know to set a header style or not
echo '';
}
endif;
/**
Font Style/Weight
**/
if ($this->field['font-style'] === true || $this->field['font-weight'] === true):
echo '
';
endif;
/**
Font Script
**/
if ($this->field['subsets'] === true && $this->field['google'] === true):
echo '
';
echo '
';
endif;
/**
Font Size
**/
if ($this->field['font-size'] === true):
echo '
'.$unit.'
';
echo '';
endif;
/**
Line Height
**/
if ($this->field['line-height'] === true):
echo '
'.$unit.'
';
echo '';
endif;
/**
Word Spacing
**/
if ($this->field['word-spacing'] === true):
echo '
'.$unit.'
';
echo '';
endif;
/**
Letter Spacing
**/
if ($this->field['letter-spacing'] === true):
echo '
'.$unit.'
';
echo '';
endif;
/**
Backup Font
**/
if ($this->field['font-family'] === true && $this->field['google'] === true) {
// Set a flag so we know to set a header style or not
echo '';
if ($this->field['font-backup'] === true) {
echo '
';
echo '
';
}
}
/**
Font Color
**/
if ($this->field['color'] === true):
$default = "";
if (empty($this->field['default']['color']) && !empty($this->field['color'])) {
$default = $this->value['color'];
} else if (!empty($this->field['default']['color'])) {
$default = $this->field['default']['color'];
}
echo '