Powered By Blogger

Friday, December 30, 2016

add input field in wp admin and Global Options Page and custom form in wp admin

http://stackoverflow.com/questions/11715465/how-do-i-create-a-universal-custom-field-in-wordpress

/** EGR Magnificent config in wp-admin */
add_action( 'admin_menu', 'my_plugin_menu' );

function my_plugin_menu() {
add_options_page( 'Magnificent', 'Magnificent API', 'manage_options', 'magnificent-config', 'EGR_magnificent_options' );
}

function EGR_magnificent_options() {
if ( !current_user_can( 'manage_options' ) )  {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
echo '<div class="wrap">';
echo '<p>EGR Magnificent API configuration.</p><form method="post" action="options.php">';
             wp_nonce_field('update-options');
    echo '   <p><strong>JWT token secret key:</strong><br />
                <input type="text" name="jwtsecret" size="45" value="'; echo get_option('jwtsecret');
                echo '" />
                <br /><strong>JWT token expiry time (in minutes):</strong><br />
                <input type="number" name="jwtexpire" size="45" value="'; echo get_option('jwtexpire');
                echo '" />
            </p>
            <p><input type="submit" name="Submit" value="Store Options" /></p>
            <input type="hidden" name="action" value="update" />
            <input type="hidden" name="page_options" value="jwtsecret, jwtexpire" />
        </form>';
echo '</div>';
}

No comments:

Post a Comment