Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
fix for div by zero
  • Loading branch information
jjc16105 committed Sep 8, 2016
2 parents 4674eb7 + dafd775 commit 1c91e78
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 165 deletions.
30 changes: 20 additions & 10 deletions content-az.php
Expand Up @@ -27,8 +27,9 @@ $pattern = '#[A-Za-z|~`!@\#$%^&*()_+=|\\}\][{\'/;\-":?>.<]#';

<div id="az-index" class="clearfix">
<?php
function getChars(){
$pages = get_pages();
function getChars($pages){
global $exclude;
//$pages = get_pages(array('sort_order' => 'asc', 'sort_column' => 'post_title', 'hierarchical' => false, 'exclude' => $exclude));
$letters = array();
foreach( (array) $pages as $pg ){
$parent = is_parent_private($pg->ID);
Expand All @@ -40,7 +41,8 @@ $pattern = '#[A-Za-z|~`!@\#$%^&*()_+=|\\}\][{\'/;\-":?>.<]#';
}
$title = ucwords($pg->post_title);
$char = $title{0};
if( !(is_numeric($char)) && !in_array($char, $letters) ){
if($char == 'Z') echo $title;
if(!in_array($char, $letters) ){
array_push($letters, $char);
}
}
Expand All @@ -49,19 +51,27 @@ $pattern = '#[A-Za-z|~`!@\#$%^&*()_+=|\\}\][{\'/;\-":?>.<]#';

// Generate AZ Navigation
echo '<nav class="btn-group">';
$anchors = getChars();
$pages = get_pages(array('sort_order' => 'asc', 'sort_column' => 'post_title', 'hierarchical' => false, 'exclude' => $exclude));
$anchors = getChars($pages);
foreach( range('A', 'Z') as $char ){
if( in_array( $char, $anchors ) ){
echo '<a href="#'.$char.'-pages" class="btn btn-default">'.$char.'</a>';
} else {
echo '<span class="btn btn-default disabled">'.$char.'</span>';
}
}
echo '</nav><nav class="btn-group">';
foreach( range('0', '9') as $char ){
if( in_array( (string)$char, $anchors ) ){
echo '<a href="#'.$char.'-pages" class="btn btn-default">'.$char.'</a>';
} else {
echo '<span class="btn btn-default disabled">'.$char.'</span>';
}
}
echo '</nav>';

// Generate AZ List
$pages = get_pages(array('sort_order' => 'asc', 'sort_column' => 'post_title', 'hierarchical' => false, 'exclude' => $exclude));
if( !preg_match($pattern, $exclude, $matches) ){
//if( !preg_match($pattern, $exclude, $matches) ){
$letters = array();
echo '<section class="letter-directory">';
foreach( (array) $pages as $pg ){
Expand All @@ -74,7 +84,7 @@ $pattern = '#[A-Za-z|~`!@\#$%^&*()_+=|\\}\][{\'/;\-":?>.<]#';
}
$title = ucwords($pg->post_title);
$char = $title{0};
if( !( is_numeric($char) || empty($char) ) ){
if( !( empty($char) ) ){
if( $char != end($letters) && !empty($letters) ){
echo '</ol></div>';
}
Expand All @@ -86,9 +96,9 @@ $pattern = '#[A-Za-z|~`!@\#$%^&*()_+=|\\}\][{\'/;\-":?>.<]#';
}
}
echo '</ol></div></section>';
} else {
echo '<p>Invalid input in field: "exclude"</p>';
}
//} else {
// echo '<p>Invalid input in field: "exclude"</p>';
//}
?>
</div>
<footer class="entry-footer">
Expand Down
150 changes: 0 additions & 150 deletions inc/people-grid.php

This file was deleted.

3 changes: 2 additions & 1 deletion search.php
Expand Up @@ -21,7 +21,8 @@ get_header(); ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post();?>
<?php
$url = get_field('external_url');
$url = '';
if(function_exists('get_field')) $url = get_field('external_url');
if( empty($url) ){
$url = '<a href="'.get_permalink().'">';
}else{
Expand Down
11 changes: 7 additions & 4 deletions user-people.php
Expand Up @@ -112,6 +112,12 @@ get_header(); ?>
$args[tax_query] = $tax_query;

}

$persons_per_row = get_field("persons_per_row"); // default is 4
if ( ! $persons_per_row ){
$persons_per_row = 4;
}

if ($break_into_groups == 1 ){
//echo '<h1>Break into Groups</h1>';

Expand Down Expand Up @@ -147,10 +153,7 @@ get_header(); ?>
//sort($groups_in_use);
usort($groups_in_use, 'sort_group_by_order' );

$persons_per_row = get_field("persons_per_row"); // default is 4
if ( ! $persons_per_row ){
$persons_per_row = 4;
}


// for each item in the list of terms, do a new query, but this time we're going to limit it to ONLY items from that one group.
foreach($groups_in_use as $value){
Expand Down

0 comments on commit 1c91e78

Please sign in to comment.