Making all function pluggable
This commit is contained in:
parent
b8a5f0cc5a
commit
ad03eb383a
|
@ -10,60 +10,64 @@
|
|||
*
|
||||
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
|
||||
*/
|
||||
function understrap_customize_register( $wp_customize ) {
|
||||
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
|
||||
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
|
||||
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
|
||||
if ( ! function_exists ( 'understrap_customize_register' ) ) {
|
||||
function understrap_customize_register( $wp_customize ) {
|
||||
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
|
||||
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
|
||||
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
|
||||
|
||||
}
|
||||
}
|
||||
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(
|
||||
'title' => __( 'Slider Settings', 'understrap' )
|
||||
) );
|
||||
$wp_customize->add_section( 'understrap_theme_slider_options', array(
|
||||
'title' => __( 'Slider Settings', 'understrap' )
|
||||
) );
|
||||
|
||||
$wp_customize->add_setting( 'understrap_theme_slider_count_setting', array(
|
||||
'default' => '1',
|
||||
'sanitize_callback' => 'absint'
|
||||
) );
|
||||
$wp_customize->add_setting( 'understrap_theme_slider_count_setting', array(
|
||||
'default' => '1',
|
||||
'sanitize_callback' => 'absint'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'understrap_theme_slider_count', array(
|
||||
'label' => __( 'Number of slides displaying at once', 'understrap' ),
|
||||
'section' => 'understrap_theme_slider_options',
|
||||
'type' => 'text',
|
||||
'settings' => 'understrap_theme_slider_count_setting'
|
||||
) );
|
||||
$wp_customize->add_control( 'understrap_theme_slider_count', array(
|
||||
'label' => __( 'Number of slides displaying at once', 'understrap' ),
|
||||
'section' => 'understrap_theme_slider_options',
|
||||
'type' => 'text',
|
||||
'settings' => 'understrap_theme_slider_count_setting'
|
||||
) );
|
||||
|
||||
$wp_customize->add_setting( 'understrap_theme_slider_time_setting', array(
|
||||
'default' => '5000',
|
||||
'sanitize_callback' => 'absint'
|
||||
) );
|
||||
$wp_customize->add_setting( 'understrap_theme_slider_time_setting', array(
|
||||
'default' => '5000',
|
||||
'sanitize_callback' => 'absint'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'understrap_theme_slider_time', array(
|
||||
'label' => __( 'Slider Time (in ms)', 'understrap' ),
|
||||
'section' => 'understrap_theme_slider_options',
|
||||
'type' => 'text',
|
||||
'settings' => 'understrap_theme_slider_time_setting'
|
||||
) );
|
||||
$wp_customize->add_control( 'understrap_theme_slider_time', array(
|
||||
'label' => __( 'Slider Time (in ms)', 'understrap' ),
|
||||
'section' => 'understrap_theme_slider_options',
|
||||
'type' => 'text',
|
||||
'settings' => 'understrap_theme_slider_time_setting'
|
||||
) );
|
||||
|
||||
$wp_customize->add_setting( 'understrap_theme_slider_loop_setting', array(
|
||||
'default' => 'true',
|
||||
'sanitize_callback' => 'esc_textarea'
|
||||
) );
|
||||
$wp_customize->add_setting( 'understrap_theme_slider_loop_setting', array(
|
||||
'default' => 'true',
|
||||
'sanitize_callback' => 'esc_textarea'
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( 'understrap_theme_loop', array(
|
||||
'label' => __( 'Loop Slider Content', 'understrap' ),
|
||||
'section' => 'understrap_theme_slider_options',
|
||||
'type' => 'radio',
|
||||
'choices' => array(
|
||||
'true' => 'yes',
|
||||
'false' => 'no',
|
||||
),
|
||||
'settings' => 'understrap_theme_slider_loop_setting'
|
||||
) );
|
||||
$wp_customize->add_control( 'understrap_theme_loop', array(
|
||||
'label' => __( 'Loop Slider Content', 'understrap' ),
|
||||
'section' => 'understrap_theme_slider_options',
|
||||
'type' => 'radio',
|
||||
'choices' => array(
|
||||
'true' => 'yes',
|
||||
'false' => 'no',
|
||||
),
|
||||
'settings' => 'understrap_theme_slider_loop_setting'
|
||||
) );
|
||||
|
||||
}
|
||||
}
|
||||
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.
|
||||
*/
|
||||
function understrap_customize_preview_js() {
|
||||
wp_enqueue_script( 'understrap_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20130508', true );
|
||||
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 );
|
||||
}
|
||||
}
|
||||
add_action( 'customize_preview_init', 'understrap_customize_preview_js' );
|
||||
|
|
|
@ -5,29 +5,31 @@
|
|||
* @package understrap
|
||||
*/
|
||||
|
||||
function understrap_scripts() {
|
||||
wp_enqueue_style( 'understrap-styles', get_stylesheet_directory_uri() . '/css/theme.min.css', array(), '0.4.9' );
|
||||
wp_enqueue_script( 'jquery' );
|
||||
wp_enqueue_script( 'understrap-scripts', get_template_directory_uri() . '/js/theme.min.js', array(), '0.4.9', true );
|
||||
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_script( 'jquery' );
|
||||
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' ) ) {
|
||||
wp_enqueue_script( 'comment-reply' );
|
||||
}
|
||||
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
|
||||
wp_enqueue_script( 'comment-reply' );
|
||||
}
|
||||
|
||||
// menu - vertical page association
|
||||
if ( is_page_template( 'page-templates/vertical-one-page.php' ) || is_home() || is_single() ) {
|
||||
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' ) ) );
|
||||
$home_url = home_url();
|
||||
$is_single = is_single();
|
||||
$vars = array(
|
||||
'pageForPosts' => $page_for_posts,
|
||||
'homeUrl' => $home_url,
|
||||
'isSingle' => $is_single
|
||||
);
|
||||
wp_localize_script( 'vertical-one-page', 'vars', $vars );
|
||||
// menu - vertical page association
|
||||
if ( is_page_template( 'page-templates/vertical-one-page.php' ) || is_home() || is_single() ) {
|
||||
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' ) ) );
|
||||
$home_url = home_url();
|
||||
$is_single = is_single();
|
||||
$vars = array(
|
||||
'pageForPosts' => $page_for_posts,
|
||||
'homeUrl' => $home_url,
|
||||
'isSingle' => $is_single
|
||||
);
|
||||
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' );
|
||||
|
@ -39,15 +41,17 @@ add_action( 'wp_enqueue_scripts', 'understrap_scripts' );
|
|||
if ( is_active_sidebar( 'hero' ) ):
|
||||
add_action( "wp_enqueue_scripts", "understrap_slider" );
|
||||
|
||||
function understrap_slider() {
|
||||
if ( is_front_page() ) {
|
||||
$data = array(
|
||||
"timeout" => intval( get_theme_mod( 'understrap_theme_slider_time_setting', 5000 ) ),
|
||||
"items" => intval( get_theme_mod( 'understrap_theme_slider_count_setting', 1 ) )
|
||||
);
|
||||
if ( ! function_exists ( 'understrap_slider' ) ) {
|
||||
function understrap_slider() {
|
||||
if ( is_front_page() ) {
|
||||
$data = array(
|
||||
"timeout" => intval( get_theme_mod( 'understrap_theme_slider_time_setting', 5000 ) ),
|
||||
"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_localize_script( "understrap-slider-script", "understrap_slider_variables", $data );
|
||||
wp_enqueue_script( "understrap-slider-script", get_stylesheet_directory_uri() . '/js/slider_settings.js', array(), '0.4.9' );
|
||||
wp_localize_script( "understrap-slider-script", "understrap_slider_variables", $data );
|
||||
}
|
||||
}
|
||||
}
|
||||
endif;
|
||||
|
|
|
@ -12,37 +12,46 @@
|
|||
* @param array $classes Classes for the body element.
|
||||
* @return array
|
||||
*/
|
||||
function understrap_body_classes( $classes ) {
|
||||
// Adds a class of group-blog to blogs with more than 1 published author.
|
||||
if ( is_multi_author() ) {
|
||||
$classes[] = 'group-blog';
|
||||
|
||||
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.
|
||||
if ( is_multi_author() ) {
|
||||
$classes[] = 'group-blog';
|
||||
}
|
||||
// Adds a class of hfeed to non-singular pages.
|
||||
if ( ! is_singular() ) {
|
||||
$classes[] = 'hfeed';
|
||||
}
|
||||
return $classes;
|
||||
}
|
||||
// Adds a class of hfeed to non-singular pages.
|
||||
if ( ! is_singular() ) {
|
||||
$classes[] = 'hfeed';
|
||||
}
|
||||
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', 'adjust_body_class' );
|
||||
function adjust_body_class( $classes ) {
|
||||
|
||||
foreach ( $classes as $key => $value ) {
|
||||
if ( $value == 'tag' ) unset( $classes[ $key ] );
|
||||
}
|
||||
if ( ! function_exists ( 'adjust_body_class' ) ) {
|
||||
function adjust_body_class( $classes ) {
|
||||
|
||||
return $classes;
|
||||
foreach ( $classes as $key => $value ) {
|
||||
if ( $value == 'tag' ) unset( $classes[ $key ] );
|
||||
}
|
||||
|
||||
return $classes;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Filter custom logo with correct classes
|
||||
add_filter('get_custom_logo','change_logo_class');
|
||||
function change_logo_class($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);
|
||||
return $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-link"', 'class="navbar-brand custom-logo-link"', $html);
|
||||
return $html;
|
||||
}
|
||||
}
|
|
@ -12,28 +12,32 @@
|
|||
* See: https://jetpack.com/support/infinite-scroll/
|
||||
* See: https://jetpack.com/support/responsive-videos/
|
||||
*/
|
||||
function understrap_jetpack_setup() {
|
||||
// Add theme support for Infinite Scroll.
|
||||
add_theme_support( 'infinite-scroll', array(
|
||||
'container' => 'main',
|
||||
'render' => 'understrap_infinite_scroll_render',
|
||||
'footer' => 'wrapper-footer',
|
||||
) );
|
||||
// Add theme support for Responsive Videos.
|
||||
add_theme_support( 'jetpack-responsive-videos' );
|
||||
if ( ! function_exists ( 'understrap_jetpack_setup' ) ) {
|
||||
function understrap_jetpack_setup() {
|
||||
// Add theme support for Infinite Scroll.
|
||||
add_theme_support( 'infinite-scroll', array(
|
||||
'container' => 'main',
|
||||
'render' => 'understrap_infinite_scroll_render',
|
||||
'footer' => 'wrapper-footer',
|
||||
) );
|
||||
// Add theme support for Responsive Videos.
|
||||
add_theme_support( 'jetpack-responsive-videos' );
|
||||
}
|
||||
}
|
||||
add_action( 'after_setup_theme', 'understrap_jetpack_setup' );
|
||||
/**
|
||||
* Custom render function for Infinite Scroll.
|
||||
*/
|
||||
function understrap_infinite_scroll_render() {
|
||||
while ( have_posts() ) {
|
||||
the_post();
|
||||
if ( is_search() ) :
|
||||
get_template_part( 'loop-templates/content', 'search' );
|
||||
else :
|
||||
get_template_part( 'loop-templates/content', get_post_format() );
|
||||
endif;
|
||||
if ( ! function_exists ( 'understrap_infinite_scroll_render' ) ) {
|
||||
function understrap_infinite_scroll_render() {
|
||||
while ( have_posts() ) {
|
||||
the_post();
|
||||
if ( is_search() ) :
|
||||
get_template_part( 'loop-templates/content', 'search' );
|
||||
else :
|
||||
get_template_part( 'loop-templates/content', get_post_format() );
|
||||
endif;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -89,15 +89,18 @@ add_action( 'after_setup_theme', 'understrap_setup' );
|
|||
}
|
||||
add_filter( 'excerpt_more', 'new_excerpt_more' );*/
|
||||
/* Removes the ... from the excerpt read more link */
|
||||
function custom_excerpt_more( $more ) {
|
||||
return '';
|
||||
if ( ! function_exists ( 'custom_excerpt_more' ) ) {
|
||||
function custom_excerpt_more( $more ) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
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' ) ) {
|
||||
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');
|
||||
|
|
|
@ -5,46 +5,48 @@
|
|||
*
|
||||
* @package understrap
|
||||
*/
|
||||
function understrap_widgets_init() {
|
||||
register_sidebar( array(
|
||||
'name' => __( 'Sidebar', 'understrap' ),
|
||||
'id' => 'sidebar-1',
|
||||
'description' => 'Sidebar widget area',
|
||||
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
|
||||
'after_widget' => '</aside>',
|
||||
'before_title' => '<h3 class="widget-title">',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
|
||||
register_sidebar( array(
|
||||
'name' => __( 'Hero Slider', 'understrap' ),
|
||||
'id' => 'hero',
|
||||
'description' => 'Hero slider area. Place two or more widgets here and they will slide!',
|
||||
'before_widget' => '<div class="item">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '',
|
||||
'after_title' => '',
|
||||
) );
|
||||
|
||||
register_sidebar( array(
|
||||
'name' => __( 'Hero Static', 'understrap' ),
|
||||
'id' => 'statichero',
|
||||
'description' => 'Static Hero widget. no slider functionallity',
|
||||
'before_widget' => '',
|
||||
'after_widget' => '',
|
||||
'before_title' => '',
|
||||
'after_title' => '',
|
||||
) );
|
||||
if ( ! function_exists ( 'understrap_widgets_init' ) ) {
|
||||
function understrap_widgets_init() {
|
||||
register_sidebar( array(
|
||||
'name' => __( 'Sidebar', 'understrap' ),
|
||||
'id' => 'sidebar-1',
|
||||
'description' => 'Sidebar widget area',
|
||||
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
|
||||
'after_widget' => '</aside>',
|
||||
'before_title' => '<h3 class="widget-title">',
|
||||
'after_title' => '</h3>',
|
||||
) );
|
||||
|
||||
register_sidebar( array(
|
||||
'name' => __( 'Footer Full', 'understrap' ),
|
||||
'id' => 'footerfull',
|
||||
'description' => 'Widget area below main content and above footer',
|
||||
'before_widget' => '',
|
||||
'after_widget' => '',
|
||||
'before_title' => '',
|
||||
'after_title' => '',
|
||||
) );
|
||||
'name' => __( 'Hero Slider', 'understrap' ),
|
||||
'id' => 'hero',
|
||||
'description' => 'Hero slider area. Place two or more widgets here and they will slide!',
|
||||
'before_widget' => '<div class="item">',
|
||||
'after_widget' => '</div>',
|
||||
'before_title' => '',
|
||||
'after_title' => '',
|
||||
) );
|
||||
|
||||
register_sidebar( array(
|
||||
'name' => __( 'Hero Static', 'understrap' ),
|
||||
'id' => 'statichero',
|
||||
'description' => 'Static Hero widget. no slider functionallity',
|
||||
'before_widget' => '',
|
||||
'after_widget' => '',
|
||||
'before_title' => '',
|
||||
'after_title' => '',
|
||||
) );
|
||||
|
||||
register_sidebar( array(
|
||||
'name' => __( 'Footer Full', 'understrap' ),
|
||||
'id' => 'footerfull',
|
||||
'description' => 'Widget area below main content and above footer',
|
||||
'before_widget' => '',
|
||||
'after_widget' => '',
|
||||
'before_title' => '',
|
||||
'after_title' => '',
|
||||
) );
|
||||
|
||||
}
|
||||
}
|
||||
add_action( 'widgets_init', 'understrap_widgets_init' );
|
|
@ -7,6 +7,8 @@
|
|||
*/
|
||||
|
||||
add_action( 'after_setup_theme', 'woocommerce_support' );
|
||||
function woocommerce_support() {
|
||||
add_theme_support( 'woocommerce' );
|
||||
if ( ! function_exists ( 'woocommerce_support' ) ) {
|
||||
function woocommerce_support() {
|
||||
add_theme_support( 'woocommerce' );
|
||||
}
|
||||
}
|
|
@ -12,18 +12,20 @@
|
|||
*
|
||||
* @global array $themecolors
|
||||
*/
|
||||
function understrap_wpcom_setup() {
|
||||
global $themecolors;
|
||||
if ( ! function_exists ( 'understrap_wpcom_setup' ) ) {
|
||||
function understrap_wpcom_setup() {
|
||||
global $themecolors;
|
||||
|
||||
// Set theme colors for third party services.
|
||||
if ( ! isset( $themecolors ) ) {
|
||||
$themecolors = array(
|
||||
'bg' => '',
|
||||
'border' => '',
|
||||
'text' => '',
|
||||
'link' => '',
|
||||
'url' => '',
|
||||
);
|
||||
// Set theme colors for third party services.
|
||||
if ( ! isset( $themecolors ) ) {
|
||||
$themecolors = array(
|
||||
'bg' => '',
|
||||
'border' => '',
|
||||
'text' => '',
|
||||
'link' => '',
|
||||
'url' => '',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
add_action( 'after_setup_theme', 'understrap_wpcom_setup' );
|
||||
|
|
Reference in New Issue