function wpsight_do_listing_agent($location = false, $widget = false, $instance = false) { /** * Check location and set * $args accordingly */ if ($location == 'archive') { // Set agent ID $agent = get_userdata(get_query_var('author')); $agent_id = $agent->ID; // Set contact link $contact_link = is_pagetemplate_active('page-tpl-contact.php') ? add_query_arg(array(apply_filters('wpsight_author_slug', 'agent') => $agent_id), get_pagetemplate_permalink('page-tpl-contact.php')) : false; // Set $args $args = array('title' => $agent->display_name, 'contact' => esc_url($contact_link), 'image' => array('show' => true, 'align' => 'right', 'linked' => true), 'bio' => true, 'email' => array('show' => true, 'icon' => '<i class="icon-envelope"></i> ', 'linked' => true), 'url' => array('show' => true, 'icon' => '<i class="icon-external-link"></i> ', 'linked' => true), 'custom' => array('fields' => wpsight_profile_contact_fields($location), 'icon' => true, 'linked' => true), 'button' => false); $args = apply_filters('wpsight_listing_agent_info_args_archive', $args, $agent_id); } elseif ($location == 'listing') { // Set agent ID $agent_id = get_the_author_meta('ID'); // Set $args $args = array('title' => get_the_author(), 'image' => array('show' => true, 'align' => 'left', 'linked' => true), 'bio' => true, 'email' => array('show' => true, 'icon' => '<i class="icon-envelope"></i> ', 'linked' => true), 'url' => array('show' => true, 'icon' => '<i class="icon-external-link"></i> ', 'linked' => true), 'custom' => array('fields' => wpsight_profile_contact_fields($location), 'icon' => true, 'linked' => true), 'button' => true); $args = apply_filters('wpsight_listing_agent_info_args_listing', $args, $widget, $instance, $agent_id); } elseif ($location == 'featured') { // Set agent ID $agent_id = $instance['agent']; // Set $args $args = array('title' => false, 'image' => array('show' => true, 'align' => 'left', 'linked' => true), 'bio' => true, 'email' => array('show' => true, 'icon' => '<i class="icon-envelope"></i> ', 'linked' => true), 'url' => array('show' => true, 'icon' => '<i class="icon-external-link"></i> ', 'linked' => true), 'custom' => array('fields' => wpsight_profile_contact_fields($location), 'icon' => true, 'linked' => true), 'button' => true); $args = apply_filters('wpsight_listing_agent_info_args_featured', $args, $widget, $instance, $agent_id); } elseif ($location == 'list') { // Set agent ID global $agent_id; // Set $args $args = array('title' => true, 'image' => array('show' => true, 'align' => 'left', 'linked' => true), 'bio' => true, 'email' => array('show' => true, 'icon' => '<i class="icon-envelope"></i> ', 'linked' => true), 'url' => array('show' => true, 'icon' => '<i class="icon-external-link"></i> ', 'linked' => true), 'custom' => array('fields' => wpsight_profile_contact_fields($location), 'icon' => true, 'linked' => true), 'button' => true); $args = apply_filters('wpsight_listing_agent_info_args_list', $args, $agent_id); } $args = apply_filters('wpsight_listing_agent_info_args', $args); // Extract $args extract($args, EXTR_SKIP); // Create listing agent info $listing_agent = '<div class="listing-agent listing-agent-' . $agent_id . ' author-info clearfix">'; if ($title && !is_singular()) { $listing_agent .= '<div class="title title-author clearfix">'; $listing_agent .= '<h2>' . $title . '</h2>'; if (isset($contact) && $contact != false) { $listing_agent .= '<div class="title-actions title-actions-contact">' . "\n"; $listing_agent .= '<a href="' . $contact_link . '" class="btn btn-mini"><i class="icon-envelope-alt"></i>' . __('Contact', 'wpsight') . '</a>' . "\n"; $listing_agent .= '</div>' . "\n"; } $listing_agent .= '</div><!-- .title -->'; } // Get profile image or avatar if ($image['show'] == true) { $author_image = get_the_author_meta('profile_image', $agent_id); if (!empty($author_image)) { $agent_image = '<img src="' . $author_image['url'] . '" class="avatar avatar-align-' . $image['align'] . '" alt="' . $title . '" />'; } else { $agent_image = '<span class="avatar-align-' . $image['align'] . '">' . get_avatar(get_the_author_meta('email', $agent_id), '80', false, $title) . '</span>'; } if ($image['linked'] == true) { $listing_agent .= '<a href="' . get_author_posts_url($agent_id) . '" title="' . __('See my listings', 'wpsight') . '" class="avatar-wrap avatar-wrap-align-' . $image['align'] . '">'; } else { $listing_agent .= '<div class="avatar-wrap avatar-wrap-align-' . $image['align'] . '">'; } $listing_agent .= $agent_image; if ($image['linked'] == true) { $listing_agent .= '</a><!-- .avatar-wrap -->'; } else { $listing_agent .= '</div><!-- .avatar-wrap -->'; } } // Put text next to image in extra div $listing_agent .= '<div class="listing-agent-info">'; // Display agent name on agent list if ($title && $location == 'list') { $listing_agent .= '<h2>' . get_the_author_meta('display_name', $agent_id) . '</h2>'; } // Get profile contact email // if( $email['show'] == true ) { // $agent_email = get_the_author_meta( 'email', $agent_id ); // if( ! empty( $agent_email ) ) { // $listing_agent .= '<div class="listing-agent-email">'; // if( ! empty( $email['icon'] ) ) // $listing_agent .= $email['icon']; // $listing_agent .= '<strong>' . __( 'Email', 'wpsight' ) . ':</strong> '; // if( $email['linked'] == true ) // $listing_agent .= '<a href="mailto:' . antispambot( $agent_email ) . '">'; // $listing_agent .= antispambot( $agent_email ); // if( $email['linked'] == true ) // $listing_agent .= '</a>'; // $listing_agent .= '</div><!-- .listing-agent-email -->'; // } // } // Get profile contact website if ($url['show'] == true) { $agent_url = get_the_author_meta('url', $agent_id); if (!empty($agent_url)) { $listing_agent .= '<div class="listing-agent-url">'; if (!empty($url['icon'])) { $listing_agent .= $url['icon']; } $listing_agent .= '<strong>' . __('Website', 'wpsight') . ':</strong> '; if ($url['linked'] == true) { $listing_agent .= '<a href="' . $agent_url . '" target="_blank">'; } $listing_agent .= $agent_url; if ($email['linked'] == true) { $listing_agent .= '</a>'; } $listing_agent .= '</div><!-- .listing-agent-url -->'; } } // Get profile contact custom fields foreach ($custom['fields'] as $k => $v) { $agent_meta = get_the_author_meta($k, $agent_id); if (!empty($agent_meta)) { $listing_agent .= '<div class="listing-agent-' . $k . '">'; if (!empty($v['icon']) && $custom['icon'] !== false) { $listing_agent .= $v['icon']; } // $listing_agent .= '<strong>' . $v['label'] . ':</strong> '; if ($custom['linked'] == true && $v['url'] != false) { $url = $v['url'] . $agent_meta; if ($v['url'] === true) { $url = $agent_meta; } $listing_agent .= '<a href="' . $url . '" target="_blank">'; } if ($k == 'email') { $listing_agent .= '<strong><a href="mailto:' . $agent_meta . '">' . $agent_meta . '</a></strong>'; } else { $listing_agent .= '<strong>' . $agent_meta . '</strong>'; } if ($custom['linked'] == true && $v['url'] != false) { $listing_agent .= '</a>'; } $listing_agent .= '</div><!-- .listing-agent-' . $k . ' -->'; } } // Create author archive button if ($button == true && !is_author()) { // $listing_agent .= '<a href="' . get_author_posts_url( $agent_id ) . '" class="' . apply_filters( 'wpsight_button_class_agent', 'btn' ) . '">'; // $listing_agent .= __( 'See my listings', 'wpsight' ); // $listing_agent .= '</a>'; $listing_agent .= '<div><i class="fa fa-user"></i> <a href="' . get_author_posts_url($agent_id) . '" class="agent-profile-link">'; $listing_agent .= __('Agent profile', 'wpsight'); $listing_agent .= '</a></div>'; } // Get profile description/bio if ($bio == true) { $listing_agent .= '<div class="listing-agent-bio">'; $listing_agent .= wpsight_format_content(get_the_author_meta('description', $agent_id)); $listing_agent .= '</div><!-- .listing-agent-bio -->'; } // Add link to profile for admins // if( current_user_can( 'edit_users' ) ) { // $listing_agent .= '<div class="listing-agent-profile">'; // $listing_agent .= '<i class="icon-user"></i> <strong>' . __ ( 'Admin', 'wpsight' ) . ':</strong> '; // $listing_agent .= '<a href="' . admin_url( 'user-edit.php?user_id=' . $agent_id, is_ssl() ? 'https' : 'http' ) . '" class="wpsight-listing-agent-profile">' . __ ( 'See profile', 'wpsight' ) . '</a>'; // $listing_agent .= '</div><!-- .listing-agent-profile -->'; // } // Put text next to image in extra div $listing_agent .= '</div><!-- .listing-agent-info -->'; // Create listing agent info $listing_agent .= '</div><!-- .listing-agent -->'; // Filter and output echo apply_filters('wpsight_listing_agent_info', $listing_agent); }
function wpsight_do_listing_favorites_contact_link() { if (!is_page_template('page-tpl-favorites.php') || empty($_COOKIE[WPSIGHT_COOKIE_FAVORITES]) || !is_pagetemplate_active('page-tpl-contact.php')) { return; } ?> <div class="title-actions title-actions-contact"> <a href="<?php echo esc_url(add_query_arg(array('fav' => '1'), get_pagetemplate_permalink('page-tpl-contact.php'))); ?> " class="<?php echo apply_filters('wpsight_title_action_css', 'btn btn-mini', 'contact'); ?> "><i class="icon-envelope-alt"></i> <?php _e('Contact', 'wpsight'); ?> </a> </div><?php }
function wpsight_listing_title_action_favorite($data) { $labels = array('favorites_add' => $data['label'], 'favorites_see' => __('Favorites', 'wpsight')); $labels = apply_filters('wpsight_do_listing_title_actions_labels', $labels); // Check if listings are still published $favorites_removed = array(); if (isset($_COOKIE[WPSIGHT_COOKIE_FAVORITES])) { $favorites = explode(',', $_COOKIE[WPSIGHT_COOKIE_FAVORITES]); foreach ($favorites as $favorite) { if (get_post_status($favorite) != 'publish') { $favorites_removed[] = $favorite; } } } ?> <script type="text/javascript"> jQuery(document).ready(function($){ var cookie_favs = '<?php echo WPSIGHT_COOKIE_FAVORITES; ?> '; var removeValue = function(list, value) { var values = list.split(","); for(var i = 0 ; i < values.length ; i++) { if(values[i] == value) { values.splice(i, 1); return values.join(","); } } return list; }; <?php // Remove unpublished listings from cookie if (!array_empty($favorites_removed)) { foreach ($favorites_removed as $favorite_removed) { echo 'var favs = removeValue($.cookie(cookie_favs), ' . $favorite_removed . ');'; } echo '$.cookie(cookie_favs, favs,{ expires: 60, path: \'' . COOKIEPATH . '\' });'; } ?> if($.cookie(cookie_favs)!=null) { if($.cookie(cookie_favs).search('<?php the_ID(); ?> ')!=-1) { $('.actions-favorites').hide(); $('.actions-favorites-link').show(); if($('.actions-favorites-link small').length == 0) { $('.actions-favorites-link').append(' <span class="badge badge-important">' + $.cookie(cookie_favs).split(',').length + '</span>'); } } } $('.actions-favorites').click(function(e) { e.preventDefault(); if($.cookie(cookie_favs)==null || $.cookie(cookie_favs)=='') { $.cookie(cookie_favs, <?php the_ID(); ?> ,{ expires: 60, path: '<?php echo COOKIEPATH; ?> ' }); } else { var fav = $.cookie(cookie_favs); $.cookie(cookie_favs, fav + ',' + <?php the_ID(); ?> ,{ expires: 60, path: '<?php echo COOKIEPATH; ?> ' }); } $(this).fadeOut(75, function() { $('.actions-favorites-link').fadeIn(75); $('.actions-favorites-link').append(' <span class="badge badge-important">' + $.cookie(cookie_favs).split(',').length + '</span>'); }); }); }); </script><?php $output = ''; if (is_pagetemplate_active('page-tpl-favorites.php')) { // Save Button $output .= '<a href="' . $data['href'] . '" id="' . $data['id'] . '" class="' . $data['class'] . '" target="' . $data['target'] . '" ' . $data['atts'] . '>'; // check if icon is available if ($data['icon']) { $output .= '<i class="' . $data['icon'] . '"></i>'; } $output .= $labels['favorites_add']; $output .= '</a>'; // Favorites Button $output .= '<a href="' . get_pagetemplate_permalink('page-tpl-favorites.php') . '" class="' . apply_filters('wpsight_title_action_css', 'btn btn-mini actions-favorites-link action-link', 'favorites_see') . '" style="display:none">'; $output .= '<i class="icon-star"></i>' . $labels['favorites_see']; $output .= '</a>'; } // return output return $output; }