Skip to content

Commit

Permalink
Merge branch 'release/1.8.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Hemberger committed Feb 9, 2019
2 parents 40bcb87 + 1c4be12 commit 5ccaf20
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 17 deletions.
5 changes: 4 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Changelog

##
## 1.8.2 (2/8/19)
* Fixed: Broken layout when using [col] shortcodes with image attribute.
* Fixed: Hidden overflow on widgets hiding grid slider arrows.
* Fixed: Jetpack Photon "Speed up image load times" setting blowing up image srcset filters.
* Fixed: Error when switching to a non-Mai Theme in multisite.

## 1.8.1 (2/7/19)
* Fixed: Hotfix for missing argument in srscet function.
Expand Down
29 changes: 22 additions & 7 deletions lib/classes/class-col.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ function render() {
*/
function get_col() {

// Trim because testing returned string of nbsp.
$this->content = mai_get_processed_content( trim( $this->content ) );

$image = $overlay = '';

$attributes = array(
'class' => $this->get_classes(),
'id' => ! empty( $this->args['id'] ) ? $this->args['id'] : '',
Expand Down Expand Up @@ -138,8 +143,12 @@ function get_col() {
$image_id = absint( $this->args['image'] );
}

// Add the aspect ratio attributes.
$attributes = mai_add_background_image_attributes( $attributes, $image_id, $this->args['image_size'] );
// Do the image.
$image_html = wp_get_attachment_image( $image_id, $this->args['image_size'], false, array( 'class' => 'bg-image' ) );
if ( $image_html ) {
$attributes['class'] .= ' has-bg-image';
$image = wp_image_add_srcset_and_sizes( $image_html, wp_get_attachment_metadata( $image_id ), $image_id );
}
}

// If we have a valid overlay.
Expand All @@ -150,8 +159,11 @@ function get_col() {
$light_content = true;
}

// Build the overlay.
$overlay = mai_get_overlay_html( $this->args['overlay'] );

// Add overlay classes.
$attributes['class'] = mai_add_overlay_classes( $attributes['class'], $this->args['overlay'] );
$attributes['class'] .= ' has-overlay';
}

// Shade class
Expand All @@ -170,14 +182,17 @@ function get_col() {
// Maybe add inline styles.
$attributes = mai_add_inline_styles( $attributes, $this->args['style'] );

// Trim because testing returned string of nbsp.
$this->content = trim( $this->content );

/**
* Return the content with col wrap.
* With flex-col attr so devs can filter elsewhere.
*/
return sprintf( '<div %s>%s%s</div>', genesis_attr( 'flex-col', $attributes, $this->args ), mai_get_processed_content( $this->content ), $bg_link );
return sprintf( '<div %s>%s%s%s%s</div>',
genesis_attr( 'flex-col', $attributes, $this->args ),
$image,
$overlay,
$this->content,
$bg_link
);
}

/**
Expand Down
37 changes: 31 additions & 6 deletions lib/classes/class-section.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class Mai_Section {
private $has_overlay;
private $has_inner;


public function __construct( $args = array(), $content = null ) {

// Save original args in a variable for filtering later.
Expand Down Expand Up @@ -223,7 +222,11 @@ function get_section_open() {
}

// Build the opening markup.
return sprintf( '<%s %s>%s', $this->args['wrapper'], genesis_attr( $this->args['context'], $attributes, $this->args ), $inner_html );
return sprintf( '<%s %s>%s',
$this->args['wrapper'],
genesis_attr( $this->args['context'], $attributes, $this->args ),
$inner_html
);
}

/**
Expand Down Expand Up @@ -495,35 +498,57 @@ function get_section_wrap_close() {
*/
function calculate_srcset( $sources, $size_array, $image_src, $image_meta, $attachment_id ) {

// Bail if no sources.
if ( ! is_array( $sources ) ) {
return $sources;
}

// Bail if Jetpack Photon (image performance) is active.
if ( class_exists( 'Jetpack_Photon' ) && class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) {
return $sources;
}

$sizes = $image_meta['sizes'];

// Bail if no sizes.
if ( ! array( $sizes ) || empty( $sizes ) ) {
return $sources;
}

foreach( $sizes as $size => $values ) {
$theme_sizes = array( 'full-width', 'featured', 'one-half', 'one-third', 'one-fourth' );

foreach( $sizes as $size => $value ) {

// Skip if not a size we want to check.
if ( ! in_array( $size, array( 'full-width', 'featured', 'one-half', 'one-third', 'one-fourth' ) ) ) {
if ( ! in_array( $size, $theme_sizes ) ) {
continue;
}

// Get new image data.
$source = wp_get_attachment_image_src( $attachment_id, $size );
$source = wp_get_attachment_image_src( $attachment_id, $size );
if ( ! $source ) {
continue;
}

$url = $source[0];
$width = $source[1];
$height = $source[2];
$crop = $source[3];
$ratio = $width/$height;
$in_range = ( $ratio > 1 ) && ( $ratio < 3 );

// Skip if not hard-cropping.
if ( ! $crop ) {
continue;
}

// Skip if this image size isn't a valid aspect ratio.
if ( ! $in_range ) {
continue;
}

// Add to our new srcset.
$sources[ $values['width'] ] = array(
$sources[ $value['width'] ] = array(
'url' => $url,
'descriptor' => 'w',
'value' => $width,
Expand Down
6 changes: 3 additions & 3 deletions mai-theme-engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Plugin URI: https://maitheme.com/
* Description: The Mai Theme Engine plugin
*
* Version: 1.8.1.1
* Version: 1.8.2
*
* GitHub URI: maithemewp/mai-theme-engine
*
Expand Down Expand Up @@ -89,7 +89,7 @@ public function __wakeup() {
private function setup_constants() {

// Plugin version.
define( 'MAI_THEME_ENGINE_VERSION', '1.8.1.1' );
define( 'MAI_THEME_ENGINE_VERSION', '1.8.2' );

// DB version.
define( 'MAI_THEME_ENGINE_DB_VERSION', '1400' );
Expand Down Expand Up @@ -146,7 +146,7 @@ private function hooks() {
$updater = Puc_v4_Factory::buildUpdateChecker( 'https://github.com/maithemewp/mai-theme-engine/', __FILE__, 'mai-theme-engine' );

// Get the branch. If checking for beta releases.
$tester = genesis_get_option( 'mai_tester' );
$tester = function_exists( 'genesis_get_option' ) && genesis_get_option( 'mai_tester' );
$tester = $tester ? 'beta' : 'master';

// Allow branch and updater object manipulation.
Expand Down

0 comments on commit 5ccaf20

Please sign in to comment.