From 1795b419d1516191faa9e3ef0023c664a3e2f5bc Mon Sep 17 00:00:00 2001 From: John Calande Date: Fri, 13 May 2016 08:59:48 -0400 Subject: [PATCH 1/3] Added Link Guessing checkbox to Dashboard->Settings --- functions.php | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/functions.php b/functions.php index f56392c..d69c2d9 100644 --- a/functions.php +++ b/functions.php @@ -264,4 +264,77 @@ function uc_redirect_403() { add_action( 'template_redirect', 'uc_redirect_403' ); -?> \ No newline at end of file + +//==================================================== +// WordPress Link Guessing Option adds a checkbox +// to the Settings page +//==================================================== + +add_action( 'admin_init', 'link_guessing_settings_init' ); + +//==================================================== +// Link Guessing - ON or OFF ? +//==================================================== + +add_action( 'wp_loaded', function () +{ + $checked = get_option( 'link_guessing' ); + if ( empty( $checked ) ){ + remove_filter('template_redirect', 'redirect_canonical'); + }else{ + add_filter('template_redirect', 'redirect_canonical'); + } +}); + +//==================================================== +// Link Guessing init +//==================================================== + +function link_guessing_settings_init(){ + + /* Register Settings */ + register_setting( + 'general', // Options group + 'link_guessing', // Option name/database + 'link_guessing_sanitize' // sanitize callback function + ); + + /* Create settings section */ + add_settings_section( + 'link_guessing_section_id', // Section ID + '', // Section title - leave it blank + null, // Section description callback function - we don't need it + 'general' // Settings page slug + ); + + /* Create settings field */ + add_settings_field( + 'link_guessing_field_id', // Field ID + 'Link Guessing', // Field title + 'link_guessing_field_callback', // Field callback function + 'general', // Settings page slug + 'link_guessing_section_id' // Section ID + ); +} + + //==================================================== +/* Sanitize Callback Function */ +//==================================================== + +function link_guessing_sanitize( $input ){ + return isset( $input ) ? true : false; +} + + //==================================================== +/* Settings Field Callback */ +//==================================================== + +function link_guessing_field_callback(){ + ?> + + \ No newline at end of file From 4674eb7e01de8cf2c859786695128e5d537439a8 Mon Sep 17 00:00:00 2001 From: John Calande Date: Tue, 6 Sep 2016 11:24:59 -0400 Subject: [PATCH 2/3] fix for people grid group layout --- inc/people-grid.php | 17 ++++---- user-people.php | 95 ++++++++++++++++++++++++--------------------- 2 files changed, 61 insertions(+), 51 deletions(-) diff --git a/inc/people-grid.php b/inc/people-grid.php index 98a9cbe..16ccfcd 100644 --- a/inc/people-grid.php +++ b/inc/people-grid.php @@ -1,13 +1,15 @@ have_posts() ) { ?>
"; + + $person_count = 1; while ( $the_query->have_posts() ) { $the_query->the_post(); @@ -16,7 +18,7 @@ if ( $the_query->have_posts() ) { ?> ?> - +
have_posts() ) { ?>
'; } diff --git a/user-people.php b/user-people.php index eea5cf8..149c81b 100644 --- a/user-people.php +++ b/user-people.php @@ -1,8 +1,8 @@ @@ -24,9 +24,10 @@ get_header(); ?> ', '' ); ?>
- -1, @@ -34,12 +35,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,7 +48,7 @@ get_header(); ?> $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)) { @@ -56,24 +57,24 @@ get_header(); ?> echo ''; } }; - - function sort_group_by_order( $a, $b ){ + + 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}" ); + $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}" ); + $array_orderGroupB = get_option( "taxonomy_{$groupB}" ); $orderGroupB = $array_orderGroupB['group_order']; - + $r = strnatcasecmp( $orderGroupA, $orderGroupB ); if( $r === 0 ){ $r = strnatcasecmp( $a, $b ); } - return $r; + return $r; } - + if ($specific_people){ global $specific_people; global $args; @@ -84,20 +85,20 @@ get_header(); ?> } $args[post__in]= $post__in; } - + // do we need a tax query? - if ($specific_groups != false || $specific_tags != false){ - + if ($specific_groups != false || $specific_tags != false){ + $tax_query = array(); - $isTagSet = false; - + $isTagSet = false; + 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; @@ -109,20 +110,20 @@ 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; @@ -133,7 +134,7 @@ get_header(); ?> $slug = $value->slug; $groups_in_use[$slug]= $slug; } - }; + }; } if(!empty($specific_groups) && is_array($specific_groups)){ $groups_in_use = array(); @@ -146,10 +147,15 @@ get_header(); ?> //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. + $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){ - - // 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', @@ -160,33 +166,34 @@ get_header(); ?> 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'); } - + } + } ?> - - + +
From a026959a0cbda64635582e3e86d47cfaab4790f7 Mon Sep 17 00:00:00 2001 From: John Calande Date: Thu, 8 Sep 2016 11:16:40 -0400 Subject: [PATCH 3/3] various fixes --- functions.php | 76 +--------------------- inc/people-grid.php | 154 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 155 insertions(+), 75 deletions(-) create mode 100644 inc/people-grid.php diff --git a/functions.php b/functions.php index d69c2d9..7ea796d 100644 --- a/functions.php +++ b/functions.php @@ -263,78 +263,4 @@ function uc_redirect_403() { } add_action( 'template_redirect', 'uc_redirect_403' ); - - -//==================================================== -// WordPress Link Guessing Option adds a checkbox -// to the Settings page -//==================================================== - -add_action( 'admin_init', 'link_guessing_settings_init' ); - -//==================================================== -// Link Guessing - ON or OFF ? -//==================================================== - -add_action( 'wp_loaded', function () -{ - $checked = get_option( 'link_guessing' ); - if ( empty( $checked ) ){ - remove_filter('template_redirect', 'redirect_canonical'); - }else{ - add_filter('template_redirect', 'redirect_canonical'); - } -}); - -//==================================================== -// Link Guessing init -//==================================================== - -function link_guessing_settings_init(){ - - /* Register Settings */ - register_setting( - 'general', // Options group - 'link_guessing', // Option name/database - 'link_guessing_sanitize' // sanitize callback function - ); - - /* Create settings section */ - add_settings_section( - 'link_guessing_section_id', // Section ID - '', // Section title - leave it blank - null, // Section description callback function - we don't need it - 'general' // Settings page slug - ); - - /* Create settings field */ - add_settings_field( - 'link_guessing_field_id', // Field ID - 'Link Guessing', // Field title - 'link_guessing_field_callback', // Field callback function - 'general', // Settings page slug - 'link_guessing_section_id' // Section ID - ); -} - - //==================================================== -/* Sanitize Callback Function */ -//==================================================== - -function link_guessing_sanitize( $input ){ - return isset( $input ) ? true : false; -} - - //==================================================== -/* Settings Field Callback */ -//==================================================== - -function link_guessing_field_callback(){ - ?> - - \ No newline at end of file +?> \ No newline at end of file diff --git a/inc/people-grid.php b/inc/people-grid.php new file mode 100644 index 0000000..3b0ae02 --- /dev/null +++ b/inc/people-grid.php @@ -0,0 +1,154 @@ +have_posts() ) { ?> +
+ "; + + $person_count = 1; + + while ( $the_query->have_posts() ) { + $the_query->the_post(); + + /*$persons_per_row = get_field( 'persons_per_row' ); + if( empty($persons_per_row) ){ + $persons_per_row = 4; // default is 4 + } + */ + ?> + + + +
+
+ '; + }else{ + echo ''; + } + 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('department', $information_to_display)) { + echo '

'; + $departmentPieces = explode(";", get_field('department')); + foreach( $departmentPieces as $d ){ + echo ( !empty($d) ? "{$d}
": "" ); + } + 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['url']); + 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('campus', $information_to_display)) { + echo '

'; + the_field('campus'); + 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 '

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

'.get_field('url').'

'; + }; ?> +
+
+ +
'; + } + $person_count++; + } //end of posts?> +
+ + \ No newline at end of file