Need to use an external variable inside a function

Need help with a theme I’m working on.

Basically I have a variable that’s set early called type

<?php if ( preg_match(“/^kssm-/i”, $licensekey) && preg_match(“/@/i”, $licensekey) == true ) : ?>
<span style=”color:#ae5842;”> <?php print(‘Your License is Active’); $type = 1; ?></span>

then I have a function where I want to use the $type variable

function file_pull() {
if ( $upgrade_type == 1 ) {
$import_path = ‘/main/’;

$files_array = array(
‘start’ => array(),
‘home’ => array(
‘description’ => __( ‘Importing: Main Templates’, ‘kss’ ),
‘files’ => array(
‘home.xml’,
),
),

);
}
if ( $upgrade_type == 2 ) {
$import_path = ‘/main/’;

$files_array = array(
‘start’ => array(),
‘home’ => array(
‘description’ => __( ‘Importing: Main Templates’, ‘kss’ ),
‘files’ => array(
‘page1.xml’,
),
),

);
}

I have tried globals but to no avail.

Anything that’s worth a try here?

Thanks, appreciate it.

Read more here:: Need to use an external variable inside a function

Leave a Reply

Your email address will not be published. Required fields are marked *