Skip to content

Instantly share code, notes, and snippets.

@hmbashar
Last active September 13, 2019 19:07
Show Gist options
  • Save hmbashar/bb4f48360b4a86424f7c97931e911d2b to your computer and use it in GitHub Desktop.
Save hmbashar/bb4f48360b4a86424f7c97931e911d2b to your computer and use it in GitHub Desktop.
Set theme activition date and time into wp get_otpion database.
<?php
add_action('after_setup_theme', 'mytheme_init');
function mytheme_init() {
// Check if already saved the activation date & time
// to prevent over-writing if user deactive & active theme
// multiple time
if(!get_option('mytheme_activation_time', false)){
// Generate Current Date & Time in MySQL Date Time Formate
$activation_datetime = current_time( 'mysql' );
// Save it in `wp_options` table
add_option('mytheme_activation_time', $activation_datetime);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment