2012-05-29 23:42:46 +02:00
|
|
|
<?php
|
|
|
|
|
2015-10-15 18:24:32 +02:00
|
|
|
/**
|
|
|
|
* Custom functions / External files
|
|
|
|
*/
|
2017-01-12 16:50:14 +01:00
|
|
|
require_once 'includes/functions.php';
|
2015-10-19 12:54:53 +02:00
|
|
|
|
2015-10-15 18:24:32 +02:00
|
|
|
|
|
|
|
|
2015-02-09 15:44:12 +01:00
|
|
|
/**
|
2014-08-07 11:54:20 +02:00
|
|
|
* Add support for useful stuff
|
|
|
|
*/
|
2016-08-09 14:22:26 +02:00
|
|
|
if (function_exists('add_theme_support')) {
|
2015-10-23 11:00:28 +02:00
|
|
|
// Add support for document title tag
|
2016-08-09 14:22:26 +02:00
|
|
|
add_theme_support('title-tag');
|
2015-10-23 11:00:28 +02:00
|
|
|
|
2015-10-15 18:24:32 +02:00
|
|
|
// Add Thumbnail Theme Support
|
2016-08-09 14:22:26 +02:00
|
|
|
add_theme_support('post-thumbnails');
|
2017-01-12 16:50:14 +01:00
|
|
|
|
|
|
|
// Add image sizes
|
2016-08-09 14:22:26 +02:00
|
|
|
// add_image_size( 'custom-size', 700, 200, true );
|
2012-05-29 23:42:46 +02:00
|
|
|
|
2015-10-15 18:24:32 +02:00
|
|
|
// Add Support for post formats
|
2016-04-19 13:27:54 +02:00
|
|
|
// add_theme_support( 'post-formats', ['post'] );
|
2015-10-19 12:54:53 +02:00
|
|
|
// add_post_type_support( 'page', 'excerpt' );
|
2015-10-15 18:24:32 +02:00
|
|
|
|
|
|
|
// Localisation Support
|
2016-08-09 14:22:26 +02:00
|
|
|
load_theme_textdomain('barebones', get_template_directory() . '/languages');
|
2015-10-15 18:24:32 +02:00
|
|
|
}
|
2014-08-07 11:54:20 +02:00
|
|
|
|
2015-10-14 12:10:55 +02:00
|
|
|
|
2015-10-19 12:54:53 +02:00
|
|
|
|
2015-02-09 15:44:12 +01:00
|
|
|
/**
|
2014-08-07 11:54:20 +02:00
|
|
|
* Remove junk
|
|
|
|
*/
|
2016-04-19 13:27:54 +02:00
|
|
|
|
2016-08-09 14:22:26 +02:00
|
|
|
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
|
|
|
|
2016-08-09 14:22:26 +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);
|
|
|
|
remove_action('wp_head', 'print_emoji_detection_script', 7);
|
|
|
|
remove_action('wp_print_styles', 'print_emoji_styles');
|
|
|
|
|
|
|
|
function barebones_remove_comments_rss($for_comments)
|
2015-10-15 18:24:32 +02:00
|
|
|
{
|
2013-10-11 18:26:23 +02:00
|
|
|
return;
|
|
|
|
}
|
2016-08-09 14:22:26 +02:00
|
|
|
add_filter('post_comments_feed_link', 'barebones_remove_comments_rss');
|
2014-08-07 11:54:20 +02:00
|
|
|
|
2013-10-11 18:26:23 +02:00
|
|
|
|
2015-10-19 12:54:53 +02:00
|
|
|
|
2015-02-09 15:44:12 +01:00
|
|
|
/**
|
2014-08-07 11:54:20 +02:00
|
|
|
* jQuery the right way
|
|
|
|
*/
|
2013-10-11 18:26:23 +02:00
|
|
|
|
2016-04-19 13:27:54 +02:00
|
|
|
function barebones_scripts()
|
2015-10-15 18:24:32 +02:00
|
|
|
{
|
2015-10-19 12:54:53 +02:00
|
|
|
// wp_enqueue_style( 'fonts', '//fonts.googleapis.com/css?family=Font+Family' );
|
2016-05-11 17:40:21 +02:00
|
|
|
// wp_enqueue_style( 'icons', '//maxcdn.bootstrapcdn.com/font-awesome/4.6.0/css/font-awesome.min.css' );
|
2017-01-12 16:50:14 +01:00
|
|
|
wp_enqueue_script('script', get_stylesheet_directory_uri() . '/js/script.min.js?' . time(), [], null, true);
|
2013-08-06 10:24:03 +02:00
|
|
|
}
|
2016-08-09 14:22:26 +02:00
|
|
|
add_action('wp_enqueue_scripts', 'barebones_scripts');
|
2014-08-07 11:54:20 +02:00
|
|
|
|
2013-08-06 10:24:03 +02:00
|
|
|
|
2015-10-14 12:10:55 +02:00
|
|
|
|
2015-02-09 15:44:12 +01:00
|
|
|
/**
|
2014-08-07 11:54:20 +02:00
|
|
|
* Nav menus
|
|
|
|
*/
|
2013-01-01 20:09:48 +01:00
|
|
|
|
2016-08-09 14:22:26 +02:00
|
|
|
if (function_exists('register_nav_menus')) {
|
2015-10-14 12:10:55 +02:00
|
|
|
register_nav_menus([
|
|
|
|
'header' => 'Header',
|
|
|
|
'footer' => 'Footer'
|
|
|
|
]);
|
2014-08-07 11:54:20 +02:00
|
|
|
}
|
2014-02-21 11:44:42 +01:00
|
|
|
|
2016-08-09 14:22:26 +02:00
|
|
|
function barebones_nav_menu_args($args = '')
|
2015-10-15 18:24:32 +02:00
|
|
|
{
|
2015-10-14 12:10:55 +02:00
|
|
|
$args['container'] = false;
|
|
|
|
$args['container_class'] = false;
|
|
|
|
$args['menu_id'] = false;
|
|
|
|
$args['items_wrap'] = '<ul class="%2$s">%3$s</ul>';
|
2015-10-15 18:24:32 +02:00
|
|
|
|
2015-10-14 12:10:55 +02:00
|
|
|
return $args;
|
2014-02-21 11:44:42 +01:00
|
|
|
}
|
2016-08-09 14:22:26 +02:00
|
|
|
add_filter('wp_nav_menu_args', 'barebones_nav_menu_args');
|
2014-08-07 11:54:20 +02:00
|
|
|
|
|
|
|
|
2015-10-14 12:10:55 +02:00
|
|
|
|
2015-02-09 15:44:12 +01:00
|
|
|
/**
|
2014-08-07 11:54:20 +02:00
|
|
|
* Email
|
|
|
|
*/
|
|
|
|
|
2016-08-09 14:22:26 +02:00
|
|
|
function barebones_mail_from($email)
|
2015-10-15 18:24:32 +02:00
|
|
|
{
|
2016-08-09 14:22:26 +02:00
|
|
|
return get_option('admin_email');
|
2014-08-07 11:54:20 +02:00
|
|
|
}
|
2016-08-09 14:22:26 +02:00
|
|
|
add_filter('wp_mail_from', 'barebones_mail_from');
|
2014-08-07 11:54:20 +02:00
|
|
|
|
2015-10-14 12:10:55 +02:00
|
|
|
|
2016-08-09 14:22:26 +02:00
|
|
|
function barebones_mail_from_name($name)
|
2015-10-15 18:24:32 +02:00
|
|
|
{
|
2016-08-09 14:22:26 +02:00
|
|
|
return get_bloginfo('name');
|
2014-08-07 11:54:20 +02:00
|
|
|
}
|
2016-08-09 14:22:26 +02:00
|
|
|
add_filter('wp_mail_from_name', 'barebones_mail_from_name');
|
2015-02-09 15:44:12 +01:00
|
|
|
|
2015-02-09 15:44:47 +01:00
|
|
|
|
2015-10-14 12:10:55 +02:00
|
|
|
|
2015-02-09 15:44:12 +01:00
|
|
|
/**
|
|
|
|
* Shortcodes ([button] shortcode included)
|
|
|
|
*/
|
|
|
|
|
2016-08-09 14:22:26 +02:00
|
|
|
function button_shortcode($atts, $content = null)
|
2015-10-15 18:24:32 +02:00
|
|
|
{
|
2016-04-19 13:27:54 +02:00
|
|
|
$atts['class'] = isset($atts['class']) ? $atts['class'] : 'btn';
|
2015-10-15 18:24:32 +02:00
|
|
|
|
2015-10-14 12:10:55 +02:00
|
|
|
return '<a class="' . $atts['class'] . '" href="' . $atts['link'] . '">' . $content . '</a>';
|
2015-02-09 15:44:12 +01:00
|
|
|
}
|
2016-08-09 14:22:26 +02:00
|
|
|
add_shortcode('button', 'button_shortcode');
|
2015-02-09 15:44:12 +01:00
|
|
|
|
|
|
|
|
2015-10-14 12:10:55 +02:00
|
|
|
|
2015-02-09 15:44:12 +01:00
|
|
|
/**
|
|
|
|
* TinyMCE
|
|
|
|
*/
|
|
|
|
|
2016-08-09 14:22:26 +02:00
|
|
|
function barebones_mce_buttons_2($buttons)
|
2015-10-15 18:24:32 +02:00
|
|
|
{
|
2016-08-09 14:22:26 +02:00
|
|
|
array_unshift($buttons, 'styleselect');
|
2015-10-14 12:10:55 +02:00
|
|
|
$buttons[] = 'hr';
|
2015-10-15 18:24:32 +02:00
|
|
|
|
2015-10-14 12:10:55 +02:00
|
|
|
return $buttons;
|
2015-02-09 15:44:12 +01:00
|
|
|
}
|
2016-08-09 14:22:26 +02:00
|
|
|
add_filter('mce_buttons_2', 'barebones_mce_buttons_2');
|
2015-02-09 15:44:12 +01:00
|
|
|
|
2016-08-09 14:22:26 +02:00
|
|
|
function barebones_tiny_mce_before_init($settings)
|
2015-10-15 18:24:32 +02:00
|
|
|
{
|
2015-10-14 12:10:55 +02:00
|
|
|
$style_formats = [
|
2015-10-15 18:24:32 +02:00
|
|
|
// [
|
|
|
|
// 'title' => '',
|
|
|
|
// 'selector' => '',
|
|
|
|
// 'classes' => ''
|
|
|
|
// ]
|
2015-10-14 12:10:55 +02:00
|
|
|
];
|
2015-10-15 18:24:32 +02:00
|
|
|
|
2016-08-09 14:22:26 +02:00
|
|
|
$settings['style_formats'] = json_encode($style_formats);
|
2015-10-15 18:24:32 +02:00
|
|
|
$settings['style_formats_merge'] = true;
|
|
|
|
|
2015-10-14 12:10:55 +02:00
|
|
|
return $settings;
|
2015-02-09 15:44:12 +01:00
|
|
|
}
|
2016-08-09 14:22:26 +02:00
|
|
|
add_filter('tiny_mce_before_init', 'barebones_tiny_mce_before_init');
|
2016-04-19 13:57:14 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get post thumbnail url
|
2016-08-09 14:22:26 +02:00
|
|
|
*
|
2016-04-19 13:57:14 +02:00
|
|
|
* @param int $post_id
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
|
2016-08-09 14:22:26 +02:00
|
|
|
function get_post_thumbnail_url($post_id)
|
2016-04-19 13:57:14 +02:00
|
|
|
{
|
2016-08-09 14:22:26 +02:00
|
|
|
return wp_get_attachment_url(get_post_thumbnail_id($post_id));
|
2016-04-19 13:57:14 +02:00
|
|
|
}
|