-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathknowledge-base-cpt.php
89 lines (66 loc) · 1.98 KB
/
knowledge-base-cpt.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
<?php
/**
* Knowledge Base CPT
*
* Plugin Name: Knowledge Base CPT
* Plugin URI: https://wordpress.org/plugins/knowledge-base-cpt/
* Description: Enables a knowledge base post type and section taxonomy.
* Version: 1.0.9
* Author: Danny Cooper
* Author URI: http://olympusthemes.com/
* Text Domain: ot-knowledge
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Domain Path: /languages
*
* @package knowledge-base-cpt
*/
/**
* Main Olympus_Knowledge Class
*/
class Olympus_Knowledge {
/**
* Initialize plugin.
*/
public function __construct() {
$this->includes();
add_action( 'init', array( $this, 'ot_check_version' ) );
add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
}
/**
* Load plugin files.
*/
public function includes() {
// Required files for registering the post type, taxonomies. settings and widget.
require plugin_dir_path( __FILE__ ) . 'includes/register-cpt.php';
require plugin_dir_path( __FILE__ ) . 'includes/register-taxonomy.php';
require plugin_dir_path( __FILE__ ) . 'includes/register-settings.php';
require plugin_dir_path( __FILE__ ) . 'includes/register-recent-widget.php';
}
/**
* Load plugin textdomain.
*/
public function load_textdomain() {
load_plugin_textdomain( 'ot-knowledge', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
/**
* Flush rewrites.
*/
public static function flush_rewrites() {
ot_knowledge_cpt();
ot_knowledge_section();
flush_rewrite_rules();
}
/**
* Check if rewrite rules need to be flushed after update as updates don't trigger register_activation_hook().
*/
public function ot_check_version() {
$db_version = get_option( 'ot_knowledge_version' );
if ( $db_version < 104 ) {
$this->flush_rewrites();
}
update_option( 'ot_knowledge_version', 109 );
}
}
$olympus_knowledge = new Olympus_Knowledge();
register_activation_hook( __FILE__, array( 'Olympus_Knowledge', 'flush_rewrites' ) );