WC_Admin_Settings::get_field_description PHP Method

get_field_description() public static method

Helper function to get the formated description and tip HTML for a given form field. Plugins can call this when implementing their own custom settings types.
public static get_field_description ( array $value ) : array
$value array The form field value array
return array The description and tip as a 2 element array
        public static function get_field_description($value)
        {
            $description = '';
            $tooltip_html = '';
            if (true === $value['desc_tip']) {
                $tooltip_html = $value['desc'];
            } elseif (!empty($value['desc_tip'])) {
                $description = $value['desc'];
                $tooltip_html = $value['desc_tip'];
            } elseif (!empty($value['desc'])) {
                $description = $value['desc'];
            }
            if ($description && in_array($value['type'], array('textarea', 'radio'))) {
                $description = '<p style="margin-top:0">' . wp_kses_post($description) . '</p>';
            } elseif ($description && in_array($value['type'], array('checkbox'))) {
                $description = wp_kses_post($description);
            } elseif ($description) {
                $description = '<span class="description">' . wp_kses_post($description) . '</span>';
            }
            if ($tooltip_html && in_array($value['type'], array('checkbox'))) {
                $tooltip_html = '<p class="description">' . $tooltip_html . '</p>';
            } elseif ($tooltip_html) {
                $tooltip_html = wc_help_tip($tooltip_html);
            }
            return array('description' => $description, 'tooltip_html' => $tooltip_html);
        }

Usage Example

 function wc_autoship_import_muenster_file_settings_field($value)
 {
     $vars = array('value' => $value, 'description' => WC_Admin_Settings::get_field_description($value), 'frequency_options' => get_option($value['id']));
     $relative_path = 'admin/wc-settings/wc-autoship/import-muenster-file';
     wc_autoship_import_muenster_include_plugin_template($relative_path, $vars);
 }
All Usage Examples Of WC_Admin_Settings::get_field_description