Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

Feature/protocol relative theme assets #430

Merged
merged 5 commits into from
Aug 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions codesniffer.ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar" />
<exclude name="Squiz.Commenting.ClassComment.Missing" />
<exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace" />
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterOpenHint" />

<exclude name="WordPress.XSS.EscapeOutput.UnsafePrintingFunction" />
<exclude name="WordPress.XSS.EscapeOutput.OutputNotEscaped" />
<exclude name="WordPress.Arrays.ArrayDeclaration.NoSpaceAfterOpenParenthesis" />
<exclude name="WordPress.Variables.GlobalVariables" />
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceAfterOpenParenthesis" />
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceBeforeCloseParenthesis)" />
</rule>
</ruleset>
5 changes: 4 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,7 @@
/** Add Nav Options to Customer */
require_once( 'library/custom-nav.php' );

?>
/** Add protocol relative theme assets */
require_once( 'library/protocol-relative-theme-assets.php' );

?>
2 changes: 1 addition & 1 deletion library/cleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function foundationpress_remove_recent_comments_style() {

// Remove injected CSS from gallery.
if ( ! function_exists( 'foundationpress_gallery_style' ) ) :
function foundationpress_gallery_style($css) {
function foundationpress_gallery_style( $css ) {
return preg_replace( "!<style type='text/css'>(.*?)</style>!s", '', $css );
}
endif;
Expand Down
52 changes: 26 additions & 26 deletions library/foundation.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,27 @@ class Foundationpress_Comments extends Walker_Comment{
* You'll have to use this if you plan to get to the top of the comments list, as
* start_lvl() only goes as high as 1 deep nested comments */
function __construct() { ?>

<h3><?php comments_number( __( 'No Responses to', 'foundationpress' ), __( 'One Response to', 'foundationpress' ), __( '% Responses to', 'foundationpress' ) ); ?> &#8220;<?php the_title(); ?>&#8221;</h3>
<ol class="comment-list">

<?php }

/** START_LVL
* Starts the list before the CHILD elements are added. */
function start_lvl( &$output, $depth = 0, $args = array() ) {
$GLOBALS['comment_depth'] = $depth + 1; ?>

<ul class="children">
<?php }

/** END_LVL
* Ends the children list of after the elements are added. */
function end_lvl( &$output, $depth = 0, $args = array() ) {
$GLOBALS['comment_depth'] = $depth + 1; ?>

</ul><!-- /.children -->

<?php }

/** START_EL */
Expand All @@ -131,38 +131,38 @@ function start_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 ) {
$GLOBALS['comment_depth'] = $depth;
$GLOBALS['comment'] = $comment;
$parent_class = ( empty( $args['has_children'] ) ? '' : 'parent' ); ?>

<li <?php comment_class( $parent_class ); ?> id="comment-<?php comment_ID() ?>">
<article id="comment-body-<?php comment_ID() ?>" class="comment-body">
<header class="comment-author">



<header class="comment-author">

<?php echo get_avatar( $comment, $args['avatar_size'] ); ?>
<div class="author-meta vcard author">

<div class="author-meta vcard author">

<?php printf( __( '<cite class="fn">%s</cite>', 'foundationpress' ), get_comment_author_link() ) ?>
<time datetime="<?php echo comment_date( 'c' ) ?>"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf( __( '%1$s', 'foundationpress' ), get_comment_date(), get_comment_time() ) ?></a></time>

</div><!-- /.comment-author -->

</header>

<section id="comment-content-<?php comment_ID(); ?>" class="comment">
<?php if ( ! $comment->comment_approved ) : ?>
<div class="notice">
<p class="bottom"><?php $args['moderation']; ?></p>
</div>
</div>
<?php else : comment_text(); ?>
<?php endif; ?>
</section><!-- /.comment-content -->

<div class="comment-meta comment-meta-data hide">
<a href="<?php echo htmlspecialchars( get_comment_link( get_comment_ID() ) ) ?>"><?php comment_date(); ?> at <?php comment_time(); ?></a> <?php edit_comment_link( '(Edit)' ); ?>
</div><!-- /.comment-meta -->

<div class="reply">
<?php $reply_args = array(
'depth' => $depth,
Expand All @@ -172,20 +172,20 @@ function start_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 ) {
comment_reply_link( array_merge( $args, $reply_args ) ); ?>
</div><!-- /.reply -->
</article><!-- /.comment-body -->

<?php }

function end_el(&$output, $comment, $depth = 0, $args = array() ) { ?>
function end_el(& $output, $comment, $depth = 0, $args = array() ) { ?>

</li><!-- /#comment-' . get_comment_ID() . ' -->

<?php }

/** DESTRUCTOR */
function __destruct() { ?>

</ol><!-- /#comment-list -->

<?php }
}
endif;
Expand Down
3 changes: 1 addition & 2 deletions library/menu-walker.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ function start_el( &$output, $object, $depth = 0, $args = array(), $current_obje
function start_lvl( &$output, $depth = 0, $args = array() ) {
$output .= "\n<ul class=\"sub-menu dropdown\">\n";
}

}
endif;
?>
?>
6 changes: 3 additions & 3 deletions library/navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function foundationpress_top_bar_r() {
* Mobile off-canvas
*/
if ( ! function_exists( 'foundationpress_mobile_off_canvas' ) ) {
function foundationpress_mobile_off_canvas($direction = 'left') {
function foundationpress_mobile_off_canvas( $direction = 'left' ) {
wp_nav_menu(array(
'container' => false, // Remove nav container
'container_class' => '', // Class of container
Expand All @@ -90,7 +90,7 @@ function foundationpress_mobile_off_canvas($direction = 'left') {
* 4) Save Menu. Your menu item will now appear as a button in your top-menu
*/
if ( ! function_exists( 'foundationpress_add_menuclass' ) ) {
function foundationpress_add_menuclass($ulclass) {
function foundationpress_add_menuclass( $ulclass ) {
$find = array('/<a rel="button"/', '/<a title=".*?" rel="button"/');
$replace = array('<a rel="button" class="button"', '<a rel="button" class="button"');

Expand All @@ -107,7 +107,7 @@ function foundationpress_add_menuclass($ulclass) {
*/

if ( ! function_exists( 'foundationpress_breadcrumb' ) ) {
function foundationpress_breadcrumb($showhome = true, $separatorclass = false) {
function foundationpress_breadcrumb( $showhome = true, $separatorclass = false ) {

// Settings
$separator = '&gt;';
Expand Down
3 changes: 1 addition & 2 deletions library/offcanvas-walker.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Foundationpress_Offcanvas_Walker extends Walker_Nav_Menu {

private $direction = 'left';

public function __construct($direction) {
public function __construct( $direction ) {
$this->direction = $direction;
}

Expand Down Expand Up @@ -45,7 +45,6 @@ function start_el( &$output, $object, $depth = 0, $args = array(), $current_obje
function start_lvl( &$output, $depth = 0, $args = array() ) {
$output .= "\n<ul class=\"{$this->direction}-submenu\">\n<li class=\"back\"><a href=\"#\">". __( 'Back', 'foundationpress' ) ."</a></li>\n";
}

}
endif;
?>
93 changes: 93 additions & 0 deletions library/protocol-relative-theme-assets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php
/**
* Protocol Relative Theme Assets
*
* @package WordPress
* @subpackage FoundationPress
* @since FoundationPress 1.1.0
*/

if ( ! class_exists( 'Foundationpress_protocol_relative_theme_assets' ) ) :
class Foundationpress_protocol_relative_theme_assets {
/**
* Plugin URI: https://github.com/ryanjbonnell/Protocol-Relative-Theme-Assets
* Description: Transforms enqueued CSS and JavaScript theme URLs to use protocol-relative paths.
* Version: 1.0
* Author: Ryan J. Bonnell
* Author URI: https://github.com/ryanjbonnell
*
* Class Constructor
*
* @access public
* @since 1.0
*/
public function __construct() {
add_filter( 'style_loader_src', array( $this, 'style_loader_src' ), 10, 2 );
add_filter( 'script_loader_src', array( $this, 'script_loader_src' ), 10, 2 );

add_filter( 'template_directory_uri', array( $this, 'template_directory_uri' ), 10, 3 );
add_filter( 'stylesheet_directory_uri', array( $this, 'stylesheet_directory_uri' ), 10, 3 );
}

/**
* Convert
*
* @access private
* @return string
* @since 1.0
*/
private function make_protocol_relative_url( $url ) {
return preg_replace( '(https?://)', '//', $url );
}

/**
* Transform Enqueued Stylesheet URLs
*
* @access public
* @return string
* @since 1.0
*/
public function style_loader_src( $src, $handle ) {
return $this->make_protocol_relative_url( $src );
}

/**
* Transform Enqueued JavaScript URLs
*
* @access public
* @return string
* @since 1.0
*/
public function script_loader_src( $src, $handle ) {
return $this->make_protocol_relative_url( $src );
}

/**
* Transform Enqueued Theme Files
*
* @access public
* @return string
* @since 1.0
* @link http://codex.wordpress.org/Function_Reference/get_template_directory_uri
*/
public function template_directory_uri( $template_dir_uri, $template, $theme_root_uri ) {
return $this->make_protocol_relative_url( $template_dir_uri );
}

/**
* Transform Enqueued Theme Files
*
* @access public
* @return string
* @since 1.0
* @link http://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri
*/
public function stylesheet_directory_uri( $stylesheet_dir_uri, $stylesheet, $theme_root_uri ) {
return $this->make_protocol_relative_url( $stylesheet_dir_uri );
}
}

$Foundationpress_protocol_relative_theme_assets = new Foundationpress_protocol_relative_theme_assets;
endif;

?>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "foundationpress",
"title": "FoundationPress",
"version": "1.1.0",
"version": "1.2.0",
"description": "FoundationPress is a WordPress starter theme based on Foundation 5 by Zurb",
"keywords": [ "FoundationPress", "WordPress", "starter theme", "Foundation", "semantic", "mobile first", "customizable", "responsive" ],
"homepage": "http://foundationpress.olefredrik.com/",
Expand Down
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Theme Name: FoundationPress
Theme URI: http://foundationpress.olefredrik.com
Github Theme URI: https://github.com/olefredrik/FoundationPress
Description: FoundationPress is a WordPress starter theme based on Foundation 5 by Zurb
Version: 1.1.0
Version: 1.2.0
Author: Ole Fredrik Lie
Author URI: http://olefredrik.com/

Expand Down