function wm_shortcode_staff( $atts, $content = null ) { extract( shortcode_atts( array( 'align' => 'left', 'columns' => 4, 'count' => 4, 'department' => null, 'desc_size' => 4, 'order' => 'new', 'thumb' => true, ), $atts ) ); if ( 'disable' === wm_option( 'cp-role-staff' ) ) return; $out = ''; $imgSize = ( wm_option( 'general-staff-image-ratio' ) ) ? ( 'mobile-' . wm_option( 'general-staff-image-ratio' ) ) : ( 'mobile-ratio-169' ); //validation $align = ( 'right' === trim( $align ) ) ? ( trim( $align ) ) : ( 'left' ); $cols = ( 0 < absint( $columns ) && 7 > absint( $columns ) ) ? ( absint( $columns ) ) : ( 4 ); $colsDesc = ( 1 < absint( $desc_size ) && 7 > absint( $desc_size ) ) ? ( absint( $desc_size ) ) : ( 4 ); $count = ( $count ) ? ( absint( $count ) ) : ( 4 ); $orderMethod = array( 'all' => array( 'new', 'old', 'name', 'random' ), 'new' => array( 'date', 'DESC' ), 'old' => array( 'date', 'ASC' ), 'name' => array( 'title', 'ASC' ), 'random' => array( 'rand', '' ) ); $order = ( in_array( trim( $order ), $orderMethod['all'] ) ) ? ( $orderMethod[trim( $order )] ) : ( $orderMethod['new'] ); $thumb = ( $thumb ) ? ( ' has-thumbs' ) : ( false ); if ( $department ) if ( is_numeric( $department ) ) { $department = absint( $department ); } else { $department = get_term_by( 'slug', sanitize_title( $department ), 'department' ); $department = ( $department && isset( $department->term_id ) ) ? ( $department->term_id ) : ( null ); } else $department = null; //get the staff wp_reset_query(); $queryArgs = array( 'post_type' => 'wm_staff', 'posts_per_page' => $count, 'ignore_sticky_posts' => 1, 'orderby' => $order[0], 'order' => $order[1] ); if ( 0 < $department ) $queryArgs['tax_query'] = array( array( 'taxonomy' => 'department', 'field' => 'id', 'terms' => explode( ',', $department ) ) ); $staff = new WP_Query( $queryArgs ); if ( $staff->have_posts() ) { $i = $row = 0; $out .= '<div class="wrap-staff-shortcode clearfix apply-top-margin' . $thumb . '">'; if ( $content ) { //if description (shortcode content) $out .= ( 'right' === $align ) ? ( '<div class="column col-' . ( $colsDesc - 1 ) . $colsDesc . '"><div class="wrap-staff"><div class="row">' ) : ( '<div class="column col-1' . $colsDesc . ' wrap-description">' . do_shortcode( $content ) . '</div><div class="column col-' . ( $colsDesc - 1 ) . $colsDesc . ' last"><div class="wrap-staff"><div class="row">' ); //if description on the right - open staff container and inner container only ELSE output content column and open staff container } else { //if no description (no shortcode content) $out .= '<div class="wrap-staff"><div class="row">'; } while ( $staff->have_posts() ) : //output post content $staff->the_post(); if ( wm_option( 'cp-staff-rich' ) ) $excerptText = ( has_excerpt() ) ? ( apply_filters( 'wm_default_content_filters', get_the_excerpt() ) ) : ( '' ); else $excerptText = apply_filters( 'wm_default_content_filters', get_the_content() ); $contacts = ''; if ( wm_meta_option( 'staff-phone' ) ) $contacts .= '<li class="staff-phone">' . wm_meta_option( 'staff-phone' ) . '</li>'; if ( wm_meta_option( 'staff-email' ) ) $contacts .= '<li class="staff-email"><a href="#" data-address="' . wm_nospam( wm_meta_option( 'staff-email' ) ) . '" class="email-nospam">' . wm_nospam( wm_meta_option( 'staff-email' ) ) . '</a></li>'; if ( wm_meta_option( 'staff-linkedin' ) ) $contacts .= '<li class="staff-linkedin"><a href="' . esc_url( wm_meta_option( 'staff-linkedin' ) ) . '" target="_blank">' . get_the_title() . '</a></li>'; if ( wm_meta_option( 'staff-skype' ) ) $contacts .= '<li class="staff-skype"><a href="skype:' . sanitize_title( wm_meta_option( 'staff-skype' ) ) . '?call">' . wm_meta_option( 'staff-skype' ) . '</a></li>'; if ( is_array( wm_meta_option( 'staff-custom-contacts' ) ) ) { foreach ( wm_meta_option( 'staff-custom-contacts' ) as $contact ) { $contacts .= '<li class="' . $contact['attr'] . '">' . strip_tags( trim( $contact['val'] ), '<a><img><strong><span><small><em><b><i>' ) . '</li>'; } } $excerptText .= ( $contacts ) ? ( '<ul>' . $contacts . '</ul>' ) : ( '' ); $staffOutput = array( 'thumb' => wm_thumb( array( 'class' => 'staff-thumb', 'size' => $imgSize, 'list' => true, 'link' => 'modal', 'placeholder' => true, 'overlay' => __( 'Zoom', 'lespaul_domain' ), ) ), 'thumb-permalink' => wm_thumb( array( 'class' => 'staff-thumb', 'size' => $imgSize, 'list' => true, 'placeholder' => true, 'overlay' => __( 'Read more', 'lespaul_domain' ), ) ), 'title' => '<h3 class="staff-title text-element"><strong>' . get_the_title() . '</strong></h3>', 'title-link' => '<h3 class="staff-title text-element"><a href="' . get_permalink() . '"><strong>' . get_the_title() . '</strong></a></h3>', 'position' => '<p class="staff-position text-element">' . wm_meta_option( 'staff-position' ) . '</p>', 'excerpt' => $excerptText ); $row = ( ++$i % $cols === 1 ) ? ( $row + 1 ) : ( $row ); $out .= ( $i % $cols === 1 && 1 < $row ) ? ( '</div><div class="row">' ) : ( '' ); $out .= '<article class="column col-1' . $cols . ' no-margin">'; if ( $thumb ) $out .= ( wm_option( 'cp-staff-rich' ) && ! wm_meta_option( 'staff-no-rich' ) ) ? ( $staffOutput['thumb-permalink'] ) : ( $staffOutput['thumb'] ); $out .= '<div class="text">'; $out .= ( wm_option( 'cp-staff-rich' ) && ! wm_meta_option( 'staff-no-rich' ) ) ? ( $staffOutput['title-link'] ) : ( $staffOutput['title'] ); $out .= $staffOutput['position']; $out .= '<div class="staff-excerpt text-element">' . $staffOutput['excerpt'] . '</div>'; $out .= '</div>'; $out .= '</article>'; endwhile; if ( $content ) { //if description (shortcode content) $out .= ( 'right' === $align ) ? ( '</div></div></div><div class="column col-1' . $colsDesc . ' last wrap-description">' . do_shortcode( $content ) . '</div>' ) : ( '</div></div></div>' ); //if description on the right - close staff container and its inner container and output content column ELSE just close staff container and its inner container } else { //if no description (no shortcode content) $out .= '</div></div>'; } $out .= '</div>'; } wp_reset_query(); return $out; }
function widget( $args, $instance ) { extract( $args ); extract( $instance ); $out = $outAddress = ''; //if the title is not filled, no title will be displayed if ( isset( $title ) && '' != $title && ' ' != $title ) $out .= $before_title . apply_filters( 'widget_title', $title ) . $after_title; //HTML to display output //address if ( ( isset( $name ) && $name ) || ( isset( $address ) && $address ) ) $outAddress .= '<div class="address contact-info"><strong>' . $name . '</strong><br />' . $address . '</div>'; //hours if ( isset( $hours ) && $hours ) { if ( false === strpos( $hours, ',' ) ) $hours .= '−,0:00 − 0:00'; $hours = trim( $hours ); $hours = str_replace( array( "\r\n", "\r", "\n" ), '</td></tr><tr><td>', $hours ); $hours = str_replace( array( ',', ', ' ), '</td><td>', $hours ); $hours = str_replace( '-', '−', $hours ); $hours = '<table><tr><td>' . $hours . '</td></tr></table>'; $outAddress .= '<div class="hours contact-info">' . $hours . '</div>'; } //phone numbers if ( isset( $phone ) && $phone ) $outAddress .= '<div class="phone contact-info">' . $phone . '</div>'; //email addresses if ( isset( $email ) && $email ) { $regex = '/(\S+@\S+\.\S+)/i'; preg_match_all( $regex, $email, $emailArray ); if ( $emailArray && is_array( $emailArray ) ) { foreach ( $emailArray[0] as $e ) { $email = str_replace( $e, '<a href="#" data-address="' . wm_nospam( $e ) . '" class="email-nospam">' . wm_nospam( $e ) . '</a>', $email ); } } $outAddress .= '<div class="email contact-info">' . $email . '</div>'; } //output wrapper if ( $outAddress ) $out .= '<div class="address-container">' . apply_filters( 'wm_default_content_filters', $outAddress ) . '</div>'; if ( $out ) echo $before_widget . $out . $after_widget; } // /widget
} $terms = $outTerms; } else { $terms = false; } $out = '<li class="staff-name" title="' . __( 'Name', 'lespaul_domain_adm' ) . '"><strong>' . get_the_title() . '</strong>'; if ( wm_meta_option( 'staff-position' ) ) $out .= '<br /><span class="staff-position">' . wm_meta_option( 'staff-position' ) . '</span>'; if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) $out .= '<br /><span class="staff-department">' . $terms . '</span>'; $out .= '</li>'; if ( wm_meta_option( 'staff-phone' ) ) $out .= '<li class="staff-phone" title="' . __( 'Phone', 'lespaul_domain_adm' ) . '"><strong>' . __( 'Phone', 'lespaul_domain_adm' ) . ': </strong>' . wm_meta_option( 'staff-phone' ) . '</li>'; if ( wm_meta_option( 'staff-email' ) ) $out .= '<li class="staff-email" title="' . __( 'Email', 'lespaul_domain_adm' ) . '"><strong>' . __( 'Email', 'lespaul_domain_adm' ) . ': </strong><a href="#" data-address="' . wm_nospam( wm_meta_option( 'staff-email' ) ) . '" class="email-nospam">' . wm_nospam( wm_meta_option( 'staff-email' ) ) . '</a></li>'; if ( wm_meta_option( 'staff-linkedin' ) ) $out .= '<li class="staff-linkedin" title="' . __( 'LinkedIn', 'lespaul_domain_adm' ) . '"><strong>' . __( 'LinkedIn', 'lespaul_domain_adm' ) . ': </strong><a href="' . esc_url( wm_meta_option( 'staff-linkedin' ) ) . '" target="_blank">' . get_the_title() . '</a></li>'; if ( wm_meta_option( 'staff-skype' ) ) $out .= '<li class="staff-skype" title="' . __( 'Skype', 'lespaul_domain_adm' ) . '"><strong>' . __( 'Skype', 'lespaul_domain_adm' ) . ': </strong><a href="skype:' . sanitize_title( wm_meta_option( 'staff-skype' ) ) . '?call">' . wm_meta_option( 'staff-skype' ) . '</a></li>'; if ( is_array( wm_meta_option( 'staff-custom-contacts' ) ) ) { foreach ( wm_meta_option( 'staff-custom-contacts' ) as $contact ) { $out .= '<li class="' . $contact['attr'] . '">' . strip_tags( trim( $contact['val'] ), '<a><img><strong><span><small><em><b><i>' ) . '</li>'; } } if ( $out ) echo '<div class="staff-card alignleft">' . wm_thumb( array( 'size' => 'mobile' ) ) . '<ul>' . $out . '</ul></div>'; ?> <?php