Skip to content

Instantly share code, notes, and snippets.

@davidjenner
Last active August 21, 2023 19:36
Show Gist options
  • Save davidjenner/70edc5996297923ca1369a877920a85e to your computer and use it in GitHub Desktop.
Save davidjenner/70edc5996297923ca1369a877920a85e to your computer and use it in GitHub Desktop.
Plugin Reusable Code - Maintenance Page
// Header
// Codex - https://developer.wordpress.org/plugins/plugin-basics/header-requirements/
/**
* Plugin Name
*
* @package PluginPackage
* @author David Jenner
* @copyright David Jenner
* @license GPL-2.0-or-later
*
* @wordpress-plugin
* Plugin Name: Maintenance or Coming Soon Page
* Plugin URI: https://example.com/plugin-name
* Description: A maintenance plugin
* Version: 1.0.0
* Requires at least: 5.2
* Requires PHP: 7.2
* Author: David Jenner
* Author URI: https://example.com
* Text Domain: maintenance-page
* License: GPL v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Update URI: https://example.com/my-plugin/
*/
// Adding the Styling
// links to maintenence-page-styles
// Enqueue styles for the frontend
function enqueue_maintenance_page_styles() {
wp_enqueue_style('admin-plugin-styles', plugin_dir_url(__FILE__) . 'admin-plugin-styles.css', array(), '1.0.0', 'all');
wp_enqueue_style('maintenance-page-styles', plugin_dir_url(__FILE__) . 'maintenance-page.css', array(), '1.0.0', 'all');
}
add_action('wp_enqueue_scripts', 'enqueue_maintenance_page_styles');
// Add a settings page to the admin menu
function add_maintenance_settings_page() {
add_menu_page(
'Maintenance Page Settings',
'Maintenance Page',
'manage_options',
'maintenance-settings',
'maintenance_settings_page',
'dashicons-admin-generic',
20
);
}
add_action('admin_menu', 'add_maintenance_settings_page');
// Display the settings page
function maintenance_settings_page()
// code
// Hook to display maintenance page
function display_maintenance_page()
// code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment