Skip to content

Commit

Permalink
make sure to remove footprints of the language blocks that are not di…
Browse files Browse the repository at this point in the history
…splayed
  • Loading branch information
imath committed Nov 1, 2018
1 parent 1fb094e commit 022c6f7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 25 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,14 @@
# Changelog

## 1.3.2

+ _Requires Gutenberg 4.1.0 & WordPress 4.9_
+ _Tested up to WordPress 5.0_

### Bug fixes

- Dubber block: make sure to remove footprints of the language blocks that are not displayed.

## 1.3.1

+ _Requires Gutenberg 4.1.0 & WordPress 4.9_
Expand Down
4 changes: 2 additions & 2 deletions gutenblocks.php
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: GutenBlocks
* Plugin URI: https://imathi.eu/tag/gutenblocks/
* Description: Ma collection personnelle de blocs Gutenberg.
* Version: 1.3.1
* Version: 1.3.2
* Requires at least: 4.9
* Tested up to: 5.0
* License: GNU/GPL 2
Expand Down Expand Up @@ -68,7 +68,7 @@ public static function start() {
*/
private function globals() {
// Version
$this->version = '1.3.1';
$this->version = '1.3.2';

// Domain
$this->domain = 'gutenblocks';
Expand Down
28 changes: 6 additions & 22 deletions inc/functions.php
Expand Up @@ -941,29 +941,13 @@ function gutenblocks_translate_blocks( $content = '' ) {

// Remove all other languages blocks' content.
$content = str_replace( $innerblock['innerHTML'], '', $content );
$blockname = str_replace( '/', '\/',
str_replace( 'core/', '(?:core/)?',
preg_quote( $innerblock['blockName'] )
)
);

$layout = ! empty( $block['attrs']['layout'] ) ? $block['attrs']['layout'] : false;

if ( $layout ) {
$footprint = (
'/<!--\s+wp:(' .
$blockname .
')(\s+(\{.*' .
$layout .
'.*\}))?\s+(-->.*\<!--\s+\/wp:' .
$blockname .
'\s+--\>|\/--\>)/'
);

// Remove remaining HTML comments.
$content = preg_replace( $footprint, '', $content, 1 );
}
}

$blockname = addcslashes( $block['blockName'], '/' );
$footprint = '/(<!--\s+wp:' . $blockname .'\s+-->)(.|\n)*?(<!--\s+\/wp:' . $blockname .'\s+-->)/';

// Remove the dubber language container
$content = preg_replace( $footprint, '', $content, 1 );
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -36,5 +36,5 @@
"type": "git",
"url": "https://github.com/imath/gutenblocks.git"
},
"version": "1.3.1"
"version": "1.3.2"
}

0 comments on commit 022c6f7

Please sign in to comment.