I know title seems obscure but trust me I have researched this already but it fails for my code.
I have a code for licensing which pretty much looks like this
<?php if ( true ) : ?>
<?php print( 'Your License is Active' ); $type = 1; ?>
It pretty much sets the $type variable.
Now my problem:
function file_pull() {
if ( $type == 1 ) {
$import_path = '/main/';
$files_array = array(
'start' => array(),
'home' => array(
'description' => __( 'Importing: Main Templates', 'kss' ),
'files' => array(
'home.xml',
),
),
);
}
if ( $type == 2 ) {
$import_path = '/main/';
$files_array = array(
'start' => array(),
'home' => array(
'description' => __( 'Importing: Main Templates', 'kss' ),
'files' => array(
'page1.xml',
),
),
);
}
}
How can I use the $type variable inside this function so that it runs these file pull requests?
I have tried global to no avail. I have also tried setting it as a parameter.
function file_pull($type) {
Thanks.
$typebefore you call the function.function file_pull($type) {is the way to go, but be aware that$typein this case does not automatically use your$typefrom outside the function. You'd need to call the function likefile_pull(1)orfile_pull(2)$typeis out of scope from your function. Have a read of the documentation on function scopes to get a better grasp on the issue.