-
Notifications
You must be signed in to change notification settings - Fork 1
/
doc.php
184 lines (168 loc) · 7.71 KB
/
doc.php
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php
/**
* Plugin Name: WP Documenter
* Plugin URI:
* Description: Documentation is now easy way
* Author: asaquzzaman
* Version: 0.3
* Author URI: http://mishubd.com
* License: GPL2
* TextDomain: doc
*/
/**
* Copyright (c) 2013 asaquzzaman (email: joy.mishu@gmail.com). All rights reserved.
*
* Released under the GPL license
* http://www.opensource.org/licenses/gpl-license.php
*
* This is an add-on for WordPress
* http://wordpress.org/
*
* **********************************************************************
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* **********************************************************************
*/
/**
* Autoload class files on demand
*
* @param string $class requested class name
*/
function doc_autoload( $class ) {
if ( stripos( $class, 'DOC_' ) !== false ) {
$admin = ( stripos( $class, '_Admin_' ) !== false ) ? true : false;
if ( $admin ) {
$class_name = str_replace( array('DOC_Admin_', '_'), array('', '-'), $class );
$filename = dirname( __FILE__ ) . '/admin/' . strtolower( $class_name ) . '.php';
} else {
$class_name = str_replace( array('DOC_', '_'), array('', '-'), $class );
$filename = dirname( __FILE__ ) . '/class/' . strtolower( $class_name ) . '.php';
}
if ( file_exists( $filename ) ) {
require_once $filename;
}
}
}
spl_autoload_register( 'doc_autoload' );
require_once dirname( __FILE__ ) . '/include/' . 'function.php';
class Wp_doc {
function __construct() {
$this->instantiate();
add_action( 'init', array( $this, 'register_post_type' ) );
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'scripts' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'rad_scripts' ) );
}
function rad_scripts() {
wp_enqueue_script( 'jquery' );
wp_enqueue_style( 'doc-read', plugins_url( 'assets/css/read.css', __FILE__ ), false, false, 'all' );
wp_enqueue_script( 'doc-read', plugins_url( 'assets/js/read.js', __FILE__ ), array( 'jquery' ), false, true );
wp_enqueue_script( 'doc-scroll', plugins_url( 'assets/js/animatescroll.js', __FILE__ ), array( 'jquery' ), false, true );
}
function admin_menu() {
$capability = 'read';
$menu = add_menu_page( __( 'Documenter', 'doc' ), __( 'Documenter', 'doc' ), $capability, 'doc-documenter', array($this, 'admin_page_handler'), 'dashicons-exerpt-view' );
}
function scripts() {
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-ui-sortable' );
wp_enqueue_script( 'doc-menu-nested', plugins_url( 'assets/js/jquery.nestable.js', __FILE__ ), array( 'jquery' ), false, true );
wp_enqueue_script( 'doc-scripts', plugins_url( 'assets/js/doc.js', __FILE__ ), array( 'jquery' ), false, true );
wp_localize_script( 'doc-scripts', 'doc', array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
'_wpnonce' => wp_create_nonce( 'doc_nonce' ),
'is_admin' => is_admin() ? true : false,
));
wp_enqueue_style( 'nestable', plugins_url( 'assets/css/nestable.css', __FILE__ ), false, false, 'all' );
wp_enqueue_style( 'font-awesome', plugins_url( 'assets/css/font-awesome.css', __FILE__ ), false, false, 'all' );
wp_enqueue_style( 'doc-style', plugins_url( 'assets/css/doc.css', __FILE__ ), false, false, 'all' );
}
function instantiate() {
DOC_Admin_Admin_doc::getInstance();
DOC_Ajax::getInstance();
DOC_Read::getInstance();
}
function admin_page_handler() {
if ( isset($_GET['page']) && $_GET['page'] == 'doc-support' ) {
require_once dirname (__FILE__) . '/views/support.php';
}
}
function register_post_type() {
register_post_type( 'doc_documenter', array(
'label' => __( 'documenter', 'doc' ),
'description' => __( 'documenter', 'doc' ),
'public' => false,
'show_in_admin_bar' => false,
'exclude_from_search' => true,
'publicly_queryable' => false,
'show_in_admin_bar' => false,
'show_ui' => true,
'show_in_menu' => 'doc-documenter', //false,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array('slug' => 'doc_documenter'),
'query_var' => true,
'supports' => array('title', 'editor'),
'labels' => array(
'name' => __( 'documenter', 'doc' ),
'singular_name' => __( 'documenter', 'doc' ),
'menu_name' => __( 'documenter', 'doc' ),
'add_new' => __( 'Add documenter', 'doc' ),
'add_new_item' => __( 'Add New documenter', 'doc' ),
'edit' => __( 'Edit', 'doc' ),
'edit_item' => __( 'Edit documenter', 'doc' ),
'new_item' => __( 'New documenter', 'doc' ),
'view' => __( 'View documenter', 'doc' ),
'view_item' => __( 'View documenter', 'doc' ),
'search_items' => __( 'Search documenter', 'doc' ),
'not_found' => __( 'No documenter Found', 'doc' ),
'not_found_in_trash' => __( 'No documenter Found in Trash', 'doc' ),
'parent' => __( 'Parent documenter', 'doc' ),
),
));
register_post_type( 'doc_section', array(
'label' => __( 'section', 'doc' ),
'description' => __( 'section', 'doc' ),
'public' => false,
'show_in_admin_bar' => false,
'exclude_from_search' => true,
'publicly_queryable' => false,
'show_in_admin_bar' => false,
'show_ui' => true,
'show_in_menu' => 'doc-section', //false,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array('slug' => 'doc_section'),
'query_var' => true,
'supports' => array('title', 'editor'),
'labels' => array(
'name' => __( 'section', 'doc' ),
'singular_name' => __( 'section', 'doc' ),
'menu_name' => __( 'section', 'doc' ),
'add_new' => __( 'Add section', 'doc' ),
'add_new_item' => __( 'Add New section', 'doc' ),
'edit' => __( 'Edit', 'doc' ),
'edit_item' => __( 'Edit section', 'doc' ),
'new_item' => __( 'New section', 'doc' ),
'view' => __( 'View section', 'doc' ),
'view_item' => __( 'View section', 'doc' ),
'search_items' => __( 'Search section', 'doc' ),
'not_found' => __( 'No section Found', 'doc' ),
'not_found_in_trash' => __( 'No section Found in Trash', 'doc' ),
'parent' => __( 'Parent section', 'doc' ),
),
));
}
}
new Wp_doc();