Tuesday, October 30, 2018

Wordpress create custom fields into Settings -> General

<?php
add_filter('admin_init', 'notification_start_date');
function notification_start_date() {
    register_setting('general', 'notification_start_date', 'esc_attr');
    add_settings_field('notification_start_date', '<label for="notification_start_date">' . __('Notification start date', 'notification_start_date') . '</label>', 'notification_start_date_html', 'general');
}
function notification_start_date_html() {
    $value = get_option('notification_start_date', '');
    echo '<input type="date" id="notification_start_date" name="notification_start_date" value="' . $value . '" />';
}




add_filter('admin_init', 'notification_end_date');
function notification_end_date() {
    register_setting('general', 'notification_end_date', 'esc_attr');
    add_settings_field('notification_end_date', '<label for="notification_end_date">' . __('Notification start date', 'notification_end_date') . '</label>', 'notification_end_date_html', 'general');
}
function notification_end_date_html() {
    $value = get_option('notification_end_date', '');
    echo '<input type="date" id="notification_end_date" name="notification_end_date" value="' . $value . '" />';
}



add_filter('admin_init', 'notification');
function notification() {
    register_setting('general', 'notification', 'esc_attr');
    add_settings_field('notification', '<label for="notification">' . __('Notification start date', 'notification') . '</label>', 'notification_html', 'general');
}
function notification_html() {
    $value = get_option('notification', '');
    echo '<input type="date" id="notification" name="notification" value="' . $value . '" />';
}
?>

No comments:

Post a Comment

Please mention your comments.......