adding fresh FoundationPress theme from scratch

This commit is contained in:
ut 2018-10-26 11:51:32 +02:00
commit 3785add5fa
127 changed files with 29293 additions and 0 deletions

View file

@ -0,0 +1,118 @@
<?php
/**
* FoundationPress Comments
*
* @package FoundationPress
*/
if ( ! class_exists( 'Foundationpress_Comments' ) ) :
class Foundationpress_Comments extends Walker_Comment {
// Init classwide variables.
public $tree_type = 'comment';
// Comment ID
public $db_fields = array(
'parent' => 'comment_parent',
'id' => 'comment_ID',
);
/** CONSTRUCTOR
* 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 */
function start_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 ) {
$depth++;
$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">
<?php echo get_avatar( $comment, $args['avatar_size'] ); ?>
<div class="author-meta vcard author">
<?php
/* translators: %s: comment author link */
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( 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 _e( 'Your comment is awaiting moderation.', 'foundationpress' ); ?></p>
</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,
'max_depth' => $args['max_depth'],
);
comment_reply_link( array_merge( $args, $reply_args ) ); ?>
</div><!-- /.reply -->
</article><!-- /.comment-body -->
<?php }
function end_el( & $output, $comment, $depth = 0, $args = array() ) { ?>
</li><!-- /#comment-' . get_comment_ID() . ' -->
<?php }
/** DESTRUCTOR */
function __destruct() { ?>
</ol><!-- /#comment-list -->
<?php
}
}
endif;

View file

@ -0,0 +1,20 @@
<?php
/**
* Customize the output of menus for Foundation mobile walker
*
* @package FoundationPress
* @since FoundationPress 1.0.0
*/
/**
* Big thanks to Brett Mason (https://github.com/brettsmason) for the awesome walker
*/
if ( ! class_exists( 'Foundationpress_Mobile_Walker' ) ) :
class Foundationpress_Mobile_Walker extends Walker_Nav_Menu {
function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat( "\t", $depth );
$output .= "\n$indent<ul class=\"vertical nested menu\">\n";
}
}
endif;

View file

@ -0,0 +1,90 @@
<?php
/**
* Protocol Relative Theme Assets
*
* @package 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;

View file

@ -0,0 +1,20 @@
<?php
/**
* Customize the output of menus for Foundation top bar
*
* @package FoundationPress
* @since FoundationPress 1.0.0
*/
/**
* Big thanks to Brett Mason (https://github.com/brettsmason) for the awesome walker
*/
if ( ! class_exists( 'Foundationpress_Top_Bar_Walker' ) ) :
class Foundationpress_Top_Bar_Walker extends Walker_Nav_Menu {
function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat( "\t", $depth );
$output .= "\n$indent<ul class=\"dropdown menu vertical\" data-toggle>\n";
}
}
endif;

View file

@ -0,0 +1,100 @@
<?php
/**
* Clean up WordPress defaults
*
* @package FoundationPress
* @since FoundationPress 1.0.0
*/
if ( ! function_exists( 'foundationpress_start_cleanup' ) ) :
function foundationpress_start_cleanup() {
// Launching operation cleanup.
add_action( 'init', 'foundationpress_cleanup_head' );
// Remove WP version from RSS.
add_filter( 'the_generator', 'foundationpress_remove_rss_version' );
// Remove pesky injected css for recent comments widget.
add_filter( 'wp_head', 'foundationpress_remove_wp_widget_recent_comments_style', 1 );
// Clean up comment styles in the head.
add_action( 'wp_head', 'foundationpress_remove_recent_comments_style', 1 );
}
add_action( 'after_setup_theme', 'foundationpress_start_cleanup' );
endif;
/**
* Clean up head.+
* ----------------------------------------------------------------------------
*/
if ( ! function_exists( 'foundationpress_cleanup_head' ) ) :
function foundationpress_cleanup_head() {
// EditURI link.
remove_action( 'wp_head', 'rsd_link' );
// Category feed links.
remove_action( 'wp_head', 'feed_links_extra', 3 );
// Post and comment feed links.
remove_action( 'wp_head', 'feed_links', 2 );
// Windows Live Writer.
remove_action( 'wp_head', 'wlwmanifest_link' );
// Index link.
remove_action( 'wp_head', 'index_rel_link' );
// Previous link.
remove_action( 'wp_head', 'parent_post_rel_link', 10 );
// Start link.
remove_action( 'wp_head', 'start_post_rel_link', 10 );
// Canonical.
remove_action( 'wp_head', 'rel_canonical', 10 );
// Shortlink.
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10 );
// Links for adjacent posts.
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10 );
// WP version.
remove_action( 'wp_head', 'wp_generator' );
// Emoji detection script.
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
// Emoji styles.
remove_action( 'wp_print_styles', 'print_emoji_styles' );
}
endif;
// Remove WP version from RSS.
if ( ! function_exists( 'foundationpress_remove_rss_version' ) ) :
function foundationpress_remove_rss_version() {
return '';
}
endif;
// Remove injected CSS for recent comments widget.
if ( ! function_exists( 'foundationpress_remove_wp_widget_recent_comments_style' ) ) :
function foundationpress_remove_wp_widget_recent_comments_style() {
if ( has_filter( 'wp_head', 'wp_widget_recent_comments_style' ) ) {
remove_filter( 'wp_head', 'wp_widget_recent_comments_style' );
}
}
endif;
// Remove injected CSS from recent comments widget.
if ( ! function_exists( 'foundationpress_remove_recent_comments_style' ) ) :
function foundationpress_remove_recent_comments_style() {
global $wp_widget_factory;
if ( isset( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'] ) ) {
remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
}
}
endif;

View file

@ -0,0 +1,70 @@
<?php
/**
* Allow users to select Topbar or Offcanvas menu. Adds body class of offcanvas or topbar based on which they choose.
*
* @package FoundationPress
* @since FoundationPress 1.0.0
*/
if ( ! function_exists( 'wpt_register_theme_customizer' ) ) :
function wpt_register_theme_customizer( $wp_customize ) {
// Create custom panels
$wp_customize->add_panel(
'mobile_menu_settings', array(
'priority' => 1000,
'theme_supports' => '',
'title' => __( 'Mobile Menu Settings', 'foundationpress' ),
'description' => __( 'Controls the mobile menu', 'foundationpress' ),
)
);
// Create custom field for mobile navigation layout
$wp_customize->add_section(
'mobile_menu_layout', array(
'title' => __( 'Mobile navigation layout', 'foundationpress' ),
'panel' => 'mobile_menu_settings',
'priority' => 1000,
)
);
// Set default navigation layout
$wp_customize->add_setting(
'wpt_mobile_menu_layout',
array(
'default' => __( 'topbar', 'foundationpress' ),
)
);
// Add options for navigation layout
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'mobile_menu_layout',
array(
'type' => 'radio',
'section' => 'mobile_menu_layout',
'settings' => 'wpt_mobile_menu_layout',
'choices' => array(
'topbar' => 'Topbar',
'offcanvas' => 'Offcanvas',
),
)
)
);
}
add_action( 'customize_register', 'wpt_register_theme_customizer' );
// Add class to body to help w/ CSS
add_filter( 'body_class', 'mobile_nav_class' );
function mobile_nav_class( $classes ) {
if ( ! get_theme_mod( 'wpt_mobile_menu_layout' ) || get_theme_mod( 'wpt_mobile_menu_layout' ) === 'topbar' ) :
$classes[] = 'topbar';
elseif ( get_theme_mod( 'wpt_mobile_menu_layout' ) === 'offcanvas' ) :
$classes[] = 'offcanvas';
endif;
return $classes;
}
endif;

View file

@ -0,0 +1,71 @@
<?php
/**
* Enqueue all styles and scripts
*
* Learn more about enqueue_script: {@link https://codex.wordpress.org/Function_Reference/wp_enqueue_script}
* Learn more about enqueue_style: {@link https://codex.wordpress.org/Function_Reference/wp_enqueue_style }
*
* @package FoundationPress
* @since FoundationPress 1.0.0
*/
// Check to see if rev-manifest exists for CSS and JS static asset revisioning
//https://github.com/sindresorhus/gulp-rev/blob/master/integration.md
if ( ! function_exists( 'foundationpress_asset_path' ) ) :
function foundationpress_asset_path( $filename ) {
$filename_split = explode( '.', $filename );
$dir = end( $filename_split );
$manifest_path = dirname( dirname( __FILE__ ) ) . '/dist/assets/' . $dir . '/rev-manifest.json';
if ( file_exists( $manifest_path ) ) {
$manifest = json_decode( file_get_contents( $manifest_path ), true );
} else {
$manifest = [];
}
if ( array_key_exists( $filename, $manifest ) ) {
return $manifest[ $filename ];
}
return $filename;
}
endif;
if ( ! function_exists( 'foundationpress_scripts' ) ) :
function foundationpress_scripts() {
// Enqueue the main Stylesheet.
wp_enqueue_style( 'main-stylesheet', get_stylesheet_directory_uri() . '/dist/assets/css/' . foundationpress_asset_path( 'app.css' ), array(), '2.10.4', 'all' );
// Deregister the jquery version bundled with WordPress.
wp_deregister_script( 'jquery' );
// CDN hosted jQuery placed in the header, as some plugins require that jQuery is loaded in the header.
wp_enqueue_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js', array(), '3.2.1', false );
// Deregister the jquery-migrate version bundled with WordPress.
wp_deregister_script( 'jquery-migrate' );
// CDN hosted jQuery migrate for compatibility with jQuery 3.x
wp_register_script( 'jquery-migrate', '//code.jquery.com/jquery-migrate-3.0.1.min.js', array('jquery'), '3.0.1', false );
// Enqueue jQuery migrate. Uncomment the line below to enable.
// wp_enqueue_script( 'jquery-migrate' );
// Enqueue Foundation scripts
wp_enqueue_script( 'foundation', get_stylesheet_directory_uri() . '/dist/assets/js/' . foundationpress_asset_path( 'app.js' ), array( 'jquery' ), '2.10.4', true );
// Enqueue FontAwesome from CDN. Uncomment the line below if you need FontAwesome.
//wp_enqueue_script( 'fontawesome', 'https://use.fontawesome.com/5016a31c8c.js', array(), '4.7.0', true );
// Add the comment-reply library on pages where it is necessary
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'foundationpress_scripts' );
endif;

View file

@ -0,0 +1,15 @@
<?php
/**
* Entry meta information for posts
*
* @package FoundationPress
* @since FoundationPress 1.0.0
*/
if ( ! function_exists( 'foundationpress_entry_meta' ) ) :
function foundationpress_entry_meta() {
/* translators: %1$s: current date, %2$s: current time */
echo '<time class="updated" datetime="' . get_the_time( 'c' ) . '">' . sprintf( __( 'Posted on %1$s at %2$s.', 'foundationpress' ), get_the_date(), get_the_time() ) . '</time>';
echo '<p class="byline author">' . __( 'Written by', 'foundationpress' ) . ' <a href="' . get_author_posts_url( get_the_author_meta( 'ID' ) ) . '" rel="author" class="fn">' . get_the_author() . '</a></p>';
}
endif;

View file

@ -0,0 +1,325 @@
<?php
/**
* Foundation PHP template
*
* @package FoundationPress
* @since FoundationPress 1.0.0
*/
// Pagination.
if ( ! function_exists( 'foundationpress_pagination' ) ) :
function foundationpress_pagination() {
global $wp_query;
$big = 999999999; // This needs to be an unlikely integer
// For more options and info view the docs for paginate_links()
// http://codex.wordpress.org/Function_Reference/paginate_links
$paginate_links = paginate_links(
array(
'base' => str_replace( $big, '%#%', html_entity_decode( get_pagenum_link( $big ) ) ),
'current' => max( 1, get_query_var( 'paged' ) ),
'total' => $wp_query->max_num_pages,
'mid_size' => 5,
'prev_next' => true,
'prev_text' => __( '&laquo;', 'foundationpress' ),
'next_text' => __( '&raquo;', 'foundationpress' ),
'type' => 'list',
)
);
$paginate_links = str_replace( "<ul class='page-numbers'>", "<ul class='pagination text-center' role='navigation' aria-label='Pagination'>", $paginate_links );
$paginate_links = str_replace( '<li><span class="page-numbers dots">', "<li><a href='#'>", $paginate_links );
$paginate_links = str_replace( '</span>', '</a>', $paginate_links );
$paginate_links = str_replace( "<li><span class='page-numbers current'>", "<li class='current'>", $paginate_links );
$paginate_links = str_replace( "<li><a href='#'>&hellip;</a></li>", "<li><span class='dots'>&hellip;</span></li>", $paginate_links );
$paginate_links = preg_replace( '/\s*page-numbers/', '', $paginate_links );
// Display the pagination if more than one page is found.
if ( $paginate_links ) {
echo $paginate_links;
}
}
endif;
/**
* A fallback when no navigation is selected by default.
*/
if ( ! function_exists( 'foundationpress_menu_fallback' ) ) :
function foundationpress_menu_fallback() {
echo '<div class="alert-box secondary">';
/* translators: %1$s: link to menus, %2$s: link to customize. */
printf(
__( 'Please assign a menu to the primary menu location under %1$s or %2$s the design.', 'foundationpress' ),
/* translators: %s: menu url */
sprintf(
__( '<a href="%s">Menus</a>', 'foundationpress' ),
get_admin_url( get_current_blog_id(), 'nav-menus.php' )
),
/* translators: %s: customize url */
sprintf(
__( '<a href="%s">Customize</a>', 'foundationpress' ),
get_admin_url( get_current_blog_id(), 'customize.php' )
)
);
echo '</div>';
}
endif;
// Add Foundation 'is-active' class for the current menu item.
if ( ! function_exists( 'foundationpress_active_nav_class' ) ) :
function foundationpress_active_nav_class( $classes, $item ) {
if ( $item->current == 1 || $item->current_item_ancestor == true ) {
$classes[] = 'is-active';
}
return $classes;
}
add_filter( 'nav_menu_css_class', 'foundationpress_active_nav_class', 10, 2 );
endif;
/**
* Use the is-active class of ZURB Foundation on wp_list_pages output.
* From required+ Foundation http://themes.required.ch.
*/
if ( ! function_exists( 'foundationpress_active_list_pages_class' ) ) :
function foundationpress_active_list_pages_class( $input ) {
$pattern = '/current_page_item/';
$replace = 'current_page_item is-active';
$output = preg_replace( $pattern, $replace, $input );
return $output;
}
add_filter( 'wp_list_pages', 'foundationpress_active_list_pages_class', 10, 2 );
endif;
/**
* Enable Foundation responsive embeds for WP video embeds
*/
if ( ! function_exists( 'foundationpress_responsive_video_oembed_html' ) ) :
function foundationpress_responsive_video_oembed_html( $html, $url, $attr, $post_id ) {
// Whitelist of oEmbed compatible sites that **ONLY** support video.
// Cannot determine if embed is a video or not from sites that
// support multiple embed types such as Facebook.
// Official list can be found here https://codex.wordpress.org/Embeds
$video_sites = array(
'youtube', // first for performance
'collegehumor',
'dailymotion',
'funnyordie',
'ted',
'videopress',
'vimeo',
);
$is_video = false;
// Determine if embed is a video
foreach ( $video_sites as $site ) {
// Match on `$html` instead of `$url` because of
// shortened URLs like `youtu.be` will be missed
if ( strpos( $html, $site ) ) {
$is_video = true;
break;
}
}
// Process video embed
if ( true == $is_video ) {
// Find the `<iframe>`
$doc = new DOMDocument();
$doc->loadHTML( $html );
$tags = $doc->getElementsByTagName( 'iframe' );
// Get width and height attributes
foreach ( $tags as $tag ) {
$width = $tag->getAttribute( 'width' );
$height = $tag->getAttribute( 'height' );
break; // should only be one
}
$class = 'responsive-embed'; // Foundation class
// Determine if aspect ratio is 16:9 or wider
if ( is_numeric( $width ) && is_numeric( $height ) && ( $width / $height >= 1.7 ) ) {
$class .= ' widescreen'; // space needed
}
// Wrap oEmbed markup in Foundation responsive embed
return '<div class="' . $class . '">' . $html . '</div>';
} else { // not a supported embed
return $html;
}
}
add_filter( 'embed_oembed_html', 'foundationpress_responsive_video_oembed_html', 10, 4 );
endif;
/**
* Get mobile menu ID
*/
if ( ! function_exists( 'foundationpress_mobile_menu_id' ) ) :
function foundationpress_mobile_menu_id() {
if ( get_theme_mod( 'wpt_mobile_menu_layout' ) === 'offcanvas' ) {
echo 'off-canvas-menu';
} else {
echo 'mobile-menu';
}
}
endif;
/**
* Get title bar responsive toggle attribute
*/
if ( ! function_exists( 'foundationpress_title_bar_responsive_toggle' ) ) :
function foundationpress_title_bar_responsive_toggle() {
if ( ! get_theme_mod( 'wpt_mobile_menu_layout' ) || get_theme_mod( 'wpt_mobile_menu_layout' ) === 'topbar' ) {
echo 'data-responsive-toggle="mobile-menu"';
}
}
endif;
/**
* Custom markup for Wordpress gallery
*/
if ( ! function_exists( 'foundationpress_gallery' ) ) :
function foundationpress_gallery($attr) {
$post = get_post();
static $instance = 0;
$instance++;
if ( ! empty( $attr['ids'] ) ) {
// 'ids' is explicitly ordered, unless you specify otherwise.
if ( empty( $attr['orderby'] ) )
$attr['orderby'] = 'post__in';
$attr['include'] = $attr['ids'];
}
// Allow plugins/themes to override the default gallery template.
$output = apply_filters('post_gallery', '', $attr, $instance);
if ( $output != '' )
return $output;
// Let's make sure it looks like a valid orderby statement
if ( isset( $attr['orderby'] ) ) {
$attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
if ( !$attr['orderby'] )
unset( $attr['orderby'] );
}
$atts = shortcode_atts(array(
'order' => 'ASC',
'orderby' => 'menu_order ID',
'id' => $post ? $post->ID : 0,
'itemtag' => 'figure',
'icontag' => 'div',
'captiontag' => 'figcaption',
'columns-small' => 2, // set default columns for small screen
'columns-medium'=> 4, // set default columns for medium screen
'columns' => 3, // set default columns for large screen (3 = wordpress default)
'size' => 'thumbnail',
'include' => '',
'exclude' => ''
), $attr, 'gallery');
$id = intval($atts['id']);
if ( !empty($atts['include']) ) {
$_attachments = get_posts( array('include' => $atts['include'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby']) );
$attachments = array();
foreach ( $_attachments as $key => $val ) {
$attachments[$val->ID] = $_attachments[$key];
}
} elseif ( !empty($atts['exclude']) ) {
$attachments = get_children( array('post_parent' => $id, 'exclude' => $atts['exclude'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby']) );
} else {
$attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby']) );
}
if ( empty($attachments) )
return '';
if ( is_feed() ) {
$output = "\n";
foreach ( $attachments as $att_id => $attachment )
$output .= wp_get_attachment_link($att_id, $atts['size'], true) . "\n";
return $output;
}
$item_tag = tag_escape($atts['itemtag']);
$caption_tag = tag_escape($atts['captiontag']);
$icon_tag = tag_escape($atts['icontag']);
$valid_tags = wp_kses_allowed_html( 'post' );
if ( ! isset( $valid_tags[ $item_tag ] ) )
$item_tag = 'figure';
if ( ! isset( $valid_tags[ $caption_tag ] ) )
$caption_tag = 'figcaption';
if ( ! isset( $valid_tags[ $icon_tag ] ) )
$icon_tag = 'div';
$columns = intval($atts['columns']);
$columns_small = intval($atts['columns-small']);
$columns_medium = intval($atts['columns-medium']);
$selector = "gallery-{$instance}";
$size_class = sanitize_html_class( $atts['size'] );
// Edit this line to modify the default number of grid columns for the small and medium sizes. The large size is passed in the WordPress gallery settings.
$output = "<div id='$selector' class='fp-gallery galleryid-{$id} gallery-size-{$size_class} grid-x grid-margin-x small-up-{$columns_small} medium-up-{$columns_medium} large-up-{$columns}'>";
foreach ( $attachments as $id => $attachment ) {
// Check if destination is file, nothing or attachment page.
if ( isset($attr['link']) && $attr['link'] == 'file' ){
$link = wp_get_attachment_link($id, $size_class, false, false, false,array('class' => '', 'id' => "imageid-$id"));
// Edit this line to implement your html params in <a> tag with use a custom lightbox plugin.
$link = str_replace('<a href', '<a class="thumbnail fp-gallery-lightbox" data-gall="fp-gallery-'. $post->ID .'" data-title="'. wptexturize($attachment->post_excerpt) .'" title="'. wptexturize($attachment->post_excerpt) .'" href', $link);
} elseif ( isset($attr['link']) && $attr['link'] == 'none' ){
$link = wp_get_attachment_image($id,$size_class,false, array('class' => "thumbnail attachment-$size_class size-$size_class", 'id' => "imageid-$id"));
} else {
$link = wp_get_attachment_link($id, $size_class, true, false, false,array('class' => '', 'id' => "imageid-$id"));
$link = str_replace('<a href', '<a class="thumbnail" title="'. wptexturize($attachment->post_excerpt) .'" href', $link);
}
$image_meta = wp_get_attachment_metadata( $id );
$orientation = '';
if ( isset( $image_meta['height'], $image_meta['width'] ) ) {
$orientation = ( $image_meta['height'] > $image_meta['width'] ) ? 'portrait' : 'landscape';
}
$output .= "<{$item_tag} class='fp-gallery-item cell'>";
$output .= "
<{$icon_tag} class='fp-gallery-icon {$orientation}'>
$link
</{$icon_tag}>";
// Uncomment if you wish to display captions inline on gallery.
/*
if ( $caption_tag && trim($attachment->post_excerpt) ) {
$output .= "
<{$caption_tag} class='wp-caption-text gallery-caption'>
" . wptexturize($attachment->post_excerpt) . "
</{$caption_tag}>";
}
*/
$output .= "</{$item_tag}>";
}
$output .= "</div>\n";
return $output;
}
add_shortcode('gallery', 'foundationpress_gallery');
endif;

View file

@ -0,0 +1,75 @@
<?php
/**
* Register Menus
*
* @link http://codex.wordpress.org/Function_Reference/register_nav_menus#Examples
* @package FoundationPress
* @since FoundationPress 1.0.0
*/
register_nav_menus(
array(
'top-bar-r' => esc_html__( 'Right Top Bar', 'foundationpress' ),
'mobile-nav' => esc_html__( 'Mobile', 'foundationpress' ),
)
);
/**
* Desktop navigation - right top bar
*
* @link http://codex.wordpress.org/Function_Reference/wp_nav_menu
*/
if ( ! function_exists( 'foundationpress_top_bar_r' ) ) {
function foundationpress_top_bar_r() {
wp_nav_menu(
array(
'container' => false,
'menu_class' => 'dropdown menu',
'items_wrap' => '<ul id="%1$s" class="%2$s desktop-menu" data-dropdown-menu>%3$s</ul>',
'theme_location' => 'top-bar-r',
'depth' => 3,
'fallback_cb' => false,
'walker' => new Foundationpress_Top_Bar_Walker(),
)
);
}
}
/**
* Mobile navigation - topbar (default) or offcanvas
*/
if ( ! function_exists( 'foundationpress_mobile_nav' ) ) {
function foundationpress_mobile_nav() {
wp_nav_menu(
array(
'container' => false, // Remove nav container
'menu' => __( 'mobile-nav', 'foundationpress' ),
'menu_class' => 'vertical menu',
'theme_location' => 'mobile-nav',
'items_wrap' => '<ul id="%1$s" class="%2$s" data-accordion-menu data-submenu-toggle="true">%3$s</ul>',
'fallback_cb' => false,
'walker' => new Foundationpress_Mobile_Walker(),
)
);
}
}
/**
* Add support for buttons in the top-bar menu:
* 1) In WordPress admin, go to Apperance -> Menus.
* 2) Click 'Screen Options' from the top panel and enable 'CSS CLasses' and 'Link Relationship (XFN)'
* 3) On your menu item, type 'has-form' in the CSS-classes field. Type 'button' in the XFN field
* 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 ) {
$find = array( '/<a rel="button"/', '/<a title=".*?" rel="button"/' );
$replace = array( '<a rel="button" class="button"', '<a rel="button" class="button"' );
return preg_replace( $find, $replace, $ulclass, 1 );
}
add_filter( 'wp_nav_menu', 'foundationpress_add_menuclass' );
}

View file

@ -0,0 +1,70 @@
<?php
/**
* Configure responsive images sizes
*
* @package WordPress
* @subpackage FoundationPress
* @since FoundationPress 2.6.0
*/
// Add featured image sizes
//
// Sizes are optimized and cropped for landscape aspect ratio
// and optimized for HiDPI displays on 'small' and 'medium' screen sizes.
add_image_size( 'featured-small', 640, 200, true ); // name, width, height, crop
add_image_size( 'featured-medium', 1280, 400, true );
add_image_size( 'featured-large', 1440, 400, true );
add_image_size( 'featured-xlarge', 1920, 400, true );
// Add additional image sizes
add_image_size( 'fp-small', 640 );
add_image_size( 'fp-medium', 1024 );
add_image_size( 'fp-large', 1200 );
add_image_size( 'fp-xlarge', 1920 );
// Register the new image sizes for use in the add media modal in wp-admin
function foundationpress_custom_sizes( $sizes ) {
return array_merge(
$sizes, array(
'fp-small' => __( 'FP Small' ),
'fp-medium' => __( 'FP Medium' ),
'fp-large' => __( 'FP Large' ),
'fp-xlarge' => __( 'FP XLarge' ),
)
);
}
add_filter( 'image_size_names_choose', 'foundationpress_custom_sizes' );
// Add custom image sizes attribute to enhance responsive image functionality for content images
function foundationpress_adjust_image_sizes_attr( $sizes, $size ) {
// Actual width of image
$width = $size[0];
// Full width page template
if ( is_page_template( 'page-templates/page-full-width.php' ) ) {
if ( 1200 < $width ) {
$sizes = '(max-width: 1199px) 98vw, 1200px';
} else {
$sizes = '(max-width: 1199px) 98vw, ' . $width . 'px';
}
} else { // Default 3/4 column post/page layout
if ( 770 < $width ) {
$sizes = '(max-width: 639px) 98vw, (max-width: 1199px) 64vw, 770px';
} else {
$sizes = '(max-width: 639px) 98vw, (max-width: 1199px) 64vw, ' . $width . 'px';
}
}
return $sizes;
}
add_filter( 'wp_calculate_image_sizes', 'foundationpress_adjust_image_sizes_attr', 10, 2 );
// Remove inline width and height attributes for post thumbnails
function remove_thumbnail_dimensions( $html, $post_id, $post_image_id ) {
if ( ! strpos( $html, 'attachment-shop_single' ) ) {
$html = preg_replace( '/^(width|height)=\"\d*\"\s/', '', $html );
}
return $html;
}
add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10, 3 );

View file

@ -0,0 +1,19 @@
<?php
/**
* Change the class for sticky posts to .wp-sticky to avoid conflicts with Foundation's Sticky plugin
*
* @package FoundationPress
* @since FoundationPress 2.2.0
*/
if ( ! function_exists( 'foundationpress_sticky_posts' ) ) :
function foundationpress_sticky_posts( $classes ) {
if ( in_array( 'sticky', $classes, true ) ) {
$classes = array_diff( $classes, array( 'sticky' ) );
$classes[] = 'wp-sticky';
}
return $classes;
}
add_filter( 'post_class', 'foundationpress_sticky_posts' );
endif;

View file

@ -0,0 +1,50 @@
<?php
/**
* Register theme support for languages, menus, post-thumbnails, post-formats etc.
*
* @package FoundationPress
* @since FoundationPress 1.0.0
*/
if ( ! function_exists( 'foundationpress_theme_support' ) ) :
function foundationpress_theme_support() {
// Add language support
load_theme_textdomain( 'foundationpress', get_template_directory() . '/languages' );
// 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 menu support
add_theme_support( 'menus' );
// Let WordPress manage the document title
add_theme_support( 'title-tag' );
// Add post thumbnail support: http://codex.wordpress.org/Post_Thumbnails
add_theme_support( 'post-thumbnails' );
// RSS thingy
add_theme_support( 'automatic-feed-links' );
// Add post formats support: http://codex.wordpress.org/Post_Formats
add_theme_support( 'post-formats', array( 'aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat' ) );
// Additional theme support for woocommerce 3.0.+
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
// Add foundation.css as editor style https://codex.wordpress.org/Editor_Style
add_editor_style( 'dist/assets/css/' . foundationpress_asset_path( 'app.css' ) );
}
add_action( 'after_setup_theme', 'foundationpress_theme_support' );
endif;

View file

@ -0,0 +1,37 @@
<?php
/**
* Register widget areas
*
* @package FoundationPress
* @since FoundationPress 1.0.0
*/
if ( ! function_exists( 'foundationpress_sidebar_widgets' ) ) :
function foundationpress_sidebar_widgets() {
register_sidebar(
array(
'id' => 'sidebar-widgets',
'name' => __( 'Sidebar widgets', 'foundationpress' ),
'description' => __( 'Drag widgets to this sidebar container.', 'foundationpress' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h6>',
'after_title' => '</h6>',
)
);
register_sidebar(
array(
'id' => 'footer-widgets',
'name' => __( 'Footer widgets', 'foundationpress' ),
'description' => __( 'Drag widgets to this footer container', 'foundationpress' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h6>',
'after_title' => '</h6>',
)
);
}
add_action( 'widgets_init', 'foundationpress_sidebar_widgets' );
endif;