Issue
Having trouble setting custom icons for a text format. Followed the instructions given on the Edit Format page:
“Add your custom icons by creating a new folder called gctf in the WordPress upload directory and adding your icons (svg or png 40x40px) there. The correct path for the custom icons should be: …wp-content/uploads/gctf/. When added, the icons will automatically show up the Format Icon dropdown-menu.”
If I follow these instructions I get an error showing up on the Edit Format page:
“Fatal error: Uncaught Error: [] operator not supported for strings in /bitnami/wordpress/wp-content/plugins/custom-text-formats/custom-text-formats.php:205 Stack trace: #0 /opt/bitnami/wordpress/wp-admin/includes/template.php(1456): gctf_tag_options() #1 /opt/bitnami/wordpress/wp-admin/edit-form-advanced.php(723): do_meta_boxes() #2 /opt/bitnami/wordpress/wp-admin/post.php(206): require(‘…’) #3 {main} thrown in /bitnami/wordpress/wp-content/plugins/custom-text-formats/custom-text-formats.php on line 205. There has been a critical error on this website. Please check your site admin email inbox for instructions.”
Potential fix
I checked the code and this is the code block causing the issue:
$customicons = ”;
if(is_array($uploadfiles) && count($uploadfiles) >2) {
foreach($uploadfiles as $file) {
if($file != “.” && $file != “..”) {
$customicons[] = $file;
Changing the variable declaration from a string to an array fixes the issue:
$customicons = [];
The icons now have an entry in the dropdown list, although the icon image itself is not displayed, possibly caused by another bug. In the Gutenberg editor the icons are displayed, hooray!
Environment
Thanks for the great plugin!
]]>