1
0
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:
Matthias Kretschmann 2016-03-17 13:21:58 +01:00
parent c602004941
commit 1722303797
2 changed files with 25 additions and 62 deletions

View File

@ -3,12 +3,6 @@
/**
* 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
* @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-testimonial.php';
// Run the setup functions
TenUp\ascribe\Core\setup();
// REMOVE WIDTH AND HEIGHT ATTRIBUTES ON THUMBNAILS
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 THUMBNAILS TO POSTS
add_theme_support( 'post-thumbnails' );
// ENABLE HR IN WSYWIG
function enable_more_buttons($buttons) {
$buttons[] = 'hr';
@ -91,16 +78,6 @@ function enable_more_buttons($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_filter('query_vars', 'add_my_var');
function add_my_var($public_query_vars) {

View File

@ -1,36 +1,39 @@
<?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() {
$n = function( $function ) {
return __NAMESPACE__ . "\\$function";
};
function ascribe_setup() {
add_theme_support('post-thumbnails');
add_theme_support('html5', ['caption']);
add_action( 'wp_enqueue_scripts', $n( 'scripts' ) );
add_action( 'wp_enqueue_scripts', $n( 'styles' ) );
add_image_size( 'blog-crop', 600, 350, true ); //(cropped)
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()) {
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);
@ -45,23 +48,6 @@ function scripts( $debug = false ) {
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
);
}
?>