';
echo $html;
}
}
/**
* Display Social Sharing Buttons.
*
* @since 1.0.0
*/
function the_acadp_social_sharing_buttons() {
global $post;
$page_settings = get_option( 'acadp_page_settings' );
$socialshare_settings = get_option( 'acadp_socialshare_settings' );
$page = 'none';
if( 'acadp_listings' == $post->post_type ) {
$page = 'listing';
}
if( $post->ID == $page_settings['categories'] ) {
$page = 'categories';
}
if( $post->ID == $page_settings['locations'] ) {
$page = 'locations';
}
if( in_array( $post->ID, array( $page_settings['listings'], $page_settings['category'], $page_settings['location'], $page_settings['search'] ) ) ) {
$page = 'listings';
}
if( isset( $socialshare_settings['pages'] ) && in_array( $page, $socialshare_settings['pages'] ) ) {
// Get current page URL
$url = acadp_get_current_url();
// Get current page title
$title = get_the_title();
if( $post->ID == $page_settings['category'] ) {
if( $slug = get_query_var( 'acadp_category' ) ) {
$term = get_term_by( 'slug', $slug, 'acadp_categories' );
$title = $term->name;
}
}
if( $post->ID == $page_settings['location'] ) {
if( $slug = get_query_var( 'acadp_location' ) ) {
$term = get_term_by( 'slug', $slug, 'acadp_locations' );
$title = $term->name;
}
}
if( $post->ID == $page_settings['user_listings'] ) {
if( $slug = get_query_var( 'acadp_user' ) ) {
$user = get_user_by( 'slug', $slug );
$title = $user->display_name;
}
}
$title = str_replace( ' ', '%20', $title );
// Get Post Thumbnail
$thumbnail = '';
if( 'listing' == $page ) {
$images = get_post_meta( $post->ID, 'images', true );
if( ! empty( $images ) ) {
$image_attributes = wp_get_attachment_image_src( $images[0], 'full' );
$thumbnail = is_array( $image_attributes ) ? $image_attributes[0] : '';
}
} else {
$image_attributes = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
$thumbnail = is_array( $image_attributes ) ? $image_attributes[0] : '';
}
// Construct sharing buttons
$buttons = array();
if( isset( $socialshare_settings['services'] ) ) {
if( in_array( 'facebook', $socialshare_settings['services'] ) ) {
$facebookURL = 'https://www.facebook.com/sharer/sharer.php?u='.$url;
$buttons[] = ''.__( 'Facebook', 'advanced-classifieds-and-directory-pro' ).'';
}
if( in_array( 'twitter', $socialshare_settings['services'] ) ) {
$twitterURL = 'https://twitter.com/intent/tweet?text='.$title.'&url='.$url;
$buttons[] = '';
}
if( in_array( 'gplus', $socialshare_settings['services'] ) ) {
$googleURL = 'https://plus.google.com/share?url='.$url;
$buttons[] = ''.__( 'Google+', 'advanced-classifieds-and-directory-pro' ).'';
}
if( in_array( 'linkedin', $socialshare_settings['services'] ) ) {
$linkedinURL = 'https://www.linkedin.com/shareArticle?url='.$url.'&title='.$title;
$buttons[] = ''.__( 'Linkedin', 'advanced-classifieds-and-directory-pro' ).'';
}
if( in_array( 'pinterest', $socialshare_settings['services'] ) ) {
$pinterestURL = 'https://pinterest.com/pin/create/button/?url='.$url.'&media='.$thumbnail.'&description='.$title;
$buttons[] = ''.__( 'Pin It', 'advanced-classifieds-and-directory-pro' ).'';
}
}
if( count( $buttons ) ) {
echo ''.implode( ' ', $buttons ).'
';
}
}
}
/**
* Display the listing thumbnail.
*
* @since 1.0.0
*
* @param array $post_meta Post Meta.
*/
function the_acadp_listing_thumbnail( $post_meta ) {
$image = '';
if( isset( $post_meta['images'] ) ) {
$images = unserialize( $post_meta['images'][0] );
$image_attributes = wp_get_attachment_image_src( $images[0], 'medium' );
$image = $image_attributes[0];
} else {
$image = ACADP_PLUGIN_URL . 'public/images/no-image.png';
}
if( '' !== $image ) {
echo '
';
}
}
/**
* Display the listing labels.
*
* @since 1.0.0
*
* @param array $post_meta Post Meta.
*/
function the_acadp_listing_labels( $post_meta ) {
global $post;
$general_settings = get_option( 'acadp_general_settings' );
$featured_listing_settings = get_option( 'acadp_featured_listing_settings' );
if( ! empty( $general_settings['show_new_tag'] ) ) {
$each_hours = 60 * 60 * 24; // seconds in a day
$s_date1 = strtotime( current_time( 'mysql' ) ); // seconds for date 1
$s_date2 = strtotime( $post->post_date ); // seconds for date 2
$s_date_diff = abs( $s_date1 - $s_date2 ); // different of the two dates in seconds
$days = round( $s_date_diff / $each_hours ); // divided the different with second in a day
if( $days <= (int) $general_settings['new_listing_threshold'] ) {
echo ''.$general_settings['new_listing_label'].' ';
}
}
if( ! empty( $general_settings['show_popular_tag'] ) ) {
if( isset( $post_meta['views'] ) && (int) $post_meta['views'][0] >= (int) $general_settings['popular_listing_threshold'] ) {
echo ''.$general_settings['popular_listing_label'].' ';
}
}
if( ! empty( $featured_listing_settings['show_featured_tag'] ) ) {
if( isset( $post_meta['featured'] ) && 1 == (int) $post_meta['featured'][0] ) {
echo ''.$featured_listing_settings['label'].' ';
}
}
}
/**
* Display the listing address.
*
* @since 1.0.0
*
* @param array $post_meta Post Meta.
* @param int $term_id Custom Taxonomy term ID.
*/
function the_acadp_address( $post_meta, $term_id ) {
// Get all the location term ids
$locations = array( $term_id );
$ancestors = get_ancestors( $term_id, 'acadp_locations' );
$locations = array_merge( $locations, $ancestors );
// Build address vars
echo '';
if( isset( $post_meta['address'] ) ) {
echo ''.$post_meta['address'][0].'';
}
$pieces = array();
$country = end( $locations );
if( count( $locations ) > 1 ) {
array_pop( $locations );
foreach( $locations as $region ) {
$term = get_term( $region, 'acadp_locations' );
$pieces[] = ''.$term->name.'';
}
}
$term = get_term( $country, 'acadp_locations' );
$pieces[] = ''.$term->name.'';
if( ! empty( $post_meta['zipcode'][0] ) ) {
$pieces[] = $post_meta['zipcode'][0];
}
echo implode( ',', $pieces );
if( isset( $post_meta['phone'] ) ) {
echo ' '.$post_meta['phone'][0].'';
}
if( isset( $post_meta['email'] ) ) {
$email_settings = get_option( 'acadp_email_settings' );
$show_email_address_publicly = ! empty( $email_settings['show_email_address_publicly'] ) ? 1 : 0;
if( $show_email_address_publicly || is_user_logged_in() ) {
echo ' '.$post_meta['email'][0].'';
} else {
echo ' *****';
}
}
if( isset( $post_meta['website'] ) ) {
echo ' '.$post_meta['website'][0].'';
}
echo '';
}
/**
* Get activated payment gateways.
*
* @since 1.0.0
*/
function the_acadp_payment_gateways() {
$gateways = acadp_get_payment_gateways();
$settings = get_option( 'acadp_gateway_settings' );
$list = array();
if( isset( $settings['gateways'] ) ) {
foreach( $gateways as $key => $label ) {
if( in_array( $key, $settings['gateways'] ) ) {
$gateway_settings = get_option( 'acadp_gateway_'.$key.'_settings' );
$label = ! empty( $gateway_settings['label'] ) ? $gateway_settings['label'] : $label;
$html = '';
$html .= sprintf( '', $key, ( $key == end( $settings['gateways'] ) ? ' checked' : '' ), $label );
if( ! empty( $gateway_settings['description'] ) ) {
$html .= ''.$gateway_settings['description'].'
';
}
$html .= '';
$list[] = $html;
}
}
}
if( count( $list ) ) {
echo ''.implode( "\n", $list ).'
';
}
}
/**
* Get instructions to do offline payment.
*
* @since 1.0.0
*/
function the_acadp_offline_payment_instructions() {
$settings = get_option('acadp_gateway_offline_settings');
echo '' . nl2br( $settings['instructions'] ) . '
';
}