Merged v3 into master

This commit is contained in:
Pedro Reis 2019-01-08 11:10:57 +00:00
commit 20d55874a9
69 changed files with 1305 additions and 593 deletions

188
functions.php Normal file → Executable file
View file

@ -4,20 +4,20 @@
* Custom functions / External files
*/
require_once 'functions/example.php';
require_once 'includes/custom-functions.php';
/**
* Add support for useful stuff
*/
if (function_exists('add_theme_support')) {
if ( function_exists( 'add_theme_support' ) ) {
// Add support for document title tag
add_theme_support('title-tag');
add_theme_support( 'title-tag' );
// Add Thumbnail Theme Support
add_theme_support('post-thumbnails');
add_theme_support( 'post-thumbnails' );
// add_image_size( 'custom-size', 700, 200, true );
// Add Support for post formats
@ -25,20 +25,21 @@ if (function_exists('add_theme_support')) {
// add_post_type_support( 'page', 'excerpt' );
// Localisation Support
load_theme_textdomain('barebones', get_template_directory() . '/languages');
load_theme_textdomain( 'barebones', get_template_directory() . '/languages' );
}
/**
* Hide admin bar
*/
add_filter( 'show_admin_bar', '__return_false' );
/**
* Remove junk
*/
define('ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS', true);
define('ICL_DONT_LOAD_LANGUAGES_JS', true);
add_filter('show_admin_bar', '__return_false');
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_generator');
@ -49,53 +50,61 @@ 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)
{
/**
* Remove comments feed
*
* @return void
*/
function barebones_post_comments_feed_link() {
return;
}
add_filter('post_comments_feed_link', 'barebones_remove_comments_rss');
add_filter('post_comments_feed_link', 'barebones_post_comments_feed_link');
/**
* jQuery the right way
* Enqueue scripts
*/
function barebones_scripts()
{
/*
* For IE8 to play nice, you'll need to include your CSS here, for example:
*/
function barebones_enqueue_scripts() {
// 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_deregister_script('jquery');
wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js', false, '1.11.3', true);
wp_enqueue_script('jquery');
wp_enqueue_script('script', get_stylesheet_directory_uri() . '/js/script.min.js?' . filemtime(get_stylesheet_directory() . '/js/script.min.js'), ['jquery'], null, true);
// wp_enqueue_style( 'icons', '//use.fontawesome.com/releases/v5.0.10/css/all.css' );
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_scripts');
add_action( 'wp_enqueue_scripts', 'barebones_enqueue_scripts' );
/**
* Nav menus
* Register nav menus
*
* @return void
*/
if (function_exists('register_nav_menus')) {
function barebones_register_nav_menus() {
register_nav_menus([
'header' => 'Header',
'footer' => 'Footer'
'footer' => 'Footer',
]);
}
function barebones_nav_menu_args($args = '')
{
$args['container'] = false;
add_action( 'after_setup_theme', 'barebones_register_nav_menus', 0 );
/**
* Nav menu args
*
* @param array $args
* @return void
*/
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>';
$args['menu_id'] = false;
$args['items_wrap'] = '<ul class="%2$s">%3$s</ul>';
return $args;
}
@ -103,50 +112,31 @@ function barebones_nav_menu_args($args = '')
add_filter('wp_nav_menu_args', 'barebones_nav_menu_args');
/**
* Email
* Button Shortcode
*
* @param array $atts
* @param string $content
* @return void
*/
function barebones_mail_from($email)
{
return get_option('admin_email');
}
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');
/**
* Shortcodes ([button] shortcode included)
*/
function 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>';
}
add_shortcode('button', 'button_shortcode');
add_shortcode('button', 'barebones_button_shortcode');
/**
* TinyMCE
*
* @param array $buttons
* @return void
*/
function barebones_mce_buttons_2($buttons)
{
array_unshift($buttons, 'styleselect');
function barebones_mce_buttons_2( $buttons ) {
array_unshift( $buttons, 'styleselect' );
$buttons[] = 'hr';
return $buttons;
@ -155,13 +145,34 @@ function barebones_mce_buttons_2($buttons)
add_filter('mce_buttons_2', 'barebones_mce_buttons_2');
function barebones_tiny_mce_before_init($settings)
{
/**
* TinyMCE styling
*
* @param array $settings
* @return void
*/
function barebones_tiny_mce_before_init( $settings ) {
$style_formats = [
// [
// 'title' => '',
// 'selector' => '',
// 'classes' => ''
// ],
// [
// 'title' => 'Buttons',
// 'items' => [
// [
// 'title' => 'Primary',
// 'selector' => 'a',
// 'classes' => 'btn btn--primary'
// ],
// [
// 'title' => 'Secondary',
// 'selector' => 'a',
// 'classes' => 'btn btn--secondary'
// ]
// ]
// ]
];
@ -173,18 +184,41 @@ function barebones_tiny_mce_before_init($settings)
add_filter('tiny_mce_before_init', 'barebones_tiny_mce_before_init');
/**
* Get post thumbnail url
* @param string $size Size of the returned image
* @param int $post_id post id
* @param boolean $icon if no image found, display icon
*
* @param string $size
* @param boolean $post_id
* @param boolean $icon
* @return void
*/
function get_post_thumbnail_url( $size = 'full', $post_id = false, $icon = false )
{
if(!$post_id) {
function get_post_thumbnail_url( $size = 'full', $post_id = false, $icon = false ) {
if ( ! $post_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];
}
/**
* Add Front Page edit link to admin Pages menu
*/
function front_page_on_pages_menu() {
global $submenu;
if ( get_option( 'page_on_front' ) ) {
$submenu['edit.php?post_type=page'][501] = array(
__( 'Front Page', 'barebones' ),
'manage_options',
get_edit_post_link( get_option( 'page_on_front' ) )
);
}
}
add_action( 'admin_menu' , 'front_page_on_pages_menu' );