Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
master
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
<?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 '...&nbsp; <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);
add_action( 'admin_init', 'retargeting_settings' );
//====================================================
// Link Guessing init
//====================================================
function retargeting_settings(){
/* Register Settings */
register_setting(
'general', // Options group
'retargeting_settings', // Option name/database
'retargeting_settings_sanitize' // sanitize callback function
);
/* Create settings section */
add_settings_section(
'retargeting_settings_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(
'retargeting_settings_field_id', // Field ID
'Retargeting', // Field title
'retargeting_settings_field_callback', // Field callback function
'general', // Settings page slug
'retargeting_settings_section_id' // Section ID
);
}
function retargeting_settings_sanitize( $input ){
return isset( $input ) ? true : false;
}
function retargeting_settings_field_callback(){
?>
<label for="retargeting_settings">
<?php
$checked = get_option( 'retargeting_settings' );
?>
<input id="retargeting_settings" type="checkbox" name="retargeting_settings" value="disabled" <?php checked($checked) ?>> Enable Retargeting
</label>
<?php
}
add_action('wp_head','retargeting_js');
function retargeting_js() {
$checked = get_option( 'retargeting_settings' );
if ( !empty( $checked ) ){
?>
<script type="text/javascript">
window._s4mq = (typeof _s4mq != "undefined")? _s4mq : [];
(function() {
var t='undefined'!=typeof _s4mq && _s4mq.length ? _s4mq[0][1].trackId:'undefined',
y='site', l=(window.location != window.parent.location) ? document.referrer:
document.location, s=/s4m_id=.+/.exec(l);
if (s) {y= (z=/tt%3D([a-z]+)/i.exec(l)) ? z[1]:y; t=
(u=/tid%3D([a-z0-9]+)/i.exec(l)) ? u[1]:t;}
var s4mScript = document.createElement('script'); s4mScript.type =
'text/javascript'; s4mScript.async = true;
s4mScript.src = ('https:' == document.location.protocol ? 'https' :
'http')+'://us-ma.sam4m.com/2.0/'+y+'/'+t+'/analytics/sa.js';
var s4mElement = document.getElementsByTagName('script')[0];
s4mElement.parentNode.insertBefore(s4mScript, s4mElement);
})();
window.setTimeout(function() {
_s4mq.push(['trackAction', {name: 'temps passe 6sec', uri:'/home/article/1'}]);
}, 6000);
window.setTimeout(function() {
_s4mq.push(['trackAction', {name: 'temps passe 9sec', uri:'/home/article/1'}]);
}, 9000);
window.setTimeout(function() {
_s4mq.push(['trackAction', {name: 'temps passe 12sec', uri:'/home/article/1'}]);
}, 12000);
</script>
<?php
}
}
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array (
'key' => 'group_5984832e0ffd2',
'title' => 'Sharelines',
'fields' => array (
array (
'key' => 'field_598483a2ea9d9',
'label' => 'Sharelines',
'name' => 'enable_sharelines',
'type' => 'radio',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'choices' => array (
'enabled' => 'Enabled',
'disabled' => 'Disabled',
),
'allow_null' => 0,
'other_choice' => 0,
'save_other_choice' => 0,
'default_value' => 'enabled',
'layout' => 'vertical',
'return_format' => 'value',
),
array (
'key' => 'field_5984833d3f3d8',
'label' => 'Twitter Shareline',
'name' => 'twittershareline',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
array (
'key' => 'field_5984836ecceb4',
'label' => 'Facebook Shareline',
'name' => 'facebookshareline',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
array (
'key' => 'field_5984837ecceb5',
'label' => 'Linkedin Shareline',
'name' => 'linkedinshareline',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'post',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => 1,
'description' => '',
));
endif;
function retargeting_footer() {
echo '<!-- Segment Pixel - Maki_ UCONN_EMBA_RT - DO NOT MODIFY -->
<img src="https://secure.adnxs.com/seg?add=10046298&t=2" width="1" height="1" />
<!-- End of Segment Pixel -->
<!-- Conversion Pixel - Maki_ UCONN_EMBA_CONV - DO NOT MODIFY -->
<img src="https://secure.adnxs.com/px?id=894729&t=2" width="1" height="1" />
<!-- End of Conversion Pixel -->
<!-- Conversion Pixel - Maki_ UCONN_EMBA_ENG - DO NOT MODIFY -->
<img src="https://secure.adnxs.com/px?id=894730&t=2" width="1" height="1" />
<!-- End of Conversion Pixel -->
<div id="ttdUniversalPixelTage726fe5fee41447581c154ddfccda9bb" style="display:none">
<script src="https://js.adsrvr.org/up_loader.1.1.0.js" type="text/javascript"></script>
<script type="text/javascript">
(function(global) {
if (typeof TTDUniversalPixelApi === \'function\') {
var universalPixelApi = new TTDUniversalPixelApi();
universalPixelApi.init("kdygmpk", ["yw6wjla"], "https://insight.adsrvr.org/track/up", "ttdUniversalPixelTage726fe5fee41447581c154ddfccda9bb");
}
})(this);
</script>
</div>';
}
add_action( 'wp_footer', 'retargeting_footer', 100 );
?>