diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 84c9893..758a572 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -43,8 +43,8 @@ People *love* thorough bug reports. I'm not even kidding. ## Use a Consistent Coding Style -* 2 spaces for indentation rather than tabs -* Use ./.editorconfig if your editor supports it +* Stick to the [WordPress Coding Standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/) +* Use [./.editorconfig](https://github.com/understrap/understrap/blob/master/.editorconfig) if your editor supports it ## License diff --git a/404.php b/404.php index 2298a86..8d28c1b 100644 --- a/404.php +++ b/404.php @@ -49,11 +49,11 @@ $container = get_theme_mod( 'understrap_container_type' ); 'count', - 'order' => 'DESC', + 'orderby' => 'count', + 'order' => 'DESC', 'show_count' => 1, - 'title_li' => '', - 'number' => 10, + 'title_li' => '', + 'number' => 10, ) ); ?> @@ -86,4 +86,5 @@ $container = get_theme_mod( 'understrap_container_type' ); - - - + - - - - - - - - - - - - - + } + } else { + get_template_part( 'loop-templates/content', 'none' ); + } + ?> - - + - - - - + - + - nickname ); ?> - ID ) ) : ?> - ID ); ?> - + ID ) ) { + echo get_avatar( $curauth->ID ); + } + ?> user_url ) || ! empty( $curauth->user_description ) ) : ?>
@@ -52,45 +54,39 @@ $container = get_theme_mod( 'understrap_container_type' ); user_description ) ) : ?>
-
user_description, 'understrap' ); ?>
+
user_description ); ?>
-

nickname ); ?>:

+

nickname ); ?>:

- - '; + } else { + get_template_part( 'loop-templates/content', 'none' ); + } + ?> - - @@ -105,4 +101,5 @@ $container = get_theme_mod( 'understrap_container_type' ); - - +if ( is_active_sidebar( 'hero' ) || is_active_sidebar( 'statichero' ) || is_active_sidebar( 'herocanvas' ) ) : + ?>
- - - - - +
- - - - -
diff --git a/global-templates/right-sidebar-check.php b/global-templates/right-sidebar-check.php index 90af56e..b085e46 100644 --- a/global-templates/right-sidebar-check.php +++ b/global-templates/right-sidebar-check.php @@ -11,10 +11,9 @@ defined( 'ABSPATH' ) || exit;
- + - - - - - + } + ?> + - 'primary', 'container_class' => 'collapse navbar-collapse', @@ -73,7 +77,8 @@ $container = get_theme_mod( 'understrap_container_type' ); 'depth' => 2, 'walker' => new Understrap_WP_Bootstrap_Navwalker(), ) - ); ?> + ); + ?> diff --git a/inc/class-wp-bootstrap-navwalker.php b/inc/class-wp-bootstrap-navwalker.php index aee0413..139bff9 100644 --- a/inc/class-wp-bootstrap-navwalker.php +++ b/inc/class-wp-bootstrap-navwalker.php @@ -20,7 +20,7 @@ defined( 'ABSPATH' ) || exit; * GitHub Branch: master * License: GPL-3.0+ * License URI: http://www.gnu.org/licenses/gpl-3.0.txt -*/ + */ /* Check if Class Exists. */ if ( ! class_exists( 'Understrap_WP_Bootstrap_Navwalker' ) ) { @@ -182,7 +182,7 @@ if ( ! class_exists( 'Understrap_WP_Bootstrap_Navwalker' ) ) { } $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'; } else { $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 ( array_key_exists( 'echo', $args ) && $args['echo'] ) { - echo $fallback_output; // WPCS: XSS OK. + echo $fallback_output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } else { return $fallback_output; } diff --git a/inc/custom-header.php b/inc/custom-header.php index 06336e1..fd4e86c 100644 --- a/inc/custom-header.php +++ b/inc/custom-header.php @@ -11,6 +11,9 @@ defined( 'ABSPATH' ) || exit; add_action( 'after_setup_theme', 'understrap_custom_header_setup' ); if ( ! function_exists( 'understrap_custom_header_setup' ) ) { + /** + * Set up custom header feature. + */ function understrap_custom_header_setup() { /** diff --git a/inc/customizer.php b/inc/customizer.php index 25a9edb..46ee949 100644 --- a/inc/customizer.php +++ b/inc/customizer.php @@ -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' ); /** diff --git a/inc/deprecated.php b/inc/deprecated.php index b9a5db6..6ccabb5 100644 --- a/inc/deprecated.php +++ b/inc/deprecated.php @@ -21,26 +21,26 @@ if ( ! function_exists( 'understrap_slbd_count_widgets' ) ) { // to see if wp_convert_widget_settings() has made manipulations in memory. global $_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; $sidebars_widgets_count = $_wp_sidebars_widgets; 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 ] ); - if ( 0 == $widget_count % 4 || $widget_count > 6 ) : - // Four widgets per row if there are exactly four or more than six + 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. $widget_classes .= ' col-md-3'; - elseif ( 6 == $widget_count ) : - // If two widgets are published + elseif ( 6 == $widget_count ) : // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison + // If two widgets are published. $widget_classes .= ' col-md-2'; 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'; - elseif ( 2 == $widget_count ) : - // If two widgets are published + elseif ( 2 == $widget_count ) : // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison + // If two widgets are published. $widget_classes .= ' col-md-6'; - elseif ( 1 == $widget_count ) : - // If just on widget is active + elseif ( 1 == $widget_count ) : // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison + // If just on widget is active. $widget_classes .= ' col-md-12'; endif; return $widget_classes; diff --git a/inc/editor.php b/inc/editor.php index f3c6599..c46fb61 100644 --- a/inc/editor.php +++ b/inc/editor.php @@ -24,7 +24,7 @@ add_filter( 'mce_buttons_2', 'understrap_tiny_mce_style_formats' ); if ( ! function_exists( 'understrap_tiny_mce_style_formats' ) ) { /** * Reveals TinyMCE's hidden Style dropdown. - * + * * @param array $buttons Array of Tiny MCE's button ids. * @return array */ diff --git a/inc/enqueue.php b/inc/enqueue.php index fdb6921..8bcc6ce 100644 --- a/inc/enqueue.php +++ b/inc/enqueue.php @@ -28,6 +28,6 @@ if ( ! function_exists( 'understrap_scripts' ) ) { wp_enqueue_script( 'comment-reply' ); } } -} // endif function_exists( 'understrap_scripts' ). +} // End of if function_exists( 'understrap_scripts' ). add_action( 'wp_enqueue_scripts', 'understrap_scripts' ); diff --git a/inc/extras.php b/inc/extras.php index 893e251..e1a76fd 100644 --- a/inc/extras.php +++ b/inc/extras.php @@ -48,7 +48,7 @@ if ( ! function_exists( 'understrap_adjust_body_class' ) ) { function understrap_adjust_body_class( $classes ) { foreach ( $classes as $key => $value ) { - if ( 'tag' == $value ) { + if ( 'tag' === $value ) { unset( $classes[ $key ] ); } } @@ -67,7 +67,7 @@ if ( ! function_exists( 'understrap_change_logo_class' ) ) { * * @param string $html Markup. * - * @return mixed + * @return string */ function understrap_change_logo_class( $html ) { @@ -79,11 +79,10 @@ if ( ! function_exists( 'understrap_change_logo_class' ) ) { } } -/** - * Display navigation to next/previous post when applicable. - */ - if ( ! function_exists( 'understrap_post_nav' ) ) { + /** + * Display navigation to next/previous post when applicable. + */ function understrap_post_nav() { // Don't print empty markup if there's nowhere to navigate. $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true ); @@ -148,3 +147,108 @@ if ( ! function_exists( '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' ). diff --git a/inc/hooks.php b/inc/hooks.php index a3f854d..f91daee 100644 --- a/inc/hooks.php +++ b/inc/hooks.php @@ -29,23 +29,23 @@ if ( ! function_exists( 'understrap_add_site_info' ) ) { '%2$s | %3$s(%4$s)', esc_url( __( 'http://wordpress.org/', 'understrap' ) ), sprintf( - /* translators:*/ + /* translators: WordPress */ esc_html__( 'Proudly powered by %s', 'understrap' ), 'WordPress' ), sprintf( // WPCS: XSS ok. - /* translators:*/ + /* translators: 1: Theme name, 2: Theme author */ esc_html__( 'Theme: %1$s by %2$s.', 'understrap' ), $the_theme->get( 'Name' ), 'understrap.com' ), sprintf( // WPCS: XSS ok. - /* translators:*/ + /* translators: Theme version */ esc_html__( 'Version: %1$s', 'understrap' ), $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 } } diff --git a/inc/jetpack.php b/inc/jetpack.php index f91982f..5d60333 100644 --- a/inc/jetpack.php +++ b/inc/jetpack.php @@ -10,16 +10,16 @@ // Exit if accessed directly. 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' ); 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() { // Add theme support for Infinite Scroll. add_theme_support( @@ -34,18 +34,16 @@ if ( ! function_exists( 'understrap_components_jetpack_setup' ) ) { // Add theme support for 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' ); } } - -/** - * Custom render function for Infinite Scroll. - */ - if ( ! function_exists( 'understrap_components_infinite_scroll_render' ) ) { + /** + * Custom render function for Infinite Scroll. + */ function understrap_components_infinite_scroll_render() { while ( have_posts() ) { the_post(); @@ -59,8 +57,13 @@ if ( ! function_exists( 'understrap_components_infinite_scroll_render' ) ) { } if ( ! function_exists( 'understrap_components_social_menu' ) ) { + /** + * Display Jetpack's social menu if available. + * Avoids fatal errors if Jetpack isn’t activated. + */ function understrap_components_social_menu() { if ( ! function_exists( 'jetpack_social_menu' ) ) { + // Return early if social menu is not available. return; } else { jetpack_social_menu(); diff --git a/inc/pagination.php b/inc/pagination.php index 1bfbcbb..7f5f212 100644 --- a/inc/pagination.php +++ b/inc/pagination.php @@ -77,7 +77,7 @@ if ( ! function_exists( 'understrap_pagination' ) ) { foreach ( $links as $key => $link ) { ?>
  • - +
  • __( 'Primary Menu', 'understrap' ), - ) ); + register_nav_menus( + array( + 'primary' => __( 'Primary Menu', 'understrap' ), + ) + ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ - add_theme_support( 'html5', array( - 'search-form', - 'comment-form', - 'comment-list', - 'gallery', - 'caption', - ) ); + add_theme_support( + 'html5', + array( + 'search-form', + 'comment-form', + 'comment-list', + 'gallery', + 'caption', + ) + ); /* * Adding Thumbnail basic support @@ -74,19 +79,28 @@ if ( ! function_exists( 'understrap_setup' ) ) { * Enable support for Post Formats. * See http://codex.wordpress.org/Post_Formats */ - add_theme_support( 'post-formats', array( - 'aside', - 'image', - 'video', - 'quote', - 'link', - ) ); + add_theme_support( + 'post-formats', + array( + 'aside', + 'image', + 'video', + 'quote', + 'link', + ) + ); // Set up the WordPress core custom background feature. - add_theme_support( 'custom-background', apply_filters( 'understrap_custom_background_args', array( - 'default-color' => 'ffffff', - 'default-image' => '', - ) ) ); + add_theme_support( + 'custom-background', + apply_filters( + 'understrap_custom_background_args', + array( + 'default-color' => 'ffffff', + 'default-image' => '', + ) + ) + ); // Set up the WordPress Theme logo feature. 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 ) { if ( ! is_admin() ) { - $post_excerpt = $post_excerpt . ' [...]

    ' . __( 'Read More...', - 'understrap' ) . '

    '; + $post_excerpt = $post_excerpt . ' [...]

    ' . __( + 'Read More...', + 'understrap' + ) . '

    '; } return $post_excerpt; } diff --git a/inc/template-tags.php b/inc/template-tags.php index e8bba11..ef8a4ae 100644 --- a/inc/template-tags.php +++ b/inc/template-tags.php @@ -10,23 +10,25 @@ // Exit if accessed directly. defined( 'ABSPATH' ) || exit; -/** - * Prints HTML with meta information for the current post-date/time and author. - */ if ( ! function_exists( 'understrap_posted_on' ) ) { + /** + * Prints HTML with meta information for the current post-date/time and author. + */ function understrap_posted_on() { $time_string = ''; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = ''; } - $time_string = sprintf( $time_string, + $time_string = sprintf( + $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); $posted_on = apply_filters( - 'understrap_posted_on', sprintf( + 'understrap_posted_on', + sprintf( '%1$s %3$s', esc_html_x( 'Posted on', 'post date', 'understrap' ), esc_url( get_permalink() ), @@ -34,21 +36,22 @@ if ( ! function_exists( 'understrap_posted_on' ) ) { ) ); $byline = apply_filters( - 'understrap_posted_by', sprintf( + 'understrap_posted_by', + sprintf( ' %1$s %3$s', $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_html( get_the_author() ) ) ); - echo $posted_on . $byline; // WPCS: XSS OK. + echo $posted_on . $byline; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } -/** - * Prints HTML with meta information for the categories, tags and comments. - */ if ( ! function_exists( 'understrap_entry_footer' ) ) { + /** + * Prints HTML with meta information for the categories, tags and comments. + */ function understrap_entry_footer() { // Hide category and tag text for pages. if ( 'post' === get_post_type() ) { @@ -56,13 +59,13 @@ if ( ! function_exists( 'understrap_entry_footer' ) ) { $categories_list = get_the_category_list( esc_html__( ', ', 'understrap' ) ); if ( $categories_list && understrap_categorized_blog() ) { /* translators: %s: Categories of current post */ - printf( '' . esc_html__( 'Posted in %s', 'understrap' ) . '', $categories_list ); // WPCS: XSS OK. + printf( '' . esc_html__( 'Posted in %s', 'understrap' ) . '', $categories_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } /* translators: used between list items, there is a space after the comma */ $tags_list = get_the_tag_list( '', esc_html__( ', ', 'understrap' ) ); if ( $tags_list ) { /* translators: %s: Tags of current post */ - printf( '' . esc_html__( 'Tagged %s', 'understrap' ) . '', $tags_list ); // WPCS: XSS OK. + printf( '' . esc_html__( 'Tagged %s', 'understrap' ) . '', $tags_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { @@ -82,21 +85,24 @@ if ( ! function_exists( 'understrap_entry_footer' ) ) { } } -/** - * Returns true if a blog has more than 1 category. - * - * @return bool - */ if ( ! function_exists( 'understrap_categorized_blog' ) ) { + /** + * Returns true if a blog has more than 1 category. + * + * @return bool + */ 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. - $all_the_cool_cats = get_categories( array( - 'fields' => 'ids', - 'hide_empty' => 1, - // We only need to know if there is more than one category. - 'number' => 2, - ) ); + $all_the_cool_cats = get_categories( + array( + 'fields' => 'ids', + 'hide_empty' => 1, + // We only need to know if there is more than one category. + 'number' => 2, + ) + ); // Count the number of categories that are attached to the posts. $all_the_cool_cats = count( $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( 'save_post', 'understrap_category_transient_flusher' ); +add_action( 'save_post', '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() { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; diff --git a/inc/widgets.php b/inc/widgets.php index b386a2a..f8a6842 100644 --- a/inc/widgets.php +++ b/inc/widgets.php @@ -17,6 +17,7 @@ defined( 'ABSPATH' ) || exit; add_filter( 'dynamic_sidebar_params', 'understrap_widget_classes' ); if ( ! function_exists( 'understrap_widget_classes' ) ) { + /** * 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. @@ -24,6 +25,8 @@ if ( ! function_exists( 'understrap_widget_classes' ) ) { * @global array $sidebars_widgets * * @param array $params { + * Parameters passed to a widget’s display callback. + * * @type array $args { * An array of widget display arguments. * @@ -86,7 +89,7 @@ if ( ! function_exists( 'understrap_widget_classes' ) ) { return $params; } -} // endif function_exists( 'understrap_widget_classes' ). +} // End of if function_exists( 'understrap_widget_classes' ). 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' ). diff --git a/inc/woocommerce.php b/inc/woocommerce.php index fe284d2..40c451b 100644 --- a/inc/woocommerce.php +++ b/inc/woocommerce.php @@ -26,18 +26,18 @@ if ( ! function_exists( 'understrap_woocommerce_support' ) ) { } } -/** - * First unhook the WooCommerce wrappers - */ +// First unhook the WooCommerce content wrappers. remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 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_after_main_content', 'understrap_woocommerce_wrapper_end', 10 ); + if ( ! function_exists( 'understrap_woocommerce_wrapper_start' ) ) { + /** + * Display the theme specific start of the page wrapper. + */ function understrap_woocommerce_wrapper_start() { $container = get_theme_mod( 'understrap_container_type' ); echo '
    '; @@ -47,7 +47,11 @@ if ( ! function_exists( 'understrap_woocommerce_wrapper_start' ) ) { echo '
    '; } } + if ( ! function_exists( 'understrap_woocommerce_wrapper_end' ) ) { + /** + * Display the theme specific end of the page wrapper. + */ function understrap_woocommerce_wrapper_end() { echo '
    '; get_template_part( 'global-templates/right-sidebar-check' ); @@ -57,18 +61,17 @@ if ( ! function_exists( 'understrap_woocommerce_wrapper_end' ) ) { } } - -/** - * Filter hook function monkey patching form classes - * Author: Adriano Monecchi http://stackoverflow.com/a/36724593/307826 - * - * @param string $args Form attributes. - * @param string $key Not in use. - * @param null $value Not in use. - * - * @return mixed - */ if ( ! function_exists( 'understrap_wc_form_field_args' ) ) { + /** + * Filter hook function monkey patching form classes + * Author: Adriano Monecchi http://stackoverflow.com/a/36724593/307826 + * + * @param string $args Form attributes. + * @param string $key Not in use. + * @param null $value Not in use. + * + * @return mixed + */ function understrap_wc_form_field_args( $args, $key, $value = null ) { // Start field type switch case. switch ( $args['type'] ) { @@ -133,7 +136,7 @@ if ( ! function_exists( 'understrap_wc_form_field_args' ) ) { $args['input_class'] = array( 'form-control', 'input-lg' ); $args['label_class'] = array( 'control-label' ); break; - } // end switch ($args). + } // End of switch ( $args ). return $args; } } diff --git a/inc/wpcom.php b/inc/wpcom.php index 4f40f01..7a30ecb 100644 --- a/inc/wpcom.php +++ b/inc/wpcom.php @@ -10,14 +10,14 @@ // Exit if accessed directly. defined( 'ABSPATH' ) || exit; -/** - * Adds support for wp.com-specific theme functions. - * - * @global array $themecolors - */ add_action( 'after_setup_theme', 'understrap_wpcom_setup' ); if ( ! function_exists( 'understrap_wpcom_setup' ) ) { + /** + * Adds support for wp.com-specific theme functions. + * + * @global array $themecolors + */ function understrap_wpcom_setup() { global $themecolors; @@ -37,13 +37,12 @@ if ( ! function_exists( 'understrap_wpcom_setup' ) ) { } } - -/* - * WordPress.com-specific styles - */ add_action( 'wp_enqueue_scripts', 'understrap_wpcom_styles' ); if ( ! function_exists( 'understrap_wpcom_styles' ) ) { + /** + * WordPress.com-specific styles + */ function understrap_wpcom_styles() { wp_enqueue_style( 'understrap-wpcom', get_template_directory_uri() . '/inc/style-wpcom.css', array(), '20160411' ); } diff --git a/index.php b/index.php index f10d4c7..6de21f7 100644 --- a/index.php +++ b/index.php @@ -34,13 +34,11 @@ $container = get_theme_mod( 'understrap_container_type' );
    - - - - - - - - - - - - - - - + } + } else { + get_template_part( 'loop-templates/content', 'none' ); + } + ?>
    @@ -72,4 +66,5 @@ $container = get_theme_mod( 'understrap_container_type' );
    - + if ( is_home() && current_user_can( 'publish_posts' ) ) : -

    Get started here.', 'understrap' ), array( - 'a' => array( - 'href' => array(), - ), -) ), esc_url( admin_url( 'post-new.php' ) ) ); ?>

    + $kses = array( 'a' => array( 'href' => array() ) ); + printf( + /* translators: 1: Link to WP admin new post page. */ + '

    ' . wp_kses( __( 'Ready to publish your first post? Get started here.', 'understrap' ), $kses ) . '

    ', + esc_url( admin_url( 'post-new.php' ) ) + ); - + elseif ( is_search() ) : -

    - + printf( + '

    %s

    ', + esc_html__( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'understrap' ) + ); + get_search_form(); -

    - + else : + + printf( + '

    %s

    ', + esc_html__( 'It seems we can’t find what you’re looking for. Perhaps searching can help.', 'understrap' ) + ); + get_search_form(); + + endif; + ?> diff --git a/loop-templates/content-search.php b/loop-templates/content-search.php index 48d25b9..71cf4af 100644 --- a/loop-templates/content-search.php +++ b/loop-templates/content-search.php @@ -20,7 +20,7 @@ defined( 'ABSPATH' ) || exit; ); ?> - +

    diff --git a/loop-templates/content.php b/loop-templates/content.php index 1bc0864..29bdc53 100644 --- a/loop-templates/content.php +++ b/loop-templates/content.php @@ -20,7 +20,7 @@ defined( 'ABSPATH' ) || exit; ); ?> - +
    diff --git a/page-templates/blank.php b/page-templates/blank.php index cb58a77..329305e 100644 --- a/page-templates/blank.php +++ b/page-templates/blank.php @@ -20,11 +20,12 @@ defined( 'ABSPATH' ) || exit; - - - - - - + diff --git a/page-templates/both-sidebarspage.php b/page-templates/both-sidebarspage.php index 8a79321..8f5677c 100644 --- a/page-templates/both-sidebarspage.php +++ b/page-templates/both-sidebarspage.php @@ -20,30 +20,33 @@ $container = get_theme_mod( 'understrap_container_type' );
    - + col-md-8col-md-4col-md-12 content-area" - id="primary"> + if ( is_active_sidebar( 'left-sidebar' ) xor is_active_sidebar( 'right-sidebar' ) ) { + $class = 'col-md-8'; + } elseif ( is_active_sidebar( 'left-sidebar' ) && is_active_sidebar( 'right-sidebar' ) ) { + $class = 'col-md-4'; + } else { + $class = 'col-md-12'; + } + ?> +
    - + + get_template_part( 'loop-templates/content', 'page' ); - - - + } + } + ?>
    @@ -57,4 +60,5 @@ $container = get_theme_mod( 'understrap_container_type' );
    - - - - - -
    @@ -29,18 +28,17 @@ $container = get_theme_mod( 'understrap_container_type' );
    - + - - - - + } + } + ?>
    @@ -52,4 +50,5 @@ $container = get_theme_mod( 'understrap_container_type' );
    - -
    +
    - + + get_template_part( 'loop-templates/content', 'page' ); - - - + } + } + ?>
    @@ -51,4 +49,5 @@ $container = get_theme_mod( 'understrap_container_type' );
    - -
    +
    - + + get_template_part( 'loop-templates/content', 'page' ); - - - + } + } + ?>
    @@ -51,4 +49,5 @@ $container = get_theme_mod( 'understrap_container_type' );
    - - + - - - - + } + } + ?> @@ -54,4 +53,5 @@ $container = get_theme_mod( 'understrap_container_type' );
    - - - A custom set of code standard rules for UnderStrap. + Apply WordPress Coding Standards to UnderStrap + + + + + + + + + @@ -13,44 +21,16 @@ - - - . - - */vendor/* - */node_modules/* + + /vendor/* + /node_modules/* + /dist/* - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + * + + + + + /inc/class-wp-bootstrap-navwalker\.php + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + *\.php$ - diff --git a/search.php b/search.php index 728fc44..dd3a1ec 100644 --- a/search.php +++ b/search.php @@ -42,18 +42,18 @@ $container = get_theme_mod( 'understrap_container_type' ); - + - - + endwhile; + ?> @@ -75,4 +75,5 @@ $container = get_theme_mod( 'understrap_container_type' );
    - - - - +if ( is_active_sidebar( 'herocanvas' ) ) { - + dynamic_sidebar( 'herocanvas' ); - - - - - + - - - - - - + } + } + ?> @@ -49,4 +47,5 @@ $container = get_theme_mod( 'understrap_container_type' );
    - 0 ) : ?> +if ( wc_get_page_id( 'shop' ) > 0 ) : + ?>

    - $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key ); if ( ! $product_permalink ) { - echo $thumbnail; // PHPCS: XSS ok. + echo $thumbnail; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } else { - printf( '%s', esc_url( $product_permalink ), $thumbnail ); // PHPCS: XSS ok. + printf( '%s', esc_url( $product_permalink ), $thumbnail ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } ?> @@ -85,7 +85,7 @@ do_action( 'woocommerce_before_cart' ); ?> do_action( 'woocommerce_after_cart_item_name', $cart_item, $cart_item_key ); // 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. if ( $_product->backorders_require_notification() && $_product->is_on_backorder( $cart_item['quantity'] ) ) { @@ -96,7 +96,7 @@ do_action( 'woocommerce_before_cart' ); ?> 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 ?> @@ -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 ?> 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 ?> @@ -173,4 +173,5 @@ do_action( 'woocommerce_before_cart' ); ?> ?>
    - + - + - + diff --git a/woocommerce/checkout/form-checkout.php b/woocommerce/checkout/form-checkout.php index 15beffb..8c2cd1f 100644 --- a/woocommerce/checkout/form-checkout.php +++ b/woocommerce/checkout/form-checkout.php @@ -61,4 +61,5 @@ if ( ! $checkout->is_registration_enabled() && $checkout->is_registration_requir -get_order_item_totals(); +$item_totals = $order->get_order_item_totals(); ?>
    @@ -56,8 +56,8 @@ $totals = $order->get_order_item_totals(); - - + + diff --git a/woocommerce/global/form-login.php b/woocommerce/global/form-login.php index 6523868..0172de8 100644 --- a/woocommerce/global/form-login.php +++ b/woocommerce/global/form-login.php @@ -10,10 +10,9 @@ * happen. When this occurs the version of the template file will be bumped and * the readme will list any important changes. * - * @see https://docs.woocommerce.com/document/template-structure/ - * @package WooCommerce/Templates - - * @version 3.6.1 + * @see https://docs.woocommerce.com/document/template-structure/ + * @package WooCommerce/Templates + * @version 3.6.1 */ // Exit if accessed directly. @@ -47,7 +46,7 @@ if ( is_user_logged_in() ) { - +

    diff --git a/woocommerce/loop/add-to-cart.php b/woocommerce/loop/add-to-cart.php index ecd9133..aa12ef1 100644 --- a/woocommerce/loop/add-to-cart.php +++ b/woocommerce/loop/add-to-cart.php @@ -10,10 +10,10 @@ * happen. When this occurs the version of the template file will be bumped and * the readme will list any important changes. * - * @see https://docs.woocommerce.com/document/template-structure/ - * @author WooThemes - * @package WooCommerce/Templates - * @version 3.6.1 + * @see https://docs.woocommerce.com/document/template-structure/ + * @author WooThemes + * @package WooCommerce/Templates + * @version 3.6.1 */ if ( ! defined( 'ABSPATH' ) ) { @@ -22,14 +22,18 @@ if ( ! defined( 'ABSPATH' ) ) { global $product; -echo apply_filters( 'woocommerce_loop_add_to_cart_link', // WPCS: XSS ok. - sprintf( '', +echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + 'woocommerce_loop_add_to_cart_link', + sprintf( + '', esc_url( $product->add_to_cart_url() ), esc_attr( isset( $args['quantity'] ) ? $args['quantity'] : 1 ), $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '', 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'] ) : '', esc_html( $product->add_to_cart_text() ) ), -$product, $args ); + $product, + $args +); diff --git a/woocommerce/loop/orderby.php b/woocommerce/loop/orderby.php index b31a8b6..09be8b0 100644 --- a/woocommerce/loop/orderby.php +++ b/woocommerce/loop/orderby.php @@ -10,9 +10,9 @@ * happen. When this occurs the version of the template file will be bumped and * the readme will list any important changes. * - * @see https://docs.woocommerce.com/document/template-structure/ - * @package WooCommerce/Templates - * @version 3.6.1 + * @see https://docs.woocommerce.com/document/template-structure/ + * @package WooCommerce/Templates + * @version 3.6.1 */ if ( ! defined( 'ABSPATH' ) ) { @@ -22,8 +22,8 @@ if ( ! defined( 'ABSPATH' ) ) { ?> diff --git a/woocommerce/myaccount/downloads.php b/woocommerce/myaccount/downloads.php index 0feac83..0f9cdb5 100644 --- a/woocommerce/myaccount/downloads.php +++ b/woocommerce/myaccount/downloads.php @@ -12,7 +12,7 @@ * happen. When this occurs the version of the template file will be bumped and * the readme will list any important changes. * - * @see https://docs.woocommerce.com/document/template-structure/ + * @see https://docs.woocommerce.com/document/template-structure/ * @author WooThemes * @package WooCommerce/Templates * @version 3.6.1 @@ -38,10 +38,11 @@ do_action( 'woocommerce_before_account_downloads', $has_downloads ); ?> -
    - -
    - __( 'Billing address', 'understrap' ), - 'shipping' => __( 'Shipping address', 'understrap' ), - ), $customer_id ); + $get_addresses = apply_filters( + 'woocommerce_my_account_get_addresses', + array( + 'billing' => __( 'Billing address', 'understrap' ), + 'shipping' => __( 'Shipping address', 'understrap' ), + ), + $customer_id + ); } else { - $get_addresses = apply_filters( 'woocommerce_my_account_get_addresses', array( - 'billing' => __( 'Billing address', 'understrap' ), - ), $customer_id ); + $get_addresses = apply_filters( + 'woocommerce_my_account_get_addresses', + array( + 'billing' => __( 'Billing address', 'understrap' ), + ), + $customer_id + ); } $oldcol = 1; @@ -38,28 +46,31 @@ $col = 1; ?>

    - +

    - $title ) : ?> + $address_title ) : ?>
    -

    - +

    +
    -
    +
    + ?> +
    - __( 'Order', 'understrap' ), - 'order-date' => __( 'Date', 'understrap' ), - 'order-status' => __( 'Status', 'understrap' ), - 'order-total' => __( 'Total', 'understrap' ), - 'order-actions' => ' ', -) ); +$my_orders_columns = apply_filters( + 'woocommerce_my_account_my_orders_columns', + array( + 'order-number' => esc_html__( 'Order', 'understrap' ), + 'order-date' => esc_html__( 'Date', 'understrap' ), + 'order-status' => esc_html__( 'Status', 'understrap' ), + 'order-total' => esc_html__( 'Total', 'understrap' ), + 'order-actions' => ' ', + ) +); -$customer_orders = get_posts( apply_filters( 'woocommerce_my_account_my_orders_query', array( - 'numberposts' => $order_count, - 'meta_key' => '_customer_user', - 'meta_value' => get_current_user_id(), - 'post_type' => wc_get_order_types( 'view-orders' ), - 'post_status' => array_keys( wc_get_order_statuses() ), -) ) ); +$customer_orders = get_posts( + apply_filters( + 'woocommerce_my_account_my_orders_query', + array( + 'numberposts' => $order_count, + 'meta_key' => '_customer_user', // phpcs:ignore WordPress.DB.SlowDBQuery + 'meta_value' => get_current_user_id(), // phpcs:ignore WordPress.DB.SlowDBQuery + 'post_type' => wc_get_order_types( 'view-orders' ), + 'post_status' => array_keys( wc_get_order_statuses() ), + ) + ) +); if ( $customer_orders ) : ?> -

    +

    @@ -40,8 +49,9 @@ if ( $customer_orders ) : ?> - get_item_count(); ?> @@ -52,7 +62,7 @@ if ( $customer_orders ) : ?> - get_order_number(); ?> + get_order_number(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> @@ -64,16 +74,16 @@ if ( $customer_orders ) : ?> 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 ?> $action ) { - echo '' . esc_html( $action['name'] ) . ''; + if ( ! empty( $orders_actions ) ) { + foreach ( $orders_actions as $key => $orders_action ) { + echo '' . esc_html( $orders_action['name'] ) . ''; } } ?> @@ -84,4 +94,5 @@ if ( $customer_orders ) : ?>
    - $label ) : ?> + class="list-group-item list-group-item-action">
    - 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(); ?> @@ -63,11 +63,11 @@ do_action( 'woocommerce_before_account_orders', $has_orders ); ?> $action ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited - echo '' . esc_html( $action['name'] ) . ''; + if ( ! empty( $orders_actions ) ) { + foreach ( $orders_actions as $key => $orders_action ) { + echo '' . esc_html( $orders_action['name'] ) . ''; } } ?> @@ -104,4 +104,5 @@ do_action( 'woocommerce_before_account_orders', $has_orders ); ?> - +is_purchasable() ) { 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() ) : ?> @@ -35,11 +35,13 @@ if ( $product->is_in_stock() ) : ?> 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 ), - 'input_value' => isset( $_POST['quantity'] ) ? wc_stock_amount( wp_unslash( $_POST['quantity'] ) ) : $product->get_min_purchase_quantity(), // WPCS: CSRF ok, input var ok. - ) ); + woocommerce_quantity_input( + array( + '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 ), + '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' ); ?> @@ -51,4 +53,5 @@ if ( $product->is_in_stock() ) : ?> - 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 ), - 'input_value' => isset( $_POST['quantity'] ) ? wc_stock_amount( wp_unslash( $_POST['quantity'] ) ) : $product->get_min_purchase_quantity(), // WPCS: CSRF ok, input var ok. - ) ); + woocommerce_quantity_input( + array( + '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 ), + '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' ); ?>