__( 'Primary Menu', 'albinomouse' ),
) );
/**
* Enable support for Post Formats
*/
add_theme_support( 'post-formats', array( 'aside', 'chat', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio' ) );
}
endif; // albinomouse_setup
add_action( 'after_setup_theme', 'albinomouse_setup' );
/**
* Register widgetized area and update sidebar with default widgets
*/
function albinomouse_widgets_init() {
global $options;
register_sidebar( array(
'name' => __( 'Sidebar', 'albinomouse' ),
'id' => 'sidebar-1',
'before_widget' => '',
'before_title' => '
',
) );
if ($options['footer-layout']) {
register_sidebar( array(
'name' => __( 'Footer 1', 'albinomouse' ),
'id' => 'footer-1',
'before_widget' => '',
'before_title' => '',
) );
}
if ($options['footer-layout'] == '2col' || $options['footer-layout'] == '3col' || $options['footer-layout'] == '4col') {
register_sidebar( array(
'name' => __( 'Footer 2', 'albinomouse' ),
'id' => 'footer-2',
'before_widget' => '',
'before_title' => '',
) );
}
if ($options['footer-layout'] == '3col' || $options['footer-layout'] == '4col') {
register_sidebar( array(
'name' => __( 'Footer 3', 'albinomouse' ),
'id' => 'footer-3',
'before_widget' => '',
'before_title' => '',
) );
}
if ($options['footer-layout'] == '4col') {
register_sidebar( array(
'name' => __( 'Footer 4', 'albinomouse' ),
'id' => 'footer-4',
'before_widget' => '',
'before_title' => '',
) );
}
}
add_action( 'widgets_init', 'albinomouse_widgets_init' );
/**
* Enqueue scripts and styles
*/
function albinomouse_scripts() {
wp_enqueue_style( 'albinomouse-style', get_stylesheet_uri() );
wp_enqueue_script( 'bootstrap-scripts', get_template_directory_uri() . '/scripts.js', array('jquery'), '', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'albinomouse_scripts' );
/**
* Overwrite Jetpacks social sharing buttons
*/
if(!isset($options['flat-social-btn']) or $options['flat-social-btn'] == '1') {
function overwrite_jetpack_social_buttons(){
wp_deregister_style('sharedaddy');
wp_enqueue_style( 'flat-social-buttons', get_template_directory_uri() . '/inc/flat-social-buttons/flat-social-buttons.css' );
}
add_action('wp_print_styles', 'overwrite_jetpack_social_buttons');
}
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Custom functions that act independently of the theme templates.
*/
require get_template_directory() . '/inc/extras.php';
/**
* Register Custom Navigation Walker
*/
require get_template_directory() . '/inc/wp_bootstrap_navwalker.php';
/**
* Enqueue stylesheet for Google web fonts
* This function is attached to the wp_head action hook.
*/
function albinomouse_google_web_fonts() {
global $options;
if ($options['title_font'] == 'Anton') {
wp_enqueue_style( 'Anton', 'http://fonts.googleapis.com/css?family=Anton' );
}
if ($options['title_font'] == 'Bitter') {
wp_enqueue_style( 'Bitter', 'http://fonts.googleapis.com/css?family=Bitter' );
}
if ($options['title_font'] == 'Droid Sans' || $options['general_font'] == 'Droid Sans') {
wp_enqueue_style( 'DroidSans', 'http://fonts.googleapis.com/css?family=Droid+Sans:400,700' );
}
if ($options['title_font'] == 'Droid Serif' || $options['general_font'] == 'Droid Serif') {
wp_enqueue_style( 'DroidSerif', 'http://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic,700italic' );
}
if ($options['title_font'] == 'Open Sans' || $options['general_font'] == 'Open Sans') {
wp_enqueue_style( 'OpenSans', 'http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700' );
}
if ($options['title_font'] == 'Source Sans Pro' || $options['general_font'] == 'Source Sans Pro') {
wp_enqueue_style( 'SourceSansPro', 'http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,400italic,700italic' );
}
if ($options['title_font'] == 'Ubuntu' || $options['general_font'] == 'Ubuntu') {
wp_enqueue_style( 'Ubuntu', 'http://fonts.googleapis.com/css?family=Ubuntu:400,700,400italic,700italic' );
}
if ($options['title_font'] == 'Yanone Kaffeesatz') {
wp_enqueue_style( 'YanoneKaffeesatz', 'http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz' );
}
}
add_action( 'wp_enqueue_scripts', 'albinomouse_google_web_fonts' );
/**
* Add a style block with some configurations of the theme options.
* This function is attached to the wp_head action hook.
*/
$originalColor = $options['link_footer_color'];
$d5 = -5;
$d8 = -8;
$d10 = -10;
$d12 = -12;
$d15 = -15;
$l40 = 40;
function colorCreator($color, $per) {
$color = substr( $color, 1 ); // Removes first character of hex string (#)
$rgb = ''; // Empty variable
$per = $per/100*255; // Creates a percentage to work with. Change the middle figure to control color temperature
if ($per < 0 ) // Check to see if the percentage is a negative number
{
// DARKER
$per = abs($per); // Turns Neg Number to Pos Number
for ($x=0;$x<3;$x++)
{
$c = hexdec(substr($color,(2*$x),2)) - $per;
$c = ($c < 0) ? 0 : dechex($c);
$rgb .= (strlen($c) < 2) ? '0'.$c : $c;
}
}
else
{
// LIGHTER
for ($x=0;$x<3;$x++)
{
$c = hexdec(substr($color,(2*$x),2)) + $per;
$c = ($c > 255) ? 'ff' : dechex($c);
$rgb .= (strlen($c) < 2) ? '0'.$c : $c;
}
}
return '#'.$rgb;
}
$color_b40 = colorCreator($originalColor, $l40);
$color_d5 = colorCreator($originalColor, $d5);
$color_d8 = colorCreator($originalColor, $d8);
$color_d10 = colorCreator($originalColor, $d10);
$color_d12 = colorCreator($originalColor, $d12);
$color_d15 = colorCreator($originalColor, $d15);
function albinomouse_add_custom_styles() {
global $options;
global $originalColor;
global $color_b40;
global $color_d5;
global $color_d8;
global $color_d10;
global $color_d12;
global $color_d15;
$header_bg = $options['header-background'];
$footer_cols = $options['footer-layout']; ?>
' . __( "Continue reading", "albinomouse" ) . '';
}
add_filter('excerpt_more', 'excerpt_readmore');
/**
* Display a notice that can be dismissed
*/
add_action('admin_notices', 'albinomouse_200_admin_notice');
function albinomouse_200_admin_notice() {
global $current_user ;
$user_id = $current_user->ID;
/* Check that the user hasn't already clicked to ignore the message */
if ( ! get_user_meta($user_id, 'albinomouse_200_ignore_notice') ) {
echo '';
printf(__('Please check your posts for shortcodes which were available in older versions of the theme AlbinoMouse. The theme guidelines do not allow shortcodes in themes anymore. Hide Notice', 'albinomouse'), '?albinomouse_200_nag_ignore=0');
echo "
";
}
}
add_action('admin_init', 'albinomouse_200_nag_ignore');
function albinomouse_200_nag_ignore() {
global $current_user;
$user_id = $current_user->ID;
/* If user clicks to ignore the notice, add that to their user meta */
if ( isset($_GET['albinomouse_200_nag_ignore']) && '0' == $_GET['albinomouse_200_nag_ignore'] ) {
add_user_meta($user_id, 'albinomouse_200_ignore_notice', 'true', true);
}
}
?>