From 72583f18d0f2f6ee746c54f35e71f981c9b7722d Mon Sep 17 00:00:00 2001 From: Ednilson Maia Date: Thu, 22 Feb 2018 16:03:37 -0300 Subject: [PATCH 1/4] Added styles for image gallery --- src/assets/scss/global/_wp-overrides.scss | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/assets/scss/global/_wp-overrides.scss b/src/assets/scss/global/_wp-overrides.scss index aff1fdbf0..7a81e1c60 100644 --- a/src/assets/scss/global/_wp-overrides.scss +++ b/src/assets/scss/global/_wp-overrides.scss @@ -28,3 +28,15 @@ p.wp-caption-text{ margin-left: auto; margin-right: auto; } + +.gallery { + @include xy-grid; +} +@for $i from 1 through 9 { + .gallery-columns-#{$i} { + @include xy-grid-layout($i, '.gallery-item', true); + } +} +.gallery-icon { + @include thumbnail; +} \ No newline at end of file From f16a8d387913cc05a74a1f75d78a66862512c511 Mon Sep 17 00:00:00 2001 From: Ednilson Maia Date: Thu, 22 Feb 2018 16:11:39 -0300 Subject: [PATCH 2/4] Remove warning "no new line at the end of file" --- src/assets/scss/global/_wp-overrides.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assets/scss/global/_wp-overrides.scss b/src/assets/scss/global/_wp-overrides.scss index 7a81e1c60..6007af9ab 100644 --- a/src/assets/scss/global/_wp-overrides.scss +++ b/src/assets/scss/global/_wp-overrides.scss @@ -39,4 +39,4 @@ p.wp-caption-text{ } .gallery-icon { @include thumbnail; -} \ No newline at end of file +} From 4a91d2ebbc5fbc8efbcee6810fc70bc2ab49c08a Mon Sep 17 00:00:00 2001 From: Ednilson Maia Date: Thu, 22 Feb 2018 17:32:43 -0300 Subject: [PATCH 3/4] Added custom markup for wordpress gallery --- library/foundation.php | 131 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) diff --git a/library/foundation.php b/library/foundation.php index fcdc6c0cd..d439e2c03 100644 --- a/library/foundation.php +++ b/library/foundation.php @@ -186,3 +186,134 @@ function foundationpress_title_bar_responsive_toggle() { } } endif; + +/** + * Custom markup for Wordpress gallery + */ +if ( ! function_exists( 'foundationpress_gallery' ) ) : + function foundationpress_gallery($attr) { + + $post = get_post(); + static $instance = 0; + $instance++; + + if ( ! empty( $attr['ids'] ) ) { + // 'ids' is explicitly ordered, unless you specify otherwise. + if ( empty( $attr['orderby'] ) ) + $attr['orderby'] = 'post__in'; + $attr['include'] = $attr['ids']; + } + + // Allow plugins/themes to override the default gallery template. + $output = apply_filters('post_gallery', '', $attr, $instance); + if ( $output != '' ) + return $output; + + // Let's make sure it looks like a valid orderby statement + if ( isset( $attr['orderby'] ) ) { + $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] ); + if ( !$attr['orderby'] ) + unset( $attr['orderby'] ); + } + + $atts = shortcode_atts(array( + 'order' => 'ASC', + 'orderby' => 'menu_order ID', + 'id' => $post ? $post->ID : 0, + 'itemtag' => 'figure', + 'icontag' => 'div', + 'captiontag' => 'figcaption', + 'columns' => 3, + 'size' => 'thumbnail', + 'include' => '', + 'exclude' => '' + ), $attr, 'gallery'); + + $id = intval($atts['id']); + + if ( !empty($atts['include']) ) { + $_attachments = get_posts( array('include' => $atts['include'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby']) ); + + $attachments = array(); + foreach ( $_attachments as $key => $val ) { + $attachments[$val->ID] = $_attachments[$key]; + } + } elseif ( !empty($atts['exclude']) ) { + $attachments = get_children( array('post_parent' => $id, 'exclude' => $atts['exclude'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby']) ); + } else { + $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby']) ); + } + + if ( empty($attachments) ) + return ''; + + if ( is_feed() ) { + $output = "\n"; + foreach ( $attachments as $att_id => $attachment ) + $output .= wp_get_attachment_link($att_id, $atts['size'], true) . "\n"; + return $output; + } + + $item_tag = tag_escape($atts['itemtag']); + $caption_tag = tag_escape($atts['captiontag']); + $icon_tag = tag_escape($atts['icontag']); + $valid_tags = wp_kses_allowed_html( 'post' ); + + if ( ! isset( $valid_tags[ $item_tag ] ) ) + $item_tag = 'figure'; + if ( ! isset( $valid_tags[ $caption_tag ] ) ) + $caption_tag = 'figcaption'; + if ( ! isset( $valid_tags[ $icon_tag ] ) ) + $icon_tag = 'div'; + + $columns = intval($atts['columns']); + $selector = "gallery-{$instance}"; + $size_class = sanitize_html_class( $atts['size'] ); + + $output = "\n"; + + return $output; + } + add_shortcode('gallery', 'foundationpress_gallery'); +endif; From f95251c45e8a191cf269a7425577c69a1b92881a Mon Sep 17 00:00:00 2001 From: Ednilson Maia Date: Mon, 2 Apr 2018 11:14:55 -0300 Subject: [PATCH 4/4] Update Wordpress custom gallery with Foundation Block Grids markup --- library/foundation.php | 46 +++++++++++++---------- src/assets/scss/global/_wp-overrides.scss | 29 ++++++++++---- 2 files changed, 48 insertions(+), 27 deletions(-) diff --git a/library/foundation.php b/library/foundation.php index d439e2c03..3c5b88f21 100644 --- a/library/foundation.php +++ b/library/foundation.php @@ -217,16 +217,18 @@ function foundationpress_gallery($attr) { } $atts = shortcode_atts(array( - 'order' => 'ASC', - 'orderby' => 'menu_order ID', - 'id' => $post ? $post->ID : 0, - 'itemtag' => 'figure', - 'icontag' => 'div', - 'captiontag' => 'figcaption', - 'columns' => 3, - 'size' => 'thumbnail', - 'include' => '', - 'exclude' => '' + 'order' => 'ASC', + 'orderby' => 'menu_order ID', + 'id' => $post ? $post->ID : 0, + 'itemtag' => 'figure', + 'icontag' => 'div', + 'captiontag' => 'figcaption', + 'columns-small' => 2, // set default columns for small screen + 'columns-medium'=> 4, // set default columns for medium screen + 'columns' => 3, // set default columns for large screen (3 = wordpress default) + 'size' => 'thumbnail', + 'include' => '', + 'exclude' => '' ), $attr, 'gallery'); $id = intval($atts['id']); @@ -267,24 +269,28 @@ function foundationpress_gallery($attr) { $icon_tag = 'div'; $columns = intval($atts['columns']); + $columns_small = intval($atts['columns-small']); + $columns_medium = intval($atts['columns-medium']); $selector = "gallery-{$instance}"; $size_class = sanitize_html_class( $atts['size'] ); - $output = "