/** * Add custom columns to the admin list. * * @param $columns * @since 1.4.0 * @since 2.5.1 Added comments column. * @return array */ function wpmtst_edit_columns($columns) { $fields = wpmtst_get_all_fields(); $comments = isset($columns['comments']) ? $columns['comments'] : ''; /* INCOMING COLUMNS = Array ( [cb] => <input type="checkbox" /> [title] => Title [comments] => <span class="vers comment-grey-bubble" title="Comments"><span class="screen-reader-text">Comments</span></span> [date] => Date [search_exclude] => Search Exclude // other plugin [thumbnail] => Thumbnail ) */ // 1. remove [thumbnail] (may be re-added in custom field loop) and [date] unset($columns['thumbnail'], $columns['date']); if ($comments) { unset($columns['comments']); } // 2. insert [order] after [cb] if (!wpmtst_is_column_sorted() && !wpmtst_is_viewing_trash() && class_exists('Strong_Testimonials_Order')) { $columns = array_merge(array_slice($columns, 0, 1), array('handle' => 'Order'), array_slice($columns, 1, null)); } // 3. insert [excerpt] after [title] $key = 'title'; $offset = array_search($key, array_keys($columns)) + 1; $fields_to_add = array('post_excerpt' => __('Excerpt', 'strong-testimonials')); // 4. add custom fields foreach ($fields as $key => $field) { if ($field['admin_table']) { if ('post_title' == $field['name']) { continue; } elseif ('featured_image' == $field['name']) { $fields_to_add['thumbnail'] = __('Thumbnail', 'strong-testimonials'); } else { $fields_to_add[$field['name']] = apply_filters('wpmtst_l10n', $field['label'], wpmtst_get_l10n_context('form-fields'), $field['name'] . ' : label'); } } } // 5. add [category], [comments] and [date] // 'categories' is reserved by WordPress. if (wpmtst_get_category_list()) { $fields_to_add['category'] = __('Categories', 'strong-testimonials'); } if ($comments) { $fields_to_add['comments'] = $comments; } $fields_to_add['date'] = __('Date', 'strong-testimonials'); // Push other added columns like [search_exclude] to the end. $columns = array_merge(array_slice($columns, 0, $offset), $fields_to_add, array_slice($columns, $offset, null)); return $columns; }
echo $key; ?> ][description]" value="<?php esc_attr_e($messages[$key]['description']); ?> "> </td> <td> <input type="text" id="<?php echo $key; ?> " name="wpmtst_form_options[messages][<?php echo $key; ?> ][text]" value="<?php echo esc_attr(apply_filters('wpmtst_l10n', $messages[$key]['text'], wpmtst_get_l10n_context('form-messages'), $key . ' : text')); ?> " required /> </td> <td class="actions"> <input type="button" class="button secondary restore-default-message" value="<?php _ex('restore default', 'singular', 'strong-testimonials'); ?> "> </td> </tr> <?php } ?> <tr> <td colspan="3">