If you want to prevent deleting a single or a list of category IDs within the admin, you can prevent so by blocking all requests that delete the category.
There is no hook in wordpress you can make use of to use easily, but there’s always a work-around. In my example I use the check_admin_referer
and check_ajax_referer
hooks (note the typo in the hook name) combined with a check if the request is actually one to delete a category (delete something within the category
taxnonomy).
Example Must-Use Plugin: WordPress Block Category Deletion Example
On deletion of a blocked category, you will get either a You do not have permission to do that. message (Ajax) or a This category is blocked for deletion. message and you need to go back with your browser.
Related Posts:
- What’s the difference between term_id and term_taxonomy_id
- Inserting Taxonomy Terms During a Plugin Activation?
- Rewrite Point Doesn’t Work on Custom Taxonomy
- If a function requires add_action(‘init’) how can I run it only once on plugin activation?
- Custom plugin: Loop through taxonomy types and update columns for all types?
- Insert terms for custom taxonomy on plugin activation, or each page load (init hook)
- Custom Taxonomy to dropdown box on adminside wordpress
- $_FILES empty on created_{taxonomy} and create_{taxonomy} yet is is not on edit_{taxonomy}
- Why is the WordPress taxonomy not registering?
- Translate slug in WPMU with PO files
- How to Get Current Custom Post Type Associated Taxonomy Term
- How to remove plugin-specific custom taxonomy terms when plugin is uninstalled?
- term_exists() returning NULL on term that exists
- Taxonomies within plugin invalid
- Let plugin check if taxonomy is already registered by another plugin
- Non editable custom taxonomy
- modify show UI of a registered taxonomy
- How to create taxonomy without using register_taxonomy () function
- Add location tag to wordpress posts
- Using init hook for register_taxonomy is causing invalid_taxonomy in wp_insert_term()
- Add default custom taxonomy to plugin activation
- Javascript not being loaded only in custom taxonomy template
- set a custom post type to a taxonomy term programmatically in metabox
- Making Woocommerce optimized for more than 500k products
- add_action priority and taxonomy used in plugin
- edit-tags.php in plugin admin menu hides when is the active page
- How to display custom taxonomy and terms using/creating plugin template
- How to show custom taxonomy child posts through shortcode in WordPress
- If I want to create new taxonomies (e.g. Project / Documents / Etc…) is it better to create them in the theme’s functions.php or within a plugin? [duplicate]
- Is the only way to add taxonomy terms via an admin panel?
- WordPress Breadcrumb Taxonomy Display
- How to boost WP custom post REST API GET queries by custom taxonomies
- Injecting HTML on (arbitrary) admin pages
- Custom Stylesheet instead of Inline CSS for WordPress Customizer API Overrides
- my own SVN for a plugin/theme
- Issue on Checkbox with Custom Option Page
- Issue on Setting $icon_url Parameter on WP add_menu_page()
- How to enqueue scripts in right way in a plugin?
- Add information to HTTP Header in WordPress Plugin
- Are there any official or unofficial guidelines for the styling of a widget?
- How to get error object returned by wp_create_user
- change add to cart button link [closed]
- Plugin AJAX Save to Custom Table
- Why enqueue styles on hook?
- How do I change the image from the default mysteryman in the WP Profile page
- Wp-admin Custom User Management
- Dynamically generate meta tags and titles for a wordpress page
- Fatal error: Cannot redeclare admin_notice() [closed]
- Error: Call to a member function get_error_code() on a non-object
- Update wordpress Core Remotely
- How to Add a Custom Size for Thumbnails for WP – Gallery
- Check user’s role and store in variable
- Custom avatars in wordpress comments?
- What’s the hook for filtering every texts of site?
- Make Database query only when option is updated
- Admin Subpages without Menu entry
- Create Widget or Enable Shortcodes in Sidebar
- The Correct Way to Use Nonce Field without Settings API
- Special Formatting for WordPress Plugin Description?
- I am trying to make a page in the admin section similar to the appearance of the Profile page for users
- why do I have to use required parametres?
- Getting a WordPress Debug Strategy
- Default taxonomy template in plugin, override in theme
- Include file in plugin file
- Proper way to include stylesheet for panels
- post_title is empty on global $post object
- Inserted double quote when prepending to the_content
- unable to wp_enqueue_script(‘suggest’);
- Plugin development – loading Javascript and Flash
- Meta box on options page save form problem
- Quasi-custom API Call Plugin
- Drawing the line between theme & plugin on large scale bespoke projects
- making a plugin that moves other plugins wp_head actions to wp_footer
- Using add_sub_menu to put into Appearance Section
- WordPress multisite,use same cookies across all website?
- How can I show posts for a single category?
- How to check via conditional tags for a single plugin page?
- my basic php code producing unexpected results
- HowTo to add my rewrite rules at the beginning, redirect to the right page and flush the rules on plugin activation?
- Apply styles to blockquote element with the WYSIWYG editor
- Check if post belongs to any category
- Mixing l18n string from my plugin with WordPress’ translations
- How to add search form in main page body?
- Can I use %category% like Templates in my Plugin?
- How to add custom options for plugin into the add post screen – like yoast seo
- WordPress – manually relate a post to page(s)?
- Menu page with minimum capability as ‘Subscriber’ doesn’t allow ‘Admin’ to access it?
- What’s wrong with my usage of add_filter
- Minimum Widget Width for Plugin Development
- Moving/dragging a metabox removes TinyMCE’s content
- Activate theme via plugin script?
- get author of published post
- How can I develop a plugin that generates a page dynamically
- How can I add function calls to my plugin’s options.php default submit routine?
- Error passing post_content to function
- Remove Default Blogroll Links via Plugin script
- Encoding Method for URLs?
- Store custom meta box data as serialized array
- Catching Gutenberg sidebar switch event
- How To Update WordPress Custom Plugin For Customer? [closed]