I have a theme builder that I'm working on, and have a problem that I cannot figure out. I have a text to image (png) script that works great outside of my WP plugin submit forms, but when inside, it will not execute.
I've used var_dump on all of the variables. The text field is being passed properly, the directory is being passed properly. Every single variable is being passed properly. I've tried pasting the entire script into the plugin file, and also using "include" which is how I usually do it.
What could cause this to happen? If I manually set the variables inside "text-to-image.php" and visit the URL, it executes properly. If I run the script inside of my WP plugin page, it doesn't work (even with manually assigned variables).
Note that all of the other functions of the "theme builder" work fine, it's just the image creator that doesn't.
$sitename = $_REQUEST['sitename'];
$logoselect = $_REQUEST['logoselect'];
$domain = $sitename;
if ($logoselect == "No") { }
} else {
include 'text-to-image.php';
}
text-to-image.php includes a script that I found on SO, which is confirmed working outside of the WP plugin page. The last 2 lines are this (the theme name and image are dynamically created names specified in the main part of the script):
imagepng($image, "C:\\wamp64\\www\\wp-install\\wp-content\\themes\\$themenamereplacer\\$imagefilename.png");
imagedestroy($image);
The text field for submission
<input type="text" name="sitename" value="<?php echo get_option("blogname"); ?>" />
For testing, I used var_dump on...
$themenamereplacer
$imagefilename
$sitename
$domain
Every single one properly passed the variable. Even if I manually assign a location for the image output, if being run inside the WP plugin page, it will not execute (meaning, the image will not be created). If I visit the text-to-image.php URL directly, it executes properly (the image is created).
The reason I'm using $domain = $sitename, is because I created the theme builder using the variable $domain and didn't want to change it all... However, I did indeed test changing all the "domain" elements to "sitename," and it still did not work.
Anyone have any idea what's going on? Thank you so much for the help.
Solved.
Inside of text-to-image.php,
I was using the code
$font = "./fonts/$arrayoffontsrandomized.tff";
Apparently the path was no accurate. Changing to:
$font = dirname(__FILE__) . "/fonts/$arrayoffontsrandomized.ttf";
Solved the issue.