Skip to content

Commit

Permalink
Added logic to ensure deleted/drafted programs don't appear in colleg…
Browse files Browse the repository at this point in the history
…e profiles' top degree lists
  • Loading branch information
cjg89 committed Jun 16, 2020
1 parent 651e2ca commit 63d6466
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
19 changes: 12 additions & 7 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,24 @@
**/
function display_top_degrees( $term ) {
$ret = "";
$top_degrees = get_field( 'top_degrees', 'colleges_' . $term->term_id );
if( $top_degrees ) :
foreach( $top_degrees as $top_degree ) :
$ret .= '<li><a href="' . get_permalink( $top_degree->ID ) . '" class="text-inverse nav-link">' . $top_degree->post_title . '</a></li>';

$top_degrees = get_field( 'top_degrees', $term );
if ( $top_degrees ) :
foreach ( $top_degrees as $top_degree ) :
// Ensure stale degrees are omitted from this list:
if ( $top_degree->post_status === 'publish' ):
$ret .= '<li><a href="' . get_permalink( $top_degree->ID ) . '" class="text-inverse nav-link">' . $top_degree->post_title . '</a></li>';
endif;
endforeach;
endif;

$top_degrees_custom = get_field( 'top_degrees_custom', 'colleges_' . $term->term_id );
if( $top_degrees_custom ) :
foreach( $top_degrees_custom as $top_degree_custom ) :
$top_degrees_custom = get_field( 'top_degrees_custom', $term );
if ( $top_degrees_custom ) :
foreach ( $top_degrees_custom as $top_degree_custom ) :
$ret .= '<li><a href="' . $top_degree_custom["top_degree_custom_link"] . '" class="text-inverse nav-link">' . $top_degree_custom["top_degree_custom_text"] . '</a></li>';
endforeach;
endif;

return $ret;
}

Expand Down
20 changes: 20 additions & 0 deletions includes/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,26 @@ function yoast_sitemap_empty_terms( $hide_empty, $taxonomies ) {
add_filter( 'wpseo_sitemap_exclude_empty_terms', 'yoast_sitemap_empty_terms', 10, 2 );


/**
* Ensures that only published degrees are available to
* select from when picking existing degrees for Colleges'
* "Top Degrees" lists.
*
* @since 3.4.2
* @author Jo Dickson
* @param array $args WP_Query args
* @param array $field Array of ACF field settings
* @param int $post_id Post ID
* @return array Modified query args
*/
function college_top_degrees_options( $args, $field, $post_id ) {
$args['post_status'] = array( 'publish' );
return $args;
}

add_filter( 'acf/fields/post_object/query/name=top_degrees', 'college_top_degrees_options', 10, 3 );


/**
* Prevent the Lazy Loader plugin from modifying contents of REST API feeds.
*
Expand Down
6 changes: 5 additions & 1 deletion taxonomy-colleges.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
$degree_search_url = "https://www.ucf.edu/degree-search/#!/college/" . $term->slug . "/";
$degree_types = get_field( 'degree_types_available', 'colleges_' . $term->term_id );
$degree_types = map_degree_types( $degree_types );
$top_degrees = display_top_degrees( $term );
// CTA
$cta = get_field( 'college_page_cta_section', 'colleges_' . $term->term_id );
// News
Expand Down Expand Up @@ -88,6 +89,8 @@
?>
</ul>
</div>

<?php if ( $top_degrees ): ?>
<div class="col-lg-1 hidden-md-down">
<hr class="hidden-xs hidden-sm hr-vertical hr-vertical-white center-block">
</div>
Expand All @@ -98,10 +101,11 @@
</a>
<div id="top-degree-collapse" class="collapse d-lg-block">
<ul class="top-majors-list nav flex-column align-items-start list-unstyled pl-3">
<?php echo display_top_degrees( $term ); // located in functions.php ?>
<?php echo $top_degrees; // located in functions.php ?>
</ul>
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
Expand Down

0 comments on commit 63d6466

Please sign in to comment.