Is there a way to tell WordPress not to list certain files of my plugin in the Plugins -> Editor screen?
1
-
I'm not exactly sure what the plugin editor is. I have an Appearance -> Editor, but no Plugins -> Editor. – Howdy_McGee♦ Mar 21 '14 at 16:45
-
There is a Plugins -> Editor on 3.9-alpha, at least. I can't check other recent releases right now. – s_ha_dum Mar 21 '14 at 17:04
-
I think it's been there for a very long time I always use it to fix certain problems in PHP for customers when I don't have FTP access just wp-admin. But it shows files that shouldn't be edited, ever - it's just clutter to list there. Appearance -> Editor is the theme editor by the way. – Firsh - LetsWP.io Mar 22 '14 at 19:06
0
Ok I figured it out, there is just one filter hook in the wp-admin/plugin-editor.php
that can be useful but it's enough (otherwise one would probably need to mess with the output buffer).
if(is_admin()){
add_filter('editable_extensions', array($this, 'my_editable_extensions'));
}
and then
function my_editable_extensions($editable_extensions){
if(empty($_POST['plugin']) || (!empty($_POST['plugin']) && $_POST['plugin'] !== "plugin-name/plugin-name.php"){
return $editable_extensions;
}else{
return array_diff($editable_extensions, array('txt', 'html'));
}
}
Note: wp_reset_vars()
is called so the only way to know which plugin's files are being edited is from the $_POST
.