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 |
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); }
/** * Output button type settings field * * @since 1.0.0 * @param array $value */ public function admin_wc_memberships_groups_button($value) { // Custom attribute handling $custom_attributes = array(); if (!empty($value['custom_attributes']) && is_array($value['custom_attributes'])) { foreach ($value['custom_attributes'] as $attribute => $attribute_value) { $custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"'; } } // Description handling $field_description = WC_Admin_Settings::get_field_description($value); ?> <tr valign="top"> <th scope="row" class="titledesc"> <label for="<?php echo esc_attr($value['id']); ?> "><?php echo esc_html($value['title']); ?> </label> <?php echo $field_description['tooltip_html']; ?> </th> <td class="forminp forminp-<?php echo sanitize_title($value['type']); ?> "> <a id="<?php echo esc_attr($value['id']); ?> " type="<?php echo esc_attr($value['type']); ?> " style="<?php echo esc_attr($value['css']); ?> " value="<?php echo esc_attr($value['default']); ?> " class="<?php echo esc_attr($value['class']); ?> " <?php echo implode(' ', $custom_attributes); ?> ><?php echo esc_html($value['default']); ?> </a> <?php echo $field_description['description']; ?> </td> </tr><?php }
/** * Output image select field */ public function output_image_select($value) { // Define the defaults if (!isset($value['title_select'])) { $value['title_select'] = __('Select', 'woocommerce-delivery-notes'); } if (!isset($value['title_remove'])) { $value['title_remove'] = __('Remove', 'woocommerce-delivery-notes'); } // Get additional data fields $field = WC_Admin_Settings::get_field_description($value); $description = $field['description']; $tooltip_html = $field['tooltip_html']; $option_value = WC_Admin_Settings::get_option($value['id'], $value['default']); $class_name = 'wcdn-image-select'; ?> <tr valign="top"> <th scope="row" class="titledesc"> <label for="<?php echo esc_attr($value['id']); ?> "><?php echo esc_html($value['title']); ?> <?php echo $tooltip_html; ?> </label> </th> <td class="forminp image_width_settings"> <input name="<?php echo esc_attr($value['id']); ?> " id="<?php echo esc_attr($value['id']); ?> " type="hidden" value="<?php echo esc_attr($option_value); ?> " class="<?php echo $class_name; ?> -image-id <?php echo esc_attr($value['class']); ?> " /> <div id="<?php echo esc_attr($value['id']); ?> _field" class="<?php echo $class_name; ?> -field <?php echo esc_attr($value['class']); ?> " style="<?php echo esc_attr($value['css']); ?> "> <span id="<?php echo esc_attr($value['id']); ?> _spinner" class="<?php echo $class_name; ?> -spinner spinner"></span> <div id="<?php echo esc_attr($value['id']); ?> _attachment" class="<?php echo $class_name; ?> -attachment <?php echo esc_attr($value['class']); ?> "> <div class="thumbnail"> <div class="centered"> <?php if (!empty($option_value)) { ?> <?php $this->create_image($option_value); ?> <?php } ?> </div> </div> </div> <div id="<?php echo esc_attr($value['id']); ?> _buttons" class="<?php echo $class_name; ?> -buttons <?php echo esc_attr($value['class']); ?> "> <a href="#" id="<?php echo esc_attr($value['id']); ?> _remove_button" class="<?php echo $class_name; ?> -remove-button <?php if (empty($option_value)) { ?> hidden<?php } ?> button"> <?php echo esc_html($value['title_remove']); ?> </a> <a href="#" id="<?php echo esc_attr($value['id']); ?> _add_button" class="<?php echo $class_name; ?> -add-button <?php if (!empty($option_value)) { ?> hidden<?php } ?> button" data-uploader-title="<?php echo esc_attr($value['title']); ?> " data-uploader-button-title="<?php echo esc_attr($value['title_select']); ?> "> <?php echo esc_html($value['title_select']); ?> </a> </div> </div> <?php echo $description; ?> </td> </tr><?php }
public function sysinfo_field($value) { // $option_value = self::get_option( $value['id'], $value['default'] ); $option_value = SS_System_Info::get_system_info(); // Description handling $field_description = WC_Admin_Settings::get_field_description($value); extract($field_description); ?> <tr valign="top"> <th scope="row" class="titledesc"> <label for="<?php echo esc_attr($value['id']); ?> "><?php echo esc_html($value['title']); ?> </label> <?php echo $tooltip_html; ?> </th> <td class="forminp forminp-<?php echo sanitize_title($value['type']); ?> "> <?php echo $description; ?> <textarea name="<?php echo esc_attr($value['id']); ?> " id="<?php echo esc_attr($value['id']); ?> " style="font-family: Menlo,Monaco,monospace;display: block; overflow: auto; white-space: pre; width: 800px; height: 400px;<?php echo esc_attr($value['css']); ?> " class="<?php echo esc_attr($value['class']); ?> " placeholder="<?php echo esc_attr($value['placeholder']); ?> " readonly="readonly" onclick="this.focus(); this.select()" <?php //echo implode( ' ', $custom_attributes ); ?> ><?php echo esc_textarea($option_value); ?> </textarea> </td> </tr> <?php }