barebones/functions.php

146 lines
3.4 KiB
PHP
Raw Normal View History

2012-05-29 23:42:46 +02:00
<?php
/**
2014-08-07 11:54:20 +02:00
* Add support for useful stuff
*/
2013-10-11 18:26:23 +02:00
2012-05-29 23:42:46 +02:00
add_theme_support( 'post-thumbnails' );
2012-12-20 22:18:50 +01:00
add_theme_support( 'post-formats', array( 'post' ) );
2012-12-20 22:06:54 +01:00
add_theme_support( 'custom-header' );
2012-12-20 22:18:50 +01:00
add_theme_support( 'custom-background' );
2012-08-24 11:44:15 +02:00
add_post_type_support( 'page', 'excerpt' );
2012-05-29 23:42:46 +02:00
2014-08-07 11:54:20 +02:00
/**
2014-08-07 11:54:20 +02:00
* Remove junk
*/
define( 'ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS', true );
define( 'ICL_DONT_LOAD_LANGUAGES_JS', true );
2014-03-10 11:49:44 +01:00
add_filter('show_admin_bar', '__return_false');
2013-10-11 18:26:23 +02:00
2012-05-29 23:42:46 +02:00
remove_action( 'wp_head', 'rsd_link' );
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'wp_generator' );
remove_action( 'wp_head', 'start_post_rel_link' );
remove_action( 'wp_head', 'index_rel_link' );
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' );
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
2015-04-28 10:58:44 +02:00
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
2012-05-29 23:42:46 +02:00
2014-08-07 11:54:20 +02:00
function barebones_remove_comments_rss( $for_comments ) {
2013-10-11 18:26:23 +02:00
return;
}
2014-08-07 11:54:20 +02:00
add_filter( 'post_comments_feed_link', 'barebones_remove_comments_rss' );
2013-10-11 18:26:23 +02:00
/**
2014-08-07 11:54:20 +02:00
* jQuery the right way
*/
2013-10-11 18:26:23 +02:00
2014-08-07 11:54:20 +02:00
function barebones_scripts() {
2014-08-15 12:43:24 +02:00
/*
* For IE8 to play nice, you'll need to include your CSS here, for example:
*/
// wp_enqueue_style( 'fonts', '//fonts.googleapis.com/css?family=Font+Family' );
2013-08-06 10:24:03 +02:00
wp_deregister_script( 'jquery' );
2015-02-06 11:18:21 +01:00
wp_register_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js', false, '1.11.2', true );
2013-08-06 10:24:03 +02:00
wp_enqueue_script( 'jquery' );
2014-12-08 10:50:55 +01:00
wp_enqueue_script( 'script', get_stylesheet_directory_uri() . '/js/script.min.js', array( 'jquery' ), null, true );
2013-08-06 10:24:03 +02:00
}
2014-08-07 11:54:20 +02:00
add_action( 'wp_enqueue_scripts', 'barebones_scripts' );
2013-08-06 10:24:03 +02:00
/**
2014-08-07 11:54:20 +02:00
* Nav menus
*/
2013-01-01 20:09:48 +01:00
2014-08-07 11:54:20 +02:00
if ( function_exists( 'register_nav_menus' ) ) {
2014-02-21 11:44:42 +01:00
register_nav_menus(array(
2014-05-21 17:32:58 +02:00
'header' => 'Header',
2014-04-08 14:29:05 +02:00
'footer' => 'Footer'
2014-02-21 11:44:42 +01:00
));
2014-08-07 11:54:20 +02:00
}
2014-02-21 11:44:42 +01:00
2014-08-07 11:54:20 +02:00
function barebones_nav_menu_args( $args = '' ) {
2014-02-21 11:44:42 +01:00
$args['container'] = false;
$args['container_class'] = false;
$args['menu_id'] = false;
$args['items_wrap'] = '<ul class="%2$s">%3$s</ul>';
return $args;
}
2014-08-07 11:54:20 +02:00
add_filter( 'wp_nav_menu_args', 'barebones_nav_menu_args' );
/**
2014-08-07 11:54:20 +02:00
* Email
*/
function barebones_mail_from( $email ) {
return get_option( 'admin_email' );
}
2014-08-07 11:54:20 +02:00
add_filter( 'wp_mail_from', 'barebones_mail_from' );
function barebones_mail_from_name( $name ) {
return get_bloginfo( 'name' );
}
add_filter( 'wp_mail_from_name', 'barebones_mail_from_name' );
2015-02-09 15:44:47 +01:00
/**
* Shortcodes ([button] shortcode included)
*/
function button_shortcode( $atts, $content = null ) {
return '<a class="btn" href="' . $atts['link'] . '">' . $content . '</a>';
}
add_shortcode( 'button', 'button_shortcode' );
/**
* TinyMCE
*/
2015-02-09 15:45:53 +01:00
function barebones_mce_buttons_2( $buttons ) {
array_unshift( $buttons, 'styleselect' );
$buttons[] = 'hr';
return $buttons;
}
2015-02-09 15:45:53 +01:00
add_filter( 'mce_buttons_2', 'barebones_mce_buttons_2' );
2015-02-09 15:45:53 +01:00
function barebones_tiny_mce_before_init( $settings ) {
$style_formats = array(
/*
* Example
*
array(
'title' => '',
'selector' => '',
'classes' => ''
) */
);
$settings['style_formats'] = json_encode( $style_formats );
return $settings;
}
2015-02-09 15:45:53 +01:00
add_filter( 'tiny_mce_before_init', 'barebones_tiny_mce_before_init' );
/**
* Get image URL for whatever size.
*/
function wp_get_attachment_image_url( $id, $size = 'full', $attrs = []) {
$image = wp_get_attachment_image_src( $id, $size, $attrs );
return $image[0];
}