Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
shortcode-fuelcell-faculty-profiles/site-shortcode.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
123 lines (84 sloc)
3.14 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!function_exists('display_research_fac_sc')) { | |
add_shortcode('display_research_fac', 'display_research_fac_sc'); | |
function display_research_fac_sc ($atts) { | |
$defaults = array(); | |
$info = array(); | |
$m_argv = array(); | |
$m_query = null; | |
$no_content = "<p>No Profiles Are Available</p>"; | |
$content = ""; | |
$m_cats = null; | |
$fac_terms = array(); | |
$fac_terms_nice = array(); | |
$defaults = array('post_type' => 'facultyprofile', 'taxonomy' => 'profilecategory', 'category' => 'group-1'); | |
$info = shortcode_atts($defaults, $atts); | |
$m_argv = array('post_type' => $info['post_type'], | |
'orderby' => 'meta_value', | |
'meta_key' => 'lastname', | |
'order' => 'ASC', | |
'tax_query' => array( | |
array('taxonomy' => $info['taxonomy'], | |
'field' => 'slug', | |
'terms' => $info['category']) | |
) | |
); | |
$m_query = new WP_Query($m_argv); | |
if($m_query->have_posts()){ | |
$content .= "<ul class = \"small-block-grid-1 medium-block-grid-2 large-block-grid-3\">\n"; | |
while($m_query->have_posts()){ | |
$m_query->the_post(); | |
$post_id = get_the_ID(); | |
$fac_terms = get_the_terms($post_id, $info['taxonomy']); | |
$res_areas = array(); | |
$m_cats = ""; | |
$m_css_dots = array(); | |
$j = 0; | |
for($i = 0; $i < count($fac_terms); $i++) { | |
if(preg_match('/-res-area/', $fac_terms[$i]->slug)) { | |
$m_cats .= $fac_terms[$i]->slug . " "; | |
$res_areas[$j] = $fac_terms[$i]->name; | |
$m_css_dots[$j] = $fac_terms[$i]->slug . "-bg"; | |
$j++; | |
} | |
} | |
$res_areas = implode(", ", $res_areas); | |
$content .= "<li>\n | |
<p><a data-reveal-id = \"faculty-id-$post_id\" class = \"faculty-links $m_cats\" href = \"#\"><img class = \"gray-default\" data-id = \"$post_id\" src = \"" . get_field('photo') . "\" /></a></p>"; | |
$content .= "<p>\n"; | |
for($i = 0; $i < count($m_css_dots); $i++) { | |
$content .= "<span class = \"" . $m_css_dots[$i] . " active\"> </span> "; | |
} | |
$content .= "</p>\n"; | |
$content .= "<!-- start of modal profile --> | |
<div id = \"faculty-id-$post_id\" class=\"reveal-modal\" data-reveal aria-labelledby=\"modalTitle\" aria-hidden=\"true\" role=\"dialog\"> | |
<h3>" . get_the_title() ."</h3> | |
<div> | |
<div class = \"left columns large-4\"> | |
<p><img src = \"" . get_field("photo") . "\" alt = \"\" /></p> | |
<p><a href = \"" . get_field("website") . "\" class = \"button radius medium\" target = \"_faculty_web\">Website</a></p> | |
</div> | |
<div class = \"right columns large-8\"> | |
<p><strong>Department: </strong> " . get_field("department") . "</p> | |
<p><strong>Title: </strong> " . get_field("title") . "</p> | |
<p><strong>Research Areas</strong> $res_areas</p> | |
<p><b>Brief Description</b></p> | |
" . get_field("facultydescription") . "</div> | |
</div> | |
<a class=\"close-reveal-modal\" aria-label=\"Close\">×</a> | |
</div> | |
<!-- end of modal profile -->\n"; | |
$content .= "</li>\n"; | |
} | |
$content .= "</ul>\n"; | |
} else { | |
$content = $no_content = "<p>No Profiles Are Available</p>"; | |
} | |
wp_reset_postdata(); | |
return $content; | |
} | |
function appendString($m_data, $content) { | |
$content .= $m_data; | |
return $content; | |
} | |
} // end if -- end of detection |