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 = '
' . __('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' ), + ' ' + ); + + echo '' . esc_html( $posted_on ) . ' '; + } - - $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' ), - ' ' - ); - - echo '' . $posted_on . ' '; - -} 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( ' ', $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( ' ', $tags_list ); + if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { + echo ''; + comments_popup_link( __( 'Leave a comment', 'understrap' ), __( '1 Comment', 'understrap' ), + __( '% Comments', 'understrap' ) ); + echo ''; } - } - - if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { - echo ''; - comments_popup_link( __( 'Leave a comment', 'understrap' ), __( '1 Comment', 'understrap' ), __( '% Comments', 'understrap' ) ); - 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 .= ''; } 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;