Skip to content

Commit

Permalink
More cleanup for easy testing later
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisWiegman committed Aug 20, 2020
1 parent 8aa7ba3 commit 6ca778a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
Expand Up @@ -19,7 +19,7 @@ class PluginFileTest extends \WP_Mock\Tools\TestCase {
*/ */
public function test_chriswiegman_wordpress_plugin_starter_loader() { public function test_chriswiegman_wordpress_plugin_starter_loader() {


this->assertEquals( 1, 1 ); $this->assertEquals( 1, 1 );


} }
} }
45 changes: 33 additions & 12 deletions theme/functions.php
Expand Up @@ -5,17 +5,45 @@
* @package chriswiegman-theme * @package chriswiegman-theme
*/ */


namespace CW\Theme;

// Useful global constants. // Useful global constants.
define( 'CW_THEME_VERSION', '9.0.0' ); define( 'CW_THEME_VERSION', '9.0.0' );


/**
* Setup theme hooks.
*
* @since 9.0.0
*
* @return void
*/
function init() {

$n = function ( $function ) {
return __NAMESPACE__ . "\\$function";
};

// Add new actions and filters.
add_action( 'after_setup_theme', $n( 'action_after_setup_theme' ) );
add_action( 'widgets_init', $n( 'action_widgets_init' ) );
add_action( 'wp_enqueue_scripts', $n( 'action_wp_enqueue_scripts' ) );

// Cleanup extra garbage.
if ( function_exists( 'remove_action' ) ) {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
}

}

/** /**
* Action after_theme_setup * Action after_theme_setup
* *
* Sets up theme defaults and registers support for various WordPress features. * Sets up theme defaults and registers support for various WordPress features.
* *
* @since 5.0.0 * @since 9.0.0
*/ */
function cw_theme_action_after_setup_theme() { function action_after_setup_theme() {


// Add default posts and comments RSS feed links to head. // Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' ); add_theme_support( 'automatic-feed-links' );
Expand All @@ -40,16 +68,14 @@ function cw_theme_action_after_setup_theme() {


} }


add_action( 'after_setup_theme', 'cw_theme_action_after_setup_theme' );

/** /**
* Action widgets_init * Action widgets_init
* *
* Register widget area. * Register widget area.
* *
* @since 9.0.0 * @since 9.0.0
*/ */
function cw_theme_action_widgets_init() { function action_widgets_init() {


register_sidebar( register_sidebar(
array( array(
Expand All @@ -65,7 +91,6 @@ function cw_theme_action_widgets_init() {


} }


add_action( 'widgets_init', 'cw_theme_action_widgets_init' );


/** /**
* Action wp_enqueue_scripts * Action wp_enqueue_scripts
Expand All @@ -74,7 +99,7 @@ function cw_theme_action_widgets_init() {
* *
* @since 9.0.0 * @since 9.0.0
*/ */
function cw_theme_action_wp_enqueue_scripts() { function action_wp_enqueue_scripts() {


$min = ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) ? '' : '.min'; $min = ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) ? '' : '.min';


Expand All @@ -84,8 +109,4 @@ function cw_theme_action_wp_enqueue_scripts() {


} }


add_action( 'wp_enqueue_scripts', 'cw_theme_action_wp_enqueue_scripts' ); init();

// Cleanup extra garbage.
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );

0 comments on commit 6ca778a

Please sign in to comment.