General updates
This commit is contained in:
parent
7c5bfdc0d4
commit
05c8670de0
20 changed files with 929 additions and 129 deletions
|
@ -1,15 +1,29 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Custom functions / External files
|
||||
*/
|
||||
|
||||
require get_template_directory() . '/functions/example.php';
|
||||
|
||||
|
||||
/**
|
||||
* Add support for useful stuff
|
||||
*/
|
||||
|
||||
add_theme_support( 'post-thumbnails' );
|
||||
add_theme_support( 'post-formats', ['post'] );
|
||||
add_theme_support( 'custom-header' );
|
||||
add_theme_support( 'custom-background' );
|
||||
add_post_type_support( 'page', 'excerpt' );
|
||||
if ( function_exists( 'add_theme_support' ) )
|
||||
{
|
||||
// Add Thumbnail Theme Support
|
||||
add_theme_support( 'post-thumbnails' );
|
||||
add_image_size( 'custom-size', 700, 200, true );
|
||||
|
||||
// Add Support for post formats
|
||||
add_theme_support( 'post-formats', ['post'] );
|
||||
add_post_type_support( 'page', 'excerpt' );
|
||||
|
||||
// Localisation Support
|
||||
load_theme_textdomain( 'barebones', get_template_directory() . '/languages' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -31,19 +45,20 @@ 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 ) {
|
||||
function barebones_remove_comments_rss( $for_comments )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
add_filter( 'post_comments_feed_link', 'barebones_remove_comments_rss' );
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* jQuery the right way
|
||||
*/
|
||||
|
||||
function barebones_scripts() {
|
||||
function barebones_scripts()
|
||||
{
|
||||
/*
|
||||
* For IE8 to play nice, you'll need to include your CSS here, for example:
|
||||
*/
|
||||
|
@ -52,7 +67,7 @@ function barebones_scripts() {
|
|||
wp_deregister_script( 'jquery' );
|
||||
wp_register_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js', false, '2.1.4', true );
|
||||
wp_enqueue_script( 'jquery' );
|
||||
wp_enqueue_script( 'script', get_stylesheet_directory_uri() . '/js/scripts.min.js', ['jquery'], null, true );
|
||||
wp_enqueue_script( 'script', get_stylesheet_directory_uri() . '/js/script.min.js', ['jquery'], null, true );
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'barebones_scripts' );
|
||||
|
@ -63,18 +78,21 @@ add_action( 'wp_enqueue_scripts', 'barebones_scripts' );
|
|||
* Nav menus
|
||||
*/
|
||||
|
||||
if ( function_exists( 'register_nav_menus' ) ) {
|
||||
if ( function_exists( 'register_nav_menus' ) )
|
||||
{
|
||||
register_nav_menus([
|
||||
'header' => 'Header',
|
||||
'footer' => 'Footer'
|
||||
]);
|
||||
}
|
||||
|
||||
function barebones_nav_menu_args( $args = '' ) {
|
||||
function barebones_nav_menu_args( $args = '' )
|
||||
{
|
||||
$args['container'] = false;
|
||||
$args['container_class'] = false;
|
||||
$args['menu_id'] = false;
|
||||
$args['items_wrap'] = '<ul class="%2$s">%3$s</ul>';
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
|
@ -86,14 +104,16 @@ add_filter( 'wp_nav_menu_args', 'barebones_nav_menu_args' );
|
|||
* Email
|
||||
*/
|
||||
|
||||
function barebones_mail_from( $email ) {
|
||||
function barebones_mail_from( $email )
|
||||
{
|
||||
return get_option( 'admin_email' );
|
||||
}
|
||||
|
||||
add_filter( 'wp_mail_from', 'barebones_mail_from' );
|
||||
|
||||
|
||||
function barebones_mail_from_name( $name ) {
|
||||
function barebones_mail_from_name( $name )
|
||||
{
|
||||
return get_bloginfo( 'name' );
|
||||
}
|
||||
|
||||
|
@ -105,8 +125,10 @@ add_filter( 'wp_mail_from_name', 'barebones_mail_from_name' );
|
|||
* Shortcodes ([button] shortcode included)
|
||||
*/
|
||||
|
||||
function button_shortcode( $atts, $content = null ) {
|
||||
function button_shortcode( $atts, $content = null )
|
||||
{
|
||||
$atts['class'] = $atts['class'] ? $atts['class'] : 'btn';
|
||||
|
||||
return '<a class="' . $atts['class'] . '" href="' . $atts['link'] . '">' . $content . '</a>';
|
||||
}
|
||||
|
||||
|
@ -118,27 +140,30 @@ add_shortcode( 'button', 'button_shortcode' );
|
|||
* TinyMCE
|
||||
*/
|
||||
|
||||
function barebones_mce_buttons_2( $buttons ) {
|
||||
function barebones_mce_buttons_2( $buttons )
|
||||
{
|
||||
array_unshift( $buttons, 'styleselect' );
|
||||
$buttons[] = 'hr';
|
||||
|
||||
return $buttons;
|
||||
}
|
||||
|
||||
add_filter( 'mce_buttons_2', 'barebones_mce_buttons_2' );
|
||||
|
||||
|
||||
function barebones_tiny_mce_before_init( $settings ) {
|
||||
function barebones_tiny_mce_before_init( $settings )
|
||||
{
|
||||
$style_formats = [
|
||||
/*
|
||||
* Example
|
||||
*
|
||||
[
|
||||
'title' => '',
|
||||
'selector' => '',
|
||||
'classes' => ''
|
||||
] */
|
||||
// [
|
||||
// 'title' => '',
|
||||
// 'selector' => '',
|
||||
// 'classes' => ''
|
||||
// ]
|
||||
];
|
||||
|
||||
$settings['style_formats'] = json_encode( $style_formats );
|
||||
$settings['style_formats_merge'] = true;
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
|
@ -150,15 +175,9 @@ 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 = []) {
|
||||
function wp_get_attachment_image_url( $id, $size = 'full', $attrs = [])
|
||||
{
|
||||
$image = wp_get_attachment_image_src( $id, $size, $attrs );
|
||||
|
||||
return $image[0];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Custom functions / External files
|
||||
*/
|
||||
|
||||
require_once( 'functions/example.php' );
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue