roles;
$role = array_shift($roles);
return isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role] ) : false;
}
/**
* Get and include template files.
*
* @param mixed $template_name
* @param array $args (default: array())
* @param string $template_path (default: '')
* @param string $default_path (default: '')
* @return void
*/
function get_event_manager_template( $template_name, $args = array(), $template_path = 'wp-event-manager', $default_path = '' ) {
if ( $args && is_array( $args ) ) {
extract( $args );
}
include( locate_event_manager_template( $template_name, $template_path, $default_path ) );
}
/**
* Locate a template and return the path for inclusion.
*
* This is the load order:
*
* yourtheme / $template_path / $template_name
* yourtheme / $template_name
* $default_path / $template_name
*
* @param string $template_name
* @param string $template_path (default: 'wp-event-manager')
* @param string|bool $default_path (default: '') False to not load a default
* @return string
*/
function locate_event_manager_template( $template_name, $template_path = 'wp-event-manager', $default_path = '' ) {
// Look within passed path within the theme - this is priority
$template = locate_template(
array(
trailingslashit( $template_path ) . $template_name,
$template_name
)
);
// Get default template
if ( ! $template && $default_path !== false ) {
$default_path = $default_path ? $default_path : EVENT_MANAGER_PLUGIN_DIR . '/templates/';
if ( file_exists( trailingslashit( $default_path ) . $template_name ) ) {
$template = trailingslashit( $default_path ) . $template_name;
}
}
// Return what we found
return apply_filters( 'event_manager_locate_template', $template, $template_name, $template_path );
}
/**
* Get template part (for templates in loops).
*
* @param string $slug
* @param string $name (default: '')
* @param string $template_path (default: 'wp-event-manager')
* @param string|bool $default_path (default: '') False to not load a default
*/
function get_event_manager_template_part( $slug, $name = '', $template_path = 'wp-event-manager', $default_path = '' ) {
$template = '';
if ( $name ) {
$template = locate_event_manager_template( "{$slug}-{$name}.php", $template_path, $default_path );
}
// If template file doesn't exist, look in yourtheme/slug.php and yourtheme/wp-event-manager/slug.php
if ( ! $template ) {
$template = locate_event_manager_template( "{$slug}.php", $template_path, $default_path );
}
if ( $template ) {
load_template( $template, false );
}
}
/**
* Add custom body classes
* @param array $classes
* @return array
*/
function event_manager_body_class( $classes ) {
$classes = (array) $classes;
$classes[] = sanitize_title( wp_get_theme() );
return array_unique( $classes );
}
add_filter( 'body_class', 'event_manager_body_class' );
/**
* Get events pagination for [events] shortcode
* @return [type] [description]
*/
function get_event_listing_pagination( $max_num_pages, $current_page = 1 ) {
ob_start();
get_event_manager_template( 'event-pagination.php', array( 'max_num_pages' => $max_num_pages, 'current_page' => absint( $current_page ) ) );
return ob_get_clean();
}
/**
* Outputs the events status
*
* @return void
*/
function display_event_status( $post = null ) {
echo get_event_status( $post );
}
/**
* Gets the events status
*
* @return string
*/
function get_event_status( $post = null ) {
$post = get_post( $post );
$status = $post->post_status;
$statuses = get_event_listing_post_statuses();
if ( isset( $statuses[ $status ] ) ) {
$status = $statuses[ $status ];
} else {
$status = __( 'Inactive', 'wp-event-manager' );
}
return apply_filters( 'display_event_status', $status, $post );
}
/**
* Return whether or not the position has been marked as cancelled
*
* @param object $post
* @return boolean
*/
function is_event_cancelled( $post = null ) {
$post = get_post( $post );
return $post->_cancelled ? true : false;
}
/**
* Return whether or not the position has been featured
*
* @param object $post
* @return boolean
*/
function is_event_featured( $post = null ) {
$post = get_post( $post );
return $post->_featured ? true : false;
}
/**
* Return whether or not registrations are allowed
*
* @param object $post
* @return boolean
*/
function attendees_can_apply( $post = null ) {
$post = get_post( $post );
return apply_filters( 'event_manager_attendees_can_register', ( ! is_event_cancelled() && ! in_array( $post->post_status, array( 'preview', 'expired' ) ) ), $post );
}
/**
* display_event_permalink function.
*
* @access public
* @return void
*/
function display_event_permalink( $post = null ) {
echo get_event_permalink( $post );
}
/**
* get_event_registration_method function.
*
* @access public
* @param mixed $post (default: null)
* @return object
*/
function get_event_registration_method( $post = null ) {
$post = get_post( $post );
if ( $post && $post->post_type !== 'event_listing' ) {
return;
}
$method = new stdClass();
$register = $post->_registration;
if ( empty( $register ) ) {
$method->type ='url';
return apply_filters( 'get_event_registration_method', $method, $post );
}
if ( strstr( $register, '@' ) && is_email( $register ) ) {
$method->type = 'email';
$method->raw_email = $register;
$method->email = antispambot( $register );
$method->subject = apply_filters( 'event_manager_registration_email_subject', sprintf( __( 'Registration via "%s" listing on %s', 'wp-event-manager' ), $post->post_title, home_url() ), $post );
} else {
if ( strpos( $register, 'http' ) !== 0 )
$register = 'http://' . $register;
$method->type = 'url';
$method->url = $register;
}
return apply_filters( 'display_event_registration_method', $method, $post );
}
/**
* get_event_permalink function
*
* @access public
* @param mixed $post (default: null)
* @return string
*/
function get_event_permalink( $post = null ) {
$post = get_post( $post );
$link = get_permalink( $post );
return apply_filters( 'display_event_permalink', $link, $post );
}
/**
* display_event_type function.
*
* @access public
* @return void
*/
function display_event_type( $post = null, $after = '') {
if ( $event_type = get_event_type( $post ) ) {
if (! empty( $event_type ) ) {
$numType = count($event_type);
$i = 0;
foreach ( $event_type as $type ) {
echo ''. $type->name.'';
if($numType > ++$i){
echo $after;
}
}
}
}
}
/**
* get_event_type function.
*
* @access public
* @param mixed $post (default: null)
* @return void
*/
function get_event_type( $post = null ) {
$post = get_post( $post );
if ( $post->post_type !== 'event_listing' || !get_option( 'event_manager_enable_event_types' ) ) {
return;
}
$types = wp_get_post_terms( $post->ID, 'event_listing_type' );
// Return single if not enabled.
if ( ! empty( $types ) && ! event_manager_multiselect_event_type() ) {
$types = array( current( $types ) );
}
if(empty($types))
$types = '';
return apply_filters( 'display_event_type', $types, $post );
}
/**
* display_event_category function.
*
* @access public
* @return void
*/
function display_event_category( $post = null, $after = '' ) {
if ( $event_category = get_event_category( $post ) ) {
if (! empty( $event_category ) ) {
$numCategory = count($event_category);
$i = 0;
foreach ( $event_category as $cat ) {
echo ''. $cat->name.'';
if($numCategory > ++$i){
echo $after;
}
}
}
}
}
/**
* get_event_category function.
*
* @access public
* @param mixed $post (default: null)
* @return void
*/
function get_event_category( $post = null ) {
$post = get_post( $post );
if ( $post->post_type !== 'event_listing' || !get_option( 'event_manager_enable_categories' ) ) {
return;
}
$categories = wp_get_post_terms( $post->ID, 'event_listing_category' );
// Return single if not enabled.
if ( !empty( $categories ) && ! event_manager_multiselect_event_category() ) {
$categories = array( current( $categories ) );
}
return apply_filters( 'display_event_category', $categories, $post );
}
/**
* Returns the registration fields used when an account is required.
*
* @since 2.2
*
* @return array $registration_fields
*/
function wp_event_manager_get_registration_fields() {
$generate_username_from_email = event_manager_generate_username_from_email();
$use_standard_password_setup_email = event_manager_use_standard_password_setup_email();
$account_required = event_manager_user_requires_account();
$registration_fields = array();
if ( event_manager_enable_registration() ) {
if ( ! $generate_username_from_email ) {
$registration_fields['create_account_username'] = array(
'type' => 'text',
'label' => __( 'Username', 'wp-event-manager' ),
'required' => $account_required,
'value' => isset( $_POST['create_account_username'] ) ? $_POST['create_account_username'] : '',
);
}
if ( ! $use_standard_password_setup_email ) {
$registration_fields['create_account_password'] = array(
'type' => 'password',
'label' => __( 'Password', 'wp-event-manager' ),
'placeholder' => __( 'Password', 'wp-event-manager' ),
'autocomplete' => false,
'required' => $account_required,
);
$password_hint = event_manager_get_password_rules_hint();
if ( $password_hint ) {
$registration_fields['create_account_password']['description'] = $password_hint;
}
$registration_fields['create_account_password_verify'] = array(
'type' => 'password',
'label' => __( 'Verify Password', 'wp-event-manager' ),
'placeholder' => __( 'Confirm Password', 'wp-event-manager' ),
'autocomplete' => false,
'required' => $account_required,
);
}
$registration_fields['create_account_email'] = array(
'type' => 'text',
'label' => __( 'Your email', 'wp-event-manager' ),
'placeholder' => __( 'you@yourdomain.com', 'wp-event-manager' ),
'required' => $account_required,
'value' => isset( $_POST['create_account_email'] ) ? $_POST['create_account_email'] : '',
);
}
return apply_filters( 'event_manager_get_registration_fields', $registration_fields );
}
/**
* display_event_publish_date function.
* @param mixed $post (default: null)
* @return [type]
*/
function display_event_publish_date( $post = null ) {
$date_format = get_option( 'event_manager_date_format' );
if ( $date_format === 'default' ) {
$display_date = __( 'Posted on ', 'wp-event-manager' ) . get_post_time( get_option( 'date_format' ) );
} else {
$display_date = sprintf( __( 'Posted %s ago', 'wp-event-manager' ), human_time_diff( get_post_time( 'U' ), current_time( 'timestamp' ) ) );
}
echo '';
}
/**
* get_event_publish_date function.
* @param mixed $post (default: null)
* @return [type]
*/
function get_event_publish_date( $post = null ) {
$date_format = get_option( 'event_manager_date_format' );
if ( $date_format === 'default' ) {
return get_post_time( get_option( 'date_format' ) );
} else {
return sprintf( __( 'Posted %s ago', 'wp-event-manager' ), human_time_diff( get_post_time( 'U' ), current_time( 'timestamp' ) ) );
}
}
/**
* get_event_location function.
*
* @access public
* @param mixed $post (default: null)
* @return void
*/
function get_event_location( $post = null ) {
$post = get_post( $post );
if ( $post->post_type !== 'event_listing' )
return;
return apply_filters( 'display_event_location', $post->_event_location, $post );
}
/**
* display_event_location function.
* @param boolean $map_link whether or not to link to the map on google maps
* @return [type]
*/
function display_event_location( $map_link = true, $post = null ) {
$location = get_event_location( $post );
if ( $location ) {
if ( $map_link )
echo apply_filters( 'display_event_location_map_link', '' . $location . '', $location, $post );
else
echo $location;
} else {
echo apply_filters( 'display_event_location_anywhere_text', __( 'Online Event', 'wp-event-manager' ) );
}
}
/**
* get_the_event_ticket function.
*
* @access public
* @param mixed $post (default: null)
* @return string
*/
function get_event_ticket_option( $post = null ) {
$post = get_post( $post );
if ( $post->post_type !== 'event_listing' )
return;
return apply_filters( 'display_event_ticket_option', $post->_event_ticket_options, $post );
}
/**
* Display or retrieve the current event ticket price information with optional content.
*
* @access public
* @param mixed $id (default: null
* @return void
*/
function display_event_ticket_option( $before = '', $after = '', $echo = true, $post = null ) {
$event_ticket_option = get_event_ticket_option( $post );
if ( strlen( $event_ticket_option ) == 0 )
return;
$event_ticket_option = esc_attr( strip_tags( $event_ticket_option ) );
//find the option value from the field editor array
$fields = get_option( 'event_manager_form_fields',true);
if(is_array($fields) && count($fields) > 0 ){
$ticket_option_field = array_column($fields,'event_ticket_options');
foreach ($ticket_option_field as $key => $value) {
if(isset($value['options']) && isset($value['options'][$event_ticket_option]) ){
$event_ticket_option = $value['options'][$event_ticket_option];
}
}
}
$event_ticket_option = $before . $event_ticket_option . $after;
if ( $echo )
echo $event_ticket_option;
else
return $event_ticket_option;
}
/**
* get_event_registration_end_date function.
*
* @access public
* @param mixed $post (default: null)
* @return string
*/
function get_event_registration_end_date( $post = null ) {
$post = get_post( $post );
if ( $post->post_type !== 'event_listing' )
return;
return apply_filters( 'display_event_registration_end_date', $post->_event_registration_deadline, $post );
}
/**
* Display or retrieve the current event registration end date.
*
* @access public
* @param mixed $id (default: null)
* @return void
*/
function display_event_registration_end_date( $before = '', $after = '', $echo = true, $post = null ) {
$event_registration_end_date = get_event_registration_end_date( $post );
if ( strlen( $event_registration_end_date ) == 0 )
return;
$date_format = WP_Event_Manager_Date_Time::get_event_manager_view_date_format();
$event_registration_end_date = date_i18n( $date_format, strtotime( $event_registration_end_date ) );
$event_registration_end_date = $before . $event_registration_end_date . $after;
if ( $echo )
echo $event_registration_end_date;
else
return $event_registration_end_date;
}
/**
* get_the_event_logo function.
*
* @access public
* @param mixed $post (default: null)
* @return string
*/
function get_event_banner( $post = null ) {
$post = get_post( $post );
if ( $post->post_type !== 'event_listing' )
return;
if(isset($post->_event_banner) && empty($post->_event_banner))
$event_banner = apply_filters( 'event_manager_default_event_banner', EVENT_MANAGER_PLUGIN_URL . '/assets/images/wpem-placeholder-wide.jpg' );
else
$event_banner = $post->_event_banner;
return apply_filters( 'display_event_banner', $event_banner, $post );
}
/**
* get_event_thumbnail function.
*
* @access public
* @param mixed $post (default: null)
* @return string
*/
function get_event_thumbnail( $post = null ) {
$post = get_post( $post );
if ( $post->post_type !== 'event_listing' )
return;
$event_thumbnail = get_the_post_thumbnail_url( $post );
if( isset($event_thumbnail) && empty($event_thumbnail) )
$event_thumbnail = apply_filters( 'event_manager_default_event_banner', EVENT_MANAGER_PLUGIN_URL . '/assets/images/wpem-placeholder.jpg' );
return apply_filters( 'display_event_thumbnail', $event_thumbnail, $post );
}
/**
* display_event_banner function.
*
* @access public
* @param string $size (default: 'full')
* @param mixed $default (default: null)
* @return void
*/
function display_event_banner( $size = 'full', $default = null, $post = null ) {
$banner = get_event_banner( $post );
if ( ! empty( $banner ) && ! is_array( $banner ) && ( strstr( $banner, 'http' ) || file_exists( $banner ) ) )
{
if ( $size !== 'full' ) {
$banner = event_manager_get_resized_image( $banner, $size );
}
echo '';
} else if ( $default ) {
echo '
';
} else if(is_array($banner) && isset($banner[0]) ){
echo '
';
}
else {
echo '
';
}
}
/**
* get_event_start_date function.
*
* @access public
* @param int $post (default: null)
* @return string
*/
function get_event_start_date( $post = null ) {
$post = get_post( $post );
if ( $post->post_type !== 'event_listing' ) {
return '';
}
$event_start_date = $post->_event_start_date;
return apply_filters( 'display_event_start_date', $event_start_date, $post );
}
/**
* Display or retrieve the current event start date.
*
* @access public
* @param mixed $id (default: null)
* @return void
*/
function display_event_start_date( $before = '', $after = '', $echo = true, $post = null ) {
$event_start_date = get_event_start_date( $post );
if ( strlen( $event_start_date ) == 0 )
return;
$date_format = WP_Event_Manager_Date_Time::get_event_manager_view_date_format();
$event_start_date = date_i18n( $date_format, strtotime( $event_start_date ) );
$event_start_date = $before . $event_start_date . $after;
if ( $echo )
echo $event_start_date;
else
return $event_start_date;
}
/**
* get_event_start_time function.
*
* @access public
* @param int $post (default: null)
* @return string
*/
function get_event_start_time( $post = null ) {
$post = get_post( $post );
if ( $post->post_type !== 'event_listing' || empty($post->_event_start_time)) {
return '';
}
$event_timezone = get_event_timezone_abbr( $post );
$time_format = WP_Event_Manager_Date_Time::get_timepicker_format();
$event_start_time = date( $time_format ,strtotime($post->_event_start_time) );
if( $event_timezone )
$event_start_time = $event_start_time.' (' . $event_timezone.')';
else
$event_start_time = $event_start_time;
return apply_filters( 'display_event_start_time', $event_start_time , $post );
}
/**
* Display or retrieve the current event start time.
*
* @access public
* @param mixed $id (default: null)
* @return void
*/
function display_event_start_time( $before = '', $after = '', $echo = true, $post = null ) {
$event_start_time = get_event_start_time( $post );
if ( strlen( $event_start_time ) == 0 )
return;
$event_start_time = esc_attr( strip_tags( $event_start_time ) );
$event_start_time = $before . $event_start_time . $after;
if ( $echo )
echo $event_start_time;
else
return $event_start_time;
}
/**
* get_event_end_date function.
*
* @access public
* @param int $post (default: null)
* @return string
*/
function get_event_end_date( $post = null ) {
$post = get_post( $post );
if ( $post->post_type !== 'event_listing' ) {
return '';
}
$event_end_date = $post->_event_end_date;
return apply_filters( 'display_event_end_date', $event_end_date, $post );
}
/**
* Display or retrieve the current event end date.
*
* @access public
* @param mixed $id (default: null)
* @return void
*/
function display_event_end_date( $before = '', $after = '', $echo = true, $post = null ) {
$event_end_date = get_event_end_date( $post );
if ( strlen( $event_end_date ) == 0 )
return;
$event_end_date = esc_attr( strip_tags( $event_end_date ) );
$date_format = WP_Event_Manager_Date_Time::get_event_manager_view_date_format();
$event_end_date = date_i18n( $date_format, strtotime( $event_end_date ) );
$event_end_date = $before . $event_end_date . $after;
if ( $echo )
echo $event_end_date;
else
return $event_end_date;
}
/**
* get_event_end_time function.
*
* @access public
* @param int $post (default: null)
* @return string
*/
function get_event_end_time( $post = null ) {
$post = get_post( $post );
if ( $post->post_type !== 'event_listing' || empty($post->_event_end_time) ) {
return '';
}
$event_timezone = get_event_timezone_abbr( $post );
$time_format = WP_Event_Manager_Date_Time::get_timepicker_format();
$event_end_time = date( $time_format ,strtotime($post->_event_end_time) );
if( $event_timezone )
$event_end_time = $event_end_time.' (' . $event_timezone.')';
else
$event_end_time = $event_end_time;
return apply_filters( 'display_event_end_time', $event_end_time, $post );
}
/**
* Display or retrieve the current event end time.
*
* @access public
* @param mixed $id (default: null)
* @return void
*/
function display_event_end_time( $before = '', $after = '', $echo = true, $post = null ) {
$event_end_time = get_event_end_time( $post );
if ( strlen( $event_end_time ) == 0 )
return;
$event_end_time= esc_attr( strip_tags( $event_end_time ) );
$event_end_time= $before . $event_end_time . $after;
if ( $echo )
echo $event_end_time;
else
return $event_end_time;
}
/**
* get_event_timezone function.
*
* @access public
* @since 3.0
* @param int $post (default: null)
* @return string
*/
function get_event_timezone( $post = null , $abbr = true ) {
$post = get_post( $post );
if ( $post->post_type !== 'event_listing' ) {
return '';
}
if(WP_Event_Manager_Date_Time::get_event_manager_timezone_setting() == 'site_timezone')
return false;
return apply_filters( 'display_event_timezone', $post->_event_timezone, $post );
}
/**
* Display or retrieve the user selected timezone.
*
* @access public
* @param mixed $id (default: null)
* @return void
*/
function display_event_timezone( $before = '', $after = '', $echo = true, $post = null ) {
$event_timezone = get_event_timezone( $post );
if ( strlen( $event_timezone ) == 0 )
return;
$event_timezone= $before . $event_timezone . $after;
if ( $echo )
echo $event_timezone;
else
return $event_timezone;
}
/**
* get_event_timezone function.
*
* @since 3.0
* @access public
* @param int $post (default: null)
* @return string
*/
function get_event_timezone_abbr( $post = null ){
$event_timezone = get_event_timezone($post);
if( $event_timezone )
$event_timezone = WP_Event_Manager_Date_Time::convert_event_timezone_into_abbr( $event_timezone );
return apply_filters( 'display_event_timezone_abbr', $event_timezone, $post );
}
/**
* Display or retrieve the user selected timezone in abbriviation.
*
* @access public
* @param mixed $id (default: null)
* @return void
*/
function display_event_timezone_abbr( $before = '', $after = '', $echo = true, $post = null ) {
$event_timezone = get_event_timezone_abbr( $post );
if ( strlen( $event_timezone ) == 0 )
return;
$event_timezone= $before . $event_timezone . $after;
if ( $echo )
echo $event_timezone;
else
return $event_timezone;
}
/**
* get_event_venue_name function.
*
* @access public
* @param mixed $post (default: null)
* @return void
*/
function get_event_venue_name( $post = null, $link = false ) {
$post = get_post( $post );
/* if ( $post->post_type !== 'event_listing' ) */
if( empty($post) || !in_array($post->post_type, ['event_listing', 'event_venue']) )
return;
if(!empty($post->_event_venue_ids))
{
$venue_name = '';
foreach ($post->_event_venue_ids as $key => $venue_id)
{
if($link)
{
$venue_name .= '';
}
$venue_name .= get_post_meta($venue_id, '_venue_name', true);
if($link)
{
$venue_name .= '';
}
}
return apply_filters( 'display_event_venue_name', $venue_name, $post );
}
if( $post->post_type == 'event_venue' )
return apply_filters( 'display_event_venue_name', $post->_venue_name, $post );
else
return apply_filters( 'display_event_venue_name', $post->_event_venue_name, $post );
}
/**
* Display or retrieve the current event venue name.
*
* @access public
*
* @param mixed $id (default: null)
* @return void
*/
function display_event_venue_name( $before = '', $after = '', $echo = true, $post = null ) {
$event_venue_name = get_event_venue_name( $post );
if ( strlen( $event_venue_name ) == 0 )
return;
$event_venue_name = esc_attr( strip_tags( $event_venue_name ) );
$event_venue_name = $before . $event_venue_name . $after;
if ( $echo )
echo $event_venue_name;
else
return $event_venue_name;
}
/**
* is_event_online function.
*
* @access public
* @param mixed $post (default: null)
* @return void
*/
function is_event_online($post = null ) {
$post = get_post( $post );
if ( $post->post_type !== 'event_listing' )
return;
if(get_event_location($post)=='Online Event' || get_event_location($post) == '' || $post->_event_online =='yes' )
return true;
else
return false;
}
/**
* get_event_address function.
*
* @access public
* @param mixed $post (default: null)
* @return void
*/
function get_event_address( $post = null ) {
$post = get_post( $post );
if ( $post->post_type !== 'event_listing' )
return;
return apply_filters( 'display_event_address', $post->_event_address, $post );
}
/**
* Display or retrieve the current event address.
*
* @access public
*
* @param mixed $id (default: null)
* @return void
*/
function display_event_address( $before = '', $after = '', $echo = true, $post = null ) {
$event_address = get_event_address( $post );
if ( strlen( $event_address ) == 0 )
return;
$event_address = esc_attr( strip_tags( $event_address ) );
$event_address = $before . $event_address . $after;
if ( $echo )
echo $event_address;
else
return $event_address;
}
/**
* get_event_pincode function.
*
* @access public
* @param mixed $post (default: null)
* @return void
*/
function get_event_pincode( $post = null ) {
$post = get_post( $post );
if ( $post->post_type !== 'event_listing' )
return;
return apply_filters( 'display_event_pincode', $post->_event_pincode, $post );
}
/**
* Display or retrieve the current event pincode.
*
* @access public
* @param mixed $id (default: null)
* @return void
*/
function display_event_pincode( $before = '', $after = '', $echo = true, $post = null ) {
$event_pincode = get_event_pincode( $post );
if ( strlen( $event_pincode ) == 0 )
return;
$event_pincode = esc_attr( strip_tags( $event_pincode ) );
$event_pincode = $before . $event_pincode . $after;
if ( $echo )
echo $event_pincode;
else
return $event_pincode;
}
/**
* get_organizer_name function.
*
* @access public
* @param int $post (default: null)
* @return string
*/
function get_organizer_name( $post = null, $link = false ) {
$post = get_post( $post );
/* if ( $post->post_type !== 'event_listing' ) */
if( empty($post) || !in_array($post->post_type, ['event_listing', 'event_organizer']) )
{
return '';
}
if(!empty($post->_event_organizer_ids))
{
$organizer_name = '';
foreach ($post->_event_organizer_ids as $key => $organizer_id) {
if($key > 0)
{
$organizer_name .= ', ';
}
if($link)
{
$organizer_name .= '';
}
$organizer_name .= get_post_meta($organizer_id, '_organizer_name', true);
if($link)
{
$organizer_name .= '';
}
}
return apply_filters( 'display_organizer_name', $organizer_name, $post );
}
return apply_filters( 'display_organizer_name', $post->_organizer_name, $post );
}
/**
* Display or retrieve the current organization or company name who oraganizing events with optional content.
*
* @access public
* @param mixed $id (default: null)
* @return void
*/
function display_organizer_name( $before = '', $after = '', $echo = true, $post = null ) {
$organizer_name = get_organizer_name( $post );
if ( strlen( $organizer_name ) == 0 )
return;
$organizer_name = esc_attr( strip_tags( $organizer_name ) );
$organizer_name = $before . $organizer_name . $after;
if ( $echo )
echo $organizer_name;
else
return $organizer_name;
}
/**
* get_organizer_description_data function.
*
* @access public
* @param int $post (default: null)
* @return string
*/
function get_organizer_description( $post = null ) {
$post = get_post( $post );
/* if ( $post->post_type !== 'event_listing' ) */
if( empty($post) || !in_array($post->post_type, ['event_listing', 'event_organizer']) )
{
return '';
}
return apply_filters( 'display_organizer_description', $post->_organizer_description, $post );
}
/**
* display_organizer_logo function.
*
* @access public
* @param string $size (default: 'full')
* @param mixed $default (default: null)
* @return void
*/
function display_organizer_logo( $size = 'full', $default = null, $post = null ) {
/* $logo = get_organizer_logo( $post = null, $size = 'full' ); */
$logo = get_organizer_logo( $post, $size );
if ( has_post_thumbnail( $post ) ) {
echo '';
// Before 1.0., logo URLs were stored in post meta.
} elseif ( ! empty( $logo ) && ( strstr( $logo, 'http' ) || file_exists( $logo ) ) ) {
if ( $size !== 'full' ) {
$logo = event_manager_get_resized_image( $logo, $size );
}
echo '
';
} elseif ( $default ) {
echo '
';
} else {
echo '
';
}
}
/**
* get_organizer_logo function.
*
* @access public
* @param mixed $post (default: null)
* @return string
*/
function get_organizer_logo( $post = null , $size = 'thumbnail') {
$post = get_post( $post );
/* if ( $post->post_type !== 'event_listing' || $post->post_type !== 'event_organizer' ) */
if( empty($post) || !in_array($post->post_type, ['event_listing', 'event_organizer']) )
return;
if ( has_post_thumbnail( $post->ID ) ) {
$src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), $size );
return $src ? $src[0] : '';
}
elseif ( ! empty( $post->_organizer_logo ) ) {
// Before were stored in post meta.
return apply_filters( 'display_organizer_logo', $post->_organizer_logo, $post );
}
return '';
}
/**
* get_venue_description_data function.
*
* @access public
* @param int $post (default: null)
* @return string
*/
function get_venue_description( $post = null ) {
$post = get_post( $post );
/* if ( $post->post_type !== 'event_listing' ) */
if( empty($post) || !in_array($post->post_type, ['event_listing', 'event_venue']) )
{
return '';
}
return apply_filters( 'display_venue_description', $post->_venue_description, $post );
}
/**
* display_venue_logo function.
*
* @access public
* @param string $size (default: 'full')
* @param mixed $default (default: null)
* @return void
*/
function display_venue_logo( $size = 'full', $default = null, $post = null ) {
/* $logo = get_venue_logo( $post = null, $size = 'full' ); */
$logo = get_venue_logo( $post, $size );
if ( has_post_thumbnail( $post ) ) {
echo '';
// Before 1.0., logo URLs were stored in post meta.
} elseif ( ! empty( $logo ) && ( strstr( $logo, 'http' ) || file_exists( $logo ) ) ) {
if ( $size !== 'full' ) {
$logo = event_manager_get_resized_image( $logo, $size );
}
echo '
';
} elseif ( $default ) {
echo '
';
} else {
echo '
';
}
}
/**
* get_venue_logo function.
*
* @access public
* @param mixed $post (default: null)
* @return string
*/
function get_venue_logo( $post = null , $size = 'thumbnail') {
$post = get_post( $post );
/* if ( $post->post_type !== 'event_listing' || $post->post_type !== 'event_venue' ) */
if( empty($post) || !in_array($post->post_type, ['event_listing', 'event_venue']) )
return;
if ( has_post_thumbnail( $post->ID ) ) {
$src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), $size );
return $src ? $src[0] : '';
}
elseif ( ! empty( $post->_venue_logo ) ) {
// Before were stored in post meta.
return apply_filters( 'display_venue_logo', $post->_venue_logo, $post );
}
return '';
}
/**
* Resize and get url of the image
*
* @param string $logo
* @param string $size
* @return string
*/
function event_manager_get_resized_image( $logo, $size ) {
global $_wp_additional_image_sizes;
if ( $size !== 'full' && strstr( $logo, WP_CONTENT_URL ) && ( isset( $_wp_additional_image_sizes[ $size ] ) || in_array( $size, array( 'thumbnail', 'medium', 'large' ) ) ) ) {
if ( in_array( $size, array( 'thumbnail', 'medium', 'large' ) ) ) {
$img_width = get_option( $size . '_size_w' );
$img_height = get_option( $size . '_size_h' );
$img_crop = get_option( $size . '_size_crop' );
} else {
$img_width = $_wp_additional_image_sizes[ $size ]['width'];
$img_height = $_wp_additional_image_sizes[ $size ]['height'];
$img_crop = $_wp_additional_image_sizes[ $size ]['crop'];
}
$upload_dir = wp_upload_dir();
$logo_path = str_replace( array( $upload_dir['baseurl'], $upload_dir['url'], WP_CONTENT_URL ), array( $upload_dir['basedir'], $upload_dir['path'], WP_CONTENT_DIR ), $logo );
$path_parts = pathinfo( $logo_path );
$dims = $img_width . 'x' . $img_height;
$resized_logo_path = str_replace( '.' . $path_parts['extension'], '-' . $dims . '.' . $path_parts['extension'], $logo_path );
if ( strstr( $resized_logo_path, 'http:' ) || strstr( $resized_logo_path, 'https:' ) ) {
return $logo;
}
if ( ! file_exists( $resized_logo_path ) ) {
ob_start();
$image = wp_get_image_editor( $logo_path );
if ( ! is_wp_error( $image ) ) {
$resize = $image->resize( $img_width, $img_height, $img_crop );
if ( ! is_wp_error( $resize ) ) {
$save = $image->save( $resized_logo_path );
if ( ! is_wp_error( $save ) ) {
$logo = dirname( $logo ) . '/' . basename( $resized_logo_path );
}
}
}
ob_get_clean();
} else {
$logo = dirname( $logo ) . '/' . basename( $resized_logo_path );
}
}
return $logo;
}
/**
* get_event_organizer_contact_person_name function.
*
* @access public
* @param mixed $post (default: null)
* @return string
*/
function get_event_organizer_contact_person_name( $post = null ) {
$post = get_post( $post );
if ( $post->post_type !== 'event_listing' )
return;
return apply_filters( 'display_organizer_contact_person_name', $post->_organizer_contact_person_name, $post );
}
/**
* Display or retrieve the current organization's contact person name with optional content.
*
* @access public
* @param mixed $id (default: null)
* @return void
*/
function display_organizer_contact_person_name( $before = '', $after = '', $echo = true, $post = null ) {
$organizer_contact_person_name = get_event_organizer_contact_person_name( $post );
if ( strlen( $organizer_contact_person_name ) == 0 )
return;
$organizer_contact_person_name = esc_attr( strip_tags( $organizer_contact_person_name ) );
$organizer_contact_person_name = $before . $organizer_contact_person_name . $after;
if ( $echo )
echo $organizer_contact_person_name;
else
return $organizer_contact_person_name;
}
/**
* get_event_organizer_email function.
*
* @access public
* @param mixed $post (default: null)
* @return string
*/
function get_event_organizer_email( $post = null ) {
$post = get_post( $post );
if ( $post->post_type !== 'event_listing' )
return;
if(!empty($post->_event_organizer_ids))
{
$organizers_email = '';
foreach ($post->_event_organizer_ids as $key => $organizer_id) {
if($key > 0)
{
$organizers_email .= ', ';
}
$organizers_email .= get_post_meta($organizer_id, '_organizer_email', true);
}
return apply_filters( 'display_organizer_email', $organizers_email, $post );
}
return apply_filters( 'display_organizer_email', $post->_organizer_email, $post );
}
/**
* Display or retrieve the current organizer email with optional content.
*
* @access public
* @param mixed $id (default: null)
* @return void
*/
function display_organizer_email( $before = '', $after = '', $echo = true, $post = null ) {
$organizer_email = get_event_organizer_email( $post );
if ( strlen( $organizer_email ) == 0 )
return;
$organizer_email = esc_attr( strip_tags( $organizer_email ) );
$organizer_email = $before . $organizer_email . $after;
if ( $echo )
echo $organizer_email;
else
return $organizer_email;
}
/**
* Get the organizer video URL
*
* @param mixed $post (default: null)
* @return string
*/
function get_organizer_video( $post = null ) {
$post = get_post( $post );
if ( $post->post_type !== 'event_listing' )
{
return;
}
return apply_filters( 'display_organizer_video', $post->_organizer_video, $post );
}
/**
* Output the organizer video
*/
function display_organizer_video( $before = '', $after = '', $echo = true, $post = null) {
$video_embed = false;
$video = get_organizer_video( $post );
$filetype = wp_check_filetype( $video );
if( ! empty( $video ) )
{
// FV Wordpress Flowplayer Support for advanced video formats
if ( shortcode_exists( 'flowplayer' ) ) {
$video_embed = '[flowplayer src="' . esc_attr( $video ) . '"]';
} elseif ( ! empty( $filetype[ 'ext' ] ) ) {
$video_embed = wp_video_shortcode( array( 'src' => $video ) );
} else {
$video_embed = wp_oembed_get( $video );
}
}
$video_embed = apply_filters( 'display_organizer_video_embed', $video_embed, $post );
if ( $video_embed ) {
echo '