Esempio n. 1
0
 /**
  * Filter the markup based on the type.
  *
  * @param  string $text    The tooltip text.
  * @param  string $type    The tooltip display type.
  * @param  string $render  The entire field markup.
  *
  * @return string $render  The updated field markup.
  */
 public static function render_tooltip_markup($text = '', $type = '', $render = '', $field, $form_id)
 {
     // Grab our tooltip design and target.
     $design = GF_Tooltips_Helper::get_tooltip_data('design', 'light');
     $target = GF_Tooltips_Helper::get_tooltip_data('target', 'right');
     // Set a class.
     $class = self::get_tooltip_class($design, $target, $type);
     // Build out label version.
     if ($type == 'label') {
         // First add the class.
         $render = GF_Tooltips_Helper::str_replace_limit('gfield_label', 'gfield_label ' . $class, $render);
         // Now add the tooltip.
         $render = GF_Tooltips_Helper::str_replace_limit('<label', '<label data-hint="' . esc_attr($text) . '"', $render);
     }
     // Build out icon version.
     if ($type == 'icon') {
         // Get my icon.
         $icon = self::get_tooltip_icon();
         // Build the markup.
         $setup = '<span class="gf-icon ' . $class . '" data-hint="' . esc_attr($text) . '">' . $icon . '</span>';
         // Render it.
         $render = GF_Tooltips_Helper::str_replace_limit('</label>', $setup . '</label>', $render);
     }
     // Build out single version.
     if ($type == 'single') {
         // Get my icon.
         $icon = self::get_tooltip_icon();
         // Build the markup.
         $setup = '<span class="gf-icon ' . $class . '" data-hint="' . esc_attr($text) . '">' . $icon . '</span>';
         // Render it.
         $render = GF_Tooltips_Helper::str_replace_limit('</div>', '</div>' . $setup, $render);
     }
     // Return field content with new tooltip.
     return apply_filters('gf_tooltips_filter_display', $render, $type, $field, $form_id);
 }