You’re looking for this:
register_activation_hook( __FILE__, 'your_plugin_activate_function_name' );
Edit: for a theme, you can use something like this instead:
$theme_version = get_option('my_theme_version');
switch ((string) $theme_version) {
// an early alpha... run upgrade code
case '0.1':
// another version... run upgrade code
case '0.5':
// add other cases as needed... without any break statement.
// if we're here and in the admin area (to avoid race conditions),
// actually save whichever changes we did
if (is_admin()) {
update_option('my_theme_version', '1.0');
// do other stuff
}
// we're at the latest version: bail here.
case '1.0':
break;
default:
// install code goes here
}
Related Posts:
- How to create .pot files with POedit?
- How do I get the theme URL in PHP?
- Why when I submit a form in wordpress it loads a 404 page though URL is correct
- What is the constant WP_USE_THEMES for?
- What is the difference between front-page.php and home.php? [duplicate]
- Any alternate TinyMCE4 themes / subthemes?
- Strict Standards Error bootstrap navwalker
- wp_get_attachment_image_attributes not working for me
- Specify image dimensions
- Adding Action Hooks In Parent Theme For Easier Child Theme Customization
- register_sidebar ignores ‘id’ and ‘class’
- add_editor_style not working
- Add colors to existing color palette without replacing it
- Add link option to featured image?
- How to hide and content from auto-generated excerpts?
- How can I include a post in a theme?
- Custom CSS In Uploads Folder
- Default header image does not display
- How to write .htaccess dynamically? [closed]
- Adding wp_enqueue_media(); causes problem
- A guide or tool for inserting bootstrap in underscores theme? [closed]
- What is the correct way to do a mobile theme for WordPress?
- What is the right way to make custom main page?
- .sub-menu or .children?
- Custom CSS without css.php file
- Why is the post type on the search result page random?
- How to add infinite scroll?
- How can I have a page on a site that isn’t a ‘Page’ in the WordPress sense?
- get_option in header.php not returning value from customizer
- What happens to child theme if I change to new version of parent theme?
- Show notice just below the search form on the themes page
- Save Widget State Between Theme Swaps?
- How do I build a post_thumbnail based archive? [closed]
- Single translation for many locales
- Display theme layouts [closed]
- Is accessing theme and using customizer GPL distribution?
- WordPress 500 Internal server error when activating custom theme [closed]
- How do i place same widgets multiple time by default on theme activation?
- Getting php_network_getaddress error : No such host is known?
- Combining CSS files into a single cached one
- How to set a page as homepage in stead of the newspages?
- WordPress Theme Validator?
- Get the amount of posts on a given page
- Wpautop in wp_editor not working
- Comment status shows ‘closed’ in db, but it shows ‘open’ when i echo it
- I used single quote to design HTML of my WordPress blog. Now site redirects to index.php everytime than page.php or single.php
- Is there any way to register custom background images like header images?
- html5-reset theme does not show the image [closed]
- WordPress HTML5 Gallery Support – Convert HTML4 -> HTML5
- Issue On Displaying Pages with Post Name Permalink
- How to make javascript work on theme options page
- Second menu has the first menu ID
- Contact Form Security
- Where do you add code in custom fuctions so it works on a specific page?
- WordPress: Allowed Memory Size Exhausted – After Moving from Dev to Live [closed]
- What exactly is “wordpress theming”? [closed]
- Present Color Schemes to Clients
- GrandParent ,Parent, Child issue
- Unable to add widgets to sidebars in custom theme
- View list of all attachments on site
- How do I display a greyed out next_post_link when there is no next post
- What is the difference between Twenty eleven & roots framework?
- Dynamically Populating Image/Excerpt/LInks from Pages in WordPress
- If I remove Category base from my URLs, how difficult will rollback be?
- Woocommerce AJAX filters option loading spiner – problem on mobile device
- Is there a list of default generated Gutenberg block CSS? Unable to align video blocks
- How to Modify WP_Includes/blocks/latest_posts.php
- Adding popup support to the theme
- How do I change the color of individual page titles in WordPress?
- Page For Specific Posts
- How toprint informations in footer
- How to implement pagination in category.php template
- How to reduce the vertical space above and below a ul list uniformly with one command?
- How can I show a custom WordPress menu anywhere I want on my website?
- WordPress Menu item > Sub menu Class update
- How can I use a different template file for the blog index’s paginated pages?
- How to know and change the machine name of a menu?
- How to customize the colors within a stylesheet using a WordPress setting
- How does mediaelement.js work in WordPress?
- Images use & location, on new wordpress theme
- On wordpress, how do i require specific dimensions from user uploads only
- how to create export / import theme options in wordpress without plugin
- WordPress Theme Developments – Start from another theme
- Access meta box checked value in another file
- Slider should be display in home template [closed]
- WordPress Customization API overwrite LESS variable
- Dynamic meta description
- How to Remove Sidebar when get_sidebar() is not get called in page?
- How does offset works on pagination? (get_results)
- Plugin or script to apply updated media settings to all featured images
- Header links also appearing in the footer
- Extending arrays in parent theme without completely overriding the files
- WordPress Subpages Fancybox Trouble
- Toolbox theme using printif statement – help needed understanding code block
- Search Results not displaying for multiple word search
- How to Create a Multi Purpose Theme?
- WordPress does not know the parametrs i sent to admin post
- Custom Single Page Portfolio Theme [closed]
- Not Able to Access Terms Under Custom Taxonomy Archive
- WordPress search field won’t get wider