Making all function pluggable
This commit is contained in:
parent
b8a5f0cc5a
commit
ad03eb383a
|
@ -10,15 +10,18 @@
|
||||||
*
|
*
|
||||||
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
|
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
|
||||||
*/
|
*/
|
||||||
function understrap_customize_register( $wp_customize ) {
|
if ( ! function_exists ( 'understrap_customize_register' ) ) {
|
||||||
|
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';
|
||||||
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
|
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
add_action( 'customize_register', 'understrap_customize_register' );
|
add_action( 'customize_register', 'understrap_customize_register' );
|
||||||
|
|
||||||
function understrap_theme_customize_register( $wp_customize ) {
|
if ( ! function_exists ( 'understrap_theme_customize_register' ) ) {
|
||||||
|
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' )
|
||||||
|
@ -64,6 +67,7 @@ function understrap_theme_customize_register( $wp_customize ) {
|
||||||
'settings' => 'understrap_theme_slider_loop_setting'
|
'settings' => 'understrap_theme_slider_loop_setting'
|
||||||
) );
|
) );
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
add_action( 'customize_register', 'understrap_theme_customize_register' );
|
add_action( 'customize_register', 'understrap_theme_customize_register' );
|
||||||
|
|
||||||
|
@ -72,7 +76,9 @@ 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.
|
||||||
*/
|
*/
|
||||||
function understrap_customize_preview_js() {
|
if ( ! function_exists ( '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' );
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
* @package understrap
|
* @package understrap
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function understrap_scripts() {
|
if ( ! function_exists ( '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 );
|
||||||
|
@ -28,6 +29,7 @@ function understrap_scripts() {
|
||||||
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action( 'wp_enqueue_scripts', 'understrap_scripts' );
|
add_action( 'wp_enqueue_scripts', 'understrap_scripts' );
|
||||||
|
@ -39,6 +41,7 @@ add_action( 'wp_enqueue_scripts', 'understrap_scripts' );
|
||||||
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' ) ) {
|
||||||
function understrap_slider() {
|
function understrap_slider() {
|
||||||
if ( is_front_page() ) {
|
if ( is_front_page() ) {
|
||||||
$data = array(
|
$data = array(
|
||||||
|
@ -50,5 +53,6 @@ if ( is_active_sidebar( 'hero' ) ):
|
||||||
wp_localize_script( "understrap-slider-script", "understrap_slider_variables", $data );
|
wp_localize_script( "understrap-slider-script", "understrap_slider_variables", $data );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,9 @@
|
||||||
* @param array $classes Classes for the body element.
|
* @param array $classes Classes for the body element.
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function understrap_body_classes( $classes ) {
|
|
||||||
|
if ( ! function_exists ( 'understrap_body_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() ) {
|
||||||
$classes[] = 'group-blog';
|
$classes[] = 'group-blog';
|
||||||
|
@ -22,13 +24,16 @@ function understrap_body_classes( $classes ) {
|
||||||
$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' );
|
||||||
function adjust_body_class( $classes ) {
|
|
||||||
|
if ( ! function_exists ( 'adjust_body_class' ) ) {
|
||||||
|
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 ] );
|
||||||
|
@ -36,13 +41,17 @@ function adjust_body_class( $classes ) {
|
||||||
|
|
||||||
return $classes;
|
return $classes;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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');
|
||||||
function change_logo_class($html)
|
|
||||||
{
|
if ( ! function_exists ( 'change_logo_class' ) ) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -12,7 +12,8 @@
|
||||||
* 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/
|
||||||
*/
|
*/
|
||||||
function understrap_jetpack_setup() {
|
if ( ! function_exists ( '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(
|
||||||
'container' => 'main',
|
'container' => 'main',
|
||||||
|
@ -21,12 +22,14 @@ function understrap_jetpack_setup() {
|
||||||
) );
|
) );
|
||||||
// Add theme support for Responsive Videos.
|
// Add theme support for Responsive Videos.
|
||||||
add_theme_support( 'jetpack-responsive-videos' );
|
add_theme_support( 'jetpack-responsive-videos' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
add_action( 'after_setup_theme', 'understrap_jetpack_setup' );
|
add_action( 'after_setup_theme', 'understrap_jetpack_setup' );
|
||||||
/**
|
/**
|
||||||
* Custom render function for Infinite Scroll.
|
* Custom render function for Infinite Scroll.
|
||||||
*/
|
*/
|
||||||
function understrap_infinite_scroll_render() {
|
if ( ! function_exists ( 'understrap_infinite_scroll_render' ) ) {
|
||||||
|
function understrap_infinite_scroll_render() {
|
||||||
while ( have_posts() ) {
|
while ( have_posts() ) {
|
||||||
the_post();
|
the_post();
|
||||||
if ( is_search() ) :
|
if ( is_search() ) :
|
||||||
|
@ -35,5 +38,6 @@ function understrap_infinite_scroll_render() {
|
||||||
get_template_part( 'loop-templates/content', get_post_format() );
|
get_template_part( 'loop-templates/content', get_post_format() );
|
||||||
endif;
|
endif;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,15 +89,18 @@ add_action( 'after_setup_theme', 'understrap_setup' );
|
||||||
}
|
}
|
||||||
add_filter( 'excerpt_more', 'new_excerpt_more' );*/
|
add_filter( 'excerpt_more', 'new_excerpt_more' );*/
|
||||||
/* Removes the ... from the excerpt read more link */
|
/* Removes the ... from the excerpt read more link */
|
||||||
function custom_excerpt_more( $more ) {
|
if ( ! function_exists ( 'custom_excerpt_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 */
|
/* Adds a custom read more link to all excerpts, manually or automatically generated */
|
||||||
|
if ( ! function_exists ( 'all_excerpts_get_more_link' ) ) {
|
||||||
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');
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
*
|
*
|
||||||
* @package understrap
|
* @package understrap
|
||||||
*/
|
*/
|
||||||
function understrap_widgets_init() {
|
if ( ! function_exists ( 'understrap_widgets_init' ) ) {
|
||||||
|
function understrap_widgets_init() {
|
||||||
register_sidebar( array(
|
register_sidebar( array(
|
||||||
'name' => __( 'Sidebar', 'understrap' ),
|
'name' => __( 'Sidebar', 'understrap' ),
|
||||||
'id' => 'sidebar-1',
|
'id' => 'sidebar-1',
|
||||||
|
@ -46,5 +47,6 @@ function understrap_widgets_init() {
|
||||||
'after_title' => '',
|
'after_title' => '',
|
||||||
) );
|
) );
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
add_action( 'widgets_init', 'understrap_widgets_init' );
|
add_action( 'widgets_init', 'understrap_widgets_init' );
|
|
@ -7,6 +7,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
add_action( 'after_setup_theme', 'woocommerce_support' );
|
add_action( 'after_setup_theme', 'woocommerce_support' );
|
||||||
function woocommerce_support() {
|
if ( ! function_exists ( 'woocommerce_support' ) ) {
|
||||||
|
function woocommerce_support() {
|
||||||
add_theme_support( 'woocommerce' );
|
add_theme_support( 'woocommerce' );
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -12,7 +12,8 @@
|
||||||
*
|
*
|
||||||
* @global array $themecolors
|
* @global array $themecolors
|
||||||
*/
|
*/
|
||||||
function understrap_wpcom_setup() {
|
if ( ! function_exists ( 'understrap_wpcom_setup' ) ) {
|
||||||
|
function understrap_wpcom_setup() {
|
||||||
global $themecolors;
|
global $themecolors;
|
||||||
|
|
||||||
// Set theme colors for third party services.
|
// Set theme colors for third party services.
|
||||||
|
@ -25,5 +26,6 @@ function understrap_wpcom_setup() {
|
||||||
'url' => '',
|
'url' => '',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
add_action( 'after_setup_theme', 'understrap_wpcom_setup' );
|
add_action( 'after_setup_theme', 'understrap_wpcom_setup' );
|
||||||
|
|
Reference in New Issue