Browse Source

Heavy refactoring

tags/5.0.0^2
Chris Wiegman 4 years ago
parent
commit
2188ed45bf
75 changed files with 740 additions and 8110 deletions
  1. +3
    -0
      .gitignore
  2. +24
    -0
      .jshintrc
  3. +113
    -29
      Gruntfile.js
  4. +0
    -65
      assets/css/editor.css
  5. +0
    -4132
      assets/css/master.css
  6. +0
    -0
      assets/fonts/FontAwesome.otf
  7. +0
    -0
      assets/fonts/fontawesome-webfont.eot
  8. +0
    -0
      assets/fonts/fontawesome-webfont.svg
  9. +0
    -0
      assets/fonts/fontawesome-webfont.ttf
  10. +0
    -0
      assets/fonts/fontawesome-webfont.woff
  11. +0
    -0
      assets/fonts/fontawesome-webfont.woff2
  12. +0
    -0
      assets/images/logo.png
  13. +0
    -0
      assets/js/src/backstretch.js
  14. +0
    -0
      assets/js/src/progress.js
  15. +0
    -0
      assets/js/src/scripts.js
  16. +0
    -0
      assets/js/src/skip-link-focus-fix.js
  17. +0
    -0
      assets/sass/components/_accessibility.scss
  18. +0
    -0
      assets/sass/components/_alignments.scss
  19. +0
    -0
      assets/sass/components/_clearings.scss
  20. +0
    -0
      assets/sass/components/_colors.scss
  21. +0
    -0
      assets/sass/components/_content.scss
  22. +0
    -0
      assets/sass/components/_elements.scss
  23. +0
    -0
      assets/sass/components/_fonts.scss
  24. +0
    -0
      assets/sass/components/_forms.scss
  25. +0
    -0
      assets/sass/components/_layout.scss
  26. +0
    -0
      assets/sass/components/_links.scss
  27. +0
    -0
      assets/sass/components/_max-1152.scss
  28. +0
    -0
      assets/sass/components/_max-1192.scss
  29. +0
    -0
      assets/sass/components/_max-350.scss
  30. +0
    -0
      assets/sass/components/_max-700.scss
  31. +0
    -0
      assets/sass/components/_max-900.scss
  32. +0
    -0
      assets/sass/components/_media.scss
  33. +0
    -0
      assets/sass/components/_menus.scss
  34. +0
    -0
      assets/sass/components/_min-1192.scss
  35. +0
    -0
      assets/sass/components/_print.scss
  36. +0
    -0
      assets/sass/components/_projects.scss
  37. +0
    -0
      assets/sass/components/_reset.scss
  38. +0
    -0
      assets/sass/components/_speaking.scss
  39. +0
    -0
      assets/sass/components/_typography.scss
  40. +0
    -0
      assets/sass/components/_widgets.scss
  41. +0
    -0
      assets/sass/components/font-awesome/_animated.scss
  42. +0
    -0
      assets/sass/components/font-awesome/_bordered-pulled.scss
  43. +0
    -0
      assets/sass/components/font-awesome/_core.scss
  44. +0
    -0
      assets/sass/components/font-awesome/_fixed-width.scss
  45. +0
    -0
      assets/sass/components/font-awesome/_icons.scss
  46. +0
    -0
      assets/sass/components/font-awesome/_larger.scss
  47. +0
    -0
      assets/sass/components/font-awesome/_list.scss
  48. +0
    -0
      assets/sass/components/font-awesome/_mixins.scss
  49. +0
    -0
      assets/sass/components/font-awesome/_path.scss
  50. +0
    -0
      assets/sass/components/font-awesome/_rotated-flipped.scss
  51. +0
    -0
      assets/sass/components/font-awesome/_stacked.scss
  52. +0
    -0
      assets/sass/components/font-awesome/_variables.scss
  53. +0
    -0
      assets/sass/components/font-awesome/font-awesome.scss
  54. +0
    -0
      assets/sass/editor.scss
  55. +0
    -0
      assets/sass/master.scss
  56. +24
    -0
      bootstrap.php
  57. +18
    -0
      codesniffer.ruleset.xml
  58. +25
    -0
      composer.json
  59. +13
    -188
      functions.php
  60. +0
    -89
      inc/extras.php
  61. +348
    -0
      includes/functions/core.php
  62. +0
    -0
      includes/functions/template-tags.php
  63. +0
    -54
      lib/css/editor.css
  64. +0
    -1
      lib/css/editor.css.map
  65. +0
    -1
      lib/css/editor.min.css
  66. +0
    -3459
      lib/css/master.css
  67. +0
    -1
      lib/css/master.css.map
  68. +0
    -7
      lib/css/master.min.css
  69. +0
    -67
      lib/js/footer.js
  70. +0
    -1
      lib/js/footer.min.js
  71. +19
    -15
      package.json
  72. +21
    -0
      phpunit.xml
  73. +1
    -1
      style.css
  74. +49
    -0
      tests/phpunit/Core_Tests.php
  75. +82
    -0
      tests/phpunit/test-tools/TestCase.php

+ 3
- 0
.gitignore View File

@@ -1 +1,4 @@
node_modules
vendor
.DS_Store
composer.lock

+ 24
- 0
.jshintrc View File

@@ -0,0 +1,24 @@
{
"boss": true,
"curly": true,
"eqeqeq": true,
"eqnull": true,
"es3": true,
"expr": true,
"immed": true,
"noarg": true,
"nonbsp": true,
"onevar": true,
"quotmark": "single",
"trailing": true,
"undef": false,
"unused": true,
"browser": true,
"globals": {
"_": false,
"Backbone": false,
"jQuery": false,
"JSON": false,
"wp": false
}
}

+ 113
- 29
Gruntfile.js View File

@@ -1,17 +1,32 @@
module.exports = function ( grunt ) {

// Start out by loading the grunt modules we'll need
require ( 'load-grunt-tasks' ) ( grunt );
require( 'load-grunt-tasks' )( grunt );

grunt.initConfig (
grunt.initConfig(
{

/**
* Clean existing files
*/
clean : {
dist : {
src : ['lib']
styles : {
src : [
'assets/css/*.css',
'assets/css/*.map'
]
},
scripts : {
src : [
'assets/js/*.js',
'assets/js/*.map'
]
}
},

/**
* Autoprefix CSS
*/
autoprefixer : {

options : {
@@ -22,21 +37,24 @@ module.exports = function ( grunt ) {
files : {
expand : true,
flatten : true,
src : 'lib/css/*.css',
dest : 'lib/css'
src : ['assets/css/*.css'],
dest : 'assets/css'
}

},

/**
* Minify CSS
*/
cssmin : {

target : {

files : [{
expand : true,
cwd : 'lib/css',
cwd : 'assets/css',
src : ['*.css'],
dest : 'lib/css',
dest : 'assets/css',
ext : '.min.css'
}]

@@ -44,6 +62,9 @@ module.exports = function ( grunt ) {

},

/**
* Process SASS files
*/
sass : {

dist : {
@@ -55,14 +76,16 @@ module.exports = function ( grunt ) {
},

files : {
'lib/css/master.css' : 'assets/scss/master.scss',
'lib/css/editor.css' : 'assets/scss/editor.scss'
'assets/css/style.css' : 'assets/sass/style.scss'
}

}

},

/**
* Processes and compresses JavaScript.
*/
uglify : {

production : {
@@ -70,72 +93,133 @@ module.exports = function ( grunt ) {
options : {
beautify : false,
preserveComments : false,
sourceMap : false,
mangle : {
except : ['jQuery']
}
},

files : {
'lib/js/footer.min.js' : [
'assets/js/progress.js',
'assets/js/skip-link-focus-fix.js',
'assets/js/scripts.js'
'assets/js/theme.min.js' : [
'assets/js/src/navigation.js',
'assets/js/src/skip-link-focus-fix.js',
'assets/js/src/scripts.js'
]
}

},

development : {
dev : {

options : {
beautify : true,
preserveComments : true
preserveComments : true,
sourceMap : true,
mangle : {
except : ['jQuery']
}
},

files : {
'lib/js/footer.js' : [
'assets/js/progress.js',
'assets/js/skip-link-focus-fix.js',
'assets/js/scripts.js'
'assets/js/theme.js' : [
'assets/js/src/navigation.js',
'assets/js/src/skip-link-focus-fix.js',
'assets/js/src/scripts.js'
]
}
}

},

/**
* Update translation file.
*/
makepot : {

target : {
options : {
type : 'wp-theme',
domainPath : '/languages',
mainFile : 'style.css'
}
}
},

/**
* Run PHP unit tests.
*/
phpunit : {

classes : {
dir : 'tests/'
},

options : {

bin : './vendor/bin/phpunit',
testSuffix : 'Tests.php',
bootstrap : 'bootstrap.php',
colors : true

}
},

/**
* Clean up the JavaScript
*/
jshint : {
options : {
jshintrc : true
},
all : ['assets/js/src/*.js']
},

/**
* A better browser reloader
*/
browserSync : {
bsFiles : {
src : 'assets/**/*.*'
},
options : {
proxy : 'www.chriswiegman.pv',
watchTask : true
}
},

/**
* Watch scripts and styles for changes
*/
watch : {

options : {
livereload : true
livereload : false
},

styles : {

files : [
'assets/scss/**/*'
'assets/sass/**/*'
],

tasks : ['sass', 'autoprefixer', 'cssmin']
tasks : ['clean:styles', 'sass', 'autoprefixer', 'cssmin']

},

scripts : {

files : [
'assets/js/**/*'
'assets/js/src/**/*.*'
],

tasks : ['uglify:development', 'uglify:production']
tasks : ['clean:scripts','uglify:production']

}

}

}
);

// A very basic default task.
grunt.registerTask ( 'default', ['clean', 'sass', 'autoprefixer', 'cssmin', 'uglify:development', 'uglify:production'] );
grunt.registerTask( 'default', ['phpunit', 'jshint', 'clean:styles', 'sass', 'autoprefixer', 'cssmin', 'phpunit', 'jshint', 'clean:scripts', 'uglify:production', 'uglify:dev', 'makepot'] );
grunt.registerTask( 'dev', ['default', 'browserSync', 'watch'] );

};

+ 0
- 65
assets/css/editor.css View File

@@ -1,65 +0,0 @@
#tinymce {
background: #fff;
color: #5f5f5f;
padding: 8px;
font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
font-weight: 400;
font-size: 22px;
font-size: 1.375rem;
line-height: 1.6;
}

#tinymce p {
margin-bottom: 1.5rem;
}

#tinymce img.alignleft {
display: inline;
margin: 0 24px 24px 0;
}

#tinymce img.centered, #tinymce .aligncenter {
display: block;
margin: 0 auto 24px;
}

#tinymce img.alignnone {
display: inline;
margin-bottom: 12px;
}

#tinymce h1, #tinymce h2, #tinymce h3, #tinymce h4, #tinymce h5, #tinymce h6 {
font-family: Georgia, Times, Times New Roman, serif;
font-weight: 700;
}

#tinymce h2 {
font-size: 30px;
font-size: 1.875rem;
}

#tinymce h3 {
font-size: 24px;
font-size: 1.5rem;
}

#tinymce h4 {
font-size: 24px;
font-size: 1.5rem;
padding-bottom: 16px;
padding-bottom: 1rem;
}

#tinymce h5 {
font-size: 18px;
font-size: 1.125rem;
}

#tinymce h6 {
font-size: 16px;
font-size: 1rem;
}

#tinymce a {
color: #e80;
}

+ 0
- 4132
assets/css/master.css
File diff suppressed because it is too large
View File


fonts/FontAwesome.otf → assets/fonts/FontAwesome.otf View File


fonts/fontawesome-webfont.eot → assets/fonts/fontawesome-webfont.eot View File


fonts/fontawesome-webfont.svg → assets/fonts/fontawesome-webfont.svg View File


fonts/fontawesome-webfont.ttf → assets/fonts/fontawesome-webfont.ttf View File


fonts/fontawesome-webfont.woff → assets/fonts/fontawesome-webfont.woff View File


fonts/fontawesome-webfont.woff2 → assets/fonts/fontawesome-webfont.woff2 View File


img/logo.png → assets/images/logo.png View File


assets/js/backstretch.js → assets/js/src/backstretch.js View File


assets/js/progress.js → assets/js/src/progress.js View File


assets/js/scripts.js → assets/js/src/scripts.js View File


assets/js/skip-link-focus-fix.js → assets/js/src/skip-link-focus-fix.js View File


assets/scss/components/_accessibility.scss → assets/sass/components/_accessibility.scss View File


assets/scss/components/_alignments.scss → assets/sass/components/_alignments.scss View File


assets/scss/components/_clearings.scss → assets/sass/components/_clearings.scss View File


assets/scss/components/_colors.scss → assets/sass/components/_colors.scss View File


assets/scss/components/_content.scss → assets/sass/components/_content.scss View File


assets/scss/components/_elements.scss → assets/sass/components/_elements.scss View File


assets/scss/components/_fonts.scss → assets/sass/components/_fonts.scss View File


assets/scss/components/_forms.scss → assets/sass/components/_forms.scss View File


assets/scss/components/_layout.scss → assets/sass/components/_layout.scss View File


assets/scss/components/_links.scss → assets/sass/components/_links.scss View File


assets/scss/components/_max-1152.scss → assets/sass/components/_max-1152.scss View File


assets/scss/components/_max-1192.scss → assets/sass/components/_max-1192.scss View File


assets/scss/components/_max-350.scss → assets/sass/components/_max-350.scss View File


assets/scss/components/_max-700.scss → assets/sass/components/_max-700.scss View File


assets/scss/components/_max-900.scss → assets/sass/components/_max-900.scss View File


assets/scss/components/_media.scss → assets/sass/components/_media.scss View File


assets/scss/components/_menus.scss → assets/sass/components/_menus.scss View File


assets/scss/components/_min-1192.scss → assets/sass/components/_min-1192.scss View File


assets/scss/components/_print.scss → assets/sass/components/_print.scss View File


assets/scss/components/_projects.scss → assets/sass/components/_projects.scss View File


assets/scss/components/_reset.scss → assets/sass/components/_reset.scss View File


assets/scss/components/_speaking.scss → assets/sass/components/_speaking.scss View File


assets/scss/components/_typography.scss → assets/sass/components/_typography.scss View File


assets/scss/components/_widgets.scss → assets/sass/components/_widgets.scss View File


assets/scss/components/font-awesome/_animated.scss → assets/sass/components/font-awesome/_animated.scss View File


assets/scss/components/font-awesome/_bordered-pulled.scss → assets/sass/components/font-awesome/_bordered-pulled.scss View File


assets/scss/components/font-awesome/_core.scss → assets/sass/components/font-awesome/_core.scss View File


assets/scss/components/font-awesome/_fixed-width.scss → assets/sass/components/font-awesome/_fixed-width.scss View File


assets/scss/components/font-awesome/_icons.scss → assets/sass/components/font-awesome/_icons.scss View File


assets/scss/components/font-awesome/_larger.scss → assets/sass/components/font-awesome/_larger.scss View File


assets/scss/components/font-awesome/_list.scss → assets/sass/components/font-awesome/_list.scss View File


assets/scss/components/font-awesome/_mixins.scss → assets/sass/components/font-awesome/_mixins.scss View File


assets/scss/components/font-awesome/_path.scss → assets/sass/components/font-awesome/_path.scss View File


assets/scss/components/font-awesome/_rotated-flipped.scss → assets/sass/components/font-awesome/_rotated-flipped.scss View File


assets/scss/components/font-awesome/_stacked.scss → assets/sass/components/font-awesome/_stacked.scss View File


assets/scss/components/font-awesome/_variables.scss → assets/sass/components/font-awesome/_variables.scss View File


assets/scss/components/font-awesome/font-awesome.scss → assets/sass/components/font-awesome/font-awesome.scss View File


assets/scss/editor.scss → assets/sass/editor.scss View File


assets/scss/master.scss → assets/sass/master.scss View File


+ 24
- 0
bootstrap.php View File

@@ -0,0 +1,24 @@
<?php
if ( ! defined( 'PROJECT' ) ) {
define( 'PROJECT', __DIR__ . '/includes/' );
}

// Place any additional bootstrapping requirements here for PHP Unit.
if ( ! defined( 'WP_LANG_DIR' ) ) {
define( 'WP_LANG_DIR', 'lang_dir' );
}

if ( ! file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
throw new PHPUnit_Framework_Exception(
'ERROR' . PHP_EOL . PHP_EOL .
'You must use Composer to install the test suite\'s dependencies!' . PHP_EOL
);
}

require_once __DIR__ . '/vendor/autoload.php';

require_once __DIR__ . '/tests/phpunit/test-tools/TestCase.php';

WP_Mock::setUsePatchwork( true );
WP_Mock::bootstrap();
WP_Mock::tearDown();

+ 18
- 0
codesniffer.ruleset.xml View File

@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<ruleset name="WordPress Theme Coding Standards">
<!-- See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
<!-- See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/blob/develop/WordPress-Core/ruleset.xml -->

<!-- Set a description for this ruleset. -->
<description>A custom set of code standard rules to check for WordPress themes.</description>

<!-- Include the WordPress ruleset, with exclusions. -->
<rule ref="WordPress">
<exclude name="Generic.WhiteSpace.ScopeIndent.IncorrectExact"/>
<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect"/>
<exclude name="PEAR.Functions.FunctionCallSignature.Indent"/>
</rule>

<!-- Include sniffs for PHP cross-version compatibility. -->
<rule ref="PHPCompatibility"/>
</ruleset>

+ 25
- 0
composer.json View File

@@ -0,0 +1,25 @@
{
"name": "chriswiegman",
"description": "The theme for www.chriswiegman.com.",
"version": "5.0.0",
"type": "wordpress-theme",
"keywords": [],
"homepage": "https://www.chriswiegman.com/",
"license": "GPLv2.0+",
"authors": [
{
"name": "Chris Wiegman",
"email": "chris@chriswiegman.com",
"homepage": "https://www.chriswiegman.com/",
"role": "Developer"
}
],
"minimum-stability": "dev",
"require": {
"php": ">=5.3"
},
"require-dev": {
"phpunit/phpunit": "*@stable",
"10up/wp_mock": "dev-master"
}
}

+ 13
- 188
functions.php View File

@@ -1,195 +1,20 @@
<?php
/**
* ChrisWiegman functions and definitions
* ChrisWiegman functions and definitions.
*
* @package ChrisWiegman
*/

define( 'CW_THEME_VERISON', '1.2.0' );

/**
* Set the content width based on the theme's design and stylesheet.
*/
if ( ! isset( $content_width ) ) {
$content_width = 640; /* pixels */
}

/**
* Sets up theme defaults and registers support for various WordPress features.
*/
function chriswiegman_setup() {

// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );

// Enable support for Post Thumbnails on posts and pages.
add_theme_support( 'post-thumbnails' );

// Enable post formats.
add_theme_support( 'post-formats', array( 'image', 'quote' ) );

// This theme uses wp_nav_menu() in one location.
register_nav_menus(
array(
'primary' => __( 'Primary Menu', 'chriswiegman' ),
'footer' => __( 'Footer Menu', 'chriswiegman' ),
)
);

/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support(
'html5',
array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
)
);

}

add_action( 'after_setup_theme', 'chriswiegman_setup' );

/**
* Register widget area.
*/
function chriswiegman_widgets_init() {

register_sidebar( array(
'name' => __( 'Sidebar', 'chriswiegman' ),
'id' => 'sidebar',
'description' => 'The primary sidebar on the right side of most content.',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );

register_sidebar( array(
'name' => __( 'Intro', 'chriswiegman' ),
'id' => 'intro',
'description' => 'The intro area at the top of most pages.',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
}

add_action( 'widgets_init', 'chriswiegman_widgets_init' );

/**
* Enqueue scripts and styles.
*/
function chriswiegman_scripts() {

if ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) {

wp_enqueue_style( 'chriswiegman-style', get_template_directory_uri() . '/lib/css/master.css', array(), CW_THEME_VERISON );

wp_enqueue_script( 'chriswiegman-footer', get_template_directory_uri() . '/lib/js/footer.js', array( 'jquery' ), CW_THEME_VERISON, true );

} else {

wp_enqueue_style( 'chriswiegman-style', get_template_directory_uri() . '/lib/css/master.min.css', array(), CW_THEME_VERISON );

wp_enqueue_script( 'chriswiegman-footer', get_template_directory_uri() . '/lib/js/footer.min.js', array( 'jquery' ), CW_THEME_VERISON, true );

}

$vars = array(
'small' => wp_get_attachment_image_src( get_post_thumbnail_id(), array( 150, 150 ) ),
'medium' => wp_get_attachment_image_src( get_post_thumbnail_id(), array( 250, 250 ) ),
'large' => wp_get_attachment_image_src( get_post_thumbnail_id(), array( 350, 350 ) ),
'full' => wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' ),
);

wp_localize_script(
'chriswiegman-footer',
'chriswiegman_featured_image',
$vars
);

if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}

}

/**
* Create the correct more link
*/
function chriswiegman_excerpt_more() {

return '... <a class="more-link" href="' . get_permalink( get_the_ID() ) . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'chriswiegman' ) . '</a>';

}

add_filter( 'excerpt_more', 'chriswiegman_excerpt_more' );

add_action( 'wp_enqueue_scripts', 'chriswiegman_scripts' );

/**
* Add custom styles to wysiwyg editor
*/
function chriswiegman_add_editor_styles() {

if ( defined( 'WP_LOCAL_DEV' ) && true === WP_LOCAL_DEV ) {

add_editor_style( get_stylesheet_directory_uri() . '/lib/css/editor.min.css' );

} else {

add_editor_style( get_stylesheet_directory_uri() . '/lib/css/editor.css' );

}

}

add_action( 'init', 'chriswiegman_add_editor_styles' );

/**
* Removes an extra jQuery Script
*/
function cw_remove_jquery_migrate( $scripts ) {

if ( ! is_admin() ) {
$scripts->remove( 'jquery' );
$scripts->add( 'jquery', false, array( 'jquery-core' ), '1.11.1' );
}

}

add_filter( 'wp_default_scripts', 'cw_remove_jquery_migrate' );

/**
* Clean up the header
* @since 5.0.0
*
* @package CW\Theme\Functions
*
* @author Chris Wiegman <chris@chriswiegman.com>
*/
function cw_feed_links() {

echo '<link rel="alternate" type="' . esc_attr( feed_content_type() ) . '" title="Chris Wiegman | All Posts" href="http://feeds.chriswiegman.com" />' . PHP_EOL;
echo '<link rel="alternate" type="' . esc_attr( feed_content_type() ) . '" title="Chris Wiegman | All Comments" href="http://feeds.chriswiegman.com/comments" />' . PHP_EOL;

}

remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'wp_generator' );
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'feed_links', 2 );
remove_action( 'wp_head', 'rsd_link' );
add_action( 'wp_head', 'cw_feed_links' );
// Useful global constants.
define( 'CW_THEME_VERSION', '5.0.0' );
define( 'CW_THEME_PATH', get_template_directory() . '/' );
define( 'CW_THEME_INCLUDES', CW_THEME_PATH . 'includes/' );

/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
require( CW_THEME_INCLUDES . 'functions/core.php' );
require( CW_THEME_INCLUDES . 'functions/template-tags.php' );

/**
* Custom functions that act independently of the theme templates.
*/
require get_template_directory() . '/inc/extras.php';
CW\Theme\Functions\Core\init();

+ 0
- 89
inc/extras.php View File

@@ -1,89 +0,0 @@
<?php
/**
* Custom functions that act independently of the theme templates
*
* Eventually, some of the functionality here could be replaced by core features
*
* @package ChrisWiegman
*/

/**
* Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
*
* @param array $args Configuration arguments.
* @return array
*/
function chriswiegman_page_menu_args( $args ) {
$args['show_home'] = true;
return $args;
}
add_filter( 'wp_page_menu_args', 'chriswiegman_page_menu_args' );

/**
* Adds custom classes to the array of body classes.
*
* @param array $classes Classes for the body element.
* @return array
*/
function chriswiegman_body_classes( $classes ) {
// Adds a class of group-blog to blogs with more than 1 published author.
if ( is_multi_author() ) {
$classes[] = 'group-blog';
}

return $classes;
}
add_filter( 'body_class', 'chriswiegman_body_classes' );

/**
* Filters wp_title to print a neat <title> tag based on what is being viewed.
*
* @param string $title Default title text for current view.
* @param string $sep Optional separator.
* @return string The filtered title.
*/
function chriswiegman_wp_title( $title, $sep ) {
if ( is_feed() ) {
return $title;
}

global $page, $paged;

// Add the blog name
$title .= get_bloginfo( 'name', 'display' );

// Add the blog description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) ) {
$title .= " $sep $site_description";
}

// Add a page number if necessary:
if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
$title .= " $sep " . sprintf( __( 'Page %s', 'chriswiegman' ), max( $paged, $page ) );
}

return $title;
}
add_filter( 'wp_title', 'chriswiegman_wp_title', 10, 2 );

/**
* Sets the authordata global when viewing an author archive.
*
* This provides backwards compatibility with
* http://core.trac.wordpress.org/changeset/25574
*
* It removes the need to call the_post() and rewind_posts() in an author
* template to print information about the author.
*
* @global WP_Query $wp_query WordPress Query object.
* @return void
*/
function chriswiegman_setup_author() {
global $wp_query;

if ( $wp_query->is_author() && isset( $wp_query->post ) ) {
$GLOBALS['authordata'] = get_userdata( $wp_query->post->post_author );
}
}
add_action( 'wp', 'chriswiegman_setup_author' );

+ 348
- 0
includes/functions/core.php View File

@@ -0,0 +1,348 @@
<?php
/**
* ChrisWiegman Core functions and definitions.
*
* @since 5.0.0
*
* @package CW\Theme\Functions\Core
*
* @author Chris Wiegman <chris@chriswiegman.com>
*/

namespace CW\Theme\Functions\Core;

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

// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );

// Enable support for Post Thumbnails on posts and pages.
add_theme_support( 'post-thumbnails' );

// Enable post formats.
add_theme_support( 'post-formats', array( 'image', 'quote' ) );

// This theme uses wp_nav_menu() in one location.
register_nav_menus(
array(
'primary' => __( 'Primary Menu', 'chriswiegman' ),
'footer' => __( 'Footer Menu', 'chriswiegman' ),
)
);

/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support(
'html5',
array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
)
);

}

/**
* Action init
*
* Add custom styles to wysiwyg editor
*
* @since 5.0.0
*
* @return void
*/
function action_init() {

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

add_editor_style( get_stylesheet_directory_uri() . '/assets/css/editor' . $min . '.css' );

}

/**
* Action widgets_init
*
* Register widget area.
*
* @since 5.0.0
*
* @return void
*/
function action_widgets_init() {

register_sidebar(
array(
'name' => esc_html__( 'Sidebar', 'chriswiegman' ),
'id' => 'sidebar',
'description' => esc_html__( 'The primary sidebar on the right side of most content.', 'chriswiegman' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
)
);

register_sidebar(
array(
'name' => esc_html__( 'Intro', 'chriswiegman' ),
'id' => 'intro',
'description' => esc_html__( 'The intro area at the top of most pages.', 'chriswiegman' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
)
);

}

/**
* Action wp
*
* Sets the authordata global when viewing an author archive.
*
* This provides backwards compatibility with
* http://core.trac.wordpress.org/changeset/25574
*
* It removes the need to call the_post() and rewind_posts() in an author
* template to print information about the author.
*
* @since 5.0.0
*
* @global \WP_Query $wp_query WordPress Query object.
*
* @return void
*/
function action_wp() {

global $wp_query;

if ( $wp_query->is_author() && isset( $wp_query->post ) ) {
$GLOBALS['authordata'] = get_userdata( $wp_query->post->post_author );
}
}

/**
* Action wp_enqueue_scripts
*
* Enqueue scripts and styles.
*
* @since 5.0.0
*
* @return void
*/
function action_wp_enqueue_scripts() {

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

wp_enqueue_style( 'chriswiegman-style', get_template_directory_uri() . '/assets/css/master' . $min . '.css', array(), CW_THEME_VERSION );

wp_enqueue_script( 'chriswiegman-footer', get_template_directory_uri() . '/assets/js/footer' . $min . '.js', array( 'jquery' ), CW_THEME_VERSION, true );

$vars = array(
'small' => wp_get_attachment_image_src( get_post_thumbnail_id(), array( 150, 150 ) ),
'medium' => wp_get_attachment_image_src( get_post_thumbnail_id(), array( 250, 250 ) ),
'large' => wp_get_attachment_image_src( get_post_thumbnail_id(), array( 350, 350 ) ),
'full' => wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' ),
);

wp_localize_script(
'chriswiegman-footer',
'chriswiegman_featured_image',
$vars
);

if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}

}

/**
* Action wp_head
*
* Clean up the header
*
* @since 5.0.0
*
* @return void
*/
function action_wp_head() {

printf(
'<link rel="alternate" type="%s" title="%s" href="%s" />%s',
esc_attr( feed_content_type() ),
get_the_title() . ' | ' . esc_attr__( 'All Posts', 'chriswiegman' ),
'http://feeds.chriswiegman.com/',
esc_attr( PHP_EOL )
);

printf(
'<link rel="alternate" type="%s" title="%s" href="%s" />%s',
esc_attr( feed_content_type() ),
get_the_title() . ' | ' . esc_attr__( 'All Comments', 'chriswiegman' ),
'http://feeds.chriswiegman.com/comments',
esc_attr( PHP_EOL )
);

}

/**
*Filter body_classees
*
* Adds custom classes to the array of body classes.
*
* @since 5.0.0
*
* @param array $classes Classes for the body element.
*
* @return array
*/
function filter_body_classes( $classes ) {

// Adds a class of group-blog to blogs with more than 1 published author.
if ( is_multi_author() ) {
$classes[] = 'group-blog';
}

return $classes;

}

/**
* Filter excerpt_more
*
* Create the correct more link
*
* @since 5.0.0
*
* @return string The return more text
*/
function filter_excerpt_more() {

return '... <a class="more-link" href="' . esc_url( get_permalink( get_the_ID() ) ) . '">' . sprintf( esc_html__( 'Continue Reading %s', 'chriswiegman' ), '<span class="meta-nav">&rarr;</span>' ) . '</a>';

}

/**
* Filter wp_default_scripts
*
* Removes an extra jQuery Script
*
* @since 5.0.0
*
* @param \WP_Scripts $scripts The Default WordPress scripts.
*
* @return void
*/
function filter_wp_default_scripts( $scripts ) {

if ( ! is_admin() ) {

$scripts->remove( 'jquery' );
$scripts->add( 'jquery', false, array( 'jquery-core' ), '1.11.3' );

}

}

/**
* Filter wp_page_menu_args
*
* Show home item on menu.
*
* @since 5.0.0
*
* @param array $args Array of menu arguments.
*
* @return array Filtered array of menu arguments
*/
function filter_wp_page_menu_args( $args ) {

$args['show_home'] = true;

return $args;

}

/**
* Filter wp_title
*
* Filters wp_title to print a neat <title> tag based on what is being viewed.
*
* @since 5.0.0
*
* @param string $title Default title text for current view.
* @param string $sep Optional separator.
*
* @return string The filtered title.
*/
function filter_wp_title( $title, $sep ) {

if ( is_feed() ) {
return $title;
}

global $page, $paged;

// Add the blog name.
$title .= get_bloginfo( 'name', 'display' );

// Add the blog description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) ) {
$title .= " $sep $site_description";
}

// Add a page number if necessary.
if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
$title .= " $sep " . sprintf( __( 'Page %s', 'chriswiegman' ), max( $paged, $page ) );
}

return $title;

}

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

remove_action( 'wp_head', 'feed_links', 2 );
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'rsd_link' );
remove_action( 'wp_head', 'wlwmanifest_link' );
remove_action( 'wp_head', 'wp_generator' );

add_action( 'after_setup_theme', 'CW\Theme\Functions\Core\action_after_setup_theme' );
add_filter( 'excerpt_more', 'CW\Theme\Functions\Core\filter_excerpt_more' );
add_action( 'init', 'CW\Theme\Functions\Core\action_init' );
add_action( 'widgets_init', 'CW\Theme\Functions\Core\action_widgets_init' );
add_action( 'wp', 'CW\Theme\Functions\Core\action_wp' );
add_action( 'wp_enqueue_scripts', 'CW\Theme\Functions\Core\action_wp_enqueue_scripts' );
add_action( 'wp_head', 'CW\Theme\Functions\Core\action_wp_head' );

add_filter( 'body_class', 'CW\Theme\Functions\Core\filter_body_class' );
add_filter( 'wp_default_scripts', 'CW\Theme\Functions\Core\filter_wp_default_scripts' );
add_filter( 'wp_page_menu_args', 'CW\Theme\Functions\Core\filter_wp_page_menu_args' );
add_filter( 'wp_title', 'CW\Theme\Functions\Core\filter_wp_title', 10, 2 );

}

inc/template-tags.php → includes/functions/template-tags.php View File


+ 0
- 54
lib/css/editor.css View File

@@ -1,54 +0,0 @@
#tinymce {
background: #fff;
color: #5f5f5f;
padding: 8px;
font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
font-weight: 400;
font-size: 22px;
font-size: 1.375rem;
line-height: 1.6; }

#tinymce p {
margin-bottom: 1.5rem; }

#tinymce img.alignleft {
display: inline;
margin: 0 24px 24px 0; }

#tinymce img.centered, #tinymce .aligncenter {
display: block;
margin: 0 auto 24px; }

#tinymce img.alignnone {
display: inline;
margin-bottom: 12px; }

#tinymce h1, #tinymce h2, #tinymce h3, #tinymce h4, #tinymce h5, #tinymce h6 {
font-family: Georgia, Times, Times New Roman, serif;
font-weight: 700; }

#tinymce h2 {
font-size: 30px;
font-size: 1.875rem; }

#tinymce h3 {
font-size: 24px;
font-size: 1.5rem; }

#tinymce h4 {
font-size: 24px;
font-size: 1.5rem;
padding-bottom: 16px;
padding-bottom: 1rem; }

#tinymce h5 {
font-size: 18px;
font-size: 1.125rem; }

#tinymce h6 {
font-size: 16px;
font-size: 1rem; }

#tinymce a {
color: #e80; }
/*# sourceMappingURL=editor.css.map */

+ 0
- 1
lib/css/editor.css.map View File

@@ -1 +0,0 @@
{"version":3,"sources":["../../assets/scss/editor.scss"],"names":[],"mappings":"AAAA;EACC,iBAAmB;EACnB,eAAsB;EACtB,aAAkB;EAClB,0DAA2D;EAC3D,iBAAkB;EAClB,gBAAmB;EACnB,oBAAuB;EACvB,iBAAkB,EAClB;;AAED;EACC,sBAAuB,EACvB;;AAED;EACC,gBAAiB;EACjB,sBAAwB,EACxB;;AAED;EACC,eAAgB;EAChB,oBAAsB,EACtB;;AAED;EACC,gBAAuB;EACvB,oBAAqB,EACrB;;AAED;EACC,oDAAqD;EACrD,iBAAkB,EAClB;;AAED;EACC,gBAAiB;EACjB,oBAAqB,EACrB;;AAED;EACC,gBAAiB;EACjB,kBAAmB,EACnB;;AAED;EACC,gBAAsB;EACtB,kBAAwB;EACxB,qBAAsB;EACtB,qBAAsB,EACtB;;AAED;EACC,gBAAiB;EACjB,oBAAqB,EACrB;;AAED;EACC,gBAAiB;EACjB,gBAAiB,EACjB;;AAED;EACC,YAAa,EACb","file":"editor.css"}

+ 0
- 1
lib/css/editor.min.css View File

@@ -1 +0,0 @@
#tinymce{background:#fff;color:#5f5f5f;padding:8px;font-family:Arial,Helvetica Neue,Helvetica,sans-serif;font-weight:400;font-size:22px;font-size:1.375rem;line-height:1.6}#tinymce p{margin-bottom:1.5rem}#tinymce img.alignleft{display:inline;margin:0 24px 24px 0}#tinymce .aligncenter,#tinymce img.centered{display:block;margin:0 auto 24px}#tinymce img.alignnone{display:inline;margin-bottom:12px}#tinymce h1,#tinymce h2,#tinymce h3,#tinymce h4,#tinymce h5,#tinymce h6{font-family:Georgia,Times,Times New Roman,serif;font-weight:700}#tinymce h2{font-size:30px;font-size:1.875rem}#tinymce h3{font-size:24px;font-size:1.5rem}#tinymce h4{font-size:24px;font-size:1.5rem;padding-bottom:1rem}#tinymce h5{font-size:18px;font-size:1.125rem}#tinymce h6{font-size:16px;font-size:1rem}#tinymce a{color:#e80}

+ 0
- 3459
lib/css/master.css
File diff suppressed because it is too large
View File


+ 0
- 1
lib/css/master.css.map
File diff suppressed because it is too large
View File


+ 0
- 7
lib/css/master.min.css
File diff suppressed because it is too large
View File


+ 0
- 67
lib/js/footer.js View File

@@ -1,67 +0,0 @@
jQuery(document).ready(function(a) {
function b() {
var b = a("article");
e = h.height(), f = b.height() + b.position().top, g = f - e;
}
function c() {
var a = Math.max(0, Math.min(1, h.scrollTop() / g));
i.css({
width: 100 * a + "%"
});
}
var d = a("body");
if (d.hasClass("single") || d.hasClass("page")) {
var e, f, g, h = a(window), i = a(".progress-indicator");
b(), c(), h.on("scroll", function() {
c();
}).on("resize", function() {
b(), c();
});
}
}), function() {
var a = navigator.userAgent.toLowerCase().indexOf("webkit") > -1, b = navigator.userAgent.toLowerCase().indexOf("opera") > -1, c = navigator.userAgent.toLowerCase().indexOf("msie") > -1;
(a || b || c) && document.getElementById && window.addEventListener && window.addEventListener("hashchange", function() {
var a = document.getElementById(location.hash.substring(1));
a && (/^(?:a|select|input|button|textarea)$/i.test(a.tagName) || (a.tabIndex = -1),
a.focus());
}, !1);
}(), jQuery(document).ready(function(a) {
//welcome message
console.log("Thanks for visiting! Please don't forget to subscribe at http://feeds.chriswiegman.com"),
//toggle nav
a(".menu-toggle").on("click", function() {
a("#menu-primary").slideToggle("slow"), a(this).toggleClass("active");
}), //hide the menu button when we resize the menu
a(window).resize(function() {
a(window).width() >= 900 && a("#menu-primary").removeAttr("style");
});
var b = a(".site-header, .progress-indicator");
a(".progress-indicator");
//Add correct class to header on load
a(this).scrollTop() > 10 ? b.hasClass("scrolled") || b.addClass("scrolled") : b.hasClass("scrolled") && b.removeClass("scrolled"),
//Add or removed header class on scroll
a(window).scroll(function() {
a(this).scrollTop() > 55 ? b.hasClass("scrolled") || b.addClass("scrolled") : b.hasClass("scrolled") && b.removeClass("scrolled");
});
var c = 0, d = a(".software-short");
d.each(function() {
a(this).height() > c && (c = a(this).height());
}), d.height(c);
}), /**
* Removes inline styles from element
*
* @param style Name of style to remove
* @return string Inline styles without removed element
*/
jQuery.fn.removeStyle = function(a) {
var b = new RegExp(a + "[^;]+;?", "g");
return this.each(function() {
$(this).attr("style", function(a, c) {
try {
return c.replace(b, "");
} catch (d) {
return "";
}
});
});
};

+ 0
- 1
lib/js/footer.min.js View File

@@ -1 +0,0 @@
jQuery(document).ready(function(a){function b(){var b=a("article");e=h.height(),f=b.height()+b.position().top,g=f-e}function c(){var a=Math.max(0,Math.min(1,h.scrollTop()/g));i.css({width:100*a+"%"})}var d=a("body");if(d.hasClass("single")||d.hasClass("page")){var e,f,g,h=a(window),i=a(".progress-indicator");b(),c(),h.on("scroll",function(){c()}).on("resize",function(){b(),c()})}}),function(){var a=navigator.userAgent.toLowerCase().indexOf("webkit")>-1,b=navigator.userAgent.toLowerCase().indexOf("opera")>-1,c=navigator.userAgent.toLowerCase().indexOf("msie")>-1;(a||b||c)&&document.getElementById&&window.addEventListener&&window.addEventListener("hashchange",function(){var a=document.getElementById(location.hash.substring(1));a&&(/^(?:a|select|input|button|textarea)$/i.test(a.tagName)||(a.tabIndex=-1),a.focus())},!1)}(),jQuery(document).ready(function(a){console.log("Thanks for visiting! Please don't forget to subscribe at http://feeds.chriswiegman.com"),a(".menu-toggle").on("click",function(){a("#menu-primary").slideToggle("slow"),a(this).toggleClass("active")}),a(window).resize(function(){a(window).width()>=900&&a("#menu-primary").removeAttr("style")});var b=a(".site-header, .progress-indicator");a(".progress-indicator");a(this).scrollTop()>10?b.hasClass("scrolled")||b.addClass("scrolled"):b.hasClass("scrolled")&&b.removeClass("scrolled"),a(window).scroll(function(){a(this).scrollTop()>55?b.hasClass("scrolled")||b.addClass("scrolled"):b.hasClass("scrolled")&&b.removeClass("scrolled")});var c=0,d=a(".software-short");d.each(function(){a(this).height()>c&&(c=a(this).height())}),d.height(c)}),jQuery.fn.removeStyle=function(a){var b=new RegExp(a+"[^;]+;?","g");return this.each(function(){$(this).attr("style",function(a,c){try{return c.replace(b,"")}catch(d){return""}})})};

+ 19
- 15
package.json View File

@@ -1,22 +1,26 @@
{
"name" : "ChrisWiegman",
"private" : true,
"version" : "2.2.0",
"description" : "Grunt base for the ChrisWiegman.com theme.",
"dependencies" : { },
"name": "ChrisWiegman",
"private": true,
"version": "5.0.0",
"description": "Grunt base for the ChrisWiegman.com Theme.",
"dependencies": {},
"devDependencies": {
"grunt" : "*",
"grunt-contrib-clean" : "*",
"grunt": "*",
"grunt-contrib-uglify": "*",
"grunt-contrib-watch" : "*",
"grunt-sass" : "*",
"grunt-contrib-watch": "*",
"load-grunt-tasks": "*",
"grunt-wp-i18n": "*",
"grunt-sass": "*",
"grunt-contrib-clean": "*",
"grunt-contrib-cssmin": "*",
"load-grunt-tasks" : "*",
"grunt-autoprefixer" : "*"
"grunt-phpunit": "*",
"grunt-contrib-jshint": "*",
"grunt-browser-sync": "*",
"grunt-autoprefixer": "*"
},
"author" : "Chris Wiegman",
"repository" : {
"author": "Chris Wiegman",
"repository": {
"type": "git",
"url" : "https://bitbucket.org/ChrisWiegman/chriswiegman-theme.git"
"url": "https://github.com/ChrisWiegman/chriswiegman-theme"
}
}
}

+ 21
- 0
phpunit.xml View File

@@ -0,0 +1,21 @@
<phpunit
bootstrap="bootstrap.php"
backupGlobals="false"
processIsolation="false"
colors="false">
<testsuites>
<testsuite name="Default">
<directory suffix="Tests.php">./tests/phpunit</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./includes</directory>
</whitelist>
</filter>
<php>
<ini name="error_reporting" value="32767"/>
<ini name="display_errors" value="1"/>
<ini name="display_startup_errors" value="1"/>
</php>
</phpunit>

+ 1
- 1
style.css View File

@@ -4,7 +4,7 @@ Theme URI: http://underscores.me/
Author: Chris Wiegman
Author URI: https://www.chriswiegman.com/
Description: Theme for ChrisWiegman.com
Version: 1.2.0
Version: 5.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: chriswiegman


+ 49
- 0
tests/phpunit/Core_Tests.php View File

@@ -0,0 +1,49 @@
<?php
/**
* Test Core functions
*
* Unit tests for Core functions
*
* @since 0.1.0
*
* @package CW\Theme\Core
*
* @author Chris Wiegman <chris@chriswiegman.com>
*/

namespace CW\Theme\Functions\Core;

use CW\Theme as Base;

/**
* Class Core_Tests
*/
class Functions_Tests extends Base\TestCase {

/**
* Files required for test.
*
* @var array
*/
protected $test_files = array(
'functions/core.php',
);

/**
* Test theme setup
*
* @since 5.0.0
*/
function test_init() {

// Setup.
\WP_Mock::expectActionAdded( 'after_setup_theme', '\CW\Theme\Functions\Core\setup' );

// Act.
init();

// Verify.
$this->assertConditionsMet();

}
}

+ 82
- 0
tests/phpunit/test-tools/TestCase.php View File

@@ -0,0 +1,82 @@
<?php

namespace CW\Theme;

use PHPUnit_Framework_TestResult;
use Text_Template;
use WP_Mock;
use WP_Mock\Tools\TestCase as BaseTestCase;

class TestCase extends BaseTestCase {

public function run( PHPUnit_Framework_TestResult $result = null ) {

$this->setPreserveGlobalState( false );

return parent::run( $result );
}

protected $test_files = array();

public function setUp() {

if ( ! empty( $this->test_files ) ) {
foreach ( $this->test_files as $file ) {
if ( file_exists( PROJECT . $file ) ) {
require_once( PROJECT . $file );
}
}
}

parent::setUp();
}

public function assertActionsCalled() {

$actions_not_added = $expected_actions = 0;
try {
WP_Mock::assertActionsCalled();
} catch ( \Exception $e ) {
$actions_not_added = 1;
$expected_actions = $e->getMessage();
}
$this->assertEmpty( $actions_not_added, $expected_actions );
}

public function ns( $function ) {

if ( ! is_string( $function ) || false !== strpos( $function, '\\' ) ) {
return $function;
}

$thisClassName = trim( get_class( $this ), '\\' );

if ( ! strpos( $thisClassName, '\\' ) ) {
return $function;
}

// $thisNamespace is constructed by exploding the current class name on
// namespace separators, running array_slice on that array starting at 0
// and ending one element from the end (chops the class name off) and
// imploding that using namespace separators as the glue.
$thisNamespace = implode( '\\', array_slice( explode( '\\', $thisClassName ), 0, - 1 ) );

return "$thisNamespace\\$function";
}

/**
* Define constants after requires/includes
*
* See http://kpayne.me/2012/07/02/phpunit-process-isolation-and-constant-already-defined/
* for more details
*
* @param \Text_Template $template
*/
public function prepareTemplate( \Text_Template $template ) {

$template->setVar( [
'globals' => '$GLOBALS[\'__PHPUNIT_BOOTSTRAP\'] = \'' . $GLOBALS['__PHPUNIT_BOOTSTRAP'] . '\';',
] );
parent::prepareTemplate( $template );
}
}