-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmdwp-docs.php
More file actions
81 lines (72 loc) · 2.07 KB
/
Copy pathmdwp-docs.php
File metadata and controls
81 lines (72 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
/**
*
* @wordpress-plugin
* Plugin Name: Markdown WordPress Docs
* Plugin URI: https://github.com/gnowland/markdown-wordpress-docs
* Description: Generate WordPress website documentation from Markdown Fieles
* Version: 1.0.0
* Author: Gifford Nowland
* Author URI: https://hi@giffordnowland.com
* License: GPLv2.0+
*
* @since 1.0.0
* @package Markdown_WordPress_Docs
*
*/
// Prevent direct execution
if (!defined('WPINC')) {
die;
};
class Markdown_WordPress_Docs {
// Static property to hold our singleton instance
static $instance = false;
/**
* This is our constructor
*
* @return void
*/
private function __construct() {
add_action( 'admin_menu', [ $this, 'add_admin_menu' ] );
add_action( 'admin_enqueue_scripts', [ $this, 'admin_scripts' ] );
}
/**
* If an instance exists, this returns it. If not, it creates one and retuns it.
*
* @return Markdown_WordPress_Docs
*/
public static function init() {
if ( !self::$instance )
self::$instance = new self;
return self::$instance;
}
/**
* Admin styles
*
* @return void
*/
public function admin_scripts() {
$screen = get_current_screen();
if ( !empty($screen) && $screen->id === 'dashboard_page_docs' ) {
wp_enqueue_style( 'mdwp-docs', plugins_url('mdwp-docs.css', __FILE__), [], '1.0.0', 'all' );
wp_enqueue_script( 'mdwp-docs', plugins_url('mdwp-docs.js', __FILE__), [], '1.0.0', true );
}
}
/**
* Register the administration menu for this plugin into the WordPress Dashboard menu.
*
* @since 1.0.0
*/
public function add_admin_menu() {
/* Add settings page */
add_dashboard_page( 'Seabird Tracking Database Documentation', 'Site Help', 'manage_options', 'mdwp-docs', [ $this, 'display_docs' ] );
}
public function display_docs() {
require __DIR__ . '/vendor/autoload.php';
include_once( 'mdwp-docs-display.php' );
}
}
if ( is_admin() ) {
// Instantiate our class
$Markdown_WordPress_Docs = Markdown_WordPress_Docs::init();
}