/** * An individual view settings page. * * @since 1.21.0 * * @param string $action * @param null $view_id */ function wpmtst_view_settings($action = '', $view_id = null) { if (('edit' == $action || 'duplicate' == $action) && !$view_id) { return; } global $view, $strong_templates; add_thickbox(); $screen = get_current_screen(); $url = $screen->parent_file; $fields = wpmtst_get_custom_fields(); $all_fields = wpmtst_get_all_fields(); $order_list = wpmtst_get_order_list(); $posts_list = get_posts(array('orderby' => 'post_date', 'order' => 'ASC', 'post_type' => 'wpm-testimonial', 'post_status' => 'publish', 'posts_per_page' => -1, 'suppress_filters' => true)); $category_list = wpmtst_get_category_list(); /** * Show category filter if necessary. * * @since 2.2.0 */ if (count($category_list) > 5) { wp_enqueue_script('wpmtst-view-category-filter-script'); } $pages_list = get_pages(array('sort_order' => 'ASC', 'sort_column' => 'menu_order', 'post_type' => 'page', 'post_status' => 'publish')); $view_options = get_option('wpmtst_view_options'); $default_view = get_option('wpmtst_view_default'); if ('edit' == $action) { $view_array = wpmtst_get_view($view_id); $view = unserialize($view_array['value']); $view_name = $view_array['name']; } elseif ('duplicate' == $action) { $view_array = wpmtst_get_view($view_id); $view = unserialize($view_array['value']); $view_id = 0; $view_name = $view_array['name'] . ' - COPY'; } else { $view_id = 1; $view = $default_view; $view_name = 'new'; } // Deselect title & thumbnail if not in field group $has_title_field = false; $has_thumbnail_field = false; foreach ($all_fields as $key => $field) { if ('post_title' == $field['name']) { $has_title_field = true; } if ('featured_image' == $field['name']) { $has_thumbnail_field = true; } } if (!$has_title_field) { $view['title'] = false; } if (!$has_thumbnail_field) { $view['thumbnail'] = false; } // Select default template if necessary if (!$view['template']) { if ('form' == $view['mode']) { $view['template'] = 'default:form'; } else { $view['template'] = 'default:content'; } } $view['nav'] = explode(',', str_replace(' ', '', $view['nav'])); //$view_cats_array = explode( ',', $view['category'] ); $view_cats_array = apply_filters('wpmtst_l10n_cats', explode(',', $view['category'])); // Assemble list of templates $templates = $strong_templates->get_templates(array('content', 'widget')); $form_templates = $strong_templates->get_templates('form'); $group = strtok($view['template'], ':'); $type = strtok(':'); if ('form' == $type) { $template_found = in_array($view['template'], array_keys($form_templates)); } else { $template_found = in_array($view['template'], array_keys($templates)); } // Get list of image sizes $image_sizes = wpmtst_get_image_sizes(); ?> <h2> <?php 'edit' == $action ? _e('Edit View', 'strong-testimonials') : _e('Add View', 'strong-testimonials'); ?> <a href="<?php echo $url; ?> &page=testimonial-views&action=add" class="add-new-h2">Add New</a> </h2> <p><a href="<?php echo admin_url('edit.php?post_type=wpm-testimonial&page=testimonial-views'); ?> ">Return to list</a></p> <form id="wpmtst-views-form" method="post" action="<?php echo get_admin_url() . 'admin-post.php'; ?> " autocomplete="off"> <?php wp_nonce_field('view_form_submit', 'view_form_nonce', true, true); ?> <input type="hidden" name="action" value="view_<?php echo $action; ?> _form"> <input type="hidden" name="view[id]" value="<?php echo $view_id; ?> "> <input type="hidden" name="view_original_mode" value="<?php echo $view['mode']; ?> "> <input type="hidden" name="view[data][_form_id]" value="<?php echo $view['form_id']; ?> "> <div class="view-info"> <div class="form-view-name"><span class="title">Name:</span><input type="text" id="view-name" class="view-name" name="view[name]" value="<?php echo $view_name; ?> " tabindex="1"></div> </div> <div class="view-info"> <div class="form-view-shortcode"> <span class="title">Shortcode:</span> <?php if ('edit' == $action) { ?> <span class="saved">[testimonial_view id=<?php echo $view_id; ?> ]</span> <?php } else { ?> <span class="unsaved"><?php _ex('will be available after you save this', 'The shortcode for a new View.', 'strong-testimonials'); ?> </span> <?php } ?> </div> </div> <?php include 'views/mode.php'; // TODO Generify both hook and include do_action('wpmtst_view_editor_before_group_select'); include 'views/group-select.php'; do_action('wpmtst_view_editor_before_group_fields'); include 'views/group-fields.php'; do_action('wpmtst_view_editor_before_group_form'); include 'views/group-form.php'; do_action('wpmtst_view_editor_before_group_extra'); include 'views/group-extra.php'; do_action('wpmtst_view_editor_before_group_style'); include 'views/group-style.php'; do_action('wpmtst_view_editor_before_group_general'); include 'views/group-general.php'; do_action('wpmtst_view_editor_after_groups'); ?> <p class="wpmtst-submit"> <?php submit_button('', 'primary', 'submit', false); ?> <?php submit_button(__('Undo Changes', 'strong-testimonials'), 'secondary', 'reset', false); ?> <?php submit_button(__('Restore Defaults', 'strong-testimonials'), 'secondary', 'restore-defaults', false); ?> </p> </form> <?php }
/** * Filter the gravatar size. * * @param array $size * @since 1.23.0 * @return mixed */ function wpmtst_gravatar_size_filter($size = array(150, 150)) { // avatars are square so get the width of the requested size if (is_array($size)) { // if dimension array $gravatar_size = $size[0]; } else { // if named size $image_sizes = wpmtst_get_image_sizes(); $gravatar_size = $image_sizes[$size]['width']; } return $gravatar_size; }