Merge branch 'master' into deps

This commit is contained in:
IanDelMar 2020-04-28 14:33:38 +02:00 committed by GitHub
commit 0860210d27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
61 changed files with 671 additions and 499 deletions

View File

@ -43,8 +43,8 @@ People *love* thorough bug reports. I'm not even kidding.
## Use a Consistent Coding Style ## Use a Consistent Coding Style
* 2 spaces for indentation rather than tabs * Stick to the [WordPress Coding Standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/)
* Use ./.editorconfig if your editor supports it * Use [./.editorconfig](https://github.com/understrap/understrap/blob/master/.editorconfig) if your editor supports it
<!-- * You can try running `npm run lint` for style unification --> <!-- * You can try running `npm run lint` for style unification -->
## License ## License

View File

@ -86,4 +86,5 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #error-404-wrapper --> </div><!-- #error-404-wrapper -->
<?php get_footer(); <?php
get_footer();

View File

@ -26,19 +26,19 @@ $container = get_theme_mod( 'understrap_container_type' );
<main class="site-main" id="main"> <main class="site-main" id="main">
<?php if ( have_posts() ) : ?> <?php
if ( have_posts() ) {
?>
<header class="page-header"> <header class="page-header">
<?php <?php
the_archive_title( '<h1 class="page-title">', '</h1>' ); the_archive_title( '<h1 class="page-title">', '</h1>' );
the_archive_description( '<div class="taxonomy-description">', '</div>' ); the_archive_description( '<div class="taxonomy-description">', '</div>' );
?> ?>
</header><!-- .page-header --> </header><!-- .page-header -->
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php <?php
// Start the loop.
while ( have_posts() ) {
the_post();
/* /*
* Include the Post-Format-specific template for the content. * Include the Post-Format-specific template for the content.
@ -46,23 +46,20 @@ $container = get_theme_mod( 'understrap_container_type' );
* called content-___.php (where ___ is the Post Format name) and that will be used instead. * called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/ */
get_template_part( 'loop-templates/content', get_post_format() ); get_template_part( 'loop-templates/content', get_post_format() );
}
} else {
get_template_part( 'loop-templates/content', 'none' );
}
?> ?>
<?php endwhile; ?>
<?php else : ?>
<?php get_template_part( 'loop-templates/content', 'none' ); ?>
<?php endif; ?>
</main><!-- #main --> </main><!-- #main -->
<!-- The pagination component --> <?php
<?php understrap_pagination(); ?> // Display the pagination component.
understrap_pagination();
<!-- Do the right sidebar check --> // Do the right sidebar check.
<?php get_template_part( 'global-templates/right-sidebar-check' ); ?> get_template_part( 'global-templates/right-sidebar-check' );
?>
</div><!-- .row --> </div><!-- .row -->
@ -70,4 +67,5 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #archive-wrapper --> </div><!-- #archive-wrapper -->
<?php get_footer(); <?php
get_footer();

View File

@ -28,8 +28,8 @@ $container = get_theme_mod( 'understrap_container_type' );
<header class="page-header author-header"> <header class="page-header author-header">
<?php <?php
if ( isset( $_GET['author_name'] ) ) { if ( get_query_var( 'author_name' ) ) {
$curauth = get_user_by( 'slug', $author_name ); $curauth = get_user_by( 'slug', get_query_var( 'author_name' ) );
} else { } else {
$curauth = get_userdata( intval( $author ) ); $curauth = get_userdata( intval( $author ) );
} }
@ -37,9 +37,11 @@ $container = get_theme_mod( 'understrap_container_type' );
<h1><?php echo esc_html__( 'About:', 'understrap' ) . ' ' . esc_html( $curauth->nickname ); ?></h1> <h1><?php echo esc_html__( 'About:', 'understrap' ) . ' ' . esc_html( $curauth->nickname ); ?></h1>
<?php if ( ! empty( $curauth->ID ) ) : ?> <?php
<?php echo get_avatar( $curauth->ID ); ?> if ( ! empty( $curauth->ID ) ) {
<?php endif; ?> echo get_avatar( $curauth->ID );
}
?>
<?php if ( ! empty( $curauth->user_url ) || ! empty( $curauth->user_description ) ) : ?> <?php if ( ! empty( $curauth->user_url ) || ! empty( $curauth->user_description ) ) : ?>
<dl> <dl>
@ -52,45 +54,39 @@ $container = get_theme_mod( 'understrap_container_type' );
<?php if ( ! empty( $curauth->user_description ) ) : ?> <?php if ( ! empty( $curauth->user_description ) ) : ?>
<dt><?php esc_html_e( 'Profile', 'understrap' ); ?></dt> <dt><?php esc_html_e( 'Profile', 'understrap' ); ?></dt>
<dd><?php esc_html_e( $curauth->user_description, 'understrap' ); ?></dd> <dd><?php echo esc_html( $curauth->user_description ); ?></dd>
<?php endif; ?> <?php endif; ?>
</dl> </dl>
<?php endif; ?> <?php endif; ?>
<h2><?php echo esc_html( 'Posts by', 'understrap' ) . ' ' . esc_html( $curauth->nickname ); ?>:</h2> <h2><?php echo esc_html__( 'Posts by', 'understrap' ) . ' ' . esc_html( $curauth->nickname ); ?>:</h2>
</header><!-- .page-header --> </header><!-- .page-header -->
<ul>
<!-- The Loop --> <!-- The Loop -->
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<li>
<?php <?php
if ( have_posts() ) {
echo '<ul>';
while ( have_posts() ) {
the_post();
echo '<li>';
printf( printf(
'<a rel="bookmark" href="%1$s" title="%2$s %3$s">%3$s</a>', '<a rel="bookmark" href="%1$s" title="%2$s %3$s">%3$s</a>',
esc_url( apply_filters( 'the_permalink', get_permalink( $post ), $post ) ), esc_url( apply_filters( 'the_permalink', get_permalink( $post ), $post ) ),
esc_attr( __( 'Permanent Link:', 'understrap' ) ), esc_attr( __( 'Permanent Link:', 'understrap' ) ),
the_title( '', '', false ) get_the_title()
); );
understrap_posted_on();
esc_html_e( 'in', 'understrap' );
the_category( '&' );
echo '</li>';
}
echo '</ul>';
} else {
get_template_part( 'loop-templates/content', 'none' );
}
?> ?>
<?php understrap_posted_on(); ?>
<?php esc_html_e( 'in', 'understrap' ); ?>
<?php the_category( '&' ); ?>
</li>
<?php endwhile; ?>
<?php else : ?>
<?php get_template_part( 'loop-templates/content', 'none' ); ?>
<?php endif; ?>
<!-- End Loop --> <!-- End Loop -->
</ul>
</main><!-- #main --> </main><!-- #main -->
<!-- The pagination component --> <!-- The pagination component -->
@ -105,4 +101,5 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #author-wrapper --> </div><!-- #author-wrapper -->
<?php get_footer(); <?php
get_footer();

View File

@ -20,7 +20,7 @@
"wptrt/wpthemereview": "^0.2" "wptrt/wpthemereview": "^0.2"
}, },
"scripts": { "scripts": {
"check-cs": ["@php ./vendor/squizlabs/php_codesniffer/bin/phpcs"], "check-cs": ["@php ./vendor/squizlabs/php_codesniffer/bin/phpcs -w"],
"fix-cs": ["@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf"] "fix-cs": ["@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf"]
}, },
"support": { "support": {

View File

@ -20,7 +20,7 @@ $understrap_includes = array(
'/customizer.php', // Customizer additions. '/customizer.php', // Customizer additions.
'/custom-comments.php', // Custom Comments file. '/custom-comments.php', // Custom Comments file.
'/jetpack.php', // Load Jetpack compatibility file. '/jetpack.php', // Load Jetpack compatibility file.
'/class-wp-bootstrap-navwalker.php', // Load custom WordPress nav walker. Trying to get deeper navigation? Check out: https://github.com/understrap/understrap/issues/567 '/class-wp-bootstrap-navwalker.php', // Load custom WordPress nav walker. Trying to get deeper navigation? Check out: https://github.com/understrap/understrap/issues/567.
'/woocommerce.php', // Load WooCommerce functions. '/woocommerce.php', // Load WooCommerce functions.
'/editor.php', // Load Editor functions. '/editor.php', // Load Editor functions.
'/deprecated.php', // Load deprecated functions. '/deprecated.php', // Load deprecated functions.

View File

@ -7,18 +7,19 @@
// Exit if accessed directly. // Exit if accessed directly.
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
?>
<?php if ( is_active_sidebar( 'hero' ) || is_active_sidebar( 'statichero' ) || is_active_sidebar( 'herocanvas' ) ) : ?> if ( is_active_sidebar( 'hero' ) || is_active_sidebar( 'statichero' ) || is_active_sidebar( 'herocanvas' ) ) :
?>
<div class="wrapper" id="wrapper-hero"> <div class="wrapper" id="wrapper-hero">
<?php get_template_part( 'sidebar-templates/sidebar', 'hero' ); ?> <?php
get_template_part( 'sidebar-templates/sidebar', 'hero' );
<?php get_template_part( 'sidebar-templates/sidebar', 'herocanvas' ); ?> get_template_part( 'sidebar-templates/sidebar', 'herocanvas' );
get_template_part( 'sidebar-templates/sidebar', 'statichero' );
<?php get_template_part( 'sidebar-templates/sidebar', 'statichero' ); ?> ?>
</div> </div>
<?php endif; <?php
endif;

View File

@ -9,10 +9,10 @@
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
$sidebar_pos = get_theme_mod( 'understrap_sidebar_position' ); $sidebar_pos = get_theme_mod( 'understrap_sidebar_position' );
if ( 'left' === $sidebar_pos || 'both' === $sidebar_pos ) {
get_template_part( 'sidebar-templates/sidebar', 'left' );
}
?> ?>
<?php if ( 'left' === $sidebar_pos || 'both' === $sidebar_pos ) : ?>
<?php get_template_part( 'sidebar-templates/sidebar', 'left' ); ?>
<?php endif; ?>
<div class="col-md content-area" id="primary"> <div class="col-md content-area" id="primary">

View File

@ -11,10 +11,9 @@ defined( 'ABSPATH' ) || exit;
</div><!-- #closing the primary container from /global-templates/left-sidebar-check.php --> </div><!-- #closing the primary container from /global-templates/left-sidebar-check.php -->
<?php $sidebar_pos = get_theme_mod( 'understrap_sidebar_position' ); ?> <?php
$sidebar_pos = get_theme_mod( 'understrap_sidebar_position' );
<?php if ( 'right' === $sidebar_pos || 'both' === $sidebar_pos ) : ?> if ( 'right' === $sidebar_pos || 'both' === $sidebar_pos ) {
get_template_part( 'sidebar-templates/sidebar', 'right' );
<?php get_template_part( 'sidebar-templates/sidebar', 'right' ); ?> }
<?php endif;

View File

@ -53,16 +53,20 @@ $container = get_theme_mod( 'understrap_container_type' );
<?php endif; ?> <?php endif; ?>
<?php } else { <?php
} else {
the_custom_logo(); the_custom_logo();
} ?><!-- end custom logo --> }
?>
<!-- end custom logo -->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="<?php esc_attr_e( 'Toggle navigation', 'understrap' ); ?>"> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="<?php esc_attr_e( 'Toggle navigation', 'understrap' ); ?>">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<!-- The WordPress Menu goes here --> <!-- The WordPress Menu goes here -->
<?php wp_nav_menu( <?php
wp_nav_menu(
array( array(
'theme_location' => 'primary', 'theme_location' => 'primary',
'container_class' => 'collapse navbar-collapse', 'container_class' => 'collapse navbar-collapse',
@ -73,7 +77,8 @@ $container = get_theme_mod( 'understrap_container_type' );
'depth' => 2, 'depth' => 2,
'walker' => new Understrap_WP_Bootstrap_Navwalker(), 'walker' => new Understrap_WP_Bootstrap_Navwalker(),
) )
); ?> );
?>
<?php if ( 'container' === $container ) : ?> <?php if ( 'container' === $container ) : ?>
</div><!-- .container --> </div><!-- .container -->
<?php endif; ?> <?php endif; ?>

View File

@ -182,7 +182,7 @@ if ( ! class_exists( 'Understrap_WP_Bootstrap_Navwalker' ) ) {
} }
$atts['target'] = ! empty( $item->target ) ? $item->target : ''; $atts['target'] = ! empty( $item->target ) ? $item->target : '';
if ( '_blank' === $item->target && empty( $item->xfn ) ) { // Thanks to LukaszJaro, see https://github.com/understrap/understrap/issues/973 if ( '_blank' === $item->target && empty( $item->xfn ) ) { // Thanks to LukaszJaro, see https://github.com/understrap/understrap/issues/973.
$atts['rel'] = 'noopener noreferrer'; $atts['rel'] = 'noopener noreferrer';
} else { } else {
$atts['rel'] = $item->xfn; $atts['rel'] = $item->xfn;
@ -381,7 +381,7 @@ if ( ! class_exists( 'Understrap_WP_Bootstrap_Navwalker' ) ) {
// if $args has 'echo' key and it's true echo, otherwise return. // if $args has 'echo' key and it's true echo, otherwise return.
if ( array_key_exists( 'echo', $args ) && $args['echo'] ) { if ( array_key_exists( 'echo', $args ) && $args['echo'] ) {
echo $fallback_output; // WPCS: XSS OK. echo $fallback_output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} else { } else {
return $fallback_output; return $fallback_output;
} }

View File

@ -11,6 +11,9 @@ defined( 'ABSPATH' ) || exit;
add_action( 'after_setup_theme', 'understrap_custom_header_setup' ); add_action( 'after_setup_theme', 'understrap_custom_header_setup' );
if ( ! function_exists( 'understrap_custom_header_setup' ) ) { if ( ! function_exists( 'understrap_custom_header_setup' ) ) {
/**
* Set up custom header feature.
*/
function understrap_custom_header_setup() { function understrap_custom_header_setup() {
/** /**

View File

@ -130,7 +130,7 @@ if ( ! function_exists( 'understrap_theme_customize_register' ) ) {
) )
); );
} }
} // endif function_exists( 'understrap_theme_customize_register' ). } // End of if function_exists( 'understrap_theme_customize_register' ).
add_action( 'customize_register', 'understrap_theme_customize_register' ); add_action( 'customize_register', 'understrap_theme_customize_register' );
/** /**

View File

@ -21,26 +21,26 @@ if ( ! function_exists( 'understrap_slbd_count_widgets' ) ) {
// to see if wp_convert_widget_settings() has made manipulations in memory. // to see if wp_convert_widget_settings() has made manipulations in memory.
global $_wp_sidebars_widgets; global $_wp_sidebars_widgets;
if ( empty( $_wp_sidebars_widgets ) ) : if ( empty( $_wp_sidebars_widgets ) ) :
$_wp_sidebars_widgets = get_option( 'sidebars_widgets', array() ); $_wp_sidebars_widgets = get_option( 'sidebars_widgets', array() ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
endif; endif;
$sidebars_widgets_count = $_wp_sidebars_widgets; $sidebars_widgets_count = $_wp_sidebars_widgets;
if ( isset( $sidebars_widgets_count[ $sidebar_id ] ) ) : if ( isset( $sidebars_widgets_count[ $sidebar_id ] ) ) :
$widget_count = count( $sidebars_widgets_count[ $sidebar_id ] ); $widget_count = count( $sidebars_widgets_count[ $sidebar_id ] );
$widget_classes = 'widget-count-' . count( $sidebars_widgets_count[ $sidebar_id ] ); $widget_classes = 'widget-count-' . count( $sidebars_widgets_count[ $sidebar_id ] );
if ( 0 == $widget_count % 4 || $widget_count > 6 ) : if ( 0 == $widget_count % 4 || $widget_count > 6 ) : // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
// Four widgets per row if there are exactly four or more than six // Four widgets per row if there are exactly four or more than six.
$widget_classes .= ' col-md-3'; $widget_classes .= ' col-md-3';
elseif ( 6 == $widget_count ) : elseif ( 6 == $widget_count ) : // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
// If two widgets are published // If two widgets are published.
$widget_classes .= ' col-md-2'; $widget_classes .= ' col-md-2';
elseif ( $widget_count >= 3 ) : elseif ( $widget_count >= 3 ) :
// Three widgets per row if there's three or more widgets // Three widgets per row if there's three or more widgets.
$widget_classes .= ' col-md-4'; $widget_classes .= ' col-md-4';
elseif ( 2 == $widget_count ) : elseif ( 2 == $widget_count ) : // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
// If two widgets are published // If two widgets are published.
$widget_classes .= ' col-md-6'; $widget_classes .= ' col-md-6';
elseif ( 1 == $widget_count ) : elseif ( 1 == $widget_count ) : // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
// If just on widget is active // If just on widget is active.
$widget_classes .= ' col-md-12'; $widget_classes .= ' col-md-12';
endif; endif;
return $widget_classes; return $widget_classes;

View File

@ -28,6 +28,6 @@ if ( ! function_exists( 'understrap_scripts' ) ) {
wp_enqueue_script( 'comment-reply' ); wp_enqueue_script( 'comment-reply' );
} }
} }
} // endif function_exists( 'understrap_scripts' ). } // End of if function_exists( 'understrap_scripts' ).
add_action( 'wp_enqueue_scripts', 'understrap_scripts' ); add_action( 'wp_enqueue_scripts', 'understrap_scripts' );

View File

@ -48,7 +48,7 @@ if ( ! function_exists( 'understrap_adjust_body_class' ) ) {
function understrap_adjust_body_class( $classes ) { function understrap_adjust_body_class( $classes ) {
foreach ( $classes as $key => $value ) { foreach ( $classes as $key => $value ) {
if ( 'tag' == $value ) { if ( 'tag' === $value ) {
unset( $classes[ $key ] ); unset( $classes[ $key ] );
} }
} }
@ -67,7 +67,7 @@ if ( ! function_exists( 'understrap_change_logo_class' ) ) {
* *
* @param string $html Markup. * @param string $html Markup.
* *
* @return mixed * @return string
*/ */
function understrap_change_logo_class( $html ) { function understrap_change_logo_class( $html ) {
@ -79,11 +79,10 @@ if ( ! function_exists( 'understrap_change_logo_class' ) ) {
} }
} }
if ( ! function_exists( 'understrap_post_nav' ) ) {
/** /**
* Display navigation to next/previous post when applicable. * Display navigation to next/previous post when applicable.
*/ */
if ( ! function_exists( 'understrap_post_nav' ) ) {
function understrap_post_nav() { function understrap_post_nav() {
// Don't print empty markup if there's nowhere to navigate. // 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 ); $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
@ -148,3 +147,108 @@ if ( ! function_exists( 'understrap_default_body_attributes' ) ) {
} }
} }
add_filter( 'understrap_body_attributes', 'understrap_default_body_attributes' ); add_filter( 'understrap_body_attributes', 'understrap_default_body_attributes' );
// Escapes all occurances of 'the_archive_description'.
add_filter( 'get_the_archive_description', 'understrap_escape_the_archive_description' );
if ( ! function_exists( 'understrap_escape_the_archive_description' ) ) {
/**
* Escapes the description for an author or post type archive.
*
* @param string $description Archive description.
* @return string Maybe escaped $description.
*/
function understrap_escape_the_archive_description( $description ) {
if ( is_author() || is_post_type_archive() ) {
return wp_kses_post( $description );
} else {
/*
* All other descriptions are retrieved via term_description() which returns
* a sanitized description.
*/
return $description;
}
}
} // End of if function_exists( 'understrap_escape_the_archive_description' ).
// Escapes all occurances of 'the_title()' and 'get_the_title()'.
add_filter( 'the_title', 'understrap_kses_title' );
// Escapes all occurances of 'the_archive_title' and 'get_the_archive_title()'.
add_filter( 'get_the_archive_title', 'understrap_kses_title' );
if ( ! function_exists( 'understrap_kses_title' ) ) {
/**
* Sanitizes data for allowed HTML tags for post title.
*
* @param string $data Post title to filter.
* @return string Filtered post title with allowed HTML tags and attributes intact.
*/
function understrap_kses_title( $data ) {
// Tags not supported in HTML5 are not allowed.
$allowed_tags = array(
'abbr' => array(),
'aria-describedby' => true,
'aria-details' => true,
'aria-label' => true,
'aria-labelledby' => true,
'aria-hidden' => true,
'b' => array(),
'bdo' => array(
'dir' => true,
),
'blockquote' => array(
'cite' => true,
'lang' => true,
'xml:lang' => true,
),
'cite' => array(
'dir' => true,
'lang' => true,
),
'dfn' => array(),
'em' => array(),
'i' => array(
'aria-describedby' => true,
'aria-details' => true,
'aria-label' => true,
'aria-labelledby' => true,
'aria-hidden' => true,
'class' => true,
),
'code' => array(),
'del' => array(
'datetime' => true,
),
'ins' => array(
'datetime' => true,
'cite' => true,
),
'kbd' => array(),
'mark' => array(),
'pre' => array(
'width' => true,
),
'q' => array(
'cite' => true,
),
's' => array(),
'samp' => array(),
'span' => array(
'dir' => true,
'align' => true,
'lang' => true,
'xml:lang' => true,
),
'small' => array(),
'strong' => array(),
'sub' => array(),
'sup' => array(),
'u' => array(),
'var' => array(),
);
$allowed_tags = apply_filters( 'understrap_kses_title', $allowed_tags );
return wp_kses( $data, $allowed_tags );
}
} // End of if function_exists( 'understrap_kses_title' ).

View File

@ -29,23 +29,23 @@ if ( ! function_exists( 'understrap_add_site_info' ) ) {
'<a href="%1$s">%2$s</a><span class="sep"> | </span>%3$s(%4$s)', '<a href="%1$s">%2$s</a><span class="sep"> | </span>%3$s(%4$s)',
esc_url( __( 'http://wordpress.org/', 'understrap' ) ), esc_url( __( 'http://wordpress.org/', 'understrap' ) ),
sprintf( sprintf(
/* translators:*/ /* translators: WordPress */
esc_html__( 'Proudly powered by %s', 'understrap' ), esc_html__( 'Proudly powered by %s', 'understrap' ),
'WordPress' 'WordPress'
), ),
sprintf( // WPCS: XSS ok. sprintf( // WPCS: XSS ok.
/* translators:*/ /* translators: 1: Theme name, 2: Theme author */
esc_html__( 'Theme: %1$s by %2$s.', 'understrap' ), esc_html__( 'Theme: %1$s by %2$s.', 'understrap' ),
$the_theme->get( 'Name' ), $the_theme->get( 'Name' ),
'<a href="' . esc_url( __( 'http://understrap.com', 'understrap' ) ) . '">understrap.com</a>' '<a href="' . esc_url( __( 'http://understrap.com', 'understrap' ) ) . '">understrap.com</a>'
), ),
sprintf( // WPCS: XSS ok. sprintf( // WPCS: XSS ok.
/* translators:*/ /* translators: Theme version */
esc_html__( 'Version: %1$s', 'understrap' ), esc_html__( 'Version: %1$s', 'understrap' ),
$the_theme->get( 'Version' ) $the_theme->get( 'Version' )
) )
); );
echo apply_filters( 'understrap_site_info_content', $site_info ); // WPCS: XSS ok. echo apply_filters( 'understrap_site_info_content', $site_info ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} }
} }

View File

@ -10,16 +10,16 @@
// Exit if accessed directly. // Exit if accessed directly.
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/**
* Jetpack setup function.
*
* See: https://jetpack.me/support/infinite-scroll/
* See: https://jetpack.me/support/responsive-videos/
*/
add_action( 'after_setup_theme', 'understrap_components_jetpack_setup' ); add_action( 'after_setup_theme', 'understrap_components_jetpack_setup' );
if ( ! function_exists( 'understrap_components_jetpack_setup' ) ) { if ( ! function_exists( 'understrap_components_jetpack_setup' ) ) {
/**
* Jetpack setup function.
*
* @link https://jetpack.me/support/infinite-scroll/
* @link https://jetpack.me/support/responsive-videos/
* @link https://jetpack.me/support/social-menu/
*/
function understrap_components_jetpack_setup() { function understrap_components_jetpack_setup() {
// Add theme support for Infinite Scroll. // Add theme support for Infinite Scroll.
add_theme_support( add_theme_support(
@ -34,18 +34,16 @@ if ( ! function_exists( 'understrap_components_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 theme support for Social Menus // Add theme support for Social Menus.
add_theme_support( 'jetpack-social-menu' ); add_theme_support( 'jetpack-social-menu' );
} }
} }
if ( ! function_exists( 'understrap_components_infinite_scroll_render' ) ) {
/** /**
* Custom render function for Infinite Scroll. * Custom render function for Infinite Scroll.
*/ */
if ( ! function_exists( 'understrap_components_infinite_scroll_render' ) ) {
function understrap_components_infinite_scroll_render() { function understrap_components_infinite_scroll_render() {
while ( have_posts() ) { while ( have_posts() ) {
the_post(); the_post();
@ -59,8 +57,13 @@ if ( ! function_exists( 'understrap_components_infinite_scroll_render' ) ) {
} }
if ( ! function_exists( 'understrap_components_social_menu' ) ) { if ( ! function_exists( 'understrap_components_social_menu' ) ) {
/**
* Display Jetpack's social menu if available.
* Avoids fatal errors if Jetpack isnt activated.
*/
function understrap_components_social_menu() { function understrap_components_social_menu() {
if ( ! function_exists( 'jetpack_social_menu' ) ) { if ( ! function_exists( 'jetpack_social_menu' ) ) {
// Return early if social menu is not available.
return; return;
} else { } else {
jetpack_social_menu(); jetpack_social_menu();

View File

@ -77,7 +77,7 @@ if ( ! function_exists( 'understrap_pagination' ) ) {
foreach ( $links as $key => $link ) { foreach ( $links as $key => $link ) {
?> ?>
<li class="page-item <?php echo strpos( $link, 'current' ) ? 'active' : ''; ?>"> <li class="page-item <?php echo strpos( $link, 'current' ) ? 'active' : ''; ?>">
<?php echo str_replace( 'page-numbers', 'page-link', $link ); ?> <?php echo str_replace( 'page-numbers', 'page-link', $link ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</li> </li>
<?php <?php
} }

View File

@ -44,21 +44,26 @@ if ( ! function_exists( 'understrap_setup' ) ) {
add_theme_support( 'title-tag' ); add_theme_support( 'title-tag' );
// This theme uses wp_nav_menu() in one location. // This theme uses wp_nav_menu() in one location.
register_nav_menus( array( register_nav_menus(
array(
'primary' => __( 'Primary Menu', 'understrap' ), 'primary' => __( 'Primary Menu', 'understrap' ),
) ); )
);
/* /*
* Switch default core markup for search form, comment form, and comments * Switch default core markup for search form, comment form, and comments
* to output valid HTML5. * to output valid HTML5.
*/ */
add_theme_support( 'html5', array( add_theme_support(
'html5',
array(
'search-form', 'search-form',
'comment-form', 'comment-form',
'comment-list', 'comment-list',
'gallery', 'gallery',
'caption', 'caption',
) ); )
);
/* /*
* Adding Thumbnail basic support * Adding Thumbnail basic support
@ -74,19 +79,28 @@ if ( ! function_exists( 'understrap_setup' ) ) {
* Enable support for Post Formats. * Enable support for Post Formats.
* See http://codex.wordpress.org/Post_Formats * See http://codex.wordpress.org/Post_Formats
*/ */
add_theme_support( 'post-formats', array( add_theme_support(
'post-formats',
array(
'aside', 'aside',
'image', 'image',
'video', 'video',
'quote', 'quote',
'link', 'link',
) ); )
);
// Set up the WordPress core custom background feature. // Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'understrap_custom_background_args', array( add_theme_support(
'custom-background',
apply_filters(
'understrap_custom_background_args',
array(
'default-color' => 'ffffff', 'default-color' => 'ffffff',
'default-image' => '', 'default-image' => '',
) ) ); )
)
);
// Set up the WordPress Theme logo feature. // Set up the WordPress Theme logo feature.
add_theme_support( 'custom-logo' ); add_theme_support( 'custom-logo' );
@ -131,8 +145,10 @@ if ( ! function_exists( 'understrap_all_excerpts_get_more_link' ) ) {
*/ */
function understrap_all_excerpts_get_more_link( $post_excerpt ) { function understrap_all_excerpts_get_more_link( $post_excerpt ) {
if ( ! is_admin() ) { if ( ! is_admin() ) {
$post_excerpt = $post_excerpt . ' [...]<p><a class="btn btn-secondary understrap-read-more-link" href="' . esc_url( get_permalink( get_the_ID() ) ) . '">' . __( 'Read More...', $post_excerpt = $post_excerpt . ' [...]<p><a class="btn btn-secondary understrap-read-more-link" href="' . esc_url( get_permalink( get_the_ID() ) ) . '">' . __(
'understrap' ) . '</a></p>'; 'Read More...',
'understrap'
) . '</a></p>';
} }
return $post_excerpt; return $post_excerpt;
} }

View File

@ -10,23 +10,25 @@
// Exit if accessed directly. // Exit if accessed directly.
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
if ( ! function_exists( 'understrap_posted_on' ) ) {
/** /**
* Prints HTML with meta information for the current post-date/time and author. * Prints HTML with meta information for the current post-date/time and author.
*/ */
if ( ! function_exists( 'understrap_posted_on' ) ) {
function understrap_posted_on() { function understrap_posted_on() {
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>'; $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s"> (%4$s) </time>'; $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s"> (%4$s) </time>';
} }
$time_string = sprintf( $time_string, $time_string = sprintf(
$time_string,
esc_attr( get_the_date( 'c' ) ), esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ), esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ), esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() ) esc_html( get_the_modified_date() )
); );
$posted_on = apply_filters( $posted_on = apply_filters(
'understrap_posted_on', sprintf( 'understrap_posted_on',
sprintf(
'<span class="posted-on">%1$s <a href="%2$s" rel="bookmark">%3$s</a></span>', '<span class="posted-on">%1$s <a href="%2$s" rel="bookmark">%3$s</a></span>',
esc_html_x( 'Posted on', 'post date', 'understrap' ), esc_html_x( 'Posted on', 'post date', 'understrap' ),
esc_url( get_permalink() ), esc_url( get_permalink() ),
@ -34,21 +36,22 @@ if ( ! function_exists( 'understrap_posted_on' ) ) {
) )
); );
$byline = apply_filters( $byline = apply_filters(
'understrap_posted_by', sprintf( 'understrap_posted_by',
sprintf(
'<span class="byline"> %1$s<span class="author vcard"> <a class="url fn n" href="%2$s">%3$s</a></span></span>', '<span class="byline"> %1$s<span class="author vcard"> <a class="url fn n" href="%2$s">%3$s</a></span></span>',
$posted_on ? esc_html_x( 'by', 'post author', 'understrap' ) : esc_html_x( 'Posted by', 'post author', 'understrap' ), $posted_on ? esc_html_x( 'by', 'post author', 'understrap' ) : esc_html_x( 'Posted by', 'post author', 'understrap' ),
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_html( get_the_author() ) esc_html( get_the_author() )
) )
); );
echo $posted_on . $byline; // WPCS: XSS OK. echo $posted_on . $byline; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} }
} }
if ( ! function_exists( 'understrap_entry_footer' ) ) {
/** /**
* Prints HTML with meta information for the categories, tags and comments. * Prints HTML with meta information for the categories, tags and comments.
*/ */
if ( ! function_exists( 'understrap_entry_footer' ) ) {
function understrap_entry_footer() { function understrap_entry_footer() {
// Hide category and tag text for pages. // Hide category and tag text for pages.
if ( 'post' === get_post_type() ) { if ( 'post' === get_post_type() ) {
@ -56,13 +59,13 @@ if ( ! function_exists( 'understrap_entry_footer' ) ) {
$categories_list = get_the_category_list( esc_html__( ', ', 'understrap' ) ); $categories_list = get_the_category_list( esc_html__( ', ', 'understrap' ) );
if ( $categories_list && understrap_categorized_blog() ) { if ( $categories_list && understrap_categorized_blog() ) {
/* translators: %s: Categories of current post */ /* translators: %s: Categories of current post */
printf( '<span class="cat-links">' . esc_html__( 'Posted in %s', 'understrap' ) . '</span>', $categories_list ); // WPCS: XSS OK. printf( '<span class="cat-links">' . esc_html__( 'Posted in %s', 'understrap' ) . '</span>', $categories_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} }
/* translators: used between list items, there is a space after the comma */ /* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', esc_html__( ', ', 'understrap' ) ); $tags_list = get_the_tag_list( '', esc_html__( ', ', 'understrap' ) );
if ( $tags_list ) { if ( $tags_list ) {
/* translators: %s: Tags of current post */ /* translators: %s: Tags of current post */
printf( '<span class="tags-links">' . esc_html__( 'Tagged %s', 'understrap' ) . '</span>', $tags_list ); // WPCS: XSS OK. printf( '<span class="tags-links">' . esc_html__( 'Tagged %s', 'understrap' ) . '</span>', $tags_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} }
} }
if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
@ -82,21 +85,24 @@ if ( ! function_exists( 'understrap_entry_footer' ) ) {
} }
} }
if ( ! function_exists( 'understrap_categorized_blog' ) ) {
/** /**
* Returns true if a blog has more than 1 category. * Returns true if a blog has more than 1 category.
* *
* @return bool * @return bool
*/ */
if ( ! function_exists( 'understrap_categorized_blog' ) ) {
function understrap_categorized_blog() { function understrap_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'understrap_categories' ) ) ) { $all_the_cool_cats = get_transient( 'understrap_categories' );
if ( false === $all_the_cool_cats ) {
// Create an array of all the categories that are attached to posts. // Create an array of all the categories that are attached to posts.
$all_the_cool_cats = get_categories( array( $all_the_cool_cats = get_categories(
array(
'fields' => 'ids', 'fields' => 'ids',
'hide_empty' => 1, 'hide_empty' => 1,
// We only need to know if there is more than one category. // We only need to know if there is more than one category.
'number' => 2, 'number' => 2,
) ); )
);
// Count the number of categories that are attached to the posts. // Count the number of categories that are attached to the posts.
$all_the_cool_cats = count( $all_the_cool_cats ); $all_the_cool_cats = count( $all_the_cool_cats );
set_transient( 'understrap_categories', $all_the_cool_cats ); set_transient( 'understrap_categories', $all_the_cool_cats );
@ -111,13 +117,13 @@ if ( ! function_exists( 'understrap_categorized_blog' ) ) {
} }
} }
/**
* Flush out the transients used in understrap_categorized_blog.
*/
add_action( 'edit_category', 'understrap_category_transient_flusher' ); add_action( 'edit_category', 'understrap_category_transient_flusher' );
add_action( 'save_post', 'understrap_category_transient_flusher' ); add_action( 'save_post', 'understrap_category_transient_flusher' );
if ( ! function_exists( 'understrap_category_transient_flusher' ) ) { if ( ! function_exists( 'understrap_category_transient_flusher' ) ) {
/**
* Flush out the transients used in understrap_categorized_blog.
*/
function understrap_category_transient_flusher() { function understrap_category_transient_flusher() {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return; return;

View File

@ -17,6 +17,7 @@ defined( 'ABSPATH' ) || exit;
add_filter( 'dynamic_sidebar_params', 'understrap_widget_classes' ); add_filter( 'dynamic_sidebar_params', 'understrap_widget_classes' );
if ( ! function_exists( 'understrap_widget_classes' ) ) { if ( ! function_exists( 'understrap_widget_classes' ) ) {
/** /**
* Count number of visible widgets in a sidebar and add classes to widgets accordingly, * Count number of visible widgets in a sidebar and add classes to widgets accordingly,
* so widgets can be displayed one, two, three or four per row. * so widgets can be displayed one, two, three or four per row.
@ -24,6 +25,8 @@ if ( ! function_exists( 'understrap_widget_classes' ) ) {
* @global array $sidebars_widgets * @global array $sidebars_widgets
* *
* @param array $params { * @param array $params {
* Parameters passed to a widgets display callback.
*
* @type array $args { * @type array $args {
* An array of widget display arguments. * An array of widget display arguments.
* *
@ -86,7 +89,7 @@ if ( ! function_exists( 'understrap_widget_classes' ) ) {
return $params; return $params;
} }
} // endif function_exists( 'understrap_widget_classes' ). } // End of if function_exists( 'understrap_widget_classes' ).
add_action( 'widgets_init', 'understrap_widgets_init' ); add_action( 'widgets_init', 'understrap_widgets_init' );
@ -168,4 +171,4 @@ if ( ! function_exists( 'understrap_widgets_init' ) ) {
); );
} }
} // endif function_exists( 'understrap_widgets_init' ). } // End of function_exists( 'understrap_widgets_init' ).

View File

@ -26,18 +26,18 @@ if ( ! function_exists( 'understrap_woocommerce_support' ) ) {
} }
} }
/** // First unhook the WooCommerce content wrappers.
* First unhook the WooCommerce wrappers
*/
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 ); remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 ); remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
/** // Then hook in your own functions to display the wrappers your theme requires.
* Then hook in your own functions to display the wrappers your theme requires
*/
add_action( 'woocommerce_before_main_content', 'understrap_woocommerce_wrapper_start', 10 ); add_action( 'woocommerce_before_main_content', 'understrap_woocommerce_wrapper_start', 10 );
add_action( 'woocommerce_after_main_content', 'understrap_woocommerce_wrapper_end', 10 ); add_action( 'woocommerce_after_main_content', 'understrap_woocommerce_wrapper_end', 10 );
if ( ! function_exists( 'understrap_woocommerce_wrapper_start' ) ) { if ( ! function_exists( 'understrap_woocommerce_wrapper_start' ) ) {
/**
* Display the theme specific start of the page wrapper.
*/
function understrap_woocommerce_wrapper_start() { function understrap_woocommerce_wrapper_start() {
$container = get_theme_mod( 'understrap_container_type' ); $container = get_theme_mod( 'understrap_container_type' );
echo '<div class="wrapper" id="woocommerce-wrapper">'; echo '<div class="wrapper" id="woocommerce-wrapper">';
@ -47,7 +47,11 @@ if ( ! function_exists( 'understrap_woocommerce_wrapper_start' ) ) {
echo '<main class="site-main" id="main">'; echo '<main class="site-main" id="main">';
} }
} }
if ( ! function_exists( 'understrap_woocommerce_wrapper_end' ) ) { if ( ! function_exists( 'understrap_woocommerce_wrapper_end' ) ) {
/**
* Display the theme specific end of the page wrapper.
*/
function understrap_woocommerce_wrapper_end() { function understrap_woocommerce_wrapper_end() {
echo '</main><!-- #main -->'; echo '</main><!-- #main -->';
get_template_part( 'global-templates/right-sidebar-check' ); get_template_part( 'global-templates/right-sidebar-check' );
@ -57,7 +61,7 @@ if ( ! function_exists( 'understrap_woocommerce_wrapper_end' ) ) {
} }
} }
if ( ! function_exists( 'understrap_wc_form_field_args' ) ) {
/** /**
* Filter hook function monkey patching form classes * Filter hook function monkey patching form classes
* Author: Adriano Monecchi http://stackoverflow.com/a/36724593/307826 * Author: Adriano Monecchi http://stackoverflow.com/a/36724593/307826
@ -68,7 +72,6 @@ if ( ! function_exists( 'understrap_woocommerce_wrapper_end' ) ) {
* *
* @return mixed * @return mixed
*/ */
if ( ! function_exists( 'understrap_wc_form_field_args' ) ) {
function understrap_wc_form_field_args( $args, $key, $value = null ) { function understrap_wc_form_field_args( $args, $key, $value = null ) {
// Start field type switch case. // Start field type switch case.
switch ( $args['type'] ) { switch ( $args['type'] ) {
@ -133,7 +136,7 @@ if ( ! function_exists( 'understrap_wc_form_field_args' ) ) {
$args['input_class'] = array( 'form-control', 'input-lg' ); $args['input_class'] = array( 'form-control', 'input-lg' );
$args['label_class'] = array( 'control-label' ); $args['label_class'] = array( 'control-label' );
break; break;
} // end switch ($args). } // End of switch ( $args ).
return $args; return $args;
} }
} }

View File

@ -10,14 +10,14 @@
// Exit if accessed directly. // Exit if accessed directly.
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
add_action( 'after_setup_theme', 'understrap_wpcom_setup' );
if ( ! function_exists( 'understrap_wpcom_setup' ) ) {
/** /**
* Adds support for wp.com-specific theme functions. * Adds support for wp.com-specific theme functions.
* *
* @global array $themecolors * @global array $themecolors
*/ */
add_action( 'after_setup_theme', 'understrap_wpcom_setup' );
if ( ! function_exists( 'understrap_wpcom_setup' ) ) {
function understrap_wpcom_setup() { function understrap_wpcom_setup() {
global $themecolors; global $themecolors;
@ -37,13 +37,12 @@ if ( ! function_exists( 'understrap_wpcom_setup' ) ) {
} }
} }
/*
* WordPress.com-specific styles
*/
add_action( 'wp_enqueue_scripts', 'understrap_wpcom_styles' ); add_action( 'wp_enqueue_scripts', 'understrap_wpcom_styles' );
if ( ! function_exists( 'understrap_wpcom_styles' ) ) { if ( ! function_exists( 'understrap_wpcom_styles' ) ) {
/**
* WordPress.com-specific styles
*/
function understrap_wpcom_styles() { function understrap_wpcom_styles() {
wp_enqueue_style( 'understrap-wpcom', get_template_directory_uri() . '/inc/style-wpcom.css', array(), '20160411' ); wp_enqueue_style( 'understrap-wpcom', get_template_directory_uri() . '/inc/style-wpcom.css', array(), '20160411' );
} }

View File

@ -34,13 +34,11 @@ $container = get_theme_mod( 'understrap_container_type' );
<main class="site-main" id="main"> <main class="site-main" id="main">
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php <?php
if ( have_posts() ) {
// Start the Loop.
while ( have_posts() ) {
the_post();
/* /*
* Include the Post-Format-specific template for the content. * Include the Post-Format-specific template for the content.
@ -48,16 +46,12 @@ $container = get_theme_mod( 'understrap_container_type' );
* called content-___.php (where ___ is the Post Format name) and that will be used instead. * called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/ */
get_template_part( 'loop-templates/content', get_post_format() ); get_template_part( 'loop-templates/content', get_post_format() );
}
} else {
get_template_part( 'loop-templates/content', 'none' );
}
?> ?>
<?php endwhile; ?>
<?php else : ?>
<?php get_template_part( 'loop-templates/content', 'none' ); ?>
<?php endif; ?>
</main><!-- #main --> </main><!-- #main -->
<!-- The pagination component --> <!-- The pagination component -->
@ -72,4 +66,5 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #index-wrapper --> </div><!-- #index-wrapper -->
<?php get_footer(); <?php
get_footer();

View File

@ -22,25 +22,33 @@ defined( 'ABSPATH' ) || exit;
<div class="page-content"> <div class="page-content">
<?php <?php
if ( is_home() && current_user_can( 'publish_posts' ) ) : ?> if ( is_home() && current_user_can( 'publish_posts' ) ) :
<p><?php printf( wp_kses( __( 'Ready to publish your first post? <a href="%1$s">Get started here</a>.', 'understrap' ), array( $kses = array( 'a' => array( 'href' => array() ) );
'a' => array( printf(
'href' => array(), /* translators: 1: Link to WP admin new post page. */
), '<p>' . wp_kses( __( 'Ready to publish your first post? <a href="%1$s">Get started here</a>.', 'understrap' ), $kses ) . '</p>',
) ), esc_url( admin_url( 'post-new.php' ) ) ); ?></p> esc_url( admin_url( 'post-new.php' ) )
);
<?php elseif ( is_search() ) : ?> elseif ( is_search() ) :
<p><?php esc_html_e( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'understrap' ); ?></p> printf(
<?php '<p>%s<p>',
esc_html__( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'understrap' )
);
get_search_form(); get_search_form();
else : ?>
<p><?php esc_html_e( 'It seems we can&rsquo;t find what you&rsquo;re looking for. Perhaps searching can help.', 'understrap' ); ?></p> else :
<?php
printf(
'<p>%s<p>',
esc_html__( 'It seems we can&rsquo;t find what you&rsquo;re looking for. Perhaps searching can help.', 'understrap' )
);
get_search_form(); get_search_form();
endif; ?>
endif;
?>
</div><!-- .page-content --> </div><!-- .page-content -->
</section><!-- .no-results --> </section><!-- .no-results -->

View File

@ -20,7 +20,7 @@ defined( 'ABSPATH' ) || exit;
); );
?> ?>
<?php if ( 'post' == get_post_type() ) : ?> <?php if ( 'post' === get_post_type() ) : ?>
<div class="entry-meta"> <div class="entry-meta">

View File

@ -20,7 +20,7 @@ defined( 'ABSPATH' ) || exit;
); );
?> ?>
<?php if ( 'post' == get_post_type() ) : ?> <?php if ( 'post' === get_post_type() ) : ?>
<div class="entry-meta"> <div class="entry-meta">
<?php understrap_posted_on(); ?> <?php understrap_posted_on(); ?>

View File

@ -20,11 +20,12 @@ defined( 'ABSPATH' ) || exit;
<?php wp_head(); ?> <?php wp_head(); ?>
</head> </head>
<body> <body>
<?php while ( have_posts() ) : the_post(); ?> <?php
while ( have_posts() ) {
<?php get_template_part( 'loop-templates/content', 'blank' ); ?> the_post();
get_template_part( 'loop-templates/content', 'blank' );
<?php endwhile; // end of the loop. ?> }
<?php wp_footer(); ?> wp_footer();
?>
</body> </body>
</html> </html>

View File

@ -20,30 +20,33 @@ $container = get_theme_mod( 'understrap_container_type' );
<div class="row"> <div class="row">
<?php get_template_part( 'sidebar-templates/sidebar', 'left' ); ?> <?php
get_template_part( 'sidebar-templates/sidebar', 'left' );
<div if ( is_active_sidebar( 'left-sidebar' ) xor is_active_sidebar( 'right-sidebar' ) ) {
class="<?php $class = 'col-md-8';
if ( is_active_sidebar( 'left-sidebar' ) xor is_active_sidebar( 'right-sidebar' ) ) : ?>col-md-8<?php } elseif ( is_active_sidebar( 'left-sidebar' ) && is_active_sidebar( 'right-sidebar' ) ) {
elseif ( is_active_sidebar( 'left-sidebar' ) && is_active_sidebar( 'right-sidebar' ) ) : ?>col-md-4<?php $class = 'col-md-4';
else : ?>col-md-12<?php } else {
endif; ?> content-area" $class = 'col-md-12';
id="primary"> }
?>
<div class="<?php echo $class; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> content-area" id="primary">
<main class="site-main" id="main" role="main"> <main class="site-main" id="main" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'loop-templates/content', 'page' ); ?>
<?php <?php
// If comments are open or we have at least one comment, load up the comment template. while ( have_posts() ) {
if ( comments_open() || get_comments_number() ) : the_post();
comments_template();
endif;
?>
<?php endwhile; // end of the loop. ?> get_template_part( 'loop-templates/content', 'page' );
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) {
comments_template();
}
}
?>
</main><!-- #main --> </main><!-- #main -->
@ -57,4 +60,5 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #page-wrapper --> </div><!-- #page-wrapper -->
<?php get_footer(); <?php
get_footer();

View File

@ -12,13 +12,12 @@ defined( 'ABSPATH' ) || exit;
get_header(); get_header();
$container = get_theme_mod( 'understrap_container_type' ); $container = get_theme_mod( 'understrap_container_type' );
if ( is_front_page() ) {
get_template_part( 'global-templates/hero' );
}
?> ?>
<?php if ( is_front_page() ) : ?>
<?php get_template_part( 'global-templates/hero' ); ?>
<?php endif; ?>
<div class="wrapper" id="full-width-page-wrapper"> <div class="wrapper" id="full-width-page-wrapper">
<div class="<?php echo esc_attr( $container ); ?>" id="content"> <div class="<?php echo esc_attr( $container ); ?>" id="content">
@ -29,18 +28,17 @@ $container = get_theme_mod( 'understrap_container_type' );
<main class="site-main" id="main" role="main"> <main class="site-main" id="main" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'loop-templates/content', 'page' ); ?>
<?php <?php
// If comments are open or we have at least one comment, load up the comment template. while ( have_posts() ) {
if ( comments_open() || get_comments_number() ) : the_post();
comments_template(); get_template_part( 'loop-templates/content', 'page' );
endif;
?>
<?php endwhile; // end of the loop. ?> // If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) {
comments_template();
}
}
?>
</main><!-- #main --> </main><!-- #main -->
@ -52,4 +50,5 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #full-width-page-wrapper --> </div><!-- #full-width-page-wrapper -->
<?php get_footer(); <?php
get_footer();

View File

@ -22,24 +22,22 @@ $container = get_theme_mod( 'understrap_container_type' );
<?php get_template_part( 'sidebar-templates/sidebar', 'left' ); ?> <?php get_template_part( 'sidebar-templates/sidebar', 'left' ); ?>
<div <div class="<?php echo is_active_sidebar( 'right-sidebar' ) ? 'col-md-8' : 'col-md-12'; ?> content-area" id="primary">
class="<?php if ( is_active_sidebar( 'left-sidebar' ) ) : ?>col-md-8<?php else : ?>col-md-12<?php endif; ?> content-area"
id="primary">
<main class="site-main" id="main" role="main"> <main class="site-main" id="main" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'loop-templates/content', 'page' ); ?>
<?php <?php
// If comments are open or we have at least one comment, load up the comment template. while ( have_posts() ) {
if ( comments_open() || get_comments_number() ) : the_post();
comments_template();
endif;
?>
<?php endwhile; // end of the loop. ?> get_template_part( 'loop-templates/content', 'page' );
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) {
comments_template();
}
}
?>
</main><!-- #main --> </main><!-- #main -->
@ -51,4 +49,5 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #page-wrapper --> </div><!-- #page-wrapper -->
<?php get_footer(); <?php
get_footer();

View File

@ -20,24 +20,22 @@ $container = get_theme_mod( 'understrap_container_type' );
<div class="row"> <div class="row">
<div <div class="<?php echo is_active_sidebar( 'right-sidebar' ) ? 'col-md-8' : 'col-md-12'; ?> content-area" id="primary">
class="<?php if ( is_active_sidebar( 'right-sidebar' ) ) : ?>col-md-8<?php else : ?>col-md-12<?php endif; ?> content-area"
id="primary">
<main class="site-main" id="main" role="main"> <main class="site-main" id="main" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'loop-templates/content', 'page' ); ?>
<?php <?php
// If comments are open or we have at least one comment, load up the comment template. while ( have_posts() ) {
if ( comments_open() || get_comments_number() ) : the_post();
comments_template();
endif;
?>
<?php endwhile; // end of the loop. ?> get_template_part( 'loop-templates/content', 'page' );
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) {
comments_template();
}
}
?>
</main><!-- #main --> </main><!-- #main -->
@ -51,4 +49,5 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #page-wrapper --> </div><!-- #page-wrapper -->
<?php get_footer(); <?php
get_footer();

View File

@ -30,18 +30,17 @@ $container = get_theme_mod( 'understrap_container_type' );
<main class="site-main" id="main"> <main class="site-main" id="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'loop-templates/content', 'page' ); ?>
<?php <?php
// If comments are open or we have at least one comment, load up the comment template. while ( have_posts() ) {
if ( comments_open() || get_comments_number() ) : the_post();
comments_template(); get_template_part( 'loop-templates/content', 'page' );
endif;
?>
<?php endwhile; // end of the loop. ?> // If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) {
comments_template();
}
}
?>
</main><!-- #main --> </main><!-- #main -->
@ -54,4 +53,5 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #page-wrapper --> </div><!-- #page-wrapper -->
<?php get_footer(); <?php
get_footer();

106
phpcs.xml
View File

@ -1,8 +1,16 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<ruleset name="UnderStrap Coding Standards"> <ruleset name="UnderStrap Coding Standards">
<!-- Set a description for this ruleset. --> <description>Apply WordPress Coding Standards to UnderStrap</description>
<description>A custom set of code standard rules for UnderStrap.</description>
<!-- Only scan PHP files. -->
<arg name="extensions" value="php"/>
<!-- Whenever possible, cache the scan results and re-use those for unchanged files on the next scan. -->
<arg name="cache"/>
<!-- Strip the filepaths down to the relevant bit. -->
<arg name="basepath" value="./"/>
<!-- Show colors in console --> <!-- Show colors in console -->
<arg value="-colors"/> <arg value="-colors"/>
@ -13,44 +21,16 @@
<!-- Don't show warnings --> <!-- Don't show warnings -->
<arg value="n"/> <arg value="n"/>
<!-- Only check the PHP files -->
<arg name="extensions" value="php"/>
<!-- Scan these files --> <!-- Scan these files -->
<file>.</file> <file>.</file>
<!-- Ignore the vendor directory --> <!-- Directories and third party library exclusions. -->
<exclude-pattern>*/vendor/*</exclude-pattern> <exclude-pattern>/vendor/*</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern> <exclude-pattern>/node_modules/*</exclude-pattern>
<exclude-pattern>/dist/*</exclude-pattern>
<!-- Use the WordPress Ruleset --> <!-- Use the WordPress Ruleset -->
<rule ref="WordPress"> <rule ref="WordPress"/>
<exclude name="WordPress.Files.FileName.InvalidClassFileName"/>
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing.BlankLineAfterEnd"/>
<exclude name="WordPress.WhiteSpace.DisallowInlineTabs.NonIndentTabsUsed"/>
<exclude name="WordPress.Security.EscapeOutput.UnsafePrintingFunction"/>
<exclude name="WordPress.Security.EscapeOutput.OutputNotEscaped"/>
<exclude name="WordPress.Security.ValidatedSanitizedInput.InputNotSanitized"/>
<exclude name="WordPress.WP.GlobalVariablesOverride.Prohibited"/>
<exclude name="WordPress.WP.I18n.MissingTranslatorsComment"/>
<exclude name="WordPress.WP.I18n.NonSingularStringLiteralText"/>
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.TooMuchSpaceAfterComma"/>
<exclude name="Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed"/>
<exclude name="Generic.WhiteSpace.ScopeIndent"/>
<exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket"/>
<exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine"/>
<exclude name="PEAR.Functions.FunctionCallSignature.Indent"/>
<exclude name="PEAR.Functions.FunctionCallSignature.MultipleArguments"/>
<exclude name="Squiz.Commenting.FunctionComment.Missing"/>
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop"/>
<exclude name="Squiz.Commenting.InlineComment.InvalidEndChar"/>
<exclude name="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace"/>
<exclude name="Squiz.PHP.DisallowMultipleAssignments.Found"/>
<exclude name="Squiz.PHP.EmbeddedPhp"/>
</rule>
<!-- <!--
Verify that the text_domain is set to the desired text-domain. Verify that the text_domain is set to the desired text-domain.
@ -72,33 +52,41 @@
</properties> </properties>
</rule> </rule>
<!-- Assignments in while conditions are a valid method of looping over iterables. -->
<rule ref="WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition">
<exclude-pattern>*</exclude-pattern>
</rule>
<!-- Exclude incorrectly named files that won't be renamed. -->
<rule ref="WordPress.Files.FileName.InvalidClassFileName">
<exclude-pattern>/inc/class-wp-bootstrap-navwalker\.php</exclude-pattern>
</rule>
<rule ref="WordPress.Security.EscapeOutput">
<!-- Exclude functions which are escaped in inc/extras.php -->
<properties>
<property name="customAutoEscapedFunctions" type="array">
<element value="get_the_title"/>
<element value="get_the_archive_title"/>
<element value="get_the_archive_description"/>
</property>
</properties>
</rule>
<!--
Exclude checking of line endings when reporting errors, but fix them
when running phpcbf.
-->
<rule ref="Generic.Files.LineEndings">
<exclude phpcs-only="true" name="Generic.Files.LineEndings"/>
</rule>
<!-- A closing tag is not permitted at the end of a PHP file --> <!-- A closing tag is not permitted at the end of a PHP file -->
<rule ref="Zend.Files.ClosingTag"/> <rule ref="Zend.Files.ClosingTag"/>
<!-- Use the PHPCompatibility Ruleset --> <!-- Use the PHPCompatibility Ruleset -->
<config name="testVersion" value="5.2-99.0"/> <config name="testVersion" value="5.6-99.0"/>
<rule ref="PHPCompatibility"> <rule ref="PHPCompatibilityWP">
<!-- <include-pattern>*\.php$</include-pattern>
Whitelist PHP native classes, interfaces, functions and constants which
are back-filled by WP.
Based on:
* /wp-includes/compat.php
* /wp-includes/random_compat/random.php
-->
<exclude name="PHPCompatibility.PHP.NewClasses.errorFound"/>
<exclude name="PHPCompatibility.PHP.NewClasses.typeerrorFound"/>
<exclude name="PHPCompatibility.PHP.NewConstants.json_pretty_printFound"/>
<exclude name="PHPCompatibility.PHP.NewConstants.php_version_idFound"/>
<exclude name="PHPCompatibility.PHP.NewFunctions.hash_equalsFound"/>
<exclude name="PHPCompatibility.PHP.NewFunctions.json_last_error_msgFound"/>
<exclude name="PHPCompatibility.PHP.NewFunctions.random_intFound"/>
<exclude name="PHPCompatibility.PHP.NewFunctions.random_bytesFound"/>
<exclude name="PHPCompatibility.PHP.NewFunctions.array_replace_recursiveFound"/>
<exclude name="PHPCompatibility.PHP.NewInterfaces.jsonserializableFound"/>
</rule> </rule>
</ruleset> </ruleset>

View File

@ -42,19 +42,19 @@ $container = get_theme_mod( 'understrap_container_type' );
</header><!-- .page-header --> </header><!-- .page-header -->
<?php /* Start the Loop */ ?> <?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php <?php
/** while ( have_posts() ) :
the_post();
/*
* Run the loop for the search to output the results. * Run the loop for the search to output the results.
* If you want to overload this in a child theme then include a file * If you want to overload this in a child theme then include a file
* called content-search.php and that will be used instead. * called content-search.php and that will be used instead.
*/ */
get_template_part( 'loop-templates/content', 'search' ); get_template_part( 'loop-templates/content', 'search' );
endwhile;
?> ?>
<?php endwhile; ?>
<?php else : ?> <?php else : ?>
<?php get_template_part( 'loop-templates/content', 'none' ); ?> <?php get_template_part( 'loop-templates/content', 'none' ); ?>
@ -75,4 +75,5 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #search-wrapper --> </div><!-- #search-wrapper -->
<?php get_footer(); <?php
get_footer();

View File

@ -30,4 +30,5 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #wrapper-footer-full --> </div><!-- #wrapper-footer-full -->
<?php endif; <?php
endif;

View File

@ -43,4 +43,5 @@ defined( 'ABSPATH' ) || exit;
jQuery( ".carousel-item" ).first().addClass( "active" ); jQuery( ".carousel-item" ).first().addClass( "active" );
</script> </script>
<?php endif; <?php
endif;

View File

@ -1,18 +1,15 @@
<?php <?php
/** /**
* Sidebar - hero canvas setup * Sidebar - The Hero Canvas Widget Area
* *
* @package understrap * @package understrap
*/ */
// Exit if accessed directly. // Exit if accessed directly.
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
?>
<?php if ( is_active_sidebar( 'herocanvas' ) ) : ?> if ( is_active_sidebar( 'herocanvas' ) ) {
<!-- ******************* The Hero Canvas Widget Area ******************* --> dynamic_sidebar( 'herocanvas' );
<?php dynamic_sidebar( 'herocanvas' ); ?> }
<?php endif;

View File

@ -29,4 +29,5 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #wrapper-static-hero --> </div><!-- #wrapper-static-hero -->
<?php endif; <?php
endif;

View File

@ -23,20 +23,18 @@ $container = get_theme_mod( 'understrap_container_type' );
<main class="site-main" id="main"> <main class="site-main" id="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'loop-templates/content', 'single' ); ?>
<?php understrap_post_nav(); ?>
<?php <?php
// If comments are open or we have at least one comment, load up the comment template. while ( have_posts() ) {
if ( comments_open() || get_comments_number() ) : the_post();
comments_template(); get_template_part( 'loop-templates/content', 'single' );
endif; understrap_post_nav();
?>
<?php endwhile; // end of the loop. ?> // If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) {
comments_template();
}
}
?>
</main><!-- #main --> </main><!-- #main -->
@ -49,4 +47,5 @@ $container = get_theme_mod( 'understrap_container_type' );
</div><!-- #single-wrapper --> </div><!-- #single-wrapper -->
<?php get_footer(); <?php
get_footer();

View File

@ -22,10 +22,12 @@ defined( 'ABSPATH' ) || exit;
*/ */
do_action( 'woocommerce_cart_is_empty' ); do_action( 'woocommerce_cart_is_empty' );
if ( wc_get_page_id( 'shop' ) > 0 ) : ?> if ( wc_get_page_id( 'shop' ) > 0 ) :
?>
<p class="return-to-shop"> <p class="return-to-shop">
<a class="btn btn-outline-primary" href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>"> <a class="btn btn-outline-primary" href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>">
<?php esc_html_e( 'Return to shop', 'understrap' ); ?> <?php esc_html_e( 'Return to shop', 'understrap' ); ?>
</a> </a>
</p> </p>
<?php endif; <?php
endif;

View File

@ -67,9 +67,9 @@ do_action( 'woocommerce_before_cart' ); ?>
$thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key ); $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key );
if ( ! $product_permalink ) { if ( ! $product_permalink ) {
echo $thumbnail; // PHPCS: XSS ok. echo $thumbnail; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} else { } else {
printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $thumbnail ); // PHPCS: XSS ok. printf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $thumbnail ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} }
?> ?>
</td> </td>
@ -85,7 +85,7 @@ do_action( 'woocommerce_before_cart' ); ?>
do_action( 'woocommerce_after_cart_item_name', $cart_item, $cart_item_key ); do_action( 'woocommerce_after_cart_item_name', $cart_item, $cart_item_key );
// Meta data. // Meta data.
echo wc_get_formatted_cart_item_data( $cart_item ); // PHPCS: XSS ok. echo wc_get_formatted_cart_item_data( $cart_item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
// Backorder notification. // Backorder notification.
if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) ) { if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) ) {
@ -96,7 +96,7 @@ do_action( 'woocommerce_before_cart' ); ?>
<td class="product-price" data-title="<?php esc_attr_e( 'Price', 'understrap' ); ?>"> <td class="product-price" data-title="<?php esc_attr_e( 'Price', 'understrap' ); ?>">
<?php <?php
echo apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); // PHPCS: XSS ok. echo apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?> ?>
</td> </td>
@ -118,13 +118,13 @@ do_action( 'woocommerce_before_cart' ); ?>
); );
} }
echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item ); // PHPCS: XSS ok. echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?> ?>
</td> </td>
<td class="product-subtotal" data-title="<?php esc_attr_e( 'Subtotal', 'understrap' ); ?>"> <td class="product-subtotal" data-title="<?php esc_attr_e( 'Subtotal', 'understrap' ); ?>">
<?php <?php
echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); // PHPCS: XSS ok. echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?> ?>
</td> </td>
</tr> </tr>
@ -173,4 +173,5 @@ do_action( 'woocommerce_before_cart' ); ?>
?> ?>
</div> </div>
<?php do_action( 'woocommerce_after_cart' ); ?> <?php
do_action( 'woocommerce_after_cart' );

View File

@ -93,4 +93,5 @@ do_action( 'woocommerce_before_mini_cart' ); ?>
<?php endif; ?> <?php endif; ?>
<?php do_action( 'woocommerce_after_mini_cart' ); ?> <?php
do_action( 'woocommerce_after_mini_cart' );

View File

@ -61,4 +61,5 @@ if ( ! $checkout->is_registration_enabled() && $checkout->is_registration_requir
</form> </form>
<?php do_action( 'woocommerce_after_checkout_form', $checkout ); <?php
do_action( 'woocommerce_after_checkout_form', $checkout );

View File

@ -17,7 +17,7 @@
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
$totals = $order->get_order_item_totals(); $item_totals = $order->get_order_item_totals();
?> ?>
<form id="order_review" method="post"> <form id="order_review" method="post">
@ -56,8 +56,8 @@ $totals = $order->get_order_item_totals();
<?php endif; ?> <?php endif; ?>
</tbody> </tbody>
<tfoot> <tfoot>
<?php if ( $totals ) : ?> <?php if ( $item_totals ) : ?>
<?php foreach ( $totals as $total ) : ?> <?php foreach ( $item_totals as $total ) : ?>
<tr> <tr>
<th scope="row" colspan="2"><?php echo $total['label']; ?></th><?php // @codingStandardsIgnoreLine ?> <th scope="row" colspan="2"><?php echo $total['label']; ?></th><?php // @codingStandardsIgnoreLine ?>
<td class="product-total"><?php echo $total['value']; ?></td><?php // @codingStandardsIgnoreLine ?> <td class="product-total"><?php echo $total['value']; ?></td><?php // @codingStandardsIgnoreLine ?>

View File

@ -12,7 +12,6 @@
* *
* @see https://docs.woocommerce.com/document/template-structure/ * @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates * @package WooCommerce/Templates
* @version 3.6.1 * @version 3.6.1
*/ */
@ -47,7 +46,7 @@ if ( is_user_logged_in() ) {
<input class="woocommerce-form__input woocommerce-form__input-checkbox" name="rememberme" type="checkbox" id="rememberme" value="forever" /> <span><?php esc_html_e( 'Remember me', 'understrap' ); ?></span> <input class="woocommerce-form__input woocommerce-form__input-checkbox" name="rememberme" type="checkbox" id="rememberme" value="forever" /> <span><?php esc_html_e( 'Remember me', 'understrap' ); ?></span>
</label> </label>
<?php wp_nonce_field( 'woocommerce-login', 'woocommerce-login-nonce' ); ?> <?php wp_nonce_field( 'woocommerce-login', 'woocommerce-login-nonce' ); ?>
<input type="hidden" name="redirect" value="<?php echo esc_url( $redirect ) ?>" /> <input type="hidden" name="redirect" value="<?php echo esc_url( $redirect ); ?>" />
<button type="submit" class="btn btn-outline-primary" name="login" value="<?php esc_attr_e( 'Login', 'understrap' ); ?>"><?php esc_html_e( 'Login', 'understrap' ); ?></button> <button type="submit" class="btn btn-outline-primary" name="login" value="<?php esc_attr_e( 'Login', 'understrap' ); ?>"><?php esc_html_e( 'Login', 'understrap' ); ?></button>
</p> </p>

View File

@ -22,14 +22,18 @@ if ( ! defined( 'ABSPATH' ) ) {
global $product; global $product;
echo apply_filters( 'woocommerce_loop_add_to_cart_link', // WPCS: XSS ok. echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
sprintf( '<div class="add-to-cart-container"><a href="%s" data-quantity="%s" class="%s product_type_%s single_add_to_cart_button btn btn-outline-primary btn-block %s" %s> %s</a></div>', 'woocommerce_loop_add_to_cart_link',
sprintf(
'<div class="add-to-cart-container"><a href="%s" data-quantity="%s" class="%s product_type_%s single_add_to_cart_button btn btn-outline-primary btn-block %s" %s> %s</a></div>',
esc_url( $product->add_to_cart_url() ), esc_url( $product->add_to_cart_url() ),
esc_attr( isset( $args['quantity'] ) ? $args['quantity'] : 1 ), esc_attr( isset( $args['quantity'] ) ? $args['quantity'] : 1 ),
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '', $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
esc_attr( $product->get_type() ), esc_attr( $product->get_type() ),
$product->get_type() == 'simple' ? 'ajax_add_to_cart' : '', $product->get_type() === 'simple' ? 'ajax_add_to_cart' : '',
isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : '', isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : '',
esc_html( $product->add_to_cart_text() ) esc_html( $product->add_to_cart_text() )
), ),
$product, $args ); $product,
$args
);

View File

@ -22,8 +22,8 @@ if ( ! defined( 'ABSPATH' ) ) {
?> ?>
<form class="woocommerce-ordering" method="get"> <form class="woocommerce-ordering" method="get">
<select name="orderby" class="orderby custom-select" aria-label="<?php esc_attr_e( 'Shop order', 'understrap' ); ?>"> <select name="orderby" class="orderby custom-select" aria-label="<?php esc_attr_e( 'Shop order', 'understrap' ); ?>">
<?php foreach ( $catalog_orderby_options as $id => $name ) : ?> <?php foreach ( $catalog_orderby_options as $option_id => $name ) : ?>
<option value="<?php echo esc_attr( $id ); ?>" <?php selected( $orderby, $id ); ?>><?php echo esc_html( $name ); ?></option> <option value="<?php echo esc_attr( $option_id ); ?>" <?php selected( $orderby, $option_id ); ?>><?php echo esc_html( $name ); ?></option>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
<input type="hidden" name="paged" value="1" /> <input type="hidden" name="paged" value="1" />

View File

@ -38,10 +38,11 @@ do_action( 'woocommerce_before_account_downloads', $has_downloads ); ?>
<?php else : ?> <?php else : ?>
<div class="woocommerce-Message woocommerce-Message--info woocommerce-info"> <div class="woocommerce-Message woocommerce-Message--info woocommerce-info">
<a class="btn btn-outline-primary" href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>"> <a class="btn btn-outline-primary" href="<?php echo esc_url( apply_filters( 'woocommerce_return_to_shop_redirect', wc_get_page_permalink( 'shop' ) ) ); ?>">
<?php esc_html_e( 'Go shop', 'understrap' ) ?> <?php esc_html_e( 'Go shop', 'understrap' ); ?>
</a> </a>
<?php esc_html_e( 'No downloads available yet.', 'understrap' ); ?> <?php esc_html_e( 'No downloads available yet.', 'understrap' ); ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php do_action( 'woocommerce_after_account_downloads', $has_downloads ); <?php
do_action( 'woocommerce_after_account_downloads', $has_downloads );

View File

@ -73,4 +73,5 @@ do_action( 'woocommerce_before_edit_account_form' ); ?>
<?php do_action( 'woocommerce_edit_account_form_end' ); ?> <?php do_action( 'woocommerce_edit_account_form_end' ); ?>
</form> </form>
<?php do_action( 'woocommerce_after_edit_account_form' ); <?php
do_action( 'woocommerce_after_edit_account_form' );

View File

@ -53,4 +53,5 @@ do_action( 'woocommerce_before_edit_account_address_form' ); ?>
<?php endif; ?> <?php endif; ?>
<?php do_action( 'woocommerce_after_edit_account_address_form' ); <?php
do_action( 'woocommerce_after_edit_account_address_form' );

View File

@ -117,4 +117,5 @@ do_action( 'woocommerce_before_customer_login_form' ); ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php do_action( 'woocommerce_after_customer_login_form' ); <?php
do_action( 'woocommerce_after_customer_login_form' );

View File

@ -17,20 +17,28 @@
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly exit; // Exit if accessed directly.
} }
$customer_id = get_current_user_id(); $customer_id = get_current_user_id();
if ( ! wc_ship_to_billing_address_only() && wc_shipping_enabled() ) { if ( ! wc_ship_to_billing_address_only() && wc_shipping_enabled() ) {
$get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array( $get_addresses = apply_filters(
'woocommerce_my_account_get_addresses',
array(
'billing' => __( 'Billing address', 'understrap' ), 'billing' => __( 'Billing address', 'understrap' ),
'shipping' => __( 'Shipping address', 'understrap' ), 'shipping' => __( 'Shipping address', 'understrap' ),
), $customer_id ); ),
$customer_id
);
} else { } else {
$get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array( $get_addresses = apply_filters(
'woocommerce_my_account_get_addresses',
array(
'billing' => __( 'Billing address', 'understrap' ), 'billing' => __( 'Billing address', 'understrap' ),
), $customer_id ); ),
$customer_id
);
} }
$oldcol = 1; $oldcol = 1;
@ -38,28 +46,31 @@ $col = 1;
?> ?>
<p> <p>
<?php echo apply_filters( 'woocommerce_my_account_my_address_description', __( 'The following addresses will be used on the checkout page by default.', 'understrap' ) ); ?> <?php echo apply_filters( 'woocommerce_my_account_my_address_description', esc_html__( 'The following addresses will be used on the checkout page by default.', 'understrap' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</p> </p>
<?php if ( ! wc_ship_to_billing_address_only() && wc_shipping_enabled() ) : ?> <?php if ( ! wc_ship_to_billing_address_only() && wc_shipping_enabled() ) : ?>
<div class="u-columns woocommerce-Addresses col2-set addresses"> <div class="u-columns woocommerce-Addresses col2-set addresses">
<?php endif; ?> <?php endif; ?>
<?php foreach ( $get_addresses as $name => $title ) : ?> <?php foreach ( $get_addresses as $name => $address_title ) : ?>
<div class="u-column woocommerce-Address"> <div class="u-column woocommerce-Address">
<header class="woocommerce-Address-title title"> <header class="woocommerce-Address-title title">
<h3><?php echo $title; ?></h3> <h3><?php echo esc_html( $address_title ); ?></h3>
<a href="<?php echo esc_url( wc_get_endpoint_url( 'edit-address', $name ) ); ?>" class="edit"><?php _e( 'Edit', 'understrap' ); ?></a> <a href="<?php echo esc_url( wc_get_endpoint_url( 'edit-address', $name ) ); ?>" class="edit"><?php esc_html_e( 'Edit', 'understrap' ); ?></a>
</header> </header>
<address><?php <address>
<?php
$address = wc_get_account_formatted_address( $name ); $address = wc_get_account_formatted_address( $name );
echo $address ? wp_kses_post( $address ) : esc_html_e( 'You have not set up this type of address yet.', 'understrap' ); echo $address ? wp_kses_post( $address ) : esc_html_e( 'You have not set up this type of address yet.', 'understrap' );
?></address> ?>
</address>
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
<?php if ( ! wc_ship_to_billing_address_only() && wc_shipping_enabled() ) : ?> <?php if ( ! wc_ship_to_billing_address_only() && wc_shipping_enabled() ) : ?>
</div> </div>
<?php endif; <?php
endif;

View File

@ -2,6 +2,7 @@
/** /**
* My Orders - Deprecated * My Orders - Deprecated
* *
* @package WooCommerce/Templates
* @deprecated 2.6.0 this template file is no longer used. My Account shortcode uses orders.php. * @deprecated 2.6.0 this template file is no longer used. My Account shortcode uses orders.php.
*/ */
@ -9,25 +10,33 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
$my_orders_columns = apply_filters( 'woocommerce_my_account_my_orders_columns', array( $my_orders_columns = apply_filters(
'order-number' => __( 'Order', 'understrap' ), 'woocommerce_my_account_my_orders_columns',
'order-date' => __( 'Date', 'understrap' ), array(
'order-status' => __( 'Status', 'understrap' ), 'order-number' => esc_html__( 'Order', 'understrap' ),
'order-total' => __( 'Total', 'understrap' ), 'order-date' => esc_html__( 'Date', 'understrap' ),
'order-status' => esc_html__( 'Status', 'understrap' ),
'order-total' => esc_html__( 'Total', 'understrap' ),
'order-actions' => '&nbsp;', 'order-actions' => '&nbsp;',
) ); )
);
$customer_orders = get_posts( apply_filters( 'woocommerce_my_account_my_orders_query', array( $customer_orders = get_posts(
apply_filters(
'woocommerce_my_account_my_orders_query',
array(
'numberposts' => $order_count, 'numberposts' => $order_count,
'meta_key' => '_customer_user', 'meta_key' => '_customer_user', // phpcs:ignore WordPress.DB.SlowDBQuery
'meta_value' => get_current_user_id(), 'meta_value' => get_current_user_id(), // phpcs:ignore WordPress.DB.SlowDBQuery
'post_type' => wc_get_order_types( 'view-orders' ), 'post_type' => wc_get_order_types( 'view-orders' ),
'post_status' => array_keys( wc_get_order_statuses() ), 'post_status' => array_keys( wc_get_order_statuses() ),
) ) ); )
)
);
if ( $customer_orders ) : ?> if ( $customer_orders ) : ?>
<h2><?php echo apply_filters( 'woocommerce_my_account_my_orders_title', __( 'Recent orders', 'understrap' ) ); ?></h2> <h2><?php echo apply_filters( 'woocommerce_my_account_my_orders_title', esc_html__( 'Recent orders', 'understrap' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></h2>
<table class="shop_table shop_table_responsive my_account_orders table-hover table-striped"> <table class="shop_table shop_table_responsive my_account_orders table-hover table-striped">
@ -40,8 +49,9 @@ if ( $customer_orders ) : ?>
</thead> </thead>
<tbody> <tbody>
<?php foreach ( $customer_orders as $customer_order ) : <?php
$order = wc_get_order( $customer_order ); foreach ( $customer_orders as $customer_order ) :
$order = wc_get_order( $customer_order ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Override
$item_count = $order->get_item_count(); $item_count = $order->get_item_count();
?> ?>
<tr class="order"> <tr class="order">
@ -52,7 +62,7 @@ if ( $customer_orders ) : ?>
<?php elseif ( 'order-number' === $column_id ) : ?> <?php elseif ( 'order-number' === $column_id ) : ?>
<a href="<?php echo esc_url( $order->get_view_order_url() ); ?>"> <a href="<?php echo esc_url( $order->get_view_order_url() ); ?>">
<?php echo _x( '#', 'hash before order number', 'understrap' ) . $order->get_order_number(); ?> <?php echo _x( '#', 'hash before order number', 'understrap' ) . $order->get_order_number(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</a> </a>
<?php elseif ( 'order-date' === $column_id ) : ?> <?php elseif ( 'order-date' === $column_id ) : ?>
@ -64,16 +74,16 @@ if ( $customer_orders ) : ?>
<?php elseif ( 'order-total' === $column_id ) : ?> <?php elseif ( 'order-total' === $column_id ) : ?>
<?php <?php
/* translators: 1: formatted order total 2: total order items */ /* translators: 1: formatted order total 2: total order items */
printf( _n( '%1$s for %2$s item', '%1$s for %2$s items', $item_count, 'understrap' ), $order->get_formatted_order_total(), $item_count ); printf( _n( '%1$s for %2$s item', '%1$s for %2$s items', $item_count, 'understrap' ), $order->get_formatted_order_total(), $item_count ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
?> ?>
<?php elseif ( 'order-actions' === $column_id ) : ?> <?php elseif ( 'order-actions' === $column_id ) : ?>
<?php <?php
$actions = wc_get_account_orders_actions( $order ); $orders_actions = wc_get_account_orders_actions( $order );
if ( ! empty( $actions ) ) { if ( ! empty( $orders_actions ) ) {
foreach ( $actions as $key => $action ) { foreach ( $orders_actions as $key => $orders_action ) {
echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-outline-primary ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</a>'; echo '<a href="' . esc_url( $orders_action['url'] ) . '" class="btn btn-outline-primary ' . sanitize_html_class( $key ) . '">' . esc_html( $orders_action['name'] ) . '</a>';
} }
} }
?> ?>
@ -84,4 +94,5 @@ if ( $customer_orders ) : ?>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
</table> </table>
<?php endif; <?php
endif;

View File

@ -32,4 +32,5 @@ do_action( 'woocommerce_before_account_navigation' );
</div> </div>
</nav> </nav>
<?php do_action( 'woocommerce_after_account_navigation' ); <?php
do_action( 'woocommerce_after_account_navigation' );

View File

@ -35,7 +35,7 @@ do_action( 'woocommerce_before_account_orders', $has_orders ); ?>
<tbody> <tbody>
<?php <?php
foreach ( $customer_orders->orders as $customer_order ) { foreach ( $customer_orders->orders as $customer_order ) {
$order = wc_get_order( $customer_order ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited $order = wc_get_order( $customer_order ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Override
$item_count = $order->get_item_count() - $order->get_item_count_refunded(); $item_count = $order->get_item_count() - $order->get_item_count_refunded();
?> ?>
<tr class="woocommerce-orders-table__row woocommerce-orders-table__row--status-<?php echo esc_attr( $order->get_status() ); ?> order"> <tr class="woocommerce-orders-table__row woocommerce-orders-table__row--status-<?php echo esc_attr( $order->get_status() ); ?> order">
@ -63,11 +63,11 @@ do_action( 'woocommerce_before_account_orders', $has_orders ); ?>
<?php elseif ( 'order-actions' === $column_id ) : ?> <?php elseif ( 'order-actions' === $column_id ) : ?>
<?php <?php
$actions = wc_get_account_orders_actions( $order ); $orders_actions = wc_get_account_orders_actions( $order );
if ( ! empty( $actions ) ) { if ( ! empty( $orders_actions ) ) {
foreach ( $actions as $key => $action ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited foreach ( $orders_actions as $key => $orders_action ) {
echo '<a href="' . esc_url( $action['url'] ) . '" class="woocommerce-button btn btn-outline-primary ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</a>'; echo '<a href="' . esc_url( $orders_action['url'] ) . '" class="woocommerce-button btn btn-outline-primary ' . sanitize_html_class( $key ) . '">' . esc_html( $orders_action['name'] ) . '</a>';
} }
} }
?> ?>
@ -104,4 +104,5 @@ do_action( 'woocommerce_before_account_orders', $has_orders ); ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php do_action( 'woocommerce_after_account_orders', $has_orders ); ?> <?php
do_action( 'woocommerce_after_account_orders', $has_orders );

View File

@ -23,7 +23,7 @@ if ( ! $product->is_purchasable() ) {
return; return;
} }
echo wc_get_stock_html( $product ); // WPCS: XSS ok. echo wc_get_stock_html( $product ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
if ( $product->is_in_stock() ) : ?> if ( $product->is_in_stock() ) : ?>
@ -35,11 +35,13 @@ if ( $product->is_in_stock() ) : ?>
<?php <?php
do_action( 'woocommerce_before_add_to_cart_quantity' ); do_action( 'woocommerce_before_add_to_cart_quantity' );
woocommerce_quantity_input( array( woocommerce_quantity_input(
array(
'min_value' => apply_filters( 'woocommerce_quantity_input_min', $product->get_min_purchase_quantity(), $product ), 'min_value' => apply_filters( 'woocommerce_quantity_input_min', $product->get_min_purchase_quantity(), $product ),
'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->get_max_purchase_quantity(), $product ), 'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->get_max_purchase_quantity(), $product ),
'input_value' => isset( $_POST['quantity'] ) ? wc_stock_amount( wp_unslash( $_POST['quantity'] ) ) : $product->get_min_purchase_quantity(), // WPCS: CSRF ok, input var ok. 'input_value' => isset( $_POST['quantity'] ) ? wc_stock_amount( wp_unslash( $_POST['quantity'] ) ) : $product->get_min_purchase_quantity(), // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
) ); )
);
do_action( 'woocommerce_after_add_to_cart_quantity' ); do_action( 'woocommerce_after_add_to_cart_quantity' );
?> ?>
@ -51,4 +53,5 @@ if ( $product->is_in_stock() ) : ?>
<?php do_action( 'woocommerce_after_add_to_cart_form' ); ?> <?php do_action( 'woocommerce_after_add_to_cart_form' ); ?>
<?php endif; <?php
endif;

View File

@ -17,11 +17,13 @@ global $product;
<?php <?php
do_action( 'woocommerce_before_add_to_cart_quantity' ); do_action( 'woocommerce_before_add_to_cart_quantity' );
woocommerce_quantity_input( array( woocommerce_quantity_input(
array(
'min_value' => apply_filters( 'woocommerce_quantity_input_min', $product->get_min_purchase_quantity(), $product ), 'min_value' => apply_filters( 'woocommerce_quantity_input_min', $product->get_min_purchase_quantity(), $product ),
'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->get_max_purchase_quantity(), $product ), 'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->get_max_purchase_quantity(), $product ),
'input_value' => isset( $_POST['quantity'] ) ? wc_stock_amount( wp_unslash( $_POST['quantity'] ) ) : $product->get_min_purchase_quantity(), // WPCS: CSRF ok, input var ok. 'input_value' => isset( $_POST['quantity'] ) ? wc_stock_amount( wp_unslash( $_POST['quantity'] ) ) : $product->get_min_purchase_quantity(), // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
) ); )
);
do_action( 'woocommerce_after_add_to_cart_quantity' ); do_action( 'woocommerce_after_add_to_cart_quantity' );
?> ?>