Skip to content

Commit

Permalink
Fixes for the customizer, footer, and front page
Browse files Browse the repository at this point in the history
  • Loading branch information
priscillamc committed Apr 29, 2019
1 parent 6890b23 commit 73aac62
Show file tree
Hide file tree
Showing 9 changed files with 369 additions and 50 deletions.
31 changes: 31 additions & 0 deletions assets/js/skip-link-focus-fix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* File skip-link-focus-fix.js.
*
* Helps with accessibility for keyboard only users.
*
* Learn more: https://git.io/vWdr2
*/
(function() {
var isIe = /(trident|msie)/i.test( navigator.userAgent );

if ( isIe && document.getElementById && window.addEventListener ) {
window.addEventListener( 'hashchange', function() {
var id = location.hash.substring( 1 ),
element;

if ( ! ( /^[A-z0-9_-]+$/.test( id ) ) ) {
return;
}

element = document.getElementById( id );

if ( element ) {
if ( ! ( /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) ) {
element.tabIndex = -1;
}

element.focus();
}
}, false );
}
})();
2 changes: 1 addition & 1 deletion assets/js/theme.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

// Theme Custom JS

var e = document.getElementsByClassName("X-tile");
var sublist;
Expand Down
35 changes: 17 additions & 18 deletions footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
</div>

<?php
$s = get_theme_mods();
if ( !empty($s['dept_address']) ):
if ( !empty(get_theme_mod('dept_address')) ):
echo '<p class="footer-clas-address">';
echo esc_html( $s['dept_address'] );
echo esc_html( get_theme_mod('dept_address') );
echo '</p>';
else :
?>
Expand Down Expand Up @@ -134,32 +133,32 @@
<ul class="social-nav">
<?php
// Get all the social media links. These are set on the CLAS DEPT Theme Settings page
if ( !empty($s['fb']) ):
echo '<li><a href="' . esc_url($s['fb']) . '" class=" icon-svg icon-social-media icon-facebook" target="_blank">' . twentyseventeen_get_svg( array( 'icon_id' => 'facebook' )) . '<span class="SVGaltText">Share this page on Facebook</span></a></li>';
if ( !empty(get_theme_mod('fb')) ):
echo '<li><a href="' . esc_url(get_theme_mod('fb')) . '" class=" icon-svg icon-social-media icon-facebook" target="_blank">' . twentyseventeen_get_svg( array( 'icon_id' => 'facebook' )) . '<span class="SVGaltText">Share this page on Facebook</span></a></li>';
endif;

if ( !empty($s['twitter']) ):
echo '<li><a href="' . esc_url( $s['twitter'] ) . '" class=" icon-svg icon-social-media icon-twitter" target="_blank">' . twentyseventeen_get_svg( array( 'icon_id' => 'twitter' )) . '<span class="SVGaltText">Share this page on Twitter</span></a></li>';
if ( !empty(get_theme_mod('twitter')) ):
echo '<li><a href="' . esc_url( get_theme_mod('twitter') ) . '" class=" icon-svg icon-social-media icon-twitter" target="_blank">' . twentyseventeen_get_svg( array( 'icon_id' => 'twitter' )) . '<span class="SVGaltText">Share this page on Twitter</span></a></li>';
endif;

if ( !empty($s['instagram']) ):
echo '<li><a href="' . esc_url( $s['instagram'] ) . '" class=" icon-svg icon-social-media icon-instagram" target="_blank">' . twentyseventeen_get_svg( array( 'icon_id' => 'instagram' )) . '<span class="SVGaltText">Share this page on Instagram</span></a></li>';
if ( !empty(get_theme_mod('instagram')) ):
echo '<li><a href="' . esc_url( get_theme_mod('instagram') ) . '" class=" icon-svg icon-social-media icon-instagram" target="_blank">' . twentyseventeen_get_svg( array( 'icon_id' => 'instagram' )) . '<span class="SVGaltText">Share this page on Instagram</span></a></li>';
endif;

if ( !empty($s['youtube']) ):
echo '<li><a href="' . esc_url( $s['youtube'] ) . '" class=" icon-svg icon-social-media icon-youtube" target="_blank">' . twentyseventeen_get_svg( array( 'icon_id' => 'youtube' )) . '<span class="SVGaltText">Share this page on YouTube</span></a></li>';
if ( !empty(get_theme_mod('youtube')) ):
echo '<li><a href="' . esc_url( get_theme_mod('youtube') ) . '" class=" icon-svg icon-social-media icon-youtube" target="_blank">' . twentyseventeen_get_svg( array( 'icon_id' => 'youtube' )) . '<span class="SVGaltText">Share this page on YouTube</span></a></li>';
endif;

if ( !empty($s['rss']) ):
echo '<li><a href="' . esc_url( $s['rss'] ) . '" class=" icon-svg icon-social-media icon-rss" target="_blank">' . twentyseventeen_get_svg( array( 'icon_id' => 'rss' )) . '<span class="SVGaltText">RSS Feed</span></a></li>';
if ( !empty(get_theme_mod('rss')) ):
echo '<li><a href="' . esc_url( get_theme_mod('rss') ) . '" class=" icon-svg icon-social-media icon-rss" target="_blank">' . twentyseventeen_get_svg( array( 'icon_id' => 'rss' )) . '<span class="SVGaltText">RSS Feed</span></a></li>';
endif;

if ( !empty($s['email']) ):
echo '<li><a href="' . esc_url( $s['email'] ) . '" class=" icon-svg icon-social-media icon-email" target="_blank">' . twentyseventeen_get_svg( array( 'icon_id' => 'icon-footer-email' )) . '<span class="SVGaltText">Contact <abbr title="College of Liberal Arts and Sciences">CLAS</abbr></span></a></li>';
if ( !empty(get_theme_mod('email')) ):
echo '<li><a href="mailto:' . esc_attr( get_theme_mod('email') ) . '" class=" icon-svg icon-social-media icon-email" target="_blank">' . twentyseventeen_get_svg( array( 'icon_id' => 'icon-footer-email' )) . '<span class="SVGaltText">Contact <abbr title="College of Liberal Arts and Sciences">CLAS</abbr></span></a></li>';
endif;

if ( !empty($s['linkedin']) ):
echo '<li><a href="' . esc_url( $s['linkedin'] ) . '" class=" icon-svg icon-social-media icon-linkedin" target="_blank">' . twentyseventeen_get_svg( array( 'icon_id' => 'icon-footer-linkedin' )) . '<span class="SVGaltText"><abbr title="College of Liberal Arts and Sciences">CLAS</abbr> LinkedIn Profile</span></a></li>';
if ( !empty(get_theme_mod('linkedin')) ):
echo '<li><a href="' . esc_url( get_theme_mod('linkedin') ) . '" class=" icon-svg icon-social-media icon-linkedin" target="_blank">' . twentyseventeen_get_svg( array( 'icon_id' => 'icon-footer-linkedin' )) . '<span class="SVGaltText"><abbr title="College of Liberal Arts and Sciences">CLAS</abbr> LinkedIn Profile</span></a></li>';
endif;

?>
Expand All @@ -181,7 +180,7 @@
<div class="footer-uf-wrap">
<div class="footer-uf-col-1 bottom-links">
<p>
&#169; 2018 University of Florida | <a href ="//assistive.usablenet.com/tt/referrer"> Text-only </a> | <a href="mailto:[email protected]"> Website Feedback</a> | <a href ="http://privacy.ufl.edu/privacy-policies-and-procedures/onlineinternet-privacy-statement"> UF Privacy Policy </a>
&#169; <?php echo current_time('Y'); ?> University of Florida | <a href ="//assistive.usablenet.com/tt/referrer"> Text-only </a> | <a href="mailto:[email protected]"> Website Feedback</a> | <a href ="http://privacy.ufl.edu/privacy-policies-and-procedures/onlineinternet-privacy-statement"> UF Privacy Policy </a>
</p>

</div>
Expand Down
9 changes: 7 additions & 2 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function ufclas_emily_X_theme_setup() {
'width' => 980,
'flex-height' => true,
'height' => 200,
'default-image' => get_template_directory_uri() . 'assets/images/header.jpg',
'default-image' => get_template_directory_uri() . '/assets/images/header.jpg',
);
add_theme_support( 'custom-header', $args );

Expand Down Expand Up @@ -833,6 +833,11 @@ function ufclas_emily_jquery_migrate( $scripts ) {
add_action( 'wp_default_scripts', 'ufclas_emily_jquery_migrate' );

/**
* Implement the Custom Header feature.
* Moves theme options to Appearance > Customizer
*/
require get_theme_file_path( '/inc/customizer-options.php' );

/**
* Includes theme options for backwards compatibility, can be removed
*/
require get_theme_file_path( '/inc/settings-options.php' );
41 changes: 15 additions & 26 deletions inc/customizer-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,31 @@
*
*/

function ufclas_emily_default_option( $key, $defaults = array() ){
$default_value = '';
if ( !empty($defaults) && isset( $defaults[$key] ) ){
$default_value = $defaults[$key];
}
return $default_value;
}

/**
* Add custom theme mods to the Customizer
*
* @since 1.9.2
* @author priscillamc
*/
function ufclas_emily_customize_register( $wp_customize ) {

// Use the deprecated settings values as defaults for theme_mods
$defaults = get_option('my_option_name');


// Add a Theme Option panel for backwards compatibility
$wp_customize->add_panel( 'ufclas_emily_theme_options', array(
'title' => __('CLAS DEPT Theme Settings', 'ufclas-emily'),
'title' => __('CLAS DEPT Theme Options', 'ufclas-emily'),
'description' => __('Options for modifying the theme.', 'ufclas-emily'),
'priority' => '129',
));

// General
$wp_customize->add_section( 'theme_options_general', array(
'title' => __('General', 'ufclas-emily'),
'title' => __('General', 'ufclas-emily'),
'description' => __('', 'ufclas-emily'),
'panel' => 'ufclas_emily_theme_options',
));

$wp_customize->add_setting( 'dept_address', array( 'default' => ufclas_emily_default_option( 'dept_address', $defaults ), 'sanitize_callback' => 'sanitize_textarea_field' ));
$wp_customize->add_setting( 'title', array( 'default' => ufclas_emily_default_option( 'title', $defaults ), 'sanitize_callback' => 'sanitize_text_field' ));
$wp_customize->add_setting( 'dept_address', array( 'default' => '', 'sanitize_callback' => 'sanitize_textarea_field' ));
$wp_customize->add_setting( 'title', array( 'default' => '', 'sanitize_callback' => 'sanitize_text_field' ));


$wp_customize->add_control( 'dept_address', array(
Expand All @@ -55,23 +45,22 @@ function ufclas_emily_customize_register( $wp_customize ) {
'type' => 'text',
));


// Social
$wp_customize->add_section( 'ufclas_emily_theme_options_social', array(
'title' => __('Social Media', 'ufclas-emily'),
'description' => __("Enter your organization's social media URLs (e.g. https://...). Social media icons are displayed in the footer", 'ufclas-emily'),
'description' => __("Enter your organization's social media URLs. Social media icons are displayed in the footer", 'ufclas-emily'),
'panel' => 'ufclas_emily_theme_options',
));

$wp_customize->add_setting( 'fb', array( 'default' => ufclas_emily_default_option( 'fb', $defaults ), 'sanitize_callback' => 'esc_url_raw' ));
$wp_customize->add_setting( 'twitter', array( 'default' => ufclas_emily_default_option( 'twitter', $defaults ), 'sanitize_callback' => 'esc_url_raw' ));
$wp_customize->add_setting( 'instagram', array( 'default' => ufclas_emily_default_option( 'instagram', $defaults ), 'sanitize_callback' => 'esc_url_raw' ));
$wp_customize->add_setting( 'youtube', array( 'default' => ufclas_emily_default_option( 'youtube', $defaults ), 'sanitize_callback' => 'esc_url_raw' ));
$wp_customize->add_setting( 'rss', array( 'default' => ufclas_emily_default_option( 'rss', $defaults ), 'sanitize_callback' => 'esc_url_raw' ));
$wp_customize->add_setting( 'email', array( 'default' => ufclas_emily_default_option( 'email', $defaults ), 'sanitize_callback' => 'sanitize_email' ));
$wp_customize->add_setting( 'linkedin', array( 'default' => ufclas_emily_default_option( 'linkedin', $defaults ), 'sanitize_callback' => 'esc_url_raw' ));
$wp_customize->add_setting( 'fb', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw' ));
$wp_customize->add_setting( 'twitter', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw' ));
$wp_customize->add_setting( 'instagram', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw' ));
$wp_customize->add_setting( 'youtube', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw' ));
$wp_customize->add_setting( 'rss', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw' ));
$wp_customize->add_setting( 'email', array( 'default' => '', 'sanitize_callback' => 'sanitize_email' ));
$wp_customize->add_setting( 'linkedin', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw' ));

$wp_customize->add_control( 'facebook', array(
$wp_customize->add_control( 'fb', array(
'label' => __('Facebook URL', 'ufclas-emily'),
'description' => __("", 'ufclas-emily'),
'section' => 'ufclas_emily_theme_options_social',
Expand Down Expand Up @@ -102,7 +91,7 @@ function ufclas_emily_customize_register( $wp_customize ) {
'type' => 'text',
));
$wp_customize->add_control( 'email', array(
'label' => __('Blog or Feed URL', 'ufclas-emily'),
'label' => __('Email', 'ufclas-emily'),
'description' => __("", 'ufclas-emily'),
'section' => 'ufclas_emily_theme_options_social',
'type' => 'text',
Expand Down
Loading

0 comments on commit 73aac62

Please sign in to comment.