How to add .ini file type to the plugin editor to read and edit?

Referring to /wp-admin/plugin-editor.php

The plugin editor does not include .ini files and I use that file type in a plugin to create dynamic message constants. I want to be able to edit that file via the editor.

I explored wp_doc_link_parse() but to no avail.

How can I add file types to the allowed list?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

This code below should work if you add it to your functions.php in your theme:

add_filter( 'editable_extensions', function ( $default_types ) {
    $default_types[] = 'ini';
    return $default_types;
} );

Assumptions:

  • You’re using at least PHP 5.3
  • You’re using at least WordPress 4.9


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x