* use them sparingly - WITH ESCAPING - in the markup * */ // Fetch the post ID for the currently set up post - we're in the loop $post_id = get_the_ID(); // Some custom fields $location = get_post_meta(absint($post_id), 'location', true); $department = get_post_meta(absint($post_id), 'department', true); $programlink = get_post_meta(absint($post_id), 'programlink', true); $applylink = get_post_meta(absint($post_id), 'applylink', true); // How to get the post thumbnail $post_thumbnail = wp_get_attachment_url(get_post_thumbnail_id(absint($post_id))); // Replacement for [plain_tags_slug] $plain_tags_slug = \UBC\Helpers::get_plain_tags(absint($post_id), 'slug', ' '); // Replacement for [plain_term_slug] $plain_term_slug = \UBC\Helpers::get_plain_terms(absint($post_id), 'slug', ' '); // Replacement for [odd-even] but *really* this should be done in CSS. global $usage_id; $usage_id++; $odd_even = 0 === $usage_id % 2 ? 'even' : 'odd'; ?> <div id="<?php echo absint($post_id); ?> " class="<?php echo esc_attr($plain_tags_slug); ?> "> <div class="boxey <?php
<?php //** //* A template for LLED Profiles. http://lled.educ.ubc.ca/faculty-and-staff/faculty/ // Fetch the post ID for the currently set up post - we're in the loop $post_id = get_the_ID(); // How to get the post thumbnail $post_thumbnail = wp_get_attachment_url(get_post_thumbnail_id(absint($post_id))); // Replacement for [plain_tags_slug] $plain_tags_slug = \UBC\Helpers::get_plain_tags(absint($post_id), 'slug', ' '); // Replacement for [plain_term_slug] $plain_term_slug = \UBC\Helpers::get_plain_terms(absint($post_id), 'slug', ' '); // To get Taxonomies as names $plain_term_name = \UBC\Helpers::get_plain_terms(absint($post_id), 'name', ' '); // Replacement for [odd-even] but *really* this should be done in CSS. global $usage_id; $usage_id++; $odd_even = 0 === $usage_id % 2 ? 'even' : 'odd'; //Get the Profile Fields $profile_cct = get_post_meta($post_id, 'profile_cct', true); $salutations = isset($profile_cct['name']['salutations']) ? $profile_cct['name']['salutations'] : false; $first_name = isset($profile_cct['name']['first']) ? $profile_cct['name']['first'] : false; $middle_name = isset($profile_cct['name']['middle']) ? $profile_cct['name']['middle'] : false; $last_name = isset($profile_cct['name']['last']) ? $profile_cct['name']['last'] : false; $position = isset($profile_cct['position']['0']['position']) ? $profile_cct['position']['0']['position'] : false; $clone_room_number = isset($profile_cct['clone_room_number']['0']['position']) ? $profile_cct['clone_room_number']['0']['position'] : false; $phone1 = isset($profile_cct['phone']['0']['tel-1']) ? $profile_cct['phone']['0']['tel-1'] : false; $phone2 = isset($profile_cct['phone']['0']['tel-2']) ? $profile_cct['phone']['0']['tel-2'] : false; $phone3 = isset($profile_cct['phone']['0']['tel-3']) ? $profile_cct['phone']['0']['tel-3'] : false; $email = isset($profile_cct['email']['0']['email']) ? $profile_cct['email']['0']['email'] : false; $bio = isset($profile_cct['bio']['textarea']) ? $profile_cct['bio']['textarea'] : false;
/** * Logic for the ubc_template shortcode. Looks for a specific template file * that is requested in the shortcode atts, if it exists, fetches it. * * @since 1.0.0 * * @param (array) $attr - Attributes passed to the shortcode * @return (string) markup for this shortcode */ public function add_shortcode__ubc_template($attr) { $attr = shortcode_atts(array('department' => '', 'template' => ''), $attr, 'ubc_template'); // Need both, bail early if not set if (empty($attr['department']) || empty($attr['template'])) { return __('ubc_template shortcode requires both a department and template', $this->get_text_domain()); } // The root URL $path = self::$plugin_path . 'templates/'; $department = sanitize_title_with_dashes($attr['department']); $template = sanitize_title_with_dashes($attr['template']); // Form the full path and then check if that template exists $path .= trailingslashit($department) . $template . '.php'; $path = apply_filters('ubc_use_template_path', $path, $department, $template); if (!file_exists($path)) { return __('Specified template file does not exist', $this->get_text_domain()); } $data = apply_filters('ubc_use_template_data', array(), $department, $template); // This allows us to use odd/even counts in templates global $usage_id; if (!isset($usage_id)) { $usage_id = 0; } // Fetch the content of this template $content = \UBC\Helpers::fetch_template_part($path, $data); // Run it through a filter so we can modify outside should someone wish to add $content = apply_filters('ubc_use_template_content', $content, $data, $department, $template); do_action('ubc_use_template_end', $content, $data, $department, $template); return wp_kses_post($content); }
$coursecodeundergrad = get_post_meta($post_id, 'CourseCodeUndergrad', true); $coursecodegrad = get_post_meta($post_id, 'CourseCodeGrad', true); $vanityurl = get_post_meta($post_id, 'VanityUrl', true); $credit = get_post_meta($post_id, 'Credit', true); $promophoto = get_post_meta($post_id, 'PromoPhoto', true); $subtitle = get_post_meta($post_id, 'Subtitle', true); $dates = get_post_meta($post_id, 'Dates', true); $location = get_post_meta($post_id, 'Location', true); $deliverymode = get_post_meta($post_id, 'DeliveryMode', true); $programtype = get_post_meta($post_id, 'ProgramType', true); // How to get the post thumbnail $post_thumbnail = wp_get_attachment_url(get_post_thumbnail_id($post_id)); // Replacement for [plain_tags_slug] $plain_tags_slug = \UBC\Helpers::get_plain_tags($post_id, 'slug', ' '); // Replacement for [plain_term_slug] $plain_term_slug = \UBC\Helpers::get_plain_terms($post_id, 'slug', ' '); // Replacement for [odd-even] but *really* this should be done in CSS. global $usage_id; $usage_id++; $odd_even = 0 === $usage_id % 2 ? 'even' : 'odd'; //change the icon based on the delivery mode $icon = ""; switch ($deliverymode) { case "Face-to-Face": $icon = 'icon-group'; break; case "Online": $icon = 'icon-laptop'; break; case "Mixed Mode": $icon = 'icon-road';
/** * Logic for the ubc_template shortcode. Looks for a specific template file * that is requested in the shortcode atts, if it exists, fetches it. * * @since 1.0.0 * * @param (array) $attr - Attributes passed to the shortcode * @return (string) markup for this shortcode */ public function add_shortcode__ubc_template($attr) { $attr = shortcode_atts(array('department' => '', 'template' => ''), $attr, 'ubc_template'); // Need both, bail early if not set if (empty($attr['department']) || empty($attr['template'])) { return esc_html__('ubc_template shortcode requires both a department and template', $this->get_text_domain()); } $department = sanitize_title_with_dashes($attr['department']); $template = sanitize_title_with_dashes($attr['template']); $path = $this->generate_path($department, $template); if (!file_exists($path)) { return esc_html__('Specified template file does not exist', $this->get_text_domain()); } $data = apply_filters('ubc_use_template_data', array(), $department, $template); // This allows us to use odd/even counts in templates global $usage_id; $usage_id = !isset($usage_id) ? 0 : $usage_id; // Fetch the content of this template $content = \UBC\Helpers::fetch_template_part($path, $data); // Run it through a filter so we can modify outside should someone wish to add $content = apply_filters('ubc_use_template_content', $content, $data, $department, $template); do_action('ubc_use_template_end', $content, $data, $department, $template); return wp_kses_post($content); }