Update functions.php
This commit is contained in:
parent
7fe52f676a
commit
7d06eccb17
|
@ -3,7 +3,9 @@
|
||||||
/**
|
/**
|
||||||
* Custom functions / External files
|
* Custom functions / External files
|
||||||
*/
|
*/
|
||||||
require_once 'includes/functions.php';
|
|
||||||
|
require_once 'includes/custom-functions.php';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add support for useful stuff
|
* Add support for useful stuff
|
||||||
|
@ -25,14 +27,18 @@ if (function_exists('add_theme_support')) {
|
||||||
load_theme_textdomain('barebones', get_template_directory() . '/languages');
|
load_theme_textdomain('barebones', get_template_directory() . '/languages');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hide admin bar
|
* Hide admin bar
|
||||||
*/
|
*/
|
||||||
add_filter('show_admin_bar', '__return_false');
|
|
||||||
|
add_filter('show_admin_bar', '__return_false');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove junk
|
* Remove junk
|
||||||
*/
|
*/
|
||||||
|
|
||||||
remove_action('wp_head', 'rsd_link');
|
remove_action('wp_head', 'rsd_link');
|
||||||
remove_action('wp_head', 'wlwmanifest_link');
|
remove_action('wp_head', 'wlwmanifest_link');
|
||||||
remove_action('wp_head', 'wp_generator');
|
remove_action('wp_head', 'wp_generator');
|
||||||
|
@ -43,50 +49,56 @@ remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);
|
||||||
remove_action('wp_head', 'print_emoji_detection_script', 7);
|
remove_action('wp_head', 'print_emoji_detection_script', 7);
|
||||||
remove_action('wp_print_styles', 'print_emoji_styles');
|
remove_action('wp_print_styles', 'print_emoji_styles');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove comments feed
|
* Remove comments feed
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function barebones_post_comments_feed_link()
|
|
||||||
{
|
function barebones_post_comments_feed_link() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_filter('post_comments_feed_link', 'barebones_post_comments_feed_link');
|
add_filter('post_comments_feed_link', 'barebones_post_comments_feed_link');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enqueue scripts
|
* Enqueue scripts
|
||||||
*/
|
*/
|
||||||
function barebones_enqueue_scripts()
|
|
||||||
{
|
function barebones_enqueue_scripts() {
|
||||||
// wp_enqueue_style( 'fonts', '//fonts.googleapis.com/css?family=Font+Family' );
|
// wp_enqueue_style( 'fonts', '//fonts.googleapis.com/css?family=Font+Family' );
|
||||||
// wp_enqueue_style( 'icons', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css' );
|
// wp_enqueue_style( 'icons', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css' );
|
||||||
wp_enqueue_script('scripts', get_stylesheet_directory_uri() . '/js/scripts.min.js?' . filemtime(get_stylesheet_directory() . '/js/scripts.min.js'), [], null, true);
|
wp_enqueue_script('scripts', get_stylesheet_directory_uri() . '/js/scripts.min.js?' . filemtime(get_stylesheet_directory() . '/js/scripts.min.js'), [], null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action('wp_enqueue_scripts', 'barebones_enqueue_scripts');
|
add_action('wp_enqueue_scripts', 'barebones_enqueue_scripts');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register nav menus
|
* Register nav menus
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function barebones_register_nav_menus()
|
|
||||||
{
|
function barebones_register_nav_menus() {
|
||||||
register_nav_menus([
|
register_nav_menus([
|
||||||
'header' => __('Header', 'barebones'),
|
'header' => 'Header'
|
||||||
'footer' => __('Footer', 'barebones'),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action('after_setup_theme', 'barebones_register_nav_menus', 0);
|
add_action('after_setup_theme', 'barebones_register_nav_menus', 0);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nav menu args
|
* Nav menu args
|
||||||
*
|
*
|
||||||
* @param array $args
|
* @param array $args
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function barebones_nav_menu_args($args)
|
|
||||||
{
|
function barebones_nav_menu_args( $args ) {
|
||||||
$args['container'] = false;
|
$args['container'] = false;
|
||||||
$args['container_class'] = false;
|
$args['container_class'] = false;
|
||||||
$args['menu_id'] = false;
|
$args['menu_id'] = false;
|
||||||
|
@ -94,8 +106,10 @@ function barebones_nav_menu_args($args)
|
||||||
|
|
||||||
return $args;
|
return $args;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_filter('wp_nav_menu_args', 'barebones_nav_menu_args');
|
add_filter('wp_nav_menu_args', 'barebones_nav_menu_args');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Button Shortcode
|
* Button Shortcode
|
||||||
*
|
*
|
||||||
|
@ -103,37 +117,40 @@ add_filter('wp_nav_menu_args', 'barebones_nav_menu_args');
|
||||||
* @param string $content
|
* @param string $content
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function barebones_button_shortcode($atts, $content = null)
|
|
||||||
{
|
|
||||||
$atts['class'] = isset($atts['class']) ? $atts['class'] : 'btn';
|
|
||||||
|
|
||||||
|
function barebones_button_shortcode( $atts, $content = null ) {
|
||||||
|
$atts['class'] = isset($atts['class']) ? $atts['class'] : 'btn';
|
||||||
return '<a class="' . $atts['class'] . '" href="' . $atts['link'] . '">' . $content . '</a>';
|
return '<a class="' . $atts['class'] . '" href="' . $atts['link'] . '">' . $content . '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
add_shortcode('button', 'barebones_button_shortcode');
|
add_shortcode('button', 'barebones_button_shortcode');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TinyMCE
|
* TinyMCE
|
||||||
*
|
*
|
||||||
* @param array $buttons
|
* @param array $buttons
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function barebones_mce_buttons_2($buttons)
|
|
||||||
{
|
function barebones_mce_buttons_2( $buttons ) {
|
||||||
array_unshift($buttons, 'styleselect');
|
array_unshift($buttons, 'styleselect');
|
||||||
$buttons[] = 'hr';
|
$buttons[] = 'hr';
|
||||||
|
|
||||||
return $buttons;
|
return $buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_filter('mce_buttons_2', 'barebones_mce_buttons_2');
|
add_filter('mce_buttons_2', 'barebones_mce_buttons_2');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TinyMCE styling
|
* TinyMCE styling
|
||||||
*
|
*
|
||||||
* @param array $settings
|
* @param array $settings
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function barebones_tiny_mce_before_init($settings)
|
|
||||||
{
|
function barebones_tiny_mce_before_init( $settings ) {
|
||||||
$style_formats = [
|
$style_formats = [
|
||||||
// [
|
// [
|
||||||
// 'title' => '',
|
// 'title' => '',
|
||||||
|
@ -147,8 +164,10 @@ function barebones_tiny_mce_before_init($settings)
|
||||||
|
|
||||||
return $settings;
|
return $settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_filter('tiny_mce_before_init', 'barebones_tiny_mce_before_init');
|
add_filter('tiny_mce_before_init', 'barebones_tiny_mce_before_init');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get post thumbnail url
|
* Get post thumbnail url
|
||||||
*
|
*
|
||||||
|
@ -157,30 +176,32 @@ add_filter('tiny_mce_before_init', 'barebones_tiny_mce_before_init');
|
||||||
* @param boolean $icon
|
* @param boolean $icon
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function get_post_thumbnail_url($size = 'full', $post_id = false, $icon = false)
|
|
||||||
{
|
function get_post_thumbnail_url( $size = 'full', $post_id = false, $icon = false ) {
|
||||||
if (!$post_id) {
|
if ( ! $post_id ) {
|
||||||
$post_id = get_the_ID();
|
$post_id = get_the_ID();
|
||||||
}
|
}
|
||||||
|
|
||||||
$thumb_url_array = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), $size, $icon);
|
$thumb_url_array = wp_get_attachment_image_src(
|
||||||
|
get_post_thumbnail_id( $post_id ), $size, $icon
|
||||||
|
);
|
||||||
return $thumb_url_array[0];
|
return $thumb_url_array[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add Front Page edit link to admin Pages menu
|
* Add Front Page edit link to admin Pages menu
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function front_page_on_pages_menu() {
|
function front_page_on_pages_menu() {
|
||||||
global $submenu;
|
global $submenu;
|
||||||
if ( get_option( 'page_on_front' ) ) {
|
if ( get_option( 'page_on_front' ) ) {
|
||||||
$submenu['edit.php?post_type=page'][501] = array(
|
$submenu['edit.php?post_type=page'][501] = array(
|
||||||
'Front Page',
|
'Front Page',
|
||||||
'manage_options',
|
'manage_options',
|
||||||
get_edit_post_link( get_option( 'page_on_front' ) )
|
get_edit_post_link( get_option( 'page_on_front' ) )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action( 'admin_menu' , 'front_page_on_pages_menu' );
|
add_action( 'admin_menu' , 'front_page_on_pages_menu' );
|
||||||
|
|
||||||
add_action( 'admin_menu' , 'front_page_on_pages_menu' );
|
|
||||||
|
|
Loading…
Reference in New Issue