I have a simple custom plugin to show a maintenance screen to non admin users. I want to integrate some options to it like a countdown and a selectable background image or color and a custom logo. I don't know how to proceed, can anyone guide me please? Here is the actual code:

class Maintenance {

  public function init()
    add_action( 'wp_loaded', array($this, 'maintenanceMode') );

  public function maintenanceMode()
    global $pagenow;
    if( $pagenow !== 'wp-login.php' && !current_user_can('manage_options') && !is_admin() ){
      header( $_SERVER['SERVER_PROTOCOL'] . '503 Service Temporarily Unavailable', true, 503 );
      header( 'Content-Type: text/html; charset=utf-8' );
      require_once plugins_dir_path(__FILE__).'assets/maintenance.php';


and this is the html

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="profile" href="http://gmpg.org/xfn/11">

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
    <link rel="stylesheet" href="<?php echo plugins_url('assets/css/maintenance.css', dirname( __FILE__ )); ?>">

    <title>Maintenance mode | <?php bloginfo('name'); ?></title>

  <div class="jumbotron jumbotron-fluid maintenance-screen">
    <div class="container">
      <div class="row">
        <div class="col-sm-12 col-md-12 col-lg-12 text-center">
          <!-- custom logo here -->
          <!-- countdown here -->

I don't have experience with the Setting API or Options API, so I need a simple way to integrate these options. I was thinking to use a shortcode but will it work?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.