Skip to content

Commit

Permalink
Check for defined variables on template header
Browse files Browse the repository at this point in the history
  • Loading branch information
pedro-mendonca committed Oct 28, 2024
1 parent ce49098 commit 3c208ac
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions gp-templates/gptoolbox-header.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@

namespace GP_Toolbox;

$defined_vars = get_defined_vars();
$defined_vars = get_defined_vars();
$template_args = is_array( $defined_vars['args'] ) ? $defined_vars['args'] : array();

$page_title = $defined_vars['args']['title'] ?? '';
$page_description = $defined_vars['args']['description'] ?? '';
$template_args = wp_parse_args(
$template_args,
array(
'title' => '',
'description' => '',
)
);

$tools_pages = Toolbox::tools_pages();

Expand All @@ -21,7 +27,7 @@
<h2>
<?php
// Page title.
echo esc_html( $page_title );
echo esc_html( $template_args['title'] );
?>
</h2>

Expand Down Expand Up @@ -58,7 +64,7 @@
<p>
<?php
// Page description.
echo esc_html( $page_description );
echo esc_html( $template_args['description'] );
?>
</p>

Expand Down

0 comments on commit 3c208ac

Please sign in to comment.