Create form or link with action=”my_media_update”
<form action="<?php echo admin_url('admin-post.php'); ?>" method="post">
<input type="hidden" name="action" value="my_media_update">
<input type="submit" value="Update Media Titles and ALT Text">
</form>
Add this function and hook in your plugin file:
public function kh_update_media_seo() {
//update media files title and alt tags here
//
// at the end redirect to target page
}
add_action( 'admin_post_my_media_update', 'kh_update_media_seo' );
When form will be sent and field “action” will have value “my_media_update”, then your function will be executed.
WordPress Codex
Related Posts:
- WordPress plugin how to run function when button is clicked
- WordPress permalink setting
- How to include PHP files in plugins the correct way
- How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?
- Why does WordPress add 0 (zero) to an Ajax response?
- Passing arguments to a admin menu page callback?
- function deactivate_plugins does not exist
- What is an alternative method to the WordPress private _doing_it_wrong() function
- Understanding WordPress functions’ naming conventions
- Using OOP plugin’s methods throughout the website
- permalinks with get variables
- function triggered by “manage_users_custom_column” filter not working
- How can I change the frequency of a scheduled event?
- When is it appropriate to put functions on page template vs. functions.php?
- Shortcodes, output buffering, and WordPress functions
- How can i list current author’s categories?
- Determine which theme location a wp_get_nav_menu_items is for
- When to check if a function exists
- Checking for existence of a page by title?
- Use an empty page to build custom plugin output
- Dynamically Override Fancy Title
- Problems with removing admin bar
- Problem with `wp_mail()`
- Calling a function from functions.php in custom page/ blog post
- Add Post and Comments menu no longer visible
- Check if I am in the Admin Panel (wp-admin)?
- What is the Difference between directly call a function and call a function using add_action?
- Call to undefined function get_blog_option()
- What is the difference between current_page_parent and current_page_ancestor?
- Plugin development: is adding empty index.php files necessary?
- Undefined function wp_set_password
- Creating a path in a plugin to call a function
- Does add_filter work outside functions.php
- What function to hook for changes made in status and visibility of a post
- URL rewriting must be activated manually for my plugin
- how to use preg_replace for wordpress video?
- Plugin Uninstall and Deactivate via Options Menu
- 404 errors after plugin options update and category base change
- How can I add a CSS rule to edit.php?
- wp_enqueue_script + wp_enqueue_style Since When
- Why doesn’t flush_rewrite_rules run on plugin activation?
- Widget update function not saving values
- add more custom post types and custom role to the code
- $content variable – Is this a reserved variable for a WordPress function? – php / wordpress
- How to use WP_Term with (menu) argument in the wp_nav_menu?
- WordPress after content Hook & external template part
- Enqueue scripts in footer
- override pluggable.php functions
- Retrieve contents/page names of various pages for use in a plugin
- Can wp_list_comments output into variable?
- is user logged in not working
- Can I change header.php of current theme through a plugin function?
- get_current_screen() return null
- Override class inside $atts shortcode_atts in WordPress
- Auto save permalink setting page with the plugin activation
- creating custom function to log actions in plugin
- add_rewrite_rule works in themes function php but when moved into plugin it stops working
- Maximum lifetime for nonce
- Where can i find wordpress auto update code flows?
- Adding option to Gallery shortcode
- correct way to call javascript into hook function
- Help With Rewrite_Rules For a Custom Plug-In
- Append varible to url or set session
- How to change the hover content of a specific menu item on WordPress?
- How can I turn a custom wordpress page into a product page?
- rewrite URL based on selected taxonomy for post page
- how to search users by ajax live search
- Why would one specify multiple arguments when using get_previous_posts_link() which takes only one parameter?
- I cant add is_admin control to plugin
- WordPress Ajax not returning Response
- Does hooking into a plugin action / filter override the plugin’s function for that hook?
- Get the current post/page URL with plain permalinks
- Adding body class in author page for custom role
- Author Meta in Author URL Link
- Remove tag from all posts when publishing new post
- wp_ajax add_action fuction won’t fire on custom jQuery action
- Add function to Dokan ajax class
- foreach argument to get specific file types getting too many returns
- Remove from a div by class name from post page if post author role is not administrator
- Function not working on any file other than the main plugin file
- Building WordPress Themes With Bootstrap with Adi Purdila → TutsPlus
- Get (eventual) permalink from post within Edit Post in Admin panel
- Ajax not working to insert, query and result data
- Template file structure , wordpress hook for altering the template
- How can I see a varibles value when my plugin runs?
- How can I add recent posts to menu like mashable
- Why is ‘register_activation_hook’ undefined?
- Dynamic banner for use on external sites
- How can i call from custom fields to the category editor?
- Get URL of Post You Are Editing
- How to use permalink query to go to specific tabs in posts
- Custom options page for themes
- Why does this fail: Disabling plugins enqueue_script() in functions.php
- Call do_action() within WordPress cronjob
- How to plugin function code move to theme function.php ? I’ve tried below code but not working [closed]
- WordPress simple ‘Hello World’ plugin – problems
- get_term_by() returning null on plugin
- Custom rewrite, url path with parameters to a page
- Sticky bar with filter button and product count
- WordPress – Custom permalinks for advanced custom fields (ACF) using post type taxonomy