function rah_add_host_og() { global $post; if ($post->post_type !== 'hosts') { return; } if (!is_single()) { return; } $user_id = get_user_id_from_host_id($post->ID); $og_tags = array('title' => 'Host Reviews for ' . $post->post_title, 'site_name' => 'Host Reviews Board', 'url' => get_permalink($post->ID), 'description' => 'Host reivews, ratings, and feedback for ' . $post->post_title, 'image' => get_user_meta($user_id, '_social_connect_avatar_url', true), 'type' => 'profile'); $user_data = get_userdata($user_id); $profile_tags = array('first_name' => $user_data->first_name, 'last_name' => $user_data->last_name); foreach ($og_tags as $key => $value) { $value = $key === 'url' || $key === 'image' ? $value : esc_attr($value); echo '<meta property="og:' . $key . '" content="' . $value . '" />'; } foreach ($profile_tags as $key => $value) { echo '<meta property="profile:' . $key . '" content="' . esc_attr($value) . '" />'; } }
function widget($args, $instance) { global $post; if (!is_object($post) || $post->post_type !== 'hosts' || !is_single()) { return; } $parent = get_post_ancestors($post); if ($parent) { $group_url = get_permalink($parent[0]); $group_name = get_the_title($parent[0]); $group_image = get_post_meta($parent[0], '_rah_group_fb_icon', true); } $group_types = get_the_terms($post->ID, 'type'); $types = implode(', ', wp_list_pluck($group_types, 'name')); $review_count = get_post_meta($post->ID, '_host_review_count', true); $host_location = get_post_meta($post->ID, '_user_postal_code', true); $location_string = ''; if (!empty($host_location)) { $city = rah_get_postal_city($host_location); $state = rah_get_postal_state($host_location); if (!empty($city)) { $location_string .= $city . ', '; } $location_string .= $state; } ?> <div class="host-widet-wraper"> <a href="<?php echo get_permalink($post->ID); ?> "> <div class="review-avatar"> <?php echo get_avatar(get_user_id_from_host_id($post->ID)); ?> </div> </a> <header class="entry-header"> <?php if (get_the_time(get_option('date_format'))) { ?> <h1 class="entry-title"><a href="<?php echo get_permalink($post->ID); ?> "> <?php the_title(); ?> </a></h1> <!-- .entry-title --> <div class="widget-host-type"><span class="dashicons dashicons-cart"></span><?php echo $types; ?> </div> <?php if (!empty($location_string)) { ?> <div class="widget-host-location"><span class="dashicons dashicons-location-alt"></span><?php echo $location_string; ?> </div> <?php } ?> <div class="entry-meta clearfix"> <div class="">Joined On: <?php the_time(get_option('date_format')); ?> </div> <?php if (isset($group_name)) { ?> <div class="group"><?php if ($group_image) { ?> <img src="<?php echo $group_image; ?> " /> <?php } ?> <a href="<?php echo $group_url; ?> " title-"<?php echo esc_attr($group_name); ?> "> <?php echo $group_name; ?> </a></div> <?php } ?> </div> <div class="widget-ratings-wrapper"> <?php echo rah_generate_stars(get_post_meta($post->ID, '_host_rating', true)); ?> <br /> <?php printf(_n('%d Review', '%d Reviews', $review_count, 'interface'), $review_count); ?> </div> <?php if (!user_is_host($post->ID)) { ?> <div class="widget-review-button"> <?php if (is_user_logged_in() && has_user_reviewed_host($post->ID)) { ?> <a href="<?php echo get_permalink($post->ID); ?> edit"><input type="button" value="Update Your Review" /></a> <?php } else { ?> <a href="<?php echo get_permalink($post->ID); ?> new"><input type="button" value="Review This Host" /></a> <?php } ?> </div> <?php } ?> <!-- .entry-meta --> </header> <!-- .entry-header --> <?php } ?> </header> </div> <?php }
function custom_columns($column, $post_id) { if ($column !== 'fb_link') { return; } $post_type = get_post_type($post_id); if ($post_type !== 'reviews' && $post_type !== 'groups' && $post_type !== 'hosts') { return; } switch ($post_type) { case 'reviews': $type = 'Review Author'; $post_data = get_post($post_id); $fb_id = get_user_meta($post_data->post_author, 'social_connect_facebook_id', true); break; case 'groups': $type = 'Group'; $fb_id = get_post_meta($post_id, '_rah_group_fb_id', true); break; case 'hosts': $type = 'Host'; $user_id = get_user_id_from_host_id($post_id); $fb_id = get_user_meta($user_id, 'social_connect_facebook_id', true); break; } $fb_link = 'https://facebook.com/' . $fb_id; if ($post_type === 'groups' && empty($fb_id)) { echo 'Group is Secret'; } else { echo '<a href="' . $fb_link . '" target="_blank">View ' . $type . ' on Facebook</a>'; } }