Action - Admin Defaults
This fired on the admin panel being loaded. It can be used to ensure that any necessary settings or theme options are added or instantiated in the database.
Example:
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
// Declare plugin option name | |
define( 'FEED_URLS_OPTION', 'RSS Feed URLs' ); | |
// Ensure plugin option exists in the DB | |
add_action( 'admin_set_defaults', function() { | |
$option_exists = does_row_exist( 'theme_options', 'name', FEED_URLS_OPTION ); | |
if( !$option_exists ) { | |
add_theme_option( FEED_URLS_OPTION, '' ); | |
} | |
}); |