Example #1
0
 function ot_recognized_google_font_families($field_id)
 {
     $families = array();
     $ot_google_fonts = get_theme_mod('ot_google_fonts', array());
     // Forces an array rebuild when we sitch themes
     if (empty($ot_google_fonts)) {
         $ot_google_fonts = ot_fetch_google_fonts(true, true);
     }
     foreach ((array) $ot_google_fonts as $key => $item) {
         if (isset($item['family'])) {
             $families[$key] = $item['family'];
         }
     }
     return apply_filters('ot_recognized_google_font_families', $families, $field_id);
 }
 /**
  * Returns a JSON encoded Google fonts array.
  *
  * @return    array
  *
  * @access    public
  * @since     2.5.0
  */
 public function retrieve_google_font()
 {
     if (isset($_POST['field_id'], $_POST['family'])) {
         ot_fetch_google_fonts();
         echo json_encode(array('variants' => ot_recognized_google_font_variants($_POST['field_id'], $_POST['family']), 'subsets' => ot_recognized_google_font_subsets($_POST['field_id'], $_POST['family'])));
         exit;
     }
 }
 /**
  * Callback for add_settings_field() to build each setting by type
  *
  * @param     array     Setting object array
  * @return    string
  *
  * @access    public
  * @since     2.0
  */
 public function display_setting($args = array())
 {
     extract($args);
     /* get current saved data */
     $options = get_option($get_option, false);
     // Set field value
     $field_value = isset($options[$id]) ? $options[$id] : '';
     /* set standard value */
     if (isset($std)) {
         $field_value = ot_filter_std_value($field_value, $std);
     }
     // Allow the descriptions to be filtered before being displayed
     $desc = apply_filters('ot_filter_description', isset($desc) ? $desc : '', $id);
     /* build the arguments array */
     $_args = array('type' => $type, 'field_id' => $id, 'field_name' => $get_option . '[' . $id . ']', 'field_value' => $field_value, 'field_desc' => $desc, 'field_std' => isset($std) ? $std : '', 'field_rows' => isset($rows) && !empty($rows) ? $rows : 15, 'field_post_type' => isset($post_type) && !empty($post_type) ? $post_type : 'post', 'field_taxonomy' => isset($taxonomy) && !empty($taxonomy) ? $taxonomy : 'category', 'field_min_max_step' => isset($min_max_step) && !empty($min_max_step) ? $min_max_step : '0,100,1', 'field_condition' => isset($condition) && !empty($condition) ? $condition : '', 'field_operator' => isset($operator) && !empty($operator) ? $operator : 'and', 'field_class' => isset($class) ? $class : '', 'field_choices' => isset($choices) && !empty($choices) ? $choices : array(), 'field_settings' => isset($settings) && !empty($settings) ? $settings : array(), 'post_id' => ot_get_media_post_ID(), 'get_option' => $get_option);
     // Limit DB queries for Google Fonts.
     if ($type == 'google-fonts') {
         ot_fetch_google_fonts();
         ot_set_google_fonts($id, $field_value);
     }
     /* get the option HTML */
     echo ot_display_by_type($_args);
 }