commit
a942fe0acf
|
@ -12,7 +12,8 @@ if ( class_exists( 'WooCommerce' ) ) {
|
||||||
get_option( 'woocommerce_cart_page_id' ) == $this_page_id || get_option( 'woocommerce_checkout_page_id' ) == $this_page_id ||
|
get_option( 'woocommerce_cart_page_id' ) == $this_page_id || get_option( 'woocommerce_checkout_page_id' ) == $this_page_id ||
|
||||||
get_option( 'woocommerce_pay_page_id' ) == $this_page_id || get_option( 'woocommerce_thanks_page_id' ) === $this_page_id ||
|
get_option( 'woocommerce_pay_page_id' ) == $this_page_id || get_option( 'woocommerce_thanks_page_id' ) === $this_page_id ||
|
||||||
get_option( 'woocommerce_myaccount_page_id' ) == $this_page_id || get_option( 'woocommerce_edit_address_page_id' ) == $this_page_id ||
|
get_option( 'woocommerce_myaccount_page_id' ) == $this_page_id || get_option( 'woocommerce_edit_address_page_id' ) == $this_page_id ||
|
||||||
get_option( 'woocommerce_view_order_page_id' ) == $this_page_id || get_option( 'woocommerce_terms_page_id' ) == $this_page_id) {
|
get_option( 'woocommerce_view_order_page_id' ) == $this_page_id || get_option( 'woocommerce_terms_page_id' ) == $this_page_id
|
||||||
|
) {
|
||||||
|
|
||||||
$is_woocommerce = true;
|
$is_woocommerce = true;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +47,7 @@ if ( class_exists( 'WooCommerce' ) ) {
|
||||||
echo $html;
|
echo $html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@
|
||||||
'menu_class' => 'nav navbar-nav',
|
'menu_class' => 'nav navbar-nav',
|
||||||
'fallback_cb' => '',
|
'fallback_cb' => '',
|
||||||
'menu_id' => 'main-menu',
|
'menu_id' => 'main-menu',
|
||||||
'walker' => new wp_bootstrap_navwalker()
|
'walker' => new WP_Bootstrap_Navwalker()
|
||||||
)
|
)
|
||||||
); ?>
|
); ?>
|
||||||
|
|
||||||
|
|
|
@ -1,129 +1,146 @@
|
||||||
<?php
|
<?php
|
||||||
//Based on Jeff Hays code and his article here: http://robido.com/wordpress/wordpress-gallery-filter-to-modify-the-html-output-of-the-default-gallery-shortcode-and-style/
|
/**
|
||||||
// Custom filter function to modify default gallery shortcode output
|
* Based on Roots Sage Gallery: https://github.com/roots/sage/blob/5b9786b8ceecfe717db55666efe5bcf0c9e1801c/lib/gallery.php
|
||||||
function bootstrap_wp_gallery( $output, $attr ) {
|
*
|
||||||
|
* @package understrap
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Remove built in shortcode.
|
||||||
|
remove_shortcode( 'gallery', 'gallery_shortcode' );
|
||||||
|
|
||||||
// Initialize
|
/**
|
||||||
global $post, $wp_locale;
|
* Replaces gallery with custom shortcode.
|
||||||
|
*
|
||||||
// Gallery instance counter
|
* @param mixed $attr Shortcode parameters.
|
||||||
|
*
|
||||||
|
* @return mixed|string|void
|
||||||
|
*/
|
||||||
|
function shortcode_gallery( $attr ) {
|
||||||
|
$post = get_post();
|
||||||
static $instance = 0;
|
static $instance = 0;
|
||||||
$instance ++;
|
$instance ++;
|
||||||
|
if ( ! empty( $attr['ids'] ) ) {
|
||||||
// Validate the author's orderby attribute
|
if ( empty( $attr['orderby'] ) ) {
|
||||||
|
$attr['orderby'] = 'post__in';
|
||||||
|
}
|
||||||
|
$attr['include'] = $attr['ids'];
|
||||||
|
}
|
||||||
|
$output = apply_filters( 'post_gallery', '', $attr );
|
||||||
|
if ( $output != '' ) {
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
if ( isset( $attr['orderby'] ) ) {
|
if ( isset( $attr['orderby'] ) ) {
|
||||||
$attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
|
$attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
|
||||||
if ( ! $attr['orderby'] ) unset( $attr['orderby'] );
|
if ( ! $attr['orderby'] ) {
|
||||||
|
unset( $attr['orderby'] );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Get attributes from shortcode
|
extract( shortcode_atts( [
|
||||||
extract( shortcode_atts( array(
|
|
||||||
'order' => 'ASC',
|
'order' => 'ASC',
|
||||||
'orderby' => 'menu_order ID',
|
'orderby' => 'menu_order ID',
|
||||||
'id' => $post->ID,
|
'id' => $post->ID,
|
||||||
'itemtag' => 'div',
|
'itemtag' => '',
|
||||||
'icontag' => 'div',
|
'icontag' => '',
|
||||||
'captiontag' => 'div',
|
'captiontag' => '',
|
||||||
'columns' => 3,
|
'columns' => 3,
|
||||||
'size' => 'thumbnail',
|
'size' => 'thumbnail',
|
||||||
'exclude' => ''
|
'include' => '',
|
||||||
), $attr ) );
|
'exclude' => '',
|
||||||
|
'link' => '',
|
||||||
// Initialize
|
], $attr ) );
|
||||||
$id = intval( $id );
|
$id = intval( $id );
|
||||||
$attachments = array();
|
$columns = ( 12 % $columns == 0 ) ? $columns : 3;
|
||||||
if ( $order == 'RAND' ) $orderby = 'none';
|
$grid = sprintf( 'col-sm-%1$s col-lg-%1$s', 12 / $columns );
|
||||||
|
if ( $order === 'RAND' ) {
|
||||||
|
$orderby = 'none';
|
||||||
|
}
|
||||||
if ( ! empty( $include ) ) {
|
if ( ! empty( $include ) ) {
|
||||||
|
$_attachments = get_posts( [
|
||||||
// Include attribute is present
|
'include' => $include,
|
||||||
$include = preg_replace( '/[^0-9,]+/', '', $include );
|
'post_status' => 'inherit',
|
||||||
$_attachments = get_posts( array( 'include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby ) );
|
'post_type' => 'attachment',
|
||||||
|
'post_mime_type' => 'image',
|
||||||
// Setup attachments array
|
'order' => $order,
|
||||||
|
'orderby' => $orderby
|
||||||
|
] );
|
||||||
|
$attachments = [];
|
||||||
foreach ( $_attachments as $key => $val ) {
|
foreach ( $_attachments as $key => $val ) {
|
||||||
$attachments[ $val->ID ] = $_attachments[ $key ];
|
$attachments[ $val->ID ] = $_attachments[ $key ];
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif ( ! empty( $exclude ) ) {
|
} elseif ( ! empty( $exclude ) ) {
|
||||||
|
$attachments = get_children( [
|
||||||
// Exclude attribute is present
|
'post_parent' => $id,
|
||||||
$exclude = preg_replace( '/[^0-9,]+/', '', $exclude );
|
'exclude' => $exclude,
|
||||||
|
'post_status' => 'inherit',
|
||||||
// Setup attachments array
|
'post_type' => 'attachment',
|
||||||
$attachments = get_children( array( 'post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby ) );
|
'post_mime_type' => 'image',
|
||||||
|
'order' => $order,
|
||||||
|
'orderby' => $orderby
|
||||||
|
] );
|
||||||
} else {
|
} else {
|
||||||
// Setup attachments array
|
$attachments = get_children( [
|
||||||
$attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby ) );
|
'post_parent' => $id,
|
||||||
|
'post_status' => 'inherit',
|
||||||
|
'post_type' => 'attachment',
|
||||||
|
'post_mime_type' => 'image',
|
||||||
|
'order' => $order,
|
||||||
|
'orderby' => $orderby
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
if ( empty( $attachments ) ) {
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( empty( $attachments ) ) return '';
|
|
||||||
|
|
||||||
// Filter gallery differently for feeds
|
|
||||||
if ( is_feed() ) {
|
if ( is_feed() ) {
|
||||||
$output = "\n";
|
$output = "\n";
|
||||||
foreach ( $attachments as $att_id => $attachment ) $output .= wp_get_attachment_link( $att_id, $size, true ) . "\n";
|
foreach ( $attachments as $att_id => $attachment ) {
|
||||||
return $output;
|
$output .= wp_get_attachment_link( $att_id, $size, true ) . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter tags and attributes
|
return $output;
|
||||||
$itemtag = tag_escape( $itemtag );
|
}
|
||||||
$captiontag = tag_escape( $captiontag );
|
$unique = ( get_query_var( 'page' ) ) ? $instance . '-p' . get_query_var( 'page' ) : $instance;
|
||||||
$columns = intval( $columns );
|
$output = '<div class="gallery gallery-' . $id . '-' . $unique . '">';
|
||||||
$itemwidth = $columns > 0 ? floor( 12 / $columns ) : 100;
|
|
||||||
$float = is_rtl() ? 'right' : 'left';
|
|
||||||
$selector = "gallery-{$instance}";
|
|
||||||
|
|
||||||
// Filter gallery CSS
|
|
||||||
$output = apply_filters( 'gallery_style', "
|
|
||||||
|
|
||||||
<div class='gallery galleryid-{$id} row' id='$selector'>"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Iterate through the attachments in this gallery instance
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ( $attachments as $id => $attachment ) {
|
foreach ( $attachments as $id => $attachment ) {
|
||||||
|
switch ( $link ) {
|
||||||
// Attachment link
|
case 'file':
|
||||||
$link = isset( $attr['link'] ) && 'file' == $attr['link'] ? wp_get_attachment_link( $id, $size, false, false ) : wp_get_attachment_link( $id, $size, true, false );
|
$image = wp_get_attachment_link( $id, $size, false, false );
|
||||||
|
break;
|
||||||
// Start itemtag
|
case 'none':
|
||||||
$output .= "<{$itemtag} class='gallery-item col-md-{$itemwidth}'>";
|
$image = wp_get_attachment_image( $id, $size, false, [ 'class' => 'thumbnail img-thumbnail' ] );
|
||||||
|
break;
|
||||||
// icontag
|
default:
|
||||||
$output .= "
|
$image = wp_get_attachment_link( $id, $size, true, false );
|
||||||
<{$icontag} class='gallery-icon'>
|
break;
|
||||||
$link
|
|
||||||
</{$icontag}>";
|
|
||||||
|
|
||||||
if ( $captiontag && trim( $attachment->post_excerpt ) ) {
|
|
||||||
|
|
||||||
// captiontag
|
|
||||||
$output .= "
|
|
||||||
<{$captiontag} class='gallery-caption'>
|
|
||||||
" . wptexturize($attachment->post_excerpt) . "
|
|
||||||
</{$captiontag}>";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
$output .= ( $i % $columns == 0 ) ? '<div class="row gallery-row">' : '';
|
||||||
// End itemtag
|
$output .= '<div class="' . $grid . '">' . $image;
|
||||||
$output .= "</{$itemtag}>";
|
if ( trim( $attachment->post_excerpt ) ) {
|
||||||
|
$output .= '<div class="caption hidden">' . wptexturize( $attachment->post_excerpt ) . '</div>';
|
||||||
// Line breaks by columns set
|
|
||||||
if($columns > 0 && ++$i % $columns == 0) $output .= '<br style="clear: both">';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
$output .= '</div>';
|
||||||
// End gallery output
|
$i ++;
|
||||||
$output .= "
|
$output .= ( $i % $columns == 0 ) ? '</div>' : '';
|
||||||
<br style='clear: both;'>
|
}
|
||||||
</div>\n";
|
$output .= ( $i % $columns != 0 ) ? '</div>' : '';
|
||||||
|
$output .= '</div>';
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply filter to default gallery shortcode
|
add_shortcode( 'gallery', 'shortcode_gallery' );
|
||||||
add_filter( 'post_gallery', 'bootstrap_wp_gallery', 10, 2 );
|
|
||||||
|
/**
|
||||||
|
* Add class="thumbnail img-thumbnail" to attachment items
|
||||||
|
*
|
||||||
|
* @param string $html Markup.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
function attachment_link_class( $html ) {
|
||||||
|
$html = str_replace( '<a', '<a class="thumbnail img-thumbnail"', $html );
|
||||||
|
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
add_filter( 'wp_get_attachment_link', 'attachment_link_class', 10, 1 );
|
||||||
|
|
|
@ -1,43 +1,53 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Adapted from Edward McIntyre's wp_bootstrap_navwalker class.
|
* Adapted from Edward McIntyre's wp_bootstrap_navwalker class.
|
||||||
* Removed support for glyphicon and added support for Font Awesome
|
* Removed support for glyphicon and added support for Font Awesome.
|
||||||
*
|
*
|
||||||
|
* @package understrap
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Exit if accessed directly.
|
||||||
|
if ( ! defined( 'ABSPATH' ) ) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Name: wp_bootstrap_navwalker
|
* Class WP_Bootstrap_Navwalker
|
||||||
* GitHub URI: https://github.com/twittem/wp-bootstrap-navwalker
|
* GitHub URI: https://github.com/twittem/wp-bootstrap-navwalker
|
||||||
* Description: A custom WordPress nav walker class to implement the Bootstrap 3 navigation style in a custom theme using the WordPress built in menu manager.
|
* Description: A custom WordPress nav walker class to implement the Bootstrap 4
|
||||||
|
* navigation style in a custom theme using the WordPress built in menu manager.
|
||||||
* Version: 2.0.4
|
* Version: 2.0.4
|
||||||
* Author: Edward McIntyre - @twittem
|
* Author: Edward McIntyre - @twittem
|
||||||
* License: GPL-2.0+
|
* License: GPL-2.0+
|
||||||
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
||||||
* @package understrap
|
|
||||||
*/
|
*/
|
||||||
//exit if accessed directly
|
class WP_Bootstrap_Navwalker extends Walker_Nav_Menu {
|
||||||
if(!defined('ABSPATH')) exit;
|
|
||||||
class wp_bootstrap_navwalker extends Walker_Nav_Menu {
|
|
||||||
/**
|
/**
|
||||||
|
* The starting level of the menu.
|
||||||
|
*
|
||||||
* @see Walker::start_lvl()
|
* @see Walker::start_lvl()
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*
|
*
|
||||||
* @param string $output Passed by reference. Used to append additional content.
|
* @param string $output Passed by reference. Used to append additional content.
|
||||||
* @param int $depth Depth of page. Used for padding.
|
* @param int $depth Depth of page. Used for padding.
|
||||||
|
* @param mixed $args Rest of arguments.
|
||||||
*/
|
*/
|
||||||
public function start_lvl( &$output, $depth = 0, $args = array() ) {
|
public function start_lvl( &$output, $depth = 0, $args = array() ) {
|
||||||
$indent = str_repeat( "\t", $depth );
|
$indent = str_repeat( "\t", $depth );
|
||||||
$output .= "\n$indent<ul class=\" dropdown-menu\" role=\"menu\">\n";
|
$output .= "\n$indent<ul class=\" dropdown-menu\" role=\"menu\">\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Open element.
|
||||||
|
*
|
||||||
* @see Walker::start_el()
|
* @see Walker::start_el()
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*
|
*
|
||||||
* @param string $output Passed by reference. Used to append additional content.
|
* @param string $output Passed by reference. Used to append additional content.
|
||||||
* @param object $item Menu item data object.
|
* @param object $item Menu item data object.
|
||||||
* @param int $depth Depth of menu item. Used for padding.
|
* @param int $depth Depth of menu item. Used for padding.
|
||||||
* @param int $current_page Menu item ID.
|
* @param mixed $args Rest arguments.
|
||||||
* @param object $args
|
* @param int $id Element's ID.
|
||||||
*/
|
*/
|
||||||
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
|
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
|
||||||
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
|
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
|
||||||
|
@ -66,9 +76,14 @@ class wp_bootstrap_navwalker extends Walker_Nav_Menu {
|
||||||
if ( $args->has_children )
|
if ( $args->has_children )
|
||||||
$class_names .= ' dropdown';
|
$class_names .= ' dropdown';
|
||||||
*/
|
*/
|
||||||
if($args->has_children && $depth === 0) { $class_names .= ' dropdown'; } elseif($args->has_children && $depth > 0) { $class_names .= ' dropdown-submenu'; }
|
if ( $args->has_children && $depth === 0 ) {
|
||||||
if ( in_array( 'current-menu-item', $classes ) )
|
$class_names .= ' dropdown';
|
||||||
|
} elseif ( $args->has_children && $depth > 0 ) {
|
||||||
|
$class_names .= ' dropdown-submenu';
|
||||||
|
}
|
||||||
|
if ( in_array( 'current-menu-item', $classes ) ) {
|
||||||
$class_names .= ' active';
|
$class_names .= ' active';
|
||||||
|
}
|
||||||
// remove Font Awesome icon from classes array and save the icon
|
// remove Font Awesome icon from classes array and save the icon
|
||||||
// we will add the icon back in via a <span> below so it aligns with
|
// we will add the icon back in via a <span> below so it aligns with
|
||||||
// the menu item
|
// the menu item
|
||||||
|
@ -107,16 +122,19 @@ class wp_bootstrap_navwalker extends Walker_Nav_Menu {
|
||||||
}
|
}
|
||||||
$item_output = $args->before;
|
$item_output = $args->before;
|
||||||
// Font Awesome icons
|
// Font Awesome icons
|
||||||
if ( ! empty( $icon ) )
|
if ( ! empty( $icon ) ) {
|
||||||
$item_output .= '<a' . $attributes . '><span class="fa ' . esc_attr( $icon ) . '"></span> ';
|
$item_output .= '<a' . $attributes . '><span class="fa ' . esc_attr( $icon ) . '"></span> ';
|
||||||
else
|
} else {
|
||||||
$item_output .= '<a' . $attributes . '>';
|
$item_output .= '<a' . $attributes . '>';
|
||||||
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
|
}
|
||||||
|
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title,
|
||||||
|
$item->ID ) . $args->link_after;
|
||||||
$item_output .= ( $args->has_children && 0 === $depth ) ? ' <span class="caret"></span></a>' : '</a>';
|
$item_output .= ( $args->has_children && 0 === $depth ) ? ' <span class="caret"></span></a>' : '</a>';
|
||||||
$item_output .= $args->after;
|
$item_output .= $args->after;
|
||||||
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
|
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Traverse elements to create list from elements.
|
* Traverse elements to create list from elements.
|
||||||
*
|
*
|
||||||
|
@ -135,17 +153,21 @@ class wp_bootstrap_navwalker extends Walker_Nav_Menu {
|
||||||
* @param int $depth Depth of current element.
|
* @param int $depth Depth of current element.
|
||||||
* @param array $args
|
* @param array $args
|
||||||
* @param string $output Passed by reference. Used to append additional content.
|
* @param string $output Passed by reference. Used to append additional content.
|
||||||
|
*
|
||||||
* @return null Null on failure with no changes to parameters.
|
* @return null Null on failure with no changes to parameters.
|
||||||
*/
|
*/
|
||||||
public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
|
public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
|
||||||
if ( ! $element )
|
if ( ! $element ) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
$id_field = $this->db_fields['id'];
|
$id_field = $this->db_fields['id'];
|
||||||
// Display this element.
|
// Display this element.
|
||||||
if ( is_object( $args[0] ) )
|
if ( is_object( $args[0] ) ) {
|
||||||
$args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] );
|
$args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] );
|
||||||
|
}
|
||||||
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
|
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Menu Fallback
|
* Menu Fallback
|
||||||
* =============
|
* =============
|
||||||
|
@ -163,22 +185,27 @@ class wp_bootstrap_navwalker extends Walker_Nav_Menu {
|
||||||
$fb_output = null;
|
$fb_output = null;
|
||||||
if ( $container ) {
|
if ( $container ) {
|
||||||
$fb_output = '<' . $container;
|
$fb_output = '<' . $container;
|
||||||
if ( $container_class )
|
if ( $container_class ) {
|
||||||
$fb_output .= ' class="' . $container_class . '"';
|
$fb_output .= ' class="' . $container_class . '"';
|
||||||
if ( $container_id )
|
}
|
||||||
|
if ( $container_id ) {
|
||||||
$fb_output .= ' id="' . $container_id . '"';
|
$fb_output .= ' id="' . $container_id . '"';
|
||||||
|
}
|
||||||
$fb_output .= '>';
|
$fb_output .= '>';
|
||||||
}
|
}
|
||||||
$fb_output .= '<ul';
|
$fb_output .= '<ul';
|
||||||
if ( $menu_class )
|
if ( $menu_class ) {
|
||||||
$fb_output .= ' class="' . $menu_class . '"';
|
$fb_output .= ' class="' . $menu_class . '"';
|
||||||
if ( $menu_id )
|
}
|
||||||
|
if ( $menu_id ) {
|
||||||
$fb_output .= ' id="' . $menu_id . '"';
|
$fb_output .= ' id="' . $menu_id . '"';
|
||||||
|
}
|
||||||
$fb_output .= '>';
|
$fb_output .= '>';
|
||||||
$fb_output .= '<li><a href="' . admin_url( 'nav-menus.php' ) . '">Add a menu</a></li>';
|
$fb_output .= '<li><a href="' . admin_url( 'nav-menus.php' ) . '">Add a menu</a></li>';
|
||||||
$fb_output .= '</ul>';
|
$fb_output .= '</ul>';
|
||||||
if ( $container )
|
if ( $container ) {
|
||||||
$fb_output .= '</' . $container . '>';
|
$fb_output .= '</' . $container . '>';
|
||||||
|
}
|
||||||
echo $fb_output;
|
echo $fb_output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,54 @@
|
||||||
<?php
|
<?php
|
||||||
/************* COMMENT LAYOUT *********************/
|
/**
|
||||||
// Comment Form
|
* Comment layout.
|
||||||
|
*
|
||||||
|
* @package understrap
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Comments form.
|
||||||
add_filter( 'comment_form_default_fields', 'bootstrap3_comment_form_fields' );
|
add_filter( 'comment_form_default_fields', 'bootstrap3_comment_form_fields' );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the comments form.
|
||||||
|
*
|
||||||
|
* @param string $fields Form fields.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
function bootstrap3_comment_form_fields( $fields ) {
|
function bootstrap3_comment_form_fields( $fields ) {
|
||||||
$commenter = wp_get_current_commenter();
|
$commenter = wp_get_current_commenter();
|
||||||
$req = get_option( 'require_name_email' );
|
$req = get_option( 'require_name_email' );
|
||||||
$aria_req = ( $req ? " aria-required='true'" : '' );
|
$aria_req = ( $req ? " aria-required='true'" : '' );
|
||||||
$html5 = current_theme_supports( 'html5', 'comment-form' ) ? 1 : 0;
|
$html5 = current_theme_supports( 'html5', 'comment-form' ) ? 1 : 0;
|
||||||
$fields = array(
|
$fields = array(
|
||||||
'author' => '<div class="form-group comment-form-author">' . '<label for="author">' . __( 'Name', 'understrap' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
|
'author' => '<div class="form-group comment-form-author" <label for="author">' . __( 'Name',
|
||||||
|
'understrap' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
|
||||||
'<input class="form-control" id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . '></div>',
|
'<input class="form-control" id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . '></div>',
|
||||||
'email' => '<div class="form-group comment-form-email"><label for="email">' . __( 'Email', 'understrap' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
|
'email' => '<div class="form-group comment-form-email"><label for="email">' . __( 'Email',
|
||||||
|
'understrap' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
|
||||||
'<input class="form-control" id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . '></div>',
|
'<input class="form-control" id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . '></div>',
|
||||||
'url' => '<div class="form-group comment-form-url"><label for="url">' . __( 'Website', 'understrap' ) . '</label> ' .
|
'url' => '<div class="form-group comment-form-url"><label for="url">' . __( 'Website',
|
||||||
|
'understrap' ) . '</label> ' .
|
||||||
'<input class="form-control" id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30"></div>',
|
'<input class="form-control" id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30"></div>',
|
||||||
);
|
);
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_filter( 'comment_form_defaults', 'bootstrap3_comment_form' );
|
add_filter( 'comment_form_defaults', 'bootstrap3_comment_form' );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the form.
|
||||||
|
*
|
||||||
|
* @param string $args Arguments for form's fields.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
function bootstrap3_comment_form( $args ) {
|
function bootstrap3_comment_form( $args ) {
|
||||||
$args['comment_field'] = '<div class="form-group comment-form-comment">
|
$args['comment_field'] = '<div class="form-group comment-form-comment">
|
||||||
<label for="comment">' . _x( 'Comment', 'noun', 'understrap' ) . ( ' <span class="required">*</span>' ) . '</label>
|
<label for="comment">' . _x( 'Comment', 'noun', 'understrap' ) . ( ' <span class="required">*</span>' ) . '</label>
|
||||||
<textarea class="form-control" id="comment" name="comment" aria-required="true" cols="45" rows="8"></textarea>
|
<textarea class="form-control" id="comment" name="comment" aria-required="true" cols="45" rows="8"></textarea>
|
||||||
</div>';
|
</div>';
|
||||||
$args['class_submit'] = 'btn btn-secondary'; // since WP 4.1
|
$args['class_submit'] = 'btn btn-secondary'; // since WP 4.1.
|
||||||
return $args;
|
return $args;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* understrap Theme Customizer
|
* Understrap Theme Customizer
|
||||||
*
|
*
|
||||||
* @package understrap
|
* @package understrap
|
||||||
*/
|
*/
|
||||||
|
@ -11,6 +11,11 @@
|
||||||
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
|
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
|
||||||
*/
|
*/
|
||||||
if ( ! function_exists( 'understrap_customize_register' ) ) {
|
if ( ! function_exists( 'understrap_customize_register' ) ) {
|
||||||
|
/**
|
||||||
|
* Register basic customizer support.
|
||||||
|
*
|
||||||
|
* @param object $wp_customize Customizer reference.
|
||||||
|
*/
|
||||||
function understrap_customize_register( $wp_customize ) {
|
function understrap_customize_register( $wp_customize ) {
|
||||||
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
|
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
|
||||||
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
|
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
|
||||||
|
@ -21,39 +26,44 @@ if ( ! function_exists( 'understrap_customize_register' ) ) {
|
||||||
add_action( 'customize_register', 'understrap_customize_register' );
|
add_action( 'customize_register', 'understrap_customize_register' );
|
||||||
|
|
||||||
if ( ! function_exists( 'understrap_theme_customize_register' ) ) {
|
if ( ! function_exists( 'understrap_theme_customize_register' ) ) {
|
||||||
|
/**
|
||||||
|
* Register individual settings through customizer's API.
|
||||||
|
*
|
||||||
|
* @param WP_Customize_Manager $wp_customize Customizer reference.
|
||||||
|
*/
|
||||||
function understrap_theme_customize_register( $wp_customize ) {
|
function understrap_theme_customize_register( $wp_customize ) {
|
||||||
|
|
||||||
$wp_customize->add_section( 'understrap_theme_slider_options', array(
|
$wp_customize->add_section( 'understrap_theme_slider_options', array(
|
||||||
'title' => __( 'Slider Settings', 'understrap' )
|
'title' => __( 'Slider Settings', 'understrap' ),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$wp_customize->add_setting( 'understrap_theme_slider_count_setting', array(
|
$wp_customize->add_setting( 'understrap_theme_slider_count_setting', array(
|
||||||
'default' => '1',
|
'default' => '1',
|
||||||
'sanitize_callback' => 'absint'
|
'sanitize_callback' => 'absint',
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$wp_customize->add_control( 'understrap_theme_slider_count', array(
|
$wp_customize->add_control( 'understrap_theme_slider_count', array(
|
||||||
'label' => __( 'Number of slides displaying at once', 'understrap' ),
|
'label' => __( 'Number of slides displaying at once', 'understrap' ),
|
||||||
'section' => 'understrap_theme_slider_options',
|
'section' => 'understrap_theme_slider_options',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'settings' => 'understrap_theme_slider_count_setting'
|
'settings' => 'understrap_theme_slider_count_setting',
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$wp_customize->add_setting( 'understrap_theme_slider_time_setting', array(
|
$wp_customize->add_setting( 'understrap_theme_slider_time_setting', array(
|
||||||
'default' => '5000',
|
'default' => '5000',
|
||||||
'sanitize_callback' => 'absint'
|
'sanitize_callback' => 'absint',
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$wp_customize->add_control( 'understrap_theme_slider_time', array(
|
$wp_customize->add_control( 'understrap_theme_slider_time', array(
|
||||||
'label' => __( 'Slider Time (in ms)', 'understrap' ),
|
'label' => __( 'Slider Time (in ms)', 'understrap' ),
|
||||||
'section' => 'understrap_theme_slider_options',
|
'section' => 'understrap_theme_slider_options',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
'settings' => 'understrap_theme_slider_time_setting'
|
'settings' => 'understrap_theme_slider_time_setting',
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$wp_customize->add_setting( 'understrap_theme_slider_loop_setting', array(
|
$wp_customize->add_setting( 'understrap_theme_slider_loop_setting', array(
|
||||||
'default' => 'true',
|
'default' => 'true',
|
||||||
'sanitize_callback' => 'esc_textarea'
|
'sanitize_callback' => 'esc_textarea',
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$wp_customize->add_control( 'understrap_theme_loop', array(
|
$wp_customize->add_control( 'understrap_theme_loop', array(
|
||||||
|
@ -64,10 +74,10 @@ if ( ! function_exists( 'understrap_theme_customize_register' ) ) {
|
||||||
'true' => 'yes',
|
'true' => 'yes',
|
||||||
'false' => 'no',
|
'false' => 'no',
|
||||||
),
|
),
|
||||||
'settings' => 'understrap_theme_slider_loop_setting'
|
'settings' => 'understrap_theme_slider_loop_setting',
|
||||||
) );
|
) );
|
||||||
|
|
||||||
// Theme layout settings
|
// Theme layout settings.
|
||||||
$wp_customize->add_section( 'understrap_theme_layout_options', array(
|
$wp_customize->add_section( 'understrap_theme_layout_options', array(
|
||||||
'title' => __( 'Theme Layout Settings', 'understrap' ),
|
'title' => __( 'Theme Layout Settings', 'understrap' ),
|
||||||
'capability' => 'edit_theme_options',
|
'capability' => 'edit_theme_options',
|
||||||
|
@ -79,7 +89,7 @@ if ( ! function_exists( 'understrap_theme_customize_register' ) ) {
|
||||||
'default' => 'container',
|
'default' => 'container',
|
||||||
'type' => 'theme_mod',
|
'type' => 'theme_mod',
|
||||||
'sanitize_callback' => 'esc_textarea',
|
'sanitize_callback' => 'esc_textarea',
|
||||||
'capability' => 'edit_theme_options'
|
'capability' => 'edit_theme_options',
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$wp_customize->add_control(
|
$wp_customize->add_control(
|
||||||
|
@ -111,7 +121,8 @@ if ( ! function_exists( 'understrap_theme_customize_register' ) ) {
|
||||||
$wp_customize,
|
$wp_customize,
|
||||||
'understrap_sidebar_position', array(
|
'understrap_sidebar_position', array(
|
||||||
'label' => __( 'Sidebar Positioning', 'understrap' ),
|
'label' => __( 'Sidebar Positioning', 'understrap' ),
|
||||||
'description' => __( "Set sidebar's position. Can either be: right, left, both or none", 'understrap' ),
|
'description' => __( "Set sidebar's position. Can either be: right, left, both or none",
|
||||||
|
'understrap' ),
|
||||||
'section' => 'understrap_theme_layout_options',
|
'section' => 'understrap_theme_layout_options',
|
||||||
'settings' => 'understrap_sidebar_position',
|
'settings' => 'understrap_sidebar_position',
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
|
@ -125,7 +136,7 @@ if ( ! function_exists( 'understrap_theme_customize_register' ) ) {
|
||||||
)
|
)
|
||||||
) );
|
) );
|
||||||
|
|
||||||
// How to display posts index page (home.php)
|
// How to display posts index page (home.php).
|
||||||
$wp_customize->add_setting( 'understrap_posts_index_style', array(
|
$wp_customize->add_setting( 'understrap_posts_index_style', array(
|
||||||
'default' => 'default',
|
'default' => 'default',
|
||||||
'type' => 'theme_mod',
|
'type' => 'theme_mod',
|
||||||
|
@ -138,7 +149,7 @@ if ( ! function_exists( 'understrap_theme_customize_register' ) ) {
|
||||||
$wp_customize,
|
$wp_customize,
|
||||||
'understrap_posts_index_style', array(
|
'understrap_posts_index_style', array(
|
||||||
'label' => __( 'Posts Index Style', 'understrap' ),
|
'label' => __( 'Posts Index Style', 'understrap' ),
|
||||||
'description' => __( "Choose how to display latest posts", 'understrap' ),
|
'description' => __( 'Choose how to display latest posts', 'understrap' ),
|
||||||
'section' => 'understrap_theme_layout_options',
|
'section' => 'understrap_theme_layout_options',
|
||||||
'settings' => 'understrap_posts_index_style',
|
'settings' => 'understrap_posts_index_style',
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
|
@ -154,14 +165,14 @@ if ( ! function_exists( 'understrap_theme_customize_register' ) ) {
|
||||||
// Columns setup for grid posts.
|
// Columns setup for grid posts.
|
||||||
/**
|
/**
|
||||||
* Function and callback to check when grid is enabled.
|
* Function and callback to check when grid is enabled.
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function is_grid_enabled ()
|
function is_grid_enabled() {
|
||||||
{
|
|
||||||
return 'grid' == get_theme_mod( 'understrap_posts_index_style' );
|
return 'grid' == get_theme_mod( 'understrap_posts_index_style' );
|
||||||
}
|
}
|
||||||
if ( is_grid_enabled() ) {
|
|
||||||
// How many columns to use each grid post
|
// How many columns to use each grid post.
|
||||||
$wp_customize->add_setting( 'understrap_grid_post_columns', array(
|
$wp_customize->add_setting( 'understrap_grid_post_columns', array(
|
||||||
'default' => '6',
|
'default' => '6',
|
||||||
'type' => 'theme_mod',
|
'type' => 'theme_mod',
|
||||||
|
@ -174,7 +185,7 @@ if ( ! function_exists( 'understrap_theme_customize_register' ) ) {
|
||||||
$wp_customize,
|
$wp_customize,
|
||||||
'understrap_grid_post_columns', array(
|
'understrap_grid_post_columns', array(
|
||||||
'label' => __( 'Grid Post Columns', 'understrap' ),
|
'label' => __( 'Grid Post Columns', 'understrap' ),
|
||||||
'description' => __( "Choose how many columns to use in grid posts", 'understrap' ),
|
'description' => __( 'Choose how many columns to use in grid posts', 'understrap' ),
|
||||||
'section' => 'understrap_theme_layout_options',
|
'section' => 'understrap_theme_layout_options',
|
||||||
'settings' => 'understrap_grid_post_columns',
|
'settings' => 'understrap_grid_post_columns',
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
|
@ -191,11 +202,11 @@ if ( ! function_exists( 'understrap_theme_customize_register' ) ) {
|
||||||
)
|
)
|
||||||
) );
|
) );
|
||||||
|
|
||||||
}
|
// hook to auto-hide/show depending the understrap_posts_index_style option.
|
||||||
// hook to auto-hide/show depending the understrap_posts_index_style option
|
|
||||||
$wp_customize->get_control( 'understrap_grid_post_columns' )->active_callback = 'is_grid_enabled';
|
$wp_customize->get_control( 'understrap_grid_post_columns' )->active_callback = 'is_grid_enabled';
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
} // endif function_exists( 'understrap_theme_customize_register' ).
|
||||||
add_action( 'customize_register', 'understrap_theme_customize_register' );
|
add_action( 'customize_register', 'understrap_theme_customize_register' );
|
||||||
|
|
||||||
|
|
||||||
|
@ -203,8 +214,12 @@ add_action( 'customize_register', 'understrap_theme_customize_register' );
|
||||||
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
|
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
|
||||||
*/
|
*/
|
||||||
if ( ! function_exists( 'understrap_customize_preview_js' ) ) {
|
if ( ! function_exists( 'understrap_customize_preview_js' ) ) {
|
||||||
|
/**
|
||||||
|
* Setup JS integration for live previewing.
|
||||||
|
*/
|
||||||
function understrap_customize_preview_js() {
|
function understrap_customize_preview_js() {
|
||||||
wp_enqueue_script( 'understrap_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20130508', true );
|
wp_enqueue_script( 'understrap_customizer', get_template_directory_uri() . '/js/customizer.js',
|
||||||
|
array( 'customize-preview' ), '20130508', true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_action( 'customize_preview_init', 'understrap_customize_preview_js' );
|
add_action( 'customize_preview_init', 'understrap_customize_preview_js' );
|
||||||
|
|
|
@ -1,15 +1,20 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* understrap enqueue scripts
|
* Understrap enqueue scripts
|
||||||
*
|
*
|
||||||
* @package understrap
|
* @package understrap
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! function_exists( 'understrap_scripts' ) ) {
|
if ( ! function_exists( 'understrap_scripts' ) ) {
|
||||||
|
/**
|
||||||
|
* Load theme's JavaScript sources.
|
||||||
|
*/
|
||||||
function understrap_scripts() {
|
function understrap_scripts() {
|
||||||
wp_enqueue_style( 'understrap-styles', get_stylesheet_directory_uri() . '/css/theme.min.css', array(), '0.4.9' );
|
wp_enqueue_style( 'understrap-styles', get_stylesheet_directory_uri() . '/css/theme.min.css', array(),
|
||||||
|
'0.4.9' );
|
||||||
wp_enqueue_script( 'jquery' );
|
wp_enqueue_script( 'jquery' );
|
||||||
wp_enqueue_script( 'understrap-scripts', get_template_directory_uri() . '/js/theme.min.js', array(), '0.4.9', true );
|
wp_enqueue_script( 'understrap-scripts', get_template_directory_uri() . '/js/theme.min.js', array(), '0.4.9',
|
||||||
|
true );
|
||||||
|
|
||||||
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
|
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
|
||||||
wp_enqueue_script( 'comment-reply' );
|
wp_enqueue_script( 'comment-reply' );
|
||||||
|
@ -17,7 +22,7 @@ if ( ! function_exists ( 'understrap_scripts' ) ) {
|
||||||
|
|
||||||
// menu - vertical page association
|
// menu - vertical page association
|
||||||
// do not load on WooCommerce pages
|
// do not load on WooCommerce pages
|
||||||
// do not load if we are in WooCommerce pages
|
// do not load if we are in WooCommerce pages.
|
||||||
$loadit = true;
|
$loadit = true;
|
||||||
if ( class_exists( 'WooCommerce' ) ) {
|
if ( class_exists( 'WooCommerce' ) ) {
|
||||||
if ( is_woocommerce() ) {
|
if ( is_woocommerce() ) {
|
||||||
|
@ -25,40 +30,45 @@ if ( ! function_exists ( 'understrap_scripts' ) ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( is_page_template( ( 'page-templates/vertical-one-page.php' ) || is_home() || is_single() ) && $loadit ) {
|
if ( is_page_template( ( 'page-templates/vertical-one-page.php' ) || is_home() || is_single() ) && $loadit ) {
|
||||||
wp_enqueue_script( 'vertical-one-page', get_template_directory_uri() . '/js/vertical-one-page.js', array( 'jquery' ), '0.4.9', true );
|
wp_enqueue_script( 'vertical-one-page', get_template_directory_uri() . '/js/vertical-one-page.js',
|
||||||
|
array( 'jquery' ), '0.4.9', true );
|
||||||
$page_for_posts = strtolower( get_the_title( get_option( 'page_for_posts' ) ) );
|
$page_for_posts = strtolower( get_the_title( get_option( 'page_for_posts' ) ) );
|
||||||
$home_url = home_url();
|
$home_url = home_url();
|
||||||
$is_single = is_single();
|
$is_single = is_single();
|
||||||
$vars = array(
|
$vars = array(
|
||||||
'pageForPosts' => $page_for_posts,
|
'pageForPosts' => $page_for_posts,
|
||||||
'homeUrl' => $home_url,
|
'homeUrl' => $home_url,
|
||||||
'isSingle' => $is_single
|
'isSingle' => $is_single,
|
||||||
);
|
);
|
||||||
wp_localize_script( 'vertical-one-page', 'vars', $vars );
|
wp_localize_script( 'vertical-one-page', 'vars', $vars );
|
||||||
}
|
}
|
||||||
// menu - vertical page association end
|
// menu - vertical page association end.
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} // endif function_exists( 'understrap_scripts' ).
|
||||||
|
|
||||||
add_action( 'wp_enqueue_scripts', 'understrap_scripts' );
|
add_action( 'wp_enqueue_scripts', 'understrap_scripts' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*Loading slider script conditionally
|
*Loading slider script conditionally
|
||||||
**/
|
*/
|
||||||
|
|
||||||
if ( is_active_sidebar( 'hero' ) ) :
|
if ( is_active_sidebar( 'hero' ) ) :
|
||||||
add_action( "wp_enqueue_scripts", "understrap_slider" );
|
add_action( 'wp_enqueue_scripts', 'understrap_slider' );
|
||||||
|
|
||||||
if ( ! function_exists( 'understrap_slider' ) ) {
|
if ( ! function_exists( 'understrap_slider' ) ) {
|
||||||
|
/**
|
||||||
|
* Setup slider.
|
||||||
|
*/
|
||||||
function understrap_slider() {
|
function understrap_slider() {
|
||||||
if ( is_front_page() ) {
|
if ( is_front_page() ) {
|
||||||
$data = array(
|
$data = array(
|
||||||
"timeout" => intval( get_theme_mod( 'understrap_theme_slider_time_setting', 5000 ) ),
|
'timeout' => intval( get_theme_mod( 'understrap_theme_slider_time_setting', 5000 ) ),
|
||||||
"items" => intval( get_theme_mod( 'understrap_theme_slider_count_setting', 1 ) )
|
'items' => intval( get_theme_mod( 'understrap_theme_slider_count_setting', 1 ) ),
|
||||||
);
|
);
|
||||||
|
|
||||||
wp_enqueue_script( "understrap-slider-script", get_stylesheet_directory_uri() . '/js/slider_settings.js', array(), '0.4.9' );
|
wp_enqueue_script( 'understrap-slider-script',
|
||||||
wp_localize_script( "understrap-slider-script", "understrap_slider_variables", $data );
|
get_stylesheet_directory_uri() . '/js/slider_settings.js', array(), '0.4.9' );
|
||||||
|
wp_localize_script( 'understrap-slider-script', 'understrap_slider_variables', $data );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,14 +6,15 @@
|
||||||
*
|
*
|
||||||
* @package understrap
|
* @package understrap
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if ( ! function_exists( 'understrap_body_classes' ) ) {
|
||||||
/**
|
/**
|
||||||
* Adds custom classes to the array of body classes.
|
* Adds custom classes to the array of body classes.
|
||||||
*
|
*
|
||||||
* @param array $classes Classes for the body element.
|
* @param array $classes Classes for the body element.
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! function_exists ( 'understrap_body_classes' ) ) {
|
|
||||||
function understrap_body_classes( $classes ) {
|
function understrap_body_classes( $classes ) {
|
||||||
// Adds a class of group-blog to blogs with more than 1 published author.
|
// Adds a class of group-blog to blogs with more than 1 published author.
|
||||||
if ( is_multi_author() ) {
|
if ( is_multi_author() ) {
|
||||||
|
@ -23,20 +24,29 @@ if ( ! function_exists ( 'understrap_body_classes' ) ) {
|
||||||
if ( ! is_singular() ) {
|
if ( ! is_singular() ) {
|
||||||
$classes[] = 'hfeed';
|
$classes[] = 'hfeed';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $classes;
|
return $classes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_filter( 'body_class', 'understrap_body_classes' );
|
add_filter( 'body_class', 'understrap_body_classes' );
|
||||||
|
|
||||||
// Removes tag class from the body_class array to avoid Bootstrap markup styling issues.
|
// Removes tag class from the body_class array to avoid Bootstrap markup styling issues.
|
||||||
|
|
||||||
add_filter( 'body_class', 'adjust_body_class' );
|
add_filter( 'body_class', 'adjust_body_class' );
|
||||||
|
|
||||||
if ( ! function_exists( 'adjust_body_class' ) ) {
|
if ( ! function_exists( 'adjust_body_class' ) ) {
|
||||||
|
/**
|
||||||
|
* Setup body classes.
|
||||||
|
*
|
||||||
|
* @param string $classes CSS classes.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
function adjust_body_class( $classes ) {
|
function adjust_body_class( $classes ) {
|
||||||
|
|
||||||
foreach ( $classes as $key => $value ) {
|
foreach ( $classes as $key => $value ) {
|
||||||
if ( $value == 'tag' ) unset( $classes[ $key ] );
|
if ( $value == 'tag' ) {
|
||||||
|
unset( $classes[ $key ] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $classes;
|
return $classes;
|
||||||
|
@ -44,14 +54,21 @@ if ( ! function_exists ( 'adjust_body_class' ) ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter custom logo with correct classes
|
// Filter custom logo with correct classes.
|
||||||
add_filter( 'get_custom_logo', 'change_logo_class' );
|
add_filter( 'get_custom_logo', 'change_logo_class' );
|
||||||
|
|
||||||
if ( ! function_exists( 'change_logo_class' ) ) {
|
if ( ! function_exists( 'change_logo_class' ) ) {
|
||||||
function change_logo_class($html)
|
/**
|
||||||
{
|
* Replaces logo CSS class.
|
||||||
|
*
|
||||||
|
* @param string $html Markup.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
function change_logo_class( $html ) {
|
||||||
$html = str_replace( 'class="custom-logo"', 'class="img-responsive"', $html );
|
$html = str_replace( 'class="custom-logo"', 'class="img-responsive"', $html );
|
||||||
$html = str_replace( 'class="custom-logo-link"', 'class="navbar-brand custom-logo-link"', $html );
|
$html = str_replace( 'class="custom-logo-link"', 'class="navbar-brand custom-logo-link"', $html );
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,13 +6,14 @@
|
||||||
*
|
*
|
||||||
* @package understrap
|
* @package understrap
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if ( ! function_exists( 'understrap_jetpack_setup' ) ) {
|
||||||
/**
|
/**
|
||||||
* Jetpack setup function.
|
* Jetpack setup function.
|
||||||
*
|
*
|
||||||
* See: https://jetpack.com/support/infinite-scroll/
|
* See: https://jetpack.com/support/infinite-scroll/
|
||||||
* See: https://jetpack.com/support/responsive-videos/
|
* See: https://jetpack.com/support/responsive-videos/
|
||||||
*/
|
*/
|
||||||
if ( ! function_exists ( 'understrap_jetpack_setup' ) ) {
|
|
||||||
function understrap_jetpack_setup() {
|
function understrap_jetpack_setup() {
|
||||||
// Add theme support for Infinite Scroll.
|
// Add theme support for Infinite Scroll.
|
||||||
add_theme_support( 'infinite-scroll', array(
|
add_theme_support( 'infinite-scroll', array(
|
||||||
|
@ -25,10 +26,10 @@ if ( ! function_exists ( 'understrap_jetpack_setup' ) ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_action( 'after_setup_theme', 'understrap_jetpack_setup' );
|
add_action( 'after_setup_theme', 'understrap_jetpack_setup' );
|
||||||
|
if ( ! function_exists( 'understrap_infinite_scroll_render' ) ) {
|
||||||
/**
|
/**
|
||||||
* Custom render function for Infinite Scroll.
|
* Custom render function for Infinite Scroll.
|
||||||
*/
|
*/
|
||||||
if ( ! function_exists ( 'understrap_infinite_scroll_render' ) ) {
|
|
||||||
function understrap_infinite_scroll_render() {
|
function understrap_infinite_scroll_render() {
|
||||||
while ( have_posts() ) {
|
while ( have_posts() ) {
|
||||||
the_post();
|
the_post();
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
<?php
|
<?php
|
||||||
/* Inspired by Simon Bradburys cleanup.php fromb4st theme https://github.com/SimonPadbury/b4st */
|
/**
|
||||||
/*
|
* Inspired by Simon Bradburys cleanup.php fromb4st theme https://github.com/SimonPadbury/b4st
|
||||||
Removes the generator tag with WP version numbers. Hackers will use this to find weak and old WP installs
|
*
|
||||||
|
* @package understrap
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the generator tag with WP version numbers. Hackers will use this to find weak and old WP installs
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
function no_generator() {
|
function no_generator() {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
add_filter( 'the_generator', 'no_generator' );
|
add_filter( 'the_generator', 'no_generator' );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -19,11 +27,15 @@ remove_action('wp_head', 'feed_links', 2);
|
||||||
remove_action( 'wp_head', 'feed_links_extra', 3 );
|
remove_action( 'wp_head', 'feed_links_extra', 3 );
|
||||||
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
|
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
|
||||||
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
|
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
|
||||||
/*
|
|
||||||
Show less info to users on failed login for security.
|
/**
|
||||||
(Will not let a valid username be known.)
|
* Show less info to users on failed login for security.
|
||||||
|
* (Will not let a valid username be known.)
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
function show_less_login_info() {
|
function show_less_login_info() {
|
||||||
return "<strong>ERROR</strong>: Stop guessing!";
|
return '<strong>ERROR</strong>: Stop guessing!';
|
||||||
}
|
}
|
||||||
|
|
||||||
add_filter( 'login_errors', 'show_less_login_info' );
|
add_filter( 'login_errors', 'show_less_login_info' );
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Set the content width based on the theme's design and stylesheet.
|
* Theme basic setup.
|
||||||
|
*
|
||||||
* @package understrap
|
* @package understrap
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require get_template_directory() . '/inc/theme-settings.php';
|
require get_template_directory() . '/inc/theme-settings.php';
|
||||||
|
|
||||||
|
// Set the content width based on the theme's design and stylesheet.
|
||||||
if ( ! isset( $content_width ) ) {
|
if ( ! isset( $content_width ) ) {
|
||||||
$content_width = 640; /* pixels */
|
$content_width = 640; /* pixels */
|
||||||
}
|
}
|
||||||
|
@ -19,7 +21,6 @@ if ( ! function_exists( 'understrap_setup' ) ) :
|
||||||
* as indicating support for post thumbnails.
|
* as indicating support for post thumbnails.
|
||||||
*/
|
*/
|
||||||
function understrap_setup() {
|
function understrap_setup() {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make theme available for translation.
|
* Make theme available for translation.
|
||||||
* Translations can be filed in the /languages/ directory.
|
* Translations can be filed in the /languages/ directory.
|
||||||
|
@ -56,20 +57,28 @@ function understrap_setup() {
|
||||||
* to output valid HTML5.
|
* to output valid HTML5.
|
||||||
*/
|
*/
|
||||||
add_theme_support( 'html5', array(
|
add_theme_support( 'html5', array(
|
||||||
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption',
|
'search-form',
|
||||||
|
'comment-form',
|
||||||
|
'comment-list',
|
||||||
|
'gallery',
|
||||||
|
'caption',
|
||||||
) );
|
) );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Adding Thumbnail basic support
|
* Adding Thumbnail basic support
|
||||||
*/
|
*/
|
||||||
add_theme_support( "post-thumbnails" );
|
add_theme_support( 'post-thumbnails' );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Enable support for Post Formats.
|
* Enable support for Post Formats.
|
||||||
* See http://codex.wordpress.org/Post_Formats
|
* See http://codex.wordpress.org/Post_Formats
|
||||||
*/
|
*/
|
||||||
add_theme_support( 'post-formats', array(
|
add_theme_support( 'post-formats', array(
|
||||||
'aside', 'image', 'video', 'quote', 'link',
|
'aside',
|
||||||
|
'image',
|
||||||
|
'video',
|
||||||
|
'quote',
|
||||||
|
'link',
|
||||||
) );
|
) );
|
||||||
|
|
||||||
// Set up the WordPress core custom background feature.
|
// Set up the WordPress core custom background feature.
|
||||||
|
@ -84,29 +93,35 @@ function understrap_setup() {
|
||||||
// Check and setup theme default settings.
|
// Check and setup theme default settings.
|
||||||
setup_theme_default_settings();
|
setup_theme_default_settings();
|
||||||
}
|
}
|
||||||
endif; // understrap_setup
|
endif; // understrap_setup.
|
||||||
add_action( 'after_setup_theme', 'understrap_setup' );
|
add_action( 'after_setup_theme', 'understrap_setup' );
|
||||||
|
|
||||||
/**
|
|
||||||
* Adding the Read more link to excerpts
|
|
||||||
*/
|
|
||||||
/*function new_excerpt_more( $more ) {
|
|
||||||
return ' <p><a class="read-more btn btn-default" href="'. get_permalink( get_the_ID() ) . '">' . __('Read More', 'understrap') . '</a></p>';
|
|
||||||
}
|
|
||||||
add_filter( 'excerpt_more', 'new_excerpt_more' );*/
|
|
||||||
/* Removes the ... from the excerpt read more link */
|
|
||||||
if ( ! function_exists( 'custom_excerpt_more' ) ) {
|
if ( ! function_exists( 'custom_excerpt_more' ) ) {
|
||||||
|
/**
|
||||||
|
* Removes the ... from the excerpt read more link
|
||||||
|
*
|
||||||
|
* @param string $more The excerpt.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function custom_excerpt_more( $more ) {
|
function custom_excerpt_more( $more ) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_filter( 'excerpt_more', 'custom_excerpt_more' );
|
add_filter( 'excerpt_more', 'custom_excerpt_more' );
|
||||||
|
|
||||||
/* Adds a custom read more link to all excerpts, manually or automatically generated */
|
|
||||||
if ( ! function_exists( 'all_excerpts_get_more_link' ) ) {
|
if ( ! function_exists( 'all_excerpts_get_more_link' ) ) {
|
||||||
|
/**
|
||||||
|
* Adds a custom read more link to all excerpts, manually or automatically generated
|
||||||
|
*
|
||||||
|
* @param string $post_excerpt Posts's excerpt.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function all_excerpts_get_more_link( $post_excerpt ) {
|
function all_excerpts_get_more_link( $post_excerpt ) {
|
||||||
|
|
||||||
return $post_excerpt . ' [...]<p><a class="btn btn-secondary understrap-read-more-link" href="'. get_permalink( get_the_ID() ) . '">' . __('Read More...', 'understrap') . '</a></p>';
|
return $post_excerpt . ' [...]<p><a class="btn btn-secondary understrap-read-more-link" href="' . get_permalink( get_the_ID() ) . '">' . __( 'Read More...',
|
||||||
|
'understrap' ) . '</a></p>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
add_filter( 'wp_trim_excerpt', 'all_excerpts_get_more_link' );
|
add_filter( 'wp_trim_excerpt', 'all_excerpts_get_more_link' );
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
* @package understrap
|
* @package understrap
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
if ( ! function_exists( 'understrap_posted_on' ) ) :
|
if ( ! function_exists( 'understrap_posted_on' ) ) :
|
||||||
/**
|
/**
|
||||||
* Prints HTML with meta information for the current post-date/time and author.
|
* Prints HTML with meta information for the current post-date/time and author.
|
||||||
|
@ -15,7 +14,8 @@ if ( ! function_exists( 'understrap_posted_on' ) ) :
|
||||||
function understrap_posted_on() {
|
function understrap_posted_on() {
|
||||||
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
|
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
|
||||||
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
|
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
|
||||||
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>, <time class="updated" datetime="%3$s">' . __( ' Edited %4$s', 'understrap' ) . '</time>';
|
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>, <time class="updated" datetime="%3$s">' . __( ' Edited %4$s',
|
||||||
|
'understrap' ) . '</time>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$time_string = sprintf( $time_string,
|
$time_string = sprintf( $time_string,
|
||||||
|
@ -50,7 +50,8 @@ function understrap_entry_footer() {
|
||||||
/* translators: used between list items, there is a space after the comma */
|
/* translators: used between list items, there is a space after the comma */
|
||||||
$categories_list = get_the_category_list( __( ', ', 'understrap' ) );
|
$categories_list = get_the_category_list( __( ', ', 'understrap' ) );
|
||||||
if ( $categories_list && understrap_categorized_blog() ) {
|
if ( $categories_list && understrap_categorized_blog() ) {
|
||||||
printf( '<span class="cat-links">' . __( 'Posted in %1$s', 'understrap' ) . '</span>', $categories_list );
|
printf( '<span class="cat-links">' . __( 'Posted in %1$s', 'understrap' ) . '</span>',
|
||||||
|
$categories_list );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* translators: used between list items, there is a space after the comma */
|
/* translators: used between list items, there is a space after the comma */
|
||||||
|
@ -62,7 +63,8 @@ function understrap_entry_footer() {
|
||||||
|
|
||||||
if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
|
if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
|
||||||
echo '<span class="comments-link">';
|
echo '<span class="comments-link">';
|
||||||
comments_popup_link( __( 'Leave a comment', 'understrap' ), __( '1 Comment', 'understrap' ), __( '% Comments', 'understrap' ) );
|
comments_popup_link( __( 'Leave a comment', 'understrap' ), __( '1 Comment', 'understrap' ),
|
||||||
|
__( '% Comments', 'understrap' ) );
|
||||||
echo '</span>';
|
echo '</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,5 +121,6 @@ function understrap_category_transient_flusher() {
|
||||||
// Like, beat it. Dig?
|
// Like, beat it. Dig?
|
||||||
delete_transient( 'understrap_categories' );
|
delete_transient( 'understrap_categories' );
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action( 'edit_category', 'understrap_category_transient_flusher' );
|
add_action( 'edit_category', 'understrap_category_transient_flusher' );
|
||||||
add_action( 'save_post', 'understrap_category_transient_flusher' );
|
add_action( 'save_post', 'understrap_category_transient_flusher' );
|
||||||
|
|
|
@ -6,7 +6,6 @@ function setup_theme_default_settings() {
|
||||||
|
|
||||||
// check if settings are set, if not set defaults.
|
// check if settings are set, if not set defaults.
|
||||||
// Caution: DO NOT check existence using === always check with == .
|
// Caution: DO NOT check existence using === always check with == .
|
||||||
|
|
||||||
// Latest blog posts style.
|
// Latest blog posts style.
|
||||||
$understrap_posts_index_style = get_theme_mod( 'understrap_posts_index_style' );
|
$understrap_posts_index_style = get_theme_mod( 'understrap_posts_index_style' );
|
||||||
if ( '' == $understrap_posts_index_style ) {
|
if ( '' == $understrap_posts_index_style ) {
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Utility functions
|
* Utility functions
|
||||||
|
*
|
||||||
|
* @package understrap
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a custom length excerpt.
|
* Generate a custom length excerpt.
|
||||||
* If the content of the post is less than the provided length,
|
* If the content of the post is less than the provided length,
|
||||||
* the entire content is returned.
|
* the entire content is returned.
|
||||||
* @param $word_count
|
*
|
||||||
|
* @param int $post_id Post's ID.
|
||||||
|
* @param int $word_count How many words to keep.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -20,7 +24,7 @@ function understrap_excerpt_with_length( $post_id, $word_count ) {
|
||||||
$words = str_word_count( $content, 2 );
|
$words = str_word_count( $content, 2 );
|
||||||
$keys = array_keys( $words );
|
$keys = array_keys( $words );
|
||||||
$excerpt = substr( $content, 0, $keys[ $word_count ] );
|
$excerpt = substr( $content, 0, $keys[ $word_count ] );
|
||||||
$link_class = " class=\"btn btn-secondary understrap-read-more-link\"";
|
$link_class = ' class=\"btn btn-secondary understrap-read-more-link\"';
|
||||||
$excerpt = '<p>' . $excerpt . '[...]</p>';
|
$excerpt = '<p>' . $excerpt . '[...]</p>';
|
||||||
$excerpt .= '<p><a href="' . $permalink . '"' . $link_class . '>Read More</a></p>';
|
$excerpt .= '<p><a href="' . $permalink . '"' . $link_class . '>Read More</a></p>';
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -2,10 +2,13 @@
|
||||||
/**
|
/**
|
||||||
* Declaring widgets
|
* Declaring widgets
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @package understrap
|
* @package understrap
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( ! function_exists( 'understrap_widgets_init' ) ) {
|
if ( ! function_exists( 'understrap_widgets_init' ) ) {
|
||||||
|
/**
|
||||||
|
* Initializes themes widgets.
|
||||||
|
*/
|
||||||
function understrap_widgets_init() {
|
function understrap_widgets_init() {
|
||||||
register_sidebar( array(
|
register_sidebar( array(
|
||||||
'name' => __( 'Right Sidebar', 'understrap' ),
|
'name' => __( 'Right Sidebar', 'understrap' ),
|
||||||
|
@ -58,5 +61,5 @@ if ( ! function_exists( 'understrap_widgets_init' ) ) {
|
||||||
) );
|
) );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
} // endif function_exists( 'understrap_widgets_init' ).
|
||||||
add_action( 'widgets_init', 'understrap_widgets_init' );
|
add_action( 'widgets_init', 'understrap_widgets_init' );
|
||||||
|
|
|
@ -2,15 +2,17 @@
|
||||||
/**
|
/**
|
||||||
* Add WooCommerce support
|
* Add WooCommerce support
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @package understrap
|
* @package understrap
|
||||||
*/
|
*/
|
||||||
|
|
||||||
add_action( 'after_setup_theme', 'woocommerce_support' );
|
add_action( 'after_setup_theme', 'woocommerce_support' );
|
||||||
if ( ! function_exists( 'woocommerce_support' ) ) {
|
if ( ! function_exists( 'woocommerce_support' ) ) {
|
||||||
|
/**
|
||||||
|
* Declares WooCommerce theme support.
|
||||||
|
*/
|
||||||
function woocommerce_support() {
|
function woocommerce_support() {
|
||||||
add_theme_support( 'woocommerce' );
|
add_theme_support( 'woocommerce' );
|
||||||
// hook in and customizer form fields
|
// hook in and customizer form fields.
|
||||||
add_filter( 'woocommerce_form_field_args', 'wc_form_field_args', 10, 3 );
|
add_filter( 'woocommerce_form_field_args', 'wc_form_field_args', 10, 3 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,16 +21,15 @@ if ( ! function_exists( 'woocommerce_support' ) ) {
|
||||||
* Filter hook function monkey patching form classes
|
* Filter hook function monkey patching form classes
|
||||||
* Author: Adriano Monecchi http://stackoverflow.com/a/36724593/307826
|
* Author: Adriano Monecchi http://stackoverflow.com/a/36724593/307826
|
||||||
*
|
*
|
||||||
* @param $args
|
* @param string $args Form attributes.
|
||||||
* @param $key
|
* @param string $key Not in use.
|
||||||
* @param null $value
|
* @param null $value Not in use.
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function wc_form_field_args( $args, $key, $value = null ) {
|
function wc_form_field_args( $args, $key, $value = null ) {
|
||||||
|
|
||||||
// Start field type switch case
|
// Start field type switch case.
|
||||||
|
|
||||||
switch ( $args['type'] ) {
|
switch ( $args['type'] ) {
|
||||||
|
|
||||||
/* Targets all select input type elements, except the country and state select input types */
|
/* Targets all select input type elements, except the country and state select input types */
|
||||||
|
@ -99,7 +100,7 @@ function wc_form_field_args( $args, $key, $value = null ) {
|
||||||
$args['input_class'] = array( 'form-control', 'input-lg' );
|
$args['input_class'] = array( 'form-control', 'input-lg' );
|
||||||
$args['label_class'] = array( 'control-label' );
|
$args['label_class'] = array( 'control-label' );
|
||||||
break;
|
break;
|
||||||
}
|
} // end switch ($args).
|
||||||
|
|
||||||
return $args;
|
return $args;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,12 @@
|
||||||
* @package understrap
|
* @package understrap
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if ( ! function_exists( 'understrap_wpcom_setup' ) ) {
|
||||||
/**
|
/**
|
||||||
* Adds support for wp.com-specific theme functions.
|
* Adds support for wp.com-specific theme functions.
|
||||||
*
|
*
|
||||||
* @global array $themecolors
|
* @global array $themecolors Array with theme's colors.
|
||||||
*/
|
*/
|
||||||
if ( ! function_exists ( 'understrap_wpcom_setup' ) ) {
|
|
||||||
function understrap_wpcom_setup() {
|
function understrap_wpcom_setup() {
|
||||||
global $themecolors;
|
global $themecolors;
|
||||||
|
|
||||||
|
|
Reference in New Issue