Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Initial commit
  • Loading branch information
ryelle committed Dec 5, 2015
0 parents commit 47d11b3
Show file tree
Hide file tree
Showing 66 changed files with 2,707 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
@@ -0,0 +1,2 @@
js/app.js
gulpfile.js
83 changes: 83 additions & 0 deletions .eslintrc
@@ -0,0 +1,83 @@
{
"parser": "babel-eslint",
"env": {
"browser": true,
"es6": true,
"mocha": true,
"node": true
},
"ecmaFeatures": {
"jsx": true,
"modules": true
},
"plugins": [
"eslint-plugin-react"
],
"rules": {
"brace-style": [ 1, "1tbs" ],
// REST API objects include underscores
"camelcase": 0,
"comma-dangle": 0,
"comma-spacing": 1,
// Allows returning early as undefined
"consistent-return": 0,
"dot-notation": 1,
"eqeqeq": [ 2, "allow-null" ],
"eol-last": 1,
"indent": [ 1, "tab", { "SwitchCase": 1 } ],
"key-spacing": 1,
// Most common is "Emitter", should be improved
"new-cap": 1,
"no-cond-assign": 2,
"no-else-return": 1,
"no-empty": 1,
// Flux stores use switch case fallthrough
"no-fallthrough": 0,
"no-lonely-if": 1,
"no-mixed-requires": 0,
"no-mixed-spaces-and-tabs": 1,
"no-multiple-empty-lines": [ 1, { max: 1 } ],
"no-multi-spaces": 1,
"no-nested-ternary": 1,
"no-new": 1,
"no-process-exit": 1,
"no-shadow": 1,
"no-spaced-func": 1,
"no-trailing-spaces": 1,
"no-undef": 1,
"no-underscore-dangle": 0,
// Allows Chai `expect` expressions
"no-unused-expressions": 0,
"no-unused-vars": 1,
// Teach eslint about React+JSX
"react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1,
// Allows function use before declaration
"no-use-before-define": [ 2, "nofunc" ],
// We split external, internal, module variables
"one-var": 0,
"operator-linebreak": [ 1, "after", { "overrides": {
"?": "before",
":": "before"
} } ],
"padded-blocks": [ 1, "never" ],
"quote-props": [ 1, "as-needed" ],
"quotes": [ 1, "single", "avoid-escape" ],
"semi-spacing": 1,
"space-after-keywords": [ 1, "always" ],
"space-before-blocks": [ 1, "always" ],
"space-before-function-paren": [ 1, "never" ],
// Our array literal index exception violates this rule
"space-in-brackets": 0,
"space-in-parens": [ 1, "always" ],
"space-infix-ops": [ 1, { "int32Hint": false } ],
// Ideal for "!" but not for "++"
"space-unary-ops": 0,
// Assumed by default with Babel
"strict": [ 2, "never" ],
"valid-jsdoc": [ 1, { "requireReturn": false } ],
// Common top-of-file requires, expressions between external, interal
"vars-on-top": 1,
"yoda": 0
}
}
6 changes: 6 additions & 0 deletions .gitignore
@@ -0,0 +1,6 @@
node_modules
js/app.js
js/app.js.map
style.css
style.css.map
sass-cache
34 changes: 34 additions & 0 deletions README.md
@@ -0,0 +1,34 @@
Foxhound
========

A react-based theme for WordPress.

Want to try out the theme? Download or clone this repo into your `/themes` folder, then run npm & gulp to install and build the javascript & CSS files. The process will look like this

git clone https://github.com/ryelle/Foxhound foxhound
cd foxhound
npm install
gulp

Now you'll see a `js/app.js` file in the theme, and it will be available for you to switch to in wp-admin. If you're having trouble getting the theme active, please [file an issue](https://github.com/ryelle/Foxhound/issues) & I'll help you out.

_If you don't have npm or gulp installed, you can find instructions on their websites: [gulp](http://gulpjs.com/), [npm](http://npmjs.com)._

Setup
-----

Since this is a more "experimental" theme, you'll need to have a few things set up before it'll work.

1. You'll need the [WP REST API plugin](https://wordpress.org/plugins/rest-api/). WP 4.4 has the framework for the REST API, but the actual content of it still requires the plugin.
2. You'll also need this [WP-API Menus plugin](https://wordpress.org/plugins/wp-api-menus/). The REST API doesn't provide an endpoint for menus, so another plugin is necessary.
3. Your permalinks will need to be set to `/%year%/%monthnum%/%postname%/`. Single-post/page views will not work without permalinks set.

Display & Features
------------------

This theme has **no** comments.

Known Issues/To Do
------------------

- Build entire theme.
28 changes: 28 additions & 0 deletions footer.php
@@ -0,0 +1,28 @@
<?php
/**
* The template for displaying the footer.
*
* Contains the closing of the #content div and all content after.
*
* @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
*
* @package Foxhound
*/

?>

</div><!-- #content -->

<footer id="colophon" class="site-footer" role="contentinfo">
<div class="site-info">
<a href="<?php echo esc_url( __( 'https://wordpress.org/', 'foxhound' ) ); ?>"><?php printf( esc_html__( 'Proudly powered by %s', 'foxhound' ), 'WordPress' ); ?></a>
<span class="sep"> | </span>
<?php printf( esc_html__( 'Theme: %1$s by %2$s.', 'foxhound' ), 'foxhound', '<a href="http://themes.redradar.net" rel="designer">Kelly Dwan & Mel Choyce</a>' ); ?>
</div><!-- .site-info -->
</footer><!-- #colophon -->
</div><!-- #page -->

<?php wp_footer(); ?>

</body>
</html>
184 changes: 184 additions & 0 deletions functions.php
@@ -0,0 +1,184 @@
<?php
/**
* Foxhound functions and definitions.
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package Foxhound
*/

if ( ! defined( 'FOXHOUND_VERSION' ) ) {
define( 'FOXHOUND_VERSION', time() );
}

if ( ! function_exists( 'foxhound_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/
function foxhound_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on Foxhound, use a find and replace
* to change 'foxhound' to the name of your theme in all the template files.
*/
load_theme_textdomain( 'foxhound', get_template_directory() . '/languages' );

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

/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );

/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );

// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => esc_html__( 'Primary Menu', 'foxhound' ),
) );

/*
* 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',
) );

/*
* Enable support for Post Formats.
* See https://developer.wordpress.org/themes/functionality/post-formats/
*/
add_theme_support( 'post-formats', array(
'aside',
'image',
'video',
'quote',
'link',
) );

add_post_type_support( 'post', 'comments' );
add_post_type_support( 'page', 'comments' );
}
endif; // foxhound_setup
add_action( 'after_setup_theme', 'foxhound_setup' );

/**
* Set the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
function foxhound_content_width() {
$GLOBALS['content_width'] = apply_filters( 'foxhound_content_width', 730 );
}
add_action( 'after_setup_theme', 'foxhound_content_width', 0 );

/**
* Enqueue scripts and styles.
*/
function foxhound_scripts() {
wp_enqueue_style( 'foxhound-style', get_stylesheet_uri() );
wp_enqueue_script( 'foxhound-react', get_template_directory_uri() . '/js/app.js', array( 'jquery' ), FOXHOUND_VERSION, true );

wp_localize_script( 'foxhound-react', 'FoxhoundSettings', array(
'nonce' => wp_create_nonce( 'wp_rest' ),
'user' => get_current_user_id(),
'title' => get_bloginfo( 'name', 'display' ),
'URL' => array(
'root' => esc_url_raw( get_rest_url( null, '/wp/v2' ) ),
'menuRoot' => esc_url_raw( get_rest_url( null, '/wp-api-menus/v2' ) ),
'base' => esc_url_raw( home_url() ),
),
) );
}
add_action( 'wp_enqueue_scripts', 'foxhound_scripts' );

/**
* Returns the Google font stylesheet URL, if available.
*
* The use of Source Serif Pro and Source Code Pro by default is
* localized. For languages that use characters not supported by
* either font, the font can be disabled.
*
* @return string Font stylesheet or empty string if disabled.
*/
function foxhound_fonts_url() {
$fonts_url = '';

/* Translators: If there are characters in your language that are not
* supported by Source Serif Pro, translate this to 'off'. Do not translate
* into your own language.
*/
$serifpro = _x( 'on', 'Source Serif Pro font: on or off', 'foxhound' );

/* Translators: If there are characters in your language that are not
* supported by Source Code Pro, translate this to 'off'. Do not translate into
* your own language.
*/
$codepro = _x( 'on', 'Source Code Pro font: on or off', 'foxhound' );

if ( 'off' !== $serifpro || 'off' !== $codepro ) {
$font_families = array();

if ( 'off' !== $serifpro )
$font_families[] = urlencode( 'Source Serif Pro:400,700' );

if ( 'off' !== $codepro )
$font_families[] = urlencode( 'Source Code Pro:400,600' );

$protocol = is_ssl() ? 'https' : 'http';
$query_args = array(
'family' => implode( '|', $font_families ),
'subset' => urlencode( 'latin,latin-ext' ),
);
$fonts_url = add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" );
}

return $fonts_url;
}

/**
* Loads our special font CSS file.
*
* To disable in a child theme, use wp_dequeue_style()
* function mytheme_dequeue_fonts() {
* wp_dequeue_style( 'foxhound-fonts' );
* }
* add_action( 'wp_enqueue_scripts', 'mytheme_dequeue_fonts', 11 );
*
* @return void
*/
function foxhound_fonts() {
$fonts_url = foxhound_fonts_url();
if ( ! empty( $fonts_url ) )
wp_enqueue_style( 'foxhound-fonts', esc_url_raw( $fonts_url ), array(), null );
}
add_action( 'wp_enqueue_scripts', 'foxhound_fonts' );

/**
* Add theme support for Jetpack Features
*/
function foxhound_jetpack_setup() {
add_theme_support( 'site-logo' );
}
add_action( 'after_setup_theme', 'foxhound_jetpack_setup' );

0 comments on commit 47d11b3

Please sign in to comment.