There is a ‘switch_theme’ action that runs right after the theme is switched.
function my_on_switch_theme($new_theme) {
$current_themes = wp_get_themes(); /* Fixed deprecated function */
$new_theme_info = $current_themes[$new_theme];
/*
$new_theme_info should now be an associative array with the following:
$new_theme_info['Title'];
$new_theme_info['Version'];
$new_theme_info['Parent Theme'];
$new_theme_info['Template Dir'];
$new_theme_info['Stylesheet Dir'];
$new_theme_info['Template'];
$new_theme_info['Stylesheet'];
$new_theme_info['Screenshot'];
$new_theme_info['Description'];
$new_theme_info['Author'];
$new_theme_info['Tags'];
$new_theme_info['Theme Root'];
$new_theme_info['Theme Root URI'];
...so do what you need from this.
*/
}
add_action('switch_theme', 'my_on_switch_theme');
Related Posts:
- Is it ever okay to include inline CSS in plugins?
- Is it mandatory to use $wpdb->prefix in custom tables
- add_action hook for completely new post?
- Is get_option function cached?
- How to include jQuery and JavaScript files correctly?
- How do I log plugin (cron) actions?
- PHPUnit testing WordPress Plugin
- Using OOP plugin’s methods throughout the website
- Why does WordPress create two transients with the same name when I specify timeout value?
- How to Rewrite WordPress URL for a Plugin
- Is it possible to add an admin page using add_submenu_page() and pass a var in the query string?
- Managing two editable fields in gutenberg
- Proper way to use apply_filters() with class functions?
- In a plugin, why is add_action(‘init’) not executed before the plugin is activated?
- Determine which theme location a wp_get_nav_menu_items is for
- Naming Admin Menus and Submenus
- Checking for existence of a page by title?
- How to use wp_set_password in a plugin?
- How to init an addon correctly after the main plugin?
- Endpoint on Specific Page Slug
- How can I free up the memory used by update_post_meta?
- add javascript button to order place button
- How to register activation and deactivation hook in plugin using OOP pattern
- Best practice for creating a custom archive template for a custom taxonomy which works on all themes?
- URL rewriting must be activated manually for my plugin
- Getting Details Of Uploaded Image
- how to activate plugin network-wide, and save setting across sites
- PHP logging framework to be used with WordPress
- What is difference between blog id and site id?
- How to Load Plugin JS in theme’s footer section
- Show dialog box in TinyMCE plugin and use WordPress php functions in it
- PHP 7 – Class Method Compatibility Issue
- Change reset password URL returned by wp_lostpassword_url() via plugin
- wp_transition_post_status does not change the status of the post
- Add notification bubble notice in navigation using transients
- How to print raw query from WP_Query class just like in CodeIgniter
- dbDelta() Error – Incorrect index name ” for query ALTER TABLE
- Custom plugin – $post_id in wp_head
- Is it safe to call do_action and apply_filters for built-in hooks?
- Creating a Link Text like Submit Button in Admin Page
- WooCommerce registration password field not displaying
- wordpress plugin php file processing form
- 403 Error when text is pasted in Custom Metabox Textarea
- Enqueueing stylesheets on particular plugin admin pages using WordPress Plugin Boilerplate
- How To Change Post Author Default?
- Editing options pages?
- is it recommended to use WP_List_Table?
- Multiple Plugin best practice in Multisite
- How to extend WooCommerce API to show bookable product availability rules?
- WordPress allows multiple users to have same email ID; and I’ve a problem with it!
- Enumerating shortcode attributes in JavaScript
- wp-cron and execution of code in is_admin() included script
- use of do_action() without any functions attached
- json_decode does not work on WordPress
- Delist entries in the_loop
- wordpress add_submenu_page adds broken link
- esc_html__() and __() not working within arrays
- WP Enqueue style on all plug-in pages
- Uploaded attachment not set as featured image
- WordPress – manually relate a post to page(s)?
- Styles don’t load correctly. Insecure content
- How to use apiFetch to get author information in Gutenberg properly?
- Gutenberg blocks error: Each child in a list should have a unique “key” prop
- Can we use a library under MIT license in a WooCommerce plugin?
- How to display the specific post content by using POST ID
- Soap web service request from wordpress plugin
- Why does comments_open() return false when publishing a scheduled post?
- How to list all images used on a specific page?
- Create fixed static pages
- Use options to control jQuery plugin
- Including template in shortcodes
- Is there anything special required to make a plugin work in a multisite environment?
- How to exclude categories from get_categories() select list inside a widget admin panel
- How to exclude “uncategorized” from custom categories widget?
- WordPress plugin development theme issue
- Using custom IDP with WP
- Trying to run a Ajax request from a checkout form in woocommerce via a custom plugin
- Securing custom rest API endpoints with public access from PWA
- By adding “?login – failed” code unable to access my dashboard
- Using WordPress Boilerplate (WPBP) for WP Multisite Plugin
- WordPress5.2.3: Better File Download Plugin validation issue
- How do I make secure API calls from my WordPress plugin?
- esc_attr() on hard coded string
- Creating a return url for getting data from external api
- WordPress Plugin Boilerplate – add actions and/or filters based on user’s role
- How to prevent users from deleting their accounts?
- How to use functions from Woocommerce documentation?
- Is it possible to restore an expired transient?
- How to Maintain url on form submit
- Experts opinions needed: How (in)secure is this approach?
- add_option_{$option} action hook not being called
- WP API users per page
- action callback, for action dispatched as reported by hook sniffer, not called
- variable created in page.php is null inside of header.php
- Access WordPress Tag Function From Modal
- Problem with Poedit [closed]
- how can I insert a link on login page
- Insert plugin html content to a specific spot in the frontpage
- Is Explicit Versioning a better alternative to Semantic Versioning for wordpress?
- Programmatically creating posts based on external JSON feed (asynchronously)