From 53815f29cb49fe6739821743f473a313442e3edb Mon Sep 17 00:00:00 2001 From: szk11001 Date: Wed, 4 Nov 2015 13:40:44 -0500 Subject: [PATCH 1/6] Update reference to Person ID I changed the return object of Specific People to Post ID instead of Post Object in uc-people/acf-export.php --- user-people.php | 92 ++++++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 44 deletions(-) diff --git a/user-people.php b/user-people.php index ee9f3d3..c13bd56 100644 --- a/user-people.php +++ b/user-people.php @@ -1,8 +1,8 @@ @@ -24,21 +24,21 @@ ', '' ); ?>
- -1, 'post_type' => 'person', 'orderby' => 'menu_order title', 'order' => 'ASC', - ); - - - + ); + + + // Settings - + $layout = get_field( "layout" ); $people_to_display = get_field( "people_to_display" ); $break_into_groups = get_field( "break_into_groups" ); @@ -46,7 +46,9 @@ $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)) { @@ -55,31 +57,32 @@ function createTextCell($setting, $field){ echo ''; } }; - - - + + + 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->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(); - + 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) { $tag_query = array( @@ -90,22 +93,23 @@ function createTextCell($setting, $field){ 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; + $id = $value; $terms = get_the_terms($id, 'group'); if (is_array($terms)){ foreach($terms as $key => $value){ @@ -113,16 +117,16 @@ function createTextCell($setting, $field){ $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. + + // 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', @@ -130,33 +134,33 @@ function createTextCell($setting, $field){ 'terms' => $value ); array_push($tax_query, $group_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'); } - + } ?> - - + +
@@ -185,4 +189,4 @@ function adjustImages(){ adjustImages(); }); - + \ No newline at end of file From a33f8a36ac1c49d6c70686152d1141b428830233 Mon Sep 17 00:00:00 2001 From: szk11001 Date: Mon, 9 Nov 2015 11:34:35 -0500 Subject: [PATCH 2/6] Fix for tags not working when breaking into groups --- user-people.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/user-people.php b/user-people.php index c13bd56..a0728c0 100644 --- a/user-people.php +++ b/user-people.php @@ -75,6 +75,7 @@ function createTextCell($setting, $field){ if ($specific_groups != false || $specific_tags != false){ $tax_query = array(); + $isTagSet = false; if ($specific_groups != false) { $group_query = array( @@ -85,6 +86,7 @@ function createTextCell($setting, $field){ array_push($tax_query, $group_query); } if ($specific_tags != false) { + $isTagSet = true; $tag_query = array( 'taxonomy' => 'persontag', 'field' => 'term_id', @@ -134,6 +136,9 @@ function createTextCell($setting, $field){ '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. From 86c487993dfe48af011aa173ef9c00adc6713262 Mon Sep 17 00:00:00 2001 From: szk11001 Date: Wed, 2 Dec 2015 15:45:48 -0500 Subject: [PATCH 3/6] Add support for multiple titles Each title will be shown a newline --- inc/people-grid.php | 60 ++++++++++++++++++---------------- inc/people-table.php | 78 ++++++++++++++++++++++++-------------------- 2 files changed, 74 insertions(+), 64 deletions(-) diff --git a/inc/people-grid.php b/inc/people-grid.php index 23ce530..6093e50 100644 --- a/inc/people-grid.php +++ b/inc/people-grid.php @@ -2,32 +2,32 @@ $the_query = new WP_Query( $args ); if ( $the_query->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)) { @@ -42,14 +42,17 @@ the_field('last_name'); }; echo '

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

'; - the_field('title'); - echo '

'; + echo '

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

'; }; if (in_array('about', $information_to_display)) { echo '
'; @@ -63,7 +66,7 @@ echo '

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

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

'; @@ -107,18 +110,17 @@ }; ?>

- -
'; + // if this is the 4th, 8th, 16th, etc person... + echo '
'; } - $person_count++; + $person_count++; } //end of posts?>
- - \ No newline at end of file diff --git a/inc/people-table.php b/inc/people-table.php index c7b1068..2aab3c2 100644 --- a/inc/people-table.php +++ b/inc/people-table.php @@ -1,18 +1,18 @@ have_posts() ) { - - // how many columns? Based on what they chose to display. - + + // how many columns? Based on what they chose to display. + $num_cols = count($information_to_display); //var_dump($num_cols); - + ?> List of People - - 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. - + + /* + 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 ''; } - createTextCell('title', 'title'); + //createTextCell('title', 'title'); + if (in_array('title', $information_to_display)) { + echo ''; + } createTextCell('about', 'about'); if (in_array('file', $information_to_display)) { echo ''; - - - + + + } //end of posts?>
- - IF any values are found to match, dump those out. - - After all possible fields, close the row. - + + IF any values are found to match, dump those out. + + After all possible fields, close the row. + */ - - - - + + + + echo '
'; the_post_thumbnail(array('65', '65')); @@ -81,7 +81,15 @@ }; echo ''; + $titlePieces = explode(";", get_field('title')); + foreach( $titlePieces as $t ){ + echo ( !empty($t) ? "{$t}
": "" ); + } + echo '
'; @@ -101,18 +109,18 @@ createTextCell('office_location', 'office_location'); createTextCell('office_hours', 'office_hours'); createTextCell('courses', 'courses'); - - + + echo '
- - \ No newline at end of file From 9f03b2d5bdc8ad0fdc4e136ca19d5d9c6676bfcd Mon Sep 17 00:00:00 2001 From: szk11001 Date: Fri, 22 Jan 2016 12:37:54 -0500 Subject: [PATCH 4/6] Add 403 redirect page Using query vars and template redirect --- 403.php | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ 404.php | 7 ------- functions.php | 33 ++++++++++++++++++++++++-------- 3 files changed, 78 insertions(+), 15 deletions(-) create mode 100644 403.php diff --git a/403.php b/403.php new file mode 100644 index 0000000..1ee77dc --- /dev/null +++ b/403.php @@ -0,0 +1,53 @@ + +
+
+
+
+
+
+
+
+ +
+

+
+ +
+
+
    + '404', + 'container' => false, + 'items_wrap' => '%3$s', + 'depth' => 1, + 'fallback_cb' => false + ); + wp_nav_menu( $defaults ); + } + ?> +
+
+
+
+
+ Photo of a puppy. +
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/404.php b/404.php index c9edda5..3565ba9 100755 --- a/404.php +++ b/404.php @@ -5,13 +5,6 @@ * @package cornerstone */ get_header(); ?> -ID, 'uc-private', true); -if($private == 'admins' || $private == 'users' || $private == 'list' || $private == 'netids'){ - $private = true; - echo 'This is a private page'; -} -?>
diff --git a/functions.php b/functions.php index e3d65e8..5b5b588 100644 --- a/functions.php +++ b/functions.php @@ -115,24 +115,24 @@ function cs_widgets_init() { */ require get_template_directory() . '/inc/customizer.php'; -/** +/** * New nav walkers */ require get_template_directory() . '/inc/nav-walker.php'; require get_template_directory() . '/inc/nav-drop-multi-walker.php'; require get_template_directory() . '/inc/nav-tabs-walker.php'; -/** +/** * Bootstrap the comment form. */ require get_template_directory() . '/inc/bootstrap-forms.php'; -/** +/** * Custom site settings */ require get_template_directory() . '/inc/settings.php'; -/** +/** * Bootstrap Whitelist */ require get_template_directory() . '/inc/bootstrap-whitelist.php'; @@ -175,13 +175,13 @@ function hale_main_nav_fallback($args) { } else { echo ''; } - + } $attributes = (!empty($args['menu_class'])?' class="'.$args['menu_class'].'"':''); $attributes .= (!empty($args['menu_id'])?' id="'.$args['menu_id'].'"':''); echo ''; if($data->length > 0) { - foreach($data as $item) { + foreach($data as $item) { echo $item->ownerDocument->saveXML($item);//saveHTML wouldn't accept it as paramater. } } @@ -193,9 +193,9 @@ function hale_main_nav_fallback($args) { } else { echo '
'; } - + } - } + } return; } @@ -237,4 +237,21 @@ function cornerstone_show_people(){ }; add_action( 'admin_init', 'cornerstone_show_people' ); +function uc_redirect_403() { + if( get_query_var( 'is_403' ) == true ){ + global $wp_query; + + status_header(403); + $wp_query->is_404=false; + + add_filter( 'wp_title', function( $title='', $sep='' ){ + return "Forbidden | ".get_bloginfo('name'); + }); + get_template_part('403'); + exit; + } +} + +add_action( 'template_redirect', 'uc_redirect_403' ); + ?> \ No newline at end of file From a1890ee77020e5ed82a391c7c3cce52c4f203ca7 Mon Sep 17 00:00:00 2001 From: szk11001 Date: Fri, 22 Jan 2016 12:50:59 -0500 Subject: [PATCH 5/6] Revert "Add 403 redirect page" This reverts commit 9f03b2d5bdc8ad0fdc4e136ca19d5d9c6676bfcd. --- 403.php | 53 --------------------------------------------------- 404.php | 7 +++++++ functions.php | 33 ++++++++------------------------ 3 files changed, 15 insertions(+), 78 deletions(-) delete mode 100644 403.php diff --git a/403.php b/403.php deleted file mode 100644 index 1ee77dc..0000000 --- a/403.php +++ /dev/null @@ -1,53 +0,0 @@ - -
-
-
-
-
-
-
-
- -
-

-
- -
-
-
    - '404', - 'container' => false, - 'items_wrap' => '%3$s', - 'depth' => 1, - 'fallback_cb' => false - ); - wp_nav_menu( $defaults ); - } - ?> -
-
-
-
-
- Photo of a puppy. -
-
-
-
-
-
-
-
- \ No newline at end of file diff --git a/404.php b/404.php index 3565ba9..c9edda5 100755 --- a/404.php +++ b/404.php @@ -5,6 +5,13 @@ * @package cornerstone */ get_header(); ?> +ID, 'uc-private', true); +if($private == 'admins' || $private == 'users' || $private == 'list' || $private == 'netids'){ + $private = true; + echo 'This is a private page'; +} +?>
diff --git a/functions.php b/functions.php index 5b5b588..e3d65e8 100644 --- a/functions.php +++ b/functions.php @@ -115,24 +115,24 @@ function cs_widgets_init() { */ require get_template_directory() . '/inc/customizer.php'; -/** +/** * New nav walkers */ require get_template_directory() . '/inc/nav-walker.php'; require get_template_directory() . '/inc/nav-drop-multi-walker.php'; require get_template_directory() . '/inc/nav-tabs-walker.php'; -/** +/** * Bootstrap the comment form. */ require get_template_directory() . '/inc/bootstrap-forms.php'; -/** +/** * Custom site settings */ require get_template_directory() . '/inc/settings.php'; -/** +/** * Bootstrap Whitelist */ require get_template_directory() . '/inc/bootstrap-whitelist.php'; @@ -175,13 +175,13 @@ function hale_main_nav_fallback($args) { } else { echo ''; } - + } $attributes = (!empty($args['menu_class'])?' class="'.$args['menu_class'].'"':''); $attributes .= (!empty($args['menu_id'])?' id="'.$args['menu_id'].'"':''); echo ''; if($data->length > 0) { - foreach($data as $item) { + foreach($data as $item) { echo $item->ownerDocument->saveXML($item);//saveHTML wouldn't accept it as paramater. } } @@ -193,9 +193,9 @@ function hale_main_nav_fallback($args) { } else { echo '
'; } - + } - } + } return; } @@ -237,21 +237,4 @@ function cornerstone_show_people(){ }; add_action( 'admin_init', 'cornerstone_show_people' ); -function uc_redirect_403() { - if( get_query_var( 'is_403' ) == true ){ - global $wp_query; - - status_header(403); - $wp_query->is_404=false; - - add_filter( 'wp_title', function( $title='', $sep='' ){ - return "Forbidden | ".get_bloginfo('name'); - }); - get_template_part('403'); - exit; - } -} - -add_action( 'template_redirect', 'uc_redirect_403' ); - ?> \ No newline at end of file From b8a5b9991f28397f59b0c1a0d2e5e8ecca8cd0fd Mon Sep 17 00:00:00 2001 From: szk11001 Date: Mon, 25 Jan 2016 10:02:16 -0500 Subject: [PATCH 6/6] 403 Forbidden Page Uses query var "is_403" set in uc-private-pages as a flag, when triggered loads 403.php --- 403.php | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ 404.php | 7 ------- functions.php | 33 ++++++++++++++++++++++++-------- 3 files changed, 78 insertions(+), 15 deletions(-) create mode 100644 403.php diff --git a/403.php b/403.php new file mode 100644 index 0000000..1ee77dc --- /dev/null +++ b/403.php @@ -0,0 +1,53 @@ + +
+
+
+
+
+
+
+
+ +
+

+
+ +
+
+
    + '404', + 'container' => false, + 'items_wrap' => '%3$s', + 'depth' => 1, + 'fallback_cb' => false + ); + wp_nav_menu( $defaults ); + } + ?> +
+
+
+
+
+ Photo of a puppy. +
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/404.php b/404.php index c9edda5..3565ba9 100755 --- a/404.php +++ b/404.php @@ -5,13 +5,6 @@ * @package cornerstone */ get_header(); ?> -ID, 'uc-private', true); -if($private == 'admins' || $private == 'users' || $private == 'list' || $private == 'netids'){ - $private = true; - echo 'This is a private page'; -} -?>
diff --git a/functions.php b/functions.php index c1503a5..f56392c 100644 --- a/functions.php +++ b/functions.php @@ -115,24 +115,24 @@ function cs_widgets_init() { */ require get_template_directory() . '/inc/customizer.php'; -/** +/** * New nav walkers */ require get_template_directory() . '/inc/nav-walker.php'; require get_template_directory() . '/inc/nav-drop-multi-walker.php'; require get_template_directory() . '/inc/nav-tabs-walker.php'; -/** +/** * Bootstrap the comment form. */ require get_template_directory() . '/inc/bootstrap-forms.php'; -/** +/** * Custom site settings */ require get_template_directory() . '/inc/settings.php'; -/** +/** * Bootstrap Whitelist */ require get_template_directory() . '/inc/bootstrap-whitelist.php'; @@ -175,13 +175,13 @@ function hale_main_nav_fallback($args) { } else { echo ''; } - + } $attributes = (!empty($args['menu_class'])?' class="'.$args['menu_class'].'"':''); $attributes .= (!empty($args['menu_id'])?' id="'.$args['menu_id'].'"':''); echo ''; if($data->length > 0) { - foreach($data as $item) { + foreach($data as $item) { echo $item->ownerDocument->saveXML($item);//saveHTML wouldn't accept it as paramater. } } @@ -193,9 +193,9 @@ function hale_main_nav_fallback($args) { } else { echo '
'; } - + } - } + } return; } @@ -247,4 +247,21 @@ function ssi_add_widget_class( $classes ) { return $classes; } +function uc_redirect_403() { + if( get_query_var( 'is_403' ) == true ){ + global $wp_query; + + status_header(403); + $wp_query->is_404=false; + + add_filter( 'wp_title', function( $title='', $sep='' ){ + return "Forbidden | ".get_bloginfo('name'); + }); + get_template_part('403'); + exit; + } +} + +add_action( 'template_redirect', 'uc_redirect_403' ); + ?> \ No newline at end of file