code formatting
This commit is contained in:
parent
968278f240
commit
b41729840f
|
@ -5,48 +5,49 @@ $sidebar_pos = get_theme_mod( 'understrap_sidebar_position' );
|
||||||
// is active and the current page is a WooCommerce page and we do
|
// is active and the current page is a WooCommerce page and we do
|
||||||
// not render sidebars.
|
// not render sidebars.
|
||||||
$is_woocommerce = false;
|
$is_woocommerce = false;
|
||||||
$this_page_id = get_queried_object_id();
|
$this_page_id = get_queried_object_id();
|
||||||
if ( class_exists( 'WooCommerce' ) ) {
|
if ( class_exists( 'WooCommerce' ) ) {
|
||||||
|
|
||||||
if ( is_woocommerce() || is_shop() || get_option( 'woocommerce_shop_page_id' ) === $this_page_id ||
|
if ( is_woocommerce() || is_shop() || get_option( 'woocommerce_shop_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_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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<?php if ( 'left' === $sidebar_pos || 'both' === $sidebar_pos && !$is_woocommerce ) : ?>
|
<?php if ( 'left' === $sidebar_pos || 'both' === $sidebar_pos && ! $is_woocommerce ) : ?>
|
||||||
<?php get_sidebar( 'left' ); ?>
|
<?php get_sidebar( 'left' ); ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if ( $is_woocommerce ) {
|
if ( $is_woocommerce ) {
|
||||||
echo '<div class="col-md-12 content-area" id="primary">';
|
echo '<div class="col-md-12 content-area" id="primary">';
|
||||||
} else {
|
} else {
|
||||||
$html = '';
|
$html = '';
|
||||||
if ( 'right' === $sidebar_pos || 'left' === $sidebar_pos ) {
|
if ( 'right' === $sidebar_pos || 'left' === $sidebar_pos ) {
|
||||||
$html = '<div class="';
|
$html = '<div class="';
|
||||||
if ( is_active_sidebar( 'right-sidebar' ) || is_active_sidebar( 'left-sidebar' ) ) {
|
if ( is_active_sidebar( 'right-sidebar' ) || is_active_sidebar( 'left-sidebar' ) ) {
|
||||||
$html .= 'col-md-8 content-area" id="primary">';
|
$html .= 'col-md-8 content-area" id="primary">';
|
||||||
} else {
|
} else {
|
||||||
$html .= 'col-md-12 content-area" id="primary">';
|
$html .= 'col-md-12 content-area" id="primary">';
|
||||||
}
|
|
||||||
echo $html;
|
|
||||||
} elseif ( is_active_sidebar( 'right-sidebar' ) && is_active_sidebar( 'left-sidebar' ) ) {
|
|
||||||
$html = '<div class="';
|
|
||||||
if ( 'both' === $sidebar_pos ) {
|
|
||||||
$html .= 'col-md-6 content-area" id="primary">';
|
|
||||||
} else {
|
|
||||||
$html .= 'col-md-12 content-area" id="primary">';
|
|
||||||
}
|
|
||||||
echo $html;
|
|
||||||
}
|
}
|
||||||
|
echo $html;
|
||||||
|
} elseif ( is_active_sidebar( 'right-sidebar' ) && is_active_sidebar( 'left-sidebar' ) ) {
|
||||||
|
$html = '<div class="';
|
||||||
|
if ( 'both' === $sidebar_pos ) {
|
||||||
|
$html .= 'col-md-6 content-area" id="primary">';
|
||||||
|
} else {
|
||||||
|
$html .= 'col-md-12 content-area" id="primary">';
|
||||||
|
}
|
||||||
|
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,105 +1,139 @@
|
||||||
<?php
|
<?php
|
||||||
//Based on Roots Sage Gallery: https://github.com/roots/sage/blob/5b9786b8ceecfe717db55666efe5bcf0c9e1801c/lib/gallery.php
|
/**
|
||||||
|
* Based on Roots Sage Gallery: https://github.com/roots/sage/blob/5b9786b8ceecfe717db55666efe5bcf0c9e1801c/lib/gallery.php
|
||||||
|
*
|
||||||
|
* @package understrap
|
||||||
|
*/
|
||||||
|
|
||||||
// Remove built in shortcode
|
// Remove built in shortcode.
|
||||||
remove_shortcode('gallery', 'gallery_shortcode');
|
remove_shortcode( 'gallery', 'gallery_shortcode' );
|
||||||
|
|
||||||
// Replace with custom shortcode
|
/*
|
||||||
function shortcode_gallery($attr) {
|
* Replace with custom shortcode
|
||||||
$post = get_post();
|
*/
|
||||||
static $instance = 0;
|
function shortcode_gallery( $attr ) {
|
||||||
$instance++;
|
$post = get_post();
|
||||||
if (!empty($attr['ids'])) {
|
static $instance = 0;
|
||||||
if (empty($attr['orderby'])) {
|
$instance ++;
|
||||||
$attr['orderby'] = 'post__in';
|
if ( ! empty( $attr['ids'] ) ) {
|
||||||
}
|
if ( empty( $attr['orderby'] ) ) {
|
||||||
$attr['include'] = $attr['ids'];
|
$attr['orderby'] = 'post__in';
|
||||||
}
|
}
|
||||||
$output = apply_filters('post_gallery', '', $attr);
|
$attr['include'] = $attr['ids'];
|
||||||
if ($output != '') {
|
}
|
||||||
return $output;
|
$output = apply_filters( 'post_gallery', '', $attr );
|
||||||
}
|
if ( $output != '' ) {
|
||||||
if (isset($attr['orderby'])) {
|
return $output;
|
||||||
$attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
|
}
|
||||||
if (!$attr['orderby']) {
|
if ( isset( $attr['orderby'] ) ) {
|
||||||
unset($attr['orderby']);
|
$attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
|
||||||
}
|
if ( ! $attr['orderby'] ) {
|
||||||
}
|
unset( $attr['orderby'] );
|
||||||
extract(shortcode_atts([
|
}
|
||||||
'order' => 'ASC',
|
}
|
||||||
'orderby' => 'menu_order ID',
|
extract( shortcode_atts( [
|
||||||
'id' => $post->ID,
|
'order' => 'ASC',
|
||||||
'itemtag' => '',
|
'orderby' => 'menu_order ID',
|
||||||
'icontag' => '',
|
'id' => $post->ID,
|
||||||
'captiontag' => '',
|
'itemtag' => '',
|
||||||
'columns' => 3,
|
'icontag' => '',
|
||||||
'size' => 'thumbnail',
|
'captiontag' => '',
|
||||||
'include' => '',
|
'columns' => 3,
|
||||||
'exclude' => '',
|
'size' => 'thumbnail',
|
||||||
'link' => ''
|
'include' => '',
|
||||||
], $attr));
|
'exclude' => '',
|
||||||
$id = intval($id);
|
'link' => '',
|
||||||
$columns = (12 % $columns == 0) ? $columns : 3;
|
], $attr ) );
|
||||||
$grid = sprintf('col-sm-%1$s col-lg-%1$s', 12 / $columns);
|
$id = intval( $id );
|
||||||
if ($order === 'RAND') {
|
$columns = ( 12 % $columns == 0 ) ? $columns : 3;
|
||||||
$orderby = 'none';
|
$grid = sprintf( 'col-sm-%1$s col-lg-%1$s', 12 / $columns );
|
||||||
}
|
if ( $order === 'RAND' ) {
|
||||||
if (!empty($include)) {
|
$orderby = 'none';
|
||||||
$_attachments = get_posts(['include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby]);
|
}
|
||||||
$attachments = [];
|
if ( ! empty( $include ) ) {
|
||||||
foreach ($_attachments as $key => $val) {
|
$_attachments = get_posts( [ 'include' => $include,
|
||||||
$attachments[$val->ID] = $_attachments[$key];
|
'post_status' => 'inherit',
|
||||||
}
|
'post_type' => 'attachment',
|
||||||
} elseif (!empty($exclude)) {
|
'post_mime_type' => 'image',
|
||||||
$attachments = get_children(['post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby]);
|
'order' => $order,
|
||||||
} else {
|
'orderby' => $orderby
|
||||||
$attachments = get_children(['post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby]);
|
] );
|
||||||
}
|
$attachments = [];
|
||||||
if (empty($attachments)) {
|
foreach ( $_attachments as $key => $val ) {
|
||||||
return '';
|
$attachments[ $val->ID ] = $_attachments[ $key ];
|
||||||
}
|
}
|
||||||
if (is_feed()) {
|
} elseif ( ! empty( $exclude ) ) {
|
||||||
$output = "\n";
|
$attachments = get_children( [ 'post_parent' => $id,
|
||||||
foreach ($attachments as $att_id => $attachment) {
|
'exclude' => $exclude,
|
||||||
$output .= wp_get_attachment_link($att_id, $size, true) . "\n";
|
'post_status' => 'inherit',
|
||||||
}
|
'post_type' => 'attachment',
|
||||||
return $output;
|
'post_mime_type' => 'image',
|
||||||
}
|
'order' => $order,
|
||||||
$unique = (get_query_var('page')) ? $instance . '-p' . get_query_var('page') : $instance;
|
'orderby' => $orderby
|
||||||
$output = '<div class="gallery gallery-' . $id . '-' . $unique . '">';
|
] );
|
||||||
$i = 0;
|
} else {
|
||||||
foreach ($attachments as $id => $attachment) {
|
$attachments = get_children( [ 'post_parent' => $id,
|
||||||
switch($link) {
|
'post_status' => 'inherit',
|
||||||
case 'file':
|
'post_type' => 'attachment',
|
||||||
$image = wp_get_attachment_link($id, $size, false, false);
|
'post_mime_type' => 'image',
|
||||||
break;
|
'order' => $order,
|
||||||
case 'none':
|
'orderby' => $orderby
|
||||||
$image = wp_get_attachment_image($id, $size, false, ['class' => 'thumbnail img-thumbnail']);
|
] );
|
||||||
break;
|
}
|
||||||
default:
|
if ( empty( $attachments ) ) {
|
||||||
$image = wp_get_attachment_link($id, $size, true, false);
|
return '';
|
||||||
break;
|
}
|
||||||
}
|
if ( is_feed() ) {
|
||||||
$output .= ($i % $columns == 0) ? '<div class="row gallery-row">' : '';
|
$output = "\n";
|
||||||
$output .= '<div class="' . $grid .'">' . $image;
|
foreach ( $attachments as $att_id => $attachment ) {
|
||||||
if (trim($attachment->post_excerpt)) {
|
$output .= wp_get_attachment_link( $att_id, $size, true ) . "\n";
|
||||||
$output .= '<div class="caption hidden">' . wptexturize($attachment->post_excerpt) . '</div>';
|
}
|
||||||
}
|
|
||||||
$output .= '</div>';
|
return $output;
|
||||||
$i++;
|
}
|
||||||
$output .= ($i % $columns == 0) ? '</div>' : '';
|
$unique = ( get_query_var( 'page' ) ) ? $instance . '-p' . get_query_var( 'page' ) : $instance;
|
||||||
}
|
$output = '<div class="gallery gallery-' . $id . '-' . $unique . '">';
|
||||||
$output .= ($i % $columns != 0 ) ? '</div>' : '';
|
$i = 0;
|
||||||
$output .= '</div>';
|
foreach ( $attachments as $id => $attachment ) {
|
||||||
return $output;
|
switch ( $link ) {
|
||||||
|
case 'file':
|
||||||
|
$image = wp_get_attachment_link( $id, $size, false, false );
|
||||||
|
break;
|
||||||
|
case 'none':
|
||||||
|
$image = wp_get_attachment_image( $id, $size, false, [ 'class' => 'thumbnail img-thumbnail' ] );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$image = wp_get_attachment_link( $id, $size, true, false );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$output .= ( $i % $columns == 0 ) ? '<div class="row gallery-row">' : '';
|
||||||
|
$output .= '<div class="' . $grid . '">' . $image;
|
||||||
|
if ( trim( $attachment->post_excerpt ) ) {
|
||||||
|
$output .= '<div class="caption hidden">' . wptexturize( $attachment->post_excerpt ) . '</div>';
|
||||||
|
}
|
||||||
|
$output .= '</div>';
|
||||||
|
$i ++;
|
||||||
|
$output .= ( $i % $columns == 0 ) ? '</div>' : '';
|
||||||
|
}
|
||||||
|
$output .= ( $i % $columns != 0 ) ? '</div>' : '';
|
||||||
|
$output .= '</div>';
|
||||||
|
|
||||||
|
return $output;
|
||||||
}
|
}
|
||||||
add_shortcode('gallery', 'shortcode_gallery');
|
|
||||||
|
add_shortcode( 'gallery', 'shortcode_gallery' );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add class="thumbnail img-thumbnail" to attachment items
|
* Add class="thumbnail img-thumbnail" to attachment items
|
||||||
|
*
|
||||||
|
* @param string $html markup.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function attachment_link_class($html) {
|
function attachment_link_class( $html ) {
|
||||||
$html = str_replace('<a', '<a class="thumbnail img-thumbnail"', $html);
|
$html = str_replace( '<a', '<a class="thumbnail img-thumbnail"', $html );
|
||||||
return $html;
|
|
||||||
|
return $html;
|
||||||
}
|
}
|
||||||
add_filter('wp_get_attachment_link', 'attachment_link_class', 10, 1);
|
|
||||||
|
add_filter( 'wp_get_attachment_link', 'attachment_link_class', 10, 1 );
|
||||||
|
|
|
@ -1,185 +1,212 @@
|
||||||
<?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() ) {
|
*/
|
||||||
$indent = str_repeat( "\t", $depth );
|
public function start_lvl( &$output, $depth = 0, $args = array() ) {
|
||||||
$output .= "\n$indent<ul class=\" dropdown-menu\" role=\"menu\">\n";
|
$indent = str_repeat( "\t", $depth );
|
||||||
}
|
$output .= "\n$indent<ul class=\" dropdown-menu\" role=\"menu\">\n";
|
||||||
/**
|
}
|
||||||
* @see Walker::start_el()
|
|
||||||
* @since 3.0.0
|
|
||||||
*
|
|
||||||
* @param string $output Passed by reference. Used to append additional content.
|
|
||||||
* @param object $item Menu item data object.
|
|
||||||
* @param int $depth Depth of menu item. Used for padding.
|
|
||||||
* @param int $current_page Menu item ID.
|
|
||||||
* @param object $args
|
|
||||||
*/
|
|
||||||
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
|
|
||||||
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
|
|
||||||
/**
|
|
||||||
* Dividers, Headers or Disabled
|
|
||||||
* =============================
|
|
||||||
* Determine whether the item is a Divider, Header, Disabled or regular
|
|
||||||
* menu item. To prevent errors we use the strcasecmp() function to so a
|
|
||||||
* comparison that is not case sensitive. The strcasecmp() function returns
|
|
||||||
* a 0 if the strings are equal.
|
|
||||||
*/
|
|
||||||
if ( strcasecmp( $item->attr_title, 'divider' ) == 0 && $depth === 1 ) {
|
|
||||||
$output .= $indent . '<li class="divider" role="presentation">';
|
|
||||||
} else if ( strcasecmp( $item->title, 'divider') == 0 && $depth === 1 ) {
|
|
||||||
$output .= $indent . '<li class="divider" role="presentation">';
|
|
||||||
} else if ( strcasecmp( $item->attr_title, 'dropdown-header') == 0 && $depth === 1 ) {
|
|
||||||
$output .= $indent . '<li class="dropdown-header" role="presentation">' . esc_attr( $item->title );
|
|
||||||
} else if ( strcasecmp($item->attr_title, 'disabled' ) == 0 ) {
|
|
||||||
$output .= $indent . '<li class="disabled" role="presentation"><a href="#">' . esc_attr( $item->title ) . '</a>';
|
|
||||||
} else {
|
|
||||||
$class_names = $value = '';
|
|
||||||
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
|
|
||||||
$classes[] = 'nav-item menu-item-' . $item->ID;
|
|
||||||
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
|
|
||||||
/*
|
|
||||||
if ( $args->has_children )
|
|
||||||
$class_names .= ' dropdown';
|
|
||||||
*/
|
|
||||||
if($args->has_children && $depth === 0) { $class_names .= ' dropdown'; } elseif($args->has_children && $depth > 0) { $class_names .= ' dropdown-submenu'; }
|
|
||||||
if ( in_array( 'current-menu-item', $classes ) )
|
|
||||||
$class_names .= ' active';
|
|
||||||
// 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
|
|
||||||
// the menu item
|
|
||||||
if ( in_array('fa', $classes)) {
|
|
||||||
$key = array_search('fa', $classes);
|
|
||||||
$icon = $classes[$key + 1];
|
|
||||||
$class_names = str_replace($classes[$key+1], '', $class_names);
|
|
||||||
$class_names = str_replace($classes[$key], '', $class_names);
|
|
||||||
}
|
|
||||||
|
|
||||||
$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
|
/**
|
||||||
$id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
|
* Open element.
|
||||||
$id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
|
*
|
||||||
$output .= $indent . '<li' . $id . $value . $class_names .'>';
|
* @see Walker::start_el()
|
||||||
$atts = array();
|
* @since 3.0.0
|
||||||
$atts['title'] = ! empty( $item->title ) ? $item->title : '';
|
*
|
||||||
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
|
* @param string $output Passed by reference. Used to append additional content.
|
||||||
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
|
* @param object $item Menu item data object.
|
||||||
// If item has_children add atts to a.
|
* @param int $depth Depth of menu item. Used for padding.
|
||||||
|
* @param mixed $args Rest arguments.
|
||||||
|
* @param int $id Element's ID.
|
||||||
|
*/
|
||||||
|
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
|
||||||
|
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
|
||||||
|
/**
|
||||||
|
* Dividers, Headers or Disabled
|
||||||
|
* =============================
|
||||||
|
* Determine whether the item is a Divider, Header, Disabled or regular
|
||||||
|
* menu item. To prevent errors we use the strcasecmp() function to so a
|
||||||
|
* comparison that is not case sensitive. The strcasecmp() function returns
|
||||||
|
* a 0 if the strings are equal.
|
||||||
|
*/
|
||||||
|
if ( strcasecmp( $item->attr_title, 'divider' ) == 0 && $depth === 1 ) {
|
||||||
|
$output .= $indent . '<li class="divider" role="presentation">';
|
||||||
|
} else if ( strcasecmp( $item->title, 'divider' ) == 0 && $depth === 1 ) {
|
||||||
|
$output .= $indent . '<li class="divider" role="presentation">';
|
||||||
|
} else if ( strcasecmp( $item->attr_title, 'dropdown-header' ) == 0 && $depth === 1 ) {
|
||||||
|
$output .= $indent . '<li class="dropdown-header" role="presentation">' . esc_attr( $item->title );
|
||||||
|
} else if ( strcasecmp( $item->attr_title, 'disabled' ) == 0 ) {
|
||||||
|
$output .= $indent . '<li class="disabled" role="presentation"><a href="#">' . esc_attr( $item->title ) . '</a>';
|
||||||
|
} else {
|
||||||
|
$class_names = $value = '';
|
||||||
|
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
|
||||||
|
$classes[] = 'nav-item menu-item-' . $item->ID;
|
||||||
|
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
|
||||||
|
/*
|
||||||
|
if ( $args->has_children )
|
||||||
|
$class_names .= ' dropdown';
|
||||||
|
*/
|
||||||
|
if ( $args->has_children && $depth === 0 ) {
|
||||||
|
$class_names .= ' dropdown';
|
||||||
|
} elseif ( $args->has_children && $depth > 0 ) {
|
||||||
|
$class_names .= ' dropdown-submenu';
|
||||||
|
}
|
||||||
|
if ( in_array( 'current-menu-item', $classes ) ) {
|
||||||
|
$class_names .= ' active';
|
||||||
|
}
|
||||||
|
// 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
|
||||||
|
// the menu item
|
||||||
|
if ( in_array( 'fa', $classes ) ) {
|
||||||
|
$key = array_search( 'fa', $classes );
|
||||||
|
$icon = $classes[ $key + 1 ];
|
||||||
|
$class_names = str_replace( $classes[ $key + 1 ], '', $class_names );
|
||||||
|
$class_names = str_replace( $classes[ $key ], '', $class_names );
|
||||||
|
}
|
||||||
|
|
||||||
if ( $args->has_children && $depth === 0 ) {
|
$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
|
||||||
$atts['href'] = '#';
|
$id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args );
|
||||||
$atts['data-toggle'] = 'dropdown';
|
$id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
|
||||||
$atts['class'] = 'nav-link dropdown-toggle';
|
$output .= $indent . '<li' . $id . $value . $class_names . '>';
|
||||||
} else {
|
$atts = array();
|
||||||
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
|
$atts['title'] = ! empty( $item->title ) ? $item->title : '';
|
||||||
$atts['class'] = 'nav-link';
|
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
|
||||||
}
|
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
|
||||||
$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args );
|
// If item has_children add atts to a.
|
||||||
$attributes = '';
|
|
||||||
foreach ( $atts as $attr => $value ) {
|
if ( $args->has_children && $depth === 0 ) {
|
||||||
if ( ! empty( $value ) ) {
|
$atts['href'] = '#';
|
||||||
$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
|
$atts['data-toggle'] = 'dropdown';
|
||||||
$attributes .= ' ' . $attr . '="' . $value . '"';
|
$atts['class'] = 'nav-link dropdown-toggle';
|
||||||
}
|
} else {
|
||||||
}
|
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
|
||||||
$item_output = $args->before;
|
$atts['class'] = 'nav-link';
|
||||||
// Font Awesome icons
|
}
|
||||||
if ( ! empty( $icon ) )
|
$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args );
|
||||||
$item_output .= '<a'. $attributes .'><span class="fa ' . esc_attr( $icon ) . '"></span> ';
|
$attributes = '';
|
||||||
else
|
foreach ( $atts as $attr => $value ) {
|
||||||
$item_output .= '<a'. $attributes .'>';
|
if ( ! empty( $value ) ) {
|
||||||
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
|
$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
|
||||||
$item_output .= ( $args->has_children && 0 === $depth ) ? ' <span class="caret"></span></a>' : '</a>';
|
$attributes .= ' ' . $attr . '="' . $value . '"';
|
||||||
$item_output .= $args->after;
|
}
|
||||||
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
|
}
|
||||||
}
|
$item_output = $args->before;
|
||||||
}
|
// Font Awesome icons
|
||||||
/**
|
if ( ! empty( $icon ) ) {
|
||||||
* Traverse elements to create list from elements.
|
$item_output .= '<a' . $attributes . '><span class="fa ' . esc_attr( $icon ) . '"></span> ';
|
||||||
*
|
} else {
|
||||||
* Display one element if the element doesn't have any children otherwise,
|
$item_output .= '<a' . $attributes . '>';
|
||||||
* display the element and its children. Will only traverse up to the max
|
}
|
||||||
* depth and no ignore elements under that depth.
|
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title,
|
||||||
*
|
$item->ID ) . $args->link_after;
|
||||||
* This method shouldn't be called directly, use the walk() method instead.
|
$item_output .= ( $args->has_children && 0 === $depth ) ? ' <span class="caret"></span></a>' : '</a>';
|
||||||
*
|
$item_output .= $args->after;
|
||||||
* @see Walker::start_el()
|
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
|
||||||
* @since 2.5.0
|
}
|
||||||
*
|
}
|
||||||
* @param object $element Data object
|
|
||||||
* @param array $children_elements List of elements to continue traversing.
|
/**
|
||||||
* @param int $max_depth Max depth to traverse.
|
* Traverse elements to create list from elements.
|
||||||
* @param int $depth Depth of current element.
|
*
|
||||||
* @param array $args
|
* Display one element if the element doesn't have any children otherwise,
|
||||||
* @param string $output Passed by reference. Used to append additional content.
|
* display the element and its children. Will only traverse up to the max
|
||||||
* @return null Null on failure with no changes to parameters.
|
* depth and no ignore elements under that depth.
|
||||||
*/
|
*
|
||||||
public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
|
* This method shouldn't be called directly, use the walk() method instead.
|
||||||
if ( ! $element )
|
*
|
||||||
return;
|
* @see Walker::start_el()
|
||||||
$id_field = $this->db_fields['id'];
|
* @since 2.5.0
|
||||||
// Display this element.
|
*
|
||||||
if ( is_object( $args[0] ) )
|
* @param object $element Data object
|
||||||
$args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] );
|
* @param array $children_elements List of elements to continue traversing.
|
||||||
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
|
* @param int $max_depth Max depth to traverse.
|
||||||
}
|
* @param int $depth Depth of current element.
|
||||||
/**
|
* @param array $args
|
||||||
* Menu Fallback
|
* @param string $output Passed by reference. Used to append additional content.
|
||||||
* =============
|
*
|
||||||
* If this function is assigned to the wp_nav_menu's fallback_cb variable
|
* @return null Null on failure with no changes to parameters.
|
||||||
* and a manu has not been assigned to the theme location in the WordPress
|
*/
|
||||||
* menu manager the function with display nothing to a non-logged in user,
|
public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
|
||||||
* and will add a link to the WordPress menu manager if logged in as an admin.
|
if ( ! $element ) {
|
||||||
*
|
return;
|
||||||
* @param array $args passed from the wp_nav_menu function.
|
}
|
||||||
*
|
$id_field = $this->db_fields['id'];
|
||||||
*/
|
// Display this element.
|
||||||
public static function fallback( $args ) {
|
if ( is_object( $args[0] ) ) {
|
||||||
if ( current_user_can( 'manage_options' ) ) {
|
$args[0]->has_children = ! empty( $children_elements[ $element->$id_field ] );
|
||||||
extract( $args );
|
}
|
||||||
$fb_output = null;
|
parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
|
||||||
if ( $container ) {
|
}
|
||||||
$fb_output = '<' . $container;
|
|
||||||
if ( $container_class )
|
/**
|
||||||
$fb_output .= ' class="' . $container_class . '"';
|
* Menu Fallback
|
||||||
if ( $container_id )
|
* =============
|
||||||
$fb_output .= ' id="' . $container_id . '"';
|
* If this function is assigned to the wp_nav_menu's fallback_cb variable
|
||||||
$fb_output .= '>';
|
* and a manu has not been assigned to the theme location in the WordPress
|
||||||
}
|
* menu manager the function with display nothing to a non-logged in user,
|
||||||
$fb_output .= '<ul';
|
* and will add a link to the WordPress menu manager if logged in as an admin.
|
||||||
if ( $menu_class )
|
*
|
||||||
$fb_output .= ' class="' . $menu_class . '"';
|
* @param array $args passed from the wp_nav_menu function.
|
||||||
if ( $menu_id )
|
*
|
||||||
$fb_output .= ' id="' . $menu_id . '"';
|
*/
|
||||||
$fb_output .= '>';
|
public static function fallback( $args ) {
|
||||||
$fb_output .= '<li><a href="' . admin_url( 'nav-menus.php' ) . '">Add a menu</a></li>';
|
if ( current_user_can( 'manage_options' ) ) {
|
||||||
$fb_output .= '</ul>';
|
extract( $args );
|
||||||
if ( $container )
|
$fb_output = null;
|
||||||
$fb_output .= '</' . $container . '>';
|
if ( $container ) {
|
||||||
echo $fb_output;
|
$fb_output = '<' . $container;
|
||||||
}
|
if ( $container_class ) {
|
||||||
}
|
$fb_output .= ' class="' . $container_class . '"';
|
||||||
|
}
|
||||||
|
if ( $container_id ) {
|
||||||
|
$fb_output .= ' id="' . $container_id . '"';
|
||||||
|
}
|
||||||
|
$fb_output .= '>';
|
||||||
|
}
|
||||||
|
$fb_output .= '<ul';
|
||||||
|
if ( $menu_class ) {
|
||||||
|
$fb_output .= ' class="' . $menu_class . '"';
|
||||||
|
}
|
||||||
|
if ( $menu_id ) {
|
||||||
|
$fb_output .= ' id="' . $menu_id . '"';
|
||||||
|
}
|
||||||
|
$fb_output .= '>';
|
||||||
|
$fb_output .= '<li><a href="' . admin_url( 'nav-menus.php' ) . '">Add a menu</a></li>';
|
||||||
|
$fb_output .= '</ul>';
|
||||||
|
if ( $container ) {
|
||||||
|
$fb_output .= '</' . $container . '>';
|
||||||
|
}
|
||||||
|
echo $fb_output;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,54 @@
|
||||||
<?php
|
<?php
|
||||||
/************* COMMENT LAYOUT *********************/
|
/**
|
||||||
// Comment Form
|
* Comment layout.
|
||||||
|
*
|
||||||
|
* @package understrap
|
||||||
|
*/
|
||||||
|
|
||||||
add_filter( 'comment_form_default_fields', 'bootstrap3_comment_form_fields' );
|
// Comments form.
|
||||||
function bootstrap3_comment_form_fields( $fields ) {
|
add_filter( 'comment_form_default_fields', 'bootstrap3_comment_form_fields' );
|
||||||
$commenter = wp_get_current_commenter();
|
|
||||||
$req = get_option( 'require_name_email' );
|
|
||||||
$aria_req = ( $req ? " aria-required='true'" : '' );
|
|
||||||
$html5 = current_theme_supports( 'html5', 'comment-form' ) ? 1 : 0;
|
|
||||||
$fields = array(
|
|
||||||
'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>',
|
|
||||||
'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>',
|
|
||||||
'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>',
|
|
||||||
);
|
|
||||||
return $fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
add_filter( 'comment_form_defaults', 'bootstrap3_comment_form' );
|
/**
|
||||||
function bootstrap3_comment_form( $args ) {
|
* Creates the comments form.
|
||||||
$args['comment_field'] = '<div class="form-group comment-form-comment">
|
*
|
||||||
|
* @param string $fields Form fields.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function bootstrap3_comment_form_fields( $fields ) {
|
||||||
|
$commenter = wp_get_current_commenter();
|
||||||
|
$req = get_option( 'require_name_email' );
|
||||||
|
$aria_req = ( $req ? " aria-required='true'" : '' );
|
||||||
|
$html5 = current_theme_supports( 'html5', 'comment-form' ) ? 1 : 0;
|
||||||
|
$fields = array(
|
||||||
|
'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>',
|
||||||
|
'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>',
|
||||||
|
'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>',
|
||||||
|
);
|
||||||
|
|
||||||
|
return $fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 ) {
|
||||||
|
$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 object $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',
|
||||||
|
@ -76,10 +86,10 @@ if ( ! function_exists( 'understrap_theme_customize_register' ) ) {
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$wp_customize->add_setting( 'understrap_container_type', array(
|
$wp_customize->add_setting( 'understrap_container_type', array(
|
||||||
'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(
|
||||||
|
@ -100,10 +110,10 @@ if ( ! function_exists( 'understrap_theme_customize_register' ) ) {
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$wp_customize->add_setting( 'understrap_sidebar_position', array(
|
$wp_customize->add_setting( 'understrap_sidebar_position', array(
|
||||||
'default' => 'right',
|
'default' => 'right',
|
||||||
'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,12 +136,12 @@ 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',
|
||||||
'sanitize_callback' => 'esc_textarea',
|
'sanitize_callback' => 'esc_textarea',
|
||||||
'capability' => 'edit_theme_options',
|
'capability' => 'edit_theme_options',
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$wp_customize->add_control(
|
$wp_customize->add_control(
|
||||||
|
@ -138,12 +149,12 @@ 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',
|
||||||
'choices' => array(
|
'choices' => array(
|
||||||
'default' => __( 'Default', 'understrap' ),
|
'default' => __( 'Default', 'understrap' ),
|
||||||
'masonry' => __( 'Masonry', 'understrap' ),
|
'masonry' => __( 'Masonry', 'understrap' ),
|
||||||
),
|
),
|
||||||
'priority' => '30',
|
'priority' => '30',
|
||||||
|
@ -159,7 +170,8 @@ add_action( 'customize_register', 'understrap_theme_customize_register' );
|
||||||
*/
|
*/
|
||||||
if ( ! function_exists( 'understrap_customize_preview_js' ) ) {
|
if ( ! function_exists( 'understrap_customize_preview_js' ) ) {
|
||||||
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' );
|
||||||
|
|
Reference in New Issue