How to put php code in an array() - wordpress&php

Viewed 26

I creating site on Wordperss. I have such code:

button.php (main part of code is <span><?php echo __( $args['button-name']); ?></span>

<a href="<?php echo __( $args['button-href'] ); ?>" class="button <?php echo __( 
$args['extra-classes'] ) ?>">
<svg> 
...
</svg>
  <span><?php echo __( $args['button-name']); ?></span>
</a>

Then i put this button on some pages this way:

<?php
    $args = array( 'button-name' => 'I want the same', 'button-href' => '#contact-us', 'extra-classes' => 'button-center' );
    get_template_part( 'template-parts/button', '', $args); 
?>

So i need to put in array 'button-name' => '<?php code ?>', 'button-...' => ...

Php code that i need to put in an array is: <?php echo __('Contact Us', 'text-domain')__; ?>

Shorter i need

<span><?php echo __('Contact Us', 'text-domain')__; ?></span>

instead of

<span><?php echo __( $args['button-name']); ?></span> 

in button.php file

How can i do it?

0 Answers
Related