function form($instance) { $rotators = get_posts(array('post_type' => 'testimonial_rotator', 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC')); $title = isset($instance['title']) ? $instance['title'] : ""; $rotator_id = isset($instance['rotator_id']) ? $instance['rotator_id'] : 0; $format = isset($instance['format']) ? $instance['format'] : "rotator"; $excerpt_length = isset($instance['excerpt_length']) ? $instance['excerpt_length'] : ""; $limit = (int) isset($instance['limit']) ? $instance['limit'] : 5; $show_size = (isset($instance['show_size']) and $instance['show_size'] == "full") ? "full" : "excerpt"; $override_rotator_settings = (isset($instance['override_rotator_settings']) and $instance['override_rotator_settings'] == 1) ? 1 : 0; // OVERRIDES $template = isset($instance['template']) ? $instance['template'] : "default"; $fx = isset($instance['fx']) ? $instance['fx'] : false; $img_size = isset($instance['img_size']) ? $instance['img_size'] : false; $timeout = isset($instance['timeout']) ? $instance['timeout'] : ""; $speed = isset($instance['speed']) ? $instance['speed'] : ""; $title_heading = isset($instance['title_heading']) ? $instance['title_heading'] : ""; $shuffle = isset($instance['shuffle']) ? $instance['shuffle'] : false; $verticalalign = isset($instance['verticalalign']) ? $instance['verticalalign'] : ""; $prevnext = isset($instance['prevnext']) ? $instance['prevnext'] : ""; $hidefeaturedimage = isset($instance['hidefeaturedimage']) ? $instance['hidefeaturedimage'] : ""; $hide_microdata = isset($instance['hide_microdata']) ? $instance['hide_microdata'] : ""; $itemreviewed = isset($instance['itemreviewed']) ? $instance['itemreviewed'] : ""; // SELECT BOX DATA $available_effects = testimonial_rotator_base_transitions(); $image_sizes = get_intermediate_image_sizes(); $available_themes = testimonial_rotator_available_themes(); ?> <p><label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:', 'testimonial-rotator'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo esc_attr($title); ?> " /></label></p> <p> <label for="<?php echo $this->get_field_id('rotator_id'); ?> "><?php _e('Rotator', 'testimonial-rotator'); ?> : <select name="<?php echo $this->get_field_name('rotator_id'); ?> " class="widefat" id="<?php echo $this->get_field_id('rotator_id'); ?> "> <option value=""><?php _e('All Rotators', 'testimonial-rotator'); ?> </option> <?php foreach ($rotators as $rotator) { ?> <option value="<?php echo $rotator->ID; ?> " <?php if ($rotator->ID == $rotator_id) { echo " SELECTED"; } ?> ><?php echo $rotator->post_title; ?> </option> <?php } ?> </select> </label> </p> <p><label for="<?php echo $this->get_field_id('limit'); ?> "><?php _e('Limit:', 'testimonial-rotator'); ?> <input class="widefat" id="<?php echo $this->get_field_id('limit'); ?> " name="<?php echo $this->get_field_name('limit'); ?> " type="text" value="<?php echo esc_attr($limit); ?> " /></label></p> <p> <label for="<?php echo $this->get_field_id('format'); ?> "><?php _e('Display:', 'testimonial-rotator'); ?> </label> <input id="<?php echo $this->get_field_id('format'); ?> " name="<?php echo $this->get_field_name('format'); ?> " value="rotator" type="radio"<?php if ($format != "list") { echo " checked='checked'"; } ?> > <?php _e('Rotator', 'testimonial-rotator'); ?> <input id="<?php echo $this->get_field_id('format'); ?> " name="<?php echo $this->get_field_name('format'); ?> " value="list" type="radio"<?php if ($format == "list") { echo " checked='checked'"; } ?> > <?php _e('List', 'testimonial-rotator'); ?> </p> <p class="testimonial_rotator_size"> <label for="<?php echo $this->get_field_id('show_size'); ?> "><?php _e('Show as:', 'testimonial-rotator'); ?> </label> <input id="<?php echo $this->get_field_id('show_size'); ?> " name="<?php echo $this->get_field_name('show_size'); ?> " value="full" type="radio"<?php if ($show_size == "full") { echo " checked='checked'"; } ?> > <?php _e('Full', 'testimonial-rotator'); ?> <input id="<?php echo $this->get_field_id('show_size'); ?> " name="<?php echo $this->get_field_name('show_size'); ?> " value="excerpt" type="radio"<?php if ($show_size == "excerpt") { echo " checked='checked'"; } ?> > <?php _e('Excerpt', 'testimonial-rotator'); ?> </p> <p class="testimonial_excerpt_length" <?php if ($show_size == "full") { echo " style='display:none'"; } ?> > <label for="<?php echo $this->get_field_id('excerpt_length'); ?> "><?php _e('Custom Excerpt Length:', 'testimonial-rotator'); ?> <br> <input class="" id="<?php echo $this->get_field_id('excerpt_length'); ?> " name="<?php echo $this->get_field_name('excerpt_length'); ?> " type="text" value="<?php echo esc_attr($excerpt_length); ?> " /></label> </p> <script> jQuery(".testimonial_rotator_size input").change(function() { jQuery("p.testimonial_excerpt_length").toggle(); }); </script> <hr> <div class="override_rotator_settings_block"> <p> <input id="<?php echo $this->get_field_id('override_rotator_settings'); ?> " name="<?php echo $this->get_field_name('override_rotator_settings'); ?> " type="checkbox" value="1" <?php if ($override_rotator_settings) { echo ' checked="checked"'; } ?> /> <label for="<?php echo $this->get_field_id('override_rotator_settings'); ?> "><?php _e('Override Rotator Settings?', 'testimonial-rotator'); ?> </label> </p> <script> jQuery('#<?php echo $this->get_field_id('override_rotator_settings'); ?> ').change(function() { jQuery(this).parents('.override_rotator_settings_block').children('.override_rotator_settings_fields').toggleClass('hidden'); }); </script> <div class="override_rotator_settings_fields<?php if (!$override_rotator_settings) { echo " hidden"; } ?> "> <?php if (count($available_themes) > 1) { ?> <p> <select id="<?php echo $this->get_field_id('template'); ?> " name="<?php echo $this->get_field_name('template'); ?> "> <?php foreach ($available_themes as $theme_slug => $available_theme) { ?> <option value="<?php echo $theme_slug; ?> " <?php if ($theme_slug == $template) { echo " SELECTED"; } ?> ><?php echo $available_theme['title']; ?> </option> <?php } ?> </select> <label for="<?php echo $this->get_field_id('template'); ?> "><?php _e('Template', 'testimonial-rotator'); ?> </label> </p> <?php } ?> <p> <select id="<?php echo $this->get_field_id('fx'); ?> " name="<?php echo $this->get_field_name('fx'); ?> "> <option value=""><?php _e('Rotator Default', 'testimonial-rotator'); ?> </option> <?php foreach ($available_effects as $available_effect) { ?> <option value="<?php echo $available_effect; ?> " <?php if ($available_effect == $fx) { echo " SELECTED"; } ?> ><?php echo $available_effect; ?> </option> <?php } ?> </select> <label for="<?php echo $this->get_field_id('fx'); ?> "><?php _e('Transition Effect', 'testimonial-rotator'); ?> </label> </p> <p> <select id="<?php echo $this->get_field_id('img_size'); ?> " name="<?php echo $this->get_field_name('img_size'); ?> "> <option value=""><?php _e('Rotator Default', 'testimonial-rotator'); ?> </option> <?php foreach ($image_sizes as $image_size) { ?> <option value="<?php echo $image_size; ?> " <?php if ($image_size == $img_size) { echo " SELECTED"; } ?> ><?php echo $image_size; ?> </option> <?php } ?> </select> <label for="<?php echo $this->get_field_id('img_size'); ?> "><?php _e('Image Size', 'testimonial-rotator'); ?> </label> </p> <p> <input id="<?php echo $this->get_field_id('timeout'); ?> " name="<?php echo $this->get_field_name('timeout'); ?> " value="<?php echo esc_attr($timeout); ?> " type="text" style="width: 45px; text-align: center;"> <label for="<?php echo $this->get_field_id('timeout'); ?> "><?php _e('Seconds per Testimonial', 'testimonial-rotator'); ?> </label> </p> <p> <input id="<?php echo $this->get_field_id('speed'); ?> " name="<?php echo $this->get_field_name('speed'); ?> " value="<?php echo esc_attr($speed); ?> " type="text" style="width: 45px; text-align: center;"> <label for="<?php echo $this->get_field_id('speed'); ?> "><?php _e('Transition Speed (in seconds)', 'testimonial-rotator'); ?> </label> </p> <p> <input id="<?php echo $this->get_field_id('title_heading'); ?> " name="<?php echo $this->get_field_name('title_heading'); ?> " value="<?php echo esc_attr($title_heading); ?> " type="text" style="width: 45px; text-align: center;"> <label for="<?php echo $this->get_field_id('title_heading'); ?> "><?php _e('Element for Title Field', 'testimonial-rotator'); ?> </label> </p> <p> <select id="<?php echo $this->get_field_id('shuffle'); ?> " name="<?php echo $this->get_field_name('shuffle'); ?> "> <option value=""><?php _e('Default', 'testimonial-rotator'); ?> </option> <option value="1"<?php if ($shuffle == "1") { echo " selected='selected'"; } ?> ><?php _e('Yes', 'testimonial-rotator'); ?> </option> <option value="0"<?php if ($shuffle == "0") { echo " selected='selected'"; } ?> ><?php _e('No', 'testimonial-rotator'); ?> </option> </select> <label for="<?php echo $this->get_field_id('shuffle'); ?> "><?php _e('Randomize Testimonials', 'testimonial-rotator'); ?> </label> </p> <p> <select id="<?php echo $this->get_field_id('verticalalign'); ?> " name="<?php echo $this->get_field_name('verticalalign'); ?> "> <option value=""><?php _e('Default', 'testimonial-rotator'); ?> </option> <option value="1"<?php if ($verticalalign == "1") { echo " selected='selected'"; } ?> ><?php _e('Yes', 'testimonial-rotator'); ?> </option> <option value="0"<?php if ($verticalalign == "0") { echo " selected='selected'"; } ?> ><?php _e('No', 'testimonial-rotator'); ?> </option> </select> <label for="<?php echo $this->get_field_id('verticalalign'); ?> "><?php _e('Vertical Align (Center Testimonials Height)', 'testimonial-rotator'); ?> </label> </p> <p> <select id="<?php echo $this->get_field_id('prevnext'); ?> " name="<?php echo $this->get_field_name('prevnext'); ?> "> <option value=""><?php _e('Default', 'testimonial-rotator'); ?> </option> <option value="1"<?php if ($prevnext == "1") { echo " selected='selected'"; } ?> ><?php _e('Yes', 'testimonial-rotator'); ?> </option> <option value="0"<?php if ($prevnext == "0") { echo " selected='selected'"; } ?> ><?php _e('No', 'testimonial-rotator'); ?> </option> </select> <label for="<?php echo $this->get_field_id('prevnext'); ?> "><?php _e('Show Previous/Next Buttons', 'testimonial-rotator'); ?> </label> </p> <p> <select id="<?php echo $this->get_field_id('hidefeaturedimage'); ?> " name="<?php echo $this->get_field_name('hidefeaturedimage'); ?> "> <option value=""><?php _e('Default', 'testimonial-rotator'); ?> </option> <option value="1"<?php if ($hidefeaturedimage == "1") { echo " selected='selected'"; } ?> ><?php _e('Yes', 'testimonial-rotator'); ?> </option> <option value="0"<?php if ($hidefeaturedimage == "0") { echo " selected='selected'"; } ?> ><?php _e('No', 'testimonial-rotator'); ?> </option> </select> <label for="<?php echo $this->get_field_id('hidefeaturedimage'); ?> "><?php _e('Hide Featured Image', 'testimonial-rotator'); ?> </label> </p> <p> <select id="<?php echo $this->get_field_id('hide_microdata'); ?> " name="<?php echo $this->get_field_name('hide_microdata'); ?> "> <option value=""><?php _e('Default', 'testimonial-rotator'); ?> </option> <option value="1"<?php if ($hide_microdata == "1") { echo " selected='selected'"; } ?> ><?php _e('Yes', 'testimonial-rotator'); ?> </option> <option value="0"<?php if ($hide_microdata == "0") { echo " selected='selected'"; } ?> ><?php _e('No', 'testimonial-rotator'); ?> </option> </select> <label for="<?php echo $this->get_field_id('hide_microdata'); ?> "><?php _e('Hide Microdata (hReview)', 'testimonial-rotator'); ?> </label> </p> <p> <label for="<?php echo $this->get_field_id('itemreviewed'); ?> "><?php _e('Name of Item Being Reviewed (optional):', 'testimonial-rotator'); ?> </label><br> <input id="<?php echo $this->get_field_id('itemreviewed'); ?> " name="<?php echo $this->get_field_name('itemreviewed'); ?> " placeholder="<?php _e("Company Name, Product Name, etc.", 'testimonial-rotator'); ?> " value="<?php echo esc_attr($itemreviewed); ?> " type="text" style="width: 95%;"> </p> </div> </div> <?php }
function testimonial_rotator_metabox_effects() { global $post; $timeout = (int) get_post_meta($post->ID, '_timeout', true); $speed = (int) get_post_meta($post->ID, '_speed', true); $fx = get_post_meta($post->ID, '_fx', true); $shuffle = get_post_meta($post->ID, '_shuffle', true); $verticalalign = get_post_meta($post->ID, '_verticalalign', true); $prevnext = get_post_meta($post->ID, '_prevnext', true); $hidefeaturedimage = get_post_meta($post->ID, '_hidefeaturedimage', true); $hide_microdata = get_post_meta($post->ID, '_hide_microdata', true); $limit = (int) get_post_meta($post->ID, '_limit', true); $itemreviewed = get_post_meta($post->ID, '_itemreviewed', true); $template = get_post_meta($post->ID, '_template', true); $img_size = get_post_meta($post->ID, '_img_size', true); $title_heading = get_post_meta($post->ID, '_title_heading', true); $available_effects = testimonial_rotator_base_transitions(); $image_sizes = get_intermediate_image_sizes(); if (!$timeout) { $timeout = 5; } if (!$speed) { $speed = 1; } if (!$template) { $template = 'default'; } if (!$img_size) { $img_size = 'thumbnail'; } if (!$title_heading) { $title_heading = apply_filters('testimonial_rotator_title_heading', 'h2'); } $available_themes = testimonial_rotator_available_themes(); ?> <style> .hg_slider_column { width: 46%; margin: 0 2%; float: left; } /* 680 */ @media only screen and (max-width: 680px) { .hg_slider_column { width: 100%; margin: 0 0 20px 0; float: none; } } </style> <div class="hg_slider_column"> <p> <select name="fx"> <?php foreach ($available_effects as $available_effect) { ?> <option value="<?php echo $available_effect; ?> " <?php if ($available_effect == $fx) { echo " SELECTED"; } ?> ><?php echo $available_effect; ?> </option> <?php } ?> </select> <?php _e('Transition Effect', 'testimonial-rotator'); ?> </p> <p> <select name="img_size"> <?php foreach ($image_sizes as $image_size) { ?> <option value="<?php echo $image_size; ?> " <?php if ($image_size == $img_size) { echo " SELECTED"; } ?> ><?php echo $image_size; ?> </option> <?php } ?> </select> <?php _e('Image Size', 'testimonial-rotator'); ?> </p> <p> <input type="text" style="width: 45px; text-align: center;" name="timeout" value="<?php echo esc_attr($timeout); ?> " maxlength="4" /> <?php _e('Seconds per Testimonial', 'testimonial-rotator'); ?> </p> <p> <input type="text" style="width: 45px; text-align: center;" name="speed" value="<?php echo esc_attr($speed); ?> " maxlength="4" /> <?php _e('Transition Speed (in seconds)', 'testimonial-rotator'); ?> </p> <p> <input type="text" style="width: 45px; text-align: center;" name="limit" value="<?php echo esc_attr($limit); ?> " maxlength="4" /> <?php _e('Limit Number of Testimonials', 'testimonial-rotator'); ?> </p> <p> <input type="text" style="width: 45px; text-align: center;" name="title_heading" value="<?php echo esc_attr($title_heading); ?> " maxlength="12" /> <?php _e('Element for Title Field', 'testimonial-rotator'); ?> </p> </div> <div class="hg_slider_column"> <p> <input type="checkbox" name="shuffle" value="1" <?php if ($shuffle) { echo " CHECKED"; } ?> /> <?php _e('Randomize Testimonials', 'testimonial-rotator'); ?> </p> <p> <input type="checkbox" name="verticalalign" value="1" <?php if ($verticalalign) { echo " CHECKED"; } ?> /> <?php _e('Vertical Align (Center Testimonials Height)', 'testimonial-rotator'); ?> </p> <p> <input type="checkbox" name="prevnext" value="1" <?php if ($prevnext) { echo " CHECKED"; } ?> /> <?php _e('Show Previous/Next Buttons', 'testimonial-rotator'); ?> </p> <p> <input type="checkbox" name="hidefeaturedimage" value="1" <?php if ($hidefeaturedimage) { echo " CHECKED"; } ?> /> <?php _e('Hide Featured Image', 'testimonial-rotator'); ?> </p> <p> <input type="checkbox" name="hide_microdata" value="1" onchange="if(this.checked) { jQuery('#item-reviewed-p').slideUp(); } else { jQuery('#item-reviewed-p').slideDown(); }" <?php if ($hide_microdata) { echo " CHECKED"; } ?> /> <?php _e('Hide Microdata (hReview)', 'testimonial-rotator'); ?> </p> </div> <div class="clear"></div> <p id="item-reviewed-p" style="border-top: solid 1px #ccc; margin-top: 15px; padding-top: 15px;<?php if ($hide_microdata) { echo " display:none;"; } ?> "> <label for="itemreviewed"><?php _e('Name of Item Being Reviewed (optional):', 'testimonial-rotator'); ?> </label><br /> <small><?php _e("Company Name, Product Name, etc.", 'testimonial-rotator'); ?> (<?php _e("not visible on your website, used for search engines", 'testimonial-rotator'); ?> )</small><br /> <input type="text" style="width: 80%;" id="itemreviewed" name="itemreviewed" value="<?php echo esc_attr($itemreviewed); ?> " /> </p> <div style="padding: 15px 0; margin: 15px 0; border-top: solid 1px #ccc; border-bottom: solid 1px #ccc;"> <style> .testimonial-rotator-template-selector-wrap { border: solid 5px #ccc; } .tr_template_selected { border: solid 5px #bee483; } #testimonial-rotator-templates a:focus { box-shadow: none; } </style> <script> jQuery(document).ready(function() { jQuery('.testimonial-rotator-template-selector-wrap a').on('click', function() { jQuery('.testimonial-rotator-template-selector-wrap').removeClass('tr_template_selected'); jQuery('#testimonial_rotator_template').val( jQuery(this).data('slug') ); jQuery(this).parent('.testimonial-rotator-template-selector-wrap').addClass('tr_template_selected'); }); }); </script> <p> <strong><?php _e('Select a Theme:', 'testimonial-rotator'); ?> </strong><br> </p> <div id="testimonial-rotator-templates"> <?php foreach ($available_themes as $theme_slug => $available_theme) { ?> <div class="testimonial-rotator-template-selector-wrap <?php if ($template == $theme_slug) { echo "tr_template_selected"; } ?> " style="float: left; text-align: center; padding: 10px; margin: 10px; min-height: 100px;"> <a href="javascript:;" class="testimonial-rotator-template-selector" data-slug="<?php echo esc_attr($theme_slug); ?> "><img src="<?php echo $available_theme['icon']; ?> " style="width: 155px;"></a><br> <b><?php echo $available_theme['title']; ?> </b> - <a href="javascript:;" class="testimonial-rotator-template-selector" data-slug="<?php echo esc_attr($theme_slug); ?> "><?php echo __('Use', 'testimonial-rotator'); ?> </a> </div> <?php } ?> <div style="float: left; text-align: center; padding: 10px; margin: 10px; min-height: 100px;"> <a href="<?php echo TESTIMONIAL_ROTATOR_THEMES_URL; ?> " class="testimonial-rotator-template-selector" target="_blank"><img src="<?php echo TESTIMONIAL_ROTATOR_URI . "/images/get-themes.png"; ?> " style="width: 155px;"></a><br> <b>Add More Themes</b> - <a href="<?php echo TESTIMONIAL_ROTATOR_THEMES_URL; ?> " target="_blank"><?php echo __('Go', 'testimonial-rotator'); ?> </a> </div> <div style="clear:both;"></div> <input type="hidden" name="template" id="testimonial_rotator_template" value="<?php echo $template; ?> " /> </div> </div> <?php if ($post->post_name) { ?> <p> <strong><?php _e('Make a Custom Template:', 'testimonial-rotator'); ?> </strong><br> <?php _e('To create custom layouts for this rotator create a file called', 'testimonial-rotator'); ?> <b>loop-testimonial-<?php echo $post->post_name; ?> .php</b> <?php _e('and place it in your theme.', 'testimonial-rotator'); ?> </p> <?php } ?> <?php }