Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
business/functions.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
241 lines (203 sloc)
7.92 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* | |
* functions.php | |
This is the functions.php files. If for whatever reason you would like to input new functions into cornerstone or tweak ones that are already created (view original theme for more information) you can use this functions.php to overwrite it. ' | |
* | |
*/ | |
// Any custom js or css - Code to make your javascript work with the theme. | |
function starterkit_scripts() { | |
wp_enqueue_style( 'executive-css', get_stylesheet_directory_uri() . '/css/executive.css'); | |
wp_enqueue_script( 'starterkit-js', get_stylesheet_directory_uri() . '/javascripts/executive.js', array( 'jquery' )); | |
wp_enqueue_script( 'business-network-ga', get_stylesheet_directory_uri() . '/javascripts/business-network-ga.js', array( 'jquery' )); | |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); | |
$maxMegaMenuActive = is_plugin_active('megamenu/megamenu.php'); | |
if ($maxMegaMenuActive){ | |
wp_dequeue_style( 'cs-megamenu' ); | |
wp_enqueue_style( 'business-megamenu', get_stylesheet_directory_uri(). '/css/business-mega-menu.css', array( 'cs-style' )); | |
}; | |
} | |
add_action( 'wp_enqueue_scripts', 'starterkit_scripts', 99); | |
// Replaces the excerpt "more" text by a link | |
function new_excerpt_more($more) { | |
global $post; | |
return '... <a class="moretag" href="'. get_permalink($post->ID) . '">Continue Reading</a>'; | |
} | |
add_filter('excerpt_more', 'new_excerpt_more'); | |
add_filter( 'the_content_more_link', 'modify_read_more_link' ); | |
function modify_read_more_link() { | |
return '<a class="moretag" href="'. get_permalink($post->ID) . '">Continue Reading</a>'; | |
} | |
function sherman_remove_theme_features() { | |
remove_theme_support( 'custom-header' ); | |
remove_theme_support( 'custom-background' ); | |
// remove_theme_support( 'post-formats' ); | |
} | |
add_action( 'init', 'sherman_remove_theme_features' ); | |
function sherman_customize_register( $wp_customize ) { | |
$wp_customize->remove_section('colors'); | |
$wp_customize->remove_section('background_image'); | |
$wp_customize->remove_section('nav'); | |
} | |
add_action( 'customize_register', 'sherman_customize_register' ); | |
function executive_header_split( $wp_customize ){ | |
$wp_customize->add_setting( 'titlesplit', //Give it a SERIALIZED name (so all theme settings can live under one db record) | |
array( | |
'default' => '3_9', //Default setting/value to save | |
'type' => 'theme_mod', //Is this an 'option' or a 'theme_mod'? | |
'capability' => 'edit_theme_options', //Optional. Special permissions for accessing this setting. | |
'transport' => 'refresh', //What triggers a refresh of the setting? 'refresh' or 'postMessage' (instant)? | |
) | |
); | |
$wp_customize->add_control('titlesplit', array( | |
'type' => 'select', | |
'label' => 'Title / Navigation Split', | |
'section' => 'title_tagline', | |
'choices' => array( | |
'3_9' =>'3/9', | |
'4_8' =>'4/8', | |
'6_6' =>'6/6', | |
'12_12' =>'2row' | |
) | |
) | |
); | |
} | |
add_action( 'customize_register', 'executive_header_split' ); | |
/* | |
add_filter('megamenu_nav_menu_args ', 'my_megamenu_nav_menu_args '); | |
function my_megamenu_nav_menu_args($defaults, $menu_id, $current_theme_location) { | |
$defaults = array( | |
'menu' => $menu_id, | |
'container' => 'div', | |
'container_class' => 'mega-menu-wrap', | |
'container_id' => 'mega-menu-wrap-' . $sanitized_location, | |
'menu_class' => 'mega-menu mega-menu-horizontal', | |
'menu_id' => 'mega-menu-' . $sanitized_location, | |
'fallback_cb' => 'wp_page_menu', | |
'before' => '', | |
'after' => '', | |
'link_before' => '', | |
'link_after' => '', | |
'items_wrap' => '<h1>HELLO FILTERS</h1><ol' . $attributes . '>%3$s</ol>', | |
'depth' => 0, | |
'walker' => new Mega_Menu_Walker() | |
); | |
$array = array($defaults, $menu_id,$current_theme_location); | |
return $array; | |
} | |
*/ | |
function executive_breadcrumbs(){ | |
$thisID = get_the_ID(); | |
$ancestors = get_ancestors($thisID, 'page'); | |
$ancestors = array_reverse($ancestors); | |
if ($ancestors) { | |
echo '<ol class="breadcrumb">'; | |
if (wp_get_nav_menu_object('precrumbs')){ | |
$defaults = array( | |
'menu' => 'Precrumbs', | |
'container' => false, | |
'items_wrap' => '%3$s', | |
'depth' => 1, | |
'fallback_cb' => false | |
); | |
wp_nav_menu( $defaults ); | |
} | |
foreach ($ancestors as &$ancestor) { | |
$ancestor_link = get_permalink($ancestor); | |
$ancestor_title = get_the_title($ancestor); | |
echo '<li><a href="'.$ancestor_link.'">'.$ancestor_title.'</a></li>'; | |
} | |
echo '<li class="active">'.get_the_title().'</li>'; | |
echo '</ol>'; | |
} | |
} | |
function press_link($id){ | |
$presslink = ''; | |
$external_link = get_post_meta( $id, 'external_link'); | |
$external_link = $external_link[0]; | |
if ($external_link){ | |
$presslink = $external_link; | |
} else { | |
$presslink = get_the_permalink(); | |
} | |
return $presslink; | |
} | |
function press_source($id){ | |
$src = get_post_meta( $id, 'story_source'); | |
if ($src[0]){ | |
echo '<p class="text-muted press-source">'.$src[0].'</p>'; | |
} | |
} | |
if ( ! function_exists( 'bus_posted_on' ) ) : | |
/** | |
* Prints HTML with meta information for the current post-date/time and author. | |
*/ | |
function bus_posted_on($categories) { | |
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>'; | |
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { | |
$time_string .= '<time class="updated" datetime="%3$s">%4$s</time>'; | |
} | |
$time_string = sprintf( $time_string, | |
esc_attr( get_the_date( 'c' ) ), | |
esc_html( get_the_date() ), | |
esc_attr( get_the_modified_date( 'c' ) ), | |
esc_html( get_the_modified_date() ) | |
); | |
$authors = array(); | |
foreach($categories as $cat){ | |
$parent = get_category($cat->parent); | |
if($parent->slug == 'authors'){ | |
$authors[] = '<a href="'.esc_url( get_category_link($cat->term_id) ).'" title="'.$cat->name.'">'.$cat->name.'</a>'; | |
} | |
} | |
if(count($authors) > 0){ | |
$by = implode(', ', $authors); | |
} | |
else { | |
$by = sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s">%2$s</a></span>', | |
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), | |
esc_html( get_the_author() ) | |
); | |
} | |
printf( __( '<span class="posted-on">Posted on %1$s</span><span class="byline"> by %2$s</span>', 'cs' ), | |
sprintf( '<a href="%1$s" rel="bookmark">%2$s</a>', | |
esc_url( get_permalink() ), | |
$time_string | |
), | |
$by | |
); | |
} | |
endif; | |
add_filter('protected_title_format', 'protected_wrapper'); | |
function protected_wrapper($title) { | |
return '<span class="glyphicons glyphicons-lock"></span>%s'; | |
} | |
function fb_opengraph() { | |
global $post; | |
if(is_single()) { | |
if(has_post_thumbnail($post->ID)) { | |
$img_src = wp_get_attachment_image_src(get_post_thumbnail_id( $post->ID ), 'medium'); | |
$img_src = $img_src[0]; | |
} | |
if($excerpt = $post->post_excerpt) { | |
$excerpt = strip_tags($post->post_excerpt); | |
$excerpt = str_replace("", "'", $excerpt); | |
} else { | |
$excerpt = get_bloginfo('description'); | |
} | |
$facebookshareline = get_post_meta( $post->ID, 'facebookshareline', true); | |
if(empty($facebookshareline)) $facebookshareline = get_the_title(); | |
?> | |
<meta property="og:title" content="<?php echo $facebookshareline; ?>"/> | |
<meta property="og:description" content="<?php echo $excerpt; ?>"/> | |
<meta property="og:type" content="article"/> | |
<meta property="og:url" content="<?php echo the_permalink(); ?>"/> | |
<meta property="og:site_name" content="<?php echo get_bloginfo(); ?>"/> | |
<meta property="og:image" content="<?php echo $img_src; ?>"/> | |
<?php | |
} else { | |
return; | |
} | |
} | |
add_action('wp_head', 'fb_opengraph', 5); | |
?> |