ID ] = $page->post_title;
}
}
return $pages;
}
/**
* Get current address bar URL.
*
* @since 1.0.0
*
* @return string Current Page URL.
*/
function aec_get_current_url() {
$current_url = ( isset( $_SERVER["HTTPS"] ) && $_SERVER["HTTPS"] == "on" ) ? "https://" : "http://";
$current_url .= $_SERVER["SERVER_NAME"];
if( $_SERVER["SERVER_PORT"] != "80" && $_SERVER["SERVER_PORT"] != "443" ) {
$current_url .= ":".$_SERVER["SERVER_PORT"];
}
$current_url .= $_SERVER["REQUEST_URI"];
return $current_url;
}
/**
* Find days between 2 dates.
*
* @since 1.0.0
*
* @param string $start Start date.
* @param string $end End date.
* @return array $dates Array of date strings.
*/
function aec_get_dates_from_range( $start, $end ) {
$interval = new DateInterval('P1D');
$real_end = new DateTime( $end );
$real_end->add( $interval );
$period = new DatePeriod( new DateTime( $start ), $interval, $real_end );
$dates = array();
foreach( $period as $date ) {
$dates[] = $date->format('Y-m-d');
}
return $dates;
}
/**
* Get AEC categories list.
*
* @since 1.0.0
*
* @param int $parent Term ID.
* @return string $html AEC Categories List.
*/
function aec_list_categories( $parent = 0 ) {
$general_settings = get_option( 'aec_general_settings' );
$categories_settings = get_option( 'aec_categories_settings' );
$show_events_count = empty( $categories_settings['show_events_count'] ) ? 0 : 1;
$show_past_events = empty( $general_settings['show_past_events'] ) ? 0 : 1;
$args = array(
'hide_empty' => empty( $categories_settings['hide_empty_categories'] ) ? false : true,
'orderby' => $categories_settings['orderby'],
'order' => $categories_settings['order'],
'parent' => $parent,
'hierarchical' => 0
);
$terms = get_terms( 'aec_categories', $args );
$li = array();
foreach( $terms as $term ) {
$count = aec_get_events_count_by_category( $term->term_id, $show_past_events );
$child_terms = aec_list_categories( $term->term_id );
if( $show_events_count ) {
$li[] = sprintf( '
";
echo "
";
printf( __( "Page %d of %d", 'another-events-calendar' ), $paged, $numpages );
echo "
";
echo "";
echo "
";
}
}
/**
* Display the socialshare buttons.
*
* @since 1.0.0
*/
function the_aec_socialshare_buttons() {
global $post;
$page_settings = get_option( 'aec_page_settings' );
$socialshare_settings = get_option( 'aec_socialshare_settings' );
$content = '';
$page = '';
if( is_singular('aec_events') ) {
$page = 'event_detail';
} else {
if( $page_settings['categories'] == $post->ID ) {
$page = 'categories';
}
if( in_array( $post->ID, array( $page_settings['calendar'], $page_settings['events'], $page_settings['category'], $page_settings['tag'], $page_settings['venue'], $page_settings['organizer'], $page_settings['search'] ) ) ) {
$page = 'event_archives';
}
}
if( isset( $socialshare_settings['pages'] ) && in_array( $page, $socialshare_settings['pages'] ) ) {
// Vars
$site_title = urlencode( get_bloginfo('name') );
$permalink = urlencode( aec_get_current_url() );
$title = urlencode( get_the_title() );
$post_thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
// If current page = single category page
if( $post->ID == $page_settings['category'] ) {
if( $slug = get_query_var( 'aec_category' ) ) {
$term = get_term_by( 'slug', $slug, 'aec_categories' );
$title = $term->name;
}
}
// If current page = single tag page
if( $post->ID == $page_settings['tag'] ) {
if( $slug = get_query_var( 'aec_tag' ) ) {
$term = get_term_by( 'slug', $slug, 'aec_tags' );
$title = $term->name;
}
}
// If current page = single venue page
if( $post->ID == $page_settings['venue'] ) {
if( $slug = get_query_var( 'aec_venue' ) ) {
$page = get_page_by_path( $slug, OBJECT, 'aec_venues' );
$title = $page->post_title;
}
}
// If current page = single organizer page
if( $post->ID == $page_settings['organizer'] ) {
if( $slug = get_query_var( 'aec_organizer' ) ) {
$page = get_page_by_path( $slug, OBJECT, 'aec_organizers' );
$title = $page->post_title;
$post_thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $page->ID ), 'full' );
}
}
$thumbnail = '';
if( ! empty( $post_thumbnail ) ) {
$thumbnail = urlencode( $post_thumbnail[0] );
}
// Construct sharing URL without using any script
$facebook_url = 'https://www.facebook.com/sharer/sharer.php?u='.$permalink;
$twitter_url = 'https://twitter.com/intent/tweet?text='.$title.'&url='.$permalink.'&via='.$site_title;
$google_url = 'https://plus.google.com/share?url='.$permalink;
$linkedin_url = 'https:///www.linkedin.com/shareArticle?url='.$permalink.'&text='.$title;
$pinterest_url = 'https://pinterest.com/pin/create/button/?url='.$permalink.'&media='.$thumbnail.'&description='.$title;
// Add sharing button at the end of page/page content
$meta = array();
if( in_array( 'facebook', $socialshare_settings['services'] ) ) {
$meta[] = sprintf( '