From 74b1de172265e911847ccf3c00ab9863ac19ba81 Mon Sep 17 00:00:00 2001
From: Stef Kariotidis
Date: Mon, 21 Nov 2016 19:12:36 +0200
Subject: [PATCH] coding standards part 1
---
inc/bootstrap-wp-gallery.php | 146 ++++++++++++++++++++++++++++
inc/customizer.php | 34 ++++---
inc/enqueue.php | 48 ++++++----
inc/extras.php | 59 ++++++++----
inc/jetpack.php | 27 +++---
inc/security.php | 52 ++++++----
inc/setup.php | 179 +++++++++++++++++++----------------
inc/template-tags.php | 123 ++++++++++++------------
inc/theme-settings.php | 1 -
inc/utilities.php | 8 +-
inc/widgets.php | 7 +-
inc/woocommerce.php | 19 ++--
inc/wpcom.php | 12 +--
13 files changed, 465 insertions(+), 250 deletions(-)
create mode 100644 inc/bootstrap-wp-gallery.php
diff --git a/inc/bootstrap-wp-gallery.php b/inc/bootstrap-wp-gallery.php
new file mode 100644
index 0000000..e8c119c
--- /dev/null
+++ b/inc/bootstrap-wp-gallery.php
@@ -0,0 +1,146 @@
+ 'ASC',
+ 'orderby' => 'menu_order ID',
+ 'id' => $post->ID,
+ 'itemtag' => '',
+ 'icontag' => '',
+ 'captiontag' => '',
+ 'columns' => 3,
+ 'size' => 'thumbnail',
+ 'include' => '',
+ 'exclude' => '',
+ 'link' => '',
+ ], $attr ) );
+ $id = intval( $id );
+ $columns = ( 12 % $columns == 0 ) ? $columns : 3;
+ $grid = sprintf( 'col-sm-%1$s col-lg-%1$s', 12 / $columns );
+ if ( $order === 'RAND' ) {
+ $orderby = 'none';
+ }
+ if ( ! empty( $include ) ) {
+ $_attachments = get_posts( [
+ 'include' => $include,
+ 'post_status' => 'inherit',
+ 'post_type' => 'attachment',
+ 'post_mime_type' => 'image',
+ 'order' => $order,
+ 'orderby' => $orderby
+ ] );
+ $attachments = [];
+ foreach ( $_attachments as $key => $val ) {
+ $attachments[ $val->ID ] = $_attachments[ $key ];
+ }
+ } elseif ( ! empty( $exclude ) ) {
+ $attachments = get_children( [
+ 'post_parent' => $id,
+ 'exclude' => $exclude,
+ 'post_status' => 'inherit',
+ 'post_type' => 'attachment',
+ 'post_mime_type' => 'image',
+ 'order' => $order,
+ 'orderby' => $orderby
+ ] );
+ } else {
+ $attachments = get_children( [
+ 'post_parent' => $id,
+ 'post_status' => 'inherit',
+ 'post_type' => 'attachment',
+ 'post_mime_type' => 'image',
+ 'order' => $order,
+ 'orderby' => $orderby
+ ] );
+ }
+ if ( empty( $attachments ) ) {
+ return '';
+ }
+ if ( is_feed() ) {
+ $output = "\n";
+ foreach ( $attachments as $att_id => $attachment ) {
+ $output .= wp_get_attachment_link( $att_id, $size, true ) . "\n";
+ }
+
+ return $output;
+ }
+ $unique = ( get_query_var( 'page' ) ) ? $instance . '-p' . get_query_var( 'page' ) : $instance;
+ $output = '';
+ $i = 0;
+ foreach ( $attachments as $id => $attachment ) {
+ switch ( $link ) {
+ case 'file':
+ $image = wp_get_attachment_link( $id, $size, false, false );
+ break;
+ case 'none':
+ $image = wp_get_attachment_image( $id, $size, false, [ 'class' => 'thumbnail img-thumbnail' ] );
+ break;
+ default:
+ $image = wp_get_attachment_link( $id, $size, true, false );
+ break;
+ }
+ $output .= ( $i % $columns == 0 ) ? '
' : '';
+ $output .= '
' . $image;
+ if ( trim( $attachment->post_excerpt ) ) {
+ $output .= '
' . wptexturize( $attachment->post_excerpt ) . '
';
+ }
+ $output .= '
';
+ $i ++;
+ $output .= ( $i % $columns == 0 ) ? '
' : '';
+ }
+ $output .= ( $i % $columns != 0 ) ? '
' : '';
+ $output .= '';
+
+ return $output;
+}
+
+add_shortcode( 'gallery', 'shortcode_gallery' );
+
+/**
+ * Add class="thumbnail img-thumbnail" to attachment items
+ *
+ * @param string $html Markup.
+ *
+ * @return mixed
+ */
+function attachment_link_class( $html ) {
+ $html = str_replace( ' __( 'Sidebar Positioning', 'understrap' ),
'description' => __( "Set sidebar's position. Can either be: right, left, both or none",
- 'understrap' ),
+ 'understrap' ),
'section' => 'understrap_theme_layout_options',
'settings' => 'understrap_sidebar_position',
'type' => 'select',
@@ -156,7 +156,7 @@ if ( ! function_exists( 'understrap_theme_customize_register' ) ) {
'choices' => array(
'default' => __( 'Default', 'understrap' ),
'masonry' => __( 'Masonry', 'understrap' ),
- 'grid' => __( 'Grid', 'understrap' ),
+ 'grid' => __( 'Grid', 'understrap' ),
),
'priority' => '30',
)
@@ -165,19 +165,20 @@ if ( ! function_exists( 'understrap_theme_customize_register' ) ) {
// Columns setup for grid posts.
/**
* Function and callback to check when grid is enabled.
+ *
* @return bool
*/
- function is_grid_enabled ()
- {
+ function is_grid_enabled() {
return 'grid' == get_theme_mod( 'understrap_posts_index_style' );
}
+
if ( is_grid_enabled() ) {
- // How many columns to use each grid post
+ // How many columns to use each grid post.
$wp_customize->add_setting( 'understrap_grid_post_columns', array(
'default' => '6',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
- 'transport' => 'refresh',
+ 'transport' => 'refresh',
) );
$wp_customize->add_control(
@@ -185,28 +186,28 @@ if ( ! function_exists( 'understrap_theme_customize_register' ) ) {
$wp_customize,
'understrap_grid_post_columns', array(
'label' => __( 'Grid Post Columns', 'understrap' ),
- 'description' => __( "Choose how many columns to use in grid posts", 'understrap' ),
+ 'description' => __( 'Choose how many columns to use in grid posts', 'understrap' ),
'section' => 'understrap_theme_layout_options',
'settings' => 'understrap_grid_post_columns',
'type' => 'select',
'choices' => array(
- '6' => '6',
- '4' => '4',
- '3' => '3',
- '2' => '2',
- '1' => '1',
+ '6' => '6',
+ '4' => '4',
+ '3' => '3',
+ '2' => '2',
+ '1' => '1',
),
- 'default' => 6,
+ 'default' => 6,
'priority' => '30',
'transport' => 'refresh',
)
) );
}
- // hook to auto-hide/show depending the understrap_posts_index_style option
+ // hook to auto-hide/show depending the understrap_posts_index_style option.
$wp_customize->get_control( 'understrap_grid_post_columns' )->active_callback = 'is_grid_enabled';
}
-}
+} // endif function_exists( 'understrap_theme_customize_register' ).
add_action( 'customize_register', 'understrap_theme_customize_register' );
@@ -214,6 +215,9 @@ add_action( 'customize_register', 'understrap_theme_customize_register' );
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
*/
if ( ! function_exists( 'understrap_customize_preview_js' ) ) {
+ /**
+ * Setup JS integration for live previewing.
+ */
function understrap_customize_preview_js() {
wp_enqueue_script( 'understrap_customizer', get_template_directory_uri() . '/js/customizer.js',
array( 'customize-preview' ), '20130508', true );
diff --git a/inc/enqueue.php b/inc/enqueue.php
index ad97456..e96067c 100644
--- a/inc/enqueue.php
+++ b/inc/enqueue.php
@@ -1,15 +1,20 @@
$page_for_posts,
'homeUrl' => $home_url,
- 'isSingle' => $is_single
+ 'isSingle' => $is_single,
);
wp_localize_script( 'vertical-one-page', 'vars', $vars );
}
- // menu - vertical page association end
+ // menu - vertical page association end.
}
-}
+} // endif function_exists( 'understrap_scripts' ).
add_action( 'wp_enqueue_scripts', 'understrap_scripts' );
/**
*Loading slider script conditionally
- **/
+ */
-if ( is_active_sidebar( 'hero' ) ):
- add_action( "wp_enqueue_scripts", "understrap_slider" );
+if ( is_active_sidebar( 'hero' ) ) :
+ add_action( 'wp_enqueue_scripts', 'understrap_slider' );
- if ( ! function_exists ( 'understrap_slider' ) ) {
+ if ( ! function_exists( 'understrap_slider' ) ) {
+ /**
+ * Setup slider.
+ */
function understrap_slider() {
if ( is_front_page() ) {
$data = array(
- "timeout" => intval( get_theme_mod( 'understrap_theme_slider_time_setting', 5000 ) ),
- "items" => intval( get_theme_mod( 'understrap_theme_slider_count_setting', 1 ) )
+ 'timeout' => intval( get_theme_mod( 'understrap_theme_slider_time_setting', 5000 ) ),
+ 'items' => intval( get_theme_mod( 'understrap_theme_slider_count_setting', 1 ) ),
);
- wp_enqueue_script( "understrap-slider-script", get_stylesheet_directory_uri() . '/js/slider_settings.js', array(), '0.4.9' );
- wp_localize_script( "understrap-slider-script", "understrap_slider_variables", $data );
+ wp_enqueue_script( 'understrap-slider-script',
+ get_stylesheet_directory_uri() . '/js/slider_settings.js', array(), '0.4.9' );
+ wp_localize_script( 'understrap-slider-script', 'understrap_slider_variables', $data );
}
}
}
diff --git a/inc/extras.php b/inc/extras.php
index 965926f..b64d1b0 100644
--- a/inc/extras.php
+++ b/inc/extras.php
@@ -6,14 +6,15 @@
*
* @package understrap
*/
-/**
- * Adds custom classes to the array of body classes.
- *
- * @param array $classes Classes for the body element.
- * @return array
- */
-if ( ! function_exists ( 'understrap_body_classes' ) ) {
+if ( ! function_exists( 'understrap_body_classes' ) ) {
+ /**
+ * Adds custom classes to the array of body classes.
+ *
+ * @param array $classes Classes for the body element.
+ *
+ * @return array
+ */
function understrap_body_classes( $classes ) {
// Adds a class of group-blog to blogs with more than 1 published author.
if ( is_multi_author() ) {
@@ -23,35 +24,51 @@ if ( ! function_exists ( 'understrap_body_classes' ) ) {
if ( ! is_singular() ) {
$classes[] = 'hfeed';
}
+
return $classes;
}
}
add_filter( 'body_class', 'understrap_body_classes' );
// Removes tag class from the body_class array to avoid Bootstrap markup styling issues.
-
add_filter( 'body_class', 'adjust_body_class' );
-if ( ! function_exists ( 'adjust_body_class' ) ) {
+if ( ! function_exists( 'adjust_body_class' ) ) {
+ /**
+ * Setup body classes.
+ *
+ * @param string $classes CSS classes.
+ *
+ * @return mixed
+ */
function adjust_body_class( $classes ) {
- foreach ( $classes as $key => $value ) {
- if ( $value == 'tag' ) unset( $classes[ $key ] );
- }
+ foreach ( $classes as $key => $value ) {
+ if ( $value == 'tag' ) {
+ unset( $classes[ $key ] );
+ }
+ }
- return $classes;
+ return $classes;
}
}
-// Filter custom logo with correct classes
-add_filter('get_custom_logo','change_logo_class');
+// Filter custom logo with correct classes.
+add_filter( 'get_custom_logo', 'change_logo_class' );
+
+if ( ! function_exists( 'change_logo_class' ) ) {
+ /**
+ * Replaces logo CSS class.
+ *
+ * @param string $html Markup.
+ *
+ * @return mixed
+ */
+ function change_logo_class( $html ) {
+ $html = str_replace( 'class="custom-logo"', 'class="img-responsive"', $html );
+ $html = str_replace( 'class="custom-logo-link"', 'class="navbar-brand custom-logo-link"', $html );
-if ( ! function_exists ( 'change_logo_class' ) ) {
- function change_logo_class($html)
- {
- $html = str_replace('class="custom-logo"', 'class="img-responsive"', $html);
- $html = str_replace('class="custom-logo-link"', 'class="navbar-brand custom-logo-link"', $html);
return $html;
}
-}
\ No newline at end of file
+}
diff --git a/inc/jetpack.php b/inc/jetpack.php
index 2586ade..2521630 100644
--- a/inc/jetpack.php
+++ b/inc/jetpack.php
@@ -6,13 +6,14 @@
*
* @package understrap
*/
-/**
- * Jetpack setup function.
- *
- * See: https://jetpack.com/support/infinite-scroll/
- * See: https://jetpack.com/support/responsive-videos/
- */
-if ( ! function_exists ( 'understrap_jetpack_setup' ) ) {
+
+if ( ! function_exists( 'understrap_jetpack_setup' ) ) {
+ /**
+ * Jetpack setup function.
+ *
+ * See: https://jetpack.com/support/infinite-scroll/
+ * See: https://jetpack.com/support/responsive-videos/
+ */
function understrap_jetpack_setup() {
// Add theme support for Infinite Scroll.
add_theme_support( 'infinite-scroll', array(
@@ -25,17 +26,17 @@ if ( ! function_exists ( 'understrap_jetpack_setup' ) ) {
}
}
add_action( 'after_setup_theme', 'understrap_jetpack_setup' );
-/**
- * Custom render function for Infinite Scroll.
- */
-if ( ! function_exists ( 'understrap_infinite_scroll_render' ) ) {
+if ( ! function_exists( 'understrap_infinite_scroll_render' ) ) {
+ /**
+ * Custom render function for Infinite Scroll.
+ */
function understrap_infinite_scroll_render() {
while ( have_posts() ) {
the_post();
if ( is_search() ) :
- get_template_part( 'loop-templates/content', 'search' );
+ get_template_part( 'loop-templates/content', 'search' );
else :
- get_template_part( 'loop-templates/content', get_post_format() );
+ get_template_part( 'loop-templates/content', get_post_format() );
endif;
}
}
diff --git a/inc/security.php b/inc/security.php
index b6ef516..2cbcd5a 100644
--- a/inc/security.php
+++ b/inc/security.php
@@ -1,29 +1,41 @@
ERROR: Stop guessing!";
+remove_action( 'wp_head', 'wp_generator' );
+remove_action( 'wp_head', 'rsd_link' );
+remove_action( 'wp_head', 'wlwmanifest_link' );
+remove_action( 'wp_head', 'index_rel_link' );
+remove_action( 'wp_head', 'feed_links', 2 );
+remove_action( 'wp_head', 'feed_links_extra', 3 );
+remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
+remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
+
+/**
+ * Show less info to users on failed login for security.
+ * (Will not let a valid username be known.)
+ *
+ * @return string
+ */
+function show_less_login_info() {
+ return 'ERROR: Stop guessing!';
}
+
add_filter( 'login_errors', 'show_less_login_info' );
diff --git a/inc/setup.php b/inc/setup.php
index e59573e..955d11a 100644
--- a/inc/setup.php
+++ b/inc/setup.php
@@ -1,112 +1,127 @@
tag in the document head, and expect WordPress to
- * provide it for us.
- */
- add_theme_support( 'title-tag' );
-
- /*
- * Enable support for Post Thumbnails on posts and pages.
+ /**
+ * Sets up theme defaults and registers support for various WordPress features.
*
- * @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
+ * Note that this function is hooked into the after_setup_theme hook, which
+ * runs before the init hook. The init hook is too late for some features, such
+ * as indicating support for post thumbnails.
*/
- //add_theme_support( 'post-thumbnails' );
+ function understrap_setup() {
+ /*
+ * Make theme available for translation.
+ * Translations can be filed in the /languages/ directory.
+ * If you're building a theme based on understrap, use a find and replace
+ * to change 'understrap' to the name of your theme in all the template files
+ */
+ load_theme_textdomain( 'understrap', get_template_directory() . '/languages' );
- // This theme uses wp_nav_menu() in one location.
- register_nav_menus( array(
- 'primary' => __( 'Primary Menu', 'understrap' ),
- ) );
+ // Add default posts and comments RSS feed links to head.
+ add_theme_support( 'automatic-feed-links' );
- /*
- * 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',
- ) );
-
- /*
- * Adding Thumbnail basic support
- */
- add_theme_support( "post-thumbnails" );
+ /*
+ * Let WordPress manage the document title.
+ * By adding theme support, we declare that this theme does not use a
+ * hard-coded tag in the document head, and expect WordPress to
+ * provide it for us.
+ */
+ add_theme_support( 'title-tag' );
- /*
- * Enable support for Post Formats.
- * See http://codex.wordpress.org/Post_Formats
- */
- add_theme_support( 'post-formats', array(
- 'aside', 'image', 'video', 'quote', 'link',
- ) );
+ /*
+ * Enable support for Post Thumbnails on posts and pages.
+ *
+ * @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
+ */
+ //add_theme_support( 'post-thumbnails' );
- // 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' => '',
- ) ) );
-
- // Set up the Wordpress Theme logo feature.
- add_theme_support('custom-logo');
+ // This theme uses wp_nav_menu() in one location.
+ register_nav_menus( array(
+ 'primary' => __( 'Primary Menu', 'understrap' ),
+ ) );
- // Check and setup theme default settings.
- setup_theme_default_settings();
-}
-endif; // understrap_setup
+ /*
+ * 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',
+ ) );
+
+ /*
+ * Adding Thumbnail basic support
+ */
+ add_theme_support( 'post-thumbnails' );
+
+ /*
+ * Enable support for Post Formats.
+ * See http://codex.wordpress.org/Post_Formats
+ */
+ 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' => '',
+ ) ) );
+
+ // Set up the Wordpress Theme logo feature.
+ add_theme_support( 'custom-logo' );
+
+ // Check and setup theme default settings.
+ setup_theme_default_settings();
+ }
+endif; // understrap_setup.
add_action( 'after_setup_theme', 'understrap_setup' );
-/**
-* Adding the Read more link to excerpts
-*/
-/*function new_excerpt_more( $more ) {
- return ' ' . __('Read More', 'understrap') . '
';
-}
-add_filter( 'excerpt_more', 'new_excerpt_more' );*/
-/* Removes the ... from the excerpt read more link */
-if ( ! function_exists ( 'custom_excerpt_more' ) ) {
+if ( ! function_exists( 'custom_excerpt_more' ) ) {
+ /**
+ * Removes the ... from the excerpt read more link
+ *
+ * @param string $more The excerpt.
+ *
+ * @return string
+ */
function custom_excerpt_more( $more ) {
return '';
}
}
add_filter( 'excerpt_more', 'custom_excerpt_more' );
-/* Adds a custom read more link to all excerpts, manually or automatically generated */
-if ( ! function_exists ( 'all_excerpts_get_more_link' ) ) {
- function all_excerpts_get_more_link($post_excerpt) {
+if ( ! function_exists( 'all_excerpts_get_more_link' ) ) {
+ /**
+ * Adds a custom read more link to all excerpts, manually or automatically generated
+ *
+ * @param string $post_excerpt Posts's excerpt.
+ *
+ * @return string
+ */
+ function all_excerpts_get_more_link( $post_excerpt ) {
- return $post_excerpt . ' [...]' . __('Read More...', 'understrap') . '
';
+ return $post_excerpt . ' [...]' . __( 'Read More...',
+ 'understrap' ) . '
';
}
}
-add_filter('wp_trim_excerpt', 'all_excerpts_get_more_link');
+add_filter( 'wp_trim_excerpt', 'all_excerpts_get_more_link' );
diff --git a/inc/template-tags.php b/inc/template-tags.php
index 483acd5..dda6baa 100644
--- a/inc/template-tags.php
+++ b/inc/template-tags.php
@@ -7,75 +7,77 @@
* @package understrap
*/
-
if ( ! function_exists( 'understrap_posted_on' ) ) :
-/**
- * Prints HTML with meta information for the current post-date/time and author.
- */
-function understrap_posted_on() {
- $time_string = '';
- if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
- $time_string = ', ';
+ /**
+ * 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,
+ 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 = sprintf(
+ esc_html_x( 'Posted on %s', 'post date', 'understrap' ),
+ '' . $time_string . ''
+ );
+
+ $byline = sprintf(
+ esc_html_x( 'by %s', 'post author', 'understrap' ),
+ '' . esc_html( get_the_author() ) . ''
+ );
+
+ echo '' . esc_html( $posted_on ) . ' ' . esc_html( $byline ) . '';
+
}
-
- $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 = sprintf(
- esc_html_x( 'Posted on %s', 'post date', 'understrap' ),
- '' . $time_string . ''
- );
-
- $byline = sprintf(
- esc_html_x( 'by %s', 'post author', 'understrap' ),
- '' . esc_html( get_the_author() ) . ''
- );
-
- echo '' . $posted_on . ' ' . $byline . '';
-
-}
endif;
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() ) {
- /* translators: used between list items, there is a space after the comma */
- $categories_list = get_the_category_list( __( ', ', 'understrap' ) );
- if ( $categories_list && understrap_categorized_blog() ) {
- printf( '' . __( 'Posted in %1$s', 'understrap' ) . '', $categories_list );
+ /**
+ * 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() ) {
+ /* translators: used between list items, there is a space after the comma */
+ $categories_list = get_the_category_list( __( ', ', 'understrap' ) );
+ if ( $categories_list && understrap_categorized_blog() ) {
+ printf( '' . __( 'Posted in %1$s', 'understrap' ) . '',
+ $categories_list );
+ }
+
+ /* translators: used between list items, there is a space after the comma */
+ $tags_list = get_the_tag_list( '', __( ', ', 'understrap' ) );
+ if ( $tags_list ) {
+ printf( '' . __( 'Tagged %1$s', 'understrap' ) . '', $tags_list );
+ }
}
- /* translators: used between list items, there is a space after the comma */
- $tags_list = get_the_tag_list( '', __( ', ', 'understrap' ) );
- if ( $tags_list ) {
- printf( '' . __( 'Tagged %1$s', 'understrap' ) . '', $tags_list );
+ if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
+ echo '';
}
- }
-
- if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
- echo '';
- }
edit_post_link(
- sprintf(
- /* translators: %s: Name of current post */
- esc_html__( 'Edit %s', 'understrap' ),
- the_title( '"', '"', false )
- ),
- '',
- ''
- );
-}
+ sprintf(
+ /* translators: %s: Name of current post */
+ esc_html__( 'Edit %s', 'understrap' ),
+ the_title( '"', '"', false )
+ ),
+ '',
+ ''
+ );
+ }
endif;
/**
@@ -119,5 +121,6 @@ function understrap_category_transient_flusher() {
// Like, beat it. Dig?
delete_transient( 'understrap_categories' );
}
+
add_action( 'edit_category', 'understrap_category_transient_flusher' );
-add_action( 'save_post', 'understrap_category_transient_flusher' );
+add_action( 'save_post', 'understrap_category_transient_flusher' );
diff --git a/inc/theme-settings.php b/inc/theme-settings.php
index c60553f..5867f1f 100644
--- a/inc/theme-settings.php
+++ b/inc/theme-settings.php
@@ -6,7 +6,6 @@ function setup_theme_default_settings() {
// check if settings are set, if not set defaults.
// Caution: DO NOT check existence using === always check with == .
-
// Latest blog posts style.
$understrap_posts_index_style = get_theme_mod( 'understrap_posts_index_style' );
if ( '' == $understrap_posts_index_style ) {
diff --git a/inc/utilities.php b/inc/utilities.php
index ece109d..a1a66aa 100644
--- a/inc/utilities.php
+++ b/inc/utilities.php
@@ -1,13 +1,17 @@
' . $excerpt . '[...]
';
$excerpt .= 'Read More
';
} else {
diff --git a/inc/widgets.php b/inc/widgets.php
index 66cce3b..d9649df 100644
--- a/inc/widgets.php
+++ b/inc/widgets.php
@@ -2,10 +2,13 @@
/**
* Declaring widgets
*
- *
* @package understrap
*/
+
if ( ! function_exists( 'understrap_widgets_init' ) ) {
+ /**
+ * Initializes themes widgets.
+ */
function understrap_widgets_init() {
register_sidebar( array(
'name' => __( 'Right Sidebar', 'understrap' ),
@@ -58,5 +61,5 @@ if ( ! function_exists( 'understrap_widgets_init' ) ) {
) );
}
-}
+} // endif function_exists( 'understrap_widgets_init' ).
add_action( 'widgets_init', 'understrap_widgets_init' );
diff --git a/inc/woocommerce.php b/inc/woocommerce.php
index b55cdc5..35243f7 100644
--- a/inc/woocommerce.php
+++ b/inc/woocommerce.php
@@ -2,15 +2,17 @@
/**
* Add WooCommerce support
*
- *
* @package understrap
*/
add_action( 'after_setup_theme', 'woocommerce_support' );
if ( ! function_exists( 'woocommerce_support' ) ) {
+ /**
+ * Declares WooCommerce theme support.
+ */
function woocommerce_support() {
add_theme_support( 'woocommerce' );
- // hook in and customizer form fields
+ // hook in and customizer form fields.
add_filter( 'woocommerce_form_field_args', 'wc_form_field_args', 10, 3 );
}
}
@@ -19,16 +21,15 @@ if ( ! function_exists( 'woocommerce_support' ) ) {
* Filter hook function monkey patching form classes
* Author: Adriano Monecchi http://stackoverflow.com/a/36724593/307826
*
- * @param $args
- * @param $key
- * @param null $value
+ * @param string $args Form attributes.
+ * @param string $key Not in use.
+ * @param null $value Not in use.
*
* @return mixed
*/
function wc_form_field_args( $args, $key, $value = null ) {
-// Start field type switch case
-
+ // Start field type switch case.
switch ( $args['type'] ) {
/* Targets all select input type elements, except the country and state select input types */
@@ -74,7 +75,7 @@ function wc_form_field_args( $args, $key, $value = null ) {
case 'email' :
case 'tel' :
case 'number' :
- $args['class'][] = 'form-group';
+ $args['class'][] = 'form-group';
$args['input_class'] = array( 'form-control', 'input-lg' );
$args['label_class'] = array( 'control-label' );
break;
@@ -99,7 +100,7 @@ function wc_form_field_args( $args, $key, $value = null ) {
$args['input_class'] = array( 'form-control', 'input-lg' );
$args['label_class'] = array( 'control-label' );
break;
- }
+ } // end switch ($args).
return $args;
}
diff --git a/inc/wpcom.php b/inc/wpcom.php
index 82abdf3..49560b0 100644
--- a/inc/wpcom.php
+++ b/inc/wpcom.php
@@ -7,12 +7,12 @@
* @package understrap
*/
-/**
- * Adds support for wp.com-specific theme functions.
- *
- * @global array $themecolors
- */
-if ( ! function_exists ( 'understrap_wpcom_setup' ) ) {
+if ( ! function_exists( 'understrap_wpcom_setup' ) ) {
+ /**
+ * Adds support for wp.com-specific theme functions.
+ *
+ * @global array $themecolors Array with theme's colors.
+ */
function understrap_wpcom_setup() {
global $themecolors;