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
.
Related Posts:
- Editor access to plugin settings
- Created Widget Not Showing up on Admin Panel
- Can I use a form in a dashboard widget?
- Determine Registered Admin Menus
- I changed font of wordpress dashboard but it is slow!
- Use localized plugin name and description even when the plugin is disabled
- How to access a wordpress plugin page or add posts without doing it from the WordPress dashboard?
- Display Any Field fromAdmin Panel in Frontend via Shortcode?
- Redesigning Custom Post Type “Add New” page
- Notify Admins about Plugin Merge
- Is there any record of installed plugins in the database?
- Why does including a file in theme’s functions.php not work?
- WooCommerce – Call to undefined function is_woocommerce()
- Custom headers for the WordPress plugin directory
- OEmbed from Pinterest
- How can I add a custom header to a custom template in a plugin without using the theme folders
- Trying to avoid including wp-load.php
- AJAX Call Via Vanilla JavaScript In WordPress Plugin Development
- Custom values are not translated
- Make the plugin directory recognize new version numbers
- Add Top-Level Menu that opens URL
- Change the name of an installed plugin
- Issue with post request to admin-post.php
- Sanitizing, Validating and Escaping in WordPress (Plugin)
- How to make first_name and last_name required fields in user profile?
- like to keep reading plugin
- Check if email address exists front end with AJAX in a plugin
- Avoiding Duplicate function names in Post Loop (WP_Footer script)
- Global matrix for shortcodes/content for every page
- How to add class in plugin only for network site?
- Plugin Development sqlite or WordPress’ database
- How to write a plugin to add users to a mail list
- WordPress plugin for activating other plugins
- Can we use a webservice with WordPress?
- WooCommerce get_price returning wrong price when used via ajax
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- New User Form – Custom Menu Page
- Checking instances of scripts in wp_head
- Fetch Children of Grouped Products Inside WooCommerce Product Loop
- How can I prevent my plugin go development trunk [closed]
- WordPress plugin creation how to execute .sql in order to insert multiple rows at activation of plugin
- Best way to maintain and update 3rd-party WP plugin when developer is unresponsive?
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- how to do login using woocommerce rest api From android
- How to create a code editor for my plugin .?
- How to create a custom shortcode based on the layout?
- Manually set a custom admin sub-menu selected?
- How do I combine a theme with a plugin
- Use wp-config.php constants in all files of plugin
- how to force tag page layout to use same as search layout?
- Prevent direct access to WordPress plugin assets?
- Using ACF default value to autoincrement a number field
- a href adds default URL with the given echo URL
- Gutenberg Block Style CSS Class Is Not Applying on Backend
- How to automatically add edit link on frontpage post of any wordpress theme?
- plugins_url() works everywhere but wp_reqister_script()
- Integrating boxtal PHP library into a custom WordPress Plugin
- Changing menu order of a specific plugin in dashboard
- Images under 1MB are not being compressed
- Sanitize $_GET variable when comparing
- Where can I save plugin data?
- show my own admin_notices after a post has been published
- How to add a WordPress Nonce for this form to avoid CSRF
- Overriding current theme files via plugin
- How to create a plugin that includes all the other plugins?
- How to add update function to plugin without adding it to https://wordpress.org/plugins/ [closed]
- Plugin option default value
- How to edit link for comment count
- Integrating Custom Database with WordPress
- specific rows style for in custom list table using WP_List_Table
- How to add the search page link to the anchor tag?
- Need to know if my approach to designing a geneaology plug-in for wordpress makes sense
- Creating one user access account for all the multiple sites
- Using id to show item
- I am Getting Sorry, no posts matched your criteria on form submit only for certain page [duplicate]
- wpdb update method is updating but not refreshing the current page data
- Shortcode and WP query using category attributes
- Securing a plugin pop-up window
- Dynamic input fields in WordPress Plugin
- Custom role not listed
- Is admin section completely customizable in terms of styling?
- WordPress ajax error 400 bad request for sending data to remote site [duplicate]
- Better way to run heavy scripts using WordPress database
- how to check plugin name unique or not?
- Change default url to plugin custom post type
- Creating a user ‘add custom field’ section
- WordPress ajax not working in registration
- How to show post attachment image
- Can a developer adopt a plugin marked as “not updated in over 2 years”?
- How wordpress plugin hooks works? [duplicate]
- Post curl function save twice using plugin hook function wordpress
- get_option returning a different value from what’s saved
- Plugin: Custom menu item problem
- Getting warning of Missing argument 2 for wpdb::prepare()
- Jquery post responses 500 error after some time and lastly an 503 error
- How to provide page_template path in custom plugin using WordPress
- WordPress custom block: Link saved in database not retrieved when editing post
- Accessing Correct Database to Create REST API Endpoint
- Detect if user is on the specific page in WordPress
- A multi-section WordPress store [closed]