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

Commit

Permalink
Cleaning up Functions.php
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmbacon committed Jan 8, 2015
1 parent 6e76a0c commit ccab2d9
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 115 deletions.
135 changes: 20 additions & 115 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function cs_setup() {
'comment-form',
'gallery',
'caption',
'post-thumbnails',
) );
}
endif; // cs_setup
Expand All @@ -79,57 +80,17 @@ function cs_widgets_init() {
/**
* Enqueue scripts and styles.
*/
function cs_scripts() {

wp_enqueue_style( 'cs-glyph', network_home_url().'wp-content/global/glyphicons_pro/glyphicons/web/html_css/css/glyphicons.css');
wp_enqueue_style( 'cs-glyph-filetypes', network_home_url().'wp-content/global/glyphicons_pro/glyphicons_filetypes/web/html_css/css/glyphicons-filetypes.css');
wp_enqueue_style( 'cs-glyph-halflings', network_home_url().'wp-content/global/glyphicons_pro/glyphicons_halflings/web/html_css/css/glyphicons-halflings.css');
wp_enqueue_style( 'cs-glyph-social', network_home_url().'wp-content/global/glyphicons_pro/glyphicons_social/web/html_css/css/glyphicons-social.css');
wp_enqueue_style( 'cs-style', get_stylesheet_uri(), array( 'cs-glyph' ));

wp_enqueue_script( 'cs-bootstrap-js', network_home_url().'wp-content/global/bootstrap-3.2.0-dist/js/bootstrap.min.js', array( 'jquery' ));
wp_enqueue_script( 'cs-modernizr', get_template_directory_uri() . '/js/cs-modernizr.js', array( 'jquery' ));
wp_enqueue_script( 'cs', get_template_directory_uri() . '/js/cs.js', array( 'jquery' ));
wp_enqueue_script( 'cs-navigation', get_template_directory_uri() . '/js/navigation.js', array( 'cs-bootstrap-js'), '20120206', true );
wp_enqueue_script( 'cs-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );

$outboundtracking = get_option( 'outbound_tracking','');
if($outboundtracking == 'yes') wp_enqueue_script('uc-link-tracking', get_bloginfo('template_url').'/js/linktracking.js', array('jquery'));

if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}

add_action( 'wp_enqueue_scripts', 'cs_scripts' );

function htmlShiv(){
$template = get_template_directory_uri();
echo '<!--[if lt IE 9]>
<script src="' . $template . '/js/html5shiv/html5shiv.min.js"></script>
<script src="' . $template . '/js/html5shiv/html5shiv-printshiv.min.js"></script>
<![endif]-->';

//needed for IE7 grid hack
/*echo '<!--[if lt IE 8]>
<link href="'. $template .'/css/bootstrap.css" rel="stylesheet">
<![endif]-->'; */
}
require get_template_directory() . '/inc/scripts-and-styles.php';

add_action( 'wp_head', htmlShiv, 1 );
/**
* Browser hacks
*/
require get_template_directory() . '/inc/ie-hacks.php';

function ieBootstrap(){
$template = get_template_directory_uri();
echo '<!--[if lt IE 9]>
<script src="' . $template . '/js/respond.min.js"></script>
<![endif]-->';
/*
echo '<!--[if lt IE 8]>
<link href="'. $template .'/css/bootstrap-ie7.css.php" rel="stylesheet">
<![endif]-->';
*/
}
add_action( 'wp_head', ieBootstrap, 99 );
/**
* Private Pages
*/
require get_template_directory() . '/inc/private-pages.php';

/**
* Implement the Custom Header feature.
Expand All @@ -151,29 +112,31 @@ function ieBootstrap(){
*/
require get_template_directory() . '/inc/customizer.php';

/**
* Load Jetpack compatibility file.
*/
//require get_template_directory() . '/inc/jetpack.php';


/**
* New versions of functions from Hale, added as includes
*/
require get_template_directory() . '/inc/nav-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';







// Change what's hidden by default
add_filter('default_hidden_meta_boxes', 'be_hidden_meta_boxes', 10, 2);
Expand All @@ -185,64 +148,6 @@ function be_hidden_meta_boxes($hidden, $screen) {
}


function load_custom_wp_admin_style($hook) {
wp_register_style( 'custom_wp_admin_css', get_template_directory_uri() . '/css/admin-style.css', false, '1.0.0' );
wp_enqueue_style( 'custom_wp_admin_css' );


wp_register_script('uc-admin-js', get_template_directory_uri() . '/js/admin-style.js', false, '1.0.0');
wp_enqueue_script('uc-admin-js');

if( 'widgets.php' != $hook )
return;
wp_register_style( 'css-widgets-area', get_template_directory_uri().'/css/widgets-area.php' );
wp_enqueue_style( 'css-widgets-area' );
}
add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );

add_theme_support( 'post-thumbnails' );

//Bootstrap whitelist
function add_allowed_tags($tags) {
$newtags = array(
'div',
'ul',
'li',
'button',
'a');
$newattrs = array(
'data-toggle' => true,
'data-dismiss' => true,
'data-target' => true,
'data-spy' => true,
'data-loading-text' => true,
'data-parent' => true,
'data-slide' => true,
'data-slide-to' => true,
'data-provide' => true,
'data-interval' => true,
'data-pause' => true,
'data-animation' => true,
'data-html' => true,
'data-placement' => true,
'data-selector' => true,
'data-title' => true,
'data-trigger' => true,
'data-delay' => true,
'data-container' => true);

foreach($newtags as $newtag){
if( isset($tags[$newtag]) && is_array($tags[$newtag])){
$tags[$newtag] = array_merge($tags[$newtag], $newattrs);
}
else{
$tags[$newtag] = $newattrs;
}
}

return $tags;
}
add_filter('wp_kses_allowed_html', 'add_allowed_tags');

/*the fallback from wp_nav_menu, we want to replicate the output of wp_page_menu to be similar to wp_nav_menu
@param args, it comes from the wp_nav_menu arguments*/
Expand Down
43 changes: 43 additions & 0 deletions inc/bootstrap-whitelist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
//Bootstrap whitelist
function add_allowed_tags($tags) {
$newtags = array(
'div',
'ul',
'li',
'button',
'a');
$newattrs = array(
'data-toggle' => true,
'data-dismiss' => true,
'data-target' => true,
'data-spy' => true,
'data-loading-text' => true,
'data-parent' => true,
'data-slide' => true,
'data-slide-to' => true,
'data-provide' => true,
'data-interval' => true,
'data-pause' => true,
'data-animation' => true,
'data-html' => true,
'data-placement' => true,
'data-selector' => true,
'data-title' => true,
'data-trigger' => true,
'data-delay' => true,
'data-container' => true);

foreach($newtags as $newtag){
if( isset($tags[$newtag]) && is_array($tags[$newtag])){
$tags[$newtag] = array_merge($tags[$newtag], $newattrs);
}
else{
$tags[$newtag] = $newattrs;
}
}

return $tags;
}
add_filter('wp_kses_allowed_html', 'add_allowed_tags');
?>
30 changes: 30 additions & 0 deletions inc/ie-hacks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
function htmlShiv(){
$template = get_template_directory_uri();
echo '<!--[if lt IE 9]>
<script src="' . $template . '/js/html5shiv/html5shiv.min.js"></script>
<script src="' . $template . '/js/html5shiv/html5shiv-printshiv.min.js"></script>
<![endif]-->';

//needed for IE7 grid hack
/*echo '<!--[if lt IE 8]>
<link href="'. $template .'/css/bootstrap.css" rel="stylesheet">
<![endif]-->'; */
}

add_action( 'wp_head', htmlShiv, 1 );

function ieBootstrap(){
$template = get_template_directory_uri();
echo '<!--[if lt IE 9]>
<script src="' . $template . '/js/respond.min.js"></script>
<![endif]-->';
/*
echo '<!--[if lt IE 8]>
<link href="'. $template .'/css/bootstrap-ie7.css.php" rel="stylesheet">
<![endif]-->';
*/
}
add_action( 'wp_head', ieBootstrap, 99 );

?>
20 changes: 20 additions & 0 deletions inc/private-pages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
// private pages

if(!function_exists('is_parent_private')){
function is_parent_private($id){
$page = get_post($id);
if($page->post_parent > 0){
$parent = get_post($page->post_parent);
$private = get_post_meta($parent->ID, 'uc-private', true);
if($private == 'admins' || $private == 'users' || $private == 'list'){
return $parent->ID;
}
else return is_parent_private($parent->ID);
}
else{
return false;
}
}
}
?>
43 changes: 43 additions & 0 deletions inc/scripts-and-styles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
function cs_scripts() {

wp_enqueue_style( 'cs-glyph', network_home_url().'wp-content/global/glyphicons_pro/glyphicons/web/html_css/css/glyphicons.css');
wp_enqueue_style( 'cs-glyph-filetypes', network_home_url().'wp-content/global/glyphicons_pro/glyphicons_filetypes/web/html_css/css/glyphicons-filetypes.css');
wp_enqueue_style( 'cs-glyph-halflings', network_home_url().'wp-content/global/glyphicons_pro/glyphicons_halflings/web/html_css/css/glyphicons-halflings.css');
wp_enqueue_style( 'cs-glyph-social', network_home_url().'wp-content/global/glyphicons_pro/glyphicons_social/web/html_css/css/glyphicons-social.css');
wp_enqueue_style( 'cs-style', get_stylesheet_uri(), array( 'cs-glyph' ));

wp_enqueue_script( 'cs-bootstrap-js', network_home_url().'wp-content/global/bootstrap-3.2.0-dist/js/bootstrap.min.js', array( 'jquery' ));
wp_enqueue_script( 'cs-modernizr', get_template_directory_uri() . '/js/cs-modernizr.js', array( 'jquery' ));
wp_enqueue_script( 'cs', get_template_directory_uri() . '/js/cs.js', array( 'jquery' ));
wp_enqueue_script( 'cs-navigation', get_template_directory_uri() . '/js/navigation.js', array( 'cs-bootstrap-js'), '20120206', true );
wp_enqueue_script( 'cs-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );

$outboundtracking = get_option( 'outbound_tracking','');
if($outboundtracking == 'yes') wp_enqueue_script('uc-link-tracking', get_bloginfo('template_url').'/js/linktracking.js', array('jquery'));

if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}

add_action( 'wp_enqueue_scripts', 'cs_scripts' );


function load_custom_wp_admin_style($hook) {
wp_register_style( 'custom_wp_admin_css', get_template_directory_uri() . '/css/admin-style.css', false, '1.0.0' );
wp_enqueue_style( 'custom_wp_admin_css' );


wp_register_script('uc-admin-js', get_template_directory_uri() . '/js/admin-style.js', false, '1.0.0');
wp_enqueue_script('uc-admin-js');

if( 'widgets.php' != $hook )
return;
wp_register_style( 'css-widgets-area', get_template_directory_uri().'/css/widgets-area.php' );
wp_enqueue_style( 'css-widgets-area' );
}
add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );


?>

0 comments on commit ccab2d9

Please sign in to comment.