mirror of
https://github.com/ascribe/wp-theme
synced 2024-12-22 09:13:38 +01:00
refactor & simplify theme setup functions
This commit is contained in:
parent
c602004941
commit
1722303797
@ -3,12 +3,6 @@
|
|||||||
/**
|
/**
|
||||||
* ascribe functions and definitions
|
* ascribe functions and definitions
|
||||||
*
|
*
|
||||||
* When using a child theme (see http://codex.wordpress.org/Theme_Development and
|
|
||||||
* http://codex.wordpress.org/Child_Themes), you can override certain functions
|
|
||||||
* (those wrapped in a function_exists() call) by defining them first in your child theme's
|
|
||||||
* functions.php file. The child theme's functions.php file is included before the parent
|
|
||||||
* theme's file, so the child theme functions would be used.
|
|
||||||
*
|
|
||||||
* @package ascribe
|
* @package ascribe
|
||||||
* @since 0.1.0
|
* @since 0.1.0
|
||||||
*/
|
*/
|
||||||
@ -31,9 +25,6 @@ require_once WPTHEME_INC . 'cpt-presscoverage.php';
|
|||||||
require_once WPTHEME_INC . 'cpt-event.php';
|
require_once WPTHEME_INC . 'cpt-event.php';
|
||||||
require_once WPTHEME_INC . 'cpt-testimonial.php';
|
require_once WPTHEME_INC . 'cpt-testimonial.php';
|
||||||
|
|
||||||
// Run the setup functions
|
|
||||||
TenUp\ascribe\Core\setup();
|
|
||||||
|
|
||||||
|
|
||||||
// REMOVE WIDTH AND HEIGHT ATTRIBUTES ON THUMBNAILS
|
// REMOVE WIDTH AND HEIGHT ATTRIBUTES ON THUMBNAILS
|
||||||
add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10 );
|
add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10 );
|
||||||
@ -79,10 +70,6 @@ function register_primary_nav_menu() {
|
|||||||
}
|
}
|
||||||
add_action( 'init', 'register_primary_nav_menu');
|
add_action( 'init', 'register_primary_nav_menu');
|
||||||
|
|
||||||
// ADD THUMBNAILS TO POSTS
|
|
||||||
add_theme_support( 'post-thumbnails' );
|
|
||||||
|
|
||||||
|
|
||||||
// ENABLE HR IN WSYWIG
|
// ENABLE HR IN WSYWIG
|
||||||
function enable_more_buttons($buttons) {
|
function enable_more_buttons($buttons) {
|
||||||
$buttons[] = 'hr';
|
$buttons[] = 'hr';
|
||||||
@ -91,16 +78,6 @@ function enable_more_buttons($buttons) {
|
|||||||
}
|
}
|
||||||
add_filter("mce_buttons", "enable_more_buttons");
|
add_filter("mce_buttons", "enable_more_buttons");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// THUMBNAIL ADD CUSTOM SIZE
|
|
||||||
add_action( 'after_setup_theme', 'ttl_image_setup' );
|
|
||||||
function ttl_image_setup() {
|
|
||||||
add_image_size( 'blog-crop', 600, 350, true ); //(cropped)
|
|
||||||
add_image_size( 'blog-feature-crop', 300, 175, true ); //(cropped)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ADD QUERY VAR FOR EVENT PAGINATION
|
// ADD QUERY VAR FOR EVENT PAGINATION
|
||||||
add_filter('query_vars', 'add_my_var');
|
add_filter('query_vars', 'add_my_var');
|
||||||
function add_my_var($public_query_vars) {
|
function add_my_var($public_query_vars) {
|
||||||
|
@ -1,36 +1,39 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace TenUp\ascribe\Core;
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Set up theme defaults and register supported WordPress features.
|
|
||||||
*
|
*
|
||||||
* @since 0.1.0
|
* Theme setup
|
||||||
*
|
*
|
||||||
* @uses add_action()
|
|
||||||
*
|
|
||||||
* @return void.
|
|
||||||
*/
|
*/
|
||||||
function setup() {
|
function ascribe_setup() {
|
||||||
$n = function( $function ) {
|
add_theme_support('post-thumbnails');
|
||||||
return __NAMESPACE__ . "\\$function";
|
add_theme_support('html5', ['caption']);
|
||||||
};
|
|
||||||
|
|
||||||
add_action( 'wp_enqueue_scripts', $n( 'scripts' ) );
|
add_image_size( 'blog-crop', 600, 350, true ); //(cropped)
|
||||||
add_action( 'wp_enqueue_scripts', $n( 'styles' ) );
|
add_image_size( 'blog-feature-crop', 300, 175, true ); //(cropped)
|
||||||
|
|
||||||
|
// Add default posts and comments RSS feed links to head.
|
||||||
|
add_theme_support( 'automatic-feed-links' );
|
||||||
}
|
}
|
||||||
|
add_action('after_setup_theme', 'ascribe_setup');
|
||||||
|
|
||||||
/**
|
|
||||||
* Enqueue scripts for front-end.
|
/*
|
||||||
*
|
*
|
||||||
* @uses wp_enqueue_script() to load front end scripts.
|
* Theme Assets
|
||||||
*
|
*
|
||||||
* @since 0.1.0
|
|
||||||
*
|
|
||||||
* @return void.
|
|
||||||
*/
|
*/
|
||||||
function scripts( $debug = false ) {
|
function ascribe_assets() {
|
||||||
|
|
||||||
|
// Styles
|
||||||
|
wp_enqueue_style(
|
||||||
|
'wptheme',
|
||||||
|
WPTHEME_URL . "/assets/dist/css/ascribe.min.css",
|
||||||
|
array(),
|
||||||
|
WPTHEME_VERSION
|
||||||
|
);
|
||||||
|
|
||||||
|
// Scripts
|
||||||
if (!is_admin()) {
|
if (!is_admin()) {
|
||||||
wp_deregister_script('jquery');
|
wp_deregister_script('jquery');
|
||||||
wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js', false, '2.2.0', true);
|
wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js', false, '2.2.0', true);
|
||||||
@ -45,23 +48,6 @@ function scripts( $debug = false ) {
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
add_action( 'wp_enqueue_scripts', 'ascribe_assets' );
|
||||||
|
|
||||||
/**
|
?>
|
||||||
* Enqueue styles for front-end.
|
|
||||||
*
|
|
||||||
* @uses wp_enqueue_style() to load front end styles.
|
|
||||||
*
|
|
||||||
* @since 0.1.0
|
|
||||||
*
|
|
||||||
* @return void.
|
|
||||||
*/
|
|
||||||
function styles( $debug = false ) {
|
|
||||||
$min = ( $debug || defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
|
|
||||||
|
|
||||||
wp_enqueue_style(
|
|
||||||
'wptheme',
|
|
||||||
WPTHEME_URL . "/assets/dist/css/ascribe{$min}.css",
|
|
||||||
array(),
|
|
||||||
WPTHEME_VERSION
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user