Merge pull request #619 from alex-wright-net/master-pluggable-functions
Apply pluggable function wrappers - Thx @axlright and the rest of you! I merge this and we should test it all together.
This commit is contained in:
commit
664fa834c4
|
@ -5,7 +5,10 @@
|
|||
* @package understrap
|
||||
*/
|
||||
|
||||
function understrap_custom_header_setup() {
|
||||
add_action( 'after_setup_theme', 'understrap_custom_header_setup' );
|
||||
|
||||
if ( ! function_exists ( 'understrap_custom_header_setup' ) ) {
|
||||
function understrap_custom_header_setup() {
|
||||
|
||||
/**
|
||||
* Filter UnderStrap custom-header support arguments.
|
||||
|
@ -38,5 +41,5 @@ function understrap_custom_header_setup() {
|
|||
'description' => __( 'Default Header Image', 'understrap' ),
|
||||
),
|
||||
) );
|
||||
}
|
||||
}
|
||||
add_action( 'after_setup_theme', 'understrap_custom_header_setup' );
|
||||
|
|
|
@ -8,23 +8,31 @@
|
|||
/**
|
||||
* Registers an editor stylesheet for the theme.
|
||||
*/
|
||||
function understrap_wpdocs_theme_add_editor_styles() {
|
||||
add_editor_style( 'css/custom-editor-style.min.css' );
|
||||
}
|
||||
|
||||
add_action( 'admin_init', 'understrap_wpdocs_theme_add_editor_styles' );
|
||||
|
||||
if ( ! function_exists ( 'understrap_wpdocs_theme_add_editor_styles' ) ) {
|
||||
function understrap_wpdocs_theme_add_editor_styles() {
|
||||
add_editor_style( 'css/custom-editor-style.min.css' );
|
||||
}
|
||||
}
|
||||
|
||||
// Add TinyMCE style formats.
|
||||
add_filter( 'mce_buttons_2', 'understrap_tiny_mce_style_formats' );
|
||||
|
||||
function understrap_tiny_mce_style_formats( $styles ) {
|
||||
if ( ! function_exists ( 'understrap_tiny_mce_style_formats' ) ) {
|
||||
function understrap_tiny_mce_style_formats( $styles ) {
|
||||
|
||||
array_unshift( $styles, 'styleselect' );
|
||||
return $styles;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
add_filter( 'tiny_mce_before_init', 'understrap_tiny_mce_before_init' );
|
||||
|
||||
function understrap_tiny_mce_before_init( $settings ) {
|
||||
if ( ! function_exists ( 'understrap_tiny_mce_before_init' ) ) {
|
||||
function understrap_tiny_mce_before_init( $settings ) {
|
||||
|
||||
$style_formats = array(
|
||||
array(
|
||||
|
@ -62,4 +70,5 @@ function understrap_tiny_mce_before_init( $settings ) {
|
|||
|
||||
$settings['style_formats'] = json_encode( $style_formats );
|
||||
return $settings;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
* @package understrap
|
||||
*/
|
||||
|
||||
add_filter( 'body_class', 'understrap_body_classes' );
|
||||
|
||||
if ( ! function_exists( 'understrap_body_classes' ) ) {
|
||||
/**
|
||||
* Adds custom classes to the array of body classes.
|
||||
|
@ -28,7 +30,6 @@ if ( ! function_exists( 'understrap_body_classes' ) ) {
|
|||
return $classes;
|
||||
}
|
||||
}
|
||||
add_filter( 'body_class', 'understrap_body_classes' );
|
||||
|
||||
// Removes tag class from the body_class array to avoid Bootstrap markup styling issues.
|
||||
add_filter( 'body_class', 'understrap_adjust_body_class' );
|
||||
|
@ -78,8 +79,8 @@ if ( ! function_exists( 'understrap_change_logo_class' ) ) {
|
|||
/**
|
||||
* Display navigation to next/previous post when applicable.
|
||||
*/
|
||||
if ( ! function_exists( 'understrap_post_nav' ) ) :
|
||||
|
||||
if ( ! function_exists ( 'understrap_post_nav' ) ) {
|
||||
function understrap_post_nav() {
|
||||
// Don't print empty markup if there's nowhere to navigate.
|
||||
$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
|
||||
|
@ -106,4 +107,4 @@ if ( ! function_exists( 'understrap_post_nav' ) ) :
|
|||
|
||||
<?php
|
||||
}
|
||||
endif;
|
||||
}
|
|
@ -13,7 +13,11 @@
|
|||
* See: https://jetpack.me/support/infinite-scroll/
|
||||
* See: https://jetpack.me/support/responsive-videos/
|
||||
*/
|
||||
function understrap_components_jetpack_setup() {
|
||||
|
||||
add_action( 'after_setup_theme', 'understrap_components_jetpack_setup' );
|
||||
|
||||
if ( ! function_exists ( 'understrap_components_jetpack_setup' ) ) {
|
||||
function understrap_components_jetpack_setup() {
|
||||
// Add theme support for Infinite Scroll.
|
||||
add_theme_support( 'infinite-scroll', array(
|
||||
'container' => 'main',
|
||||
|
@ -27,13 +31,16 @@ function understrap_components_jetpack_setup() {
|
|||
// Add theme support for Social Menus
|
||||
add_theme_support( 'jetpack-social-menu' );
|
||||
|
||||
}
|
||||
}
|
||||
add_action( 'after_setup_theme', 'understrap_components_jetpack_setup' );
|
||||
|
||||
|
||||
/**
|
||||
* Custom render function for Infinite Scroll.
|
||||
*/
|
||||
function understrap_components_infinite_scroll_render() {
|
||||
|
||||
if ( ! function_exists ( 'understrap_components_infinite_scroll_render' ) ) {
|
||||
function understrap_components_infinite_scroll_render() {
|
||||
while ( have_posts() ) {
|
||||
the_post();
|
||||
if ( is_search() ) :
|
||||
|
@ -42,12 +49,15 @@ function understrap_components_infinite_scroll_render() {
|
|||
get_template_part( 'loop-templates/content', get_post_format() );
|
||||
endif;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function understrap_components_social_menu() {
|
||||
if ( ! function_exists ( 'understrap_components_social_menu' ) ) {
|
||||
function understrap_components_social_menu() {
|
||||
if ( ! function_exists( 'jetpack_social_menu' ) ) {
|
||||
return;
|
||||
} else {
|
||||
jetpack_social_menu();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
* @package understrap
|
||||
*/
|
||||
|
||||
if ( ! function_exists( 'understrap_pagination' ) ) :
|
||||
if ( ! function_exists ( 'understrap_pagination' ) ) {
|
||||
function understrap_pagination($args = [], $class = 'pagination') {
|
||||
|
||||
if ($GLOBALS['wp_query']->max_num_pages <= 1) return;
|
||||
|
@ -38,7 +38,7 @@
|
|||
<?php
|
||||
$i = 1;
|
||||
foreach ( $links as $link ) { ?>
|
||||
<li class="page-item <?php if ($i == $args['current']) { echo active; }; ?>">
|
||||
<li class="page-item <?php if ($i == $args['current']) { echo 'active'; }; ?>">
|
||||
<?php echo str_replace( 'page-numbers', 'page-link', $link ); ?>
|
||||
</li>
|
||||
|
||||
|
@ -54,5 +54,4 @@
|
|||
</nav>
|
||||
<?php
|
||||
}
|
||||
endif;
|
||||
?>
|
||||
}
|
|
@ -11,7 +11,9 @@ if ( ! isset( $content_width ) ) {
|
|||
$content_width = 640; /* pixels */
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'understrap_setup' ) ) :
|
||||
add_action( 'after_setup_theme', 'understrap_setup' );
|
||||
|
||||
if ( ! function_exists ( 'understrap_setup' ) ) {
|
||||
/**
|
||||
* Sets up theme defaults and registers support for various WordPress features.
|
||||
*
|
||||
|
@ -91,8 +93,10 @@ if ( ! function_exists( 'understrap_setup' ) ) :
|
|||
understrap_setup_theme_default_settings();
|
||||
|
||||
}
|
||||
endif; // understrap_setup.
|
||||
add_action( 'after_setup_theme', 'understrap_setup' );
|
||||
}
|
||||
|
||||
|
||||
add_filter( 'excerpt_more', 'understrap_custom_excerpt_more' );
|
||||
|
||||
if ( ! function_exists( 'understrap_custom_excerpt_more' ) ) {
|
||||
/**
|
||||
|
@ -106,7 +110,8 @@ if ( ! function_exists( 'understrap_custom_excerpt_more' ) ) {
|
|||
return '';
|
||||
}
|
||||
}
|
||||
add_filter( 'excerpt_more', 'understrap_custom_excerpt_more' );
|
||||
|
||||
add_filter( 'wp_trim_excerpt', 'understrap_all_excerpts_get_more_link' );
|
||||
|
||||
if ( ! function_exists( 'understrap_all_excerpts_get_more_link' ) ) {
|
||||
/**
|
||||
|
@ -122,4 +127,3 @@ if ( ! function_exists( 'understrap_all_excerpts_get_more_link' ) ) {
|
|||
'understrap' ) . '</a></p>';
|
||||
}
|
||||
}
|
||||
add_filter( 'wp_trim_excerpt', 'understrap_all_excerpts_get_more_link' );
|
||||
|
|
|
@ -7,11 +7,12 @@
|
|||
* @package understrap
|
||||
*/
|
||||
|
||||
if ( ! function_exists( 'understrap_posted_on' ) ) :
|
||||
|
||||
/**
|
||||
* Prints HTML with meta information for the current post-date/time and author.
|
||||
*/
|
||||
function understrap_posted_on() {
|
||||
if ( ! function_exists ( 'understrap_posted_on' ) ) {
|
||||
function understrap_posted_on() {
|
||||
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
|
||||
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"> (%4$s) </time>';
|
||||
|
@ -31,14 +32,15 @@ function understrap_posted_on() {
|
|||
'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>'
|
||||
);
|
||||
echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK.
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists( 'understrap_entry_footer' ) ) :
|
||||
|
||||
/**
|
||||
* Prints HTML with meta information for the categories, tags and comments.
|
||||
*/
|
||||
function understrap_entry_footer() {
|
||||
if ( ! function_exists ( 'understrap_entry_footer' ) ) {
|
||||
function understrap_entry_footer() {
|
||||
// Hide category and tag text for pages.
|
||||
if ( 'post' === get_post_type() ) {
|
||||
/* translators: used between list items, there is a space after the comma */
|
||||
|
@ -66,15 +68,17 @@ function understrap_entry_footer() {
|
|||
'<span class="edit-link">',
|
||||
'</span>'
|
||||
);
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if a blog has more than 1 category.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function understrap_categorized_blog() {
|
||||
if ( ! function_exists ( 'understrap_categorized_blog' ) ) {
|
||||
function understrap_categorized_blog() {
|
||||
if ( false === ( $all_the_cool_cats = get_transient( 'understrap_categories' ) ) ) {
|
||||
// Create an array of all the categories that are attached to posts.
|
||||
$all_the_cool_cats = get_categories( array(
|
||||
|
@ -94,18 +98,22 @@ function understrap_categorized_blog() {
|
|||
// This blog has only 1 category so components_categorized_blog should return false.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Flush out the transients used in understrap_categorized_blog.
|
||||
*/
|
||||
function understrap_category_transient_flusher() {
|
||||
add_action( 'edit_category', 'understrap_category_transient_flusher' );
|
||||
add_action( 'save_post', 'understrap_category_transient_flusher' );
|
||||
|
||||
if ( ! function_exists ( 'understrap_category_transient_flusher' ) ) {
|
||||
function understrap_category_transient_flusher() {
|
||||
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
||||
return;
|
||||
}
|
||||
// Like, beat it. Dig?
|
||||
delete_transient( 'understrap_categories' );
|
||||
}
|
||||
}
|
||||
add_action( 'edit_category', 'understrap_category_transient_flusher' );
|
||||
add_action( 'save_post', 'understrap_category_transient_flusher' );
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
if ( ! function_exists( 'understrap_setup_theme_default_settings' ) ) :
|
||||
if ( ! function_exists ( 'understrap_setup_theme_default_settings' ) ) {
|
||||
function understrap_setup_theme_default_settings() {
|
||||
|
||||
// check if settings are set, if not set defaults.
|
||||
|
@ -29,4 +29,4 @@ if ( ! function_exists( 'understrap_setup_theme_default_settings' ) ) :
|
|||
set_theme_mod( 'understrap_container_type', 'container' );
|
||||
}
|
||||
}
|
||||
endif;
|
||||
}
|
|
@ -44,6 +44,8 @@ if ( ! function_exists( 'understrap_slbd_count_widgets' ) ) {
|
|||
}
|
||||
}
|
||||
|
||||
add_action( 'widgets_init', 'understrap_widgets_init' );
|
||||
|
||||
if ( ! function_exists( 'understrap_widgets_init' ) ) {
|
||||
/**
|
||||
* Initializes themes widgets.
|
||||
|
@ -101,5 +103,3 @@ if ( ! function_exists( 'understrap_widgets_init' ) ) {
|
|||
|
||||
}
|
||||
} // endif function_exists( 'understrap_widgets_init' ).
|
||||
add_action( 'widgets_init', 'understrap_widgets_init' );
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
*
|
||||
* @package understrap
|
||||
*/
|
||||
|
||||
|
||||
add_action( 'after_setup_theme', 'understrap_woocommerce_support' );
|
||||
if ( ! function_exists( 'understrap_woocommerce_support' ) ) {
|
||||
/**
|
||||
|
@ -22,6 +24,7 @@ if ( ! function_exists( 'understrap_woocommerce_support' ) ) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* First unhook the WooCommerce wrappers
|
||||
*/
|
||||
|
@ -54,6 +57,7 @@ function understrap_woocommerce_wrapper_end() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Filter hook function monkey patching form classes
|
||||
* Author: Adriano Monecchi http://stackoverflow.com/a/36724593/307826
|
||||
|
@ -64,7 +68,8 @@ function understrap_woocommerce_wrapper_end() {
|
|||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function understrap_wc_form_field_args( $args, $key, $value = null ) {
|
||||
if ( ! function_exists ( 'understrap_wc_form_field_args' ) ) {
|
||||
function understrap_wc_form_field_args( $args, $key, $value = null ) {
|
||||
// Start field type switch case.
|
||||
switch ( $args['type'] ) {
|
||||
/* Targets all select input type elements, except the country and state select input types */
|
||||
|
@ -130,6 +135,7 @@ function understrap_wc_form_field_args( $args, $key, $value = null ) {
|
|||
break;
|
||||
} // end switch ($args).
|
||||
return $args;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,7 +143,10 @@ function understrap_wc_form_field_args( $args, $key, $value = null ) {
|
|||
* Change loop add-to-cart button class to Bootstrap
|
||||
*/
|
||||
add_filter( 'woocommerce_loop_add_to_cart_args', 'understrap_woocommerce_add_to_cart_args', 10, 2 );
|
||||
function understrap_woocommerce_add_to_cart_args( $args, $product ) {
|
||||
|
||||
if ( ! function_exists ( 'understrap_woocommerce_add_to_cart_args' ) ) {
|
||||
function understrap_woocommerce_add_to_cart_args( $args, $product ) {
|
||||
$args['class'] = str_replace('button','btn btn-outline-primary', 'button');
|
||||
return $args;
|
||||
}
|
||||
}
|
|
@ -12,7 +12,10 @@
|
|||
*
|
||||
* @global array $themecolors
|
||||
*/
|
||||
function understrap_wpcom_setup() {
|
||||
add_action( 'after_setup_theme', 'understrap_wpcom_setup' );
|
||||
|
||||
if ( ! function_exists ( 'understrap_wpcom_setup' ) ) {
|
||||
function understrap_wpcom_setup() {
|
||||
global $themecolors;
|
||||
|
||||
// Set theme colors for third party services.
|
||||
|
@ -28,13 +31,17 @@ function understrap_wpcom_setup() {
|
|||
|
||||
/* Add WP.com print styles */
|
||||
add_theme_support( 'print-styles' );
|
||||
}
|
||||
}
|
||||
add_action( 'after_setup_theme', 'understrap_wpcom_setup' );
|
||||
|
||||
|
||||
/*
|
||||
* WordPress.com-specific styles
|
||||
*/
|
||||
function understrap_wpcom_styles() {
|
||||
wp_enqueue_style( 'understrap-wpcom', get_template_directory_uri() . '/inc/style-wpcom.css', '20160411' );
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'understrap_wpcom_styles' );
|
||||
|
||||
if ( ! function_exists ( 'understrap_wpcom_styles' ) ) {
|
||||
function understrap_wpcom_styles() {
|
||||
wp_enqueue_style( 'understrap-wpcom', get_template_directory_uri() . '/inc/style-wpcom.css', '20160411' );
|
||||
}
|
||||
}
|
Reference in New Issue