/** * Show a single client link field inputs. * * @since 1.21.0 * * @param $key * @param $field_name * @param $type * @param $field * @param bool|false $adding */ function wpmtst_view_field_link($key, $field_name, $type, $field, $adding = false) { if ($field_name) { $current_field = wpmtst_get_field_by_name($field_name); if (is_array($current_field)) { $field = array_merge($current_field, $field); } } $custom_fields = wpmtst_get_custom_fields(); // Add placeholder link_text and label to field in case we need to populate link_text if (!isset($field['link_text'])) { $field['link_text'] = 'field'; } if (!isset($field['link_text_custom'])) { $field['link_text_custom'] = ''; } $field['label'] = wpmtst_get_field_label($field); ?> <!-- the link text --> <div class="field-meta-row link-text"> <label for="view-fieldtext<?php echo $key; ?> ">Text</label> <select id="view-fieldtext<?php echo $key; ?> " name="view[data][client_section][<?php echo $key; ?> ][link_text]" class="if selectgroup"> <option value="value" <?php selected($field['link_text'], 'value'); ?> >this field's value</option> <option value="label" <?php selected($field['link_text'], 'label'); ?> >this field's label</option> <option value="custom" <?php selected($field['link_text'], 'custom'); ?> >custom text</option> </select> </div> <!-- the link text options --> <div class="field-meta-row link-text"> <div class="then_fieldtext<?php echo $key; ?> then_value then_not_label then_not_custom" style="display: none;"> <!-- placeholder --> </div> <div class="then_fieldtext<?php echo $key; ?> then_label then_not_value then_not_custom" style="display: none;"> <input type="text" id="view-fieldtext<?php echo $key; ?> -label" value="<?php echo $field['label']; ?> " readonly> </div> <div class="then_fieldtext<?php echo $key; ?> then_custom then_not_value then_not_label" style="display: none;"> <input type="text" id="view-fieldtext<?php echo $key; ?> -custom" name="view[data][client_section][<?php echo $key; ?> ][link_text_custom]" value="<?php echo $field['link_text_custom']; ?> "> </div> </div> <!-- the URL --> <?php if ('link' == $type) { // URL = another field ?> <div class="field-meta-row"> <label for="view-fieldurl<?php echo $key; ?> ">URL</label> <select id="view-fieldurl<?php echo $key; ?> " name="view[data][client_section][<?php echo $key; ?> ][url]" class="field-type-select"> <?php foreach ($custom_fields as $key2 => $field2) { ?> <?php if ('url' == $field2['input_type']) { ?> <option value="<?php echo $field2['name']; ?> " <?php selected($field2['name'], $field['url']); ?> ><?php echo $field2['name']; ?> </option> <?php } ?> <?php } ?> </select> </div> <?php } else { // URL = this field ?> <input type="hidden" name="view[data][client_section][<?php echo $key; ?> ][url]" value="<?php echo $field['name']; ?> "> <?php } ?> <!-- the URL options --> <div class="field-meta-row checkbox"> <label> <div class="new_tab"> <input type="checkbox" id="<?php echo $key; ?> -newtab" name="view[data][client_section][<?php echo $key; ?> ][new_tab]" value="1" <?php checked($field['new_tab']); ?> > <label for="<?php echo $key; ?> -newtab"> <?php _e('new tab', 'strong-testimonials'); ?> </label> </div> </label> </div> <?php }
/** * @param string $field_name * * @return mixed */ function wpmtst_get_field_by_name($field_name = '') { $custom_fields = wpmtst_get_custom_fields(); foreach ($custom_fields as $key => $custom_field) { if ($custom_field['name'] == $field_name) { return $custom_field; } } return ''; }
/** * Add custom fields to the testimonial editor */ function wpmtst_meta_options() { global $post; $post = wpmtst_get_post($post); $fields = wpmtst_get_custom_fields(); ?> <table class="options"> <tr> <td colspan="2"> <?php _ex('To add a photo or logo, use the Featured Image option.', 'post editor', 'strong-testimonials'); ?> </td> </tr> <?php foreach ($fields as $key => $field) { ?> <tr> <th> <label for="<?php echo $field['name']; ?> "> <?php echo apply_filters('wpmtst_l10n', $field['label'], wpmtst_get_l10n_context('form-fields'), $field['name'] . ' : label'); ?> </label> </th> <td> <?php echo sprintf('<input id="%2$s" type="%1$s" class="custom-input" name="custom[%2$s]" value="%3$s" size="">', $field['input_type'], $field['name'], $post->{$field['name']}); ?> <?php if ('url' == $field['input_type']) { ?> <label><input type="checkbox" name="custom[nofollow]" <?php checked($post->nofollow, 'on'); ?> > <code>rel="nofollow"</code></label> <?php } ?> </td> </tr> <?php } ?> </table> <?php }