function testimonial_rotator_add_columns($column, $post_id) { $edit_link = get_edit_post_link($post_id); $rotator_ids = testimonial_rotator_break_piped_string(get_post_meta($post_id, "_rotator_id", true)); $rotator_title_array = array(); foreach ($rotator_ids as $rotator_id) { $rotator_title_array[] = "<a href='post.php?action=edit&post=" . $rotator_id . "'>" . get_the_title($rotator_id) . "</a>"; } $this_testimonial = get_post($post_id); if ($column == 'ID') { echo implode(", ", $rotator_title_array); } if ($column == 'image') { echo '<a href="' . $edit_link . '">' . get_the_post_thumbnail($post->ID, array(50, 50), array('title' => trim(strip_tags($post->post_title)))) . '</a>'; } if ($column == 'order') { echo '<a href="' . $edit_link . '">' . $this_testimonial->menu_order . '</a>'; } if ($column == 'rating') { echo get_post_meta($post_id, "_rating", true); } if ($column == 'shortcode') { echo '<b>' . __('Display as Single', 'testimonial-rotator') . '</b><br />'; echo '[testimonial_single id="' . $post_id . '"]'; } }
function testimonial_rotator_single($content) { global $post; // SINGLE TESTIMONIAL if (is_single() and get_post_type() == "testimonial") { $testimonial_id = isset($testimonial_id) ? $testimonial_id : $post->ID; // IF NO ROTATOR ID IS FOUND, GRAB THE FIRST ROTATOR ASSOCIATED if (!isset($rotator_id)) { $rotator_id = get_post_meta($testimonial_id, '_rotator_id', true); $rotator_ids = (array) testimonial_rotator_break_piped_string($rotator_id); $rotator_id = reset($rotator_ids); } $itemreviewed = get_post_meta($rotator_id, '_itemreviewed', true); $img_size = get_post_meta($rotator_id, '_img_size', true); $cite = get_post_meta($testimonial_id, '_cite', true); $has_image = has_post_thumbnail() ? "has-image" : false; $template_name = get_post_meta($rotator_id, '_template', true); $rating = (int) get_post_meta($testimonial_id, '_rating', true); $title_heading = get_post_meta($rotator_id, '_title_heading', true); // SANITIZE if (!trim($template_name)) { $template_name = "default"; } if (!trim($title_heading)) { $title_heading = apply_filters('testimonial_rotator_title_heading', 'h2', $template_name, $rotator_id); } $is_single_page = true; if (!$template_name) { $template_name = apply_filters('testimonial_rotator_single_page_theme', 'default', $post->ID); } // LOOK FOR single-testimonial IN TEMPLATE IN THEME $template = locate_template(array("single-testimonial.php")); if (!$template and $template_name != "default" and $template_name != "longform" and file_exists(dirname(__FILE__) . "/../testimonial-rotator-" . $template_name . "/templates/single-testimonial.php")) { $template = dirname(__FILE__) . "/../testimonial-rotator-" . $template_name . "/templates/single-testimonial.php"; } else { if (file_exists(dirname(__FILE__) . "/templates/{$template_name}/single-testimonial.php")) { $template = dirname(__FILE__) . "/templates/{$template_name}/single-testimonial.php"; } } if ($template) { // NO CUSTOM TEMPLATE, MODIFY THE CONTENT ob_start(); $show_title = apply_filters('testimonial_rotator_single_show_title', false, $template_name, $testimonial_id, $rotator_id); $show_image = apply_filters('testimonial_rotator_single_show_image', false, $template_name, $testimonial_id, $rotator_id); $show_body = true; $show_stars = true; $show_author = true; $show_microdata = true; if ($template) { include $template; } $output = ob_get_contents(); ob_end_clean(); return $output; } else { return testimonial_rotator_error(sprintf(__("The template: %s could be found", "testimonial-rotator"), $template_name)); } } return $content; }
function testimonial_rotator_add_columns($column) { global $post; $edit_link = get_edit_post_link($post->ID); $rotator_ids = testimonial_rotator_break_piped_string(get_post_meta($post->ID, "_rotator_id", true)); $rotator_title_array = array(); foreach ($rotator_ids as $rotator_id) { $rotator_title_array[] = get_the_title($rotator_id); } if ($column == 'ID') { echo implode(", ", $rotator_title_array); } if ($column == 'image') { echo '<a href="' . $edit_link . '" title="' . $post->post_title . '">' . get_the_post_thumbnail($post->ID, array(50, 50), array('title' => trim(strip_tags($post->post_title)))) . '</a>'; } if ($column == 'order') { echo '<a href="' . $edit_link . '">' . $post->menu_order . '</a>'; } if ($column == 'rating') { echo get_post_meta($post->ID, "_rating", true); } }
function testimonial_rotator_metabox_select() { global $post; $rotator_ids = testimonial_rotator_break_piped_string(get_post_meta($post->ID, '_rotator_id', true)); $rating = get_post_meta($post->ID, '_rating', true); $cite = get_post_meta($post->ID, '_cite', true); $rotators = get_posts(array('post_type' => 'testimonial_rotator', 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC')); ?> <?php if (!count($rotators)) { ?> <p style="color: red;"> <b><?php _e('No Testimonial Rotators have been created.', 'testimonial_rotator'); ?> </b><br /> <?php _e("You need to publish this testimonial so you don't lose your work and then go create a Testimonial Rotator. You can then edit this testimonial and select the rotator here.", "testimonial_rotator"); ?> </p> <?php } else { ?> <p> <?php _e('Attach to Rotator: ', 'testimonial_rotator'); ?> <?php foreach ($rotators as $rotator) { ?> <input type="checkbox" name="rotator_id[]" <?php echo in_array($rotator->ID, $rotator_ids) ? " CHECKED" : ""; ?> value="<?php echo $rotator->ID; ?> "/> <?php echo $rotator->post_title; ?> <?php } ?> </p> <?php } ?> <div style="padding: 10px 0; margin: 10px 0; border-top: solid 1px #ccc; border-bottom: solid 1px #ccc;"> <label for="stars"><?php _e('Star Rating:', 'testimonial_rotator'); ?> </label> <input type="radio" name="rating" value="1"<?php if ($rating == 1) { echo " CHECKED"; } ?> /> 1 <input type="radio" name="rating" value="2"<?php if ($rating == 2) { echo " CHECKED"; } ?> /> 2 <input type="radio" name="rating" value="3"<?php if ($rating == 3) { echo " CHECKED"; } ?> /> 3 <input type="radio" name="rating" value="4"<?php if ($rating == 4) { echo " CHECKED"; } ?> /> 4 <input type="radio" name="rating" value="5"<?php if ($rating == 5) { echo " CHECKED"; } ?> /> 5 <input type="radio" name="rating" value=""<?php if (!$rating) { echo " CHECKED"; } ?> /> <?php echo __("Don't Show", 'testimonial_rotator'); ?> </div> <p> <label for="cite"><?php _e('Author Information:', 'testimonial_rotator'); ?> </label><br> <small><?php _e("Company Name, Credentials, etc. (this info shows below the author's testimonial by default)", 'testimonial_rotator'); ?> </small> </p> <?php wp_editor($cite, 'testimonial-rotator-cite', array('tinymce' => array('theme_advanced_buttons1' => 'bold,italic,link,unlink'), 'textarea_name' => 'cite', 'media_buttons' => false, 'textarea_rows' => 3, 'quicktags' => false, "teeny" => true)); }
<?php global $post; $rotator_id = get_post_meta(get_the_ID(), '_rotator_id', true); $rotator_ids = (array) testimonial_rotator_break_piped_string($rotator_id); $rotator_id = reset($rotator_ids); $itemreviewed = get_post_meta($rotator_id, '_itemreviewed', true); $img_size = get_post_meta($rotator_id, '_img_size', true); $cite = get_post_meta(get_the_ID(), '_cite', true); $rating = (int) get_post_meta(get_the_ID(), '_rating', true); $has_image = has_post_thumbnail() ? "has-image" : false; // WRAPPER echo "<div class=\"testimonial_rotator_single hreview itemreviewed item {$has_image} cf-tr\">\n"; // POST THUMBNAIL if ($has_image) { echo "\t<div class=\"testimonial_rotator_img img\">" . get_the_post_thumbnail(get_the_ID(), $img_size) . "</div>\n"; } // DESCRIPTION echo "\t<div class=\"text testimonial_rotator_description\">\n"; // RATING if ($rating) { echo "<div class=\"testimonial_rotator_stars cf-tr\">\n"; for ($r = 1; $r <= $rating; $r++) { echo "\t<span class=\"testimonial_rotator_star testimonial_rotator_star_{$r}\"><i class=\"fa {$testimonial_rotator_star}\"></i></span>"; } echo "</div>\n"; } // CONTENT echo "<div class=\"testimonial_rotator_quote\">\n"; echo get_the_content(); echo "</div>\n";
function testimonial_single_shortcode($atts) { $id = isset($atts['id']) ? $atts['id'] : false; if ($id) { $testimonial = get_post($id); if ($testimonial->post_type == "testimonial") { // SETUP VARIABLES $rotator_id = get_post_meta($id, '_rotator_id', true); $rotator_ids = (array) testimonial_rotator_break_piped_string($rotator_id); $rotator_id = reset($rotator_ids); $atts['is_single'] = true; $atts['id'] = $rotator_id; $atts['testimonial_id'] = $id; $atts['prev_next'] = false; return get_testimonial_rotator($atts); } else { testimonial_rotator_error(__('Testimonial is not a testimonial post type', 'testimonial-rotator')); } } else { testimonial_rotator_error(sprintf(__('Testimonial could not be found with ID: %d', 'testimonial-rotator'), $id)); } }