name = 'google_font_selector'; $this->label = __( 'Google Font Selector', 'acf-google-font-selector-field'); $this->category = __( 'Choice' , 'acf' ); $this->defaults = array( 'include_web_safe_fonts' => true, 'enqueue_font' => true, 'default_font' => 'Droid Sans', ); parent::__construct(); add_action( 'wp_ajax_acfgfs_get_font_details', 'acfgfs_action_get_font_details' ); if( !defined( 'ACFGFS_NOENQUEUE' ) ) { add_action( 'wp_enqueue_scripts', 'acfgfs_google_font_enqueue' ); } } /** * Field Options * * Creates the options for the field, they are shown when the user * creates a field in the back-end. Currently there are three fields. * * The Web Safe Fonts setting allows you to add regular fonts available * in any browser to the list * * The Enqueue Font setting will load the fonts on the appropriate page * when checked. * * The default font settings allows you to specify the font set as the * default for the field. * * @param array $field The details of this field * @author Daniel Pataki * @since 3.0.0 * */ function render_field_settings( $field ) { acf_render_field_setting( $field, array( 'label' => __('Web Safe Fonts?','acf-google-font-selector-field'), 'message' => __('Include web safe fonts?','acf-google-font-selector-field'), 'type' => 'true_false', 'name' => 'include_web_safe_fonts', 'layout' => 'horizontal', )); acf_render_field_setting( $field, array( 'label' => __('Enqueue Font?','acf-google-font-selector-field'), 'message' => __('Automatically load font?','acf-google-font-selector-field'), 'type' => 'true_false', 'name' => 'enqueue_font', 'layout' => 'horizontal', )); acf_render_field_setting( $field, array( 'label' => __('Default Font','acf-google-font-selector-field'), 'type' => 'select', 'name' => 'default_font', 'choices' => acfgfs_get_font_dropdown_array() )); } /** * Field Display * * This function takes care of displaying our field to the users, taking * the field options into account. * * @param array $field The details of this field * @author Daniel Pataki * @since 3.0.0 * */ function render_field( $field ) { $current_font_family = ( empty( $field['value'] ) ) ? $field['default_font'] : $field['value']['font']; ?>