So I'm building my own WordPress theme and I included a setting to be able to change the sites logo.
This is the part that registers the function that handles the upload:
add_settings_field("logo", "Logo", "logo_display", "theme-options", "section");
register_setting("section", "logo", "handle_logo_upload");
This is the handler function that is supposed to handle the file given:
function handle_logo_upload()
{
if ( ! function_exists( 'wp_handle_upload' ) ) {
require_once( ABSPATH . 'wp-admin/includes/file.php' );
}
$uploadedfile = $_FILES['file'];
$upload_overrides = array( 'test_form' => false );
$movefile = wp_handle_upload( $uploadedfile, $upload_overrides );
if ( $movefile && !isset( $movefile['error'] ) ) {
echo "File is valid, and was successfully uploaded.\n";
var_dump( $movefile);
} else {
/**
* Error generated by _wp_handle_upload()
* @see _wp_handle_upload() in wp-admin/includes/file.php
*/
echo $movefile['error'];
}
return 'stringaz';
}
This is what the theme panel looks like: http://pasteboard.co/uwC3Qmi.png
Here you can see that the handler is not working because a string called 'stringaz' is being presented where the logo should appear: http://pasteboard.co/vsnqkay.png
What do I need to change to the handler function to get this code to run?
cheers!