You can do this by creating a post form with a nonce field…
$url = admin_url('admin-ajax.php');
echo '<form action="'.$url.'" method='post'>';
echo '<input type="hidden" name="action" value="delete_theme">';
wp_nonce_field('updates'); // to pass check_admin_referer
echo '<input type="hidden" name="slug" value="twentythirteen">';
echo '<input type="submit" value="Delete TwentyThirteen Theme">';
echo '</form>';
You can replace the hard-coded slug
input field with a <select>
one and loop through installed themes to add them as the select options if you like, but I’ve given it this way because you say you want to delete a theme.
Related Posts:
- Disable email notification after change of password
- __(): What if I have to pass in a variable?
- Run WP-CLI using PHP
- category_name not working (not showing up in sql query debug)
- How can I make my custom shortcode work in a Custom HTML Widget?
- PHP Deprecated: Non-static method should not be called statically
- Update Multiple Post Meta for the Same Post In One call?
- WordPress Hook that will run when media file deleted
- Post source link plugin – small modification
- Which hook callback has priority if both plugin and theme use the same hook?
- Calling function from within functions.php returns unwanted value
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- Check if a class exists within a method
- How can I make the “Preview Post” button save and preview in the same window?
- Escape special characters in image link
- Cannot run the code after I activate the plugin
- Displaying admin notice dynamically
- Get total number of comment of the posts written by an author
- force customers to add only single item to card per purchase EDD [closed]
- Write to / remove from default .htaccess file from plugin?
- printf – problem to understand code
- Auto delete WordPress users according to time
- How to cancel WordPress’ action/filter when using OOP with anonymous callback
- add_query_arg not working
- Programatically download a plugin
- Error shown for Trying to get property ‘roles’ of non-object in WordPress After Content for User Roles
- How to Use Parameters with a Do_Action Function Within PHP Tags
- Theme my Login plugin, how to update fields
- CSS from textarea in options page to frontend what to do
- How do I pass a post ID to the page URL?
- New to wordpress, Question about editing PHP
- wp_set_auth_cookie causes 403 error in the wooCommerce checkout
- add image crop function like in wp customizer
- Calculate price and display on woocommerce product single page under price (simple price, variable price) [closed]
- Bootstrap and Custom CSS in custom plugin are being overwritten by theme
- Self-serve ad system like Reddit’s for WordPress? [closed]
- Create a plugin from within WordPress
- WordPress call_user_func_array() expects parameter 1 to be a valid callback, class
- Call plugin with php function
- Why is my custom post type not being activated on plug-in activation?
- What happens when WordPress memory limit is exceeded?
- iframe not showing in post (with “allow php in posts” plugin activated)
- how can I do something on new user registration?
- Any idea how to get something like this to work? [closed]
- wp_dequeue_script for a Plugin
- How do I add $_SESSION[”] to my wordpress page?
- Built a second plugin but it overwrote the first one
- WordPress: Add custom add_filter for custom functions
- How can i add simple code in only in posts by function.php
- Hide DIV if empty – Plugin Gallery
- speed up pagination for huge database
- File Uploader – Upload without adding to Media Library
- Building a plugin into a theme
- 2 wordpress site same database
- How to redirect to a page after the form is submitted
- Trying to include files in plugin isn’t working
- WP Insert Post If user refreshes override new post
- How to makes changes on the shop/category/tag pages but not on the product pages in woocommerce?
- implement custom roles in custom plugin
- How to get current cart values using WC_Shortcodes?
- How to authorize viewing and clicking a function only logged users?
- Cant create table on plugin activation
- How to arrange custom posts in the backend/admin by custom taxonomy
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- Why is my shortcode not working?
- Getting Fatal error: Uncaught Error: Call to undefined function plugin_dir_path() when linking to another file within my wordpress plugin
- the content of the uploads folder gets deleted periodically, how to figure out what causes it?
- front end editor creation for Restropress plug in – displaying information from a WP admin area, on a different URL
- implement checkbox or toggle switch in plugin code
- Custom Field used to allow a Free Story; no longer works
- How to send new visitor to a splash page for only one time in wordpress?
- Cron job shedules replace?
- Create a form and have custom menu display based on user answers?
- Can i add custom code in Source in specific page, Header from function.php?
- Problem with conditional woocommerce custom checkout field
- GET web api method from a WordPress PHP script
- Adding link on title its in description but not in title see screenshots attached
- Editing Global Variables from Inside Functions
- How to save information related to post in database?
- Save selectlist value (taxonomy) in wp:wp_set_object_terms
- Page doesn’t load
- Posting code inside the post instead of in the template file using shortcode
- Metabox Data not saving
- Can anyone tell me why I can’t edit a plugin when it is installed without having to re-install?
- conditional tags for the output of a plugin
- Xml output not places where i want
- Including a PHP file via a function that is part of a plugin?
- How to fix ‘Call to undefined function do_settings()’ error?
- How to tweak a plugin without preventing it from updating
- Place max_execution_time in plugin [closed]
- Integrate Razorpay quick payments plugin with contact form7 plugin
- Passing an input variable through a switch statement
- Function not being called on form submit, only blank admin-post.php page
- cURL External API request displays content above other content on page
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- WordPress Convert queries to slashes using function.php
- Creating a Table Row by Row
- Getting 504 Gateway Timeout Error on AWS Server! [closed]
- WordPress issue – data is not showing in wp-admin, but when searching through database, all the data is there
- WordPress Throwing Deprecated Errors on its own Files