Last active
September 13, 2019 19:07
-
-
Save hmbashar/bb4f48360b4a86424f7c97931e911d2b to your computer and use it in GitHub Desktop.
Set theme activition date and time into wp get_otpion database.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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