/** * Lists the current program's degrees. * * @since 0.3.0 */ function jc_program_list_degrees() { $degree_IDs = rbm_get_field('degrees'); $degrees = get_posts(array('post_type' => 'jcaca-degree', 'numberposts' => -1, 'post__in' => $degree_IDs, 'order' => 'ASC', 'orderby' => 'menu_order')); if ($degrees) { ?> <ul class="program-degree-list-items"> <?php foreach ($degrees as $degree) { ?> <?php if ($pdf = rbm_get_field('pdf', $degree->ID)) { $url = wp_get_attachment_url($pdf); } else { $url = get_permalink($degree->ID); } ?> <li> <a href="<?php echo $url; ?> "> <?php echo get_the_title($degree->ID); ?> </a> </li> <?php } ?> </ul> <?php } }
function jc_get_alert($post_ID) { if (get_post_status($post_ID) !== 'publish') { return false; } $post = get_post($post_ID); $alert = new JC_Alert(array('ID' => $post_ID, 'content' => $post->post_content, 'image' => rbm_get_field('popup_image', $post_ID), 'type' => rbm_get_field('type', $post_ID), 'display' => array('style' => rbm_get_field('style', $post_ID)), 'interaction' => array('method' => rbm_get_field('user_interaction', $post_ID), 'button_text' => rbm_get_field('button_text', $post_ID), 'button_link' => rbm_get_field('button_link', $post_ID)))); return $alert; }
function _admin_columns_output($column) { switch ($column) { case 'pdf_override': if (rbm_get_field('pdf')) { echo '<span class="jcaca-degree-visibility-icon dashicons dashicons-hidden" title="PDF Overriding Degree"></span>'; } else { echo '<span class="jcaca-degree-visibility-icon dashicons dashicons-visibility" title="Degree Visible"></span>'; } break; } }
/** * Grabs the grid items from the current post's meta and uses them. * * @since 0.3.0 * @access private * * @param array $grid_items The grid items. * * @return array The grid items. */ function jc_content_grid_page_template_items($grid_items) { if ($meta_grid_items = rbm_get_field('content_grid')) { foreach ($meta_grid_items as $i => $item) { if (!$item['link'] || empty($item['link'])) { continue; } $meta_grid_items[$i]['link'] = get_permalink($item['link']); } return $meta_grid_items; } return $grid_items; }
/** * Modifies the current post object for the breadcrumbs. * * @since 0.3.0 * @access private */ function jc_page_program_breadcrumbs_before() { global $post; if (get_post_type() != 'page') { return; } $program = rbm_get_field('program_link'); if (empty($program)) { return; } $post = get_post($program); setup_postdata($post); }
/** * Returns all courses prefixed with their codes. * * @since {{VERSION}} * * @return array|false The list of courses or false if none exist. */ function jcaca_get_courses_list() { $courses = get_posts(array('post_type' => 'jcaca-course', 'numberposts' => -1)); if (!$courses) { return false; } $courses = wp_list_pluck($courses, 'post_title', 'ID'); // Prefix course code foreach ($courses as $ID => $name) { $course_code = rbm_get_field('course_code', $ID); $courses[$ID] = $course_code ? "{$course_code}: {$name}" : $name; } return $courses; }
function jc_mb_post_publish_box() { echo '<div class="misc-pub-section">'; echo 'Show on Home Page: '; switch ($hidden = rbm_get_field('hidden_on_home')) { case false: case '0': echo '<span class="dashicons dashicons-visibility"></span>'; break; case '1': echo '<span class="dashicons dashicons-hidden"></span>'; break; } rbm_do_field_select('hidden_on_home', false, $hidden, array('options' => array('0' => 'Show', '1' => 'Hide'))); echo '</div>'; }
/** * Test retrieval of a field. * * @since 1.1.0 */ function test_get_field() { // Test against global post $test_field = rbm_get_field('test_field'); $this->assertEquals('1', $test_field); // Test with manual post ID $test_field = rbm_get_field('test_field', $this->test_post_ID); $this->assertEquals('1', $test_field); // Test direct echoing // Test against global post ob_start(); rbm_field('test_field'); $test_field = ob_get_clean(); $this->assertEquals('1', $test_field); // Test with manual post ID ob_start(); rbm_field('test_field', $this->test_post_ID); $test_field = ob_get_clean(); $this->assertEquals('1', $test_field); }
/** * Returns the pathway archive content grid items. * * @since 0.3.0 * @access private */ function jc_archive_content_grid_items_pathways() { global $post; $pathways = get_posts(array('post_type' => 'jcaca-pathway', 'numberposts' => -1)); if (!$pathways) { return array(); } $grid_items = array(); foreach ($pathways as $post) { setup_postdata($post); if (!($image = rbm_get_field('archive_image')) && has_post_thumbnail()) { $image = get_post_thumbnail_id(); } elseif (!$image) { $image = ''; } $grid_items[] = array('text' => get_the_title(), 'icon' => rbm_get_field('archive_icon'), 'image' => $image, 'color' => rbm_get_field('archive_color'), 'link' => get_permalink()); } wp_reset_postdata(); return $grid_items; }
function _jc_post_admin_columns_output($column) { global $current_screen; if ($current_screen->id !== 'edit-post') { return; } if ($column == 'featured') { switch (rbm_get_field('featured')) { case false: case 'not_featured': echo '<span class="dashicons dashicons-star-empty"></span>'; break; case 'primary_featured': echo '<span class="dashicons dashicons-star-filled"></span>'; break; case 'sub_featured': echo '<span class="dashicons dashicons-star-half"></span>'; break; } } }
/** * Program Courses shortcode. * * @since 1.3.0 * * @param array $atts The shortcode attributes. * * @return string The HTML of the shortcode. */ function jc_sc_program_courses($atts = array()) { global $jc_courses; $atts = shortcode_atts(array('program' => false, 'include' => false, 'exclude' => false), $atts); $courses = array(); if ($program = get_post($atts['program'])) { if ($program_courses = rbm_get_field('courses', $program->ID)) { $courses = $program_courses; } } if ($atts['include']) { $courses = array_merge($courses, explode(',', $atts['include'])); } if ($atts['exclude']) { $courses = array_diff($courses, explode(',', $atts['exclude'])); } $jc_courses = $courses; ob_start(); jc_load_template('partials', 'course-table'); return ob_get_clean(); }
function delete_degree_post_meta($post_ID) { if ($degrees = rbm_get_field('degrees', $post_ID)) { foreach ($degrees as $degree_ID) { delete_post_meta($degree_ID, 'program_parent'); } } if ($program_parent = rbm_get_field($post_ID, 'program_parent', true)) { $degrees = rbm_get_field('degrees', $program_parent); $degrees = array_diff($degrees, array($post_ID)); update_post_meta($program_parent, '_rbm_degrees', $degrees); } }
data-equalizer-watch> <?php jc_breadcrumbs(); ?> <h2 class="page-title"><?php the_title(); ?> </h2> <?php jc_the_content(); ?> <?php if ($semesters = rbm_get_field('semesters')) { ?> <p class="degree-print-button text-right"> <a href="javascript:window.print()" class="button"> Printable Degree Map </a> </p> <div class="semesters"> <!-- <div class="course-legend">--> <!-- <div>Course Type:</div>--> <!-- <div>--> <!-- <span class="course-type-indicator general_education"></span>--> <!-- = General Education--> <!-- </div>-->
* * Displays a loop of spotlights. * * @since 1.3.0 * * @package JacksonCollege * @subpackage JacksonCollege/views/loops */ defined('ABSPATH') || die; if (have_posts()) { ?> <ul class="small-block-grid-1 medium-block-grid-2 large-block-grid-3"> <?php while (have_posts()) { the_post(); if (!($images = rbm_get_field('images'))) { continue; } $img_src = wp_get_attachment_image_src(array_shift($images)['image'], 'full'); ?> <li> <article <?php post_class(array('spotlight-item')); ?> style="background-image: url('<?php echo $img_src[0]; ?> ');"> <h1 class="spotlight-title"> <a href="<?php the_permalink();
the_permalink(); ?> "> <?php the_post_thumbnail('full'); ?> </a> </div> <?php } ?> <div class="location-meta columns small-12 medium-8"> <div class="location-meta-address"> <?php echo wpautop(rbm_get_field('address')); ?> </div> <p class="location-meta-phone"> <?php rbm_field('phone'); ?> </p> </div> </div> </li> <?php } ?> </ul>
/** * Retrieves and echos a rbm post field value from the DB. * * @since 1.2.0 * * @param string $field The fieldname to get. * @param bool|false $post_ID Supply post ID to get field from different post. * * @return bool|mixed Post meta or false if can't get post. */ function rbm_field($field, $post_ID = false) { echo rbm_get_field($field, $post_ID); }
<?php /** * View: Landing Grid * * Allows a repeater field to create content boxes (links). * * @since 1.3.0 * * @package JacksonCollege * @subpackage JacksonCollege/views */ if ($grid_items = rbm_get_field('landing_grid')) { ?> <?php $columns = rbm_get_field('columns'); ?> <ul class="landing-grid small-block-grid-1 medium-block-grid-2 large-block-grid-<?php echo $columns ? $columns : 3; ?> "> <?php foreach ($grid_items as $item) { ?> <?php // Defaults $item['title'] = $item['title'] ? $item['title'] : 'Title Text'; $item['text'] = $item['text'] ? $item['text'] : 'Body Text'; $item['color'] = $item['color'] ? $item['color'] : '#fff'; if (!($background_image = wp_get_attachment_image_src($item['image'], 'content-grid'))) { $background_image = '';
?> <?php if ($phone = rbm_get_field('phone')) { ?> <p class="staff-phone"> <?php echo $phone; ?> </p> <?php } ?> <?php if ($email = rbm_get_field('email')) { ?> <p class="staff-email"> <a href="mailto:<?php echo $email; ?> "> <?php echo $email; ?> </a> </p> <?php } ?> </li>
*/ defined('ABSPATH') || die; /** This action is documented in views/content/content.php */ $page_content_classes = apply_filters('jc_template_content_classes', ''); ?> <article <?php post_class(array_merge(array('page-content'), $page_content_classes)); ?> data-equalizer-watch> <?php jc_breadcrumbs(); ?> <?php if ($sub_title = rbm_get_field('sub_title')) { ?> <h3> <?php echo esc_attr($sub_title); ?> </h3> <?php } ?> <?php if (has_post_thumbnail()) { ?> <div class="row"> <div class="columns small-12 medium-6 large-7">
function _admin_columns_output($column) { switch ($column) { case 'location': echo '<a href="' . get_edit_post_link() . '">'; $code = rbm_get_field('location'); echo $code ? $code : 'Location'; echo '</a>'; break; } }
/** * Content: Content Degree * * Displays post content on degree. * * @since 1.3.0 * * @package JacksonCollege * @subpackage JacksonCollege/views/content */ defined('ABSPATH') || die; global $post; /** This action is documented in views/content/content.php */ $page_content_classes = apply_filters('jc_template_content_classes', ''); if ($program_IDs = rbm_get_field('programs')) { $programs = get_posts(array('post_type' => 'jcaca-program', 'numberposts' => -1, 'post__in' => $program_IDs, 'orderby' => 'title', 'order' => 'ASC')); } ?> <section <?php post_class(array_merge(array('page-content'), $page_content_classes)); ?> data-equalizer-watch> <?php jc_breadcrumbs(); ?> <h2><?php the_title(); ?> Pathway</h2>
* * @param array $args */ $args = apply_filters('jc_get_staff_args', array('post_type' => 'jc-staff', 'numberposts' => -1, 'meta_key' => '_rbm_last_name', 'orderby' => 'meta_value', 'order' => 'ASC')); $staff = get_posts($args); $ordered_staff = array(); if ($staff) { foreach ($staff as $staff_member) { if (!($first_name = rbm_get_field('first_name', $staff_member->ID)) || !($last_name = rbm_get_field('last_name', $staff_member->ID)) || !($position = rbm_get_field('position', $staff_member->ID))) { continue; } $group_letter = strtoupper(substr(trim($last_name), 0, 1)); if (!isset($ordered_staff[$group_letter])) { $ordered_staff[$group_letter] = array(); } $ordered_staff[$group_letter][$staff_member->ID] = array('first_name' => $first_name, 'last_name' => $last_name, 'position' => $position, 'email' => rbm_get_field('email', $staff_member->ID), 'phone' => rbm_get_field('phone', $staff_member->ID), 'image' => get_the_post_thumbnail($staff_member->ID), 'bio' => rbm_get_field('bio', $staff_member->ID)); } } ksort($ordered_staff); if ($ordered_staff) { ?> <div class="row"> <ul class="jc-list-nav columns small-12"> <?php foreach (range('A', 'Z') as $letter) { ?> <?php if (isset($ordered_staff[$letter])) { ?> <li> <a href="#jc-list-anchor-<?php
function _admin_columns_output($column) { if ($column == 'featured') { switch (rbm_get_field('featured')) { case false: case '0': $link = add_query_arg('jc-cpt-spotlight-feature', get_the_ID()); ?> <a href="<?php echo $link; ?> " class="jc-cpt-spotlight-featured" title="Make Featured"> <span class=" dashicons dashicons-star-empty"></span> </a> <?php break; case '1': $link = add_query_arg('jc-cpt-spotlight-remove-feature', get_the_ID()); ?> <a href="<?php echo $link; ?> " class="jc-cpt-spotlight-featured" title="Remove From Featured"> <span class=" dashicons dashicons-star-filled"></span> </a> <?php break; } } }
<div class="job-left columns small-12 medium-6 large-8"> <h3 class="job-title"> <?php the_title(); ?> </h3> <p class="job-employer"> <?php rbm_field('employer'); ?> </p> <p class="job-site"> <?php $link = rbm_get_field('link'); $text = $link; if (strpos($link, '@') !== false) { $link = "mailto:{$link}"; } else { $link = esc_url_raw($link); } ?> <a href="<?php echo $link; ?> "> <?php echo $text; ?> </a>
function _jc_home_events_list_args($args) { if ($events_count = rbm_get_field('events_count')) { $args['numberposts'] = $events_count; } $args['meta_query'][] = array('key' => '_rbm_hidden_on_home', 'value' => '1', 'compare' => '!='); return $args; }
public function get_course_by_code_ajax() { if (!($code = $_REQUEST['course_code'])) { wp_die(0); } $response = array('status' => 'no_posts'); if ($courses = jcaca_get_courses_by_code($code)) { $response['status'] = 'success'; $response['courses'] = wp_list_pluck($courses, 'post_title', 'ID'); // Prefix course code foreach ($response['courses'] as $ID => $name) { $course_code = rbm_get_field('course_code', $ID); $response['courses'][$course_code] = $course_code ? "{$course_code}: {$name}" : $name; unset($response['courses'][$ID]); } } wp_send_json($response); }
function _modify_title() { // Make sure we should be here! if (!isset($_POST['_rbm_fields']) || !wp_verify_nonce($_POST['rbm-meta'], 'rbm-save-meta') || !current_user_can('edit_posts') || get_post_type(get_the_ID()) != 'jc-staff') { return; } static $did_one; if ($did_one) { return; } $did_one = true; $name = rbm_get_field('first_name') . ' ' . rbm_get_field('last_name'); wp_insert_post(array('ID' => get_the_ID(), 'post_title' => $name, 'post_type' => 'jc-staff', 'post_status' => 'publish')); }
/** * Adds section sidebars to frontend. * * @since 1.3.0 * @access private */ function jc_section_sidebars() { if (!($section_ID = jc_site_section())) { return; } if (rbm_get_field('section_sidebar', $section_ID)) { register_sidebar(array('name' => 'Section: ' . get_the_title($section_ID), 'id' => "section-sidebar-{$section_ID}", 'description' => 'Section sidebar for ' . get_the_title($section_ID), 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>')); } if (rbm_get_field('section_right_sidebar', $section_ID)) { register_sidebar(array('name' => 'Section (right): ' . get_the_title($section_ID), 'id' => "section-right-sidebar-{$section_ID}", 'description' => 'Section right sidebar for ' . get_the_title($section_ID), 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>')); } }