From 9e409176c4809f15dcb6d0f3bbfb7c2e88afca23 Mon Sep 17 00:00:00 2001 From: Joshua Roy Date: Thu, 10 Dec 2015 14:23:04 -0500 Subject: [PATCH 1/4] UC People Updates and Grandchild plugin header and footer support --- footer.php | 176 +++++++++++++++-------------- header.php | 174 +++++++++++++++-------------- inc/people-grid.php | 253 +++++++++++++++++++++--------------------- inc/people-table.php | 255 ++++++++++++++++++++++--------------------- single-person.php | 158 +++++++++++++++++++++------ user-people.php | 117 ++++++++++---------- 6 files changed, 633 insertions(+), 500 deletions(-) diff --git a/footer.php b/footer.php index 6bbcc78..b566259 100644 --- a/footer.php +++ b/footer.php @@ -1,81 +1,95 @@ - - - - -
- - -
- - - - - - + + + + +
+ + +
+ + + + + + diff --git a/header.php b/header.php index 877e34f..b56d96b 100644 --- a/header.php +++ b/header.php @@ -1,81 +1,95 @@ - section and everything up till
- * - */ - include 'inc/vars.php'; -?> - -> - - - - - -<?php wp_title( '|', true, 'right' ); ?> - - - - - -> - - - - - - -
- - -
+ section and everything up till
+ * + */ +if ( apply_filters( 'load_custom_header', false ) ) { + $custom_header = apply_filters( 'get_custom_header', '' ); + + if ( '' != $custom_header ) { + // Get the header that we just received + // and call the native 'get_header' function + // as usual + load_template( $custom_header ); + + // By calling 'return' we are skipping + // parsing this template any further + return; + } +} + include 'inc/vars.php'; +?> + +> + + + + + +<?php wp_title( '|', true, 'right' ); ?> + + + + + +> + + + + + + +
+ + +
\ No newline at end of file diff --git a/inc/people-grid.php b/inc/people-grid.php index 6093e50..72301e9 100644 --- a/inc/people-grid.php +++ b/inc/people-grid.php @@ -1,126 +1,127 @@ -have_posts() ) { ?> -
- have_posts() ) { - $the_query->the_post(); - - - ?> - - - - - - - -
-
- '; - - if (in_array('photo', $information_to_display)) { - echo '
'; - the_post_thumbnail('large'); - echo '
'; - }; - - if (in_array('first_name', $information_to_display) || in_array('middle_name', $information_to_display) || in_array('last_name', $information_to_display)){ - echo '

'; - if (in_array('first_name', $information_to_display)) { - the_field('first_name'); - echo ' '; - }; - if (in_array('middle_name', $information_to_display)) { - the_field('middle_name'); - echo ' '; - }; - if (in_array('last_name', $information_to_display)) { - the_field('last_name'); - }; - echo '

'; - }; - - echo ''; - - if (in_array('title', $information_to_display)) { - echo '

'; - $titlePieces = explode(";", get_field('title')); - foreach( $titlePieces as $t ){ - echo ( !empty($t) ? "{$t}
": "" ); - } - echo '

'; - }; - if (in_array('about', $information_to_display)) { - echo '
'; - the_field('about'); - echo '
'; - }; - if (in_array('file', $information_to_display)) { - $file = get_field('file'); - $urlLength = strlen($file); - if ($urlLength > 0){ - echo '

'; - echo ''.$file[title].''; - echo '

'; - } - }; - if (in_array('email', $information_to_display)) { - echo '

'; - echo ''.get_field('email').''; - echo '

'; - }; - if (in_array('phone', $information_to_display)) { - echo '

'; - the_field('phone'); - echo '

'; - }; - if (in_array('phone_(alternate)', $information_to_display)) { - echo '

'; - the_field('phone_(alternate)'); - echo '

'; - }; - if (in_array('fax', $information_to_display)) { - echo '

'; - the_field('fax'); - echo '

'; - }; - if (in_array('mailing_address', $information_to_display)) { - echo '

'; - the_field('mailing_address'); - echo '

'; - }; - if (in_array('office_location', $information_to_display)) { - echo '

'; - the_field('office_location'); - echo '

'; - }; - if (in_array('office_hours', $information_to_display)) { - echo '

'; - the_field('office_hours'); - echo '

'; - }; - if (in_array('courses', $information_to_display)) { - echo '

'; - the_field('courses'); - echo '

'; - }; ?> -
-
- -
'; - } - $person_count++; - } //end of posts?> -
- +have_posts() ) { ?> +
+ have_posts() ) { + $the_query->the_post(); + + + ?> + + + + + + + +
+
+ '; + + if (in_array('photo', $information_to_display)) { + echo '
'; + the_post_thumbnail('large'); + echo '
'; + }; + + if (in_array('first_name', $information_to_display) || in_array('middle_name', $information_to_display) || in_array('last_name', $information_to_display)){ + echo '

'; + if (in_array('first_name', $information_to_display)) { + the_field('first_name'); + echo ' '; + }; + if (in_array('middle_name', $information_to_display)) { + the_field('middle_name'); + echo ' '; + }; + if (in_array('last_name', $information_to_display)) { + the_field('last_name'); + }; + echo '

'; + }; + + echo ''; + + if (in_array('title', $information_to_display)) { + echo '

'; + $titlePieces = explode(";", get_field('title')); + foreach( $titlePieces as $t ){ + echo ( !empty($t) ? "{$t}
": "" ); + } + echo '

'; + }; + if (in_array('about', $information_to_display)) { + echo '
'; + the_field('about'); + echo '
'; + }; + if (in_array('file', $information_to_display)) { + $file = get_field('file'); + $urlLength = strlen($file); + if ($urlLength > 0){ + echo '

'; + echo ''.$file[title].''; + echo '

'; + } + }; + if (in_array('email', $information_to_display)) { + echo '

'; + echo ''.get_field('email').''; + echo '

'; + }; + if (in_array('phone', $information_to_display)) { + echo '

'; + the_field('phone'); + echo '

'; + }; + if (in_array('phone_(alternate)', $information_to_display)) { + echo '

'; + the_field('phone_(alternate)'); + echo '

'; + }; + if (in_array('fax', $information_to_display)) { + echo '

'; + the_field('fax'); + echo '

'; + }; + if (in_array('mailing_address', $information_to_display)) { + echo '

'; + echo str_replace(';','
',get_field('mailing_address')); + echo '

'; + }; + if (in_array('office_location', $information_to_display)) { + echo '

'; + the_field('office_location'); + echo '

'; + }; + if (in_array('office_hours', $information_to_display)) { + echo '

'; + the_field('office_hours'); + echo '

'; + }; + if (in_array('courses', $information_to_display)) { + echo '

'; + the_field('courses'); + echo '

'; + }; ?> +
+
+ +
'; + } + $person_count++; + } //end of posts?> +
+ + \ No newline at end of file diff --git a/inc/people-table.php b/inc/people-table.php index 2aab3c2..06d84df 100644 --- a/inc/people-table.php +++ b/inc/people-table.php @@ -1,126 +1,131 @@ -have_posts() ) { - - // how many columns? Based on what they chose to display. - - $num_cols = count($information_to_display); - //var_dump($num_cols); - - ?> - - List of People - - - Name'; - $nameCell = true; - }; - } elseif ($value == 'photo') { - echo ''; - } else { - //var_dump(get_field_object('field_'.$value)); - $arr = get_field_object('field_'.$value); - $label = $arr['label']; - echo ''; - } - } - ?> - - - - have_posts() ) { - $the_query->the_post(); - - /* - create a row. - - For each possible field. - - Check to see if it's within the $information_to_display array. - - If it is, create a '; - - if (in_array('photo', $information_to_display)) { - echo ''; - } - if (in_array('first_name', $information_to_display) || in_array('middle_name', $information_to_display) || in_array('last_name', $information_to_display)){ - echo ''; - } - //createTextCell('title', 'title'); - if (in_array('title', $information_to_display)) { - echo ''; - } - createTextCell('about', 'about'); - if (in_array('file', $information_to_display)) { - echo ''; - }; - if (in_array('email', $information_to_display)) { - echo ''; - }; - createTextCell('phone', 'phone'); - createTextCell('phone_(alternate)', 'phone_(alternate)'); - createTextCell('fax', 'fax'); - createTextCell('mailing_address', 'mailing_address'); - createTextCell('office_location', 'office_location'); - createTextCell('office_hours', 'office_hours'); - createTextCell('courses', 'courses'); - - - - echo ''; - - - - } //end of posts?> - -
 '.$label.'
- - IF any values are found to match, dump those out. - - After all possible fields, close the row. - - */ - - - - - echo '
'; - the_post_thumbnail(array('65', '65')); - echo ''; - if (in_array('first_name', $information_to_display)) { - the_field('first_name'); - echo ' '; - }; - if (in_array('middle_name', $information_to_display)) { - the_field('middle_name'); - echo ' '; - }; - if (in_array('last_name', $information_to_display)) { - the_field('last_name'); - }; - echo ''; - $titlePieces = explode(";", get_field('title')); - foreach( $titlePieces as $t ){ - echo ( !empty($t) ? "{$t}
": "" ); - } - echo '
'; - $file = get_field('file'); - echo ''.$file[title].''; - echo ''; - echo ''.get_field('email').''; - echo '
- - have_posts() ) { + + // how many columns? Based on what they chose to display. + + $num_cols = count($information_to_display); + //var_dump($num_cols); + + ?> + + List of People + + + Name'; + $nameCell = true; + }; + } elseif ($value == 'photo') { + echo ''; + } else { + //var_dump(get_field_object('field_'.$value)); + $arr = get_field_object('field_'.$value); + $label = $arr['label']; + echo ''; + } + } + ?> + + + + have_posts() ) { + $the_query->the_post(); + + /* + create a row. + + For each possible field. + + Check to see if it's within the $information_to_display array. + + If it is, create a '; + + if (in_array('photo', $information_to_display)) { + echo ''; + } + if (in_array('first_name', $information_to_display) || in_array('middle_name', $information_to_display) || in_array('last_name', $information_to_display)){ + echo ''; + } + //createTextCell('title', 'title'); + if (in_array('title', $information_to_display)) { + echo ''; + } + createTextCell('about', 'about'); + if (in_array('file', $information_to_display)) { + echo ''; + }; + if (in_array('email', $information_to_display)) { + echo ''; + }; + createTextCell('phone', 'phone'); + createTextCell('phone_(alternate)', 'phone_(alternate)'); + createTextCell('fax', 'fax'); + //createTextCell('mailing_address', 'mailing_address'); + if (in_array('mailing_address', $information_to_display)) { + echo ''; + } + createTextCell('office_location', 'office_location'); + createTextCell('office_hours', 'office_hours'); + createTextCell('courses', 'courses'); + + + + echo ''; + + + + } //end of posts?> + +
 '.$label.'
+ + IF any values are found to match, dump those out. + + After all possible fields, close the row. + + */ + + + + + echo '
'; + the_post_thumbnail(array('65', '65')); + echo ''; + if (in_array('first_name', $information_to_display)) { + the_field('first_name'); + echo ' '; + }; + if (in_array('middle_name', $information_to_display)) { + the_field('middle_name'); + echo ' '; + }; + if (in_array('last_name', $information_to_display)) { + the_field('last_name'); + }; + echo ''; + $titlePieces = explode(";", get_field('title')); + foreach( $titlePieces as $t ){ + echo ( !empty($t) ? "{$t}
": "" ); + } + echo '
'; + $file = get_field('file'); + echo ''.$file[title].''; + echo ''; + echo ''.get_field('email').''; + echo ''; + echo str_replace(';','
',get_field('mailing_address')); + echo '
+ + \ No newline at end of file diff --git a/single-person.php b/single-person.php index aefe8cc..717370e 100644 --- a/single-person.php +++ b/single-person.php @@ -1,33 +1,125 @@ - - -
- - -
-
-
-
-
- 0){ - include('inc/person-with-about.php'); - } else { - include('inc/person-no-about.php'); - } - ?> -
-
-
-
- -
- - -
- + + +
+ + +
+
+
+
+
+
+

+

+ + '.$t.'

': '' ); + } + ?> +
+ +
+
+ '; + the_post_thumbnail(); + echo '
'; + };?> +
+ + Contact Information + '.$field_label.''; + echo '

'; + if ($field == 'email'){ + echo ''; + the_field($field); + echo ''; + } else if ($field == 'file'){ + $file = get_field($field); + $url= $file['url']; + echo ' '; + echo $file['title']; + echo ''; + } else { + the_field($field); + } + echo '


'; + } + } + */ + function displayField($field){ + if (get_field($field)){ + + $field_key = 'field_'.$field; + $field_obj = get_field_object($field_key); + $field_value = $field_obj['value']; + $field_label = $field_obj['label']; + echo ''; + echo ''; + } + } + displayField('email'); + displayField('phone'); + displayField('phone_(alternate)'); + displayField('fax'); + displayField('file'); + displayField('mailing_address'); + displayField('office_location'); + displayField('office_hours'); + displayField('courses'); + ?> +
'.$field_label.''; + if ($field == 'email'){ + echo ''; + the_field($field); + echo ''; + } else if ($field == 'file'){ + $file = get_field($field); + $url= $file['url']; + echo ' '; + echo $file['title']; + echo ''; + } else if ($field == 'mailing_address'){ + echo str_replace(';','
',get_field('mailing_address')); + } else { + the_field($field); + } + echo '
+
+
+
+ + + +
+
+ +
+ + +
+ diff --git a/user-people.php b/user-people.php index 81a8e7f..5a33bd0 100644 --- a/user-people.php +++ b/user-people.php @@ -1,8 +1,8 @@ @@ -24,9 +24,9 @@ get_header(); ?> ', '' ); ?>
- -1, @@ -34,12 +34,12 @@ get_header(); ?> 'meta_key' => 'last_name', 'orderby' => 'menu_order meta_value title', 'order' => 'ASC', - ); - - - + ); + + + // Settings - + $layout = get_field( "layout" ); $people_to_display = get_field( "people_to_display" ); $break_into_groups = get_field( "break_into_groups" ); @@ -47,47 +47,57 @@ get_header(); ?> $specific_groups = get_field( "specific_groups" ); $specific_tags = get_field( "specific_tags" ); $information_to_display = get_field( "information_to_display" ); - - //var_dump($specific_people); - + function createTextCell($setting, $field){ global $information_to_display; if (in_array($setting, $information_to_display)) { - echo ''; + echo ''; the_field($field); echo ''; } }; - - - + + function sort_group_by_order( $a, $b ){ + // Getting the order for groups $a and $b + $groupA = get_term_by('slug', $a, 'group')->term_id; + $array_orderGroupA = get_option( "taxonomy_{$groupA}" ); + $orderGroupA = $array_orderGroupA['group_order']; + + $groupB = get_term_by('slug', $b, 'group')->term_id; + $array_orderGroupB = get_option( "taxonomy_{$groupB}" ); + $orderGroupB = $array_orderGroupB['group_order']; + + $r = strnatcasecmp( $orderGroupA, $orderGroupB ); + if( $r === 0 ){ + $r = strnatcasecmp( $a, $b ); + } + return $r; + } + if ($specific_people){ global $specific_people; global $args; $post__in = array(); foreach($specific_people as &$value){ - //array_push($post__in, $value->ID); - array_push($post__in, $value); + array_push($post__in, $value->ID); } $args[post__in]= $post__in; } - + // do we need a tax query? - if ($specific_groups != false || $specific_tags != false){ - - $tax_query = array(); - $isTagSet = false; - + if ($specific_groups != false || $specific_tags != false){ + + $tax_query = array(); + if ($specific_groups != false) { $group_query = array( 'taxonomy' => 'group', 'field' => 'term_id', 'terms' => $specific_groups ); - array_push($tax_query, $group_query); + array_push($tax_query, $group_query); } if ($specific_tags != false) { - $isTagSet = true; $tag_query = array( 'taxonomy' => 'persontag', 'field' => 'term_id', @@ -96,23 +106,22 @@ get_header(); ?> array_push($tax_query, $tag_query); } $args[tax_query] = $tax_query; - + } if ($break_into_groups == 1 ){ //echo '

Break into Groups

'; - + // get all the people $the_query = new WP_Query( $args ); - - // focusing on just the people, not the rest of the query. + + // focusing on just the people, not the rest of the query. $people = $the_query->posts; - - // look at each person, and see each group used, use that to create a list of terms. + + // look at each person, and see each group used, use that to create a list of terms. $groups_in_use = array(); - + foreach($people as $value){ - //$id = $value->ID; - $id = $value; + $id = $value->ID; $terms = get_the_terms($id, 'group'); if (is_array($terms)){ foreach($terms as $key => $value){ @@ -120,16 +129,17 @@ get_header(); ?> $slug = $value->slug; $groups_in_use[$slug]= $slug; } - }; + }; } - + // sort the groups in use alphabetically - sort($groups_in_use); - - // 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. + //sort($groups_in_use); + usort($groups_in_use, 'sort_group_by_order' ); + + // 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){ - - // this sets up the query we'll need, and will overwrite any group queries from the original settings. + + // this sets up the query we'll need, and will overwrite any group queries from the original settings. $tax_query = array(); $group_query = array( 'taxonomy' => 'group', @@ -137,36 +147,33 @@ get_header(); ?> 'terms' => $value ); array_push($tax_query, $group_query); - if( $isTagSet != false ){ - array_push($tax_query, $tag_query); - } - $args['tax_query'] = $tax_query; + $args['tax_query'] = $tax_query; - // with $arg updated, let's do a new query. + // with $arg updated, let's do a new query. echo '

'.get_term_by('slug', $value, 'group')->name.'

'; - + if ($layout == 'grid') { include('inc/people-grid.php'); } if ($layout == 'table') { include('inc/people-table.php'); } - + } } else { - + if ($layout == 'grid') { include('inc/people-grid.php'); } if ($layout == 'table') { include('inc/people-table.php'); } - + } ?> - - + +
@@ -195,4 +202,4 @@ jQuery(window).load(function() { adjustImages(); }); - \ No newline at end of file + From f8d485a589a92b16483507d03fa0cc81112244a6 Mon Sep 17 00:00:00 2001 From: Joshua Roy Date: Thu, 10 Dec 2015 14:39:42 -0500 Subject: [PATCH 2/4] Fixing dev/github inconsistency --- inc/person-no-about.php | 124 ++++++++++++++++-------------- inc/person-with-about.php | 130 ++++++++++++++++--------------- single-person.php | 158 ++++++++------------------------------ 3 files changed, 168 insertions(+), 244 deletions(-) diff --git a/inc/person-no-about.php b/inc/person-no-about.php index d1ead73..78d737a 100644 --- a/inc/person-no-about.php +++ b/inc/person-no-about.php @@ -1,58 +1,66 @@ -
- '; - the_post_thumbnail(); - echo '
'; - };?> -
-
-

-

-

- - Contact Information - '; - echo ''; - } - } - displayField('email'); - displayField('phone'); - displayField('phone_(alternate)'); - displayField('fax'); - displayField('file'); - displayField('mailing_address'); - displayField('office_location'); - displayField('office_hours'); - displayField('courses'); - ?> -
'.$field_label.''; - if ($field == 'email'){ - echo ''; - the_field($field); - echo ''; - } else if ($field == 'file'){ - $file = get_field($field); - $url= $file['url']; - echo ' '; - echo $file['title']; - echo ''; - } else { - the_field($field); - } - echo '
-
+
+ '; + the_post_thumbnail(); + echo '
'; + };?> +
+
+

+

+ '.$t.'

': '' ); + } + ?> + + Contact Information + '; + echo ''; + } + } + displayField('email'); + displayField('phone'); + displayField('phone_(alternate)'); + displayField('fax'); + displayField('file'); + displayField('mailing_address'); + displayField('office_location'); + displayField('office_hours'); + displayField('courses'); + ?> +
'.$field_label.''; + if ($field == 'email'){ + echo ''; + the_field($field); + echo ''; + } else if ($field == 'file'){ + $file = get_field($field); + $url= $file['url']; + echo ' '; + echo $file['title']; + echo ''; + } else if ($field == 'mailing_address'){ + echo str_replace(';','
',get_field('mailing_address')); + } else { + the_field($field); + } + echo '
+
diff --git a/inc/person-with-about.php b/inc/person-with-about.php index ea5ccc7..1c87360 100644 --- a/inc/person-with-about.php +++ b/inc/person-with-about.php @@ -1,62 +1,70 @@ -
-

-

-

-
- -
-
- '; - the_post_thumbnail(); - echo '
'; - };?> -
- - Contact Information - '; - echo ''; - } - } - displayField('email'); - displayField('phone'); - displayField('phone_(alternate)'); - displayField('fax'); - displayField('file'); - displayField('mailing_address'); - displayField('office_location'); - displayField('office_hours'); - displayField('courses'); - ?> -
'.$field_label.''; - if ($field == 'email'){ - echo ''; - the_field($field); - echo ''; - } else if ($field == 'file'){ - $file = get_field($field); - $url= $file['url']; - echo ' '; - echo $file['title']; - echo ''; - } else { - the_field($field); - } - echo '
-
+
+

+

+ '.$t.'

': '' ); + } + ?> +
+ +
+
+ '; + the_post_thumbnail(); + echo '
'; + };?> +
+ + Contact Information + '; + echo ''; + } + } + displayField('email'); + displayField('phone'); + displayField('phone_(alternate)'); + displayField('fax'); + displayField('file'); + displayField('mailing_address'); + displayField('office_location'); + displayField('office_hours'); + displayField('courses'); + ?> +
'.$field_label.''; + if ($field == 'email'){ + echo ''; + the_field($field); + echo ''; + } else if ($field == 'file'){ + $file = get_field($field); + $url= $file['url']; + echo ' '; + echo $file['title']; + echo ''; + } else if ($field == 'mailing_address'){ + echo str_replace(';','
',get_field('mailing_address')); + } else { + the_field($field); + } + echo '
+
\ No newline at end of file diff --git a/single-person.php b/single-person.php index 717370e..aefe8cc 100644 --- a/single-person.php +++ b/single-person.php @@ -1,125 +1,33 @@ - - -
- - -
-
-
-
-
-
-

-

- - '.$t.'

': '' ); - } - ?> -
- -
-
- '; - the_post_thumbnail(); - echo '
'; - };?> -
- - Contact Information - '.$field_label.''; - echo '

'; - if ($field == 'email'){ - echo ''; - the_field($field); - echo ''; - } else if ($field == 'file'){ - $file = get_field($field); - $url= $file['url']; - echo ' '; - echo $file['title']; - echo ''; - } else { - the_field($field); - } - echo '


'; - } - } - */ - function displayField($field){ - if (get_field($field)){ - - $field_key = 'field_'.$field; - $field_obj = get_field_object($field_key); - $field_value = $field_obj['value']; - $field_label = $field_obj['label']; - echo ''; - echo ''; - } - } - displayField('email'); - displayField('phone'); - displayField('phone_(alternate)'); - displayField('fax'); - displayField('file'); - displayField('mailing_address'); - displayField('office_location'); - displayField('office_hours'); - displayField('courses'); - ?> -
'.$field_label.''; - if ($field == 'email'){ - echo ''; - the_field($field); - echo ''; - } else if ($field == 'file'){ - $file = get_field($field); - $url= $file['url']; - echo ' '; - echo $file['title']; - echo ''; - } else if ($field == 'mailing_address'){ - echo str_replace(';','
',get_field('mailing_address')); - } else { - the_field($field); - } - echo '
-
-
-
- - - -
-
- -
- - -
- + + +
+ + +
+
+
+
+
+ 0){ + include('inc/person-with-about.php'); + } else { + include('inc/person-no-about.php'); + } + ?> +
+
+
+
+ +
+ + +
+ From c41c322f67ff611da7608c5ff4802a4c7a5eb4d8 Mon Sep 17 00:00:00 2001 From: Joshua Roy Date: Thu, 10 Dec 2015 15:07:10 -0500 Subject: [PATCH 3/4] Fixing more inconsistencies --- inc/user-people.php | 212 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 inc/user-people.php diff --git a/inc/user-people.php b/inc/user-people.php new file mode 100644 index 0000000..f1dd312 --- /dev/null +++ b/inc/user-people.php @@ -0,0 +1,212 @@ + +
+ + + +
+
+
+
+
> +
+ ', '' ); ?> +
+
+ +
+ ', '' ); ?> +
+
+ -1, + 'post_type' => 'person', + 'meta_key' => 'last_name', + 'orderby' => 'menu_order meta_value title', + 'order' => 'ASC', + ); + + + + // Settings + + $layout = get_field( "layout" ); + $people_to_display = get_field( "people_to_display" ); + $break_into_groups = get_field( "break_into_groups" ); + $specific_people = get_field( "specific_people" ); + $specific_groups = get_field( "specific_groups" ); + $specific_tags = get_field( "specific_tags" ); + $information_to_display = get_field( "information_to_display" ); + + function createTextCell($setting, $field){ + global $information_to_display; + if (in_array($setting, $information_to_display)) { + echo ''; + the_field($field); + echo ''; + } + }; + + function sort_group_by_order( $a, $b ){ + // Getting the order for groups $a and $b + $groupA = get_term_by('slug', $a, 'group')->term_id; + $array_orderGroupA = get_option( "taxonomy_{$groupA}" ); + $orderGroupA = $array_orderGroupA['group_order']; + + $groupB = get_term_by('slug', $b, 'group')->term_id; + $array_orderGroupB = get_option( "taxonomy_{$groupB}" ); + $orderGroupB = $array_orderGroupB['group_order']; + + $r = strnatcasecmp( $orderGroupA, $orderGroupB ); + if( $r === 0 ){ + $r = strnatcasecmp( $a, $b ); + } + return $r; + } + + if ($specific_people){ + global $specific_people; + global $args; + $post__in = array(); + foreach($specific_people as &$value){ + //array_push($post__in, $value->ID); + array_push($post__in, $value); + } + $args[post__in]= $post__in; + } + + // do we need a tax query? + if ($specific_groups != false || $specific_tags != false){ + + $tax_query = array(); + $isTagSet = false; + + if ($specific_groups != false) { + $group_query = array( + 'taxonomy' => 'group', + 'field' => 'term_id', + 'terms' => $specific_groups + ); + array_push($tax_query, $group_query); + } + if ($specific_tags != false) { + $isTagSet = true; + $tag_query = array( + 'taxonomy' => 'persontag', + 'field' => 'term_id', + 'terms' => $specific_tags + ); + array_push($tax_query, $tag_query); + } + $args[tax_query] = $tax_query; + + } + if ($break_into_groups == 1 ){ + //echo '

Break into Groups

'; + + // get all the people + $the_query = new WP_Query( $args ); + + // focusing on just the people, not the rest of the query. + $people = $the_query->posts; + + // look at each person, and see each group used, use that to create a list of terms. + $groups_in_use = array(); + + foreach($people as $value){ + //$id = $value->ID; + $id = $value; + $terms = get_the_terms($id, 'group'); + if (is_array($terms)){ + foreach($terms as $key => $value){ + //duplicates will overwrite themselves... + $slug = $value->slug; + $groups_in_use[$slug]= $slug; + } + }; + } + + // sort the groups in use alphabetically + //sort($groups_in_use); + usort($groups_in_use, 'sort_group_by_order' ); + + // 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){ + + // this sets up the query we'll need, and will overwrite any group queries from the original settings. + $tax_query = array(); + $group_query = array( + 'taxonomy' => 'group', + 'field' => 'slug', + 'terms' => $value + ); + array_push($tax_query, $group_query); + if( $isTagSet != false ){ + array_push($tax_query, $tag_query); + } + $args['tax_query'] = $tax_query; + + // with $arg updated, let's do a new query. + echo '

'.get_term_by('slug', $value, 'group')->name.'

'; + + if ($layout == 'grid') { + include('inc/people-grid.php'); + } + if ($layout == 'table') { + include('inc/people-table.php'); + } + + } + + } else { + + if ($layout == 'grid') { + include('inc/people-grid.php'); + } + if ($layout == 'table') { + include('inc/people-table.php'); + } + + } + ?> + + +
+
+
+
+
+
+ +
+ + +
+ + \ No newline at end of file From 5d888673dcadafb976c3b12ca17fa8190276731e Mon Sep 17 00:00:00 2001 From: Joshua Roy Date: Thu, 10 Dec 2015 15:07:46 -0500 Subject: [PATCH 4/4] Fixing more inconsistencies --- inc/user-people.php | 212 -------------------------------------------- user-people.php | 15 +++- 2 files changed, 11 insertions(+), 216 deletions(-) delete mode 100644 inc/user-people.php diff --git a/inc/user-people.php b/inc/user-people.php deleted file mode 100644 index f1dd312..0000000 --- a/inc/user-people.php +++ /dev/null @@ -1,212 +0,0 @@ - -
- - - -
-
-
-
-
> -
- ', '' ); ?> -
-
- -
- ', '' ); ?> -
-
- -1, - 'post_type' => 'person', - 'meta_key' => 'last_name', - 'orderby' => 'menu_order meta_value title', - 'order' => 'ASC', - ); - - - - // Settings - - $layout = get_field( "layout" ); - $people_to_display = get_field( "people_to_display" ); - $break_into_groups = get_field( "break_into_groups" ); - $specific_people = get_field( "specific_people" ); - $specific_groups = get_field( "specific_groups" ); - $specific_tags = get_field( "specific_tags" ); - $information_to_display = get_field( "information_to_display" ); - - function createTextCell($setting, $field){ - global $information_to_display; - if (in_array($setting, $information_to_display)) { - echo ''; - the_field($field); - echo ''; - } - }; - - function sort_group_by_order( $a, $b ){ - // Getting the order for groups $a and $b - $groupA = get_term_by('slug', $a, 'group')->term_id; - $array_orderGroupA = get_option( "taxonomy_{$groupA}" ); - $orderGroupA = $array_orderGroupA['group_order']; - - $groupB = get_term_by('slug', $b, 'group')->term_id; - $array_orderGroupB = get_option( "taxonomy_{$groupB}" ); - $orderGroupB = $array_orderGroupB['group_order']; - - $r = strnatcasecmp( $orderGroupA, $orderGroupB ); - if( $r === 0 ){ - $r = strnatcasecmp( $a, $b ); - } - return $r; - } - - if ($specific_people){ - global $specific_people; - global $args; - $post__in = array(); - foreach($specific_people as &$value){ - //array_push($post__in, $value->ID); - array_push($post__in, $value); - } - $args[post__in]= $post__in; - } - - // do we need a tax query? - if ($specific_groups != false || $specific_tags != false){ - - $tax_query = array(); - $isTagSet = false; - - if ($specific_groups != false) { - $group_query = array( - 'taxonomy' => 'group', - 'field' => 'term_id', - 'terms' => $specific_groups - ); - array_push($tax_query, $group_query); - } - if ($specific_tags != false) { - $isTagSet = true; - $tag_query = array( - 'taxonomy' => 'persontag', - 'field' => 'term_id', - 'terms' => $specific_tags - ); - array_push($tax_query, $tag_query); - } - $args[tax_query] = $tax_query; - - } - if ($break_into_groups == 1 ){ - //echo '

Break into Groups

'; - - // get all the people - $the_query = new WP_Query( $args ); - - // focusing on just the people, not the rest of the query. - $people = $the_query->posts; - - // look at each person, and see each group used, use that to create a list of terms. - $groups_in_use = array(); - - foreach($people as $value){ - //$id = $value->ID; - $id = $value; - $terms = get_the_terms($id, 'group'); - if (is_array($terms)){ - foreach($terms as $key => $value){ - //duplicates will overwrite themselves... - $slug = $value->slug; - $groups_in_use[$slug]= $slug; - } - }; - } - - // sort the groups in use alphabetically - //sort($groups_in_use); - usort($groups_in_use, 'sort_group_by_order' ); - - // 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){ - - // this sets up the query we'll need, and will overwrite any group queries from the original settings. - $tax_query = array(); - $group_query = array( - 'taxonomy' => 'group', - 'field' => 'slug', - 'terms' => $value - ); - array_push($tax_query, $group_query); - if( $isTagSet != false ){ - array_push($tax_query, $tag_query); - } - $args['tax_query'] = $tax_query; - - // with $arg updated, let's do a new query. - echo '

'.get_term_by('slug', $value, 'group')->name.'

'; - - if ($layout == 'grid') { - include('inc/people-grid.php'); - } - if ($layout == 'table') { - include('inc/people-table.php'); - } - - } - - } else { - - if ($layout == 'grid') { - include('inc/people-grid.php'); - } - if ($layout == 'table') { - include('inc/people-table.php'); - } - - } - ?> - - -
-
-
-
-
-
- -
- - -
- - \ No newline at end of file diff --git a/user-people.php b/user-people.php index 5a33bd0..f1dd312 100644 --- a/user-people.php +++ b/user-people.php @@ -79,7 +79,8 @@ get_header(); ?> global $args; $post__in = array(); foreach($specific_people as &$value){ - array_push($post__in, $value->ID); + //array_push($post__in, $value->ID); + array_push($post__in, $value); } $args[post__in]= $post__in; } @@ -87,7 +88,8 @@ get_header(); ?> // do we need a tax query? if ($specific_groups != false || $specific_tags != false){ - $tax_query = array(); + $tax_query = array(); + $isTagSet = false; if ($specific_groups != false) { $group_query = array( @@ -98,6 +100,7 @@ get_header(); ?> array_push($tax_query, $group_query); } if ($specific_tags != false) { + $isTagSet = true; $tag_query = array( 'taxonomy' => 'persontag', 'field' => 'term_id', @@ -121,7 +124,8 @@ get_header(); ?> $groups_in_use = array(); foreach($people as $value){ - $id = $value->ID; + //$id = $value->ID; + $id = $value; $terms = get_the_terms($id, 'group'); if (is_array($terms)){ foreach($terms as $key => $value){ @@ -147,6 +151,9 @@ get_header(); ?> 'terms' => $value ); array_push($tax_query, $group_query); + if( $isTagSet != false ){ + array_push($tax_query, $tag_query); + } $args['tax_query'] = $tax_query; // with $arg updated, let's do a new query. @@ -202,4 +209,4 @@ jQuery(window).load(function() { adjustImages(); }); - + \ No newline at end of file