Skip to content

Commit

Permalink
Fix a small tr_get_media bug
Browse files Browse the repository at this point in the history
  • Loading branch information
nikola-wd committed Nov 26, 2022
1 parent be1a331 commit b5c49d3
Show file tree
Hide file tree
Showing 10 changed files with 179 additions and 17 deletions.
Binary file modified gutenberg/blocks/hero/example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 17 additions & 13 deletions gutenberg/blocks/image/view.latte
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
{if $link['url']}
<a {tr_a($link, "wp-figure-link", true)|noescape}>
{/if}
{if !empty($image['src'])}

<figure class="wp-figure wp-figure-test">
{tr_get_media($image, true)}
{if strlen($caption['text'])}
<figcaption class="wp-figcaption">
{$caption['text']}
</figcaption>
{/if}
</figure>
{if $link['url']}
<a {tr_a($link, "wp-figure-link", true)|noescape}>
{/if}

<figure class="wp-figure wp-figure-test">
{tr_get_media($image, true)}
{if strlen($caption['text'])}
<figcaption class="wp-figcaption">
{$caption['text']}
</figcaption>
{/if}
</figure>

{if $link['url']}
</a>
{/if}

{if $link['url']}
</a>
{/if}
8 changes: 5 additions & 3 deletions php-inc/enqueue-block-specific-css-and-js.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ function tr_enqueue_block_specific_css_and_js() {
function tr_parse_blocks($blocks, $block_prefix, &$tr_custom_blocks_names) {

foreach ($blocks as $block) {
if (str_starts_with($block['blockName'], "$block_prefix/")) {
$block_name = $block['blockName'];

if (!is_null($block_name) && str_starts_with($block_name, "$block_prefix/")) {

if (!in_array($block['blockName'], $tr_custom_blocks_names)) {
$tr_custom_blocks_names[] = $block['blockName'];
if (!in_array($block_name, $tr_custom_blocks_names)) {
$tr_custom_blocks_names[] = $block_name;

// if nested blocks, parse them as well
if (!empty($block['innerBlocks'])) {
Expand Down
2 changes: 1 addition & 1 deletion php-inc/theme-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function tr_get_media(
$path_only = false
) {

if ($media === NULL) {
if ($media === NULL || (is_array($media) && empty($media['src']))) {
return false;
}

Expand Down
45 changes: 45 additions & 0 deletions views/temp/blocks-image-view.latte--3c6059f16b.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

use Latte\Runtime as LR;

/** source: C:\xampp\htdocs\theme_redone\wp-content\themes\theme_redone\gutenberg\blocks\image/view.latte */
final class Template3c6059f16b extends Latte\Runtime\Template
{

public function main(array $ʟ_args): void
{
extract($ʟ_args);
unset($ʟ_args);

if (!empty($image['src'])) /* line 1 */ {
echo "\n";
if ($link['url']) /* line 3 */ {
echo ' <a ';
echo tr_a($link, 'wp-figure-link', true) /* line 4 */;
echo '>
';
}
echo '
<figure class="wp-figure wp-figure-test">
';
echo LR\Filters::escapeHtmlText(tr_get_media($image, true)) /* line 8 */;
echo "\n";
if (strlen($caption['text'])) /* line 9 */ {
echo ' <figcaption class="wp-figcaption">
';
echo LR\Filters::escapeHtmlText($caption['text']) /* line 11 */;
echo '
</figcaption>
';
}
echo ' </figure>
';
if ($link['url']) /* line 16 */ {
echo ' </a>
';
}
echo "\n";
}
}
}
Empty file.
71 changes: 71 additions & 0 deletions views/temp/blocks-video-view.latte--b1ed077162.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

use Latte\Runtime as LR;

/** source: C:\xampp\htdocs\theme_redone\wp-content\themes\theme_redone\gutenberg\blocks\video/view.latte */
final class Templateb1ed077162 extends Latte\Runtime\Template
{

public function main(array $ʟ_args): void
{
extract($ʟ_args);
unset($ʟ_args);

echo '
';
if ($video_src) /* line 16 */ {
echo '<figure
class="wp-figure tr-video-outer-wrap"
>
';
$this->createTemplate(tr_part('video'), ['video_src' => $video_src, 'video_type' => tr_get_video_type_and_id($video_src)] + $this->params, 'include')->renderToContentType('html') /* line 19 */;
echo "\n";
ob_start(fn() => '');
try {
echo ' <figcaption class="wp-figcaption caption">';
ob_start();
try {
echo '
';
echo $optional_caption['text'] /* line 25 */;
echo '
';

} finally {
$ʟ_ifc[0] = rtrim(ob_get_flush()) === '';
}
echo '</figcaption>
';

} finally {
if ($ʟ_ifc[0] ?? null) {
ob_end_clean();
} else {
echo ob_get_clean();
}
}
echo '</figure>
';
}
}


public function prepare(): array
{
extract($this->params);

$video_src = '' /* line 1 */;
if ($inspector_is_self_hosted['checked']) /* line 2 */ {
if ($self_hosted_video['src']) /* line 3 */ {
$video_src = $self_hosted_video['src'] /* line 4 */;
}
} else /* line 7 */ {
if ($yt_or_vimeo_url['text']) /* line 8 */ {
$video_src = $yt_or_vimeo_url['text'] /* line 9 */;
}
}
return get_defined_vars();
}
}
Empty file.
40 changes: 40 additions & 0 deletions views/temp/views-templates-page.latte--a15047f9f0.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

use Latte\Runtime as LR;

/** source: C:\xampp\htdocs\theme_redone/wp-content/themes/theme_redone/views/templates/page.latte */
final class Templatea15047f9f0 extends Latte\Runtime\Template
{

public function main(array $ʟ_args): void
{
extract($ʟ_args);
unset($ʟ_args);

echo "\n";
$this->createTemplate(tr_view_path('/layout/header'), $this->params, 'include')->renderToContentType('html') /* line 2 */;
echo '
<div class="content">
';
while (have_posts()) /* line 5 */ {
echo ' ';
echo LR\Filters::escapeHtmlText(the_post()) /* line 6 */;
echo '
<h1>';
echo LR\Filters::escapeHtmlText(the_title()) /* line 8 */;
echo '</h1>
<hr />
';
echo LR\Filters::escapeHtmlText(the_content()) /* line 10 */;
echo '
';

}
echo '</div>
';
$this->createTemplate(tr_view_path('/layout/footer'), $this->params, 'include')->renderToContentType('html') /* line 15 */;
}
}
Empty file.

0 comments on commit b5c49d3

Please sign in to comment.