Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into nav
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-c-woodard committed Aug 2, 2024
2 parents afd7740 + 7bb42a3 commit 66e903a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 22 deletions.
2 changes: 1 addition & 1 deletion includes/assets/js/glightbox.min.js

Large diffs are not rendered by default.

55 changes: 38 additions & 17 deletions includes/class-kadence-blocks-svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,23 +161,7 @@ public static function render( $name, $fill = 'currentColor', $stroke_width = fa
$svg .= '<title>' . $title . '</title>';
}
if ( ! empty( $icon['cD'] ) ) {
foreach ( $icon['cD'] as $cd ) {
$nE = $cd['nE'];
$aBs = $cd['aBs'];
$tmpAttr = array();

foreach ( $aBs as $key => $attribute ) {
if ( ! in_array( $key, array( 'fill', 'stroke', 'none' ) ) ) {
$tmpAttr[ $key ] = $key . '="' . $attribute . '"';
}
}

if ( isset( $aBs['fill'], $aBs['stroke'] ) && $aBs['fill'] === 'none' ) {
$tmpAttr['stroke'] = 'stroke="currentColor"';
}

$svg .= '<' . $nE . ' ' . implode( ' ', $tmpAttr ) . '/>';
}
$svg .= self::generate_svg_elements($icon['cD']);
}

$svg .= '</svg>';
Expand All @@ -193,6 +177,43 @@ public static function render( $name, $fill = 'currentColor', $stroke_width = fa
return $svg;

}

/**
* Recursively generate SVG elements
* Out native SVGs do not have children, but user uploaded SVGs in pro can contain children elements.
*
* @param $elements
*
* @return string
*/
private static function generate_svg_elements( $elements ) {
$output = '';
foreach ( $elements as $element ) {
$nE = $element['nE'];
$aBs = $element['aBs'];
$children = ! empty( $element['children'] ) ? $element['children'] : [];
$tmpAttr = array();

foreach ( $aBs as $key => $attribute ) {
if ( ! in_array( $key, array( 'fill', 'stroke', 'none' ) ) ) {
$tmpAttr[ $key ] = $key . '="' . esc_attr( $attribute ) . '"';
}
}

if ( isset( $aBs['fill'], $aBs['stroke'] ) && $aBs['fill'] === 'none' ) {
$tmpAttr['stroke'] = 'stroke="currentColor"';
}

$output .= '<' . $nE . ' ' . implode( ' ', $tmpAttr );
if ( ! empty( $children ) ) {
$output .= '>' . self::generate_svg_elements( $children ) . '</' . $nE . '>';
} else {
$output .= '/>';
}
}

return $output;
}
/**
* Return an array of icons.
*
Expand Down
12 changes: 8 additions & 4 deletions src/assets/js/vendor/glightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,11 @@
{
key: 'stripTags',
value: function e(input) {
var allowed = ((('<a><br><b><i><u><p><ol><ul><li><strong><small>') + '').toLowerCase().match(/<[a-z][a-z0-9]*>/g) || []).join('');
var allowed = (
('<a><br><b><i><u><p><ol><ul><li><strong><small>' + '')
.toLowerCase()
.match(/<[a-z][a-z0-9]*>/g) || []
).join('');
const tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,
commentsAndPhpTags = /<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi;
return input.replace(commentsAndPhpTags, '').replace(tags, function ($0, $1) {
Expand Down Expand Up @@ -1326,7 +1330,7 @@
var p = t.querySelector('.glightbox-desc');
p && (o.description = p.innerHTML);
}
if ( o.description ) {
if (o.description) {
o.description = this.stripTags(o.description);
}
return this.setSize(o, i, t), (this.slideConfig = o), o;
Expand Down Expand Up @@ -1864,11 +1868,11 @@
return;
}
if ('Left' == i.direction) {
if (t.index == t.elements.length - 1) return q(f);
if (t.index == t.elements.length - 1 && !t.loop()) return q(f);
t.nextSlide();
}
if ('Right' == i.direction) {
if (0 == t.index) return q(f);
if (0 == t.index && !t.loop()) return q(f);
t.prevSlide();
}
}
Expand Down

0 comments on commit 66e903a

Please sign in to comment.